UNPKG

tanglepay-sdk-monorepo

Version:

DApp SDK to interact with TanglePay wallets

7 lines 60 kB
/** * @license * author: * tanglepaysdk-common.js v0.1.9 * Released under the ISC license. */ var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function r(){}function i(){i.init.call(this)}function o(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function s(e,t,n,i){var s,a,u,f;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),u=a[t]):(a=e._events=new r,e._eventsCount=0),u){if("function"==typeof u?u=a[t]=i?[n,u]:[u,n]:i?u.unshift(n):u.push(n),!u.warned&&(s=o(e))&&s>0&&u.length>s){u.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=u.length,f=h,"function"==typeof console.warn?console.warn(f):console.log(f)}}else u=a[t]=n,++e._eventsCount;return e}function a(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function u(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function f(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}r.prototype=Object.create(null),i.EventEmitter=i,i.usingDomains=!1,i.prototype.domain=void 0,i.prototype._events=void 0,i.prototype._maxListeners=void 0,i.defaultMaxListeners=10,i.init=function(){this.domain=null,i.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new r,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return o(this)},i.prototype.emit=function(e){var t,n,r,i,o,s,a,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(n=s[e]))return!1;var c="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=f(e,r),o=0;o<r;++o)i[o].call(n)}(n,c,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,o=f(e,i),s=0;s<i;++s)o[s].call(n,r)}(n,c,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var o=e.length,s=f(e,o),a=0;a<o;++a)s[a].call(n,r,i)}(n,c,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,o){if(t)e.call(n,r,i,o);else for(var s=e.length,a=f(e,s),u=0;u<s;++u)a[u].call(n,r,i,o)}(n,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,o=f(e,i),s=0;s<i;++s)o[s].apply(n,r)}(n,c,this,i)}return!0},i.prototype.addListener=function(e,t){return s(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return s(this,e,t,!0)},i.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,a(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,a(this,e,t)),this},i.prototype.removeListener=function(e,t){var n,i,o,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(i=this._events))return this;if(!(n=i[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new r:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){a=n[s].listener,o=s;break}if(o<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new r,this;delete i[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,o);i.removeListener&&this.emit("removeListener",e,a||t)}return this},i.prototype.off=function(e,t){return this.removeListener(e,t)},i.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new r,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new r:delete n[e]),this;if(0===arguments.length){for(var i,o=Object.keys(n),s=0;s<o.length;++s)"removeListener"!==(i=o[s])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=new r,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},i.prototype.listeners=function(e){var t,n=this._events;return n&&(t=n[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[]},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):u.call(e,t)},i.prototype.listenerCount=u,i.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var h="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},c=[],l=[],d="undefined"!=typeof Uint8Array?Uint8Array:Array,p=!1;function g(){p=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)c[t]=e[t],l[e.charCodeAt(t)]=t;l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63}function v(e,t,n){for(var r,i,o=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(c[(i=r)>>18&63]+c[i>>12&63]+c[i>>6&63]+c[63&i]);return o.join("")}function w(e){var t;p||g();for(var n=e.length,r=n%3,i="",o=[],s=16383,a=0,u=n-r;a<u;a+=s)o.push(v(e,a,a+s>u?u:a+s));return 1===r?(t=e[n-1],i+=c[t>>2],i+=c[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=c[t>>10],i+=c[t>>4&63],i+=c[t<<2&63],i+="="),o.push(i),o.join("")}function y(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,f=u>>1,h=-7,c=n?i-1:0,l=n?-1:1,d=e[t+c];for(c+=l,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+c],c+=l,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+e[t+c],c+=l,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=f}return(d?-1:1)*s*Math.pow(2,o-r)}function b(e,t,n,r,i,o){var s,a,u,f=8*o-i-1,h=(1<<f)-1,c=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,g=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=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(s++,u/=2),s+c>=h?(a=0,s=h):s+c>=1?(a=(t*u-1)*Math.pow(2,i),s+=c):(a=t*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;e[n+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[n+d]=255&s,d+=p,s/=256,f-=8);e[n+d-p]|=128*g}var m={}.toString,_=Array.isArray||function(e){return"[object Array]"==m.call(e)};function E(){return S.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function R(e,t){if(E()<t)throw new RangeError("Invalid typed array length");return S.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=S.prototype:(null===e&&(e=new S(t)),e.length=t),e}function S(e,t,n){if(!(S.TYPED_ARRAY_SUPPORT||this instanceof S))return new S(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return T(this,e)}return A(this,e,t,n)}function A(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);S.TYPED_ARRAY_SUPPORT?(e=t).__proto__=S.prototype:e=k(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!S.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|P(t,n);e=R(e,r);var i=e.write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(x(t)){var n=0|M(t.length);return 0===(e=R(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?R(e,0):k(e,t);if("Buffer"===t.type&&_(t.data))return k(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function L(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 T(e,t){if(L(t),e=R(e,t<0?0:0|M(t)),!S.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function k(e,t){var n=t.length<0?0:0|M(t.length);e=R(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function M(e){if(e>=E())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+E().toString(16)+" bytes");return 0|e}function x(e){return!(null==e||!e._isBuffer)}function P(e,t){if(x(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return ie(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return oe(e).length;default:if(r)return ie(e).length;t=(""+t).toLowerCase(),r=!0}}function C(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return J(this,t,n);case"utf8":case"utf-8":return W(this,t,n);case"ascii":return H(this,t,n);case"latin1":case"binary":return G(this,t,n);case"base64":return q(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function O(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function B(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=S.from(t,r)),x(t))return 0===t.length?-1:j(e,t,n,r,i);if("number"==typeof t)return t&=255,S.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):j(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function j(e,t,n,r,i){var o,s=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=n;o<a;o++)if(f(e,o)===f(t,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===u)return h*s}else-1!==h&&(o-=o-h),h=-1}else for(n+u>a&&(n=a-u),o=n;o>=0;o--){for(var c=!0,l=0;l<u;l++)if(f(e,o+l)!==f(t,l)){c=!1;break}if(c)return o}return-1}function U(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function D(e,t,n,r){return se(ie(t,e.length-n),e,n,r)}function I(e,t,n,r){return se(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Y(e,t,n,r){return I(e,t,n,r)}function z(e,t,n,r){return se(oe(t),e,n,r)}function N(e,t,n,r){return se(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function q(e,t,n){return 0===t&&n===e.length?w(e):w(e.slice(t,n))}function W(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,u,f=e[i],h=null,c=f>239?4:f>223?3:f>191?2:1;if(i+c<=n)switch(c){case 1:f<128&&(h=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,c=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),i+=c}return function(e){var t=e.length;if(t<=F)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=F));return n}(r)}S.TYPED_ARRAY_SUPPORT=void 0===h.TYPED_ARRAY_SUPPORT||h.TYPED_ARRAY_SUPPORT,E(),S.poolSize=8192,S._augment=function(e){return e.__proto__=S.prototype,e},S.from=function(e,t,n){return A(null,e,t,n)},S.TYPED_ARRAY_SUPPORT&&(S.prototype.__proto__=Uint8Array.prototype,S.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&S[Symbol.species]),S.alloc=function(e,t,n){return function(e,t,n,r){return L(t),t<=0?R(e,t):void 0!==n?"string"==typeof r?R(e,t).fill(n,r):R(e,t).fill(n):R(e,t)}(null,e,t,n)},S.allocUnsafe=function(e){return T(null,e)},S.allocUnsafeSlow=function(e){return T(null,e)},S.isBuffer=function(e){return null!=e&&(!!e._isBuffer||ae(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ae(e.slice(0,0))}(e))},S.compare=function(e,t){if(!x(e)||!x(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},S.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},S.concat=function(e,t){if(!_(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return S.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=S.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var o=e[n];if(!x(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},S.byteLength=P,S.prototype._isBuffer=!0,S.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)O(this,t,t+1);return this},S.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)O(this,t,t+3),O(this,t+1,t+2);return this},S.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)O(this,t,t+7),O(this,t+1,t+6),O(this,t+2,t+5),O(this,t+3,t+4);return this},S.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?W(this,0,e):C.apply(this,arguments)},S.prototype.equals=function(e){if(!x(e))throw new TypeError("Argument must be a Buffer");return this===e||0===S.compare(this,e)},S.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},S.prototype.compare=function(e,t,n,r,i){if(!x(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(r,i),f=e.slice(t,n),h=0;h<a;++h)if(u[h]!==f[h]){o=u[h],s=f[h];break}return o<s?-1:s<o?1:0},S.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},S.prototype.indexOf=function(e,t,n){return B(this,e,t,n,!0)},S.prototype.lastIndexOf=function(e,t,n){return B(this,e,t,n,!1)},S.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return U(this,e,t,n);case"utf8":case"utf-8":return D(this,e,t,n);case"ascii":return I(this,e,t,n);case"latin1":case"binary":return Y(this,e,t,n);case"base64":return z(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},S.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var F=4096;function H(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function G(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function J(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=re(e[o]);return i}function $(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function V(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function Z(e,t,n,r,i,o){if(!x(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function K(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function Q(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function X(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ee(e,t,n,r,i){return i||X(e,0,n,4),b(e,t,n,r,23,4),n+4}function te(e,t,n,r,i){return i||X(e,0,n,8),b(e,t,n,r,52,8),n+8}S.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),S.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=S.prototype;else{var i=t-e;n=new S(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},S.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||V(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},S.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||V(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},S.prototype.readUInt8=function(e,t){return t||V(e,1,this.length),this[e]},S.prototype.readUInt16LE=function(e,t){return t||V(e,2,this.length),this[e]|this[e+1]<<8},S.prototype.readUInt16BE=function(e,t){return t||V(e,2,this.length),this[e]<<8|this[e+1]},S.prototype.readUInt32LE=function(e,t){return t||V(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},S.prototype.readUInt32BE=function(e,t){return t||V(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},S.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||V(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},S.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||V(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},S.prototype.readInt8=function(e,t){return t||V(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},S.prototype.readInt16LE=function(e,t){t||V(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},S.prototype.readInt16BE=function(e,t){t||V(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},S.prototype.readInt32LE=function(e,t){return t||V(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},S.prototype.readInt32BE=function(e,t){return t||V(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},S.prototype.readFloatLE=function(e,t){return t||V(e,4,this.length),y(this,e,!0,23,4)},S.prototype.readFloatBE=function(e,t){return t||V(e,4,this.length),y(this,e,!1,23,4)},S.prototype.readDoubleLE=function(e,t){return t||V(e,8,this.length),y(this,e,!0,52,8)},S.prototype.readDoubleBE=function(e,t){return t||V(e,8,this.length),y(this,e,!1,52,8)},S.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||Z(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},S.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||Z(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},S.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Z(this,e,t,1,255,0),S.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},S.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Z(this,e,t,2,65535,0),S.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):K(this,e,t,!0),t+2},S.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Z(this,e,t,2,65535,0),S.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):K(this,e,t,!1),t+2},S.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Z(this,e,t,4,4294967295,0),S.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Q(this,e,t,!0),t+4},S.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Z(this,e,t,4,4294967295,0),S.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Q(this,e,t,!1),t+4},S.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);Z(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},S.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);Z(this,e,t,n,i-1,-i)}var o=n-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+n},S.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Z(this,e,t,1,127,-128),S.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},S.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Z(this,e,t,2,32767,-32768),S.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):K(this,e,t,!0),t+2},S.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Z(this,e,t,2,32767,-32768),S.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):K(this,e,t,!1),t+2},S.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Z(this,e,t,4,2147483647,-2147483648),S.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Q(this,e,t,!0),t+4},S.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Z(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),S.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Q(this,e,t,!1),t+4},S.prototype.writeFloatLE=function(e,t,n){return ee(this,e,t,!0,n)},S.prototype.writeFloatBE=function(e,t,n){return ee(this,e,t,!1,n)},S.prototype.writeDoubleLE=function(e,t,n){return te(this,e,t,!0,n)},S.prototype.writeDoubleBE=function(e,t,n){return te(this,e,t,!1,n)},S.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!S.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},S.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!S.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=x(e)?e:ie(new S(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var ne=/[^+\/0-9A-Za-z-_]/g;function re(e){return e<16?"0"+e.toString(16):e.toString(16)}function ie(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function oe(e){return function(e){var t,n,r,i,o,s;p||g();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new d(3*a/4-o),r=o>0?a-4:a;var u=0;for(t=0,n=0;t<r;t+=4,n+=3)i=l[e.charCodeAt(t)]<<18|l[e.charCodeAt(t+1)]<<12|l[e.charCodeAt(t+2)]<<6|l[e.charCodeAt(t+3)],s[u++]=i>>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=l[e.charCodeAt(t)]<<2|l[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=l[e.charCodeAt(t)]<<10|l[e.charCodeAt(t+1)]<<4|l[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(ne,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function se(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function ae(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function ue(){throw new Error("setTimeout has not been defined")}function fe(){throw new Error("clearTimeout has not been defined")}var he=ue,ce=fe;function le(e){if(he===setTimeout)return setTimeout(e,0);if((he===ue||!he)&&setTimeout)return he=setTimeout,setTimeout(e,0);try{return he(e,0)}catch(t){try{return he.call(null,e,0)}catch(t){return he.call(this,e,0)}}}"function"==typeof h.setTimeout&&(he=setTimeout),"function"==typeof h.clearTimeout&&(ce=clearTimeout);var de,pe=[],ge=!1,ve=-1;function we(){ge&&de&&(ge=!1,de.length?pe=de.concat(pe):ve=-1,pe.length&&ye())}function ye(){if(!ge){var e=le(we);ge=!0;for(var t=pe.length;t;){for(de=pe,pe=[];++ve<t;)de&&de[ve].run();ve=-1,t=pe.length}de=null,ge=!1,function(e){if(ce===clearTimeout)return clearTimeout(e);if((ce===fe||!ce)&&clearTimeout)return ce=clearTimeout,clearTimeout(e);try{return ce(e)}catch(t){try{return ce.call(null,e)}catch(t){return ce.call(this,e)}}}(e)}}function be(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];pe.push(new me(e,t)),1!==pe.length||ge||le(ye)}function me(e,t){this.fun=e,this.array=t}me.prototype.run=function(){this.fun.apply(null,this.array)};function _e(){}var Ee=_e,Re=_e,Se=_e,Ae=_e,Le=_e,Te=_e,ke=_e;var Me=h.performance||{},xe=Me.now||Me.mozNow||Me.msNow||Me.oNow||Me.webkitNow||function(){return(new Date).getTime()};var Pe=new Date;var Ce={nextTick:be,title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Ee,addListener:Re,once:Se,off:Ae,removeListener:Le,removeAllListeners:Te,emit:ke,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*xe.call(Me),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Pe)/1e3}},Oe="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},Be=/%[sdj%]/g;function je(e){if(!Je(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(Ye(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,o=String(e).replace(Be,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),s=r[n];n<i;s=r[++n])Ge(s)||!Ze(s)?o+=" "+s:o+=" "+Ye(s);return o}function Ue(e,t){if($e(h.process))return function(){return Ue(e,t).apply(this,arguments)};if(!0===Ce.noDeprecation)return e;var n=!1;return function(){if(!n){if(Ce.throwDeprecation)throw new Error(t);Ce.traceDeprecation?console.trace(t):console.error(t),n=!0}return e.apply(this,arguments)}}var De,Ie={};function Ye(e,t){var n={seen:[],stylize:Ne};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),He(t)?n.showHidden=t:t&&function(e,t){if(!t||!Ze(t))return e;var n=Object.keys(t),r=n.length;for(;r--;)e[n[r]]=t[n[r]]}(n,t),$e(n.showHidden)&&(n.showHidden=!1),$e(n.depth)&&(n.depth=2),$e(n.colors)&&(n.colors=!1),$e(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=ze),qe(n,e,n.depth)}function ze(e,t){var n=Ye.styles[t];return n?"["+Ye.colors[n][0]+"m"+e+"["+Ye.colors[n][1]+"m":e}function Ne(e,t){return e}function qe(e,t,n){if(e.customInspect&&t&&Xe(t.inspect)&&t.inspect!==Ye&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return Je(r)||(r=qe(e,r,n)),r}var i=function(e,t){if($e(t))return e.stylize("undefined","undefined");if(Je(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(r=t,"number"==typeof r)return e.stylize(""+t,"number");var r;if(He(t))return e.stylize(""+t,"boolean");if(Ge(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),Qe(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return We(t);if(0===o.length){if(Xe(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(Ve(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Ke(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Qe(t))return We(t)}var u,f,h="",c=!1,l=["{","}"];(u=t,Array.isArray(u)&&(c=!0,l=["[","]"]),Xe(t))&&(h=" [Function"+(t.name?": "+t.name:"")+"]");return Ve(t)&&(h=" "+RegExp.prototype.toString.call(t)),Ke(t)&&(h=" "+Date.prototype.toUTCString.call(t)),Qe(t)&&(h=" "+We(t)),0!==o.length||c&&0!=t.length?n<0?Ve(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),f=c?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s<a;++s)tt(t,String(s))?o.push(Fe(e,t,n,r,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(Fe(e,t,n,r,i,!0))})),o}(e,t,n,s,o):o.map((function(r){return Fe(e,t,n,s,r,c)})),e.seen.pop(),function(e,t,n){var r=e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);if(r>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(f,h,l)):l[0]+h+l[1]}function We(e){return"["+Error.prototype.toString.call(e)+"]"}function Fe(e,t,n,r,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),tt(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=Ge(n)?qe(e,u.value,null):qe(e,u.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),$e(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function He(e){return"boolean"==typeof e}function Ge(e){return null===e}function Je(e){return"string"==typeof e}function $e(e){return void 0===e}function Ve(e){return Ze(e)&&"[object RegExp]"===et(e)}function Ze(e){return"object"==typeof e&&null!==e}function Ke(e){return Ze(e)&&"[object Date]"===et(e)}function Qe(e){return Ze(e)&&("[object Error]"===et(e)||e instanceof Error)}function Xe(e){return"function"==typeof e}function et(e){return Object.prototype.toString.call(e)}function tt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function nt(){this.head=null,this.tail=null,this.length=0}Ye.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Ye.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},nt.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},nt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},nt.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}},nt.prototype.clear=function(){this.head=this.tail=null,this.length=0},nt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},nt.prototype.concat=function(e){if(0===this.length)return S.alloc(0);if(1===this.length)return this.head.data;for(var t=S.allocUnsafe(e>>>0),n=this.head,r=0;n;)n.data.copy(t,r),r+=n.data.length,n=n.next;return t};var rt=S.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}};function it(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!rt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=st;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=at;break;default:return void(this.write=ot)}this.charBuffer=new S(6),this.charReceived=0,this.charLength=0}function ot(e){return e.toString(this.encoding)}function st(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function at(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}it.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";if(e=e.slice(n,e.length),!((i=(t=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(t.length-1))>=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var r=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,r),r-=this.charReceived);var i;r=(t+=e.toString(this.encoding,0,r)).length-1;if((i=t.charCodeAt(r))>=55296&&i<=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,r)}return t},it.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},it.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t},ht.ReadableState=ft;var ut=function(e){if($e(De)&&(De=Ce.env.NODE_DEBUG||""),e=e.toUpperCase(),!Ie[e])if(new RegExp("\\b"+e+"\\b","i").test(De)){Ie[e]=function(){var t=je.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else Ie[e]=function(){};return Ie[e]}("stream");function ft(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof It&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new nt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new it(e.encoding),this.encoding=e.encoding)}function ht(e){if(!(this instanceof ht))return new ht(e);this._readableState=new ft(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),i.call(this)}function ct(e,t,n,r,i){var o=function(e,t){var n=null;S.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));return n}(t,n);if(o)e.emit("error",o);else if(null===n)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,pt(e)}(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||r||(n=t.decoder.write(n),u=!t.objectMode&&0===n.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&pt(e))),function(e,t){t.readingMore||(t.readingMore=!0,be(vt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(t)}Oe(ht,i),ht.prototype.push=function(e,t){var n=this._readableState;return n.objectMode||"string"!=typeof e||(t=t||n.defaultEncoding)!==n.encoding&&(e=S.from(e,t),t=""),ct(this,n,e,t,!1)},ht.prototype.unshift=function(e){return ct(this,this._readableState,e,"",!0)},ht.prototype.isPaused=function(){return!1===this._readableState.flowing},ht.prototype.setEncoding=function(e){return this._readableState.decoder=new it(e),this._readableState.encoding=e,this};var lt=8388608;function dt(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=function(e){return e>=lt?e=lt:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function pt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ut("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?be(gt,e):gt(e))}function gt(e){ut("emit readable"),e.emit("readable"),bt(e)}function vt(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(ut("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function wt(e){ut("readable nexttick read 0"),e.read(0)}function yt(e,t){t.reading||(ut("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),bt(e),t.flowing&&!t.reading&&e.read(0)}function bt(e){var t=e._readableState;for(ut("flow",t.flowing);t.flowing&&null!==e.read(););}function mt(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var r;e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):r=e===t.head.data.length?t.shift():n?function(e,t){var n=t.head,r=1,i=n.data;e-=i.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++r}return t.length-=r,i}(e,t):function(e,t){var n=S.allocUnsafe(e),r=t.head,i=1;r.data.copy(n),e-=r.data.length;for(;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,s),0===(e-=s)){s===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++i}return t.length-=i,n}(e,t);return r}(e,t.buffer,t.decoder),n);var n}function _t(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,be(Et,t,e))}function Et(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Rt(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function St(){}function At(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function Lt(e,t){Object.defineProperty(this,"buffer",{get:Ue((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof It&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=!1===e.decodeStrings;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?be(i,r):i(r);e._writableState.errorEmitted=!0,e.emit("error",r)}(e,n,r,t,i);else{var o=Pt(n);o||n.corked||n.bufferProcessing||!n.bufferedRequest||xt(e,n),r?be(Mt,e,n,o,i):Mt(e,n,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Bt(this)}function Tt(e){if(!(this instanceof Tt||this instanceof It))return new Tt(e);this._writableState=new Lt(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),i.call(this)}function kt(e,t,n,r,i,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function Mt(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),Ot(e,t)}function xt(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),o=t.corkedRequestsFree;o.entry=n;for(var s=0;n;)i[s]=n,n=n.next,s+=1;kt(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Bt(t)}else{for(;n;){var a=n.chunk,u=n.encoding,f=n.callback;if(kt(e,t,!1,t.objectMode?1:a.length,a,u,f),n=n.next,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=n,t.bufferProcessing=!1}function Pt(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ct(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function Ot(e,t){var n=Pt(t);return n&&(0===t.pendingcb?(Ct(e,t),t.finished=!0,e.emit("finish")):Ct(e,t)),n}function Bt(e){var t=this;this.next=null,this.entry=null,this.finish=function(n){var r=t.entry;for(t.entry=null;r;){var i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}ht.prototype.read=function(e){ut("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return ut("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?_t(this):pt(this),null;if(0===(e=dt(e,t))&&t.ended)return 0===t.length&&_t(this),null;var r,i=t.needReadable;return ut("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&ut("length less than watermark",i=!0),t.ended||t.reading?ut("reading or ended",i=!1):i&&(ut("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=dt(n,t))),null===(r=e>0?mt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&_t(this)),null!==r&&this.emit("data",r),r},ht.prototype._read=function(e){this.emit("error",new Error("not implemented"))},ht.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,ut("pipe count=%d opts=%j",r.pipesCount,t);var i=!t||!1!==t.end?s:f;function o(e){ut("onunpipe"),e===n&&f()}function s(){ut("onend"),e.end()}r.endEmitted?be(i):n.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ut("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,bt(e))}}(n);e.on("drain",a);var u=!1;function f(){ut("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",o),n.removeListener("end",s),n.removeListener("end",f),n.removeListener("data",c),u=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var h=!1;function c(t){ut("ondata"),h=!1,!1!==e.write(t)||h||((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==Rt(r.pipes,e))&&!u&&(ut("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,h=!0),n.pause())}function l(t){var n;ut("onerror",t),g(),e.removeListener("error",l),0===(n="error",e.listeners(n).length)&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){ut("onfinish"),e.removeListener("close",d),g()}function g(){ut("unpipe"),n.unpipe(e)}return n.on("data",c),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",l),e.once("close",d),e.once("finish",p),e.emit("pipe",n),r.flowing||(ut("pipe resume"),n.resume()),e},ht.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<r;i++)n[i].emit("unpipe",this