bltjs
Version:
A BigchainDB Load Tester
325 lines (320 loc) • 1.22 MB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["bltjs_module"] = factory();
else
root["bltjs_module"] = factory();
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const driver = __importStar(__webpack_require__(1));
const bip39 = __importStar(__webpack_require__(2));
const NodeInfo_1 = __webpack_require__(63);
exports.NodeInfo = NodeInfo_1.NodeInfo;
const ApiInfo_1 = __webpack_require__(64);
exports.ApiInfo = ApiInfo_1.ApiInfo;
const BltAsset_1 = __webpack_require__(65);
exports.BltAsset = BltAsset_1.BltAsset;
const BltMetadata_1 = __webpack_require__(66);
exports.BltMetadata = BltMetadata_1.BltMetadata;
const TestResult_1 = __webpack_require__(67);
exports.TestResult = TestResult_1.TestResult;
const axios_1 = __importDefault(__webpack_require__(68));
/**
* Blt (BigchainDB Load Tester) is the main class which we use to execute functionality in regards to the bigchaindb node/cluster we connected to.
*/
class Blt {
/**
* Initialize a new Blt instance.
*
* @constructor
* @param {string} connection_protocol - The protocol to connect to the node. (e.g. "https")
* @param {string} node_host - The host of the node to connect to. (e.g. "test.bigchaindb.com")
* @param {string} [node_port = ""] - The port of the node.
* @param {string} [api_path = "/api/v1/"] - The path to the API.
* @param {string} [api_id = ""] - The ID of the application.
* @param {string} [api_key = ""] - The Key of the application.
*/
constructor(connection_protocol, node_host, node_port = "", api_path = "/api/v1/", app_id = "", app_key = "") {
this.connection_protocol = connection_protocol;
this.node_host = node_host;
this.node_port = node_port;
this.api_path = api_path;
this.app_id = app_id;
this.app_key = app_key;
this.keySeed = "Blt";
if (connection_protocol == undefined)
throw new Error("Connection protocol is undefined.");
if (node_host == undefined)
throw new Error("Node host is undefined.");
if (this.app_id === "" || this.app_key === "") {
this.connection = new driver.Connection(this.api_url);
}
else {
this.connection = new driver.Connection(this.api_url, {
app_id: this.app_id,
app_key: this.app_key
});
}
}
/**
* Return the keypair that will be used by Blt to sign transactions.
*
* @returns {any} The keypair generated with the Bltjs keySeed.
*/
get bltIdentity() {
return this.generateKeyPair(this.keySeed);
}
/**
* Generate an Ed25519 keypair by using supplied seed.
*
* @param {string} keySeed - The string to be used as seed.
* @returns {any} The generated keypair.
*/
generateKeyPair(keySeed) {
return new driver.Ed25519Keypair(bip39.mnemonicToSeed(keySeed).slice(0, 32));
}
/**
* Get the root url of the node. (e.g. https://test.bigchaindb.com)
*
* @returns {string} The root url of the node.
*/
get root_url() {
return this.connection_protocol + "://" + this.node_host + ":" + this.node_port;
}
/**
* Get the url of the api. (e.g. "https://test.bigchaindb.com/api/v1/")
*
* @returns {string} The api url.
*/
get api_url() {
return this.root_url + this.api_path;
}
/**
* Retrieve the Node information (from the node url and node api url).
*
* @returns {Promise<NodeInfo>} The nodes information encapsulated in a NodeInfo object.
*/
getNodeInformation() {
return new Promise((resolve, reject) => {
axios_1.default.get(this.root_url).then(response => {
let returnedNodeInfo = NodeInfo_1.NodeInfo.copyConstructor(response.data);
resolve(returnedNodeInfo);
}).catch(error => {
reject(new Error(error));
});
});
}
/**
* Send a supplied amount of CREATE transactions to the BigchainDB node.
*
* @param {string} testId - The ID or name of the test.
* @param {number} [amount = 100] - The amount of transactions to be posted to the BigchainDB network.
* @param {any} [onTransactionIssued = () => {}] - A callback function that can be supplied which gets called each time a transaction is issued.
*
* @returns {Promise<TestResult>} A promise that will resolve the TestResult for this test.
*/
testCreateTransactions(testId, amount = 100, onTransactionIssued = () => { }) {
let startTime = new Date();
let transactions = new Array();
let transactionPromises = new Array();
for (let transactionIndex = 0; transactionIndex < amount; transactionIndex++) {
let newTransaction = this.generateCreateTransaction(testId, transactionIndex);
transactions.push(newTransaction);
let transactionPromise = this.connection.postTransactionCommit(newTransaction);
transactionPromises.push(transactionPromise);
transactionPromise.then(response => {
onTransactionIssued(testId, newTransaction, response, transactionIndex);
});
}
return new Promise((resolve, reject) => {
Promise.all(transactionPromises).then(responses => {
let endTime = new Date();
let newTestResult = new TestResult_1.TestResult(testId, transactions, responses, startTime, endTime);
resolve(newTestResult);
}).catch(error => {
reject(error);
});
});
}
/**
* Create a chain of a supplied amount of TRANSFER transactions.
*
* @param {string} testId - The ID or name of the test.
* @param {number} [amount = 100] - The amount of transactions to be issued.
* @param {any} [onTransactionIssued = () => {}] - A callback function that can be supplied which gets called each time a transaction is issued.
*
* @returns {Promise<TestResult>} A promise that will resolve the TestResult for this test.
*/
testTransferTransactions(testId, amount = 100, onTransactionIssued = () => { }) {
let startTime = new Date();
let transactions = new Array();
let responses = new Array();
let transactionIndex = 0;
let newCreateTransaction = this.generateCreateTransaction(testId);
transactions.push(newCreateTransaction);
return this.connection.postTransactionCommit(newCreateTransaction).then(response => {
onTransactionIssued(testId, newCreateTransaction, response, transactionIndex);
responses.push(response);
return this.connection.getTransaction(response.id);
}).then(latestTransaction => {
return this.issueTransferTransactionRecursively(testId, latestTransaction, amount, ++transactionIndex, transactions, responses, startTime, onTransactionIssued);
});
}
/**
* Chain TRANSER transactions recusrively, because loops don't play nice with promises.
*
* @param {string} testId - The name/ID of the test. Will also be used as seed for the keypairs to be used in the test-transactions.
* @param {any} previousTransaction - The transaction that should be transferred.
* @param {number} amound - The amount of times the transaction should be transferred in total.
* @param {number} transactionIndex - The index of this transaction relative to the total amount of transactions that need to be issued in this test.
* @param {Array<any>} transactions - The array where all issued transactions will be stored.
* @param {Array<any>} responses - The array where all the responses will be stored.
* @param {Date} startTime - The timestamp indicating the start of the test.
* @param {any} [onTransactionIssued = () => {}] - A callback function that can be supplied which gets called each time a transaction is issued.
*
* @returns {Promise<TestResult>} A promise that will resolve the TestResult for this test.
*/
issueTransferTransactionRecursively(testId, previousTransaction, amount, transactionIndex, transactions, responses, startTime, onTransactionIssued = () => { }) {
// Check if we've reached the amount of transactions we wanted.
if (transactionIndex === amount) {
return new Promise((resolve, reject) => {
resolve(new TestResult_1.TestResult(testId, transactions, responses, startTime, new Date()));
});
}
let newTransaction = this.generateTransferTransaction(testId, previousTransaction, transactionIndex);
transactions.push(newTransaction);
return this.connection.postTransactionCommit(newTransaction).then(response => {
onTransactionIssued(testId, newTransaction, response, transactionIndex);
responses.push(response);
return this.connection.getTransaction(response.id);
}).then(latestTransaction => {
return this.issueTransferTransactionRecursively(testId, latestTransaction, amount, ++transactionIndex, transactions, responses, startTime, onTransactionIssued);
});
}
/**
* Create a CREATE transaction with a new BltAsset as asset.
*
* @param {string} testId - The name/ID of the test. Will also be used as seed for the keypairs to be used in the test-transactions.
* @param {number} [transferTransactionIndex = 0] - The index of this transaction relative to the total amount of transactions that need to be issued in this test.
*
* @returns {any} The newly created CREATE transaction.
*/
generateCreateTransaction(testId, transactionIndex = 0) {
const newTransaction = driver.Transaction.makeCreateTransaction(new BltAsset_1.BltAsset(testId, transactionIndex), null, [driver.Transaction.makeOutput(driver.Transaction.makeEd25519Condition(this.generateKeyPair(testId).publicKey))
], this.generateKeyPair(testId).publicKey);
return driver.Transaction.signTransaction(newTransaction, this.generateKeyPair(testId).privateKey);
}
/**
* Create a TRANSFER transaction for a certain BltAsset with supplied ID.
*
* @param {string} testId - The name/ID of the test. Will also be used as seed for the keypairs to be used in the test-transactions.
* @param {any} previousTransaction - The transaction that should be transferred on.
* @param {number} [transferTransactionIndex = 0] - The index of this transaction relative to the total amount of transactions that need to be issued in this test.
*
* @returns {any} the newly created TRANSFER transaction.
*/
generateTransferTransaction(testId, previousTransaction, transferTransactionIndex = 0) {
const newTransferTransaction = driver.Transaction.makeTransferTransaction([{ tx: previousTransaction, output_index: 0 }], [driver.Transaction.makeOutput(driver.Transaction.makeEd25519Condition(this.generateKeyPair(testId).publicKey))], new BltMetadata_1.BltMetadata(transferTransactionIndex));
return driver.Transaction.signTransaction(newTransferTransaction, this.generateKeyPair(testId).privateKey);
}
}
exports.Blt = Blt;
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=86)}([function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";(function(e){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
var n=r(81),i=r(80),u=r(79);function a(){return d.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(a()<t)throw new RangeError("Invalid typed array length");return d.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=d.prototype:(null===e&&(e=new d(t)),e.length=t),e}function d(e,t,r){if(!(d.TYPED_ARRAY_SUPPORT||this instanceof d))return new d(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return c(this,e)}return f(this,e,t,r)}function f(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);d.TYPED_ARRAY_SUPPORT?(e=t).__proto__=d.prototype:e=h(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!d.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),i=(e=o(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(d.isBuffer(t)){var r=0|l(t.length);return 0===(e=o(e,r)).length?e:(t.copy(e,0,0,r),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?o(e,0):h(e,t);if("Buffer"===t.type&&u(t.data))return h(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function s(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function c(e,t){if(s(t),e=o(e,t<0?0:0|l(t)),!d.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function h(e,t){var r=t.length<0?0:0|l(t.length);e=o(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function l(e){if(e>=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function p(e,t){if(d.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(n)return z(e).length;t=(""+t).toLowerCase(),n=!0}}function b(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function y(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),r=+r,isNaN(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=d.from(t,n)),d.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,d.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){var u,a=1,o=e.length,d=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;a=2,o/=2,d/=2,r/=2}function f(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var s=-1;for(u=r;u<o;u++)if(f(e,u)===f(t,-1===s?0:u-s)){if(-1===s&&(s=u),u-s+1===d)return s*a}else-1!==s&&(u-=u-s),s=-1}else for(r+d>o&&(r=o-d),u=r;u>=0;u--){for(var c=!0,h=0;h<d;h++)if(f(e,u+h)!==f(t,h)){c=!1;break}if(c)return u}return-1}function g(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var u=t.length;if(u%2!=0)throw new TypeError("Invalid hex string");n>u/2&&(n=u/2);for(var a=0;a<n;++a){var o=parseInt(t.substr(2*a,2),16);if(isNaN(o))return a;e[r+a]=o}return a}function v(e,t,r,n){return q(z(t,e.length-r),e,r,n)}function _(e,t,r,n){return q(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function w(e,t,r,n){return _(e,t,r,n)}function S(e,t,r,n){return q(F(t),e,r,n)}function E(e,t,r,n){return q(function(e,t){for(var r,n,i,u=[],a=0;a<e.length&&!((t-=2)<0);++a)r=e.charCodeAt(a),n=r>>8,i=r%256,u.push(i),u.push(n);return u}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function x(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var u,a,o,d,f=e[i],s=null,c=f>239?4:f>223?3:f>191?2:1;if(i+c<=r)switch(c){case 1:f<128&&(s=f);break;case 2:128==(192&(u=e[i+1]))&&(d=(31&f)<<6|63&u)>127&&(s=d);break;case 3:u=e[i+1],a=e[i+2],128==(192&u)&&128==(192&a)&&(d=(15&f)<<12|(63&u)<<6|63&a)>2047&&(d<55296||d>57343)&&(s=d);break;case 4:u=e[i+1],a=e[i+2],o=e[i+3],128==(192&u)&&128==(192&a)&&128==(192&o)&&(d=(15&f)<<18|(63&u)<<12|(63&a)<<6|63&o)>65535&&d<1114112&&(s=d)}null===s?(s=65533,c=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=c}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=k));return r}(n)}t.Buffer=d,t.SlowBuffer=function(e){+e!=e&&(e=0);return d.alloc(+e)},t.INSPECT_MAX_BYTES=50,d.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=a(),d.poolSize=8192,d._augment=function(e){return e.__proto__=d.prototype,e},d.from=function(e,t,r){return f(null,e,t,r)},d.TYPED_ARRAY_SUPPORT&&(d.prototype.__proto__=Uint8Array.prototype,d.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&d[Symbol.species]===d&&Object.defineProperty(d,Symbol.species,{value:null,configurable:!0})),d.alloc=function(e,t,r){return function(e,t,r,n){return s(t),t<=0?o(e,t):void 0!==r?"string"==typeof n?o(e,t).fill(r,n):o(e,t).fill(r):o(e,t)}(null,e,t,r)},d.allocUnsafe=function(e){return c(null,e)},d.allocUnsafeSlow=function(e){return c(null,e)},d.isBuffer=function(e){return!(null==e||!e._isBuffer)},d.compare=function(e,t){if(!d.isBuffer(e)||!d.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,u=Math.min(r,n);i<u;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},d.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(e,t){if(!u(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return d.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=d.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var a=e[r];if(!d.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(n,i),i+=a.length}return n},d.byteLength=p,d.prototype._isBuffer=!0,d.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)b(this,t,t+1);return this},d.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)b(this,t,t+3),b(this,t+1,t+2);return this},d.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)b(this,t,t+7),b(this,t+1,t+6),b(this,t+2,t+5),b(this,t+3,t+4);return this},d.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?x(this,0,e):function(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.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 T(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},d.prototype.equals=function(e){if(!d.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===d.compare(this,e)},d.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},d.prototype.compare=function(e,t,r,n,i){if(!d.isBuffer(e))throw new TypeError("Argument must be a Buffer");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 u=i-n,a=r-t,o=Math.min(u,a),f=this.slice(n,i),s=e.slice(t,r),c=0;c<o;++c)if(f[c]!==s[c]){u=f[c],a=s[c];break}return u<a?-1:a<u?1:0},d.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},d.prototype.indexOf=function(e,t,r){return y(this,e,t,r,!0)},d.prototype.lastIndexOf=function(e,t,r){return y(this,e,t,r,!1)},d.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=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 u=!1;;)switch(n){case"hex":return g(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(u)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),u=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function M(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function I(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function T(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",u=t;u<r;++u)i+=D(e[u]);return i}function B(e,t,r){for(var n=e.slice(t,r),i="",u=0;u<n.length;u+=2)i+=String.fromCharCode(n[u]+256*n[u+1]);return i}function C(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,n,i,u){if(!d.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<u)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function O(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,u=Math.min(e.length-r,2);i<u;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function R(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,u=Math.min(e.length-r,4);i<u;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function j(e,t,r,n,i,u){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(e,t,r,n,u){return u||j(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function L(e,t,r,n,u){return u||j(e,0,r,8),i.write(e,t,r,n,52,8),r+8}d.prototype.slice=function(e,t){var r,n=this.length;if(e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),d.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=d.prototype;else{var i=t-e;r=new d(i,void 0);for(var u=0;u<i;++u)r[u]=this[u+e]}return r},d.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e],i=1,u=0;++u<t&&(i*=256);)n+=this[e+u]*i;return n},d.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},d.prototype.readUInt8=function(e,t){return t||C(e,1,this.length),this[e]},d.prototype.readUInt16LE=function(e,t){return t||C(e,2,this.length),this[e]|this[e+1]<<8},d.prototype.readUInt16BE=function(e,t){return t||C(e,2,this.length),this[e]<<8|this[e+1]},d.prototype.readUInt32LE=function(e,t){return t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},d.prototype.readUInt32BE=function(e,t){return t||C(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},d.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e],i=1,u=0;++u<t&&(i*=256);)n+=this[e+u]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},d.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=t,i=1,u=this[e+--n];n>0&&(i*=256);)u+=this[e+--n]*i;return u>=(i*=128)&&(u-=Math.pow(2,8*t)),u},d.prototype.readInt8=function(e,t){return t||C(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},d.prototype.readInt16LE=function(e,t){t||C(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},d.prototype.readInt16BE=function(e,t){t||C(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},d.prototype.readInt32LE=function(e,t){return t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},d.prototype.readInt32BE=function(e,t){return t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},d.prototype.readFloatLE=function(e,t){return t||C(e,4,this.length),i.read(this,e,!0,23,4)},d.prototype.readFloatBE=function(e,t){return t||C(e,4,this.length),i.read(this,e,!1,23,4)},d.prototype.readDoubleLE=function(e,t){return t||C(e,8,this.length),i.read(this,e,!0,52,8)},d.prototype.readDoubleBE=function(e,t){return t||C(e,8,this.length),i.read(this,e,!1,52,8)},d.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,u=0;for(this[t]=255&e;++u<r&&(i*=256);)this[t+u]=e/i&255;return t+r},d.prototype.writeUIntBE=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=r-1,u=1;for(this[t+i]=255&e;--i>=0&&(u*=256);)this[t+i]=e/u&255;return t+r},d.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,255,0),d.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},d.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),d.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},d.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},d.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):R(this,e,t,!0),t+4},d.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},d.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 u=0,a=1,o=0;for(this[t]=255&e;++u<r&&(a*=256);)e<0&&0===o&&0!==this[t+u-1]&&(o=1),this[t+u]=(e/a>>0)-o&255;return t+r},d.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 u=r-1,a=1,o=0;for(this[t+u]=255&e;--u>=0&&(a*=256);)e<0&&0===o&&0!==this[t+u+1]&&(o=1),this[t+u]=(e/a>>0)-o&255;return t+r},d.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,127,-128),d.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},d.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},d.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},d.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),d.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):R(this,e,t,!0),t+4},d.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),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},d.prototype.writeFloatLE=function(e,t,r){return U(this,e,t,!0,r)},d.prototype.writeFloatBE=function(e,t,r){return U(this,e,t,!1,r)},d.prototype.writeDoubleLE=function(e,t,r){return L(this,e,t,!0,r)},d.prototype.writeDoubleBE=function(e,t,r){return L(this,e,t,!1,r)},d.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,u=n-r;if(this===e&&r<t&&t<n)for(i=u-1;i>=0;--i)e[i+t]=this[i+r];else if(u<1e3||!d.TYPED_ARRAY_SUPPORT)for(i=0;i<u;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+u),t);return u},d.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),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!d.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var u;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(u=t;u<r;++u)this[u]=e;else{var a=d.isBuffer(e)?e:z(new d(e,n).toString()),o=a.length;for(u=0;u<r-t;++u)this[u+t]=a[u%o]}return this};var N=/[^+\/0-9A-Za-z-_]/g;function D(e){return e<16?"0"+e.toString(16):e.toString(16)}function z(e,t){var r;t=t||1/0;for(var n=e.length,i=null,u=[],a=0;a<n;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&u.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&u.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&u.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&u.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;u.push(r)}else if(r<2048){if((t-=2)<0)break;u.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;u.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;u.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return u}function F(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(0))},function(e,t,r){var n=r(83);e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(e,t,r){var n=r(56),i=r(54);e.exports=function(e){return n(i(e))}},function(e,t,r){e.exports=!r(15)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t){var r=e.exports={version:"2.5.4"};"number"==typeof __e&&(__e=r)},function(e,t){var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(e,t){var r,n,i=e.exports={};function u(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function o(e){if(r===setTimeout)return setTimeout(e,0);if((r===u||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:u}catch(e){r=u}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var d,f=[],s=!1,c=-1;function h(){s&&d&&(s=!1,d.length?f=d.concat(f):c=-1,f.length&&l())}function l(){if(!s){var e=o(h);s=!0;for(var t=f.length;t;){for(d=f,f=[];++c<t;)d&&d[c].run();c=-1,t=f.length}d=null,s=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function b(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];f.push(new p(e,t)),1!==f.length||s||o(l)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=b,i.addListener=b,i.once=b,i.off=b,i.removeListener=b,i.removeAllListeners=b,i.emit=b,i.prependListener=b,i.prependOnceListener=b,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function e(t){var r=void 0;"getConditionUri"in t?r=t.getConditionUri():"serializeUri"in t&&(r=t.serializeUri());var n={details:{},uri:r};0===t.getTypeId()&&(n.details.type_id=0,n.details.bitmask=3,"preimage"in t&&(n.details.preimage=t.preimage.toString(),n.details.type="fulfillment"));if(2===t.getTypeId())return{details:{type:"threshold-sha-256",threshold:t.threshold,subconditions:t.subconditions.map(function(t){var r=e(t.body);return r.details})},uri:r};4===t.getTypeId()&&(n.details.type="ed25519-sha-256","publicKey"in t&&(n.details.public_key=u.default.encode(t.publicKey)));"hash"in t&&(n.details.hash=u.default.encode(t.hash),n.details.max_fulfillment_length=t.maxFulfillmentLength,n.details.type="condition");return n};var n,i=r(2),u=(n=i)&&n.__esModule?n:{default:n}},function(e,t,r){(function(e){var n=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new i(n.call(setTimeout,window,arguments),clearTimeout)},t.setInterval=function(){return new i(n.call(setInterval,window,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(23),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(0))},function(module,exports,__webpack_require__){(function(setImmediate,clearImmediate){module.exports=function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=84)}([function(e,t,r){"use strict";(function(e){function n(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(e,t){if(n()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return d(this,e)}return a(this,e,t,r)}function a(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n),u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=f(e,t),e}(e,t,r,n):"string"==typeof t?function(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|c(t,r),a=(e=i(e,n)).write(t,r);return a!==n&&(e=e.slice(0,a)),e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|s(t.length);return 0===(e=i(e,r)).length?e:(t.copy(e,0,0,r),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||function(e){return e!=e}(t.length)?i(e,0):f(e,t);if("Buffer"===t.type&&z(t.data))return f(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function o(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function d(e,t){if(o(t),e=i(e,t<0?0:0|s(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function f(e,t){var r=t.length<0?0:0|s(t.length);e=i(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function s(e){if(e>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function c(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0: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 U(e).length;default:if(n)return j(e).length;t=(""+t).toLowerCase(),n=!0}}function h(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function l(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),r=+r,isNaN(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=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:p(e,t,r,n,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):p(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function p(e,t,r,n,i){function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var a,o=1,d=e.length,f=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;o=2,d/=2,f/=2,r/=2}if(i){var s=-1;for(a=r;a<d;a++)if(u(e,a)===u(t,-1===s?0:a-s)){if(-1===s&&(s=a),a-s+1===f)return s*o}else-1!==s&&(a-=a-s),s=-1}else for(r+f>d&&(r=d-f),a=r;a>=0;a--){for(var c=!0,h=0;h<f;h++)if(u(e,a+h)!==u(t,h)){c=!1;break}if(c)return a}return-1}function b(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var u=t.length;if(u%2!=0)throw new TypeError("Invalid hex string");n>u/2&&(n=u/2);for(var a=0;a<n;++a){var o=parseInt(t.substr(2*a,2),16);if(isNaN(o))return a;e[r+a]=o}return a}function y(e,t,r,n){return L(j(t,e.length-r),e,r,n)}function m(e,t,r,n){return L(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function g(e,t,r,n){return m(e,t,r,n)}function v(e,t,r,n){return L(U(t),e,r,n)}function _(e,t,r,n){return L(function(e,t){for(var r,n,i,u=[],a=0;a<e.length&&!((t-=2)<0);++a)r=e.charCodeAt(a),n=r>>8,i=r%256,u.push(i),u.push(n);return u}(t,e.length-r),e,r,n)}function w(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;i<r;){var u,a,o,d,f=e[i],s=null,c=f>239?4:f>223?3:f>191?2:1;if(i+c<=r)switch(c){case 1:f<128&&(s=f);break;case 2:128==(192&(u=e[i+1]))&&(d=(31&f)<<6|63&u)>127&&(s=d);break;case 3:u=e[i+1],a=e[i+2],128==(192&u)&&128==(192&a)&&(d=(15&f)<<12|(63&u)<<6|63&a)>2047&&(d<55296||d>57343)&&(s=d);break;case 4:u=e[i+1],a=e[i+2],o=e[i+3],128==(192&u)&&128==(192&a)&&128==(192&o)&&(d=(15&f)<<18|(63&u)<<12|(63&a)<<6|63&o)>65535&&d<1114112&&(s=d)}null===s?(s=65533,c=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=c}return function(e){var t=e.length;if(t<=F)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=F));return r}(n)}function E(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function A(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function x(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",u=t;u<r;++u)i+=R(e[u]);return i}function k(e,t,r){for(var n=e.slice(t,r),i="",u=0;u<n.length;u+=2)i+=String.fromCharCode(n[u]+256*n[u+1]);return i}function M(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,r,n,i,a){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<a)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function T(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,u=Math.min(e.length-r,2);i<u;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function B(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,u=Math.min(e.length-r,4);i<u;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function C(e,t,r,n,i,u){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,i){return i||C(e,0,r,4),D.write(e,t,r,n,23,4),r+4}function O(e,t,r,n,i){return i||C(e,0,r,8),D.write(e,t,r,n,52,8),r+8}function R(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){t=t||1/0;for(var r,n=e.length,i=null,u=[],a=0;a<n;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&u.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&u.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&u.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&u.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;u.push(r)}else if(r<2048){if((t-=2)<0)break;u.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;u.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;u.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return u}function U(e){return N.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function L(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}var N=r(86),D=r(87),z=r(48);t.Buffer=u,t.SlowBuffer=function(e){return+e!=e&&(e=0),u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=n(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return a(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return function(e,t,r,n){return o(t),t<=0?i(e,t):void 0!==r?"string"==typeof n?i(e,t).fill(r,n):i(e,t).fill(r):i(e,t)}(null,e,t,r)},u.allocUnsafe=function(e){return d(null,e)},u.allocUnsafeSlow=function(e){return d(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i<a;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!z(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),i=0;for(r=0;r<e.length;+