From 478fde5bc46c5638f0c300f5199dc85fe7983b7f Mon Sep 17 00:00:00 2001 From: domschiener Date: Mon, 3 Apr 2017 18:29:03 +0200 Subject: [PATCH] Added version number; improved shouldYouReplay and getAccountData --- README.md | 21 +++++-- bower.json | 2 +- dist/iota.js | 145 +++++++++++++++++++++++++++++++++++++---------- dist/iota.min.js | 10 ++-- lib/api/api.js | 89 +++++++++++++++++++---------- lib/iota.js | 1 + package.json | 2 +- 7 files changed, 196 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index f165ecb29..3917975f5 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,9 @@ var iota = new IOTA({ // now you can start using all of the functions iota.api.getNodeInfo(); + +// you can also get the version +iota.version ``` Overall, there are currently four subclasses that are accessible from the IOTA object: @@ -68,6 +71,9 @@ Overall, there are currently four subclasses that are accessible from the IOTA o - **`multisig`**: Functions for creating and signing multi-signature addresses and transactions. - **`valid`**: Validator functions that can help with determining whether the inputs or results that you get are valid. +You also have access to the `version` of the library +- **`version`**: Current version of the library + In the future new IOTA Core modules (such as Flash, MAM) and all IXI related functionality will be available. ## How to use the Library @@ -489,7 +495,7 @@ iota.api.getTransfers(seed [, options], callback) ### `getAccountData` -Similar to `getTransfers`, just a bit more comprehensive in the sense that it also returns the `balance` and `addresses` that are associated with your account (seed). This function is useful in getting all the relevant information of your account. If you want to have your transfers split into received / sent, you can use the utility function `categorizeTransfers` +Similar to `getTransfers`, just a bit more comprehensive in the sense that it also returns the `addresses`, `transfers`, `inputs` and `balance` that are associated and have been used with your account (seed). This function is useful in getting all the relevant information of your account. If you want to have your transfers split into received / sent, you can use the utility function `categorizeTransfers` #### Input ``` @@ -507,9 +513,11 @@ iota.api.getAccountData(seed [, options], callback) `Object` - returns an object of your account data in the following format: ``` { - 'addresses': [], - 'transfers': [], - 'balance': 0 + 'latestAddress': '', // Latest, unused address which has no transactions in the tangle + 'addresses': [], // List of all used addresses which have transactions associated with them + 'transfers': [], // List of all transfers associated with the addresses + 'inputs': [], // List of all inputs available for the seed. Follows the getInputs format of `address`, `balance`, `security` and `keyIndex` + 'balance': 0 // latest confirmed balance } ``` @@ -521,13 +529,14 @@ This API function helps you to determine whether you should replay a transaction #### Input ``` -iota.api.shouldYouReplay(inputAddress) +iota.api.shouldYouReplay(inputAddress, callback) ``` 1. **`inputAddress`**: `String` address used as input in a transaction +2. **`callback`**: `Function` callback function #### Returns -`Bool` - true / false +`Bool` - true / false --- diff --git a/bower.json b/bower.json index 6cf4b4bf9..dca3fe17e 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "iota.lib.js", - "version": "0.2.4", + "version": "0.2.5", "description": "Javascript Library for IOTA", "main": "./dist/iota.js", "authors": [ diff --git a/dist/iota.js b/dist/iota.js index 5a28928ba..347284d7a 100644 --- a/dist/iota.js +++ b/dist/iota.js @@ -739,7 +739,6 @@ api.prototype.getNewAddress = function(seed, options, callback) { // If total number of addresses to generate is supplied, simply generate // and return the list of all addresses if (total) { - // Increase index with each iteration for (var i = 0; i < total; i++, index++) { @@ -1601,19 +1600,23 @@ api.prototype.getAccountData = function(seed, options, callback) { var security = options.security || 2; // If start value bigger than end, return error - // or if difference between end and start is bigger than 500 keys - if (start > end || end > (start + 500)) { + // or if difference between end and start is bigger than 1000 keys + if (start > end || end > (start + 1000)) { return callback(new Error("Invalid inputs provided")) } // These are the values that will be returned to the original caller - // @addresses all addresses associated with this seed - // @transfers all sent / received transfers - // @balance the confirmed balance + // @latestAddress: latest unused address + // @addresses: all addresses associated with this seed that have been used + // @transfers: all sent / received transfers + // @inputs: all inputs of the account + // @balance: the confirmed balance var valuesToReturn = { - 'addresses' : [], - 'transfers' : [], - 'balance' : 0 + 'latestAddress' : '', + 'addresses' : [], + 'transfers' : [], + 'inputs' : [], + 'balance' : 0 } // first call findTransactions @@ -1631,8 +1634,12 @@ api.prototype.getAccountData = function(seed, options, callback) { if (error) return callback(error); + // assign the last address as the latest address + // since it has no transactions associated with it + valuesToReturn.latestAddress = addresses[addresses.length - 1]; + // Add all returned addresses to the lsit of addresses - // remove the last element as that is the most recent + // remove the last element as that is the most recent address valuesToReturn.addresses = addresses.slice(0, -1); // get all bundles from a list of addresses @@ -1646,8 +1653,24 @@ api.prototype.getAccountData = function(seed, options, callback) { // Get the correct balance count of all addresses self.getBalances(valuesToReturn.addresses, 100, function(error, balances) { - balances.balances.forEach(function(balance) { - valuesToReturn.balance += parseInt(balance); + balances.balances.forEach(function(balance, index) { + + var balance = parseInt(balance); + + valuesToReturn.balance += balance; + + if (balance > 0) { + + var newInput = { + 'address': valuesToReturn.addresses[index], + 'keyIndex': index, + 'security': security, + 'balance': balance + } + + valuesToReturn.inputs.push(newInput); + + } }) return callback(null, valuesToReturn); @@ -1664,39 +1687,45 @@ api.prototype.getAccountData = function(seed, options, callback) { * @param {String} inputAddress Input address you want to have tested * @returns {Bool} **/ -api.prototype.shouldYouReplay = function(inputAddress) { +api.prototype.shouldYouReplay = function(inputAddress, callback) { var self = this; - var inputAddress = Utils.noChecksum(inputAddress); + if (!inputValidator.isAddress(inputAddress)) { - self.findTransactions( { 'address': inputAddress }, function( e, transactions ) { + return callback(errors.invalidInputs()); - self.getTrytes(transactions, function(e, txTrytes) { + } - var valueTransactions = []; + var inputAddress = Utils.noChecksum(inputAddress); - txTrytes.forEach(function(trytes) { - var thisTransaction = Utils.transactionObject(txTrytes); + self.findTransactionObjects( { 'addresses': new Array(inputAddress) }, function( e, transactions ) { - if (thisTransaction.value < 0) { + if (e) return callback(e); - valueTransactions.push(thisTransaction.hash); + var valueTransactions = []; - } - }) + transactions.forEach(function(thisTransaction) { - if ( valueTransactions.length > 0 ) { + if (thisTransaction.value < 0) { - self.getLatestInclusion( valueTransactions, function( e, inclusionStates ) { + valueTransactions.push(thisTransaction.hash); - return inclusionStates.indexOf(true) === -1; - }) - } else { - - return true; } }) + + if ( valueTransactions.length > 0 ) { + + self.getLatestInclusion( valueTransactions, function( e, inclusionStates ) { + + return callback(null, inclusionStates.indexOf( true ) === -1); + + }) + + } else { + + return callback(null, true); + } }) } @@ -2610,6 +2639,7 @@ function IOTA(settings) { // IF NO SETTINGS, SET DEFAULT TO localhost:14265 settings = settings || {}; + this.version = require('../package.json').version; this.host = settings.host ? settings.host : "http://localhost"; this.port = settings.port ? settings.port : 14265; this.provider = settings.provider || this.host.replace(/\/$/, '') + ":" + this.port; @@ -2652,7 +2682,7 @@ IOTA.prototype.changeNode = function(settings) { module.exports = IOTA; -},{"./api/api":2,"./multisig/multisig":11,"./utils/inputValidator":14,"./utils/makeRequest":15,"./utils/utils":16}],11:[function(require,module,exports){ +},{"../package.json":55,"./api/api":2,"./multisig/multisig":11,"./utils/inputValidator":14,"./utils/makeRequest":15,"./utils/utils":16}],11:[function(require,module,exports){ var Signing = require('../crypto/signing'); var Converter = require('../crypto/converter'); var Curl = require('../crypto/curl'); @@ -17330,4 +17360,57 @@ function extend() { return target } +},{}],55:[function(require,module,exports){ +module.exports={ + "name": "iota.lib.js", + "version": "0.2.5", + "description": "Javascript Library for IOTA", + "main": "./lib/iota.js", + "scripts": { + "build": "gulp", + "test": "mocha" + }, + "author": { + "name": "Dominik Schiener (IOTA Foundation)", + "website": "https://iota.org" + }, + "keywords": [ + "iota", + "tangle", + "library", + "browser", + "javascript", + "nodejs", + "API" + ], + "license": "MIT", + "bugs": { + "url": "https://github.com/iotaledger/iota.lib.js/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/iotaledger/iota.lib.js.git" + }, + "dependencies": { + "async": "^2.1.2", + "xmlhttprequest": "^1.8.0" + }, + "devDependencies": { + "bower": "^1.8.0", + "browserify": "^14.1.0", + "chai": "^3.5.0", + "del": "^2.2.2", + "gulp": "^3.9.1", + "gulp-jshint": "^2.0.2", + "gulp-nsp": "^2.4.2", + "gulp-rename": "^1.2.2", + "gulp-replace": "^0.5.4", + "gulp-uglify": "^2.1.2", + "jshint": "^2.9.4", + "mocha": "^3.2.0", + "vinyl-buffer": "^1.0.0", + "vinyl-source-stream": "^1.1.0" + } +} + },{}]},{},[1]); diff --git a/dist/iota.min.js b/dist/iota.min.js index 041b33124..db886c296 100644 --- a/dist/iota.min.js +++ b/dist/iota.min.js @@ -1,5 +1,5 @@ -!function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[s]={exports:{}};t[s][0].call(c.exports,function(e){var r=t[s][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s0},function(e,n){if(e)return r(e);var i=t.returnAll?c:n;return r(null,i)})},n.prototype.getInputs=function(e,t,r){function n(e){i.getBalances(e,100,function(t,n){if(t)return r(t);for(var i={inputs:[],totalBalance:0},o=!f,s=0;s0){var l={address:e[s],balance:u,keyIndex:a+s,security:c};if(i.inputs.push(l),i.totalBalance+=u,f&&i.totalBalance>=f){o=!0;break}}}return o?r(null,i):r(new Error("Not enough balance"))})}var i=this;if(2===arguments.length&&"[object Function]"===Object.prototype.toString.call(t)&&(r=t,t={}),!s.isTrytes(e))return r(o.invalidSeed());var a=t.start||0,u=t.end||null,f=t.threshold||null,c=t.security||2;if(a>u||u>a+500)return r(new Error("Invalid inputs provided"));if(u){for(var l=[],h=a;h=r){var a=i-r;a>0&&p?(g.addEntry(1,p,a,d,s),l(t)):a>0?h.getNewAddress(e,{security:v},function(e,r){var n=Math.floor(Date.now()/1e3);g.addEntry(1,r,a,d,n),l(t)}):l(t)}else r-=i}}function l(t){g.finalize(),g.addTrytes(m);for(var r=0;r2187){w+=Math.floor(t[b].message.length/2187);for(var E=t[b].message;E;){var _=E.slice(0,2187);E=E.slice(2187,E.length);for(var T=0;_.length<2187;T++)_+="9";m.push(_)}}else{var _="";t[b].message&&(_=t[b].message.slice(0,2187));for(var T=0;_.length<2187;T++)_+="9";m.push(_)}var A=Math.floor(Date.now()/1e3);d=t[b].tag?t[b].tag:"999999999999999999999999999";for(var T=0;d.length<27;T++)d+="9";g.addEntry(w,t[b].address,t[b].value,d,A),y+=parseInt(t[b].value)}if(!y){g.finalize(),g.addTrytes(m);var x=[];return g.bundle.forEach(function(e){x.push(c.transactionTrytes(e))}),n(null,x.reverse())}if(r.inputs){var S=[];r.inputs.forEach(function(e){S.push(e.address)}),h.getBalances(S,100,function(e,t){for(var o=[],s=0,a=0;a0){s+=u;var f=r.inputs[a];if(f.balance=u,o.push(f),s>=y)break}}if(y>s)return n(new Error("Not enough balance"));i(o)})}else h.getInputs(e,{threshold:y,security:v},function(e,t){if(e)return n(e);i(t.inputs)})},n.prototype.traverseBundle=function(e,t,r,n){var i=this;i.getTrytes(Array(e),function(e,o){if(e)return n(e);var s=o[0];if(!s)return n(new Error("Bundle transactions not visible"));var a=c.transactionObject(s);if(!a)return n(new Error("Invalid trytes, could not create object"));if(!t&&0!==a.currentIndex)return n(new Error("Invalid tail transaction supplied."));if(t||(t=a.bundle),t!==a.bundle)return n(null,r);if(0===a.lastIndex&&0===a.currentIndex)return n(null,Array(a));var u=a.trunkTransaction;return r.push(a),i.traverseBundle(u,t,r,n)})},n.prototype.getBundle=function(e,t){var r=this;if(!s.isHash(e))return t(o.invalidInputs(e));r.traverseBundle(e,null,Array(),function(e,r){return e?t(e):c.isBundle(r)?t(null,r):t(new Error("Invalid Bundle provided"))})},n.prototype._bundlesFromAddresses=function(e,t,r){var n=this;n.findTransactionObjects({addresses:e},function(e,i){if(e)return r(e);var o=new Set,s=new Set;i.forEach(function(e){0===e.currentIndex?o.add(e.hash):s.add(e.bundle)}),n.findTransactionObjects({bundles:Array.from(s)},function(e,i){if(e)return r(e);i.forEach(function(e){0===e.currentIndex&&o.add(e.hash)});var s=[],a=Array.from(o);l.waterfall([function(e){t?n.getLatestInclusion(a,function(t,n){if(t)return r(t);e(null,n)}):e(null,[])},function(e,i){l.mapSeries(a,function(r,i){n.getBundle(r,function(n,o){if(!n){if(t){var u=e[a.indexOf(r)];o.forEach(function(e){e.persistence=u})}s.push(o)}i(null,!0)})},function(e,t){return s.sort(function(e,t){var r=parseInt(e[0].timestamp),n=parseInt(t[0].timestamp);return rn?1:0}),r(e,s)})}])})})},n.prototype.getTransfers=function(e,t,r){var n=this;if(2===arguments.length&&"[object Function]"===Object.prototype.toString.call(t)&&(r=t,t={}),!s.isTrytes(e))return r(o.invalidSeed(e));var i=t.start||0,a=t.end||null,u=t.inclusionStates||null,f=t.security||2;if(i>a||a>i+500)return r(new Error("Invalid inputs provided"));var c={index:i,total:a?a-i:null,returnAll:!0,security:f};n.getNewAddress(e,c,function(e,t){return e?r(e):n._bundlesFromAddresses(t,u,r)})},n.prototype.getAccountData=function(e,t,r){var n=this;if(2===arguments.length&&"[object Function]"===Object.prototype.toString.call(t)&&(r=t,t={}),!s.isTrytes(e))return r(o.invalidSeed(e));var i=t.start||0,a=t.end||null,u=t.security||2;if(i>a||a>i+500)return r(new Error("Invalid inputs provided"));var f={addresses:[],transfers:[],balance:0},c={index:i,total:a?a-i:null,returnAll:!0,security:u};n.getNewAddress(e,c,function(e,t){if(e)return r(e);f.addresses=t.slice(0,-1),n._bundlesFromAddresses(t,!0,function(e,t){if(e)return r(e);f.transfers=t,n.getBalances(f.addresses,100,function(e,t){return t.balances.forEach(function(e){f.balance+=parseInt(e)}),r(null,f)})})})},n.prototype.shouldYouReplay=function(e){var t=this,e=c.noChecksum(e);t.findTransactions({address:e},function(e,r){t.getTrytes(r,function(e,r){var n=[];if(r.forEach(function(e){var t=c.transactionObject(r);t.value<0&&n.push(t.hash)}),!(n.length>0))return!0;t.getLatestInclusion(n,function(e,t){return t.indexOf(!0)===-1})})})},t.exports=n},{"../crypto/bundle":4,"../crypto/converter":5,"../crypto/curl":6,"../crypto/signing":7,"../errors/inputErrors":8,"../utils/inputValidator":14,"../utils/utils":16,"./apiCommands":3,async:17}],3:[function(e,t,r){var n=function(e,t,r,n){return{command:"attachToTangle",trunkTransaction:e,branchTransaction:t,minWeightMagnitude:r,trytes:n}},i=function(e){var t={command:"findTransactions"};return Object.keys(e).forEach(function(r){t[r]=e[r]}),t},o=function(e,t){return{command:"getBalances",addresses:e,threshold:t}},s=function(e,t){return{command:"getInclusionStates",transactions:e,tips:t}},a=function(){return{command:"getNodeInfo"}},u=function(){return{command:"getNeighbors"}},f=function(e){return{command:"addNeighbors",uris:e}},c=function(e){return{command:"removeNeighbors",uris:e}},l=function(){return{command:"getTips"}},h=function(e){return{command:"getTransactionsToApprove",depth:e}},d=function(e){return{command:"getTrytes",hashes:e}},p=function(){return{command:"interruptAttachingToTangle"}},v=function(e){return{command:"broadcastTransactions",trytes:e}},g=function(e){return{command:"storeTransactions",trytes:e}};t.exports={attachToTangle:n,findTransactions:i,getBalances:o,getInclusionStates:s,getNodeInfo:a,getNeighbors:u,addNeighbors:f,removeNeighbors:c,getTips:l,getTransactionsToApprove:h,getTrytes:d,interruptAttachingToTangle:p,broadcastTransactions:v,storeTransactions:g}},{}],4:[function(e,t,r){function n(){this.bundle=[]}var i=e("./curl"),o=e("./converter");n.prototype.addEntry=function(e,t,r,n,i,o){for(var s=0;s=0){for(;n-- >0;)for(var i=0;i<27;i++)if(t[27*r+i]>-13){t[27*r+i]--;break}}else for(;n++<0;)for(var i=0;i<27;i++)if(t[27*r+i]<13){t[27*r+i]++;break}}return t},t.exports=n},{"./converter":5,"./curl":6}],5:[function(e,t,r){var n="9ABCDEFGHIJKLMNOPQRSTUVWXYZ",i=[[0,0,0],[1,0,0],[-1,1,0],[0,1,0],[1,1,0],[-1,-1,1],[0,-1,1],[1,-1,1],[-1,0,1],[0,0,1],[1,0,1],[-1,1,1],[0,1,1],[1,1,1],[-1,-1,-1],[0,-1,-1],[1,-1,-1],[-1,0,-1],[0,0,-1],[1,0,-1],[-1,1,-1],[0,1,-1],[1,1,-1],[-1,-1,0],[0,-1,0],[1,-1,0],[-1,0,0]],o=function(e,t){var r=t||[];if(Number.isInteger(e)){for(var o=e<0?-e:e;o>0;){var s=o%3;o=Math.floor(o/3),s>1&&(s=-1,o++),r[r.length]=s}if(e<0)for(var a=0;a0;)t=3*t+e[r];return t};t.exports={trits:o,trytes:s,value:a}},{}],6:[function(e,t,r){function n(){this.truthTable=[1,0,-1,1,-1,0,-1,1,0]}e("./converter");n.prototype.initialize=function(e){if(e)this.state=e;else{this.state=[];for(var t=0;t<729;t++)this.state[t]=0}},n.prototype.absorb=function(e){for(var t=0;t1;s++)i[s]=-1;var a=new n;a.initialize(),a.absorb(i),a.squeeze(i),a.initialize(),a.absorb(i);for(var u=[],f=0,c=[];r-- >0;)for(var o=0;o<27;o++){a.squeeze(c);for(var s=0;s<243;s++)u[f++]=c[s]}return u},a=function(e){for(var t=[],r=[],i=0;i0;){var a=new n;a.initialize(),a.absorb(r),a.squeeze(r)}i.absorb(r)}return i.squeeze(r),r},c=function(e,t){for(var r=t.slice(),i=[],o=new n,s=0;s<27;s++){i=r.slice(243*s,243*(s+1));for(var a=0;a<13-e[s];a++)o.initialize(),o.absorb(i),o.squeeze(i);for(var a=0;a<243;a++)r[243*s+a]=i[a]}return r},l=function(e,t,r){for(var n=this,s=new o,a=[],u=s.normalizedBundle(r),c=0;c<3;c++)a[c]=u.slice(27*c,27*(c+1));for(var l=[],c=0;c2187){v+=Math.floor(n[p].message.length/2187);for(var g=n[p].message;g;){var y=g.slice(0,2187);g=g.slice(2187,g.length);for(var m=0;y.length<2187;m++)y+="9";d.push(y)}}else{var y="";n[p].message&&(y=n[p].message.slice(0,2187));for(var m=0;y.length<2187;m++)y+="9";d.push(y)}var b=Math.floor(Date.now()/1e3);s=n[p].tag?n[p].tag:"999999999999999999999999999";for(var m=0;s.length<27;m++)s+="9";l.addEntry(v,n[p].address.slice(0,81),n[p].value,s,b),h+=parseInt(n[p].value)}if(!h)return i(new Error("Invalid value transfer: the transfer does not require a signature."));var w={command:"getBalances",addresses:new Array(t),threshold:100};o._makeRequest.send(w,function(n,o){var a=parseInt(o.balances[0]);if(a>0){var u=0-a,f=Math.floor(Date.now()/1e3);l.addEntry(e,t,u,s,f)}if(h>a)return i(new Error("Not enough balance."));if(a>h){var c=a-h;if(!r)return i(new Error("No remainder address defined"));l.addEntry(1,r,c,s,f)}return l.finalize(),l.addTrytes(d),i(null,l.bundle)})},n.prototype.addSignature=function(e,t,r,n){var s=new a;s.bundle=e;for(var u=r.length/2187,r=o.trits(r),c=0,l=0;l255)return null;var o=i%27,s=(i-o)/27;t+="9ABCDEFGHIJKLMNOPQRSTUVWXYZ"[o]+"9ABCDEFGHIJKLMNOPQRSTUVWXYZ"[s]}return t}function i(e){if("string"!=typeof e)return null;for(var t="9ABCDEFGHIJKLMNOPQRSTUVWXYZ",r="",n=0;n-1){var s=i.currentIndex===i.lastIndex&&0!==i.lastIndex;i.value<0&&!n&&!s?(r.sent.push(e),n=!0):i.value>=0&&!n&&!s&&r.received.push(e)}})}),r},y=function(e,t){for(var r,i=[],o=0;o-1&&e%1==0&&e<=wt}function v(e){return null!=e&&p(e.length)&&!d(e)}function g(){}function y(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}function m(e,t){for(var r=-1,n=Array(e);++r-1&&e%1==0&&ei?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n=n?e:J(e,t,r)}function Z(e,t){for(var r=e.length;r--&&G(t,e[r],0)>-1;);return r}function Q(e,t){for(var r=-1,n=e.length;++r-1;);return r}function ee(e){return e.split("")}function te(e){return dr.test(e)}function re(e){return e.match(_r)||[]}function ne(e){return te(e)?re(e):ee(e)}function ie(e){return null==e?"":K(e)}function oe(e,t,r){if((e=ie(e))&&(r||void 0===t))return e.replace(Tr,"");if(!e||!(t=K(t)))return e;var n=ne(e),i=ne(t);return Y(n,Q(n,i),Z(n,i)+1).join("")}function se(e){return e=e.toString().replace(kr,""),e=e.match(Ar)[2].replace(" ",""),e=e?e.split(xr):[],e=e.map(function(e){return oe(e.replace(Sr,""))})}function ae(e,t){var r={};z(e,function(e,t){function n(t,r){var n=$(i,function(e){return t[e]});n.push(r),e.apply(null,n)}var i;if(Rt(e))i=e.slice(0,-1),e=e[e.length-1],r[t]=i.concat(i.length>0?n:e);else if(1===e.length)r[t]=e;else{if(i=se(e),0===e.length&&0===i.length)throw new Error("autoInject task functions require explicit parameters.");i.pop(),r[t]=i.concat(n)}}),ur(r,t)}function ue(e){setTimeout(e,0)}function fe(e){return a(function(t,r){e(function(){t.apply(null,r)})})}function ce(){this.head=this.tail=null,this.length=0}function le(e,t){e.length=1,e.head=e.tail=t}function he(e,t,r){function n(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,Rt(e)||(e=[e]),0===e.length&&f.idle())return jr(function(){f.drain()});for(var n=0,i=e.length;n=0&&s.splice(a),i.callback.apply(i,t),null!=t[0]&&f.error(t[0],i.data)}o<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()})}if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var o=0,s=[],u=!1,f={_tasks:new ce,concurrency:t,payload:r,saturated:g,unsaturated:g,buffer:t/4,empty:g,drain:g,error:g,started:!1,paused:!1,push:function(e,t){n(e,!1,t)},kill:function(){f.drain=g,f._tasks.empty()},unshift:function(e,t){n(e,!0,t)},process:function(){if(!u){for(u=!0;!f.paused&&o1&&(n=t),r(null,{value:n})}})),e.apply(this,t)})}function ze(e,t,r,n){Ie(e,t,function(e,t){r(e,function(e,r){t(e,!r)})},n)}function He(e){var t;return Rt(e)?t=$(e,Pe):(t={},z(e,function(e,r){t[r]=Pe.call(this,e)})),t}function Ve(e){return function(){return e}}function We(e,t,r){function n(){t(function(e){e&&a++n?1:0}tr(e,function(e,r){t(e,function(t,n){if(t)return r(t);r(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,$(t.sort(n),Oe("value")))})}function Xe(e,t,r){function n(){a||(o.apply(null,arguments),clearTimeout(s))}function i(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),a=!0,o(n)}var o,s,a=!1;return rt(function(r,a){o=a,s=setTimeout(i,t),e.apply(null,r.concat(n))})}function Ke(e,t,r,n){for(var i=-1,o=ln(cn((t-e)/(r||1)),0),s=Array(o);o--;)s[n?o:++i]=e,e+=r;return s}function Je(e,t,r,n){nr(Ke(0,e,1),t,r,n)}function Ye(e,t,r,n){3===arguments.length&&(n=r,r=t,t=Rt(e)?[]:{}),n=y(n||g),er(e,function(e,n,i){r(t,e,n,i)},function(e){n(e,t)})}function Ze(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Qe(e,t,r){if(r=C(r||g),!e())return r(null);var n=a(function(i,o){return i?r(i):e()?t(n):void r.apply(null,[null].concat(o))});t(n)}function et(e,t,r){Qe(function(){return!e.apply(this,arguments)},t,r)}var tt=Math.max,rt=function(e){return a(function(t){var r=t.pop();e.call(this,t,r)})},nt="object"==typeof n&&n&&n.Object===Object&&n,it="object"==typeof self&&self&&self.Object===Object&&self,ot=nt||it||Function("return this")(),st=ot.Symbol,at=Object.prototype,ut=at.hasOwnProperty,ft=at.toString,ct=st?st.toStringTag:void 0,lt=Object.prototype,ht=lt.toString,dt="[object Null]",pt="[object Undefined]",vt=st?st.toStringTag:void 0,gt="[object AsyncFunction]",yt="[object Function]",mt="[object GeneratorFunction]",bt="[object Proxy]",wt=9007199254740991,Et={},_t="function"==typeof Symbol&&Symbol.iterator,Tt=function(e){return _t&&e[_t]&&e[_t]()},At="[object Arguments]",xt=Object.prototype,St=xt.hasOwnProperty,kt=xt.propertyIsEnumerable,Ot=w(function(){return arguments}())?w:function(e){return b(e)&&St.call(e,"callee")&&!kt.call(e,"callee")},Rt=Array.isArray,jt="object"==typeof r&&r&&!r.nodeType&&r,It=jt&&"object"==typeof t&&t&&!t.nodeType&&t,Ct=It&&It.exports===jt,Lt=Ct?ot.Buffer:void 0,Bt=Lt?Lt.isBuffer:void 0,Mt=Bt||E,Nt=9007199254740991,qt=/^(?:0|[1-9]\d*)$/,Ut={};Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Arguments]"]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object Boolean]"]=Ut["[object DataView]"]=Ut["[object Date]"]=Ut["[object Error]"]=Ut["[object Function]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut["[object Object]"]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object WeakMap]"]=!1;var Ft,Dt="object"==typeof r&&r&&!r.nodeType&&r,Pt=Dt&&"object"==typeof t&&t&&!t.nodeType&&t,zt=Pt&&Pt.exports===Dt,Ht=zt&&nt.process,Vt=function(){try{return Ht&&Ht.binding&&Ht.binding("util")}catch(e){}}(),Wt=Vt&&Vt.isTypedArray,Gt=Wt?function(e){return function(t){return e(t)}}(Wt):T,$t=Object.prototype,Xt=$t.hasOwnProperty,Kt=Object.prototype,Jt=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),Yt=Object.prototype,Zt=Yt.hasOwnProperty,Qt=M(B,1/0),er=function(e,t,r){(v(e)?N:Qt)(e,t,r)},tr=q(U),rr=u(tr),nr=F(U),ir=M(nr,1),or=u(ir),sr=a(function(e,t){return a(function(r){return e.apply(null,t.concat(r))})}),ar=function(e){return function(t,r,n){for(var i=-1,o=Object(t),s=n(t),a=s.length;a--;){var u=s[e?a:++i];if(r(o[u],u,o)===!1)break}return t}}(),ur=function(e,t,r){function n(e,t){m.push(function(){u(e,t)})}function i(){if(0===m.length&&0===d)return r(null,h);for(;m.length&&d1?i(h,n):i(n)}}function f(t){var r=[];return z(e,function(e,n){Rt(e)&&G(e,t,0)>=0&&r.push(n)}),r}"function"==typeof t&&(r=t,t=null),r=y(r||g);var c=k(e),l=c.length;if(!l)return r(null);t||(t=l);var h={},d=0,p=!1,v=Object.create(null),m=[],b=[],w={};z(e,function(t,r){if(!Rt(t))return n(r,[t]),void b.push(r);var i=t.slice(0,t.length-1),s=i.length;if(0===s)return n(r,t),void b.push(r);w[r]=s,P(i,function(a){if(!e[a])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+a+"` in "+i.join(", "));o(a,function(){0===--s&&n(r,t)})})}),function(){for(var e,t=0;b.length;)e=b.pop(),t++,P(f(e),function(e){0==--w[e]&&b.push(e)});if(t!==l)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),i()},fr="[object Symbol]",cr=1/0,lr=st?st.prototype:void 0,hr=lr?lr.toString:void 0,dr=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]"),pr="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",vr="\\ud83c[\\udffb-\\udfff]",gr="(?:\\ud83c[\\udde6-\\uddff]){2}",yr="[\\ud800-\\udbff][\\udc00-\\udfff]",mr="(?:"+pr+"|"+vr+")?",br="(?:\\u200d(?:"+["[^\\ud800-\\udfff]",gr,yr].join("|")+")[\\ufe0e\\ufe0f]?"+mr+")*",wr="[\\ufe0e\\ufe0f]?"+mr+br,Er="(?:"+["[^\\ud800-\\udfff]"+pr+"?",pr,gr,yr,"[\\ud800-\\udfff]"].join("|")+")",_r=RegExp(vr+"(?="+vr+")|"+Er+wr,"g"),Tr=/^\s+|\s+$/g,Ar=/^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,xr=/,/,Sr=/(=.+)?(\s*)$/,kr=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,Or="function"==typeof setImmediate&&setImmediate,Rr="object"==typeof e&&"function"==typeof e.nextTick;Ft=Or?setImmediate:Rr?e.nextTick:ue;var jr=fe(Ft);ce.prototype.removeLink=function(e){return e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,e.prev=e.next=null,this.length-=1,e},ce.prototype.empty=ce,ce.prototype.insertAfter=function(e,t){t.prev=e,t.next=e.next,e.next?e.next.prev=t:this.tail=t,e.next=t,this.length+=1},ce.prototype.insertBefore=function(e,t){t.prev=e.prev,t.next=e,e.prev?e.prev.next=t:this.head=t,e.prev=t,this.length+=1},ce.prototype.unshift=function(e){this.head?this.insertBefore(this.head,e):le(this,e)},ce.prototype.push=function(e){this.tail?this.insertAfter(this.tail,e):le(this,e)},ce.prototype.shift=function(){return this.head&&this.removeLink(this.head)},ce.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)};var Ir,Cr=M(B,1),Lr=a(function(e){return a(function(t){var r=this,n=t[t.length-1];"function"==typeof n?t.pop():n=g,pe(e,t,function(e,t,n){t.apply(r,e.concat(a(function(e,t){n(e,t)})))},function(e,t){n.apply(r,[e].concat(t))})})}),Br=a(function(e){return Lr.apply(null,e.reverse())}),Mr=q(ve),Nr=function(e){return function(t,r,n){return e(Cr,t,r,n)}}(ve),qr=a(function(e){var t=[null].concat(e);return rt(function(e,r){return r.apply(this,t)})}),Ur=q(ge(s,ye)),Fr=F(ge(s,ye)),Dr=M(Fr,1),Pr=me("dir"),zr=M(xe,1),Hr=q(ge(ke,ke)),Vr=F(ge(ke,ke)),Wr=M(Vr,1),Gr=q(Ie),$r=F(Ie),Xr=M($r,1),Kr=me("log"),Jr=M(Le,1/0),Yr=M(Le,1);Ir=Rr?e.nextTick:Or?setImmediate:ue;var Zr=fe(Ir),Qr=function(e,t){return he(function(t,r){e(t[0],r)},t,1)},en=function(e,t){var r=Qr(e,t);return r.push=function(e,t,n){if(null==n&&(n=g),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,Rt(e)||(e=[e]),0===e.length)return jr(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,s=e.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function i(e){return 3*e.length/4-n(e)}function o(e){var t,r,i,o,s,a,u=e.length;s=n(e),a=new l(3*u/4-s),i=s>0?u-4:u;var f=0;for(t=0,r=0;t>16&255,a[f++]=o>>8&255,a[f++]=255&o;return 2===s?(o=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,a[f++]=255&o):1===s&&(o=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,a[f++]=o>>8&255,a[f++]=255&o),a}function s(e){return f[e>>18&63]+f[e>>12&63]+f[e>>6&63]+f[63&e]}function a(e,t,r){for(var n,i=[],o=t;ou?u:s+16383));return 1===n?(t=e[r-1],i+=f[t>>2],i+=f[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=f[t>>10],i+=f[t>>4&63],i+=f[t<<2&63],i+="="),o.push(i),o.join("")}r.byteLength=i,r.toByteArray=o,r.fromByteArray=u;for(var f=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=h.length;ds)throw new RangeError("size is too large");var n=r,o=t;void 0===o&&(n=void 0,o=0);var a=new i(e);if("string"==typeof o)for(var u=new i(o,n),f=u.length,c=-1;++cs)throw new RangeError("size is too large");return new i(e)},r.from=function(e,r,n){if("function"==typeof i.from&&(!t.Uint8Array||Uint8Array.from!==i.from))return i.from(e,r,n);if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("string"==typeof e)return new i(e,r);if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var o=r;if(1===arguments.length)return new i(e);void 0===o&&(o=0);var s=n;if(void 0===s&&(s=e.byteLength-o),o>=e.byteLength)throw new RangeError("'offset' is out of bounds");if(s>e.byteLength-o)throw new RangeError("'length' is out of bounds");return new i(e.slice(o,o+s))}if(i.isBuffer(e)){var a=new i(e.length);return e.copy(a,0,0,e.length),a}if(e){if(Array.isArray(e)||"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return new i(e);if("Buffer"===e.type&&Array.isArray(e.data))return new i(e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},r.allocUnsafeSlow=function(e){if("function"==typeof i.allocUnsafeSlow)return i.allocUnsafeSlow(e);if("number"!=typeof e)throw new TypeError("size must be a number");if(e>=s)throw new RangeError("size is too large");return new o(e)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{buffer:22}],22:[function(e,t,r){"use strict";function n(e){if(e>K)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=i.prototype,t}function i(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 u(e)}return o(e,t,r)}function o(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return e instanceof ArrayBuffer?l(e,t,r):"string"==typeof e?f(e,t):h(e)}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 a(e,t,r){return s(e),e<=0?n(e):void 0!==t?"string"==typeof r?n(e).fill(t,r):n(e).fill(t):n(e)}function u(e){return s(e),n(e<0?0:0|d(e))}function f(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!i.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var r=0|v(e,t),o=n(r),s=o.write(e,t);return s!==r&&(o=o.slice(0,s)),o}function c(e){for(var t=e.length<0?0:0|d(e.length),r=n(t),i=0;i=K)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K.toString(16)+" bytes");return 0|e}function p(e){return+e!=e&&(e=0),i.alloc(+e)}function v(e,t){if(i.isBuffer(e))return e.length;if(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 P(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(e).length;default:if(n)return P(e).length;t=(""+t).toLowerCase(),n=!0}}function g(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,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return k(this,t,r);case"ascii":return R(this,t,r);case"latin1":case"binary":return j(this,t,r);case"base64":return S(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,o){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=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=i.from(t,n)),i.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){function o(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}var s=1,a=e.length,u=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,u/=2,r/=2}var f;if(i){var c=-1;for(f=r;fa&&(r=a-u), -f=r;f>=0;f--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s239?4:o>223?3:o>191?2:1;if(i+a<=r){var u,f,c,l;switch(a){case 1:o<128&&(s=o);break;case 2:u=e[i+1],128==(192&u)&&(l=(31&o)<<6|63&u)>127&&(s=l);break;case 3:u=e[i+1],f=e[i+2],128==(192&u)&&128==(192&f)&&(l=(15&o)<<12|(63&u)<<6|63&f)>2047&&(l<55296||l>57343)&&(s=l);break;case 4:u=e[i+1],f=e[i+2],c=e[i+3],128==(192&u)&&128==(192&f)&&128==(192&c)&&(l=(15&o)<<18|(63&u)<<12|(63&f)<<6|63&c)>65535&&l<1114112&&(s=l)}}null===s?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=a}return O(n)}function O(e){var t=e.length;if(t<=J)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function B(e,t,r,n,o,s){if(!i.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function M(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 N(e,t,r,n,i){return t=+t,r>>>=0,i||M(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(e,t,r,n,23,4),r+4}function q(e,t,r,n,i){return t=+t,r>>>=0,i||M(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(e,t,r,n,52,8),r+8}function U(e){if(e=F(e).replace(Y,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function F(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function D(e){return e<16?"0"+e.toString(16):e.toString(16)}function P(e,t){t=t||1/0;for(var r,n=e.length,i=null,o=[],s=0;s55295&&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 z(e){for(var t=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function V(e){return $.toByteArray(U(e))}function W(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function G(e){return e!==e}var $=e("base64-js"),X=e("ieee754");r.Buffer=i,r.SlowBuffer=p,r.INSPECT_MAX_BYTES=50;var K=2147483647;r.kMaxLength=K,i.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),"undefined"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),i.poolSize=8192,i.from=function(e,t,r){return o(e,t,r)},i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,i.alloc=function(e,t,r){return a(e,t,r)},i.allocUnsafe=function(e){return u(e)},i.allocUnsafeSlow=function(e){return u(e)},i.isBuffer=function(e){return null!=e&&e._isBuffer===!0},i.compare=function(e,t){if(!i.isBuffer(e)||!i.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,s=Math.min(r,n);o0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},i.prototype.compare=function(e,t,r,n,o){if(!i.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===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,o>>>=0,this===e)return 0;for(var s=o-n,a=r-t,u=Math.min(s,a),f=this.slice(n,o),c=e.slice(t,r),l=0;l>>=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 w(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return T(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var J=4096;i.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||L(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||L(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},i.prototype.readUInt8=function(e,t){return e>>>=0,t||L(e,1,this.length),this[e]},i.prototype.readUInt16LE=function(e,t){return e>>>=0,t||L(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUInt16BE=function(e,t){return e>>>=0,t||L(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUInt32LE=function(e,t){return e>>>=0,t||L(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUInt32BE=function(e,t){return e>>>=0,t||L(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||L(e,t,this.length);for(var n=this[e],i=1,o=0;++o=i&&(n-=Math.pow(2,8*t)),n},i.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||L(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},i.prototype.readInt8=function(e,t){return e>>>=0,t||L(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},i.prototype.readInt16LE=function(e,t){e>>>=0,t||L(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(e,t){e>>>=0,t||L(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readFloatLE=function(e,t){return e>>>=0,t||L(e,4,this.length),X.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return e>>>=0,t||L(e,4,this.length),X.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return e>>>=0,t||L(e,8,this.length),X.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return e>>>=0,t||L(e,8,this.length),X.read(this,e,!1,52,8)},i.prototype.writeUIntLE=function(e,t,r,n){if(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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.prototype.writeFloatLE=function(e,t,r){return N(this,e,t,!0,r)},i.prototype.writeFloatBE=function(e,t,r){return N(this,e,t,!1,r)},i.prototype.writeDoubleLE=function(e,t,r){return q(this,e,t,!0,r)},i.prototype.writeDoubleBE=function(e,t,r){return q(this,e,t,!1,r)},i.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=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=0;--i)e[i+t]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var s;if("number"==typeof e)for(s=t;s0&&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){function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var n=!1;return r.listener=t,this.on(e,r),this},n.prototype.removeListener=function(e,t){var r,n,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],o=r.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(s(r)){for(a=o;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(r=this._events[e],i(r))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)}},{}],26:[function(e,t,r){var n=e("http"),i=t.exports;for(var o in n)n.hasOwnProperty(o)&&(i[o]=n[o]);i.request=function(e,t){return e||(e={}),e.scheme="https",e.protocol="https:",n.request.call(this,e,t)}},{http:44}],27:[function(e,t,r){r.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=a;c>0;o=256*o+e[t+l],l+=h,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+e[t+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)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,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=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=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+l>=1?h/u:h*Math.pow(2,1-l),t*u>=2&&(s++,u/=2),s+l>=c?(a=0,s=c):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-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*v}},{}],28:[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}},{}],29:[function(e,t,r){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function i(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}t.exports=function(e){return null!=e&&(n(e)||i(e)||!!e._isBuffer)}},{}],30:[function(e,t,r){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],31:[function(e,t,r){(function(e){"use strict";function r(t,r,n,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,r)});case 3:return e.nextTick(function(){t.call(null,r,n)});case 4:return e.nextTick(function(){t.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s1)for(var r=1;r1&&(n=r[0]+"@",e=r[1]),e=e.replace(C,"."),n+o(e.split("."),t).join(".")}function a(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(e-=65536,t+=N(e>>>10&1023|55296),e=56320|1023&e),t+=N(e)}).join("")}function f(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:_}function c(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function l(e,t,r){var n=0;for(e=r?M(e/S):e>>1,e+=M(e/t);e>B*A>>1;n+=_)e=M(e/B);return M(n+(B+1)*e/(e+x))}function h(e){var t,r,n,o,s,a,c,h,d,p,v=[],g=e.length,y=0,m=O,b=k;for(r=e.lastIndexOf(R),r<0&&(r=0),n=0;n=128&&i("not-basic"),v.push(e.charCodeAt(n));for(o=r>0?r+1:0;o=g&&i("invalid-input"),h=f(e.charCodeAt(o++)),(h>=_||h>M((E-y)/a))&&i("overflow"),y+=h*a,d=c<=b?T:c>=b+A?A:c-b,!(hM(E/p)&&i("overflow"),a*=p;t=v.length+1,b=l(y-s,t,0==s),M(y/t)>E-m&&i("overflow"),m+=M(y/t),y%=t,v.splice(y++,0,m)}return u(v)}function d(e){var t,r,n,o,s,u,f,h,d,p,v,g,y,m,b,w=[];for(e=a(e),g=e.length,t=O,r=0,s=k,u=0;u=t&&vM((E-r)/y)&&i("overflow"),r+=(f-t)*y,t=f,u=0;uE&&i("overflow"),v==t){for(h=r,d=_;p=d<=s?T:d>=s+A?A:d-s,!(h= 0x80 (not a basic code point)","invalid-input":"Invalid input"},B=_-T,M=Math.floor,N=String.fromCharCode;if(b={version:"1.4.1",ucs2:{decode:a,encode:u},decode:h,encode:d,toASCII:v,toUnicode:p},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return b});else if(g&&y)if(t.exports==g)y.exports=b;else for(w in b)b.hasOwnProperty(w)&&(g[w]=b[w]);else n.punycode=b}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],34:[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;e=e.split(t);var a=1e3;o&&"number"==typeof o.maxKeys&&(a=o.maxKeys);var u=e.length;a>0&&u>a&&(u=a);for(var f=0;f=0?(c=p.substr(0,v),l=p.substr(v+1)):(c=p,l=""),h=decodeURIComponent(c),d=decodeURIComponent(l),n(s,h)?i(s[h])?s[h].push(d):s[h]=[s[h],d]:s[h]=d}return s};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],35:[function(e,t,r){"use strict";function n(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){ -var u=new Error("stream.unshift() after end event");e.emit("error",u)}else{var f;!t.decoder||i||n||(r=t.decoder.write(r),f=!t.objectMode&&0===r.length),i||(t.reading=!1),f||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&h(e))),p(e,t)}else i||(t.reading=!1);return a(t)}function a(e){return!e.ended&&(e.needReadable||e.length=P?e=P:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function f(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=u(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function c(e,t){var r=null;return B.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function l(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,h(e)}}function h(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(U("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?j(d,e):d(e))}function d(e){U("emit readable"),e.emit("readable"),w(e)}function p(e,t){t.readingMore||(t.readingMore=!0,j(v,e,t))}function v(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=_(e,t.buffer,t.decoder),r}function _(e,t,r){var n;return 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}function A(e,t){var r=M.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;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}function x(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,j(S,t,e))}function S(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function k(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return U("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?x(this):h(this),null;if(0===(e=f(e,t))&&t.ended)return 0===t.length&&x(this),null;var n=t.needReadable;U("need readable",n),(0===t.length||t.length-e0?E(e,t):null,null===i?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&x(this)),null!==i&&this.emit("data",i),i},o.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},o.prototype.pipe=function(e,t){function i(e){U("onunpipe"),e===h&&s()}function o(){U("onend"),e.end()}function s(){U("cleanup"),e.removeListener("close",f),e.removeListener("finish",c),e.removeListener("drain",y),e.removeListener("error",u),e.removeListener("unpipe",i),h.removeListener("end",o),h.removeListener("end",s),h.removeListener("data",a),m=!0,!d.awaitDrain||e._writableState&&!e._writableState.needDrain||y()}function a(t){U("ondata"),b=!1,!1!==e.write(t)||b||((1===d.pipesCount&&d.pipes===e||d.pipesCount>1&&O(d.pipes,e)!==-1)&&!m&&(U("false write response, pause",h._readableState.awaitDrain),h._readableState.awaitDrain++,b=!0),h.pause())}function u(t){U("onerror",t),l(),e.removeListener("error",u),0===L(e,"error")&&e.emit("error",t)}function f(){e.removeListener("finish",c),l()}function c(){U("onfinish"),e.removeListener("close",f),l()}function l(){U("unpipe"),h.unpipe(e)}var h=this,d=this._readableState;switch(d.pipesCount){case 0:d.pipes=e;break;case 1:d.pipes=[d.pipes,e];break;default:d.pipes.push(e)}d.pipesCount+=1,U("pipe count=%d opts=%j",d.pipesCount,t);var p=(!t||t.end!==!1)&&e!==r.stdout&&e!==r.stderr,v=p?o:s;d.endEmitted?j(v):h.once("end",v),e.on("unpipe",i);var y=g(h);e.on("drain",y);var m=!1,b=!1;return h.on("data",a),n(e,"error",u),e.once("close",f),e.once("finish",c),e.emit("pipe",h),d.flowing||(U("pipe resume"),h.resume()),e},o.prototype.unpipe=function(e){var t=this._readableState;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),this);if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1?setImmediate:A;s.WritableState=o;var S=e("core-util-is");S.inherits=e("inherits");var k,O={deprecate:e("util-deprecate")};!function(){try{k=e("stream")}catch(e){}finally{k||(k=e("events").EventEmitter)}}();var R=e("buffer").Buffer,j=e("buffer-shims");S.inherits(s,k),o.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(o.prototype,"buffer",{get:O.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var I;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(I=Function.prototype[Symbol.hasInstance],Object.defineProperty(s,Symbol.hasInstance,{value:function(e){return!!I.call(this,e)||e&&e._writableState instanceof o}})):I=function(e){return e instanceof this},s.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},s.prototype.write=function(e,t,r){var i=this._writableState,o=!1,s=R.isBuffer(e);return"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=n),i.ended?a(this,r):(s||u(this,i,e,r))&&(i.pendingcb++,o=c(this,i,s,e,t,r)),o},s.prototype.cork=function(){this._writableState.corked++},s.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||y(this,e))},s.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},s.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},s.prototype._writev=null,s.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||E(this,n,r)}}).call(this,e("_process"))},{"./_stream_duplex":37,_process:32,buffer:22,"buffer-shims":21,"core-util-is":24,events:25,inherits:28,"process-nextick-args":31,"util-deprecate":52}],42:[function(e,t,r){"use strict";function n(){this.head=null,this.tail=null,this.length=0}var i=(e("buffer").Buffer,e("buffer-shims"));t.exports=n,n.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},n.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},n.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}},n.prototype.clear=function(){this.head=this.tail=null,this.length=0},n.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},n.prototype.concat=function(e){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var t=i.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t}},{buffer:22,"buffer-shims":21}],43:[function(e,t,r){(function(n){var i=function(){try{return e("stream")}catch(e){}}();r=t.exports=e("./lib/_stream_readable.js"),r.Stream=i||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"),!n.browser&&"disable"===n.env.READABLE_STREAM&&i&&(t.exports=i)}).call(this,e("_process"))},{"./lib/_stream_duplex.js":37,"./lib/_stream_passthrough.js":38,"./lib/_stream_readable.js":39,"./lib/_stream_transform.js":40,"./lib/_stream_writable.js":41,_process:32}],44:[function(e,t,r){(function(t){var n=e("./lib/request"),i=e("xtend"),o=e("builtin-status-codes"),s=e("url"),a=r;a.request=function(e,r){e="string"==typeof e?s.parse(e):i(e);var o=t.location.protocol.search(/^https?:$/)===-1?"http:":"",a=e.protocol||o,u=e.hostname||e.host,f=e.port,c=e.path||"/";u&&u.indexOf(":")!==-1&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(f?":"+f:"")+c,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var l=new n(e);return r&&l.on("response",r),l},a.get=function(e,t){var r=a.request(e,t);return r.end(),r},a.Agent=function(){},a.Agent.defaultMaxSockets=4,a.STATUS_CODES=o,a.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":46,"builtin-status-codes":23,url:50,xtend:54}],45:[function(e,t,r){(function(e){function t(){if(void 0!==o)return o;if(e.XMLHttpRequest){o=new e.XMLHttpRequest;try{o.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(e){o=null}}else o=null;return o}function n(e){var r=t();if(!r)return!1;try{return r.responseType=e,r.responseType===e}catch(e){}return!1}function i(e){return"function"==typeof e}r.fetch=i(e.fetch)&&i(e.ReadableStream),r.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),r.blobConstructor=!0}catch(e){}var o,s=void 0!==e.ArrayBuffer,a=s&&i(e.ArrayBuffer.prototype.slice);r.arraybuffer=r.fetch||s&&n("arraybuffer"),r.msstream=!r.fetch&&a&&n("ms-stream"),r.mozchunkedarraybuffer=!r.fetch&&s&&n("moz-chunked-arraybuffer"),r.overrideMimeType=r.fetch||!!t()&&i(t().overrideMimeType),r.vbArray=i(e.VBArray),o=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],46:[function(e,t,r){(function(r,n,i){function o(e,t){return a.fetch&&t?"fetch":a.mozchunkedarraybuffer?"moz-chunked-arraybuffer":a.msstream?"ms-stream":a.arraybuffer&&e?"arraybuffer":a.vbArray&&e?"text:vbarray":"text"}function s(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}}var a=e("./capability"),u=e("inherits"),f=e("./response"),c=e("readable-stream"),l=e("to-arraybuffer"),h=f.IncomingMessage,d=f.readyStates,p=t.exports=function(e){var t=this;c.Writable.call(t),t._opts=e,t._body=[],t._headers={},e.auth&&t.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(r){t.setHeader(r,e.headers[r])});var r,n=!0;if("disable-fetch"===e.mode||"timeout"in e)n=!1,r=!0;else if("prefer-streaming"===e.mode)r=!1;else if("allow-wrong-content-type"===e.mode)r=!a.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");r=!0}t._mode=o(r,n),t.on("finish",function(){t._onFinish()})};u(p,c.Writable),p.prototype.setHeader=function(e,t){var r=this,n=e.toLowerCase();v.indexOf(n)===-1&&(r._headers[n]={name:e,value:t})},p.prototype.getHeader=function(e){return this._headers[e.toLowerCase()].value},p.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},p.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,o=e._headers,s=null;if("POST"!==t.method&&"PUT"!==t.method&&"PATCH"!==t.method&&"MERGE"!==t.method||(s=a.blobConstructor?new n.Blob(e._body.map(function(e){return l(e)}),{type:(o["content-type"]||{}).value||""}):i.concat(e._body).toString()),"fetch"===e._mode){var u=Object.keys(o).map(function(e){return[o[e].name,o[e].value]});n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin"}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var f=e._xhr=new n.XMLHttpRequest;try{f.open(e._opts.method,e._opts.url,!0)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}"responseType"in f&&(f.responseType=e._mode.split(":")[0]),"withCredentials"in f&&(f.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in f&&f.overrideMimeType("text/plain; charset=x-user-defined"),"timeout"in t&&(f.timeout=t.timeout,f.ontimeout=function(){e.emit("timeout")}),Object.keys(o).forEach(function(e){f.setRequestHeader(o[e].name,o[e].value)}),e._response=null,f.onreadystatechange=function(){switch(f.readyState){case d.LOADING:case d.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(f.onprogress=function(){e._onXHRProgress()}),f.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{f.send(s)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}}}},p.prototype._onXHRProgress=function(){var e=this;s(e._xhr)&&!e._destroyed&&(e._response||e._connect(),e._response._onXHRProgress())},p.prototype._connect=function(){var e=this;e._destroyed||(e._response=new h(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},p.prototype._write=function(e,t,r){this._body.push(e),r()},p.prototype.abort=p.prototype.destroy=function(){var e=this;e._destroyed=!0,e._response&&(e._response._destroyed=!0),e._xhr&&e._xhr.abort()},p.prototype.end=function(e,t,r){var n=this;"function"==typeof e&&(r=e,e=void 0),c.Writable.prototype.end.call(n,e,t,r)},p.prototype.flushHeaders=function(){},p.prototype.setTimeout=function(){},p.prototype.setNoDelay=function(){},p.prototype.setSocketKeepAlive=function(){};var v=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":45,"./response":47,_process:32,buffer:22,inherits:28,"readable-stream":43,"to-arraybuffer":49}],47:[function(e,t,r){(function(t,n,i){var o=e("./capability"),s=e("inherits"),a=e("readable-stream"),u=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},f=r.IncomingMessage=function(e,r,n){function s(){f.read().then(function(e){if(!u._destroyed){if(e.done)return void u.push(null);u.push(new i(e.value)),s()}}).catch(function(e){u.emit("error",e)})}var u=this;if(a.Readable.call(u),u._mode=n,u.headers={},u.rawHeaders=[],u.trailers={},u.rawTrailers=[],u.on("end",function(){t.nextTick(function(){u.emit("close")})}),"fetch"===n){u._fetchResponse=r,u.url=r.url,u.statusCode=r.status,u.statusMessage=r.statusText,r.headers.forEach(function(e,t){u.headers[t.toLowerCase()]=e,u.rawHeaders.push(t,e)});var f=r.body.getReader();s()}else{u._xhr=e,u._pos=0,u.url=e.responseURL,u.statusCode=e.status,u.statusMessage=e.statusText;if(e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();"set-cookie"===r?(void 0===u.headers[r]&&(u.headers[r]=[]),u.headers[r].push(t[2])):void 0!==u.headers[r]?u.headers[r]+=", "+t[2]:u.headers[r]=t[2],u.rawHeaders.push(t[1],t[2])}}),u._charset="x-user-defined",!o.overrideMimeType){var c=u.rawHeaders["mime-type"];if(c){var l=c.match(/;\s*charset=([^;])(;|$)/);l&&(u._charset=l[1].toLowerCase())}u._charset||(u._charset="utf-8")}}};s(f,a.Readable),f.prototype._read=function(){},f.prototype._onXHRProgress=function(){var e=this,t=e._xhr,r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(e){}if(null!==r){e.push(new i(r));break}case"text":try{r=t.responseText}catch(t){e._mode="text:vbarray";break}if(r.length>e._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var s=new i(o.length),a=0;ae._pos&&(e.push(new i(new Uint8Array(f.result.slice(e._pos)))),e._pos=f.result.byteLength)},f.onload=function(){e.push(null)},f.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":45,_process:32,buffer:22,inherits:28,"readable-stream":43}],48:[function(e,t,r){function n(e){if(e&&!u(e))throw new Error("Unknown encoding: "+e)}function i(e){return e.toString(this.encoding)}function o(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function s(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var a=e("buffer").Buffer,u=a.isEncoding||function(e){switch(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}},f=r.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),n(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=i)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};f.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,n=t.charCodeAt(i);if(n>=55296&&n<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},f.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},f.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t}},{buffer:22}],49:[function(e,t,r){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;i",'"',"`"," ","\r","\n","\t"],p=["{","}","|","\\","^","`"].concat(d),v=["'"].concat(p),g=["%","/","?",";","#"].concat(v),y=["/","?","#"],m={javascript:!0,"javascript:":!0},b={javascript:!0,"javascript:":!0},w={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},E=e("querystring");n.prototype.parse=function(e,t,r){if(!f.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var n=e.indexOf("?"),i=n!==-1&&n127?I+="x":I+=j[C];if(!I.match(/^[+a-z0-9A-Z_-]{0,63}$/)){var B=O.slice(0,T),M=O.slice(T+1),N=j.match(/^([+a-z0-9A-Z_-]{0,63})(.*)$/);N&&(B.push(N[1]),M.unshift(N[2])),M.length&&(s="/"+M.join(".")+s),this.hostname=B.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),k||(this.hostname=u.toASCII(this.hostname));var q=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+q,this.href+=this.host,k&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==s[0]&&(s="/"+s))}if(!m[d])for(var T=0,R=v.length;T0)&&r.host.split("@");x&&(r.auth=x.shift(),r.host=r.hostname=x.shift())}return r.search=e.search,r.query=e.query,f.isNull(r.pathname)&&f.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!T.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var S=T.slice(-1)[0],k=(r.host||e.host||T.length>1)&&("."===S||".."===S)||""===S,O=0,R=T.length;R>=0;R--)S=T[R],"."===S?T.splice(R,1):".."===S?(T.splice(R,1),O++):O&&(T.splice(R,1),O--);if(!E&&!_)for(;O--;O)T.unshift("..");!E||""===T[0]||T[0]&&"/"===T[0].charAt(0)||T.unshift(""),k&&"/"!==T.join("/").substr(-1)&&T.push("");var j=""===T[0]||T[0]&&"/"===T[0].charAt(0);if(A){r.hostname=r.host=j?"":T.length?T.shift():"";var x=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");x&&(r.auth=x.shift(),r.host=r.hostname=x.shift())}return E=E||r.host&&T.length,E&&!j&&T.unshift(""),T.length?r.pathname=T.join("/"):(r.pathname=null,r.path=null),f.isNull(r.pathname)&&f.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},n.prototype.parseHost=function(){var e=this.host,t=l.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":51,punycode:33,querystring:36}],51:[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}}},{}],52:[function(e,t,r){(function(e){function r(e,t){function r(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}if(n("noDeprecation"))return e;var i=!1;return r}function n(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=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],53:[function(e,t,r){(function(t,n){var i=e("url"),o=e("child_process").spawn,s=e("fs");r.XMLHttpRequest=function(){"use strict";var r,a,u=this,f=e("http"),c=e("https"),l={},h=!1,d={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},p={},v={},g=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],y=["TRACE","TRACK","CONNECT"],m=!1,b=!1,w={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null,this.withCredentials=!1;var E=function(e){return h||e&&g.indexOf(e.toLowerCase())===-1},_=function(e){return e&&y.indexOf(e)===-1};this.open=function(e,t,r,n,i){if(this.abort(),b=!1,!_(e))throw new Error("SecurityError: Request method not allowed");l={method:e,url:t.toString(),async:"boolean"!=typeof r||r,user:n||null,password:i||null},T(this.OPENED)},this.setDisableHeaderCheck=function(e){h=e},this.setRequestHeader=function(e,t){if(this.readyState!==this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!E(e))return void console.warn('Refused to set unsafe header "'+e+'"');if(m)throw new Error("INVALID_STATE_ERR: send flag is true");e=v[e.toLowerCase()]||e,v[e.toLowerCase()]=e,p[e]=p[e]?p[e]+", "+t:t},this.getResponseHeader=function(e){return"string"==typeof e&&this.readyState>this.OPENED&&a&&a.headers&&a.headers[e.toLowerCase()]&&!b?a.headers[e.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState0},function(e,n){if(e)return r(e);var i=t.returnAll?c:n;return r(null,i)})},n.prototype.getInputs=function(e,t,r){function n(e){i.getBalances(e,100,function(t,n){if(t)return r(t);for(var i={inputs:[],totalBalance:0},o=!f,s=0;s0){var l={address:e[s],balance:u,keyIndex:a+s,security:c};if(i.inputs.push(l),i.totalBalance+=u,f&&i.totalBalance>=f){o=!0;break}}}return o?r(null,i):r(new Error("Not enough balance"))})}var i=this;if(2===arguments.length&&"[object Function]"===Object.prototype.toString.call(t)&&(r=t,t={}),!s.isTrytes(e))return r(o.invalidSeed());var a=t.start||0,u=t.end||null,f=t.threshold||null,c=t.security||2;if(a>u||u>a+500)return r(new Error("Invalid inputs provided"));if(u){for(var l=[],h=a;h=r){var a=i-r;a>0&&p?(g.addEntry(1,p,a,d,s),l(t)):a>0?h.getNewAddress(e,{security:v},function(e,r){var n=Math.floor(Date.now()/1e3);g.addEntry(1,r,a,d,n),l(t)}):l(t)}else r-=i}}function l(t){g.finalize(),g.addTrytes(m);for(var r=0;r2187){w+=Math.floor(t[b].message.length/2187);for(var E=t[b].message;E;){var _=E.slice(0,2187);E=E.slice(2187,E.length);for(var T=0;_.length<2187;T++)_+="9";m.push(_)}}else{var _="";t[b].message&&(_=t[b].message.slice(0,2187));for(var T=0;_.length<2187;T++)_+="9";m.push(_)}var A=Math.floor(Date.now()/1e3);d=t[b].tag?t[b].tag:"999999999999999999999999999";for(var T=0;d.length<27;T++)d+="9";g.addEntry(w,t[b].address,t[b].value,d,A),y+=parseInt(t[b].value)}if(!y){g.finalize(),g.addTrytes(m);var x=[];return g.bundle.forEach(function(e){x.push(c.transactionTrytes(e))}),n(null,x.reverse())}if(r.inputs){var S=[];r.inputs.forEach(function(e){S.push(e.address)}),h.getBalances(S,100,function(e,t){for(var o=[],s=0,a=0;a0){s+=u;var f=r.inputs[a];if(f.balance=u,o.push(f),s>=y)break}}if(y>s)return n(new Error("Not enough balance"));i(o)})}else h.getInputs(e,{threshold:y,security:v},function(e,t){if(e)return n(e);i(t.inputs)})},n.prototype.traverseBundle=function(e,t,r,n){var i=this;i.getTrytes(Array(e),function(e,o){if(e)return n(e);var s=o[0];if(!s)return n(new Error("Bundle transactions not visible"));var a=c.transactionObject(s);if(!a)return n(new Error("Invalid trytes, could not create object"));if(!t&&0!==a.currentIndex)return n(new Error("Invalid tail transaction supplied."));if(t||(t=a.bundle),t!==a.bundle)return n(null,r);if(0===a.lastIndex&&0===a.currentIndex)return n(null,Array(a));var u=a.trunkTransaction;return r.push(a),i.traverseBundle(u,t,r,n)})},n.prototype.getBundle=function(e,t){var r=this;if(!s.isHash(e))return t(o.invalidInputs(e));r.traverseBundle(e,null,Array(),function(e,r){return e?t(e):c.isBundle(r)?t(null,r):t(new Error("Invalid Bundle provided"))})},n.prototype._bundlesFromAddresses=function(e,t,r){var n=this;n.findTransactionObjects({addresses:e},function(e,i){if(e)return r(e);var o=new Set,s=new Set;i.forEach(function(e){0===e.currentIndex?o.add(e.hash):s.add(e.bundle)}),n.findTransactionObjects({bundles:Array.from(s)},function(e,i){if(e)return r(e);i.forEach(function(e){0===e.currentIndex&&o.add(e.hash)});var s=[],a=Array.from(o);l.waterfall([function(e){t?n.getLatestInclusion(a,function(t,n){if(t)return r(t);e(null,n)}):e(null,[])},function(e,i){l.mapSeries(a,function(r,i){n.getBundle(r,function(n,o){if(!n){if(t){var u=e[a.indexOf(r)];o.forEach(function(e){e.persistence=u})}s.push(o)}i(null,!0)})},function(e,t){return s.sort(function(e,t){var r=parseInt(e[0].timestamp),n=parseInt(t[0].timestamp);return rn?1:0}),r(e,s)})}])})})},n.prototype.getTransfers=function(e,t,r){var n=this;if(2===arguments.length&&"[object Function]"===Object.prototype.toString.call(t)&&(r=t,t={}),!s.isTrytes(e))return r(o.invalidSeed(e));var i=t.start||0,a=t.end||null,u=t.inclusionStates||null,f=t.security||2;if(i>a||a>i+500)return r(new Error("Invalid inputs provided"));var c={index:i,total:a?a-i:null,returnAll:!0,security:f};n.getNewAddress(e,c,function(e,t){return e?r(e):n._bundlesFromAddresses(t,u,r)})},n.prototype.getAccountData=function(e,t,r){var n=this;if(2===arguments.length&&"[object Function]"===Object.prototype.toString.call(t)&&(r=t,t={}),!s.isTrytes(e))return r(o.invalidSeed(e));var i=t.start||0,a=t.end||null,u=t.security||2;if(i>a||a>i+1e3)return r(new Error("Invalid inputs provided"));var f={latestAddress:"",addresses:[],transfers:[],inputs:[],balance:0},c={index:i,total:a?a-i:null,returnAll:!0,security:u};n.getNewAddress(e,c,function(e,t){if(e)return r(e);f.latestAddress=t[t.length-1],f.addresses=t.slice(0,-1),n._bundlesFromAddresses(t,!0,function(e,t){if(e)return r(e);f.transfers=t,n.getBalances(f.addresses,100,function(e,t){return t.balances.forEach(function(e,t){var e=parseInt(e);if(f.balance+=e,e>0){var r={address:f.addresses[t],keyIndex:t,security:u,balance:e};f.inputs.push(r)}}),r(null,f)})})})},n.prototype.shouldYouReplay=function(e,t){var r=this;if(!s.isAddress(e))return t(o.invalidInputs());var e=c.noChecksum(e);r.findTransactionObjects({addresses:new Array(e)},function(e,n){if(e)return t(e);var i=[];if(n.forEach(function(e){e.value<0&&i.push(e.hash)}),!(i.length>0))return t(null,!0);r.getLatestInclusion(i,function(e,r){return t(null,r.indexOf(!0)===-1)})})},t.exports=n},{"../crypto/bundle":4,"../crypto/converter":5,"../crypto/curl":6,"../crypto/signing":7,"../errors/inputErrors":8,"../utils/inputValidator":14,"../utils/utils":16,"./apiCommands":3,async:17}],3:[function(e,t,r){var n=function(e,t,r,n){return{command:"attachToTangle",trunkTransaction:e,branchTransaction:t,minWeightMagnitude:r,trytes:n}},i=function(e){var t={command:"findTransactions"};return Object.keys(e).forEach(function(r){t[r]=e[r]}),t},o=function(e,t){return{command:"getBalances",addresses:e,threshold:t}},s=function(e,t){return{command:"getInclusionStates",transactions:e,tips:t}},a=function(){return{command:"getNodeInfo"}},u=function(){return{command:"getNeighbors"}},f=function(e){return{command:"addNeighbors",uris:e}},c=function(e){return{command:"removeNeighbors",uris:e}},l=function(){return{command:"getTips"}},h=function(e){return{command:"getTransactionsToApprove",depth:e}},d=function(e){return{command:"getTrytes",hashes:e}},p=function(){return{command:"interruptAttachingToTangle"}},v=function(e){return{command:"broadcastTransactions",trytes:e}},g=function(e){return{command:"storeTransactions",trytes:e}};t.exports={attachToTangle:n,findTransactions:i,getBalances:o,getInclusionStates:s,getNodeInfo:a,getNeighbors:u,addNeighbors:f,removeNeighbors:c,getTips:l,getTransactionsToApprove:h,getTrytes:d,interruptAttachingToTangle:p,broadcastTransactions:v,storeTransactions:g}},{}],4:[function(e,t,r){function n(){this.bundle=[]}var i=e("./curl"),o=e("./converter");n.prototype.addEntry=function(e,t,r,n,i,o){for(var s=0;s=0){for(;n-- >0;)for(var i=0;i<27;i++)if(t[27*r+i]>-13){t[27*r+i]--;break}}else for(;n++<0;)for(var i=0;i<27;i++)if(t[27*r+i]<13){t[27*r+i]++;break}}return t},t.exports=n},{"./converter":5,"./curl":6}],5:[function(e,t,r){var n="9ABCDEFGHIJKLMNOPQRSTUVWXYZ",i=[[0,0,0],[1,0,0],[-1,1,0],[0,1,0],[1,1,0],[-1,-1,1],[0,-1,1],[1,-1,1],[-1,0,1],[0,0,1],[1,0,1],[-1,1,1],[0,1,1],[1,1,1],[-1,-1,-1],[0,-1,-1],[1,-1,-1],[-1,0,-1],[0,0,-1],[1,0,-1],[-1,1,-1],[0,1,-1],[1,1,-1],[-1,-1,0],[0,-1,0],[1,-1,0],[-1,0,0]],o=function(e,t){var r=t||[];if(Number.isInteger(e)){for(var o=e<0?-e:e;o>0;){var s=o%3;o=Math.floor(o/3),s>1&&(s=-1,o++),r[r.length]=s}if(e<0)for(var a=0;a0;)t=3*t+e[r];return t};t.exports={trits:o,trytes:s,value:a}},{}],6:[function(e,t,r){function n(){this.truthTable=[1,0,-1,1,-1,0,-1,1,0]}e("./converter");n.prototype.initialize=function(e){if(e)this.state=e;else{this.state=[];for(var t=0;t<729;t++)this.state[t]=0}},n.prototype.absorb=function(e){for(var t=0;t1;s++)i[s]=-1;var a=new n;a.initialize(),a.absorb(i),a.squeeze(i),a.initialize(),a.absorb(i);for(var u=[],f=0,c=[];r-- >0;)for(var o=0;o<27;o++){a.squeeze(c);for(var s=0;s<243;s++)u[f++]=c[s]}return u},a=function(e){for(var t=[],r=[],i=0;i0;){var a=new n;a.initialize(),a.absorb(r),a.squeeze(r)}i.absorb(r)}return i.squeeze(r),r},c=function(e,t){for(var r=t.slice(),i=[],o=new n,s=0;s<27;s++){i=r.slice(243*s,243*(s+1));for(var a=0;a<13-e[s];a++)o.initialize(),o.absorb(i),o.squeeze(i);for(var a=0;a<243;a++)r[243*s+a]=i[a]}return r},l=function(e,t,r){for(var n=this,s=new o,a=[],u=s.normalizedBundle(r),c=0;c<3;c++)a[c]=u.slice(27*c,27*(c+1));for(var l=[],c=0;c2187){v+=Math.floor(n[p].message.length/2187);for(var g=n[p].message;g;){var y=g.slice(0,2187);g=g.slice(2187,g.length);for(var m=0;y.length<2187;m++)y+="9";d.push(y)}}else{var y="";n[p].message&&(y=n[p].message.slice(0,2187));for(var m=0;y.length<2187;m++)y+="9";d.push(y)}var b=Math.floor(Date.now()/1e3);s=n[p].tag?n[p].tag:"999999999999999999999999999";for(var m=0;s.length<27;m++)s+="9";l.addEntry(v,n[p].address.slice(0,81),n[p].value,s,b),h+=parseInt(n[p].value)}if(!h)return i(new Error("Invalid value transfer: the transfer does not require a signature."));var w={command:"getBalances",addresses:new Array(t),threshold:100};o._makeRequest.send(w,function(n,o){var a=parseInt(o.balances[0]);if(a>0){var u=0-a,f=Math.floor(Date.now()/1e3);l.addEntry(e,t,u,s,f)}if(h>a)return i(new Error("Not enough balance."));if(a>h){var c=a-h;if(!r)return i(new Error("No remainder address defined"));l.addEntry(1,r,c,s,f)}return l.finalize(),l.addTrytes(d),i(null,l.bundle)})},n.prototype.addSignature=function(e,t,r,n){var s=new a;s.bundle=e;for(var u=r.length/2187,r=o.trits(r),c=0,l=0;l255)return null;var o=i%27,s=(i-o)/27;t+="9ABCDEFGHIJKLMNOPQRSTUVWXYZ"[o]+"9ABCDEFGHIJKLMNOPQRSTUVWXYZ"[s]}return t}function i(e){if("string"!=typeof e)return null;for(var t="9ABCDEFGHIJKLMNOPQRSTUVWXYZ",r="",n=0;n-1){var s=i.currentIndex===i.lastIndex&&0!==i.lastIndex;i.value<0&&!n&&!s?(r.sent.push(e),n=!0):i.value>=0&&!n&&!s&&r.received.push(e)}})}),r},y=function(e,t){for(var r,i=[],o=0;o-1&&e%1==0&&e<=wt}function v(e){return null!=e&&p(e.length)&&!d(e)}function g(){}function y(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}function m(e,t){for(var r=-1,n=Array(e);++r-1&&e%1==0&&ei?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n=n?e:K(e,t,r)}function Z(e,t){for(var r=e.length;r--&&G(t,e[r],0)>-1;);return r}function Q(e,t){for(var r=-1,n=e.length;++r-1;);return r}function ee(e){return e.split("")}function te(e){return dr.test(e)}function re(e){return e.match(_r)||[]}function ne(e){return te(e)?re(e):ee(e)}function ie(e){return null==e?"":J(e)}function oe(e,t,r){if((e=ie(e))&&(r||void 0===t))return e.replace(Tr,"");if(!e||!(t=J(t)))return e;var n=ne(e),i=ne(t);return Y(n,Q(n,i),Z(n,i)+1).join("")}function se(e){return e=e.toString().replace(kr,""),e=e.match(Ar)[2].replace(" ",""),e=e?e.split(xr):[],e=e.map(function(e){return oe(e.replace(Sr,""))})}function ae(e,t){var r={};z(e,function(e,t){function n(t,r){var n=$(i,function(e){return t[e]});n.push(r),e.apply(null,n)}var i;if(jt(e))i=e.slice(0,-1),e=e[e.length-1],r[t]=i.concat(i.length>0?n:e);else if(1===e.length)r[t]=e;else{if(i=se(e),0===e.length&&0===i.length)throw new Error("autoInject task functions require explicit parameters.");i.pop(),r[t]=i.concat(n)}}),ur(r,t)}function ue(e){setTimeout(e,0)}function fe(e){return a(function(t,r){e(function(){t.apply(null,r)})})}function ce(){this.head=this.tail=null,this.length=0}function le(e,t){e.length=1,e.head=e.tail=t}function he(e,t,r){function n(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,jt(e)||(e=[e]),0===e.length&&f.idle())return Rr(function(){f.drain()});for(var n=0,i=e.length;n=0&&s.splice(a),i.callback.apply(i,t),null!=t[0]&&f.error(t[0],i.data)}o<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()})}if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var o=0,s=[],u=!1,f={_tasks:new ce,concurrency:t,payload:r,saturated:g,unsaturated:g,buffer:t/4,empty:g,drain:g,error:g,started:!1,paused:!1,push:function(e,t){n(e,!1,t)},kill:function(){f.drain=g,f._tasks.empty()},unshift:function(e,t){n(e,!0,t)},process:function(){if(!u){for(u=!0;!f.paused&&o1&&(n=t),r(null,{value:n})}})),e.apply(this,t)})}function ze(e,t,r,n){Ie(e,t,function(e,t){r(e,function(e,r){t(e,!r)})},n)}function He(e){var t;return jt(e)?t=$(e,Pe):(t={},z(e,function(e,r){t[r]=Pe.call(this,e)})),t}function Ve(e){return function(){return e}}function We(e,t,r){function n(){t(function(e){e&&a++n?1:0}tr(e,function(e,r){t(e,function(t,n){if(t)return r(t);r(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,$(t.sort(n),Oe("value")))})}function Xe(e,t,r){function n(){a||(o.apply(null,arguments),clearTimeout(s))}function i(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),a=!0,o(n)}var o,s,a=!1;return rt(function(r,a){o=a,s=setTimeout(i,t),e.apply(null,r.concat(n))})}function Je(e,t,r,n){for(var i=-1,o=ln(cn((t-e)/(r||1)),0),s=Array(o);o--;)s[n?o:++i]=e,e+=r;return s}function Ke(e,t,r,n){nr(Je(0,e,1),t,r,n)}function Ye(e,t,r,n){3===arguments.length&&(n=r,r=t,t=jt(e)?[]:{}),n=y(n||g),er(e,function(e,n,i){r(t,e,n,i)},function(e){n(e,t)})}function Ze(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Qe(e,t,r){if(r=L(r||g),!e())return r(null);var n=a(function(i,o){return i?r(i):e()?t(n):void r.apply(null,[null].concat(o))});t(n)}function et(e,t,r){Qe(function(){return!e.apply(this,arguments)},t,r)}var tt=Math.max,rt=function(e){return a(function(t){var r=t.pop();e.call(this,t,r)})},nt="object"==typeof n&&n&&n.Object===Object&&n,it="object"==typeof self&&self&&self.Object===Object&&self,ot=nt||it||Function("return this")(),st=ot.Symbol,at=Object.prototype,ut=at.hasOwnProperty,ft=at.toString,ct=st?st.toStringTag:void 0,lt=Object.prototype,ht=lt.toString,dt="[object Null]",pt="[object Undefined]",vt=st?st.toStringTag:void 0,gt="[object AsyncFunction]",yt="[object Function]",mt="[object GeneratorFunction]",bt="[object Proxy]",wt=9007199254740991,Et={},_t="function"==typeof Symbol&&Symbol.iterator,Tt=function(e){return _t&&e[_t]&&e[_t]()},At="[object Arguments]",xt=Object.prototype,St=xt.hasOwnProperty,kt=xt.propertyIsEnumerable,Ot=w(function(){return arguments}())?w:function(e){return b(e)&&St.call(e,"callee")&&!kt.call(e,"callee")},jt=Array.isArray,Rt="object"==typeof r&&r&&!r.nodeType&&r,It=Rt&&"object"==typeof t&&t&&!t.nodeType&&t,Lt=It&&It.exports===Rt,Ct=Lt?ot.Buffer:void 0,Bt=Ct?Ct.isBuffer:void 0,Mt=Bt||E,Nt=9007199254740991,qt=/^(?:0|[1-9]\d*)$/,Ut={};Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Arguments]"]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object Boolean]"]=Ut["[object DataView]"]=Ut["[object Date]"]=Ut["[object Error]"]=Ut["[object Function]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut["[object Object]"]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object WeakMap]"]=!1;var Ft,Dt="object"==typeof r&&r&&!r.nodeType&&r,Pt=Dt&&"object"==typeof t&&t&&!t.nodeType&&t,zt=Pt&&Pt.exports===Dt,Ht=zt&&nt.process,Vt=function(){try{return Ht&&Ht.binding&&Ht.binding("util")}catch(e){}}(),Wt=Vt&&Vt.isTypedArray,Gt=Wt?function(e){return function(t){return e(t)}}(Wt):T,$t=Object.prototype,Xt=$t.hasOwnProperty,Jt=Object.prototype,Kt=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),Yt=Object.prototype,Zt=Yt.hasOwnProperty,Qt=M(B,1/0),er=function(e,t,r){(v(e)?N:Qt)(e,t,r)},tr=q(U),rr=u(tr),nr=F(U),ir=M(nr,1),or=u(ir),sr=a(function(e,t){return a(function(r){return e.apply(null,t.concat(r))})}),ar=function(e){return function(t,r,n){for(var i=-1,o=Object(t),s=n(t),a=s.length;a--;){var u=s[e?a:++i];if(r(o[u],u,o)===!1)break}return t}}(),ur=function(e,t,r){function n(e,t){m.push(function(){u(e,t)})}function i(){if(0===m.length&&0===d)return r(null,h);for(;m.length&&d1?i(h,n):i(n)}}function f(t){var r=[];return z(e,function(e,n){jt(e)&&G(e,t,0)>=0&&r.push(n)}),r}"function"==typeof t&&(r=t,t=null),r=y(r||g);var c=k(e),l=c.length;if(!l)return r(null);t||(t=l);var h={},d=0,p=!1,v=Object.create(null),m=[],b=[],w={};z(e,function(t,r){if(!jt(t))return n(r,[t]),void b.push(r);var i=t.slice(0,t.length-1),s=i.length;if(0===s)return n(r,t),void b.push(r);w[r]=s,P(i,function(a){if(!e[a])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+a+"` in "+i.join(", "));o(a,function(){0===--s&&n(r,t)})})}),function(){for(var e,t=0;b.length;)e=b.pop(),t++,P(f(e),function(e){0==--w[e]&&b.push(e)});if(t!==l)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),i()},fr="[object Symbol]",cr=1/0,lr=st?st.prototype:void 0,hr=lr?lr.toString:void 0,dr=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]"),pr="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",vr="\\ud83c[\\udffb-\\udfff]",gr="(?:\\ud83c[\\udde6-\\uddff]){2}",yr="[\\ud800-\\udbff][\\udc00-\\udfff]",mr="(?:"+pr+"|"+vr+")?",br="(?:\\u200d(?:"+["[^\\ud800-\\udfff]",gr,yr].join("|")+")[\\ufe0e\\ufe0f]?"+mr+")*",wr="[\\ufe0e\\ufe0f]?"+mr+br,Er="(?:"+["[^\\ud800-\\udfff]"+pr+"?",pr,gr,yr,"[\\ud800-\\udfff]"].join("|")+")",_r=RegExp(vr+"(?="+vr+")|"+Er+wr,"g"),Tr=/^\s+|\s+$/g,Ar=/^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,xr=/,/,Sr=/(=.+)?(\s*)$/,kr=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,Or="function"==typeof setImmediate&&setImmediate,jr="object"==typeof e&&"function"==typeof e.nextTick;Ft=Or?setImmediate:jr?e.nextTick:ue;var Rr=fe(Ft);ce.prototype.removeLink=function(e){return e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,e.prev=e.next=null,this.length-=1,e},ce.prototype.empty=ce,ce.prototype.insertAfter=function(e,t){t.prev=e,t.next=e.next,e.next?e.next.prev=t:this.tail=t,e.next=t,this.length+=1},ce.prototype.insertBefore=function(e,t){t.prev=e.prev,t.next=e,e.prev?e.prev.next=t:this.head=t,e.prev=t,this.length+=1},ce.prototype.unshift=function(e){this.head?this.insertBefore(this.head,e):le(this,e)},ce.prototype.push=function(e){this.tail?this.insertAfter(this.tail,e):le(this,e)},ce.prototype.shift=function(){return this.head&&this.removeLink(this.head)},ce.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)};var Ir,Lr=M(B,1),Cr=a(function(e){return a(function(t){var r=this,n=t[t.length-1];"function"==typeof n?t.pop():n=g,pe(e,t,function(e,t,n){t.apply(r,e.concat(a(function(e,t){n(e,t)})))},function(e,t){n.apply(r,[e].concat(t))})})}),Br=a(function(e){return Cr.apply(null,e.reverse())}),Mr=q(ve),Nr=function(e){return function(t,r,n){return e(Lr,t,r,n)}}(ve),qr=a(function(e){var t=[null].concat(e);return rt(function(e,r){return r.apply(this,t)})}),Ur=q(ge(s,ye)),Fr=F(ge(s,ye)),Dr=M(Fr,1),Pr=me("dir"),zr=M(xe,1),Hr=q(ge(ke,ke)),Vr=F(ge(ke,ke)),Wr=M(Vr,1),Gr=q(Ie),$r=F(Ie),Xr=M($r,1),Jr=me("log"),Kr=M(Ce,1/0),Yr=M(Ce,1);Ir=jr?e.nextTick:Or?setImmediate:ue;var Zr=fe(Ir),Qr=function(e,t){return he(function(t,r){e(t[0],r)},t,1)},en=function(e,t){var r=Qr(e,t);return r.push=function(e,t,n){if(null==n&&(n=g),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,jt(e)||(e=[e]),0===e.length)return Rr(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,s=e.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function i(e){return 3*e.length/4-n(e)}function o(e){var t,r,i,o,s,a,u=e.length;s=n(e),a=new l(3*u/4-s),i=s>0?u-4:u;var f=0;for(t=0,r=0;t>16&255,a[f++]=o>>8&255,a[f++]=255&o;return 2===s?(o=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,a[f++]=255&o):1===s&&(o=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,a[f++]=o>>8&255,a[f++]=255&o),a}function s(e){return f[e>>18&63]+f[e>>12&63]+f[e>>6&63]+f[63&e]}function a(e,t,r){for(var n,i=[],o=t;ou?u:s+16383));return 1===n?(t=e[r-1],i+=f[t>>2],i+=f[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=f[t>>10],i+=f[t>>4&63],i+=f[t<<2&63],i+="="),o.push(i),o.join("")}r.byteLength=i,r.toByteArray=o,r.fromByteArray=u;for(var f=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=h.length;ds)throw new RangeError("size is too large");var n=r,o=t;void 0===o&&(n=void 0,o=0);var a=new i(e);if("string"==typeof o)for(var u=new i(o,n),f=u.length,c=-1;++cs)throw new RangeError("size is too large");return new i(e)},r.from=function(e,r,n){if("function"==typeof i.from&&(!t.Uint8Array||Uint8Array.from!==i.from))return i.from(e,r,n);if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("string"==typeof e)return new i(e,r);if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var o=r;if(1===arguments.length)return new i(e);void 0===o&&(o=0);var s=n;if(void 0===s&&(s=e.byteLength-o),o>=e.byteLength)throw new RangeError("'offset' is out of bounds");if(s>e.byteLength-o)throw new RangeError("'length' is out of bounds");return new i(e.slice(o,o+s))}if(i.isBuffer(e)){var a=new i(e.length);return e.copy(a,0,0,e.length),a}if(e){if(Array.isArray(e)||"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return new i(e);if("Buffer"===e.type&&Array.isArray(e.data))return new i(e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},r.allocUnsafeSlow=function(e){if("function"==typeof i.allocUnsafeSlow)return i.allocUnsafeSlow(e);if("number"!=typeof e)throw new TypeError("size must be a number");if(e>=s)throw new RangeError("size is too large");return new o(e)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{buffer:22}],22:[function(e,t,r){"use strict";function n(e){if(e>J)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=i.prototype,t}function i(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 u(e)}return o(e,t,r)}function o(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return e instanceof ArrayBuffer?l(e,t,r):"string"==typeof e?f(e,t):h(e)}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 a(e,t,r){return s(e),e<=0?n(e):void 0!==t?"string"==typeof r?n(e).fill(t,r):n(e).fill(t):n(e)}function u(e){return s(e),n(e<0?0:0|d(e))}function f(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!i.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var r=0|v(e,t),o=n(r),s=o.write(e,t);return s!==r&&(o=o.slice(0,s)),o}function c(e){for(var t=e.length<0?0:0|d(e.length),r=n(t),i=0;i=J)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+J.toString(16)+" bytes");return 0|e}function p(e){return+e!=e&&(e=0),i.alloc(+e)}function v(e,t){if(i.isBuffer(e))return e.length;if(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 P(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(e).length;default:if(n)return P(e).length;t=(""+t).toLowerCase(),n=!0}}function g(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,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return k(this,t,r);case"ascii":return j(this,t,r);case"latin1":case"binary":return R(this,t,r);case"base64":return S(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,o){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=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=i.from(t,n)),i.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){function o(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}var s=1,a=e.length,u=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,u/=2,r/=2}var f;if(i){var c=-1;for(f=r;fa&&(r=a-u),f=r;f>=0;f--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s239?4:o>223?3:o>191?2:1;if(i+a<=r){var u,f,c,l;switch(a){case 1:o<128&&(s=o);break;case 2:u=e[i+1],128==(192&u)&&(l=(31&o)<<6|63&u)>127&&(s=l);break;case 3:u=e[i+1],f=e[i+2],128==(192&u)&&128==(192&f)&&(l=(15&o)<<12|(63&u)<<6|63&f)>2047&&(l<55296||l>57343)&&(s=l);break;case 4:u=e[i+1],f=e[i+2],c=e[i+3],128==(192&u)&&128==(192&f)&&128==(192&c)&&(l=(15&o)<<18|(63&u)<<12|(63&f)<<6|63&c)>65535&&l<1114112&&(s=l)}}null===s?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=a}return O(n)}function O(e){var t=e.length;if(t<=K)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function B(e,t,r,n,o,s){if(!i.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function M(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 N(e,t,r,n,i){return t=+t,r>>>=0,i||M(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(e,t,r,n,23,4),r+4}function q(e,t,r,n,i){return t=+t,r>>>=0,i||M(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(e,t,r,n,52,8),r+8}function U(e){if(e=F(e).replace(Y,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function F(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function D(e){return e<16?"0"+e.toString(16):e.toString(16)}function P(e,t){t=t||1/0;for(var r,n=e.length,i=null,o=[],s=0;s55295&&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 z(e){for(var t=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function V(e){return $.toByteArray(U(e))}function W(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function G(e){return e!==e}var $=e("base64-js"),X=e("ieee754");r.Buffer=i,r.SlowBuffer=p,r.INSPECT_MAX_BYTES=50;var J=2147483647;r.kMaxLength=J,i.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),"undefined"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),i.poolSize=8192,i.from=function(e,t,r){return o(e,t,r)},i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,i.alloc=function(e,t,r){return a(e,t,r)},i.allocUnsafe=function(e){return u(e)},i.allocUnsafeSlow=function(e){return u(e)},i.isBuffer=function(e){return null!=e&&e._isBuffer===!0},i.compare=function(e,t){if(!i.isBuffer(e)||!i.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,s=Math.min(r,n);o0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},i.prototype.compare=function(e,t,r,n,o){if(!i.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===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,o>>>=0,this===e)return 0;for(var s=o-n,a=r-t,u=Math.min(s,a),f=this.slice(n,o),c=e.slice(t,r),l=0;l>>=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 w(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return T(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var K=4096;i.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||C(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=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},i.prototype.readUInt8=function(e,t){return e>>>=0,t||C(e,1,this.length),this[e]},i.prototype.readUInt16LE=function(e,t){return e>>>=0,t||C(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUInt16BE=function(e,t){return e>>>=0,t||C(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUInt32LE=function(e,t){return e>>>=0,t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUInt32BE=function(e,t){return e>>>=0,t||C(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||C(e,t,this.length);for(var n=this[e],i=1,o=0;++o=i&&(n-=Math.pow(2,8*t)),n},i.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||C(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},i.prototype.readInt8=function(e,t){return e>>>=0,t||C(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},i.prototype.readInt16LE=function(e,t){e>>>=0,t||C(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(e,t){e>>>=0,t||C(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(e,t){return e>>>=0,t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return e>>>=0,t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readFloatLE=function(e,t){return e>>>=0,t||C(e,4,this.length),X.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return e>>>=0,t||C(e,4,this.length),X.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return e>>>=0,t||C(e,8,this.length),X.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return e>>>=0,t||C(e,8,this.length),X.read(this,e,!1,52,8)},i.prototype.writeUIntLE=function(e,t,r,n){if(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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.prototype.writeFloatLE=function(e,t,r){return N(this,e,t,!0,r)},i.prototype.writeFloatBE=function(e,t,r){return N(this,e,t,!1,r)},i.prototype.writeDoubleLE=function(e,t,r){return q(this,e,t,!0,r)},i.prototype.writeDoubleBE=function(e,t,r){return q(this,e,t,!1,r)},i.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=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=0;--i)e[i+t]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var s;if("number"==typeof e)for(s=t;s0&&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){function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var n=!1;return r.listener=t,this.on(e,r),this},n.prototype.removeListener=function(e,t){var r,n,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],o=r.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(s(r)){for(a=o;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(r=this._events[e],i(r))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)}},{}],26:[function(e,t,r){var n=e("http"),i=t.exports;for(var o in n)n.hasOwnProperty(o)&&(i[o]=n[o]);i.request=function(e,t){return e||(e={}),e.scheme="https",e.protocol="https:",n.request.call(this,e,t)}},{http:44}],27:[function(e,t,r){r.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=a;c>0;o=256*o+e[t+l],l+=h,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+e[t+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)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,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=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=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+l>=1?h/u:h*Math.pow(2,1-l),t*u>=2&&(s++,u/=2),s+l>=c?(a=0,s=c):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-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*v}},{}],28:[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}},{}],29:[function(e,t,r){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function i(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}t.exports=function(e){return null!=e&&(n(e)||i(e)||!!e._isBuffer)}},{}],30:[function(e,t,r){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],31:[function(e,t,r){(function(e){"use strict";function r(t,r,n,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,r)});case 3:return e.nextTick(function(){t.call(null,r,n)});case 4:return e.nextTick(function(){t.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s1)for(var r=1;r1&&(n=r[0]+"@",e=r[1]),e=e.replace(L,"."),n+o(e.split("."),t).join(".")}function a(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(e-=65536,t+=N(e>>>10&1023|55296),e=56320|1023&e),t+=N(e)}).join("")}function f(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:_}function c(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function l(e,t,r){var n=0;for(e=r?M(e/S):e>>1,e+=M(e/t);e>B*A>>1;n+=_)e=M(e/B);return M(n+(B+1)*e/(e+x))}function h(e){var t,r,n,o,s,a,c,h,d,p,v=[],g=e.length,y=0,m=O,b=k;for(r=e.lastIndexOf(j),r<0&&(r=0),n=0;n=128&&i("not-basic"),v.push(e.charCodeAt(n));for(o=r>0?r+1:0;o=g&&i("invalid-input"),h=f(e.charCodeAt(o++)),(h>=_||h>M((E-y)/a))&&i("overflow"),y+=h*a,d=c<=b?T:c>=b+A?A:c-b,!(hM(E/p)&&i("overflow"),a*=p;t=v.length+1,b=l(y-s,t,0==s),M(y/t)>E-m&&i("overflow"),m+=M(y/t),y%=t,v.splice(y++,0,m)}return u(v)}function d(e){var t,r,n,o,s,u,f,h,d,p,v,g,y,m,b,w=[];for(e=a(e),g=e.length,t=O,r=0,s=k,u=0;u=t&&vM((E-r)/y)&&i("overflow"),r+=(f-t)*y,t=f,u=0;uE&&i("overflow"),v==t){for(h=r,d=_;p=d<=s?T:d>=s+A?A:d-s,!(h= 0x80 (not a basic code point)","invalid-input":"Invalid input"},B=_-T,M=Math.floor,N=String.fromCharCode;if(b={version:"1.4.1",ucs2:{decode:a,encode:u},decode:h,encode:d,toASCII:v,toUnicode:p},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return b});else if(g&&y)if(t.exports==g)y.exports=b;else for(w in b)b.hasOwnProperty(w)&&(g[w]=b[w]);else n.punycode=b}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],34:[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;e=e.split(t);var a=1e3;o&&"number"==typeof o.maxKeys&&(a=o.maxKeys);var u=e.length;a>0&&u>a&&(u=a);for(var f=0;f=0?(c=p.substr(0,v),l=p.substr(v+1)):(c=p,l=""),h=decodeURIComponent(c),d=decodeURIComponent(l),n(s,h)?i(s[h])?s[h].push(d):s[h]=[s[h],d]:s[h]=d}return s};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],35:[function(e,t,r){"use strict";function n(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var u=new Error("stream.unshift() after end event");e.emit("error",u)}else{var f;!t.decoder||i||n||(r=t.decoder.write(r),f=!t.objectMode&&0===r.length),i||(t.reading=!1),f||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&h(e))),p(e,t)}else i||(t.reading=!1);return a(t)}function a(e){return!e.ended&&(e.needReadable||e.length=P?e=P:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function f(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=u(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function c(e,t){var r=null;return B.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function l(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,h(e)}}function h(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(U("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?R(d,e):d(e))}function d(e){U("emit readable"),e.emit("readable"),w(e)}function p(e,t){t.readingMore||(t.readingMore=!0,R(v,e,t))}function v(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=_(e,t.buffer,t.decoder),r}function _(e,t,r){var n;return 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}function A(e,t){var r=M.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;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}function x(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,R(S,t,e))}function S(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function k(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return U("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?x(this):h(this),null;if(0===(e=f(e,t))&&t.ended)return 0===t.length&&x(this),null;var n=t.needReadable;U("need readable",n),(0===t.length||t.length-e0?E(e,t):null,null===i?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&x(this)),null!==i&&this.emit("data",i),i},o.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},o.prototype.pipe=function(e,t){function i(e){U("onunpipe"),e===h&&s()}function o(){U("onend"),e.end()}function s(){U("cleanup"),e.removeListener("close",f),e.removeListener("finish",c),e.removeListener("drain",y),e.removeListener("error",u),e.removeListener("unpipe",i),h.removeListener("end",o),h.removeListener("end",s),h.removeListener("data",a),m=!0,!d.awaitDrain||e._writableState&&!e._writableState.needDrain||y()}function a(t){U("ondata"),b=!1,!1!==e.write(t)||b||((1===d.pipesCount&&d.pipes===e||d.pipesCount>1&&O(d.pipes,e)!==-1)&&!m&&(U("false write response, pause",h._readableState.awaitDrain),h._readableState.awaitDrain++,b=!0),h.pause())}function u(t){U("onerror",t),l(),e.removeListener("error",u),0===C(e,"error")&&e.emit("error",t)}function f(){e.removeListener("finish",c),l()}function c(){U("onfinish"),e.removeListener("close",f),l()}function l(){U("unpipe"),h.unpipe(e)}var h=this,d=this._readableState;switch(d.pipesCount){case 0:d.pipes=e;break;case 1:d.pipes=[d.pipes,e];break;default:d.pipes.push(e)}d.pipesCount+=1,U("pipe count=%d opts=%j",d.pipesCount,t);var p=(!t||t.end!==!1)&&e!==r.stdout&&e!==r.stderr,v=p?o:s;d.endEmitted?R(v):h.once("end",v),e.on("unpipe",i);var y=g(h);e.on("drain",y);var m=!1,b=!1;return h.on("data",a),n(e,"error",u),e.once("close",f),e.once("finish",c),e.emit("pipe",h),d.flowing||(U("pipe resume"),h.resume()),e},o.prototype.unpipe=function(e){var t=this._readableState;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),this);if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1?setImmediate:A;s.WritableState=o;var S=e("core-util-is");S.inherits=e("inherits");var k,O={deprecate:e("util-deprecate")};!function(){try{k=e("stream")}catch(e){}finally{k||(k=e("events").EventEmitter)}}();var j=e("buffer").Buffer,R=e("buffer-shims");S.inherits(s,k),o.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(o.prototype,"buffer",{get:O.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var I;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(I=Function.prototype[Symbol.hasInstance],Object.defineProperty(s,Symbol.hasInstance,{value:function(e){return!!I.call(this,e)||e&&e._writableState instanceof o}})):I=function(e){return e instanceof this},s.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},s.prototype.write=function(e,t,r){var i=this._writableState,o=!1,s=j.isBuffer(e);return"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=n),i.ended?a(this,r):(s||u(this,i,e,r))&&(i.pendingcb++,o=c(this,i,s,e,t,r)),o},s.prototype.cork=function(){this._writableState.corked++},s.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||y(this,e))},s.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},s.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},s.prototype._writev=null,s.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||E(this,n,r)}}).call(this,e("_process"))},{"./_stream_duplex":37,_process:32,buffer:22,"buffer-shims":21,"core-util-is":24,events:25,inherits:28,"process-nextick-args":31,"util-deprecate":52}],42:[function(e,t,r){"use strict";function n(){this.head=null,this.tail=null,this.length=0}var i=(e("buffer").Buffer,e("buffer-shims"));t.exports=n,n.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},n.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},n.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}},n.prototype.clear=function(){this.head=this.tail=null,this.length=0},n.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},n.prototype.concat=function(e){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var t=i.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t}},{buffer:22,"buffer-shims":21}],43:[function(e,t,r){(function(n){var i=function(){try{return e("stream")}catch(e){}}();r=t.exports=e("./lib/_stream_readable.js"),r.Stream=i||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"),!n.browser&&"disable"===n.env.READABLE_STREAM&&i&&(t.exports=i)}).call(this,e("_process"))},{"./lib/_stream_duplex.js":37,"./lib/_stream_passthrough.js":38,"./lib/_stream_readable.js":39,"./lib/_stream_transform.js":40,"./lib/_stream_writable.js":41,_process:32}],44:[function(e,t,r){(function(t){var n=e("./lib/request"),i=e("xtend"),o=e("builtin-status-codes"),s=e("url"),a=r;a.request=function(e,r){e="string"==typeof e?s.parse(e):i(e);var o=t.location.protocol.search(/^https?:$/)===-1?"http:":"",a=e.protocol||o,u=e.hostname||e.host,f=e.port,c=e.path||"/";u&&u.indexOf(":")!==-1&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(f?":"+f:"")+c,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var l=new n(e);return r&&l.on("response",r),l},a.get=function(e,t){var r=a.request(e,t);return r.end(),r},a.Agent=function(){},a.Agent.defaultMaxSockets=4,a.STATUS_CODES=o,a.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":46,"builtin-status-codes":23,url:50,xtend:54}],45:[function(e,t,r){(function(e){function t(){if(void 0!==o)return o;if(e.XMLHttpRequest){o=new e.XMLHttpRequest;try{o.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(e){o=null}}else o=null;return o}function n(e){var r=t();if(!r)return!1;try{return r.responseType=e,r.responseType===e}catch(e){}return!1}function i(e){return"function"==typeof e}r.fetch=i(e.fetch)&&i(e.ReadableStream),r.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),r.blobConstructor=!0}catch(e){}var o,s=void 0!==e.ArrayBuffer,a=s&&i(e.ArrayBuffer.prototype.slice);r.arraybuffer=r.fetch||s&&n("arraybuffer"),r.msstream=!r.fetch&&a&&n("ms-stream"),r.mozchunkedarraybuffer=!r.fetch&&s&&n("moz-chunked-arraybuffer"),r.overrideMimeType=r.fetch||!!t()&&i(t().overrideMimeType),r.vbArray=i(e.VBArray),o=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],46:[function(e,t,r){(function(r,n,i){function o(e,t){return a.fetch&&t?"fetch":a.mozchunkedarraybuffer?"moz-chunked-arraybuffer":a.msstream?"ms-stream":a.arraybuffer&&e?"arraybuffer":a.vbArray&&e?"text:vbarray":"text"}function s(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}}var a=e("./capability"),u=e("inherits"),f=e("./response"),c=e("readable-stream"),l=e("to-arraybuffer"),h=f.IncomingMessage,d=f.readyStates,p=t.exports=function(e){var t=this;c.Writable.call(t),t._opts=e,t._body=[],t._headers={},e.auth&&t.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(r){t.setHeader(r,e.headers[r])});var r,n=!0;if("disable-fetch"===e.mode||"timeout"in e)n=!1,r=!0;else if("prefer-streaming"===e.mode)r=!1;else if("allow-wrong-content-type"===e.mode)r=!a.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");r=!0}t._mode=o(r,n),t.on("finish",function(){t._onFinish()})};u(p,c.Writable),p.prototype.setHeader=function(e,t){var r=this,n=e.toLowerCase();v.indexOf(n)===-1&&(r._headers[n]={name:e,value:t})},p.prototype.getHeader=function(e){return this._headers[e.toLowerCase()].value},p.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},p.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,o=e._headers,s=null;if("POST"!==t.method&&"PUT"!==t.method&&"PATCH"!==t.method&&"MERGE"!==t.method||(s=a.blobConstructor?new n.Blob(e._body.map(function(e){return l(e)}),{type:(o["content-type"]||{}).value||""}):i.concat(e._body).toString()),"fetch"===e._mode){var u=Object.keys(o).map(function(e){return[o[e].name,o[e].value]});n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin"}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var f=e._xhr=new n.XMLHttpRequest;try{f.open(e._opts.method,e._opts.url,!0)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}"responseType"in f&&(f.responseType=e._mode.split(":")[0]),"withCredentials"in f&&(f.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in f&&f.overrideMimeType("text/plain; charset=x-user-defined"),"timeout"in t&&(f.timeout=t.timeout,f.ontimeout=function(){e.emit("timeout")}),Object.keys(o).forEach(function(e){f.setRequestHeader(o[e].name,o[e].value)}),e._response=null,f.onreadystatechange=function(){switch(f.readyState){case d.LOADING:case d.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(f.onprogress=function(){e._onXHRProgress()}),f.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{f.send(s)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}}}},p.prototype._onXHRProgress=function(){var e=this;s(e._xhr)&&!e._destroyed&&(e._response||e._connect(),e._response._onXHRProgress())},p.prototype._connect=function(){var e=this;e._destroyed||(e._response=new h(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},p.prototype._write=function(e,t,r){this._body.push(e),r()},p.prototype.abort=p.prototype.destroy=function(){var e=this;e._destroyed=!0,e._response&&(e._response._destroyed=!0),e._xhr&&e._xhr.abort()},p.prototype.end=function(e,t,r){var n=this;"function"==typeof e&&(r=e,e=void 0),c.Writable.prototype.end.call(n,e,t,r)},p.prototype.flushHeaders=function(){},p.prototype.setTimeout=function(){},p.prototype.setNoDelay=function(){},p.prototype.setSocketKeepAlive=function(){};var v=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":45,"./response":47,_process:32,buffer:22,inherits:28,"readable-stream":43,"to-arraybuffer":49}],47:[function(e,t,r){(function(t,n,i){var o=e("./capability"),s=e("inherits"),a=e("readable-stream"),u=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},f=r.IncomingMessage=function(e,r,n){function s(){f.read().then(function(e){if(!u._destroyed){if(e.done)return void u.push(null);u.push(new i(e.value)),s()}}).catch(function(e){u.emit("error",e)})}var u=this;if(a.Readable.call(u),u._mode=n,u.headers={},u.rawHeaders=[],u.trailers={},u.rawTrailers=[],u.on("end",function(){t.nextTick(function(){u.emit("close")})}),"fetch"===n){u._fetchResponse=r,u.url=r.url,u.statusCode=r.status,u.statusMessage=r.statusText,r.headers.forEach(function(e,t){u.headers[t.toLowerCase()]=e,u.rawHeaders.push(t,e)});var f=r.body.getReader();s()}else{u._xhr=e,u._pos=0,u.url=e.responseURL,u.statusCode=e.status,u.statusMessage=e.statusText;if(e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();"set-cookie"===r?(void 0===u.headers[r]&&(u.headers[r]=[]),u.headers[r].push(t[2])):void 0!==u.headers[r]?u.headers[r]+=", "+t[2]:u.headers[r]=t[2],u.rawHeaders.push(t[1],t[2])}}),u._charset="x-user-defined",!o.overrideMimeType){var c=u.rawHeaders["mime-type"];if(c){var l=c.match(/;\s*charset=([^;])(;|$)/);l&&(u._charset=l[1].toLowerCase())}u._charset||(u._charset="utf-8")}}};s(f,a.Readable),f.prototype._read=function(){},f.prototype._onXHRProgress=function(){var e=this,t=e._xhr,r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(e){}if(null!==r){e.push(new i(r));break}case"text":try{r=t.responseText}catch(t){e._mode="text:vbarray";break}if(r.length>e._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var s=new i(o.length),a=0;ae._pos&&(e.push(new i(new Uint8Array(f.result.slice(e._pos)))),e._pos=f.result.byteLength)},f.onload=function(){e.push(null)},f.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":45,_process:32,buffer:22,inherits:28,"readable-stream":43}],48:[function(e,t,r){function n(e){if(e&&!u(e))throw new Error("Unknown encoding: "+e)}function i(e){return e.toString(this.encoding)}function o(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function s(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var a=e("buffer").Buffer,u=a.isEncoding||function(e){switch(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}},f=r.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),n(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=i)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};f.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,n=t.charCodeAt(i);if(n>=55296&&n<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},f.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},f.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t}},{buffer:22}],49:[function(e,t,r){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;i",'"',"`"," ","\r","\n","\t"],p=["{","}","|","\\","^","`"].concat(d),v=["'"].concat(p),g=["%","/","?",";","#"].concat(v),y=["/","?","#"],m={javascript:!0,"javascript:":!0},b={javascript:!0,"javascript:":!0},w={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},E=e("querystring");n.prototype.parse=function(e,t,r){if(!f.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var n=e.indexOf("?"),i=n!==-1&&n127?I+="x":I+=R[L];if(!I.match(/^[+a-z0-9A-Z_-]{0,63}$/)){var B=O.slice(0,T),M=O.slice(T+1),N=R.match(/^([+a-z0-9A-Z_-]{0,63})(.*)$/);N&&(B.push(N[1]),M.unshift(N[2])),M.length&&(s="/"+M.join(".")+s),this.hostname=B.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),k||(this.hostname=u.toASCII(this.hostname));var q=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+q,this.href+=this.host,k&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==s[0]&&(s="/"+s))}if(!m[d])for(var T=0,j=v.length;T0)&&r.host.split("@");x&&(r.auth=x.shift(),r.host=r.hostname=x.shift())}return r.search=e.search,r.query=e.query,f.isNull(r.pathname)&&f.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!T.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var S=T.slice(-1)[0],k=(r.host||e.host||T.length>1)&&("."===S||".."===S)||""===S,O=0,j=T.length;j>=0;j--)S=T[j],"."===S?T.splice(j,1):".."===S?(T.splice(j,1),O++):O&&(T.splice(j,1),O--);if(!E&&!_)for(;O--;O)T.unshift("..");!E||""===T[0]||T[0]&&"/"===T[0].charAt(0)||T.unshift(""),k&&"/"!==T.join("/").substr(-1)&&T.push("");var R=""===T[0]||T[0]&&"/"===T[0].charAt(0);if(A){r.hostname=r.host=R?"":T.length?T.shift():"";var x=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");x&&(r.auth=x.shift(),r.host=r.hostname=x.shift())}return E=E||r.host&&T.length,E&&!R&&T.unshift(""),T.length?r.pathname=T.join("/"):(r.pathname=null,r.path=null),f.isNull(r.pathname)&&f.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},n.prototype.parseHost=function(){var e=this.host,t=l.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":51,punycode:33,querystring:36}],51:[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}}},{}],52:[function(e,t,r){(function(e){function r(e,t){function r(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}if(n("noDeprecation"))return e;var i=!1;return r}function n(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=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],53:[function(e,t,r){(function(t,n){var i=e("url"),o=e("child_process").spawn,s=e("fs");r.XMLHttpRequest=function(){"use strict";var r,a,u=this,f=e("http"),c=e("https"),l={},h=!1,d={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},p={},v={},g=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],y=["TRACE","TRACK","CONNECT"],m=!1,b=!1,w={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null,this.withCredentials=!1;var E=function(e){return h||e&&g.indexOf(e.toLowerCase())===-1},_=function(e){return e&&y.indexOf(e)===-1};this.open=function(e,t,r,n,i){if(this.abort(),b=!1,!_(e))throw new Error("SecurityError: Request method not allowed");l={method:e,url:t.toString(),async:"boolean"!=typeof r||r,user:n||null,password:i||null},T(this.OPENED)},this.setDisableHeaderCheck=function(e){h=e},this.setRequestHeader=function(e,t){if(this.readyState!==this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!E(e))return void console.warn('Refused to set unsafe header "'+e+'"');if(m)throw new Error("INVALID_STATE_ERR: send flag is true");e=v[e.toLowerCase()]||e,v[e.toLowerCase()]=e,p[e]=p[e]?p[e]+", "+t:t},this.getResponseHeader=function(e){return"string"==typeof e&&this.readyState>this.OPENED&&a&&a.headers&&a.headers[e.toLowerCase()]&&!b?a.headers[e.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState end || end > (start + 500)) { + // or if difference between end and start is bigger than 1000 keys + if (start > end || end > (start + 1000)) { return callback(new Error("Invalid inputs provided")) } // These are the values that will be returned to the original caller - // @addresses all addresses associated with this seed - // @transfers all sent / received transfers - // @balance the confirmed balance + // @latestAddress: latest unused address + // @addresses: all addresses associated with this seed that have been used + // @transfers: all sent / received transfers + // @inputs: all inputs of the account + // @balance: the confirmed balance var valuesToReturn = { - 'addresses' : [], - 'transfers' : [], - 'balance' : 0 + 'latestAddress' : '', + 'addresses' : [], + 'transfers' : [], + 'inputs' : [], + 'balance' : 0 } // first call findTransactions @@ -1626,8 +1629,12 @@ api.prototype.getAccountData = function(seed, options, callback) { if (error) return callback(error); + // assign the last address as the latest address + // since it has no transactions associated with it + valuesToReturn.latestAddress = addresses[addresses.length - 1]; + // Add all returned addresses to the lsit of addresses - // remove the last element as that is the most recent + // remove the last element as that is the most recent address valuesToReturn.addresses = addresses.slice(0, -1); // get all bundles from a list of addresses @@ -1641,8 +1648,24 @@ api.prototype.getAccountData = function(seed, options, callback) { // Get the correct balance count of all addresses self.getBalances(valuesToReturn.addresses, 100, function(error, balances) { - balances.balances.forEach(function(balance) { - valuesToReturn.balance += parseInt(balance); + balances.balances.forEach(function(balance, index) { + + var balance = parseInt(balance); + + valuesToReturn.balance += balance; + + if (balance > 0) { + + var newInput = { + 'address': valuesToReturn.addresses[index], + 'keyIndex': index, + 'security': security, + 'balance': balance + } + + valuesToReturn.inputs.push(newInput); + + } }) return callback(null, valuesToReturn); @@ -1659,39 +1682,45 @@ api.prototype.getAccountData = function(seed, options, callback) { * @param {String} inputAddress Input address you want to have tested * @returns {Bool} **/ -api.prototype.shouldYouReplay = function(inputAddress) { +api.prototype.shouldYouReplay = function(inputAddress, callback) { var self = this; - var inputAddress = Utils.noChecksum(inputAddress); - - self.findTransactions( { 'address': inputAddress }, function( e, transactions ) { + if (!inputValidator.isAddress(inputAddress)) { - self.getTrytes(transactions, function(e, txTrytes) { + return callback(errors.invalidInputs()); - var valueTransactions = []; + } - txTrytes.forEach(function(trytes) { - var thisTransaction = Utils.transactionObject(txTrytes); + var inputAddress = Utils.noChecksum(inputAddress); - if (thisTransaction.value < 0) { + self.findTransactionObjects( { 'addresses': new Array(inputAddress) }, function( e, transactions ) { - valueTransactions.push(thisTransaction.hash); + if (e) return callback(e); - } - }) + var valueTransactions = []; - if ( valueTransactions.length > 0 ) { + transactions.forEach(function(thisTransaction) { - self.getLatestInclusion( valueTransactions, function( e, inclusionStates ) { + if (thisTransaction.value < 0) { - return inclusionStates.indexOf(true) === -1; - }) - } else { + valueTransactions.push(thisTransaction.hash); - return true; } }) + + if ( valueTransactions.length > 0 ) { + + self.getLatestInclusion( valueTransactions, function( e, inclusionStates ) { + + return callback(null, inclusionStates.indexOf( true ) === -1); + + }) + + } else { + + return callback(null, true); + } }) } diff --git a/lib/iota.js b/lib/iota.js index d3a0ed218..5d0e0e767 100644 --- a/lib/iota.js +++ b/lib/iota.js @@ -8,6 +8,7 @@ function IOTA(settings) { // IF NO SETTINGS, SET DEFAULT TO localhost:14265 settings = settings || {}; + this.version = require('../package.json').version; this.host = settings.host ? settings.host : "http://localhost"; this.port = settings.port ? settings.port : 14265; this.provider = settings.provider || this.host.replace(/\/$/, '') + ":" + this.port; diff --git a/package.json b/package.json index d3f36decf..b823c0ca1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iota.lib.js", - "version": "0.2.4", + "version": "0.2.5", "description": "Javascript Library for IOTA", "main": "./lib/iota.js", "scripts": {