forked from BrainJS/brain.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser.min.js
24 lines (20 loc) · 51.2 KB
/
browser.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
Copyright (c) 2010-2016 Heather Arthur
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";b.exports={NeuralNetwork:a("./neural-network"),crossValidate:a("./cross-validate")}},{"./cross-validate":2,"./neural-network":4}],2:[function(a,b,c){"use strict";function d(a,b,c,d,e){var f=new a(b),g=Date.now(),h=f.train(d,c),i=Date.now(),j=f.test(e),k=Date.now(),l=Object.assign({},j,{trainTime:i-g,testTime:k-i,iterations:h.iterations,trainError:h.error,learningRate:c.learningRate,hidden:f.hiddenSizes,network:f.toJSON()});return l}function e(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a}function f(a,b,c,f,g){g=g||4;var h=b.length/g;if(b.constructor===Array)e(b);else{var i={};e(Object.keys(b)).forEach(function(a){i[a]=b[a]}),b=i}for(var j,k,l={error:0,trainTime:0,testTime:0,iterations:0,trainError:0},m={truePos:0,trueNeg:0,falsePos:0,falseNeg:0,total:0},n=[],o=[],p=0;g>p;p++){var q=b.slice(0),r=q.splice(p*h,h),s=q,t=d(a,c,f,s,r);for(j in l)l.hasOwnProperty(j)&&(k=l[j],l[j]=k+t[j]);for(j in m)m.hasOwnProperty(j)&&(k=m[j],m[j]=k+t[j]);n.concat(o.misclasses),o.push(t)}for(j in l)l.hasOwnProperty(j)&&(k=l[j],l[j]=k/g);return m.precision=m.truePos/(m.truePos+m.falsePos),m.recall=m.truePos/(m.truePos+m.falseNeg),m.accuracy=(m.trueNeg+m.truePos)/m.total,m.testSize=h,m.trainSize=b.length-h,{avgs:l,stats:m,sets:o,misclasses:n}}b.exports=f},{}],3:[function(a,b,c){"use strict";function d(a){var b=a.reduce(function(a,b){return Object.assign(a,b)},{});return e(b)}function e(a){var b={},c=0;for(var d in a)b[d]=c++;return b}function f(a,b){var c=[];for(var d in a)c[a[d]]=b[d]||0;return c}function g(a,b){var c={};for(var d in a)c[d]=b[a[d]];return c}function h(a){for(var b={},c=0,d=a.length;d-->0;)b[a[d]]=c++;return b}b.exports={buildLookup:d,lookupFromHash:e,toArray:f,toHash:g,lookupFromArray:h}},{}],4:[function(a,b,c){"use strict";function d(a){a=a||{},this.learningRate=a.learningRate||.3,this.momentum=a.momentum||.1,this.hiddenSizes=a.hiddenLayers,this.binaryThresh=a.binaryThresh||.5,this.sizes=null,this.outputLayer=null,this.biases=null,this.weights=null,this.outputs=null,this.deltas=null,this.changes=null,this.errors=null}function e(){return.4*Math.random()-.2}function f(a){for(var b=new Array(a),c=0;a>c;c++)b[c]=0;return b}function g(a){for(var b=new Array(a),c=0;a>c;c++)b[c]=e();return b}function h(a){for(var b=0,c=0;c<a.length;c++)b+=Math.pow(a[c],2);return b/a.length}function i(a,b){for(var c=[];b>a;a++)c.push(a);return c}function j(a){return a=a||[],a.constructor===Array?a:Object.keys(a).map(function(b){return a[b]})}function k(a){return Math.max.apply(Math,j(a))}var l=a("./lookup"),m=a("./train-stream");d.prototype={initialize:function(a,b){this.sizes=a,this.outputLayer=this.sizes.length-1,b||(this.biases=[],this.weights=[],this.outputs=[]),this.deltas=[],this.changes=[],this.errors=[];for(var c=0;c<=this.outputLayer;c++){var d=this.sizes[c];if(this.deltas[c]=f(d),this.errors[c]=f(d),b||(this.outputs[c]=f(d)),c>0){this.biases[c]=g(d),b||(this.weights[c]=new Array(d)),this.changes[c]=new Array(d);for(var e=0;d>e;e++){var h=this.sizes[c-1];b||(this.weights[c][e]=g(h)),this.changes[c][e]=f(h)}}}},run:function(a){this.inputLookup&&(a=l.toArray(this.inputLookup,a));var b=this.runInput(a);return this.outputLookup&&(b=l.toHash(this.outputLookup,b)),b},runInput:function(a){this.outputs[0]=a;for(var b=1;b<=this.outputLayer;b++){for(var c=0;c<this.sizes[b];c++){for(var d=this.weights[b][c],e=this.biases[b][c],f=0;f<d.length;f++)e+=d[f]*a[f];this.outputs[b][c]=1/(1+Math.exp(-e))}var g=a=this.outputs[b]}return g},train:function(a,b){a=this.formatData(a),b=b||{};var c=b.iterations||2e4,d=b.errorThresh||.005,e=b.log?"function"==typeof b.log?b.log:console.log:!1,f=b.logPeriod||10,g=b.learningRate||this.learningRate||.3,h=b.callback,i=b.callbackPeriod||10,j=[],k=a[0].input.length,l=a[0].output.length,m=this.hiddenSizes;m?m.forEach(function(a){j.push(a)}):j.push(Math.max(3,Math.floor(k/2))),j.unshift(k),j.push(l),this.initialize(j,b.keepNetworkIntact);for(var n=1,o=0;c>o&&n>d;o++){for(var p=0,q=0;q<a.length;q++){var r=this.trainPattern(a[q].input,a[q].output,g);p+=r}n=p/a.length,e&&o%f==0&&e("iterations:",o,"training error:",n),h&&o%i==0&&h({error:n,iterations:o})}return{error:n,iterations:o}},trainPattern:function(a,b,c){c=c||this.learningRate,this.runInput(a),this.calculateDeltas(b),this.adjustWeights(c);var d=h(this.errors[this.outputLayer]);return d},calculateDeltas:function(a){for(var b=this.outputLayer;b>=0;b--)for(var c=0;c<this.sizes[b];c++){var d=this.outputs[b][c],e=0;if(b==this.outputLayer)e=a[c]-d;else for(var f=this.deltas[b+1],g=0;g<f.length;g++)e+=f[g]*this.weights[b+1][g][c];this.errors[b][c]=e,this.deltas[b][c]=e*d*(1-d)}},adjustWeights:function(a){for(var b=1;b<=this.outputLayer;b++)for(var c=this.outputs[b-1],d=0;d<this.sizes[b];d++){for(var e=this.deltas[b][d],f=0;f<c.length;f++){var g=this.changes[b][d][f];g=a*e*c[f]+this.momentum*g,this.changes[b][d][f]=g,this.weights[b][d][f]+=g}this.biases[b][d]+=a*e}},formatData:function(a){if(a.constructor!==Array){var b=[];b.push(a),a=b}var c=a[0].input;return c.constructor===Array||c instanceof Float64Array||(this.inputLookup||(this.inputLookup=l.buildLookup(a.map(function(a){return a.input}))),a=a.map(function(a){var b=l.toArray(this.inputLookup,a.input);return Object.assign({},a,{input:b})},this)),a[0].output.constructor!==Array&&(this.outputLookup||(this.outputLookup=l.buildLookup(a.map(function(a){return a.output}))),a=a.map(function(a){var b=l.toArray(this.outputLookup,a.output);return Object.assign({},a,{output:b})},this)),a},test:function(a){a=this.formatData(a);for(var b=1==a[0].output.length,c=0,d=0,e=0,f=0,g=[],i=0,j=0;j<a.length;j++){var l,m,n=this.runInput(a[j].input),o=a[j].output;if(b?(l=n[0]>this.binaryThresh?1:0,m=o[0]):(l=n.indexOf(k(n)),m=o.indexOf(k(o))),l!=m){var p=a[j];Object.assign(p,{actual:l,expected:m}),g.push(p)}b&&(0==l&&0==m?f++:1==l&&1==m?e++:0==l&&1==m?d++:1==l&&0==m&&c++);var q=n.map(function(a,b){return o[b]-a});i+=h(q)}var r=i/a.length,s={error:r,misclasses:g};return b&&Object.assign(s,{trueNeg:f,truePos:e,falseNeg:d,falsePos:c,total:a.length,precision:e/(e+c),recall:e/(e+d),accuracy:(f+e)/a.length}),s},toJSON:function(){for(var a=[],b=0;b<=this.outputLayer;b++){a[b]={};var c;c=0==b&&this.inputLookup?Object.keys(this.inputLookup):b==this.outputLayer&&this.outputLookup?Object.keys(this.outputLookup):i(0,this.sizes[b]);for(var d=0;d<c.length;d++){var e=c[d];if(a[b][e]={},b>0){a[b][e].bias=this.biases[b][d],a[b][e].weights={};for(var f in a[b-1]){var g=f;1==b&&this.inputLookup&&(g=this.inputLookup[f]),a[b][e].weights[f]=this.weights[b][d][g]}}}}return{layers:a,outputLookup:!!this.outputLookup,inputLookup:!!this.inputLookup}},fromJSON:function(a){var b=a.layers.length;this.outputLayer=b-1,this.sizes=new Array(b),this.weights=new Array(b),this.biases=new Array(b),this.outputs=new Array(b);for(var c=0;c<=this.outputLayer;c++){var d=a.layers[c];0!=c||d[0]&&!a.inputLookup?c!=this.outputLayer||d[0]&&!a.outputLookup||(this.outputLookup=l.lookupFromHash(d)):this.inputLookup=l.lookupFromHash(d);var e=Object.keys(d);this.sizes[c]=e.length,this.weights[c]=[],this.biases[c]=[],this.outputs[c]=[];for(var f in e){var g=e[f];this.biases[c][f]=d[g].bias,this.weights[c][f]=j(d[g].weights)}}return this},toFunction:function(){var a=this.toJSON();return new Function("input"," var net = "+JSON.stringify(a)+";\n\n for (var i = 1; i < net.layers.length; i++) {\n var layer = net.layers[i];\n var output = {};\n \n for (var id in layer) {\n var node = layer[id];\n var sum = node.bias;\n \n for (var iid in node.weights) {\n sum += node.weights[iid] * input[iid];\n }\n output[id] = (1 / (1 + Math.exp(-sum)));\n }\n input = output;\n }\n return output;")},createTrainStream:function(a){return a=a||{},a.neuralNetwork=this,this.trainStream=new m(a),this.trainStream}},b.exports=d},{"./lookup":3,"./train-stream":5}],5:[function(a,b,c){"user strict";function d(a){if(g.call(this,{objectMode:!0}),a=a||{},!a.neuralNetwork)throw new Error("no neural network specified");return this.neuralNetwork=a.neuralNetwork,this.dataFormatDetermined=!1,this.inputKeys=[],this.outputKeys=[],this.i=0,this.iterations=a.iterations||2e4,this.errorThresh=a.errorThresh||.005,this.log=a.log?"function"==typeof a.log?a.log:console.log:!1,this.logPeriod=a.logPeriod||10,this.callback=a.callback,this.callbackPeriod=a.callbackPeriod||10,this.floodCallback=a.floodCallback,this.doneTrainingCallback=a.doneTrainingCallback,this.size=0,this.count=0,this.sum=0,this.on("finish",this.finishStreamIteration),this}function e(a){for(var b=[],c=0,d=a.length;d>c;c++)-1===b.indexOf(a[c])&&""!==a[c]&&b.push(a[c]);return b}var f=a("./lookup"),g=a("stream").Writable;d.prototype=Object.assign(Object.create(g.prototype),{_write:function(a,b,c){if(!a)return this.emit("finish"),c();if(!this.dataFormatDetermined)return this.size++,this.inputKeys=e(this.inputKeys.slice(0).concat(Object.keys(a.input))),this.outputKeys=e(this.outputKeys.slice(0).concat(Object.keys(a.output))),this.firstDatum=this.firstDatum||a,c();this.count++;var d=this.neuralNetwork.formatData(a);this.trainDatum(d[0]),c()},trainDatum:function(a){var b=this.neuralNetwork.trainPattern(a.input,a.output);this.sum+=b},finishStreamIteration:function(){if(this.dataFormatDetermined&&this.size!==this.count&&this.log("This iteration's data length was different from the first."),!this.dataFormatDetermined){this.neuralNetwork.inputLookup=f.lookupFromArray(this.inputKeys),this.firstDatum.output.constructor!==Array&&(this.neuralNetwork.outputLookup=f.lookupFromArray(this.outputKeys));var a=this.neuralNetwork.formatData(this.firstDatum),b=[],c=a[0].input.length,d=a[0].output.length,e=this.hiddenSizes;return e?e.forEach(function(a){b.push(a)}):b.push(Math.max(3,Math.floor(c/2))),b.unshift(c),b.push(d),this.dataFormatDetermined=!0,this.neuralNetwork.initialize(b),void("function"==typeof this.floodCallback&&this.floodCallback())}var g=this.sum/this.size;if(this.log&&this.i%this.logPeriod==0&&this.log("iterations:",this.i,"training error:",g),this.callback&&this.i%this.callbackPeriod==0&&this.callback({error:g,iterations:this.i}),this.sum=0,this.count=0,this.i++,this.i<this.iterations&&g>this.errorThresh){if("function"==typeof this.floodCallback)return this.floodCallback()}else if("function"==typeof this.doneTrainingCallback)return this.doneTrainingCallback({error:g,iterations:this.i})}}),b.exports=d},{"./lookup":3,stream:12}],6:[function(a,b,c){function d(a,b,c){if(!(this instanceof d))return new d(a,b,c);var e=typeof a;if("base64"===b&&"string"===e)for(a=C(a);a.length%4!==0;)a+="=";var f;if("number"===e)f=E(a);else if("string"===e)f=d.byteLength(a,b);else{if("object"!==e)throw new Error("First argument needs to be a number, array or string.");f=E(a.length)}var g;d._useTypedArrays?g=d._augment(new Uint8Array(f)):(g=this,g.length=f,g._isBuffer=!0);var h;if(d._useTypedArrays&&"number"==typeof a.byteLength)g._set(a);else if(G(a))for(h=0;f>h;h++)d.isBuffer(a)?g[h]=a.readUInt8(h):g[h]=a[h];else if("string"===e)g.write(a,0,b);else if("number"===e&&!d._useTypedArrays&&!c)for(h=0;f>h;h++)g[h]=0;return g}function e(a,b,c,e){c=Number(c)||0;var f=a.length-c;e?(e=Number(e),e>f&&(e=f)):e=f;var g=b.length;R(g%2===0,"Invalid hex string"),e>g/2&&(e=g/2);for(var h=0;e>h;h++){var i=parseInt(b.substr(2*h,2),16);R(!isNaN(i),"Invalid hex string"),a[c+h]=i}return d._charsWritten=2*h,h}function f(a,b,c,e){var f=d._charsWritten=M(I(b),a,c,e);return f}function g(a,b,c,e){var f=d._charsWritten=M(J(b),a,c,e);return f}function h(a,b,c,d){return g(a,b,c,d)}function i(a,b,c,e){var f=d._charsWritten=M(L(b),a,c,e);return f}function j(a,b,c,e){var f=d._charsWritten=M(K(b),a,c,e);return f}function k(a,b,c){return 0===b&&c===a.length?S.fromByteArray(a):S.fromByteArray(a.slice(b,c))}function l(a,b,c){var d="",e="";c=Math.min(a.length,c);for(var f=b;c>f;f++)a[f]<=127?(d+=N(e)+String.fromCharCode(a[f]),e=""):e+="%"+a[f].toString(16);return d+N(e)}function m(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(a[e]);return d}function n(a,b,c){return m(a,b,c)}function o(a,b,c){var d=a.length;(!b||0>b)&&(b=0),(!c||0>c||c>d)&&(c=d);for(var e="",f=b;c>f;f++)e+=H(a[f]);return e}function p(a,b,c){for(var d=a.slice(b,c),e="",f=0;f<d.length;f+=2)e+=String.fromCharCode(d[f]+256*d[f+1]);return e}function q(a,b,c,d){d||(R("boolean"==typeof c,"missing or invalid endian"),R(void 0!==b&&null!==b,"missing offset"),R(b+1<a.length,"Trying to read beyond buffer length"));var e=a.length;if(!(b>=e)){var f;return c?(f=a[b],e>b+1&&(f|=a[b+1]<<8)):(f=a[b]<<8,e>b+1&&(f|=a[b+1])),f}}function r(a,b,c,d){d||(R("boolean"==typeof c,"missing or invalid endian"),R(void 0!==b&&null!==b,"missing offset"),R(b+3<a.length,"Trying to read beyond buffer length"));var e=a.length;if(!(b>=e)){var f;return c?(e>b+2&&(f=a[b+2]<<16),e>b+1&&(f|=a[b+1]<<8),f|=a[b],e>b+3&&(f+=a[b+3]<<24>>>0)):(e>b+1&&(f=a[b+1]<<16),e>b+2&&(f|=a[b+2]<<8),e>b+3&&(f|=a[b+3]),f+=a[b]<<24>>>0),f}}function s(a,b,c,d){d||(R("boolean"==typeof c,"missing or invalid endian"),R(void 0!==b&&null!==b,"missing offset"),R(b+1<a.length,"Trying to read beyond buffer length"));var e=a.length;if(!(b>=e)){var f=q(a,b,c,!0),g=32768&f;return g?-1*(65535-f+1):f}}function t(a,b,c,d){d||(R("boolean"==typeof c,"missing or invalid endian"),R(void 0!==b&&null!==b,"missing offset"),R(b+3<a.length,"Trying to read beyond buffer length"));var e=a.length;if(!(b>=e)){var f=r(a,b,c,!0),g=2147483648&f;return g?-1*(4294967295-f+1):f}}function u(a,b,c,d){return d||(R("boolean"==typeof c,"missing or invalid endian"),R(b+3<a.length,"Trying to read beyond buffer length")),T.read(a,b,c,23,4)}function v(a,b,c,d){return d||(R("boolean"==typeof c,"missing or invalid endian"),R(b+7<a.length,"Trying to read beyond buffer length")),T.read(a,b,c,52,8)}function w(a,b,c,d,e){e||(R(void 0!==b&&null!==b,"missing value"),R("boolean"==typeof d,"missing or invalid endian"),R(void 0!==c&&null!==c,"missing offset"),R(c+1<a.length,"trying to write beyond buffer length"),O(b,65535));var f=a.length;if(!(c>=f))for(var g=0,h=Math.min(f-c,2);h>g;g++)a[c+g]=(b&255<<8*(d?g:1-g))>>>8*(d?g:1-g)}function x(a,b,c,d,e){e||(R(void 0!==b&&null!==b,"missing value"),R("boolean"==typeof d,"missing or invalid endian"),R(void 0!==c&&null!==c,"missing offset"),R(c+3<a.length,"trying to write beyond buffer length"),O(b,4294967295));var f=a.length;if(!(c>=f))for(var g=0,h=Math.min(f-c,4);h>g;g++)a[c+g]=b>>>8*(d?g:3-g)&255}function y(a,b,c,d,e){e||(R(void 0!==b&&null!==b,"missing value"),R("boolean"==typeof d,"missing or invalid endian"),R(void 0!==c&&null!==c,"missing offset"),R(c+1<a.length,"Trying to write beyond buffer length"),P(b,32767,-32768));var f=a.length;c>=f||(b>=0?w(a,b,c,d,e):w(a,65535+b+1,c,d,e))}function z(a,b,c,d,e){e||(R(void 0!==b&&null!==b,"missing value"),R("boolean"==typeof d,"missing or invalid endian"),R(void 0!==c&&null!==c,"missing offset"),R(c+3<a.length,"Trying to write beyond buffer length"),P(b,2147483647,-2147483648));var f=a.length;c>=f||(b>=0?x(a,b,c,d,e):x(a,4294967295+b+1,c,d,e))}function A(a,b,c,d,e){e||(R(void 0!==b&&null!==b,"missing value"),R("boolean"==typeof d,"missing or invalid endian"),R(void 0!==c&&null!==c,"missing offset"),R(c+3<a.length,"Trying to write beyond buffer length"),Q(b,3.4028234663852886e38,-3.4028234663852886e38));var f=a.length;c>=f||T.write(a,b,c,d,23,4)}function B(a,b,c,d,e){e||(R(void 0!==b&&null!==b,"missing value"),R("boolean"==typeof d,"missing or invalid endian"),R(void 0!==c&&null!==c,"missing offset"),R(c+7<a.length,"Trying to write beyond buffer length"),Q(b,1.7976931348623157e308,-1.7976931348623157e308));var f=a.length;c>=f||T.write(a,b,c,d,52,8)}function C(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function D(a,b,c){return"number"!=typeof a?c:(a=~~a,a>=b?b:a>=0?a:(a+=b,a>=0?a:0))}function E(a){return a=~~Math.ceil(+a),0>a?0:a}function F(a){return(Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)})(a)}function G(a){return F(a)||d.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length}function H(a){return 16>a?"0"+a.toString(16):a.toString(16)}function I(a){for(var b=[],c=0;c<a.length;c++){var d=a.charCodeAt(c);if(127>=d)b.push(a.charCodeAt(c));else{var e=c;d>=55296&&57343>=d&&c++;for(var f=encodeURIComponent(a.slice(e,c+1)).substr(1).split("%"),g=0;g<f.length;g++)b.push(parseInt(f[g],16))}}return b}function J(a){for(var b=[],c=0;c<a.length;c++)b.push(255&a.charCodeAt(c));return b}function K(a){for(var b,c,d,e=[],f=0;f<a.length;f++)b=a.charCodeAt(f),c=b>>8,d=b%256,e.push(d),e.push(c);return e}function L(a){return S.toByteArray(a)}function M(a,b,c,d){for(var e=0;d>e&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}function N(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function O(a,b){R("number"==typeof a,"cannot write a non-number as a number"),R(a>=0,"specified a negative value for writing an unsigned value"),R(b>=a,"value is larger than maximum value for type"),R(Math.floor(a)===a,"value has a fractional component")}function P(a,b,c){R("number"==typeof a,"cannot write a non-number as a number"),R(b>=a,"value larger than maximum allowed value"),R(a>=c,"value smaller than minimum allowed value"),R(Math.floor(a)===a,"value has a fractional component")}function Q(a,b,c){R("number"==typeof a,"cannot write a non-number as a number"),R(b>=a,"value larger than maximum allowed value"),R(a>=c,"value smaller than minimum allowed value")}function R(a,b){if(!a)throw new Error(b||"Failed assertion")}var S=a("base64-js"),T=a("ieee754");c.Buffer=d,c.SlowBuffer=d,c.INSPECT_MAX_BYTES=50,d.poolSize=8192,d._useTypedArrays=function(){try{var a=new ArrayBuffer(0),b=new Uint8Array(a);return b.foo=function(){return 42},42===b.foo()&&"function"==typeof b.subarray}catch(c){return!1}}(),d.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.isBuffer=function(a){return!(null===a||void 0===a||!a._isBuffer)},d.byteLength=function(a,b){var c;switch(a+="",b||"utf8"){case"hex":c=a.length/2;break;case"utf8":case"utf-8":c=I(a).length;break;case"ascii":case"binary":case"raw":c=a.length;break;case"base64":c=L(a).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":c=2*a.length;break;default:throw new Error("Unknown encoding")}return c},d.concat=function(a,b){if(R(F(a),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===a.length)return new d(0);if(1===a.length)return a[0];var c;if("number"!=typeof b)for(b=0,c=0;c<a.length;c++)b+=a[c].length;var e=new d(b),f=0;for(c=0;c<a.length;c++){var g=a[c];g.copy(e,f),f+=g.length}return e},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var k=d;d=b,b=c,c=k}b=Number(b)||0;var l=this.length-b;c?(c=Number(c),c>l&&(c=l)):c=l,d=String(d||"utf8").toLowerCase();var m;switch(d){case"hex":m=e(this,a,b,c);break;case"utf8":case"utf-8":m=f(this,a,b,c);break;case"ascii":m=g(this,a,b,c);break;case"binary":m=h(this,a,b,c);break;case"base64":m=i(this,a,b,c);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":m=j(this,a,b,c);break;default:throw new Error("Unknown encoding")}return m},d.prototype.toString=function(a,b,c){var d=this;if(a=String(a||"utf8").toLowerCase(),b=Number(b)||0,c=void 0!==c?Number(c):c=d.length,c===b)return"";var e;switch(a){case"hex":e=o(d,b,c);break;case"utf8":case"utf-8":e=l(d,b,c);break;case"ascii":e=m(d,b,c);break;case"binary":e=n(d,b,c);break;case"base64":e=k(d,b,c);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":e=p(d,b,c);break;default:throw new Error("Unknown encoding")}return e},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},d.prototype.copy=function(a,b,c,e){var f=this;if(c||(c=0),e||0===e||(e=this.length),b||(b=0),e!==c&&0!==a.length&&0!==f.length){R(e>=c,"sourceEnd < sourceStart"),R(b>=0&&b<a.length,"targetStart out of bounds"),R(c>=0&&c<f.length,"sourceStart out of bounds"),R(e>=0&&e<=f.length,"sourceEnd out of bounds"),e>this.length&&(e=this.length),a.length-b<e-c&&(e=a.length-b+c);var g=e-c;if(100>g||!d._useTypedArrays)for(var h=0;g>h;h++)a[h+b]=this[h+c];else a._set(this.subarray(c,c+g),b)}},d.prototype.slice=function(a,b){var c=this.length;if(a=D(a,c,0),b=D(b,c,c),d._useTypedArrays)return d._augment(this.subarray(a,b));for(var e=b-a,f=new d(e,void 0,!0),g=0;e>g;g++)f[g]=this[g+a];return f},d.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},d.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},d.prototype.readUInt8=function(a,b){return b||(R(void 0!==a&&null!==a,"missing offset"),R(a<this.length,"Trying to read beyond buffer length")),a>=this.length?void 0:this[a]},d.prototype.readUInt16LE=function(a,b){return q(this,a,!0,b)},d.prototype.readUInt16BE=function(a,b){return q(this,a,!1,b)},d.prototype.readUInt32LE=function(a,b){return r(this,a,!0,b)},d.prototype.readUInt32BE=function(a,b){return r(this,a,!1,b)},d.prototype.readInt8=function(a,b){if(b||(R(void 0!==a&&null!==a,"missing offset"),R(a<this.length,"Trying to read beyond buffer length")),!(a>=this.length)){var c=128&this[a];return c?-1*(255-this[a]+1):this[a]}},d.prototype.readInt16LE=function(a,b){return s(this,a,!0,b)},d.prototype.readInt16BE=function(a,b){return s(this,a,!1,b)},d.prototype.readInt32LE=function(a,b){return t(this,a,!0,b)},d.prototype.readInt32BE=function(a,b){return t(this,a,!1,b)},d.prototype.readFloatLE=function(a,b){return u(this,a,!0,b)},d.prototype.readFloatBE=function(a,b){return u(this,a,!1,b)},d.prototype.readDoubleLE=function(a,b){return v(this,a,!0,b)},d.prototype.readDoubleBE=function(a,b){return v(this,a,!1,b)},d.prototype.writeUInt8=function(a,b,c){c||(R(void 0!==a&&null!==a,"missing value"),R(void 0!==b&&null!==b,"missing offset"),R(b<this.length,"trying to write beyond buffer length"),O(a,255)),b>=this.length||(this[b]=a)},d.prototype.writeUInt16LE=function(a,b,c){w(this,a,b,!0,c)},d.prototype.writeUInt16BE=function(a,b,c){w(this,a,b,!1,c)},d.prototype.writeUInt32LE=function(a,b,c){x(this,a,b,!0,c)},d.prototype.writeUInt32BE=function(a,b,c){x(this,a,b,!1,c)},d.prototype.writeInt8=function(a,b,c){c||(R(void 0!==a&&null!==a,"missing value"),R(void 0!==b&&null!==b,"missing offset"),R(b<this.length,"Trying to write beyond buffer length"),P(a,127,-128)),b>=this.length||(a>=0?this.writeUInt8(a,b,c):this.writeUInt8(255+a+1,b,c))},d.prototype.writeInt16LE=function(a,b,c){y(this,a,b,!0,c)},d.prototype.writeInt16BE=function(a,b,c){y(this,a,b,!1,c)},d.prototype.writeInt32LE=function(a,b,c){z(this,a,b,!0,c)},d.prototype.writeInt32BE=function(a,b,c){z(this,a,b,!1,c)},d.prototype.writeFloatLE=function(a,b,c){A(this,a,b,!0,c)},d.prototype.writeFloatBE=function(a,b,c){A(this,a,b,!1,c)},d.prototype.writeDoubleLE=function(a,b,c){B(this,a,b,!0,c)},d.prototype.writeDoubleBE=function(a,b,c){B(this,a,b,!1,c)},d.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),R("number"==typeof a&&!isNaN(a),"value is not a number"),R(c>=b,"end < start"),c!==b&&0!==this.length){R(b>=0&&b<this.length,"start out of bounds"),R(c>=0&&c<=this.length,"end out of bounds");for(var d=b;c>d;d++)this[d]=a}},d.prototype.inspect=function(){for(var a=[],b=this.length,d=0;b>d;d++)if(a[d]=H(this[d]),d===c.INSPECT_MAX_BYTES){a[d+1]="...";break}return"<Buffer "+a.join(" ")+">"},d.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(d._useTypedArrays)return new d(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;c>b;b+=1)a[b]=this[b];return a.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var U=d.prototype;d._augment=function(a){return a._isBuffer=!0,a._get=a.get,a._set=a.set,a.get=U.get,a.set=U.set,a.write=U.write,a.toString=U.toString,a.toLocaleString=U.toString,a.toJSON=U.toJSON,a.copy=U.copy,a.slice=U.slice,a.readUInt8=U.readUInt8,a.readUInt16LE=U.readUInt16LE,a.readUInt16BE=U.readUInt16BE,a.readUInt32LE=U.readUInt32LE,a.readUInt32BE=U.readUInt32BE,a.readInt8=U.readInt8,a.readInt16LE=U.readInt16LE,a.readInt16BE=U.readInt16BE,a.readInt32LE=U.readInt32LE,a.readInt32BE=U.readInt32BE,a.readFloatLE=U.readFloatLE,a.readFloatBE=U.readFloatBE,a.readDoubleLE=U.readDoubleLE,a.readDoubleBE=U.readDoubleBE,a.writeUInt8=U.writeUInt8,a.writeUInt16LE=U.writeUInt16LE,a.writeUInt16BE=U.writeUInt16BE,a.writeUInt32LE=U.writeUInt32LE,a.writeUInt32BE=U.writeUInt32BE,a.writeInt8=U.writeInt8,a.writeInt16LE=U.writeInt16LE,a.writeInt16BE=U.writeInt16BE,a.writeInt32LE=U.writeInt32LE,a.writeInt32BE=U.writeInt32BE,a.writeFloatLE=U.writeFloatLE,a.writeFloatBE=U.writeFloatBE,a.writeDoubleLE=U.writeDoubleLE,a.writeDoubleBE=U.writeDoubleBE,a.fill=U.fill,a.inspect=U.inspect,a.toArrayBuffer=U.toArrayBuffer,a}},{"base64-js":7,ieee754:8}],7:[function(a,b,c){var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(a){"use strict";function b(a){var b=a.charCodeAt(0);return b===g||b===l?62:b===h||b===m?63:i>b?-1:i+10>b?b-i+26+26:k+26>b?b-k:j+26>b?b-j+26:void 0}function c(a){function c(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;g>d;d+=4,e+=3)h=b(a.charAt(d))<<18|b(a.charAt(d+1))<<12|b(a.charAt(d+2))<<6|b(a.charAt(d+3)),c((16711680&h)>>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function e(a){function b(a){return d.charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var e,f,g,h=a.length%3,i="";for(e=0,g=a.length-h;g>e;e+=3)f=(a[e]<<16)+(a[e+1]<<8)+a[e+2],i+=c(f);switch(h){case 1:f=a[a.length-1],i+=b(f>>2),i+=b(f<<4&63),i+="==";break;case 2:f=(a[a.length-2]<<8)+a[a.length-1],i+=b(f>>10),i+=b(f>>4&63),i+=b(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g="+".charCodeAt(0),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0),l="-".charCodeAt(0),m="_".charCodeAt(0);a.toByteArray=c,a.fromByteArray=e}("undefined"==typeof c?this.base64js={}:c)},{}],8:[function(a,b,c){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<<h)-1,j=i>>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:(n?-1:1)*(1/0);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<<j)-1,l=k>>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<<e|h,j+=e;j>0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],9:[function(a,b,c){function d(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function e(a){return"function"==typeof a}function f(a){return"number"==typeof a}function g(a){return"object"==typeof a&&null!==a}function h(a){return void 0===a}b.exports=d,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._maxListeners=void 0,d.defaultMaxListeners=10,d.prototype.setMaxListeners=function(a){if(!f(a)||0>a||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},d.prototype.emit=function(a){var b,c,d,f,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||g(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b;throw TypeError('Uncaught, unspecified "error" event.')}if(c=this._events[a],h(c))return!1;if(e(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(d=arguments.length,f=new Array(d-1),i=1;d>i;i++)f[i-1]=arguments[i];c.apply(this,f)}else if(g(c)){for(d=arguments.length,f=new Array(d-1),i=1;d>i;i++)f[i-1]=arguments[i];for(j=c.slice(),d=j.length,i=0;d>i;i++)j[i].apply(this,f)}return!0},d.prototype.addListener=function(a,b){var c;if(!e(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,e(b.listener)?b.listener:b),this._events[a]?g(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,g(this._events[a])&&!this._events[a].warned){var c;c=h(this._maxListeners)?d.defaultMaxListeners:this._maxListeners,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){function c(){this.removeListener(a,c),d||(d=!0,b.apply(this,arguments))}if(!e(b))throw TypeError("listener must be a function");var d=!1;return c.listener=b,this.on(a,c),this},d.prototype.removeListener=function(a,b){var c,d,f,h;if(!e(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,d=-1,c===b||e(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(g(c)){for(h=f;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){d=h;break}if(0>d)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(d,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},d.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],e(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},d.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?e(this._events[a])?[this._events[a]]:this._events[a].slice():[]},d.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?e(a._events[b])?1:a._events[b].length:0}},{}],10:[function(a,b,c){function d(){}var e=b.exports={};e.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),e.title="browser",e.browser=!0,
e.env={},e.argv=[],e.on=d,e.addListener=d,e.once=d,e.off=d,e.removeListener=d,e.removeAllListeners=d,e.emit=d,e.binding=function(a){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(a){throw new Error("process.chdir is not supported")}},{}],11:[function(a,b,c){function d(a){return this instanceof d?(h.call(this,a),i.call(this,a),a&&a.readable===!1&&(this.readable=!1),a&&a.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,a&&a.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",e)):new d(a)}function e(){if(!this.allowHalfOpen&&!this._writableState.ended){var a=this;g(function(){a.end()})}}b.exports=d;var f=a("inherits"),g=a("process/browser.js").nextTick,h=a("./readable.js"),i=a("./writable.js");f(d,h),d.prototype.write=i.prototype.write,d.prototype.end=i.prototype.end,d.prototype._write=i.prototype._write},{"./readable.js":15,"./writable.js":17,inherits:19,"process/browser.js":13}],12:[function(a,b,c){function d(){e.call(this)}b.exports=d;var e=a("events").EventEmitter,f=a("inherits");f(d,e),d.Readable=a("./readable.js"),d.Writable=a("./writable.js"),d.Duplex=a("./duplex.js"),d.Transform=a("./transform.js"),d.PassThrough=a("./passthrough.js"),d.Stream=d,d.prototype.pipe=function(a,b){function c(b){a.writable&&!1===a.write(b)&&j.pause&&j.pause()}function d(){j.readable&&j.resume&&j.resume()}function f(){k||(k=!0,a.end())}function g(){k||(k=!0,"function"==typeof a.destroy&&a.destroy())}function h(a){if(i(),0===e.listenerCount(this,"error"))throw a}function i(){j.removeListener("data",c),a.removeListener("drain",d),j.removeListener("end",f),j.removeListener("close",g),j.removeListener("error",h),a.removeListener("error",h),j.removeListener("end",i),j.removeListener("close",i),a.removeListener("close",i)}var j=this;j.on("data",c),a.on("drain",d),a._isStdio||b&&b.end===!1||(j.on("end",f),j.on("close",g));var k=!1;return j.on("error",h),a.on("error",h),j.on("end",i),j.on("close",i),a.on("close",i),a.emit("pipe",j),a}},{"./duplex.js":11,"./passthrough.js":14,"./readable.js":15,"./transform.js":16,"./writable.js":17,events:9,inherits:19}],13:[function(a,b,c){var d=b.exports={};d.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),d.title="browser",d.browser=!0,d.env={},d.argv=[],d.binding=function(a){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(a){throw new Error("process.chdir is not supported")}},{}],14:[function(a,b,c){function d(a){return this instanceof d?void e.call(this,a):new d(a)}b.exports=d;var e=a("./transform.js"),f=a("inherits");f(d,e),d.prototype._transform=function(a,b,c){c(null,a)}},{"./transform.js":16,inherits:19}],15:[function(a,b,c){(function(c){function d(b,c){b=b||{};var d=b.highWaterMark;this.highWaterMark=d||0===d?d:16384,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=!1,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.calledRead=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!b.objectMode,this.defaultEncoding=b.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,b.encoding&&(x||(x=a("string_decoder").StringDecoder),this.decoder=new x(b.encoding),this.encoding=b.encoding)}function e(a){return this instanceof e?(this._readableState=new d(a,this),this.readable=!0,void z.call(this)):new e(a)}function f(a,b,c,d,e){var f=j(b,c);if(f)a.emit("error",f);else if(null===c||void 0===c)b.reading=!1,b.ended||k(a,b);else if(b.objectMode||c&&c.length>0)if(b.ended&&!e){var h=new Error("stream.push() after EOF");a.emit("error",h)}else if(b.endEmitted&&e){var h=new Error("stream.unshift() after end event");a.emit("error",h)}else!b.decoder||e||d||(c=b.decoder.write(c)),b.length+=b.objectMode?1:c.length,e?b.buffer.unshift(c):(b.reading=!1,b.buffer.push(c)),b.needReadable&&l(a),n(a,b);else e||(b.reading=!1);return g(b)}function g(a){return!a.ended&&(a.needReadable||a.length<a.highWaterMark||0===a.length)}function h(a){if(a>=D)a=D;else{a--;for(var b=1;32>b;b<<=1)a|=a>>b;a++}return a}function i(a,b){return 0===b.length&&b.ended?0:b.objectMode?0===a?0:1:isNaN(a)||null===a?b.flowing&&b.buffer.length?b.buffer[0].length:b.length:0>=a?0:(a>b.highWaterMark&&(b.highWaterMark=h(a)),a>b.length?b.ended?b.length:(b.needReadable=!0,0):a)}function j(a,b){var c=null;return A.isBuffer(b)||"string"==typeof b||null===b||void 0===b||a.objectMode||c||(c=new TypeError("Invalid non-string/buffer chunk")),c}function k(a,b){if(b.decoder&&!b.ended){var c=b.decoder.end();c&&c.length&&(b.buffer.push(c),b.length+=b.objectMode?1:c.length)}b.ended=!0,b.length>0?l(a):u(a)}function l(a){var b=a._readableState;b.needReadable=!1,b.emittedReadable||(b.emittedReadable=!0,b.sync?B(function(){m(a)}):m(a))}function m(a){a.emit("readable")}function n(a,b){b.readingMore||(b.readingMore=!0,B(function(){o(a,b)}))}function o(a,b){for(var c=b.length;!b.reading&&!b.flowing&&!b.ended&&b.length<b.highWaterMark&&(a.read(0),c!==b.length);)c=b.length;b.readingMore=!1}function p(a){return function(){var b=a._readableState;b.awaitDrain--,0===b.awaitDrain&&q(a)}}function q(a){function b(a,b,e){var f=a.write(c);!1===f&&d.awaitDrain++}var c,d=a._readableState;for(d.awaitDrain=0;d.pipesCount&&null!==(c=a.read());)if(1===d.pipesCount?b(d.pipes,0,null):v(d.pipes,b),a.emit("data",c),d.awaitDrain>0)return;return 0===d.pipesCount?(d.flowing=!1,void(y.listenerCount(a,"data")>0&&s(a))):void(d.ranOut=!0)}function r(){this._readableState.ranOut&&(this._readableState.ranOut=!1,q(this))}function s(a,b){var c=a._readableState;if(c.flowing)throw new Error("Cannot switch to old mode now.");var d=b||!1,e=!1;a.readable=!0,a.pipe=z.prototype.pipe,a.on=a.addListener=z.prototype.on,a.on("readable",function(){e=!0;for(var b;!d&&null!==(b=a.read());)a.emit("data",b);null===b&&(e=!1,a._readableState.needReadable=!0)}),a.pause=function(){d=!0,this.emit("pause")},a.resume=function(){d=!1,e?B(function(){a.emit("readable")}):this.read(0),this.emit("resume")},a.emit("readable")}function t(a,b){var c,d=b.buffer,e=b.length,f=!!b.decoder,g=!!b.objectMode;if(0===d.length)return null;if(0===e)c=null;else if(g)c=d.shift();else if(!a||a>=e)c=f?d.join(""):A.concat(d,e),d.length=0;else if(a<d[0].length){var h=d[0];c=h.slice(0,a),d[0]=h.slice(a)}else if(a===d[0].length)c=d.shift();else{c=f?"":new A(a);for(var i=0,j=0,k=d.length;k>j&&a>i;j++){var h=d[0],l=Math.min(a-i,h.length);f?c+=h.slice(0,l):h.copy(c,i,0,l),l<h.length?d[0]=h.slice(l):d.shift(),i+=l}}return c}function u(a){var b=a._readableState;if(b.length>0)throw new Error("endReadable called on non-empty stream");!b.endEmitted&&b.calledRead&&(b.ended=!0,B(function(){b.endEmitted||0!==b.length||(b.endEmitted=!0,a.readable=!1,a.emit("end"))}))}function v(a,b){for(var c=0,d=a.length;d>c;c++)b(a[c],c)}function w(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}b.exports=e,e.ReadableState=d;var x,y=a("events").EventEmitter,z=a("./index.js"),A=a("buffer").Buffer,B=a("process/browser.js").nextTick,C=a("inherits");C(e,z),e.prototype.push=function(a,b){var c=this._readableState;return"string"!=typeof a||c.objectMode||(b=b||c.defaultEncoding,b!==c.encoding&&(a=new A(a,b),b="")),f(this,c,a,b,!1)},e.prototype.unshift=function(a){var b=this._readableState;return f(this,b,a,"",!0)},e.prototype.setEncoding=function(b){x||(x=a("string_decoder").StringDecoder),this._readableState.decoder=new x(b),this._readableState.encoding=b};var D=8388608;e.prototype.read=function(a){var b=this._readableState;b.calledRead=!0;var c=a;if(("number"!=typeof a||a>0)&&(b.emittedReadable=!1),0===a&&b.needReadable&&(b.length>=b.highWaterMark||b.ended))return l(this),null;if(a=i(a,b),0===a&&b.ended)return 0===b.length&&u(this),null;var d=b.needReadable;b.length-a<=b.highWaterMark&&(d=!0),(b.ended||b.reading)&&(d=!1),d&&(b.reading=!0,b.sync=!0,0===b.length&&(b.needReadable=!0),this._read(b.highWaterMark),b.sync=!1),d&&!b.reading&&(a=i(c,b));var e;return e=a>0?t(a,b):null,null===e&&(b.needReadable=!0,a=0),b.length-=a,0!==b.length||b.ended||(b.needReadable=!0),b.ended&&!b.endEmitted&&0===b.length&&u(this),e},e.prototype._read=function(a){this.emit("error",new Error("not implemented"))},e.prototype.pipe=function(a,b){function d(a){a===k&&f()}function e(){a.end()}function f(){a.removeListener("close",h),a.removeListener("finish",i),a.removeListener("drain",o),a.removeListener("error",g),a.removeListener("unpipe",d),k.removeListener("end",e),k.removeListener("end",f),(!a._writableState||a._writableState.needDrain)&&o()}function g(b){j(),0===s&&0===y.listenerCount(a,"error")&&a.emit("error",b)}function h(){a.removeListener("finish",i),j()}function i(){a.removeListener("close",h),j()}function j(){k.unpipe(a)}var k=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=a;break;case 1:l.pipes=[l.pipes,a];break;default:l.pipes.push(a)}l.pipesCount+=1;var m=(!b||b.end!==!1)&&a!==c.stdout&&a!==c.stderr,n=m?e:f;l.endEmitted?B(n):k.once("end",n),a.on("unpipe",d);var o=p(k);a.on("drain",o);var s=y.listenerCount(a,"error");return a.once("error",g),a.once("close",h),a.once("finish",i),a.emit("pipe",k),l.flowing||(this.on("readable",r),l.flowing=!0,B(function(){q(k)})),a},e.prototype.unpipe=function(a){var b=this._readableState;if(0===b.pipesCount)return this;if(1===b.pipesCount)return a&&a!==b.pipes?this:(a||(a=b.pipes),b.pipes=null,b.pipesCount=0,this.removeListener("readable",r),b.flowing=!1,a&&a.emit("unpipe",this),this);if(!a){var c=b.pipes,d=b.pipesCount;b.pipes=null,b.pipesCount=0,this.removeListener("readable",r),b.flowing=!1;for(var e=0;d>e;e++)c[e].emit("unpipe",this);return this}var e=w(b.pipes,a);return-1===e?this:(b.pipes.splice(e,1),b.pipesCount-=1,1===b.pipesCount&&(b.pipes=b.pipes[0]),a.emit("unpipe",this),this)},e.prototype.on=function(a,b){var c=z.prototype.on.call(this,a,b);if("data"!==a||this._readableState.flowing||s(this),"readable"===a&&this.readable){var d=this._readableState;d.readableListening||(d.readableListening=!0,d.emittedReadable=!1,d.needReadable=!0,d.reading?d.length&&l(this,d):this.read(0))}return c},e.prototype.addListener=e.prototype.on,e.prototype.resume=function(){s(this),this.read(0),this.emit("resume")},e.prototype.pause=function(){s(this,!0),this.emit("pause")},e.prototype.wrap=function(a){var b=this._readableState,c=!1,d=this;a.on("end",function(){if(b.decoder&&!b.ended){var a=b.decoder.end();a&&a.length&&d.push(a)}d.push(null)}),a.on("data",function(e){if(b.decoder&&(e=b.decoder.write(e)),e&&(b.objectMode||e.length)){var f=d.push(e);f||(c=!0,a.pause())}});for(var e in a)"function"==typeof a[e]&&"undefined"==typeof this[e]&&(this[e]=function(b){return function(){return a[b].apply(a,arguments)}}(e));var f=["error","close","destroy","pause","resume"];return v(f,function(b){a.on(b,function(a){return d.emit.apply(d,b,a)})}),d._read=function(b){c&&(c=!1,a.resume())},d},e._fromList=t}).call(this,a("FWaASH"))},{"./index.js":12,FWaASH:10,buffer:6,events:9,inherits:19,"process/browser.js":13,string_decoder:18}],16:[function(a,b,c){function d(a,b){this.afterTransform=function(a,c){return e(b,a,c)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function e(a,b,c){var d=a._transformState;d.transforming=!1;var e=d.writecb;if(!e)return a.emit("error",new Error("no writecb in Transform class"));d.writechunk=null,d.writecb=null,null!==c&&void 0!==c&&a.push(c),e&&e(b);var f=a._readableState;f.reading=!1,(f.needReadable||f.length<f.highWaterMark)&&a._read(f.highWaterMark)}function f(a){if(!(this instanceof f))return new f(a);h.call(this,a);var b=(this._transformState=new d(a,this),this);this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("finish",function(){"function"==typeof this._flush?this._flush(function(a){g(b,a)}):g(b)})}function g(a,b){if(b)return a.emit("error",b);var c=a._writableState,d=(a._readableState,a._transformState);if(c.length)throw new Error("calling transform done when ws.length != 0");if(d.transforming)throw new Error("calling transform done when still transforming");return a.push(null)}b.exports=f;var h=a("./duplex.js"),i=a("inherits");i(f,h),f.prototype.push=function(a,b){return this._transformState.needTransform=!1,h.prototype.push.call(this,a,b)},f.prototype._transform=function(a,b,c){throw new Error("not implemented")},f.prototype._write=function(a,b,c){var d=this._transformState;if(d.writecb=c,d.writechunk=a,d.writeencoding=b,!d.transforming){var e=this._readableState;(d.needTransform||e.needReadable||e.length<e.highWaterMark)&&this._read(e.highWaterMark)}},f.prototype._read=function(a){var b=this._transformState;b.writechunk&&b.writecb&&!b.transforming?(b.transforming=!0,this._transform(b.writechunk,b.writeencoding,b.afterTransform)):b.needTransform=!0}},{"./duplex.js":11,inherits:19}],17:[function(a,b,c){function d(a,b,c){this.chunk=a,this.encoding=b,this.callback=c}function e(a,b){a=a||{};var c=a.highWaterMark;this.highWaterMark=c||0===c?c:16384,this.objectMode=!!a.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var d=a.decodeStrings===!1;this.decodeStrings=!d,this.defaultEncoding=a.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){n(b,a)},this.writecb=null,this.writelen=0,this.buffer=[]}function f(a){return this instanceof f||this instanceof x.Duplex?(this._writableState=new e(a,this),this.writable=!0,void x.call(this)):new f(a)}function g(a,b,c){var d=new Error("write after end");a.emit("error",d),y(function(){c(d)})}function h(a,b,c,d){var e=!0;if(!z.isBuffer(c)&&"string"!=typeof c&&null!==c&&void 0!==c&&!b.objectMode){var f=new TypeError("Invalid non-string/buffer chunk");a.emit("error",f),y(function(){d(f)}),e=!1}return e}function i(a,b,c){return a.objectMode||a.decodeStrings===!1||"string"!=typeof b||(b=new z(b,c)),b}function j(a,b,c,e,f){c=i(b,c,e);var g=b.objectMode?1:c.length;b.length+=g;var h=b.length<b.highWaterMark;return b.needDrain=!h,b.writing?b.buffer.push(new d(c,e,f)):k(a,b,g,c,e,f),h}function k(a,b,c,d,e,f){b.writelen=c,b.writecb=f,b.writing=!0,b.sync=!0,a._write(d,e,b.onwrite),b.sync=!1}function l(a,b,c,d,e){c?y(function(){e(d)}):e(d),a.emit("error",d)}function m(a){a.writing=!1,a.writecb=null,a.length-=a.writelen,a.writelen=0}function n(a,b){var c=a._writableState,d=c.sync,e=c.writecb;if(m(c),b)l(a,c,d,b,e);else{var f=r(a,c);f||c.bufferProcessing||!c.buffer.length||q(a,c),d?y(function(){o(a,c,f,e)}):o(a,c,f,e)}}function o(a,b,c,d){c||p(a,b),d(),c&&s(a,b)}function p(a,b){0===b.length&&b.needDrain&&(b.needDrain=!1,a.emit("drain"))}function q(a,b){b.bufferProcessing=!0;for(var c=0;c<b.buffer.length;c++){var d=b.buffer[c],e=d.chunk,f=d.encoding,g=d.callback,h=b.objectMode?1:e.length;if(k(a,b,h,e,f,g),b.writing){c++;break}}b.bufferProcessing=!1,c<b.buffer.length?b.buffer=b.buffer.slice(c):b.buffer.length=0}function r(a,b){return b.ending&&0===b.length&&!b.finished&&!b.writing}function s(a,b){var c=r(a,b);return c&&(b.finished=!0,a.emit("finish")),c}function t(a,b,c){b.ending=!0,s(a,b),c&&(b.finished?y(c):a.once("finish",c)),b.ended=!0}b.exports=f,f.WritableState=e;var u="undefined"!=typeof Uint8Array?function(a){return a instanceof Uint8Array}:function(a){return a&&a.constructor&&"Uint8Array"===a.constructor.name},v="undefined"!=typeof ArrayBuffer?function(a){return a instanceof ArrayBuffer}:function(a){return a&&a.constructor&&"ArrayBuffer"===a.constructor.name},w=a("inherits"),x=a("./index.js"),y=a("process/browser.js").nextTick,z=a("buffer").Buffer;w(f,x),f.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},f.prototype.write=function(a,b,c){var d=this._writableState,e=!1;return"function"==typeof b&&(c=b,b=null),!z.isBuffer(a)&&u(a)&&(a=new z(a)),v(a)&&"undefined"!=typeof Uint8Array&&(a=new z(new Uint8Array(a))),z.isBuffer(a)?b="buffer":b||(b=d.defaultEncoding),"function"!=typeof c&&(c=function(){}),d.ended?g(this,d,c):h(this,d,a,c)&&(e=j(this,d,a,b,c)),e},f.prototype._write=function(a,b,c){c(new Error("not implemented"))},f.prototype.end=function(a,b,c){var d=this._writableState;"function"==typeof a?(c=a,a=null,b=null):"function"==typeof b&&(c=b,b=null),"undefined"!=typeof a&&null!==a&&this.write(a,b),d.ending||d.finished||t(this,d,c)}},{"./index.js":12,buffer:6,inherits:19,"process/browser.js":13}],18:[function(a,b,c){function d(a){if(a&&!h.isEncoding(a))throw new Error("Unknown encoding: "+a)}function e(a){return a.toString(this.encoding)}function f(a){var b=this.charReceived=a.length%2;return this.charLength=b?2:0,b}function g(a){var b=this.charReceived=a.length%3;return this.charLength=b?3:0,b}var h=a("buffer").Buffer,i=c.StringDecoder=function(a){switch(this.encoding=(a||"utf8").toLowerCase().replace(/[-_]/,""),d(a),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=f;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=g;break;default:return void(this.write=e)}this.charBuffer=new h(6),this.charReceived=0,this.charLength=0};i.prototype.write=function(a){for(var b="",c=0;this.charLength;){var d=a.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:a.length;if(a.copy(this.charBuffer,this.charReceived,c,d),this.charReceived+=d-c,c=d,this.charReceived<this.charLength)return"";b=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var e=b.charCodeAt(b.length-1);if(!(e>=55296&&56319>=e)){if(this.charReceived=this.charLength=0,d==a.length)return b;a=a.slice(d,a.length);break}this.charLength+=this.surrogateSize,b=""}var f=this.detectIncompleteChar(a),g=a.length;this.charLength&&(a.copy(this.charBuffer,0,a.length-f,g),this.charReceived=f,g-=f),b+=a.toString(this.encoding,0,g);var g=b.length-1,e=b.charCodeAt(g);if(e>=55296&&56319>=e){var h=this.surrogateSize;return this.charLength+=h,this.charReceived+=h,this.charBuffer.copy(this.charBuffer,h,0,h),this.charBuffer.write(b.charAt(b.length-1),this.encoding),b.substring(0,g)}return b},i.prototype.detectIncompleteChar=function(a){for(var b=a.length>=3?3:a.length;b>0;b--){var c=a[a.length-b];if(1==b&&c>>5==6){this.charLength=2;break}if(2>=b&&c>>4==14){this.charLength=3;break}if(3>=b&&c>>3==30){this.charLength=4;break}}return b},i.prototype.end=function(a){var b="";if(a&&a.length&&(b=this.write(a)),this.charReceived){var c=this.charReceived,d=this.charBuffer,e=this.encoding;b+=d.slice(0,c).toString(e)}return b}},{buffer:6}],19:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:b.exports=function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}]},{},[1]);