UNPKG

@pdf-lib/fontkit

Version:

An advanced font engine for Node and the browser

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