UNPKG

@interactify-live/short

Version:

Pure MQTT connector for Interactify short videos - no UI or video dependencies

266 lines 258 kB
'use strict';

function getDefaultExportFromCjs (x) {
	return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

var mqtt_browser = {exports: {}};

/*! For license information please see mqtt.browser.js.LICENSE.txt */

var hasRequiredMqtt_browser;

function requireMqtt_browser () {
	if (hasRequiredMqtt_browser) return mqtt_browser.exports;
	hasRequiredMqtt_browser = 1;
	!function(){var e={9742:function(e,t){t.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,o=u(e),s=o[0],a=o[1],l=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),c=0,h=a>0?s-4:s;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],l[c++]=t>>16&255,l[c++]=t>>8&255,l[c++]=255&t;return 2===a&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,l[c++]=255&t),1===a&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,l[c++]=t>>8&255,l[c++]=255&t),l},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=16383,a=0,u=n-i;a<u;a+=s)o.push(l(e,a,a+s>u?u:a+s));return 1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=o.length;s<a;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return  -1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,n){for(var i,o,s=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63;},9668:function(e,t,r){const{Buffer:n}=r(8478),i=Symbol.for("BufferList");function o(e){if(!(this instanceof o))return new o(e);o._init.call(this,e);}o._init=function(e){Object.defineProperty(this,i,{value:true}),this._bufs=[],this.length=0,e&&this.append(e);},o.prototype._new=function(e){return new o(e)},o.prototype._offset=function(e){if(0===e)return [0,0];let t=0;for(let r=0;r<this._bufs.length;r++){const n=t+this._bufs[r].length;if(e<n||r===this._bufs.length-1)return [r,e-t];t=n;}},o.prototype._reverseOffset=function(e){const t=e[0];let r=e[1];for(let e=0;e<t;e++)r+=this._bufs[e].length;return r},o.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},o.prototype.slice=function(e,t){return "number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},o.prototype.copy=function(e,t,r,i){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof i||i>this.length)&&(i=this.length),r>=this.length)return e||n.alloc(0);if(i<=0)return e||n.alloc(0);const o=!!e,s=this._offset(r),a=i-r;let u=a,l=o&&t||0,c=s[1];if(0===r&&i===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:n.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,l),l+=this._bufs[t].length;return e}if(u<=this._bufs[s[0]].length-c)return o?this._bufs[s[0]].copy(e,t,c,c+u):this._bufs[s[0]].slice(c,c+u);o||(e=n.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const r=this._bufs[t].length-c;if(!(u>r)){this._bufs[t].copy(e,l,c,c+u),l+=r;break}this._bufs[t].copy(e,l,c),l+=r,u-=r,c&&(c=0);}return e.length>l?e.slice(0,l):e},o.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const r=this._offset(e),n=this._offset(t),i=this._bufs.slice(r[0],n[0]+1);return 0===n[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,n[1]),0!==r[1]&&(i[0]=i[0].slice(r[1])),this._new(i)},o.prototype.toString=function(e,t,r){return this.slice(t,r).toString(e)},o.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();}return this},o.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},o.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(n.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else "number"==typeof e&&(e=e.toString()),this._appendBuffer(n.from(e));return this},o.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length;},o.prototype.indexOf=function(e,t,r){if(void 0===r&&"string"==typeof t&&(r=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=n.from([e]):"string"==typeof e?e=n.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=n.from(e.buffer,e.byteOffset,e.byteLength):n.isBuffer(e)||(e=n.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const i=this._offset(t);let o=i[0],s=i[1];for(;o<this._bufs.length;o++){const t=this._bufs[o];for(;s<t.length;)if(t.length-s>=e.length){const r=t.indexOf(e,s);if(-1!==r)return this._reverseOffset([o,r]);s=t.length-e.length+1;}else {const t=this._reverseOffset([o,s]);if(this._match(t,e))return t;s++;}s=0;}return  -1},o.prototype._match=function(e,t){if(this.length-e<t.length)return  false;for(let r=0;r<t.length;r++)if(this.get(e+r)!==t[r])return  false;return  true},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){o.prototype[t]=null===e[t]?function(e,r){return this.slice(e,e+r)[t](0,r)}:function(r=0){return this.slice(r,r+e[t])[t](0)};}(t);}(),o.prototype._isBufferList=function(e){return e instanceof o||o.isBufferList(e)},o.isBufferList=function(e){return null!=e&&e[i]},e.exports=o;},22:function(e,t,r){const n=r(8473).Duplex,i=r(5717),o=r(9668);function s(e){if(!(this instanceof s))return new s(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null);}.bind(this);this.on("pipe",(function(e){e.on("error",t);})),this.on("unpipe",(function(e){e.removeListener("error",t);})),e=null;}o._init.call(this,e),n.call(this);}i(s,n),Object.assign(s.prototype,o.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,r){this._appendBuffer(e),"function"==typeof r&&r();},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e);},s.prototype.end=function(e){n.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null);},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e);},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof o||s.isBufferList(e)},s.isBufferList=o.isBufferList,e.exports=s,e.exports.BufferListStream=s,e.exports.BufferList=o;},8478:function(e,t,r){var n=r(9742),i=r(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=u,t.SlowBuffer=function(e){return +e!=e&&(e=0),u.alloc(+e)},t.INSPECT_MAX_BYTES=50;var s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!u.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|y(e,t),n=a(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(D(e,Uint8Array)){var t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return f(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(D(e,ArrayBuffer)||e&&D(e.buffer,ArrayBuffer))return p(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(D(e,SharedArrayBuffer)||e&&D(e.buffer,SharedArrayBuffer)))return p(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return u.from(n,t,r);var i=function(e){if(u.isBuffer(e)){var t=0|d(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||F(e.length)?a(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return u.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return c(e),a(e<0?0:0|d(e))}function f(e){for(var t=e.length<0?0:0|d(e.length),r=a(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function p(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,u.prototype),n}function d(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function y(e,t){if(u.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||D(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&true===arguments[2];if(!n&&0===r)return 0;for(var i=false;;)switch(t){case "ascii":case "latin1":case "binary":return r;case "utf8":case "utf-8":return j(e).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*r;case "hex":return r>>>1;case "base64":return q(e).length;default:if(i)return n?-1:j(e).length;t=(""+t).toLowerCase(),i=true;}}function g(e,t,r){var n=false;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 B(this,t,r);case "utf8":case "utf-8":return T(this,t,r);case "ascii":return I(this,t,r);case "latin1":case "binary":return x(this,t,r);case "base64":return C(this,t,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return R(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=true;}}function b(e,t,r){var n=e[t];e[t]=e[r],e[r]=n;}function m(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),F(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return  -1;r=e.length-1;}else if(r<0){if(!i)return  -1;r=0;}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return  -1;s=2,a/=2,u/=2,r/=2;}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(o=r;o<a;o++)if(l(e,o)===l(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===u)return c*s}else  -1!==c&&(o-=o-c),c=-1;}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var h=true,f=0;f<u;f++)if(l(e,o+f)!==l(t,f)){h=false;break}if(h)return o}return  -1}function w(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(F(a))return s;e[r+s]=a;}return s}function _(e,t,r,n){return z(j(t,e.length-r),e,r,n)}function E(e,t,r,n){return z(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function k(e,t,r,n){return z(q(t),e,r,n)}function S(e,t,r,n){return z(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function C(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,u,l=e[i],c=null,h=l>239?4:l>223?3:l>191?2:1;if(i+h<=r)switch(h){case 1:l<128&&(c=l);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&l)<<6|63&o)>127&&(c=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&l)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=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&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(c=u);}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h;}return function(e){var t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=A));return r}(n)}t.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return  false}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:true,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:true,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(e,t,r){return function(e,t,r){return c(e),e<=0?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)}(e,t,r)},u.allocUnsafe=function(e){return h(e)},u.allocUnsafeSlow=function(e){return h(e)},u.isBuffer=function(e){return null!=e&&true===e._isBuffer&&e!==u.prototype},u.compare=function(e,t){if(D(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),D(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return  true;default:return  false}},u.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(D(o,Uint8Array))i+o.length>n.length?u.from(o).copy(n,i):Uint8Array.prototype.set.call(n,o,i);else {if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i);}i+=o.length;}return n},u.byteLength=y,u.prototype._isBuffer=true,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)b(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)b(this,t,t+3),b(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)b(this,t,t+7),b(this,t+1,t+6),b(this,t+2,t+5),b(this,t+3,t+4);return this},u.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?T(this,0,e):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(e,t,r,n,i){if(D(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);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 o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),l=this.slice(n,i),c=e.slice(t,r),h=0;h<a;++h)if(l[h]!==c[h]){o=l[h],s=c[h];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(e,t,r){return  -1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return m(this,e,t,r,true)},u.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,false)},u.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 o=false;;)switch(n){case "hex":return w(this,e,t,r);case "utf8":case "utf-8":return _(this,e,t,r);case "ascii":case "latin1":case "binary":return E(this,e,t,r);case "base64":return k(this,e,t,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return S(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=true;}},u.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function I(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 x(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 B(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=V[e[o]];return i}function R(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function O(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,n,i,o){if(!u.isBuffer(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(r+n>e.length)throw new RangeError("Index out of range")}function N(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(e,t,r,n,o){return t=+t,r>>>=0,o||N(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function L(e,t,r,n,o){return t=+t,r>>>=0,o||N(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r=this.length;(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);var n=this.subarray(e,t);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||O(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){e>>>=0,t||O(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),i.read(this,e,true,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),i.read(this,e,false,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),i.read(this,e,true,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),i.read(this,e,false,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||P(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||P(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,255,0),this[t]=255&e,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i);}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i);}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeFloatLE=function(e,t,r){return M(this,e,t,true,r)},u.prototype.writeFloatBE=function(e,t,r){return M(this,e,t,false,r)},u.prototype.writeDoubleLE=function(e,t,r){return L(this,e,t,true,r)},u.prototype.writeDoubleBE=function(e,t,r){return L(this,e,t,false,r)},u.prototype.copy=function(e,t,r,n){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");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("Index out of range");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=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),i},u.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),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i);}}else "number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else {var s=u.isBuffer(e)?e:u.from(e,n),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=s[o%a];}return this};var U=/[^+/0-9A-Za-z-_]/g;function j(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r);}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function q(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(U,"")).length<2)return "";for(;e.length%4!=0;)e+="=";return e}(e))}function z(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 D(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function F(e){return e!=e}var V=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var n=16*r,i=0;i<16;++i)t[n+i]=e[r]+e[i];return t}();},8764:function(e,t,r){const n=r(9742),i=r(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=u,t.SlowBuffer=function(e){return +e!=e&&(e=0),u.alloc(+e)},t.INSPECT_MAX_BYTES=50;const s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!u.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|y(e,t);let n=a(r);const i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(Y(e,Uint8Array)){const t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return f(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Y(e,ArrayBuffer)||e&&Y(e.buffer,ArrayBuffer))return p(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(Y(e,SharedArrayBuffer)||e&&Y(e.buffer,SharedArrayBuffer)))return p(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return u.from(n,t,r);const i=function(e){if(u.isBuffer(e)){const t=0|d(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||G(e.length)?a(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return u.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return c(e),a(e<0?0:0|d(e))}function f(e){const t=e.length<0?0:0|d(e.length),r=a(t);for(let n=0;n<t;n+=1)r[n]=255&e[n];return r}function p(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,u.prototype),n}function d(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function y(e,t){if(u.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Y(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,n=arguments.length>2&&true===arguments[2];if(!n&&0===r)return 0;let i=false;for(;;)switch(t){case "ascii":case "latin1":case "binary":return r;case "utf8":case "utf-8":return K(e).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*r;case "hex":return r>>>1;case "base64":return $(e).length;default:if(i)return n?-1:K(e).length;t=(""+t).toLowerCase(),i=true;}}function g(e,t,r){let n=false;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 B(this,t,r);case "utf8":case "utf-8":return T(this,t,r);case "ascii":return I(this,t,r);case "latin1":case "binary":return x(this,t,r);case "base64":return C(this,t,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return R(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=true;}}function b(e,t,r){const n=e[t];e[t]=e[r],e[r]=n;}function m(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),G(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return  -1;r=e.length-1;}else if(r<0){if(!i)return  -1;r=0;}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,i){let o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return  -1;s=2,a/=2,u/=2,r/=2;}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){let n=-1;for(o=r;o<a;o++)if(l(e,o)===l(t,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*s}else  -1!==n&&(o-=o-n),n=-1;}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){let r=true;for(let n=0;n<u;n++)if(l(e,o+n)!==l(t,n)){r=false;break}if(r)return o}return  -1}function w(e,t,r,n){r=Number(r)||0;const i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=t.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(t.substr(2*s,2),16);if(G(n))return s;e[r+s]=n;}return s}function _(e,t,r,n){return Q(K(t,e.length-r),e,r,n)}function E(e,t,r,n){return Q(function(e){const t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function k(e,t,r,n){return Q($(t),e,r,n)}function S(e,t,r,n){return Q(function(e,t){let r,n,i;const o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function C(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);const n=[];let i=t;for(;i<r;){const t=e[i];let o=null,s=t>239?4:t>223?3:t>191?2:1;if(i+s<=r){let r,n,a,u;switch(s){case 1:t<128&&(o=t);break;case 2:r=e[i+1],128==(192&r)&&(u=(31&t)<<6|63&r,u>127&&(o=u));break;case 3:r=e[i+1],n=e[i+2],128==(192&r)&&128==(192&n)&&(u=(15&t)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=e[i+1],n=e[i+2],a=e[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(o=u));}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s;}return function(e){const t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=A));return r}(n)}t.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return  false}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:true,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:true,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(e,t,r){return function(e,t,r){return c(e),e<=0?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)}(e,t,r)},u.allocUnsafe=function(e){return h(e)},u.allocUnsafeSlow=function(e){return h(e)},u.isBuffer=function(e){return null!=e&&true===e._isBuffer&&e!==u.prototype},u.compare=function(e,t){if(Y(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),Y(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,n=t.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return  true;default:return  false}},u.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;const n=u.allocUnsafe(t);let i=0;for(r=0;r<e.length;++r){let t=e[r];if(Y(t,Uint8Array))i+t.length>n.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(n,i)):Uint8Array.prototype.set.call(n,t,i);else {if(!u.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,i);}i+=t.length;}return n},u.byteLength=y,u.prototype._isBuffer=true,u.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)b(this,t,t+1);return this},u.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)b(this,t,t+3),b(this,t+1,t+2);return this},u.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)b(this,t,t+7),b(this,t+1,t+6),b(this,t+2,t+5),b(this,t+3,t+4);return this},u.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?T(this,0,e):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(e,t,r,n,i){if(Y(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);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;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0);const a=Math.min(o,s),l=this.slice(n,i),c=e.slice(t,r);for(let e=0;e<a;++e)if(l[e]!==c[e]){o=l[e],s=c[e];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(e,t,r){return  -1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return m(this,e,t,r,true)},u.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,false)},u.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);}const 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");let o=false;for(;;)switch(n){case "hex":return w(this,e,t,r);case "utf8":case "utf-8":return _(this,e,t,r);case "ascii":case "latin1":case "binary":return E(this,e,t,r);case "base64":return k(this,e,t,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return S(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=true;}},u.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function I(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function x(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function B(e,t,r){const n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=t;n<r;++n)i+=Z[e[n]];return i}function R(e,t,r){const n=e.slice(t,r);let i="";for(let e=0;e<n.length-1;e+=2)i+=String.fromCharCode(n[e]+256*n[e+1]);return i}function O(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,n,i,o){if(!u.isBuffer(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(r+n>e.length)throw new RangeError("Index out of range")}function N(e,t,r,n,i){F(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function M(e,t,r,n,i){F(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o>>=8,e[r+6]=o,o>>=8,e[r+5]=o,o>>=8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function L(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(e,t,r,n,o){return t=+t,r>>>=0,o||L(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function j(e,t,r,n,o){return t=+t,r>>>=0,o||L(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){const r=this.length;(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);const n=this.subarray(e,t);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);let n=this[e],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[e+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);let n=this[e+--t],i=1;for(;t>0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=J((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),u.prototype.readBigUInt64BE=J((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return (BigInt(n)<<BigInt(32))+BigInt(i)})),u.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);let n=this[e],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[e+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);let n=t,i=1,o=this[e+--n];for(;n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||O(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){e>>>=0,t||O(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=J((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return (BigInt(n)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),u.prototype.readBigInt64BE=J((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return (BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)})),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),i.read(this,e,true,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),i.read(this,e,false,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),i.read(this,e,true,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),i.read(this,e,false,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||P(this,e,t,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||P(this,e,t,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,255,0),this[t]=255&e,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeBigUInt64LE=J((function(e,t=0){return N(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=J((function(e,t=0){return M(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n);}let i=0,o=1,s=0;for(this[t]=255&e;++i<r&&(o*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/o>>0)-s&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n);}let i=r-1,o=1,s=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/o>>0)-s&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeBigInt64LE=J((function(e,t=0){return N(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=J((function(e,t=0){return M(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(e,t,r){return U(this,e,t,true,r)},u.prototype.writeFloatBE=function(e,t,r){return U(this,e,t,false,r)},u.prototype.writeDoubleLE=function(e,t,r){return j(this,e,t,true,r)},u.prototype.writeDoubleBE=function(e,t,r){return j(this,e,t,false,r)},u.prototype.copy=function(e,t,r,n){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");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("Index out of range");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);const i=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),i},u.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),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){const t=e.charCodeAt(0);("utf8"===n&&t<128||"latin1"===n)&&(e=t);}}else "number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else {const o=u.isBuffer(e)?e:u.from(e,n),s=o.length;if(0===s)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=o[i%s];}return this};const q={};function z(e,t,r){q[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:true,configurable:true}),this.name=`${this.name} [${e}]`,this.stack,delete this.name;}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:true,enumerable:true,value:e,writable:true});}toString(){return `${this.name} [${e}]: ${this.message}`}};}function D(e){let t="",r=e.length;const n="-"===e[0]?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return `${e.slice(0,r)}${t}`}function F(e,t,r,n,i,o){if(e>r||e<t){const n="bigint"==typeof t?"n":"";let i;throw i=0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`,new q.ERR_OUT_OF_RANGE("value",i,e)}!function(e,t,r){V(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||W(t,e.length-(r+1));}(n,i,o);}function V(e,t){if("number"!=typeof e)throw new q.ERR_INVALID_ARG_TYPE(t,"number",e)}function W(e,t,r){if(Math.floor(e)!==e)throw V(e,r),new q.ERR_OUT_OF_RANGE("offset","an integer",e);if(t<0)throw new q.ERR_BUFFER_OUT_OF_BOUNDS;throw new q.ERR_OUT_OF_RANGE("offset",`>= ${0} and <= ${t}`,e)}z("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),z("ERR_INVALID_ARG_TYPE",(function(e,t){return `The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),z("ERR_OUT_OF_RANGE",(function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=D(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=D(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n}),RangeError);const H=/[^+/0-9A-Za-z-_]/g;function K(e,t){let r;t=t||1/0;const n=e.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r);}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function $(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(H,"")).length<2)return "";for(;e.length%4!=0;)e+="=";return e}(e))}function Q(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function G(e){return e!=e}const Z=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i];}return t}();function J(e){return "undefined"==typeof BigInt?X:e}function X(){throw new Error("BigInt not supported")}},1227:function(e,t,r){var n=r(4155);t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n));})),t.splice(i,0,r);},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug");}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug");}catch(e){}return !e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e},t.useColors=function(){return !("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=false;return ()=>{e||(e=true,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(2447)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return "[UnexpectedJSONParseError]: "+e.message}};},2447:function(e,t,r){e.exports=function(e){function t(e){let r,i,o,s=null;function a(...e){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if("%%"===r)return "%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];r=o.call(n,t),e.splice(s,1),s--;}return r})),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e);}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:true,configurable:false,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e;}}),"function"==typeof t.init&&t.init(a),a}function n(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")));},t.enabled=function(e){if("*"===e[e.length-1])return  true;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return  false;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return  true;return  false},t.humanize=r(7824),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");},Object.keys(e).forEach((r=>{t[r]=e[r];})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};},5981:function(e,t,r){var n=r(8764).Buffer,i=r(4155),o=r(8473),s=r(2840),a=r(5717),u=r(1852),l=n.from&&n.from!==Uint8Array.from?n.from([0]):new n([0]),c=function(e,t){e._corked?e.once("uncork",t):t();},h=function(e,t){return function(r){r?function(e,t){e._autoDestroy&&e.destroy(t);}(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end();}},f=function(){},p=function(e,t,r){if(!(this instanceof p))return new p(e,t,r);o.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||false!==r.autoDestroy,this._forwardDestroy=!r||false!==r.destroy,this._forwardEnd=!r||false!==r.end,this._corked=1,this._ondrain=null,this._drained=false,this._forwarding=false,this._unwrite=null,this._unread=null,this._ended=false,this.destroyed=false,e&&this.setWritable(e),t&&this.setReadable(t);};a(p,o.Duplex),p.obj=function(e,t,r){return r||(r={}),r.objectMode=true,r.highWaterMark=16,new p(e,t,r)},p.prototype.cork=function(){1==++this._corked&&this.emit("cork");},p.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork");},p.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&false!==e){var t=this,r=s(e,{writable:true,readable:false},h(this,this._forwardEnd)),n=function(){var e=t._ondrain;t._ondrain=null,e&&e();};this._unwrite&&i.nextTick(n),this._writable=e,this._writable.on("drain",n),this._unwrite=function(){t._writable.removeListener("drain",n),r();},this.uncork();}else this.end();},p.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else {if(null===e||false===e)return this.push(null),void this.resume();var t,r=this,n=s(e,{writable:false,readable:true},h(this)),i=function(){r._forward();},a=function(){r.push(null);};this._drained=true,this._readable=e,this._readable2=e._readableState?e:(t=e,new o.Readable({objectMode:true,highWaterMark:16}).wrap(t)),this._readable2.on("readable",i),this._readable2.on("end",a),this._unread=function(){r._readable2.removeListener("readable",i),r._readable2.removeListener("end",a),n();},this._forward();}},p.prototype._read=function(){this._drained=true,this._forward();},p.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=true;this._drained&&null!==(e=u(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=false;}},p.prototype.destroy=function(e,t){if(t||(t=f),this.destroyed)return t(null);this.destroyed=true;var r=this;i.nextTick((function(){r._destroy(e),t(null);}));},p.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e);}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close");},p.prototype._write=function(e,t,r){if(!this.destroyed)return this._corked?c(this,this._write.bind(this,e,t,r)):e===l?this._finish(r):this._writable?void(false===this._writable.write(e)?this._ondrain=r:this.destroyed||r()):r()},p.prototype._finish=function(e){var t=this;this.emit("preend"),c(this,(function(){var r,n;n=function(){ false===t._writableState.prefinished&&(t._writableState.prefinished=true),t.emit("prefinish"),c(t,e);},(r=t._forwardEnd&&t._writable)?r._writableState&&r._writableState.finished?n():r._writableState?r.end(n):(r.end(),n()):n();}));},p.prototype.end=function(e,t,r){return "function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=true,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(l),o.Writable.prototype.end.call(this,r))},e.exports=p;},2840:function(e,t,r){var n=r(4155),i=r(778),o=function(){},s=function(e,t,r){if("function"==typeof t)return s(e,null,t);t||(t={}),r=i(r||o);var a=e._writableState,u=e._readableState,l=t.readable||false!==t.readable&&e.readable,c=t.writable||false!==t.writable&&e.writable,h=false,f=function(){e.writable||p();},p=function(){c=false,l||r.call(e);},d=function(){l=false,c||r.call(e);},y=function(t){r.call(e,t?new Error("exited with error code: "+t):null);},g=function(t){r.call(e,t);},b=function(){n.nextTick(m);},m=function(){if(!h)return (!l||u&&u.ended&&!u.destroyed)&&(!c||a&&a.ended&&!a.destroyed)?void 0:r.call(e,new Error("premature close"))},v=function(){e.req.on("finish",p);};return function(e){return e.setHeader&&"function"==typeof e.abort}(e)?(e.on("complete",p),e.on("abort",b),e.req?v():e.on("request",v)):c&&!a&&(e.on("end",f),e.on("close",f)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",y),e.on("end",d),e.on("finish",p),false!==t.error&&e.on("error",g),e.on("close",b),function(){h=true,e.removeListener("complete",p),e.removeListener("abort",b),e.removeListener("request",v),e.req&&e.req.removeListener("finish",p),e.removeListener("end",f),e.removeListener("close",f),e.removeListener("finish",p),e.removeListener("exit",y),e.removeListener("end",d),e.removeListener("error",g),e.removeListener("close",b);}};e.exports=s;},7187:function(e){var t=Object.create||function(e){var t=function(){};return t.prototype=e,new t},r=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return r},n=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function i(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=t(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0;}e.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._maxListeners=void 0;var o,s=10;try{var a={};Object.defineProperty&&Object.defineProperty(a,"x",{value:0}),o=0===a.x;}catch(e){o=false;}function u(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function l(e,t,r){if(t)e.call(r);else for(var n=e.length,i=v(e,n),o=0;o<n;++o)i[o].call(r);}function c(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,o=v(e,i),s=0;s<i;++s)o[s].call(r,n);}function h(e,t,r,n,i){if(t)e.call(r,n,i);else for(var o=e.length,s=v(e,o),a=0;a<o;++a)s[a].call(r,n,i);}function f(e,t,r,n,i,o){if(t)e.call(r,n,i,o);else for(var s=e.length,a=v(e,s),u=0;u<s;++u)a[u].call(r,n,i,o);}function p(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,o=v(e,i),s=0;s<i;++s)o[s].apply(r,n);}function d(e,r,n,i){var o,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",r,n.listener?n.listener:n),s=e._events),a=s[r]):(s=e._events=t(null),e._eventsCount=0),a){if("function"==typeof a?a=s[r]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),!a.warned&&(o=u(e))&&o>0&&a.length>o){a.warned=true;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(r)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=e,l.type=r,l.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message);}}else a=s[r]=n,++e._eventsCount;return e}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=true,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e);}}function g(e,t,r){var i={fired:false,wrapFn:void 0,target:e,type:t,listener:r},o=n.call(y,i);return o.listener=r,i.wrapFn=o,o}function b(e,t,r){var n=e._events;if(!n)return [];var i=n[t];return i?"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):v(i,i.length):[]}function m(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 v(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}o?Object.defineProperty(i,"defaultMaxListeners",{enumerable:true,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');s=e;}}):i.defaultMaxListeners=s,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 u(this)},i.prototype.emit=function(e){var t,r,n,i,o,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return  false;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var u=new Error('Unhandled "error" event. ('+t+")");throw u.context=t,u}if(!(r=s[e]))return  false;var d="function"==typeof r;switch(n=arguments.length){case 1:l(r,d,this);break;case 2:c(r,d,this,arguments[1]);break;case 3:h(r,d,this,arguments[1],arguments[2]);break;case 4:f(r,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o<n;o++)i[o-1]=arguments[o];p(r,d,this,i);}return  true},i.prototype.addListener=function(e,t){return d(this,e,t,false)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return d(this,e,t,true)},i.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,g(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,g(this,e,t)),this},i.prototype.removeListener=function(e,r){var n,i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if(!(i=this._events))return this;if(!(n=i[e]))return this;if(n===r||n.listener===r)0==--this._eventsCount?this._events=t(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if("function"!=typeof n){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;0===o?n.shift():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();}(n,o),1===n.length&&(i[e]=n[0]),i.removeListener&&this.emit("removeListener",e,a||r);}return this},i.prototype.removeAllListeners=function(e){var n,i,o;if(!(i=this._events))return this;if(!i.removeListener)return 0===arguments.length?(this._events=t(null),this._eventsCount=0):i[e]&&(0==--this._eventsCount?this._events=t(null):delete i[e]),this;if(0===arguments.length){var s,a=r(i);for(o=0;o<a.length;++o)"removeListener"!==(s=a[o])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=t(null),this._eventsCount=0,this}if("function"==typeof(n=i[e]))this.removeListener(e,n);else if(n)for(o=n.length-1;o>=0;o--)this.removeListener(e,n[o]);return this},i.prototype.listeners=function(e){return b(this,e,true)},i.prototype.rawListeners=function(e){return b(this,e,false)},i.listenerCount=function(e,t){return "function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},i.prototype.listenerCount=m,i.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};},645:function(e,t){t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,l=u>>1,c=-7,h=r?i-1:0,f=r?-1:1,p=e[t+h];for(h+=f,o=p&(1<<-c)-1,p>>=-c,c+=a;c>0;o=256*o+e[t+h],h+=f,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+e[t+h],h+=f,c-=8);if(0===o)o=1-l;else {if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=l;}return (p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,l=8*o-i-1,c=(1<<l)-1,h=c>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+h>=1?f/u:f*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(t*u-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[r+p]=255&s,p+=d,s/=256,l-=8);e[r+p-d]|=128*y;};},5717:function(e){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}}));}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e;}};},9246:function(e,t,r){r.d(t,{l4:function(){return f}});var i=function(e){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=e;};function o(e){var t=this;void 0===e&&(e=[]);var r=0,n=void 0,o=void 0;this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){n=o=void 0,r=0;},this.front=function(){return null==n?void 0:n.value},this.back=function(){return null==o?void 0:o.value},this.forEach=function(e){for(var t=n,r=0;t;){if(void 0===t.value)throw new Error("unknown error");e(t.value,r++),t=t.next;}},this.getElementByPos=function(e){if(e<0||e>=r)throw new Error("pos must more then 0 and less then the list length");for(var t=n;e--&&t;)t=t.next;if(!t||void 0===t.value)throw new Error("unknown error");return t.value},this.eraseElementByPos=function(e){if(e<0||e>=r)throw new Error("erase pos must more then 0 and less then the list length");if(0===e)this.popFront();else if(e===r-1)this.popBack();else {for(var t=n;e--;){if(!(null==t?void 0:t.next))throw new Error("unknown error");t=t.next;}if(!t||!t.pre||!t.next)throw new Error("unknown error");var i=t.pre,o=t.next;o.pre=i,i.next=o,r>0&&--r;}},this.eraseElementByValue=function(e){for(;n&&n.value===e;)this.popFront();for(;o&&o.value===e;)this.popBack();if(n)for(var t=n;t;){if(t.value===e){var i=t.pre,s=t.next;s&&(s.pre=i),i&&(i.next=s),r>0&&--r;}t=t.next;}},this.pushBack=function(e){if(null==e)throw new Error("you can't push null or undefined here");++r;var t=new i(e);o?(o.next=t,t.pre=o,o=t):n=o=t;},this.popBack=function(){o&&(r>0&&--r,o&&(n===o?n=o=void 0:(o=o.pre)&&(o.next=void 0)));},this.setElementByPos=function(e,t){if(null==t)throw new Error("you can't set null or undefined here");if(e<0||e>=r)throw new Error("pos must more then 0 and less then the list length");for(var i=n;e--;){if(!i)throw new Error("unknown error");i=i.next;}i&&(i.value=t);},this.insert=function(e,t,o){if(void 0===o&&(o=1),null==t)throw new Error("you can't insert null or undefined here");if(e<0||e>r)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(o<0)throw new Error("insert size must more than 0");if(0===e)for(;o--;)this.pushFront(t);else if(e===r)for(;o--;)this.pushBack(t);else {for(var s=n,a=1;a<e;++a){if(!(null==s?void 0:s.next))throw new Error("unknown error");s=null==s?void 0:s.next;}if(!s)throw new Error("unknown error");var u=s.next;for(r+=o;o--;)s.next=new i(t),s.next.pre=s,s=s.next;s.next=u,u&&(u.pre=s);}},this.find=function(e){for(var t=n;t;){if(t.value===e)return  true;t=t.next;}return  false},this.reverse=function(){for(var e=n,t=o,i=0;e&&t&&2*i<r;){var s=e.value;e.value=t.value,t.value=s,e=e.next,t=t.pre,++i;}},this.unique=function(){for(var e=n;e;){for(var t=e;t&&t.next&&t.value===t.next.value;)t=t.next,r>0&&--r;e.next=t.next,e.next&&(e.next.pre=e),e=e.next;}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e);})),t.sort(e);var r=n;t.forEach((function(e){r&&(r.value=e,r=r.next);}));},this.pushFront=function(e){if(null==e)throw new Error("you can't push null or undefined here");++r;var t=new i(e);n?(t.next=n,n.pre=t,n=t):n=o=t;},this.popFront=function(){n&&(r>0&&--r,n&&(n===o?n=o=void 0:(n=n.next)&&(n.pre=void 0)));},this.merge=function(e){var t=this,s=n;e.forEach((function(e){for(;s&&void 0!==s.value&&s.value<=e;)s=s.next;if(void 0===s)t.pushBack(e),s=o;else if(s===n)t.pushFront(e),s=n;else {++r;var a=s.pre;a&&(a.next=new i(e),a.next.pre=a,a.next.next=s,s&&(s.pre=a.next));}}));},this[Symbol.iterator]=function(){return function(){var e;return function(e,t){var r,n,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(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s);}catch(e){o=[6,e],n=0;}finally{r=i=0;}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:true}}([o,a])}}}(this,(function(t){switch(t.label){case 0:e=n,t.label=1;case 1:if(void 0===e)return [3,3];if(!e.value)throw new Error("unknown error");return [4,e.value];case 2:return t.sent(),e=e.next,[3,1];case 3:return [2]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this);}Object.freeze(o);var s=o;function a(e){var t=this;void 0===e&&(e=[]);var r=[],n=0,i=0,o=0,s=0,u=0,l=0;this.size=function(){return l},this.empty=function(){return 0===l},this.clear=function(){n=o=i=s=u=l=0,h.call(this,a.bucketSize),l=0;},this.front=function(){return r[n][i]},this.back=function(){return r[o][s]},this.forEach=function(e){if(!this.empty()){var t=0;if(n!==o){for(l=i;l<a.bucketSize;++l)e(r[n][l],t++);for(l=n+1;l<o;++l)for(var u=0;u<a.bucketSize;++u)e(r[l][u],t++);for(l=0;l<=s;++l)e(r[o][l],t++);}else for(var l=i;l<=s;++l)e(r[n][l],t++);}};var c=function(e){var t=n*a.bucketSize+i,r=t+e,u=o*a.bucketSize+s;if(r<t||r>u)throw new Error("pos should more than 0 and less than queue's size");return {curNodeBucketIndex:Math.floor(r/a.bucketSize),curNodePointerIndex:r%a.bucketSize}};this.getElementByPos=function(e){var t=c(e),n=t.curNodeBucketIndex,i=t.curNodePointerIndex;return r[n][i]},this.eraseElementByPos=function(e){var t=this;if(e<0||e>l)throw new Error("pos should more than 0 and less than queue's size");if(0===e)this.popFront();else if(e===this.size())this.popBack();else {for(var r=[],n=e+1;n<l;++n)r.push(this.getElementByPos(n));this.cut(e),this.popBack(),r.forEach((function(e){return t.pushBack(e)}));}},this.eraseElementByValue=function(e){if(!this.empty()){var t=[];this.forEach((function(r){r!==e&&t.push(r);}));for(var r=t.length,n=0;n<r;++n)this.setElementByPos(n,t[n]);this.cut(r-1);}};var h=function(e){for(var t=[],c=e*a.sigma,h=Math.max(Math.ceil(c/a.bucketSize),2),f=0;f<h;++f)t.push(new Array(a.bucketSize));var p=Math.ceil(e/a.bucketSize),d=Math.floor(h/2)-Math.floor(p/2),y=d,g=0;if(this.size())for(f=0;f<p;++f){for(var b=0;b<a.bucketSize;++b)if(t[d+f][b]=this.front(),this.popFront(),this.empty()){y=d+f,g=b;break}if(this.empty())break}r=t,n=d,i=0,o=y,s=g,u=h,l=e;};this.pushBack=function(e){this.empty()||(o===u-1&&s===a.bucketSize-1&&h.call(this,this.size()),s<a.bucketSize-1?++s:o<u-1&&(++o,s=0)),++l,r[o][s]=e;},this.popBack=function(){this.empty()||(1!==this.size()&&(s>0?--s:n<o&&(--o,s=a.bucketSize-1)),l>0&&--l);},this.setElementByPos=function(e,t){var n=c(e),i=n.curNodeBucketIndex,o=n.curNodePointerIndex;r[i][o]=t;},this.insert=function(e,t,r){var n=this;if(void 0===r&&(r=1),0===e)for(;r--;)this.pushFront(t);else if(e===this.size())for(;r--;)this.pushBack(t);else {for(var i=[],o=e;o<l;++o)i.push(this.getElementByPos(o));for(this.cut(e-1),o=0;o<r;++o)this.pushBack(t);i.forEach((function(e){return n.pushBack(e)}));}},this.find=function(e){if(n===o){for(var t=i;t<=s;++t)if(r[n][t]===e)return  true;return  false}for(t=i;t<a.bucketSize;++t)if(r[n][t]===e)return  true;for(t=n+1;t<o;++t)for(var u=0;u<a.bucketSize;++u)if(r[t][u]===e)return  true;for(t=0;t<=s;++t)if(r[o][t]===e)return  true;return  false},this.reverse=function(){for(var e=0,t=l-1;e<t;){var r=this.getElementByPos(e);this.setElementByPos(e,this.getElementByPos(t)),this.setElementByPos(t,r),++e,--t;}},this.unique=function(){if(!this.empty()){var e=[],t=this.front();this.forEach((function(r,n){0!==n&&r===t||(e.push(r),t=r);}));for(var r=0;r<l;++r)this.setElementByPos(r,e[r]);this.cut(e.length-1);}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e);})),t.sort(e);for(var r=0;r<l;++r)this.setElementByPos(r,t[r]);},this.pushFront=function(e){this.empty()||(0===n&&0===i&&h.call(this,this.size()),i>0?--i:n>0&&(--n,i=a.bucketSize-1)),++l,r[n][i]=e;},this.popFront=function(){this.empty()||(1!==this.size()&&(i<a.bucketSize-1?++i:n<o&&(++n,i=0)),l>0&&--l);},this.shrinkToFit=function(){var e=this,t=[];this.forEach((function(e){t.push(e);}));var n=t.length;r=[];for(var i=Math.ceil(n/a.bucketSize),o=0;o<i;++o)r.push(new Array(a.bucketSize));this.clear(),t.forEach((function(t){return e.pushBack(t)}));},this.cut=function(e){if(e<0)this.clear();else {var t=c(e),r=t.curNodeBucketIndex,n=t.curNodePointerIndex;o=r,s=n,l=e+1;}},this[Symbol.iterator]=function(){return function(){var e,t;return function(e,t){var r,n,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(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s);}catch(e){o=[6,e],n=0;}finally{r=i=0;}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:true}}([o,a])}}}(this,(function(u){switch(u.label){case 0:if(0===l)return [2];if(n!==o)return [3,5];t=i,u.label=1;case 1:return t<=s?[4,r[n][t]]:[3,4];case 2:u.sent(),u.label=3;case 3:return ++t,[3,1];case 4:return [2];case 5:t=i,u.label=6;case 6:return t<a.bucketSize?[4,r[n][t]]:[3,9];case 7:u.sent(),u.label=8;case 8:return ++t,[3,6];case 9:t=n+1,u.label=10;case 10:if(!(t<o))return [3,15];e=0,u.label=11;case 11:return e<a.bucketSize?[4,r[t][e]]:[3,14];case 12:u.sent(),u.label=13;case 13:return ++e,[3,11];case 14:return ++t,[3,10];case 15:t=0,u.label=16;case 16:return t<=s?[4,r[o][t]]:[3,19];case 17:u.sent(),u.label=18;case 18:return ++t,[3,16];case 19:return [2]}}))}()},function(){var i=a.bucketSize;e.size?i=e.size():e.length&&(i=e.length);var s=i*a.sigma;u=Math.ceil(s/a.bucketSize),u=Math.max(u,3);for(var l=0;l<u;++l)r.push(new Array(a.bucketSize));var c=Math.ceil(i/a.bucketSize);n=Math.floor(u/2)-Math.floor(c/2),o=n,e.forEach((function(e){return t.pushBack(e)}));}(),Object.freeze(this);}a.sigma=3,a.bucketSize=5e3,Object.freeze(a);var u=function(){function e(e,t){this.color=true,this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0,this.leftChild=void 0,this.rightChild=void 0,this.key=e,this.value=t;}return e.prototype.rotateLeft=function(){var e=this.parent,t=this.brother,r=this.leftChild,n=this.rightChild;if(!n)throw new Error("unknown error");var i=n.leftChild,o=n.rightChild;return e&&(e.leftChild===this?e.leftChild=n:e.rightChild===this&&(e.rightChild=n)),n.parent=e,n.brother=t,n.leftChild=this,n.rightChild=o,t&&(t.brother=n),this.parent=n,this.brother=o,this.leftChild=r,this.rightChild=i,o&&(o.parent=n,o.brother=this),r&&(r.parent=this,r.brother=i),i&&(i.parent=this,i.brother=r),n},e.prototype.rotateRight=function(){var e=this.parent,t=this.brother,r=this.leftChild;if(!r)throw new Error("unknown error");var n=this.rightChild,i=r.leftChild,o=r.rightChild;return e&&(e.leftChild===this?e.leftChild=r:e.rightChild===this&&(e.rightChild=r)),r.parent=e,r.brother=t,r.leftChild=i,r.rightChild=this,t&&(t.brother=r),i&&(i.parent=r,i.brother=this),this.parent=r,this.brother=i,this.leftChild=o,this.rightChild=n,o&&(o.parent=this,o.brother=n),n&&(n.parent=this,n.brother=o),r},e.prototype.remove=function(){if(this.leftChild||this.rightChild)throw new Error("can only remove leaf node");this.parent&&(this===this.parent.leftChild?this.parent.leftChild=void 0:this===this.parent.rightChild&&(this.parent.rightChild=void 0)),this.brother&&(this.brother.brother=void 0),this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0;},e.TreeNodeColorType={red:true,black:false},e}();Object.freeze(u);var l=u,c=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function h(e,t){var r=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var n=0,i=new l;i.color=l.TreeNodeColorType.black,this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){n=0,i.key=void 0,i.leftChild=i.rightChild=i.brother=i.parent=void 0,i.color=l.TreeNodeColorType.black;};var o=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?o(e.leftChild):e},s=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?s(e.rightChild):e};this.front=function(){if(!this.empty())return o(i).key},this.back=function(){if(!this.empty())return s(i).key},this.forEach=function(e){var t,r,n=0;try{for(var i=c(this),o=i.next();!o.done;o=i.next())e(o.value,n++);}catch(e){t={error:e};}finally{try{o&&!o.done&&(r=i.return)&&r.call(i);}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,r;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var n=0;try{for(var i=c(this),o=i.next();!o.done;o=i.next()){var s=o.value;if(n===e)return s;++n;}}catch(e){t={error:e};}finally{try{o&&!o.done&&(r=i.return)&&r.call(i);}finally{if(t)throw t.error}}throw new Error("unknown error")};var a=function(e){var t=e.parent;if(!t){if(e===i)return;throw new Error("unknown error")}if(e.color!==l.TreeNodeColorType.red){var r=e.brother;if(!r)throw new Error("unknown error");if(e===t.leftChild)if(r.color===l.TreeNodeColorType.red){r.color=l.TreeNodeColorType.black,t.color=l.TreeNodeColorType.red;var n=t.rotateLeft();i===t&&(i=n),a(e);}else r.color===l.TreeNodeColorType.black&&(r.rightChild&&r.rightChild.color===l.TreeNodeColorType.red?(r.color=t.color,t.color=l.TreeNodeColorType.black,r.rightChild&&(r.rightChild.color=l.TreeNodeColorType.black),n=t.rotateLeft(),i===t&&(i=n),e.color=l.TreeNodeColorType.black):r.rightChild&&r.rightChild.color!==l.TreeNodeColorType.black||!r.leftChild||r.leftChild.color!==l.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==l.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==l.TreeNodeColorType.black||(r.color=l.TreeNodeColorType.red,a(t)):(r.color=l.TreeNodeColorType.red,r.leftChild&&(r.leftChild.color=l.TreeNodeColorType.black),n=r.rotateRight(),i===r&&(i=n),a(e)));else e===t.rightChild&&(r.color===l.TreeNodeColorType.red?(r.color=l.TreeNodeColorType.black,t.color=l.TreeNodeColorType.red,n=t.rotateRight(),i===t&&(i=n),a(e)):r.color===l.TreeNodeColorType.black&&(r.leftChild&&r.leftChild.color===l.TreeNodeColorType.red?(r.color=t.color,t.color=l.TreeNodeColorType.black,r.leftChild&&(r.leftChild.color=l.TreeNodeColorType.black),n=t.rotateRight(),i===t&&(i=n),e.color=l.TreeNodeColorType.black):r.leftChild&&r.leftChild.color!==l.TreeNodeColorType.black||!r.rightChild||r.rightChild.color!==l.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==l.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==l.TreeNodeColorType.black||(r.color=l.TreeNodeColorType.red,a(t)):(r.color=l.TreeNodeColorType.red,r.rightChild&&(r.rightChild.color=l.TreeNodeColorType.black),n=r.rotateLeft(),i===r&&(i=n),a(e))));}else e.color=l.TreeNodeColorType.black;},u=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=o(t.rightChild);var r=e.key;e.key=t.key,t.key=r,e=t;}t.leftChild&&(t=s(t.leftChild),r=e.key,e.key=t.key,t.key=r,e=t);}a(t),t&&t.remove(),--n,i.color=l.TreeNodeColorType.black;},h=function(e,t){return !(!e||void 0===e.key)&&(!!h(e.leftChild,t)||!!t(e)||h(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=n)throw new Error("pos must more than 0 and less than set's size");var t=0;h(i,(function(r){return e===t?(u(r),true):(++t,false)}));},this.eraseElementByValue=function(e){if(!this.empty()){var r=d(i,e);void 0!==r&&void 0!==r.key&&0===t(r.key,e)&&u(r);}};var f=function(e,r){if(!e||void 0===e.key)throw new Error("unknown error");var n=t(r,e.key);return n<0?e.leftChild?f(e.leftChild,r):(e.leftChild=new l,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):n>0?e.rightChild?f(e.rightChild,r):(e.rightChild=new l,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},p=function(e){var t=e.parent;if(!t){if(e===i)return;throw new Error("unknown error")}if(t.color!==l.TreeNodeColorType.black&&t.color===l.TreeNodeColorType.red){var r=t.brother,n=t.parent;if(!n)throw new Error("unknown error");if(r&&r.color===l.TreeNodeColorType.red)r.color=t.color=l.TreeNodeColorType.black,n.color=l.TreeNodeColorType.red,p(n);else if(!r||r.color===l.TreeNodeColorType.black)if(t===n.leftChild)if(e===t.leftChild){t.color=l.TreeNodeColorType.black,n.color=l.TreeNodeColorType.red;var o=n.rotateRight();n===i&&(i=o);}else e===t.rightChild&&(o=t.rotateLeft(),n===i&&(i=o),p(t));else t===n.rightChild&&(e===t.leftChild?(o=t.rotateRight(),n===i&&(i=o),p(t)):e===t.rightChild&&(t.color=l.TreeNodeColorType.black,n.color=l.TreeNodeColorType.red,o=n.rotateLeft(),n===i&&(i=o)));}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(this.empty())return ++n,i.key=e,void(i.color=l.TreeNodeColorType.black);var r=f(i,e);void 0!==r.key&&0===t(r.key,e)||(++n,r.key=e,p(r),i.color=l.TreeNodeColorType.black);};var d=function(e,r){if(e&&void 0!==e.key){var n=t(r,e.key);return n<0?d(e.leftChild,r):n>0?d(e.rightChild,r):e}};this.find=function(e){var r=d(i,e);return void 0!==r&&void 0!==r.key&&0===t(r.key,e)};var y=function(e,r){if(e&&void 0!==e.key){var n=t(e.key,r);if(0===n)return e.key;if(n<0)return y(e.rightChild,r);var i=y(e.leftChild,r);return void 0!==i?i:e.key}};this.lowerBound=function(e){return y(i,e)};var g=function(e,r){if(e&&void 0!==e.key){if(t(e.key,r)<=0)return g(e.rightChild,r);var n=g(e.leftChild,r);return void 0!==n?n:e.key}};this.upperBound=function(e){return g(i,e)};var b=function(e,r){if(e&&void 0!==e.key){var n=t(e.key,r);if(0===n)return e.key;if(n>0)return b(e.leftChild,r);var i=b(e.rightChild,r);return void 0!==i?i:e.key}};this.reverseLowerBound=function(e){return b(i,e)};var m=function(e,r){if(e&&void 0!==e.key){if(t(e.key,r)>=0)return m(e.leftChild,r);var n=m(e.rightChild,r);return void 0!==n?n:e.key}};this.reverseUpperBound=function(e){return m(i,e)},this.union=function(e){var t=this;e.forEach((function(e){return t.insert(e)}));},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(i)};var v=function(e){return function(e,t){var r,n,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(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s);}catch(e){o=[6,e],n=0;}finally{r=i=0;}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:true}}([o,a])}}}(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key?[5,c(v(e.leftChild))]:[2];case 1:return t.sent(),[4,e.key];case 2:return t.sent(),[5,c(v(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return v(i)},e.forEach((function(e){return r.insert(e)})),Object.freeze(this);}Object.freeze(h);var f=h,p=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function d(e,t){var r=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var n=0,i=new l;i.color=l.TreeNodeColorType.black,this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){n=0,i.key=i.value=void 0,i.leftChild=i.rightChild=i.brother=void 0;};var o=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?o(e.leftChild):e},s=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?s(e.rightChild):e};this.front=function(){if(!this.empty()){var e=o(i);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return {key:e.key,value:e.value}}},this.back=function(){if(!this.empty()){var e=s(i);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return {key:e.key,value:e.value}}},this.forEach=function(e){var t,r,n=0;try{for(var i=p(this),o=i.next();!o.done;o=i.next())e(o.value,n++);}catch(e){t={error:e};}finally{try{o&&!o.done&&(r=i.return)&&r.call(i);}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,r;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var n=0;try{for(var i=p(this),o=i.next();!o.done;o=i.next()){var s=o.value;if(n===e)return s;++n;}}catch(e){t={error:e};}finally{try{o&&!o.done&&(r=i.return)&&r.call(i);}finally{if(t)throw t.error}}throw new Error("unknown Error")};var a=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value){var n=t(e.key,r);return 0===n?{key:e.key,value:e.value}:n<0?a(e.rightChild,r):a(e.leftChild,r)||{key:e.key,value:e.value}}};this.lowerBound=function(e){return a(i,e)};var u=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,r)<=0?u(e.rightChild,r):u(e.leftChild,r)||{key:e.key,value:e.value}};this.upperBound=function(e){return u(i,e)};var c=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value){var n=t(e.key,r);return 0===n?{key:e.key,value:e.value}:n>0?c(e.leftChild,r):c(e.rightChild,r)||{key:e.key,value:e.value}}};this.reverseLowerBound=function(e){return c(i,e)};var h=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,r)>=0?h(e.leftChild,r):h(e.rightChild,r)||{key:e.key,value:e.value}};this.reverseUpperBound=function(e){return h(i,e)};var f=function(e){var t=e.parent;if(!t){if(e===i)return;throw new Error("unknown error")}if(e.color!==l.TreeNodeColorType.red){var r=e.brother;if(!r)throw new Error("unknown error");if(e===t.leftChild)if(r.color===l.TreeNodeColorType.red){r.color=l.TreeNodeColorType.black,t.color=l.TreeNodeColorType.red;var n=t.rotateLeft();i===t&&(i=n),f(e);}else r.color===l.TreeNodeColorType.black&&(r.rightChild&&r.rightChild.color===l.TreeNodeColorType.red?(r.color=t.color,t.color=l.TreeNodeColorType.black,r.rightChild&&(r.rightChild.color=l.TreeNodeColorType.black),n=t.rotateLeft(),i===t&&(i=n),e.color=l.TreeNodeColorType.black):r.rightChild&&r.rightChild.color!==l.TreeNodeColorType.black||!r.leftChild||r.leftChild.color!==l.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==l.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==l.TreeNodeColorType.black||(r.color=l.TreeNodeColorType.red,f(t)):(r.color=l.TreeNodeColorType.red,r.leftChild&&(r.leftChild.color=l.TreeNodeColorType.black),n=r.rotateRight(),i===r&&(i=n),f(e)));else e===t.rightChild&&(r.color===l.TreeNodeColorType.red?(r.color=l.TreeNodeColorType.black,t.color=l.TreeNodeColorType.red,n=t.rotateRight(),i===t&&(i=n),f(e)):r.color===l.TreeNodeColorType.black&&(r.leftChild&&r.leftChild.color===l.TreeNodeColorType.red?(r.color=t.color,t.color=l.TreeNodeColorType.black,r.leftChild&&(r.leftChild.color=l.TreeNodeColorType.black),n=t.rotateRight(),i===t&&(i=n),e.color=l.TreeNodeColorType.black):r.leftChild&&r.leftChild.color!==l.TreeNodeColorType.black||!r.rightChild||r.rightChild.color!==l.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==l.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==l.TreeNodeColorType.black||(r.color=l.TreeNodeColorType.red,f(t)):(r.color=l.TreeNodeColorType.red,r.rightChild&&(r.rightChild.color=l.TreeNodeColorType.black),n=r.rotateLeft(),i===r&&(i=n),f(e))));}else e.color=l.TreeNodeColorType.black;},d=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=o(t.rightChild);var r=e.key;e.key=t.key,t.key=r;var a=e.value;e.value=t.value,t.value=a,e=t;}t.leftChild&&(t=s(t.leftChild),r=e.key,e.key=t.key,t.key=r,a=e.value,e.value=t.value,t.value=a,e=t);}f(t),t&&t.remove(),--n,i.color=l.TreeNodeColorType.black;},y=function(e,t){return !(!e||void 0===e.key)&&(!!y(e.leftChild,t)||!!t(e)||y(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=n)throw new Error("pos must more than 0 and less than set's size");var t=0;y(i,(function(r){return e===t?(d(r),true):(++t,false)}));},this.eraseElementByKey=function(e){if(!this.empty()){var r=m(i,e);void 0!==r&&void 0!==r.key&&0===t(r.key,e)&&d(r);}};var g=function(e,r){if(!e||void 0===e.key)throw new Error("unknown error");var n=t(r,e.key);return n<0?e.leftChild?g(e.leftChild,r):(e.leftChild=new l,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):n>0?e.rightChild?g(e.rightChild,r):(e.rightChild=new l,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},b=function(e){var t=e.parent;if(!t){if(e===i)return;throw new Error("unknown error")}if(t.color!==l.TreeNodeColorType.black&&t.color===l.TreeNodeColorType.red){var r=t.brother,n=t.parent;if(!n)throw new Error("unknown error");if(r&&r.color===l.TreeNodeColorType.red)r.color=t.color=l.TreeNodeColorType.black,n.color=l.TreeNodeColorType.red,b(n);else if(!r||r.color===l.TreeNodeColorType.black)if(t===n.leftChild)if(e===t.leftChild){t.color=l.TreeNodeColorType.black,n.color=l.TreeNodeColorType.red;var o=n.rotateRight();n===i&&(i=o);}else e===t.rightChild&&(o=t.rotateLeft(),n===i&&(i=o),b(t));else t===n.rightChild&&(e===t.leftChild?(o=t.rotateRight(),n===i&&(i=o),b(t)):e===t.rightChild&&(t.color=l.TreeNodeColorType.black,n.color=l.TreeNodeColorType.red,o=n.rotateLeft(),n===i&&(i=o)));}};this.setElement=function(e,r){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=r){if(this.empty())return ++n,i.key=e,i.value=r,void(i.color=l.TreeNodeColorType.black);var o=g(i,e);void 0===o.key||0!==t(o.key,e)?(++n,o.key=e,o.value=r,b(o),i.color=l.TreeNodeColorType.black):o.value=r;}else this.eraseElementByKey(e);};var m=function(e,r){if(e&&void 0!==e.key){var n=t(r,e.key);return n<0?m(e.leftChild,r):n>0?m(e.rightChild,r):e}};this.find=function(e){return !!m(i,e)},this.getElementByKey=function(e){var t=m(i,e);if(void 0===(null==t?void 0:t.key)||void 0===(null==t?void 0:t.value))throw new Error("unknown error");return t.value},this.union=function(e){var t=this;e.forEach((function(e){var r=e.key,n=e.value;return t.setElement(r,n)}));},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(i)};var v=function(e){return function(e,t){var r,n,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(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s);}catch(e){o=[6,e],n=0;}finally{r=i=0;}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:true}}([o,a])}}}(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key&&void 0!==e.value?[5,p(v(e.leftChild))]:[2];case 1:return t.sent(),[4,{key:e.key,value:e.value}];case 2:return t.sent(),[5,p(v(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return v(i)},e.forEach((function(e){var t=e.key,n=e.value;return r.setElement(t,n)})),Object.freeze(this);}Object.freeze(d);var y=d;function g(e,t,r){var n=this;if(void 0===e&&(e=[]),void 0===t&&(t=g.initSize),r=r||function(e){var t=0,r="";if("number"==typeof e)t=((t=Math.floor(e))<<5)-t,t&=t;else {r="string"!=typeof e?JSON.stringify(e):e;for(var n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n),t&=t;}return t^t>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var i=0,o=[],a=Math.max(g.initSize,Math.min(g.maxSize,t));this.size=function(){return i},this.empty=function(){return 0===i},this.clear=function(){i=0,a=t,o=[];},this.forEach=function(e){var t=0;o.forEach((function(r){r.forEach((function(r){e(r,t++);}));}));};var u=function(e){if(!(e>=g.maxSize)){a=2*e;var t=[];o.forEach((function(n,i){if(!n.empty()){if(n instanceof s&&1===n.size()){var u=n.front();if(void 0===u)throw new Error("unknown error");t[r(u)&a-1]=new s([u]);}else if(n instanceof f){var l=new s,c=new s;n.forEach((function(t){0==(r(t)&e)?l.pushBack(t):c.pushBack(t);})),l.size()>g.untreeifyThreshold?t[i]=new f(l):l.size()&&(t[i]=l),c.size()>g.untreeifyThreshold?t[i+e]=new f(c):c.size()&&(t[i+e]=c);}else {var h=new s,p=new s;n.forEach((function(t){0==(r(t)&e)?h.pushBack(t):p.pushBack(t);})),h.size()&&(t[i]=h),p.size()&&(t[i+e]=p);}o[i].clear();}})),o=t;}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var t=r(e)&a-1;if(o[t]){var n=o[t].size();if(o[t]instanceof s){if(o[t].find(e))return;o[t].pushBack(e),o[t].size()>=g.treeifyThreshold&&(o[t]=new f(o[t]));}else o[t].insert(e);var l=o[t].size();i+=l-n;}else o[t]=new s([e]),++i;i>a*g.sigma&&u.call(this,a);},this.eraseElementByValue=function(e){var t=r(e)&a-1;if(o[t]){var n=o[t].size();o[t].eraseElementByValue(e),o[t]instanceof f&&o[t].size()<=g.untreeifyThreshold&&(o[t]=new s(o[t]));var u=o[t].size();i+=u-n;}},this.find=function(e){var t=r(e)&a-1;return !!o[t]&&o[t].find(e)},this[Symbol.iterator]=function(){return function(){var e,t,r,n,i,s;return function(e,t){var r,n,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(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s);}catch(e){o=[6,e],n=0;}finally{r=i=0;}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:true}}([o,a])}}}(this,(function(u){switch(u.label){case 0:e=0,u.label=1;case 1:if(!(e<a))return [3,10];for(;e<a&&!o[e];)++e;if(e>=a)return [3,10];u.label=2;case 2:u.trys.push([2,7,8,9]),i=void 0,t=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(o[e]),r=t.next(),u.label=3;case 3:return r.done?[3,6]:[4,r.value];case 4:u.sent(),u.label=5;case 5:return r=t.next(),[3,3];case 6:return [3,9];case 7:return n=u.sent(),i={error:n},[3,9];case 8:try{r&&!r.done&&(s=t.return)&&s.call(t);}finally{if(i)throw i.error}return [7];case 9:return ++e,[3,1];case 10:return [2]}}))}()},e.forEach((function(e){return n.insert(e)})),Object.freeze(this);}g.initSize=16,g.maxSize=1<<30,g.sigma=.75,g.treeifyThreshold=8,g.untreeifyThreshold=6,g.minTreeifySize=64,Object.freeze(g);var b=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function m(e,t,r){var n=this;if(void 0===e&&(e=[]),void 0===t&&(t=m.initSize),r=r||function(e){var t,r,n=0,i="";if("number"==typeof e)n=((n=Math.floor(e))<<5)-n,n&=n;else {i="string"!=typeof e?JSON.stringify(e):e;try{for(var o=b(i),s=o.next();!s.done;s=o.next())n=(n<<5)-n+s.value.charCodeAt(0),n&=n;}catch(e){t={error:e};}finally{try{s&&!s.done&&(r=o.return)&&r.call(o);}finally{if(t)throw t.error}}}return n^n>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var i=0,o=[],a=Math.max(m.initSize,Math.min(m.maxSize,t));this.size=function(){return i},this.empty=function(){return 0===i},this.clear=function(){i=0,a=t,o=[];},this.forEach=function(e){var t=0;o.forEach((function(r){r.forEach((function(r){e(r,t++);}));}));};var u=function(e){if(!(e>=m.maxSize)){a=2*e;var t=[];o.forEach((function(n,i){if(!n.empty()){if(n instanceof s&&1===n.size()){var u=n.front(),l=u.key,c=u.value;t[r(l)&a-1]=new s([{key:l,value:c}]);}else if(n instanceof y){var h=new s,f=new s;n.forEach((function(t){0==(r(t.key)&e)?h.pushBack(t):f.pushBack(t);})),h.size()>m.untreeifyThreshold?t[i]=new y(h):h.size()&&(t[i]=h),f.size()>m.untreeifyThreshold?t[i+e]=new y(f):f.size()&&(t[i+e]=f);}else {var p=new s,d=new s;n.forEach((function(t){0==(r(t.key)&e)?p.pushBack(t):d.pushBack(t);})),p.size()&&(t[i]=p),d.size()&&(t[i+e]=d);}o[i].clear();}})),o=t;}};this.setElement=function(e,t){var n,l;if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=t){var c=r(e)&a-1;if(o[c]){var h=o[c].size();if(o[c]instanceof s){try{for(var f=b(o[c]),p=f.next();!p.done;p=f.next()){var d=p.value;if(d.key===e)return void(d.value=t)}}catch(e){n={error:e};}finally{try{p&&!p.done&&(l=f.return)&&l.call(f);}finally{if(n)throw n.error}}o[c].pushBack({key:e,value:t}),o[c].size()>=m.treeifyThreshold&&(o[c]=new y(o[c]));}else o[c].setElement(e,t);var g=o[c].size();i+=g-h;}else ++i,o[c]=new s([{key:e,value:t}]);i>a*m.sigma&&u.call(this,a);}else this.eraseElementByKey(e);},this.getElementByKey=function(e){var t,n,i=r(e)&a-1;if(o[i]){if(o[i]instanceof y)return o[i].getElementByKey(e);try{for(var s=b(o[i]),u=s.next();!u.done;u=s.next()){var l=u.value;if(l.key===e)return l.value}}catch(e){t={error:e};}finally{try{u&&!u.done&&(n=s.return)&&n.call(s);}finally{if(t)throw t.error}}}},this.eraseElementByKey=function(e){var t,n,u=r(e)&a-1;if(o[u]){var l=o[u].size();if(o[u]instanceof y)o[u].eraseElementByKey(e),o[u].size()<=m.untreeifyThreshold&&(o[u]=new s(o[u]));else {var c=-1;try{for(var h=b(o[u]),f=h.next();!f.done;f=h.next()){var p=f.value;if(++c,p.key===e){o[u].eraseElementByPos(c);break}}}catch(e){t={error:e};}finally{try{f&&!f.done&&(n=h.return)&&n.call(h);}finally{if(t)throw t.error}}}var d=o[u].size();i+=d-l;}},this.find=function(e){var t,n,i=r(e)&a-1;if(!o[i])return  false;if(o[i]instanceof y)return o[i].find(e);try{for(var s=b(o[i]),u=s.next();!u.done;u=s.next())if(u.value.key===e)return !0}catch(e){t={error:e};}finally{try{u&&!u.done&&(n=s.return)&&n.call(s);}finally{if(t)throw t.error}}return  false},this[Symbol.iterator]=function(){return function(){var e,t,r,n,i,s;return function(e,t){var r,n,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(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s);}catch(e){o=[6,e],n=0;}finally{r=i=0;}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:true}}([o,a])}}}(this,(function(u){switch(u.label){case 0:e=0,u.label=1;case 1:if(!(e<a))return [3,10];for(;e<a&&!o[e];)++e;if(e>=a)return [3,10];u.label=2;case 2:u.trys.push([2,7,8,9]),i=void 0,t=b(o[e]),r=t.next(),u.label=3;case 3:return r.done?[3,6]:[4,r.value];case 4:u.sent(),u.label=5;case 5:return r=t.next(),[3,3];case 6:return [3,9];case 7:return n=u.sent(),i={error:n},[3,9];case 8:try{r&&!r.done&&(s=t.return)&&s.call(t);}finally{if(i)throw i.error}return [7];case 9:return ++e,[3,1];case 10:return [2]}}))}()},e.forEach((function(e){var t=e.key,r=e.value;return n.setElement(t,r)})),Object.freeze(this);}m.initSize=16,m.maxSize=1<<30,m.sigma=.75,m.treeifyThreshold=8,m.untreeifyThreshold=6,m.minTreeifySize=64,Object.freeze(m);},9593:function(e,t,r){const n=r(4411),i=Symbol("max"),o=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),u=Symbol("maxAge"),l=Symbol("dispose"),c=Symbol("noDisposeOnSet"),h=Symbol("lruList"),f=Symbol("cache"),p=Symbol("updateAgeOnGet"),d=()=>1,y=(e,t,r)=>{const n=e[f].get(t);if(n){const t=n.value;if(g(e,t)){if(m(e,n),!e[a])return}else r&&(e[p]&&(n.value.now=Date.now()),e[h].unshiftNode(n));return t.value}},g=(e,t)=>{if(!t||!t.maxAge&&!e[u])return  false;const r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[u]&&r>e[u]},b=e=>{if(e[o]>e[i])for(let t=e[h].tail;e[o]>e[i]&&null!==t;){const r=t.prev;m(e,t),t=r;}},m=(e,t)=>{if(t){const r=t.value;e[l]&&e[l](r.key,r.value),e[o]-=r.length,e[f].delete(r.key),e[h].removeNode(t);}};class v{constructor(e,t,r,n,i){this.key=e,this.value=t,this.length=r,this.now=n,this.maxAge=i||0;}}const w=(e,t,r,n)=>{let i=r.value;g(e,i)&&(m(e,r),e[a]||(i=void 0)),i&&t.call(n,i.value,i.key,e);};e.exports=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[i]=e.max||1/0;const t=e.length||d;if(this[s]="function"!=typeof t?d:t,this[a]=e.stale||false,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[u]=e.maxAge||0,this[l]=e.dispose,this[c]=e.noDisposeOnSet||false,this[p]=e.updateAgeOnGet||false,this.reset();}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[i]=e||1/0,b(this);}get max(){return this[i]}set allowStale(e){this[a]=!!e;}get allowStale(){return this[a]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[u]=e,b(this);}get maxAge(){return this[u]}set lengthCalculator(e){"function"!=typeof e&&(e=d),e!==this[s]&&(this[s]=e,this[o]=0,this[h].forEach((e=>{e.length=this[s](e.value,e.key),this[o]+=e.length;}))),b(this);}get lengthCalculator(){return this[s]}get length(){return this[o]}get itemCount(){return this[h].length}rforEach(e,t){t=t||this;for(let r=this[h].tail;null!==r;){const n=r.prev;w(this,e,r,t),r=n;}}forEach(e,t){t=t||this;for(let r=this[h].head;null!==r;){const n=r.next;w(this,e,r,t),r=n;}}keys(){return this[h].toArray().map((e=>e.key))}values(){return this[h].toArray().map((e=>e.value))}reset(){this[l]&&this[h]&&this[h].length&&this[h].forEach((e=>this[l](e.key,e.value))),this[f]=new Map,this[h]=new n,this[o]=0;}dump(){return this[h].map((e=>!g(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[h]}set(e,t,r){if((r=r||this[u])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const n=r?Date.now():0,a=this[s](t,e);if(this[f].has(e)){if(a>this[i])return m(this,this[f].get(e)),false;const s=this[f].get(e).value;return this[l]&&(this[c]||this[l](e,s.value)),s.now=n,s.maxAge=r,s.value=t,this[o]+=a-s.length,s.length=a,this.get(e),b(this),true}const p=new v(e,t,a,n,r);return p.length>this[i]?(this[l]&&this[l](e,t),false):(this[o]+=p.length,this[h].unshift(p),this[f].set(e,this[h].head),b(this),true)}has(e){if(!this[f].has(e))return  false;const t=this[f].get(e).value;return !g(this,t)}get(e){return y(this,e,true)}peek(e){return y(this,e,false)}pop(){const e=this[h].tail;return e?(m(this,e),e.value):null}del(e){m(this,this[f].get(e));}load(e){this.reset();const t=Date.now();for(let r=e.length-1;r>=0;r--){const n=e[r],i=n.e||0;if(0===i)this.set(n.k,n.v);else {const e=i-t;e>0&&this.set(n.k,n.v,e);}}}prune(){this[f].forEach(((e,t)=>y(this,t,false)));}};},9990:function(e,t,r){var n=r(8764).Buffer;const i=e.exports;i.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},i.codes={};for(const e in i.types){const t=i.types[e];i.codes[t]=e;}i.CMD_SHIFT=4,i.CMD_MASK=240,i.DUP_MASK=8,i.QOS_MASK=3,i.QOS_SHIFT=1,i.RETAIN_MASK=1,i.VARBYTEINT_MASK=127,i.VARBYTEINT_FIN_MASK=128,i.VARBYTEINT_MAX=268435455,i.SESSIONPRESENT_MASK=1,i.SESSIONPRESENT_HEADER=n.from([i.SESSIONPRESENT_MASK]),i.CONNACK_HEADER=n.from([i.codes.connack<<i.CMD_SHIFT]),i.USERNAME_MASK=128,i.PASSWORD_MASK=64,i.WILL_RETAIN_MASK=32,i.WILL_QOS_MASK=24,i.WILL_QOS_SHIFT=3,i.WILL_FLAG_MASK=4,i.CLEAN_SESSION_MASK=2,i.CONNECT_HEADER=n.from([i.codes.connect<<i.CMD_SHIFT]),i.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},i.propertiesCodes={};for(const e in i.properties){const t=i.properties[e];i.propertiesCodes[t]=e;}function o(e){return [0,1,2].map((t=>[0,1].map((r=>[0,1].map((o=>{const s=n.alloc(1);return s.writeUInt8(i.codes[e]<<i.CMD_SHIFT|(r?i.DUP_MASK:0)|t<<i.QOS_SHIFT|o,0,true),s}))))))}i.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},i.PUBLISH_HEADER=o("publish"),i.SUBSCRIBE_HEADER=o("subscribe"),i.SUBSCRIBE_OPTIONS_QOS_MASK=3,i.SUBSCRIBE_OPTIONS_NL_MASK=1,i.SUBSCRIBE_OPTIONS_NL_SHIFT=2,i.SUBSCRIBE_OPTIONS_RAP_MASK=1,i.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,i.SUBSCRIBE_OPTIONS_RH_MASK=3,i.SUBSCRIBE_OPTIONS_RH_SHIFT=4,i.SUBSCRIBE_OPTIONS_RH=[0,16,32],i.SUBSCRIBE_OPTIONS_NL=4,i.SUBSCRIBE_OPTIONS_RAP=8,i.SUBSCRIBE_OPTIONS_QOS=[0,1,2],i.UNSUBSCRIBE_HEADER=o("unsubscribe"),i.ACKS={unsuback:o("unsuback"),puback:o("puback"),pubcomp:o("pubcomp"),pubrel:o("pubrel"),pubrec:o("pubrec")},i.SUBACK_HEADER=n.from([i.codes.suback<<i.CMD_SHIFT]),i.VERSION3=n.from([3]),i.VERSION4=n.from([4]),i.VERSION5=n.from([5]),i.VERSION131=n.from([131]),i.VERSION132=n.from([132]),i.QOS=[0,1,2].map((e=>n.from([e]))),i.EMPTY={pingreq:n.from([i.codes.pingreq<<4,0]),pingresp:n.from([i.codes.pingresp<<4,0]),disconnect:n.from([i.codes.disconnect<<4,0])};},7721:function(e,t,r){var n=r(8764).Buffer;const i=r(9371),o=r(7187);class s extends o{constructor(){super(),this._array=new Array(20),this._i=0;}write(e){return this._array[this._i++]=e,true}concat(){let e=0;const t=new Array(this._array.length),r=this._array;let i,o=0;for(i=0;i<r.length&&void 0!==r[i];i++)"string"!=typeof r[i]?t[i]=r[i].length:t[i]=n.byteLength(r[i]),e+=t[i];const s=n.allocUnsafe(e);for(i=0;i<r.length&&void 0!==r[i];i++)"string"!=typeof r[i]?(r[i].copy(s,o),o+=t[i]):(s.write(r[i],o),o+=t[i]);return s}}e.exports=function(e,t){const r=new s;return i(e,r,t),r.concat()};},1772:function(e,t,r){t.parser=r(5322).parser,t.generate=r(7721),t.writeToStream=r(9371);},3903:function(e,t,r){var n=r(8764).Buffer;const i={},o=n.isBuffer(n.from([1,2]).subarray(0,1));function s(e){const t=n.allocUnsafe(2);return t.writeUInt8(e>>8,0),t.writeUInt8(255&e,1),t}e.exports={cache:i,generateCache:function(){for(let e=0;e<65536;e++)i[e]=s(e);},generateNumber:s,genBufVariableByteInt:function(e){let t=0,r=0;const i=n.allocUnsafe(4);do{t=e%128|0,(e=e/128|0)>0&&(t|=128),i.writeUInt8(t,r++);}while(e>0&&r<4);return e>0&&(r=0),o?i.subarray(0,r):i.slice(0,r)},generate4ByteBuffer:function(e){const t=n.allocUnsafe(4);return t.writeUInt32BE(e,0),t}};},9695:function(e){e.exports=class{constructor(){this.cmd=null,this.retain=false,this.qos=0,this.dup=false,this.length=-1,this.topic=null,this.payload=null;}};},5322:function(e,t,r){const n=r(22),i=r(7187),o=r(9695),s=r(9990),a=r(1227)("mqtt-packet:parser");class u extends i{constructor(){super(),this.parser=this.constructor.parser;}static parser(e){return this instanceof u?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new u).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=n(),this._stateCounter=0;}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=s.types[e>>s.CMD_SHIFT],this.packet.retain=0!=(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(e&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),true}_parseLength(){const e=this._parseVarByteNum(true);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let e=false;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case "connect":this._parseConnect();break;case "connack":this._parseConnack();break;case "publish":this._parsePublish();break;case "puback":case "pubrec":case "pubrel":case "pubcomp":this._parseConfirmation();break;case "subscribe":this._parseSubscribe();break;case "suback":this._parseSuback();break;case "unsubscribe":this._parseUnsubscribe();break;case "unsuback":this._parseUnsuback();break;case "pingreq":case "pingresp":break;case "disconnect":this._parseDisconnect();break;case "auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"));}e=true;}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,r,n;a("_parseConnect");const i={},o=this.packet,u=this._parseString();if(null===u)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==u&&"MQIsdp"!==u)return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=u,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),o.protocolVersion>=128&&(o.bridgeMode=true,o.protocolVersion=o.protocolVersion-128),3!==o.protocolVersion&&4!==o.protocolVersion&&5!==o.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,i.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,i.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,i.will&&(o.will={},o.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),o.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),o.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,o.keepalive=this._parseNum(),-1===o.keepalive)return this._emitError(new Error("Packet too short"));if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.properties=e);}const l=this._parseString();if(null===l)return this._emitError(new Error("Packet too short"));if(o.clientId=l,a("_parseConnect: packet.clientId: %s",o.clientId),i.will){if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.will.properties=e);}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(o.will.topic=e,a("_parseConnect: packet.will.topic: %s",o.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));o.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",o.will.payload);}if(i.username){if(n=this._parseString(),null===n)return this._emitError(new Error("Cannot parse username"));o.username=n,a("_parseConnect: packet.username: %s",o.username);}if(i.password){if(r=this._parseBuffer(),null===r)return this._emitError(new Error("Cannot parse password"));o.password=r;}return this.settings=o,a("_parseConnect: complete"),o}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else {if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++);}if(-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t);}a("_parseConnack: complete");}_parsePublish(){a("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t);}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload);}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,r,n,i,o,u,l;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t);}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));r=this._parseByte(),n=r&s.SUBSCRIBE_OPTIONS_QOS_MASK,u=0!=(r>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),o=0!=(r>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),i=r>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,l={topic:t,qos:n},5===this.settings.protocolVersion?(l.nl=u,l.rap=o,l.rh=i):this.settings.bridgeMode&&(l.rh=0,l.rap=true,l.nl=true),a("_parseSubscribe: push subscription `%s` to subscription",l),e.subscriptions.push(l);}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t);}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++));}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t);}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t);}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++));}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t);}return  true}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t);}return a("_parseDisconnect result: true"),true}_parseAuth(){a("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),true}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),false):(a("_parseMessageId: packet.messageId %d",e.messageId),true)}_parseString(e){const t=this._parseNum(),r=t+this._pos;if(-1===t||r>this._list.length||r>this.packet.length)return null;const n=this._list.toString("utf8",this._pos,r);return this._pos+=t,a("_parseString: result: %s",n),n}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const r=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",r),r}_parseNum(){if(this._list.length-this._pos<2)return  -1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return  -1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");let t,r=0,n=1,i=0,o=false;const u=this._pos?this._pos:0;for(;r<4&&u+r<this._list.length;){if(t=this._list.readUInt8(u+r++),i+=n*(t&s.VARBYTEINT_MASK),n*=128,0==(t&s.VARBYTEINT_FIN_MASK)){o=true;break}if(this._list.length<=r)break}return !o&&4===r&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),u&&(this._pos+=r),o=!!o&&(e?{bytes:r,value:i}:i),a("_parseVarByteNum: result: %o",o),o}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_parseByType: type: %s",e),e){case "byte":return 0!==this._parseByte();case "int8":return this._parseByte();case "int16":return this._parseNum();case "int32":return this._parse4ByteNum();case "var":return this._parseVarByteNum();case "string":return this._parseString();case "pair":return this._parseStringPair();case "binary":return this._parseBuffer()}}_parseProperties(){a("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,r={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),false;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),false;if("userProperties"!==t)r[t]?(Array.isArray(r[t])||(r[t]=[r[t]]),r[t].push(this._parseByType(s.propertiesTypes[t]))):r[t]=this._parseByType(s.propertiesTypes[t]);else {r[t]||(r[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(r[t][e.name])if(Array.isArray(r[t][e.name]))r[t][e.name].push(e.value);else {const n=r[t][e.name];r[t][e.name]=[n],r[t][e.name].push(e.value);}else r[t][e.name]=e.value;}}return r}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),a("_newPacket: new packet"),this.packet=new o,this._pos=0,true}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e);}}e.exports=u;},9371:function(e,t,r){var n=r(8764).Buffer;const i=r(9990),o=n.allocUnsafe(0),s=n.from([0]),a=r(3903),u=r(8212).nextTick,l=r(1227)("mqtt-packet:writeToStream"),c=a.cache,h=a.generateNumber,f=a.generateCache,p=a.genBufVariableByteInt,d=a.generate4ByteBuffer;let y=k,g=true;function b(e,t,r){switch(l("generate called"),t.cork&&(t.cork(),u(m,t)),g&&(g=false,f()),l("generate: packet.cmd: %s",e.cmd),e.cmd){case "connect":return function(e,t,r){const o=e||{},s=o.protocolId||"MQTT";let a=o.protocolVersion||4;const u=o.will;let l=o.clean;const c=o.keepalive||0,h=o.clientId||"",f=o.username,p=o.password,d=o.properties;void 0===l&&(l=true);let g=0;if("string"!=typeof s&&!n.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),false;if(g+=s.length+2,3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),false;if(g+=1,("string"==typeof h||n.isBuffer(h))&&(h||a>=4)&&(h||l))g+=n.byteLength(h)+2;else {if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),false;if(1*l==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),false}if("number"!=typeof c||c<0||c>65535||c%1!=0)return t.emit("error",new Error("Invalid keepalive")),false;if(g+=2,g+=1,5===a){var b=T(t,d);if(!b)return  false;g+=b.length;}if(u){if("object"!=typeof u)return t.emit("error",new Error("Invalid will")),false;if(!u.topic||"string"!=typeof u.topic)return t.emit("error",new Error("Invalid will topic")),false;if(g+=n.byteLength(u.topic)+2,g+=2,u.payload){if(!(u.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),false;"string"==typeof u.payload?g+=n.byteLength(u.payload):g+=u.payload.length;}var m={};if(5===a){if(!(m=T(t,u.properties)))return  false;g+=m.length;}}let v=false;if(null!=f){if(!R(f))return t.emit("error",new Error("Invalid username")),false;v=true,g+=n.byteLength(f)+2;}if(null!=p){if(!v)return t.emit("error",new Error("Username is required to use password")),false;if(!R(p))return t.emit("error",new Error("Invalid password")),false;g+=B(p)+2;}t.write(i.CONNECT_HEADER),w(t,g),C(t,s),o.bridgeMode&&(a+=128),t.write(131===a?i.VERSION131:132===a?i.VERSION132:4===a?i.VERSION4:5===a?i.VERSION5:i.VERSION3);let E=0;return E|=null!=f?i.USERNAME_MASK:0,E|=null!=p?i.PASSWORD_MASK:0,E|=u&&u.retain?i.WILL_RETAIN_MASK:0,E|=u&&u.qos?u.qos<<i.WILL_QOS_SHIFT:0,E|=u?i.WILL_FLAG_MASK:0,E|=l?i.CLEAN_SESSION_MASK:0,t.write(n.from([E])),y(t,c),5===a&&b.write(),C(t,h),u&&(5===a&&m.write(),_(t,u.topic),C(t,u.payload)),null!=f&&C(t,f),null!=p&&C(t,p),true}(e,t);case "connack":return function(e,t,r){const o=r?r.protocolVersion:4,a=e||{},u=5===o?a.reasonCode:a.returnCode,l=a.properties;let c=2;if("number"!=typeof u)return t.emit("error",new Error("Invalid return code")),false;let h=null;if(5===o){if(h=T(t,l),!h)return  false;c+=h.length;}return t.write(i.CONNACK_HEADER),w(t,c),t.write(a.sessionPresent?i.SESSIONPRESENT_HEADER:s),t.write(n.from([u])),null!=h&&h.write(),true}(e,t,r);case "publish":return function(e,t,r){l("publish: packet: %o",e);const s=r?r.protocolVersion:4,a=e||{},u=a.qos||0,c=a.retain?i.RETAIN_MASK:0,h=a.topic,f=a.payload||o,p=a.messageId,d=a.properties;let g=0;if("string"==typeof h)g+=n.byteLength(h)+2;else {if(!n.isBuffer(h))return t.emit("error",new Error("Invalid topic")),false;g+=h.length+2;}if(n.isBuffer(f)?g+=f.length:g+=n.byteLength(f),u&&"number"!=typeof p)return t.emit("error",new Error("Invalid messageId")),false;u&&(g+=2);let b=null;if(5===s){if(b=T(t,d),!b)return  false;g+=b.length;}return t.write(i.PUBLISH_HEADER[u][a.dup?1:0][c?1:0]),w(t,g),y(t,B(h)),t.write(h),u>0&&y(t,p),null!=b&&b.write(),l("publish: payload: %o",f),t.write(f)}(e,t,r);case "puback":case "pubrec":case "pubrel":case "pubcomp":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.cmd||"puback",u=s.messageId,l=s.dup&&"pubrel"===a?i.DUP_MASK:0;let c=0;const h=s.reasonCode,f=s.properties;let p=5===o?3:2;if("pubrel"===a&&(c=1),"number"!=typeof u)return t.emit("error",new Error("Invalid messageId")),false;let d=null;if(5===o&&"object"==typeof f){if(d=A(t,f,r,p),!d)return  false;p+=d.length;}return t.write(i.ACKS[a][c][l][0]),w(t,p),y(t,u),5===o&&t.write(n.from([h])),null!==d&&d.write(),true}(e,t,r);case "subscribe":return function(e,t,r){l("subscribe: packet: ");const o=r?r.protocolVersion:4,s=e||{},a=s.dup?i.DUP_MASK:0,u=s.messageId,c=s.subscriptions,h=s.properties;let f=0;if("number"!=typeof u)return t.emit("error",new Error("Invalid messageId")),false;f+=2;let p=null;if(5===o){if(p=T(t,h),!p)return  false;f+=p.length;}if("object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid subscriptions")),false;for(let e=0;e<c.length;e+=1){const r=c[e].topic,i=c[e].qos;if("string"!=typeof r)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),false;if("number"!=typeof i)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),false;if(5===o){if("boolean"!=typeof(c[e].nl||false))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),false;if("boolean"!=typeof(c[e].rap||false))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),false;const r=c[e].rh||0;if("number"!=typeof r||r>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),false}f+=n.byteLength(r)+2+1;}l("subscribe: writing to stream: %o",i.SUBSCRIBE_HEADER),t.write(i.SUBSCRIBE_HEADER[1][a?1:0][0]),w(t,f),y(t,u),null!==p&&p.write();let d=true;for(const e of c){const r=e.topic,s=e.qos,a=+e.nl,u=+e.rap,l=e.rh;let c;_(t,r),c=i.SUBSCRIBE_OPTIONS_QOS[s],5===o&&(c|=a?i.SUBSCRIBE_OPTIONS_NL:0,c|=u?i.SUBSCRIBE_OPTIONS_RAP:0,c|=l?i.SUBSCRIBE_OPTIONS_RH[l]:0),d=t.write(n.from([c]));}return d}(e,t,r);case "suback":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.messageId,u=s.granted,l=s.properties;let c=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),false;if(c+=2,"object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid qos vector")),false;for(let e=0;e<u.length;e+=1){if("number"!=typeof u[e])return t.emit("error",new Error("Invalid qos vector")),false;c+=1;}let h=null;if(5===o){if(h=A(t,l,r,c),!h)return  false;c+=h.length;}return t.write(i.SUBACK_HEADER),w(t,c),y(t,a),null!==h&&h.write(),t.write(n.from(u))}(e,t,r);case "unsubscribe":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.messageId,u=s.dup?i.DUP_MASK:0,l=s.unsubscriptions,c=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),false;if(h+=2,"object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid unsubscriptions")),false;for(let e=0;e<l.length;e+=1){if("string"!=typeof l[e])return t.emit("error",new Error("Invalid unsubscriptions")),false;h+=n.byteLength(l[e])+2;}let f=null;if(5===o){if(f=T(t,c),!f)return  false;h+=f.length;}t.write(i.UNSUBSCRIBE_HEADER[1][u?1:0][0]),w(t,h),y(t,a),null!==f&&f.write();let p=true;for(let e=0;e<l.length;e++)p=_(t,l[e]);return p}(e,t,r);case "unsuback":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.messageId,u=s.dup?i.DUP_MASK:0,l=s.granted,c=s.properties,h=s.cmd;let f=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),false;if(5===o){if("object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid qos vector")),false;for(let e=0;e<l.length;e+=1){if("number"!=typeof l[e])return t.emit("error",new Error("Invalid qos vector")),false;f+=1;}}let p=null;if(5===o){if(p=A(t,c,r,f),!p)return  false;f+=p.length;}return t.write(i.ACKS[h][0][u][0]),w(t,f),y(t,a),null!==p&&p.write(),5===o&&t.write(n.from(l)),true}(e,t,r);case "pingreq":case "pingresp":return function(e,t,r){return t.write(i.EMPTY[e.cmd])}(e,t);case "disconnect":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.reasonCode,u=s.properties;let l=5===o?1:0,c=null;if(5===o){if(c=A(t,u,r,l),!c)return  false;l+=c.length;}return t.write(n.from([i.codes.disconnect<<4])),w(t,l),5===o&&t.write(n.from([a])),null!==c&&c.write(),true}(e,t,r);case "auth":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.reasonCode,u=s.properties;let l=5===o?1:0;5!==o&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const c=A(t,u,r,l);return !!c&&(l+=c.length,t.write(n.from([i.codes.auth<<4])),w(t,l),t.write(n.from([a])),null!==c&&c.write(),true)}(e,t,r);default:return t.emit("error",new Error("Unknown command")),false}}function m(e){e.uncork();}Object.defineProperty(b,"cacheNumbers",{get:()=>y===k,set(e){e?(c&&0!==Object.keys(c).length||(g=true),y=k):(g=false,y=S);}});const v={};function w(e,t){if(t>i.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),false;let r=v[t];return r||(r=p(t),t<16384&&(v[t]=r)),l("writeVarByteInt: writing to stream: %o",r),e.write(r)}function _(e,t){const r=n.byteLength(t);return y(e,r),l("writeString: %s",t),e.write(t,"utf8")}function E(e,t,r){_(e,t),_(e,r);}function k(e,t){return l("writeNumberCached: number: %d",t),l("writeNumberCached: %o",c[t]),e.write(c[t])}function S(e,t){const r=h(t);return l("writeNumberGenerated: %o",r),e.write(r)}function C(e,t){"string"==typeof t?_(e,t):t?(y(e,t.length),e.write(t)):y(e,0);}function T(e,t){if("object"!=typeof t||null!=t.length)return {length:1,write(){x(e,{},0);}};let r=0;function o(t,r){let o=0;switch(i.propertiesTypes[t]){case "byte":if("boolean"!=typeof r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),false;o+=2;break;case "int8":if("number"!=typeof r||r<0||r>255)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),false;o+=2;break;case "binary":if(r&&null===r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),false;o+=1+n.byteLength(r)+2;break;case "int16":if("number"!=typeof r||r<0||r>65535)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),false;o+=3;break;case "int32":if("number"!=typeof r||r<0||r>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),false;o+=5;break;case "var":if("number"!=typeof r||r<0||r>268435455)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),false;o+=1+n.byteLength(p(r));break;case "string":if("string"!=typeof r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),false;o+=3+n.byteLength(r.toString());break;case "pair":if("object"!=typeof r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),false;o+=Object.getOwnPropertyNames(r).reduce(((e,t)=>{const i=r[t];return Array.isArray(i)?e+=i.reduce(((e,r)=>e+(3+n.byteLength(t.toString())+2+n.byteLength(r.toString()))),0):e+=3+n.byteLength(t.toString())+2+n.byteLength(r[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${r}`)),false}return o}if(t)for(const e in t){let n=0,i=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(i=o(e,s[t]),!i)return  false;n+=i;}else {if(i=o(e,s),!i)return  false;n=i;}if(!n)return  false;r+=n;}return {length:n.byteLength(p(r))+r,write(){x(e,t,r);}}}function A(e,t,r,n){const i=["reasonString","userProperties"],o=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0;let s=T(e,t);if(o)for(;n+s.length>o;){const r=i.shift();if(!r||!t[r])return  false;delete t[r],s=T(e,t);}return s}function I(e,t,r){switch(i.propertiesTypes[t]){case "byte":e.write(n.from([i.properties[t]])),e.write(n.from([+r]));break;case "int8":e.write(n.from([i.properties[t]])),e.write(n.from([r]));break;case "binary":e.write(n.from([i.properties[t]])),C(e,r);break;case "int16":e.write(n.from([i.properties[t]])),y(e,r);break;case "int32":e.write(n.from([i.properties[t]])),function(e,t){const r=d(t);l("write4ByteNumber: %o",r),e.write(r);}(e,r);break;case "var":e.write(n.from([i.properties[t]])),w(e,r);break;case "string":e.write(n.from([i.properties[t]])),_(e,r);break;case "pair":Object.getOwnPropertyNames(r).forEach((o=>{const s=r[o];Array.isArray(s)?s.forEach((r=>{e.write(n.from([i.properties[t]])),E(e,o.toString(),r.toString());})):(e.write(n.from([i.properties[t]])),E(e,o.toString(),s.toString()));}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${r}`)),false}}function x(e,t,r){w(e,r);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&null!==t[r]){const n=t[r];if(Array.isArray(n))for(let t=0;t<n.length;t++)I(e,r,n[t]);else I(e,r,n);}}function B(e){return e?e instanceof n?e.length:n.byteLength(e):0}function R(e){return "string"==typeof e||e instanceof n}e.exports=b;},7824:function(e){var t=1e3,r=60*t,n=60*r,i=24*n;function o(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,s){s=s||{};var a,u,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var s=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case "years":case "year":case "yrs":case "yr":case "y":return 315576e5*s;case "weeks":case "week":case "w":return 6048e5*s;case "days":case "day":case "d":return s*i;case "hours":case "hour":case "hrs":case "hr":case "h":return s*n;case "minutes":case "minute":case "mins":case "min":case "m":return s*r;case "seconds":case "second":case "secs":case "sec":case "s":return s*t;case "milliseconds":case "millisecond":case "msecs":case "msec":case "ms":return s;default:return}}}}(e);if("number"===l&&isFinite(e))return s.long?(a=e,(u=Math.abs(a))>=i?o(a,u,i,"day"):u>=n?o(a,u,n,"hour"):u>=r?o(a,u,r,"minute"):u>=t?o(a,u,t,"second"):a+" ms"):function(e){var o=Math.abs(e);return o>=i?Math.round(e/i)+"d":o>=n?Math.round(e/n)+"h":o>=r?Math.round(e/r)+"m":o>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};},423:function(e,t,r){const n=r(9759);e.exports.Q=n;},9759:function(e,t,r){const n=r(9246).l4,i=r(1227)("number-allocator:trace"),o=r(1227)("number-allocator:error");function s(e,t){this.low=e,this.high=t;}function a(e,t){if(!(this instanceof a))return new a(e,t);this.min=e,this.max=t,this.ss=new n([],((e,t)=>e.compare(t))),i("Create"),this.clear();}s.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},s.prototype.compare=function(e){return this.low<e.low&&this.high<e.low?-1:e.low<this.low&&e.high<this.low?1:0},a.prototype.firstVacant=function(){return 0===this.ss.size()?null:this.ss.front().low},a.prototype.alloc=function(){if(0===this.ss.size())return i("alloc():empty"),null;const e=this.ss.front(),t=e.low;return t+1<=e.high?++e.low:this.ss.eraseElementByPos(0),i("alloc():"+t),t},a.prototype.use=function(e){const t=new s(e,e),r=this.ss.lowerBound(t);if(r){if(r.equals(t))return this.ss.eraseElementByValue(r),i("use():"+e),true;if(r.low>e)return  false;if(r.low===e)return ++r.low,i("use():"+e),true;if(r.high===e)return --r.high,i("use():"+e),true;const n=r.low;return r.low=e+1,this.ss.insert(new s(n,e-1)),i("use():"+e),true}return i("use():failed"),false},a.prototype.free=function(e){if(e<this.min||e>this.max)return void o("free():"+e+" is out of range");const t=new s(e,e),r=this.ss.lowerBound(t);if(r){if(r.low<=e&&e<=r.high)return void o("free():"+e+" has already been vacant");if(r===this.ss.front())e+1===r.low?--r.low:this.ss.insert(t);else {const n=this.ss.reverseLowerBound(t);n.high+1===e?e+1===r.low?(this.ss.eraseElementByValue(n),r.low=n.low):n.high=e:e+1===r.low?r.low=e:this.ss.insert(t);}}else {if(r===this.ss.front())return void this.ss.insert(t);const n=this.ss.reverseLowerBound(t);n.high+1===e?n.high=e:this.ss.insert(t);}i("free():"+e);},a.prototype.clear=function(){i("clear()"),this.ss.clear(),this.ss.insert(new s(this.min,this.max));},a.prototype.intervalCount=function(){return this.ss.size()},a.prototype.dump=function(){console.log("length:"+this.ss.size());for(const e of this.ss)console.log(e);},e.exports=a;},778:function(e,t,r){var n=r(2479);function i(e){var t=function(){return t.called?t.value:(t.called=true,t.value=e.apply(this,arguments))};return t.called=false,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=true,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=false,t}e.exports=n(i),e.exports.strict=n(o),i.proto=i((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:true}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:true});}));},8212:function(e,t,r){var n=r(4155);void 0===n||!n.version||0===n.version.indexOf("v0.")||0===n.version.indexOf("v1.")&&0!==n.version.indexOf("v1.8.")?e.exports={nextTick:function(e,t,r,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return n.nextTick(e);case 2:return n.nextTick((function(){e.call(null,t);}));case 3:return n.nextTick((function(){e.call(null,t,r);}));case 4:return n.nextTick((function(){e.call(null,t,r,i);}));default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return n.nextTick((function(){e.apply(null,o);}))}}}:e.exports=n;},4155:function(e){var t,r,n=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i;}catch(e){t=i;}try{r="function"==typeof clearTimeout?clearTimeout:o;}catch(e){r=o;}}();var a,u=[],l=false,c=-1;function h(){l&&a&&(l=false,a.length?u=a.concat(u):c=-1,u.length&&f());}function f(){if(!l){var e=s(h);l=true;for(var t=u.length;t;){for(a=u,u=[];++c<t;)a&&a[c].run();c=-1,t=u.length;}a=null,l=false,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e);}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e);}}function p(e,t){this.fun=e,this.array=t;}function d(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new p(e,t)),1!==u.length||l||s(f);},p.prototype.run=function(){this.fun.apply(null,this.array);},n.title="browser",n.browser=true,n.env={},n.argv=[],n.version="",n.versions={},n.on=d,n.addListener=d,n.once=d,n.off=d,n.removeListener=d,n.removeAllListeners=d,n.emit=d,n.prependListener=d,n.prependOnceListener=d,n.listeners=function(e){return []},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return "/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0};},2587:function(e){function t(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,r,n,i){r=r||"&",n=n||"=";var o={};if("string"!=typeof e||0===e.length)return o;var s=/\+/g;e=e.split(r);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var u=e.length;a>0&&u>a&&(u=a);for(var l=0;l<u;++l){var c,h,f,p,d=e[l].replace(s,"%20"),y=d.indexOf(n);y>=0?(c=d.substr(0,y),h=d.substr(y+1)):(c=d,h=""),f=decodeURIComponent(c),p=decodeURIComponent(h),t(o,f)?Array.isArray(o[f])?o[f].push(p):o[f]=[o[f],p]:o[f]=p;}return o};},2182:function(e){var t=function(e){switch(typeof e){case "string":return e;case "boolean":return e?"true":"false";case "number":return isFinite(e)?e:"";default:return ""}};e.exports=function(e,r,n,i){return r=r||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(i){var o=encodeURIComponent(t(i))+n;return Array.isArray(e[i])?e[i].map((function(e){return o+encodeURIComponent(t(e))})).join(r):o+encodeURIComponent(t(e[i]))})).join(r):i?encodeURIComponent(t(i))+n+encodeURIComponent(t(e)):""};},7673:function(e,t,r){t.decode=t.parse=r(2587),t.encode=t.stringify=r(2182);},4281:function(e){var t={};function r(e,r,n){n||(n=Error);var i=function(e){var t,n;function i(t,n,i){return e.call(this,function(e,t,n){return "string"==typeof r?r:r(e,t,n)}(t,n,i))||this}return n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=e,t[e]=i;}function n(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return "of ".concat(t," ").concat(String(e))}r("ERR_INVALID_OPT_VALUE",(function(e,t){return 'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(e,t,r){var i,o,s,a,u;if("string"==typeof t&&(o="not ",t.substr(0,o.length)===o)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,r){return (void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))s="The ".concat(e," ").concat(i," ").concat(n(t,"type"));else {var l=("number"!=typeof u&&(u=0),u+".".length>(a=e).length||-1===a.indexOf(".",u)?"argument":"property");s='The "'.concat(e,'" ').concat(l," ").concat(i," ").concat(n(t,"type"));}return s+". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return "The "+e+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(e){return "Cannot call "+e+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(e){return "Unknown encoding: "+e}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.q=t;},6753:function(e,t,r){var n=r(4155),i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=c;var o=r(9481),s=r(4229);r(5717)(c,o);for(var a=i(s.prototype),u=0;u<a.length;u++){var l=a[u];c.prototype[l]||(c.prototype[l]=s.prototype[l]);}function c(e){if(!(this instanceof c))return new c(e);o.call(this,e),s.call(this,e),this.allowHalfOpen=true,e&&(false===e.readable&&(this.readable=false),false===e.writable&&(this.writable=false),false===e.allowHalfOpen&&(this.allowHalfOpen=false,this.once("end",h)));}function h(){this._writableState.ended||n.nextTick(f,this);}function f(e){e.end();}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:false,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:false,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:false,get:function(){return this._writableState.length}}),Object.defineProperty(c.prototype,"destroyed",{enumerable:false,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){ void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e);}});},2725:function(e,t,r){e.exports=i;var n=r(4605);function i(e){if(!(this instanceof i))return new i(e);n.call(this,e);}r(5717)(i,n),i.prototype._transform=function(e,t,r){r(null,e);};},9481:function(e,t,r){var n,i=r(4155);e.exports=C,C.ReadableState=S,r(7187).EventEmitter;var o,s=function(e,t){return e.listeners(t).length},a=r(2503),u=r(8764).Buffer,l=r.g.Uint8Array||function(){},c=r(4616);o=c&&c.debuglog?c.debuglog("stream"):function(){};var h,f,p,d=r(7327),y=r(1195),g=r(2457).getHighWaterMark,b=r(4281).q,m=b.ERR_INVALID_ARG_TYPE,v=b.ERR_STREAM_PUSH_AFTER_EOF,w=b.ERR_METHOD_NOT_IMPLEMENTED,_=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(5717)(C,a);var E=y.errorOrDestroy,k=["error","close","destroy","pause","resume"];function S(e,t,i){n=n||r(6753),e=e||{},"boolean"!=typeof i&&(i=t instanceof n),this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=g(this,e,"readableHighWaterMark",i),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=false,this.endEmitted=false,this.reading=false,this.sync=true,this.needReadable=false,this.emittedReadable=false,this.readableListening=false,this.resumeScheduled=false,this.paused=true,this.emitClose=false!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=false,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=false,this.decoder=null,this.encoding=null,e.encoding&&(h||(h=r(2553).s),this.decoder=new h(e.encoding),this.encoding=e.encoding);}function C(e){if(n=n||r(6753),!(this instanceof C))return new C(e);var t=this instanceof n;this._readableState=new S(e,this,t),this.readable=true,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),a.call(this);}function T(e,t,r,n,i){o("readableAddChunk",t);var s,a=e._readableState;if(null===t)a.reading=false,function(e,t){if(o("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length);}t.ended=true,t.sync?B(e):(t.needReadable=false,t.emittedReadable||(t.emittedReadable=true,R(e)));}}(e,a);else if(i||(s=function(e,t){var r,n;return n=t,u.isBuffer(n)||n instanceof l||"string"==typeof t||void 0===t||e.objectMode||(r=new m("chunk",["string","Buffer","Uint8Array"],t)),r}(a,t)),s)E(e,s);else if(a.objectMode||t&&t.length>0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===u.prototype||(t=function(e){return u.from(e)}(t)),n)a.endEmitted?E(e,new _):A(e,a,t,true);else if(a.ended)E(e,new v);else {if(a.destroyed)return  false;a.reading=false,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?A(e,a,t,false):O(e,a)):A(e,a,t,false);}else n||(a.reading=false,O(e,a));return !a.ended&&(a.length<a.highWaterMark||0===a.length)}function A(e,t,r,n){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&B(e)),O(e,t);}Object.defineProperty(C.prototype,"destroyed",{enumerable:false,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e);}}),C.prototype.destroy=y.destroy,C.prototype._undestroy=y.undestroy,C.prototype._destroy=function(e,t){t(e);},C.prototype.push=function(e,t){var r,n=this._readableState;return n.objectMode?r=true:"string"==typeof e&&((t=t||n.defaultEncoding)!==n.encoding&&(e=u.from(e,t),t=""),r=true),T(this,e,t,false,r)},C.prototype.unshift=function(e){return T(this,e,null,true,false)},C.prototype.isPaused=function(){return  false===this._readableState.flowing},C.prototype.setEncoding=function(e){h||(h=r(2553).s);var t=new h(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var I=1073741824;function x(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>=I?e=I:(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=true,0))}function B(e){var t=e._readableState;o("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=false,t.emittedReadable||(o("emitReadable",t.flowing),t.emittedReadable=true,i.nextTick(R,e));}function R(e){var t=e._readableState;o("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=false),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,U(e);}function O(e,t){t.readingMore||(t.readingMore=true,i.nextTick(P,e,t));}function P(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(o("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=false;}function N(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=true:e.listenerCount("data")>0&&e.resume();}function M(e){o("readable nexttick read 0"),e.read(0);}function L(e,t){o("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=false,e.emit("resume"),U(e),t.flowing&&!t.reading&&e.read(0);}function U(e){var t=e._readableState;for(o("flow",t.flowing);t.flowing&&null!==e.read(););}function j(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.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r;}function q(e){var t=e._readableState;o("endReadable",t.endEmitted),t.endEmitted||(t.ended=true,i.nextTick(z,t,e));}function z(e,t){if(o("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=true,t.readable=false,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy();}}function D(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return  -1}C.prototype.read=function(e){o("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=false),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return o("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?q(this):B(this),null;if(0===(e=x(e,t))&&t.ended)return 0===t.length&&q(this),null;var n,i=t.needReadable;return o("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&o("length less than watermark",i=true),t.ended||t.reading?o("reading or ended",i=false):i&&(o("do read"),t.reading=true,t.sync=true,0===t.length&&(t.needReadable=true),this._read(t.highWaterMark),t.sync=false,t.reading||(e=x(r,t))),null===(n=e>0?j(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=true),r!==e&&t.ended&&q(this)),null!==n&&this.emit("data",n),n},C.prototype._read=function(e){E(this,new w("_read()"));},C.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,o("pipe count=%d opts=%j",n.pipesCount,t);var a=t&&false===t.end||e===i.stdout||e===i.stderr?y:u;function u(){o("onend"),e.end();}n.endEmitted?i.nextTick(a):r.once("end",a),e.on("unpipe",(function t(i,s){o("onunpipe"),i===r&&s&&false===s.hasUnpiped&&(s.hasUnpiped=true,o("cleanup"),e.removeListener("close",p),e.removeListener("finish",d),e.removeListener("drain",l),e.removeListener("error",f),e.removeListener("unpipe",t),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",h),c=true,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||l());}));var l=function(e){return function(){var t=e._readableState;o("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=true,U(e));}}(r);e.on("drain",l);var c=false;function h(t){o("ondata");var i=e.write(t);o("dest.write",i),false===i&&((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==D(n.pipes,e))&&!c&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause());}function f(t){o("onerror",t),y(),e.removeListener("error",f),0===s(e,"error")&&E(e,t);}function p(){e.removeListener("finish",d),y();}function d(){o("onfinish"),e.removeListener("close",p),y();}function y(){o("unpipe"),r.unpipe(e);}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events.error?Array.isArray(e._events.error)?e._events.error.unshift(r):e._events.error=[r,e._events.error]:e.on(t,r);}(e,"error",f),e.once("close",p),e.once("finish",d),e.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),e},C.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:false};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=false,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=false;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:false});return this}var s=D(t.pipes,e);return  -1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},C.prototype.on=function(e,t){var r=a.prototype.on.call(this,e,t),n=this._readableState;return "data"===e?(n.readableListening=this.listenerCount("readable")>0,false!==n.flowing&&this.resume()):"readable"===e&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=true,n.flowing=false,n.emittedReadable=false,o("on readable",n.length,n.reading),n.length?B(this):n.reading||i.nextTick(M,this))),r},C.prototype.addListener=C.prototype.on,C.prototype.removeListener=function(e,t){var r=a.prototype.removeListener.call(this,e,t);return "readable"===e&&i.nextTick(N,this),r},C.prototype.removeAllListeners=function(e){var t=a.prototype.removeAllListeners.apply(this,arguments);return "readable"!==e&&void 0!==e||i.nextTick(N,this),t},C.prototype.resume=function(){var e=this._readableState;return e.flowing||(o("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=true,i.nextTick(L,e,t));}(this,e)),e.paused=false,this},C.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),false!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=false,this.emit("pause")),this._readableState.paused=true,this},C.prototype.wrap=function(e){var t=this,r=this._readableState,n=false;for(var i in e.on("end",(function(){if(o("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e);}t.push(null);})),e.on("data",(function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(t.push(i)||(n=true,e.pause()));})),e) void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var s=0;s<k.length;s++)e.on(k[s],this.emit.bind(this,k[s]));return this._read=function(t){o("wrapped _read",t),n&&(n=false,e.resume());},this},"function"==typeof Symbol&&(C.prototype[Symbol.asyncIterator]=function(){return void 0===f&&(f=r(5850)),f(this)}),Object.defineProperty(C.prototype,"readableHighWaterMark",{enumerable:false,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(C.prototype,"readableBuffer",{enumerable:false,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(C.prototype,"readableFlowing",{enumerable:false,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e);}}),C._fromList=j,Object.defineProperty(C.prototype,"readableLength",{enumerable:false,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(C.from=function(e,t){return void 0===p&&(p=r(5167)),p(C,e,t)});},4605:function(e,t,r){e.exports=c;var n=r(4281).q,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(6753);function l(e,t){var r=this._transformState;r.transforming=false;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=false,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark);}function c(e){if(!(this instanceof c))return new c(e);u.call(this,e),this._transformState={afterTransform:l.bind(this),needTransform:false,transforming:false,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=true,this._readableState.sync=false,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h);}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?f(this,null,null):this._flush((function(t,r){f(e,t,r);}));}function f(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}r(5717)(c,u),c.prototype.push=function(e,t){return this._transformState.needTransform=false,u.prototype.push.call(this,e,t)},c.prototype._transform=function(e,t,r){r(new i("_transform()"));},c.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark);}},c.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=true:(t.transforming=true,this._transform(t.writechunk,t.writeencoding,t.afterTransform));},c.prototype._destroy=function(e,t){u.prototype._destroy.call(this,e,(function(e){t(e);}));};},4229:function(e,t,r){var n,i=r(4155);function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(undefined),n=n.next;}t.corkedRequestsFree.next=e;}(t,e);};}e.exports=C,C.WritableState=S;var s,a={deprecate:r(4927)},u=r(2503),l=r(8764).Buffer,c=r.g.Uint8Array||function(){},h=r(1195),f=r(2457).getHighWaterMark,p=r(4281).q,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,g=p.ERR_MULTIPLE_CALLBACK,b=p.ERR_STREAM_CANNOT_PIPE,m=p.ERR_STREAM_DESTROYED,v=p.ERR_STREAM_NULL_VALUES,w=p.ERR_STREAM_WRITE_AFTER_END,_=p.ERR_UNKNOWN_ENCODING,E=h.errorOrDestroy;function k(){}function S(e,t,s){n=n||r(6753),e=e||{},"boolean"!=typeof s&&(s=t instanceof n),this.objectMode=!!e.objectMode,s&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=f(this,e,"writableHighWaterMark",s),this.finalCalled=false,this.needDrain=false,this.ending=false,this.ended=false,this.finished=false,this.destroyed=false;var a=false===e.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=false,this.corked=0,this.sync=true,this.bufferProcessing=false,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new g;if(function(e){e.writing=false,e.writecb=null,e.length-=e.writelen,e.writelen=0;}(r),t)!function(e,t,r,n,o){--t.pendingcb,r?(i.nextTick(o,n),i.nextTick(R,e,t),e._writableState.errorEmitted=true,E(e,n)):(o(n),e._writableState.errorEmitted=true,E(e,n),R(e,t));}(e,r,n,t,o);else {var s=x(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||I(e,r),n?i.nextTick(A,e,r,s,o):A(e,r,s,o);}}(t,e);},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=false,this.errorEmitted=false,this.emitClose=false!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this);}function C(e){var t=this instanceof(n=n||r(6753));if(!t&&!s.call(C,this))return new C(e);this._writableState=new S(e,this,t),this.writable=true,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),u.call(this);}function T(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=true,t.sync=true,t.destroyed?t.onwrite(new m("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=false;}function A(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=false,e.emit("drain"));}(e,t),t.pendingcb--,n(),R(e,t);}function I(e,t){t.bufferProcessing=true;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),s=t.corkedRequestsFree;s.entry=r;for(var a=0,u=true;r;)i[a]=r,r.isBuf||(u=false),r=r.next,a+=1;i.allBuffers=u,T(e,t,true,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0;}else {for(;r;){var l=r.chunk,c=r.encoding,h=r.callback;if(T(e,t,false,t.objectMode?1:l.length,l,c,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null);}t.bufferedRequest=r,t.bufferProcessing=false;}function x(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function B(e,t){e._final((function(r){t.pendingcb--,r&&E(e,r),t.prefinished=true,e.emit("prefinish"),R(e,t);}));}function R(e,t){var r=x(t);if(r&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=true,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=true,i.nextTick(B,e,t)));}(e,t),0===t.pendingcb&&(t.finished=true,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy();}return r}r(5717)(C,u),S.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(S.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")});}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(s=Function.prototype[Symbol.hasInstance],Object.defineProperty(C,Symbol.hasInstance,{value:function(e){return !!s.call(this,e)||this===C&&e&&e._writableState instanceof S}})):s=function(e){return e instanceof this},C.prototype.pipe=function(){E(this,new b);},C.prototype.write=function(e,t,r){var n,o=this._writableState,s=false,a=!o.objectMode&&(n=e,l.isBuffer(n)||n instanceof c);return a&&!l.isBuffer(e)&&(e=function(e){return l.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=k),o.ending?function(e,t){var r=new w;E(e,r),i.nextTick(t,r);}(this,r):(a||function(e,t,r,n){var o;return null===r?o=new v:"string"==typeof r||t.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(E(e,o),i.nextTick(n,o),false)}(this,o,e,r))&&(o.pendingcb++,s=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){return e.objectMode||false===e.decodeStrings||"string"!=typeof t||(t=l.from(t,r)),t}(t,n,i);n!==s&&(r=true,i="buffer",n=s);}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length<t.highWaterMark;if(u||(t.needDrain=true),t.writing||t.corked){var c=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},c?c.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1;}else T(e,t,false,a,n,i,o);return u}(this,o,a,e,t,r)),s},C.prototype.cork=function(){this._writableState.corked++;},C.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||I(this,e));},C.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new _(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(C.prototype,"writableBuffer",{enumerable:false,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(C.prototype,"writableHighWaterMark",{enumerable:false,get:function(){return this._writableState.highWaterMark}}),C.prototype._write=function(e,t,r){r(new y("_write()"));},C.prototype._writev=null,C.prototype.end=function(e,t,r){var n=this._writableState;return "function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||function(e,t,r){t.ending=true,R(e,t),r&&(t.finished?i.nextTick(r):e.once("finish",r)),t.ended=true,e.writable=false;}(this,n,r),this},Object.defineProperty(C.prototype,"writableLength",{enumerable:false,get:function(){return this._writableState.length}}),Object.defineProperty(C.prototype,"destroyed",{enumerable:false,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e);}}),C.prototype.destroy=h.destroy,C.prototype._undestroy=h.undestroy,C.prototype._destroy=function(e,t){t(e);};},5850:function(e,t,r){var n,i=r(4155);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}var s=r(8610),a=Symbol("lastResolve"),u=Symbol("lastReject"),l=Symbol("error"),c=Symbol("ended"),h=Symbol("lastPromise"),f=Symbol("handlePromise"),p=Symbol("stream");function d(e,t){return {value:e,done:t}}function y(e){var t=e[a];if(null!==t){var r=e[p].read();null!==r&&(e[h]=null,e[a]=null,e[u]=null,t(d(r,false)));}}function g(e){i.nextTick(y,e);}var b=Object.getPrototypeOf((function(){})),m=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var e=this,t=this[l];if(null!==t)return Promise.reject(t);if(this[c])return Promise.resolve(d(void 0,true));if(this[p].destroyed)return new Promise((function(t,r){i.nextTick((function(){e[l]?r(e[l]):t(d(void 0,true));}));}));var r,n=this[h];if(n)r=new Promise(function(e,t){return function(r,n){e.then((function(){t[c]?r(d(void 0,true)):t[f](r,n);}),n);}}(n,this));else {var o=this[p].read();if(null!==o)return Promise.resolve(d(o,false));r=new Promise(this[f]);}return this[h]=r,r}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var e=this;return new Promise((function(t,r){e[p].destroy(null,(function(e){e?r(e):t(d(void 0,true));}));}))})),n),b);e.exports=function(e){var t,r=Object.create(m,(o(t={},p,{value:e,writable:true}),o(t,a,{value:null,writable:true}),o(t,u,{value:null,writable:true}),o(t,l,{value:null,writable:true}),o(t,c,{value:e._readableState.endEmitted,writable:true}),o(t,f,{value:function(e,t){var n=r[p].read();n?(r[h]=null,r[a]=null,r[u]=null,e(d(n,false))):(r[a]=e,r[u]=t);},writable:true}),t));return r[h]=null,s(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[u];return null!==t&&(r[h]=null,r[a]=null,r[u]=null,t(e)),void(r[l]=e)}var n=r[a];null!==n&&(r[h]=null,r[a]=null,r[u]=null,n(d(void 0,true))),r[c]=true;})),e.on("readable",g.bind(null,r)),r};},7327:function(e,t,r){function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,n.key,n);}}var s=r(8764).Buffer,a=r(2361).inspect,u=a&&a.custom||"inspect";e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0;}var t,r;return t=e,r=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length;}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length;}},{key:"shift",value: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}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0;}},{key:"join",value:function(e){if(0===this.length)return "";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return s.alloc(0);for(var t,r,n,i=s.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,r=i,n=a,s.prototype.copy.call(t,r,n),a+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,n=t.data;for(e-=n.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r;}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n;}return this.length-=n,t}},{key:u,value:function(e,t){return a(this,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),true).forEach((function(t){i(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}({},t,{depth:0,customInspect:false}))}}],r&&o(t.prototype,r),e}();},1195:function(e,t,r){var n=r(4155);function i(e,t){s(e,t),o(e);}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close");}function s(e,t){e.emit("error",t);}e.exports={destroy:function(e,t){var r=this,a=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return a||u?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=true,n.nextTick(s,this,e)):n.nextTick(s,this,e)),this):(this._readableState&&(this._readableState.destroyed=true),this._writableState&&(this._writableState.destroyed=true),this._destroy(e||null,(function(e){!t&&e?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=true,n.nextTick(i,r,e)):n.nextTick(i,r,e):t?(n.nextTick(o,r),t(e)):n.nextTick(o,r);})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=false,this._readableState.reading=false,this._readableState.ended=false,this._readableState.endEmitted=false),this._writableState&&(this._writableState.destroyed=false,this._writableState.ended=false,this._writableState.ending=false,this._writableState.finalCalled=false,this._writableState.prefinished=false,this._writableState.finished=false,this._writableState.errorEmitted=false);},errorOrDestroy:function(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t);}};},8610:function(e,t,r){var n=r(4281).q.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),o=function(e){var t=false;return function(){if(!t){t=true;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n);}}}(o||i);var s=r.readable||false!==r.readable&&t.readable,a=r.writable||false!==r.writable&&t.writable,u=function(){t.writable||c();},l=t._writableState&&t._writableState.finished,c=function(){a=false,l=true,s||o.call(t);},h=t._readableState&&t._readableState.endEmitted,f=function(){s=false,h=true,a||o.call(t);},p=function(e){o.call(t,e);},d=function(){var e;return s&&!h?(t._readableState&&t._readableState.ended||(e=new n),o.call(t,e)):a&&!l?(t._writableState&&t._writableState.ended||(e=new n),o.call(t,e)):void 0},y=function(){t.req.on("finish",c);};return function(e){return e.setHeader&&"function"==typeof e.abort}(t)?(t.on("complete",c),t.on("abort",d),t.req?y():t.on("request",y)):a&&!t._writableState&&(t.on("end",u),t.on("close",u)),t.on("end",f),t.on("finish",c),false!==r.error&&t.on("error",p),t.on("close",d),function(){t.removeListener("complete",c),t.removeListener("abort",d),t.removeListener("request",y),t.req&&t.req.removeListener("finish",c),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",c),t.removeListener("end",f),t.removeListener("error",p),t.removeListener("close",d);}};},5167:function(e){e.exports=function(){throw new Error("Readable.from is not available in the browser")};},9946:function(e,t,r){var n,i=r(4281).q,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function u(e,t,i,o){o=function(e){var t=false;return function(){t||(t=true,e.apply(void 0,arguments));}}(o);var a=false;e.on("close",(function(){a=true;})),void 0===n&&(n=r(8610)),n(e,{readable:t,writable:i},(function(e){if(e)return o(e);a=true,o();}));var u=false;return function(t){if(!a&&!u)return u=true,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void o(t||new s("pipe"))}}function l(e){e();}function c(e,t){return e.pipe(t)}function h(e){return e.length?"function"!=typeof e[e.length-1]?a:e.pop():a}e.exports=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,i=h(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new o("streams");var s=t.map((function(e,r){var o=r<t.length-1;return u(e,o,r>0,(function(e){n||(n=e),e&&s.forEach(l),o||(s.forEach(l),i(n));}))}));return t.reduce(c)};},2457:function(e,t,r){var n=r(4281).q.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(e,t,r,i){var o=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}};},2503:function(e,t,r){e.exports=r(7187).EventEmitter;},8473:function(e,t,r){(t=e.exports=r(9481)).Stream=t,t.Readable=t,t.Writable=r(4229),t.Duplex=r(6753),t.Transform=r(4605),t.PassThrough=r(2725),t.finished=r(8610),t.pipeline=r(9946);},5408:function(e){function t(e,t,r){var n=this;this._callback=e,this._args=r,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=n._interval),n._interval&&clearInterval(n._interval),n._interval=setInterval(n._callback,e,n._args);},this.clear=function(){n._interval&&(clearInterval(n._interval),n._interval=void 0);},this.destroy=function(){n._interval&&clearInterval(n._interval),n._callback=void 0,n._interval=void 0,n._args=void 0;};}e.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var r=0;r<e.length;r++)e[r]=arguments[r+2];}return new t(arguments[0],arguments[1],e)};},1697:function(e,t,r){e.exports=r(3188)();},3188:function(e,t,r){var n=r(8764).Buffer;function i(e){return e instanceof n?n.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}e.exports=function(e){return (e=e||{}).circles?function(e){var t=[],r=[];return e.proto?function e(o){if("object"!=typeof o||null===o)return o;if(o instanceof Date)return new Date(o);if(Array.isArray(o))return n(o,e);if(o instanceof Map)return new Map(n(Array.from(o),e));if(o instanceof Set)return new Set(n(Array.from(o),e));var s={};for(var a in t.push(o),r.push(s),o){var u=o[a];if("object"!=typeof u||null===u)s[a]=u;else if(u instanceof Date)s[a]=new Date(u);else if(u instanceof Map)s[a]=new Map(n(Array.from(u),e));else if(u instanceof Set)s[a]=new Set(n(Array.from(u),e));else if(ArrayBuffer.isView(u))s[a]=i(u);else {var l=t.indexOf(u);s[a]=-1!==l?r[l]:e(u);}}return t.pop(),r.pop(),s}:function e(o){if("object"!=typeof o||null===o)return o;if(o instanceof Date)return new Date(o);if(Array.isArray(o))return n(o,e);if(o instanceof Map)return new Map(n(Array.from(o),e));if(o instanceof Set)return new Set(n(Array.from(o),e));var s={};for(var a in t.push(o),r.push(s),o)if(false!==Object.hasOwnProperty.call(o,a)){var u=o[a];if("object"!=typeof u||null===u)s[a]=u;else if(u instanceof Date)s[a]=new Date(u);else if(u instanceof Map)s[a]=new Map(n(Array.from(u),e));else if(u instanceof Set)s[a]=new Set(n(Array.from(u),e));else if(ArrayBuffer.isView(u))s[a]=i(u);else {var l=t.indexOf(u);s[a]=-1!==l?r[l]:e(u);}}return t.pop(),r.pop(),s};function n(e,n){for(var o=Object.keys(e),s=new Array(o.length),a=0;a<o.length;a++){var u=o[a],l=e[u];if("object"!=typeof l||null===l)s[u]=l;else if(l instanceof Date)s[u]=new Date(l);else if(ArrayBuffer.isView(l))s[u]=i(l);else {var c=t.indexOf(l);s[u]=-1!==c?r[c]:n(l);}}return s}}(e):e.proto?function e(r){if("object"!=typeof r||null===r)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return t(r,e);if(r instanceof Map)return new Map(t(Array.from(r),e));if(r instanceof Set)return new Set(t(Array.from(r),e));var n={};for(var o in r){var s=r[o];"object"!=typeof s||null===s?n[o]=s:s instanceof Date?n[o]=new Date(s):s instanceof Map?n[o]=new Map(t(Array.from(s),e)):s instanceof Set?n[o]=new Set(t(Array.from(s),e)):ArrayBuffer.isView(s)?n[o]=i(s):n[o]=e(s);}return n}:function e(r){if("object"!=typeof r||null===r)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return t(r,e);if(r instanceof Map)return new Map(t(Array.from(r),e));if(r instanceof Set)return new Set(t(Array.from(r),e));var n={};for(var o in r)if(false!==Object.hasOwnProperty.call(r,o)){var s=r[o];"object"!=typeof s||null===s?n[o]=s:s instanceof Date?n[o]=new Date(s):s instanceof Map?n[o]=new Map(t(Array.from(s),e)):s instanceof Set?n[o]=new Set(t(Array.from(s),e)):ArrayBuffer.isView(s)?n[o]=i(s):n[o]=e(s);}return n};function t(e,t){for(var r=Object.keys(e),n=new Array(r.length),o=0;o<r.length;o++){var s=r[o],a=e[s];"object"!=typeof a||null===a?n[s]=a:a instanceof Date?n[s]=new Date(a):ArrayBuffer.isView(a)?n[s]=i(a):n[s]=t(a);}return n}};},9509:function(e,t,r){var n=r(8764),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r];}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,t),t.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)};},1852:function(e){e.exports=function(e){var t,r=e._readableState;return r?r.objectMode||"number"==typeof e._duplexState?e.read():e.read((t=r).buffer.length?t.buffer.head?t.buffer.head.data.length:t.buffer[0].length:t.length):null};},2553:function(e,t,r){var n=r(9509).Buffer,i=n.isEncoding||function(e){switch((e=""+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  true;default:return  false}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return "utf8";for(var t;;)switch(e){case "utf8":case "utf-8":return "utf8";case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return "utf16le";case "latin1":case "binary":return "latin1";case "base64":case "ascii":case "hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=true;}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case "utf16le":this.text=u,this.end=l,t=4;break;case "utf8":this.fillLast=a,t=4;break;case "base64":this.text=c,this.end=h,t=3;break;default:return this.write=f,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t);}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function l(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function c(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function f(e){return e.toString(this.encoding)}function p(e){return e&&e.length?this.write(e):""}t.s=o,o.prototype.write=function(e){if(0===e.length)return "";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return "";r=this.lastNeed,this.lastNeed=0;}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var r=function(e,t,r){var n=t.length-1;if(n<r)return 0;var i=s(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||-2===i?0:(i=s(t[n]))>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||-2===i?0:(i=s(t[n]))>=0?(i>0&&(2===i?i=0:e.lastNeed=i-3),i):0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length;};},2511:function(e,t,r){var n;e=r.nmd(e),function(i){t&&t.nodeType,e&&e.nodeType;var o="object"==typeof r.g&&r.g;o.global!==o&&o.window!==o&&o.self;var s,a=2147483647,u=36,l=/^xn--/,c=/[^\x20-\x7E]/,h=/[\x2E\u3002\uFF0E\uFF61]/g,f={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,d=String.fromCharCode;function y(e){throw RangeError(f[e])}function g(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function b(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+g((e=e.replace(h,".")).split("."),t).join(".")}function m(e){for(var t,r,n=[],i=0,o=e.length;i<o;)(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<o?56320==(64512&(r=e.charCodeAt(i++)))?n.push(((1023&t)<<10)+(1023&r)+65536):(n.push(t),i--):n.push(t);return n}function v(e){return g(e,(function(e){var t="";return e>65535&&(t+=d((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+d(e)})).join("")}function w(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function _(e,t,r){var n=0;for(e=r?p(e/700):e>>1,e+=p(e/t);e>455;n+=u)e=p(e/35);return p(n+36*e/(e+38))}function E(e){var t,r,n,i,o,s,l,c,h,f,d,g=[],b=e.length,m=0,w=128,E=72;for((r=e.lastIndexOf("-"))<0&&(r=0),n=0;n<r;++n)e.charCodeAt(n)>=128&&y("not-basic"),g.push(e.charCodeAt(n));for(i=r>0?r+1:0;i<b;){for(o=m,s=1,l=u;i>=b&&y("invalid-input"),((c=(d=e.charCodeAt(i++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:u)>=u||c>p((a-m)/s))&&y("overflow"),m+=c*s,!(c<(h=l<=E?1:l>=E+26?26:l-E));l+=u)s>p(a/(f=u-h))&&y("overflow"),s*=f;E=_(m-o,t=g.length+1,0==o),p(m/t)>a-w&&y("overflow"),w+=p(m/t),m%=t,g.splice(m++,0,w);}return v(g)}function k(e){var t,r,n,i,o,s,l,c,h,f,g,b,v,E,k,S=[];for(b=(e=m(e)).length,t=128,r=0,o=72,s=0;s<b;++s)(g=e[s])<128&&S.push(d(g));for(n=i=S.length,i&&S.push("-");n<b;){for(l=a,s=0;s<b;++s)(g=e[s])>=t&&g<l&&(l=g);for(l-t>p((a-r)/(v=n+1))&&y("overflow"),r+=(l-t)*v,t=l,s=0;s<b;++s)if((g=e[s])<t&&++r>a&&y("overflow"),g==t){for(c=r,h=u;!(c<(f=h<=o?1:h>=o+26?26:h-o));h+=u)k=c-f,E=u-f,S.push(d(w(f+k%E,0))),c=p(k/E);S.push(d(w(c,0))),o=_(r,v,n==i),r=0,++n;}++r,++t;}return S.join("")}s={version:"1.3.2",ucs2:{decode:m,encode:v},decode:E,encode:k,toASCII:function(e){return b(e,(function(e){return c.test(e)?"xn--"+k(e):e}))},toUnicode:function(e){return b(e,(function(e){return l.test(e)?E(e.slice(4).toLowerCase()):e}))}},void 0===(n=function(){return s}.call(t,r,t,e))||(e.exports=n);}();},8575:function(e,t,r){var n=r(2511),i=r(2502);function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null;}t.parse=v,t.resolve=function(e,t){return v(e,false,true).resolve(t)},t.resolveObject=function(e,t){return e?v(e,false,true).resolveObject(t):t},t.format=function(e){return i.isString(e)&&(e=v(e)),e instanceof o?e.format():o.prototype.format.call(e)},t.Url=o;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(l),h=["%","/","?",";","#"].concat(c),f=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:true,"javascript:":true},g={javascript:true,"javascript:":true},b={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},m=r(7673);function v(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),a=-1!==o&&o<e.indexOf("#")?"?":"#",l=e.split(a);l[0]=l[0].replace(/\\/g,"/");var v=e=l.join(a);if(v=v.trim(),!r&&1===e.split("#").length){var w=u.exec(v);if(w)return this.path=v,this.href=v,this.pathname=w[1],w[2]?(this.search=w[2],this.query=t?m.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var _=s.exec(v);if(_){var E=(_=_[0]).toLowerCase();this.protocol=E,v=v.substr(_.length);}if(r||_||v.match(/^\/\/[^@\/]+@[^@\/]+/)){var k="//"===v.substr(0,2);!k||_&&g[_]||(v=v.substr(2),this.slashes=true);}if(!g[_]&&(k||_&&!b[_])){for(var S,C,T=-1,A=0;A<f.length;A++) -1!==(I=v.indexOf(f[A]))&&(-1===T||I<T)&&(T=I);for(-1!==(C=-1===T?v.lastIndexOf("@"):v.lastIndexOf("@",T))&&(S=v.slice(0,C),v=v.slice(C+1),this.auth=decodeURIComponent(S)),T=-1,A=0;A<h.length;A++){var I;-1!==(I=v.indexOf(h[A]))&&(-1===T||I<T)&&(T=I);} -1===T&&(T=v.length),this.host=v.slice(0,T),v=v.slice(T),this.parseHost(),this.hostname=this.hostname||"";var x="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!x)for(var B=this.hostname.split(/\./),R=(A=0,B.length);A<R;A++){var O=B[A];if(O&&!O.match(p)){for(var P="",N=0,M=O.length;N<M;N++)O.charCodeAt(N)>127?P+="x":P+=O[N];if(!P.match(p)){var L=B.slice(0,A),U=B.slice(A+1),j=O.match(d);j&&(L.push(j[1]),U.unshift(j[2])),U.length&&(v="/"+U.join(".")+v),this.hostname=L.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),x||(this.hostname=n.toASCII(this.hostname));var q=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+q,this.href+=this.host,x&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v));}if(!y[E])for(A=0,R=c.length;A<R;A++){var D=c[A];if(-1!==v.indexOf(D)){var F=encodeURIComponent(D);F===D&&(F=escape(D)),v=v.split(D).join(F);}}var V=v.indexOf("#");-1!==V&&(this.hash=v.substr(V),v=v.slice(0,V));var W=v.indexOf("?");if(-1!==W?(this.search=v.substr(W),this.query=v.substr(W+1),t&&(this.query=m.parse(this.query)),v=v.slice(0,W)):t&&(this.search="",this.query={}),v&&(this.pathname=v),b[E]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){q=this.pathname||"";var H=this.search||"";this.path=q+H;}return this.href=this.format(),this},o.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",r=this.pathname||"",n=this.hash||"",o=false,s="";this.host?o=e+this.host:this.hostname&&(o=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&i.isObject(this.query)&&Object.keys(this.query).length&&(s=m.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||b[t])&&false!==o?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),t+o+(r=r.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+n},o.prototype.resolve=function(e){return this.resolveObject(v(e,false,true)).format()},o.prototype.resolveObject=function(e){if(i.isString(e)){var t=new o;t.parse(e,false,true),e=t;}for(var r=new o,n=Object.keys(this),s=0;s<n.length;s++){var a=n[s];r[a]=this[a];}if(r.hash=e.hash,""===e.href)return r.href=r.format(),r;if(e.slashes&&!e.protocol){for(var u=Object.keys(e),l=0;l<u.length;l++){var c=u[l];"protocol"!==c&&(r[c]=e[c]);}return b[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(e.protocol&&e.protocol!==r.protocol){if(!b[e.protocol]){for(var h=Object.keys(e),f=0;f<h.length;f++){var p=h[f];r[p]=e[p];}return r.href=r.format(),r}if(r.protocol=e.protocol,e.host||g[e.protocol])r.pathname=e.pathname;else {for(var d=(e.pathname||"").split("/");d.length&&!(e.host=d.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),r.pathname=d.join("/");}if(r.search=e.search,r.query=e.query,r.host=e.host||"",r.auth=e.auth,r.hostname=e.hostname||e.host,r.port=e.port,r.pathname||r.search){var y=r.pathname||"",m=r.search||"";r.path=y+m;}return r.slashes=r.slashes||e.slashes,r.href=r.format(),r}var v=r.pathname&&"/"===r.pathname.charAt(0),w=e.host||e.pathname&&"/"===e.pathname.charAt(0),_=w||v||r.host&&e.pathname,E=_,k=r.pathname&&r.pathname.split("/")||[],S=(d=e.pathname&&e.pathname.split("/")||[],r.protocol&&!b[r.protocol]);if(S&&(r.hostname="",r.port=null,r.host&&(""===k[0]?k[0]=r.host:k.unshift(r.host)),r.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===d[0]?d[0]=e.host:d.unshift(e.host)),e.host=null),_=_&&(""===d[0]||""===k[0])),w)r.host=e.host||""===e.host?e.host:r.host,r.hostname=e.hostname||""===e.hostname?e.hostname:r.hostname,r.search=e.search,r.query=e.query,k=d;else if(d.length)k||(k=[]),k.pop(),k=k.concat(d),r.search=e.search,r.query=e.query;else if(!i.isNullOrUndefined(e.search))return S&&(r.hostname=r.host=k.shift(),(x=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=x.shift(),r.host=r.hostname=x.shift())),r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!k.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var C=k.slice(-1)[0],T=(r.host||e.host||k.length>1)&&("."===C||".."===C)||""===C,A=0,I=k.length;I>=0;I--)"."===(C=k[I])?k.splice(I,1):".."===C?(k.splice(I,1),A++):A&&(k.splice(I,1),A--);if(!_&&!E)for(;A--;A)k.unshift("..");!_||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),T&&"/"!==k.join("/").substr(-1)&&k.push("");var x,B=""===k[0]||k[0]&&"/"===k[0].charAt(0);return S&&(r.hostname=r.host=B?"":k.length?k.shift():"",(x=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=x.shift(),r.host=r.hostname=x.shift())),(_=_||r.host&&k.length)&&!B&&k.unshift(""),k.length?r.pathname=k.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e);};},2502:function(e){e.exports={isString:function(e){return "string"==typeof e},isObject:function(e){return "object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}};},4927:function(e,t,r){function n(e){try{if(!r.g.localStorage)return !1}catch(e){return  false}var t=r.g.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}e.exports=function(e,t){if(n("noDeprecation"))return e;var r=false;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=true;}return e.apply(this,arguments)}};},2479:function(e){e.exports=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){n[e]=t[e];})),n;function n(){for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var n=t.apply(this,e),i=e[e.length-1];return "function"==typeof n&&n!==i&&Object.keys(i).forEach((function(e){n[e]=i[e];})),n}};},7026:function(e){e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")};},7529:function(e){e.exports=function(){for(var e={},r=0;r<arguments.length;r++){var n=arguments[r];for(var i in n)t.call(n,i)&&(e[i]=n[i]);}return e};var t=Object.prototype.hasOwnProperty;},9602:function(e){e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value;};};},4411:function(e,t,r){function n(e){var t=this;if(t instanceof n||(t=new n),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e);}));else if(arguments.length>0)for(var r=0,i=arguments.length;r<i;r++)t.push(arguments[r]);return t}function i(e,t){e.tail=new s(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++;}function o(e,t){e.head=new s(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++;}function s(e,t,r,n){if(!(this instanceof s))return new s(e,t,r,n);this.list=n,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,r?(r.prev=this,this.next=r):this.next=null;}e.exports=n,n.Node=s,n.create=n,n.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,r=e.prev;return t&&(t.prev=r),r&&(r.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=r),e.list.length--,e.next=null,e.prev=null,e.list=null,t},n.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++;}},n.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++;}},n.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)i(this,arguments[e]);return this.length},n.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)o(this,arguments[e]);return this.length},n.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},n.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},n.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,n=0;null!==r;n++)e.call(t,r.value,n,this),r=r.next;},n.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,n=this.length-1;null!==r;n--)e.call(t,r.value,n,this),r=r.prev;},n.prototype.get=function(e){for(var t=0,r=this.head;null!==r&&t<e;t++)r=r.next;if(t===e&&null!==r)return r.value},n.prototype.getReverse=function(e){for(var t=0,r=this.tail;null!==r&&t<e;t++)r=r.prev;if(t===e&&null!==r)return r.value},n.prototype.map=function(e,t){t=t||this;for(var r=new n,i=this.head;null!==i;)r.push(e.call(t,i.value,this)),i=i.next;return r},n.prototype.mapReverse=function(e,t){t=t||this;for(var r=new n,i=this.tail;null!==i;)r.push(e.call(t,i.value,this)),i=i.prev;return r},n.prototype.reduce=function(e,t){var r,n=this.head;if(arguments.length>1)r=t;else {if(!this.head)throw new TypeError("Reduce of empty list with no initial value");n=this.head.next,r=this.head.value;}for(var i=0;null!==n;i++)r=e(r,n.value,i),n=n.next;return r},n.prototype.reduceReverse=function(e,t){var r,n=this.tail;if(arguments.length>1)r=t;else {if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");n=this.tail.prev,r=this.tail.value;}for(var i=this.length-1;null!==n;i--)r=e(r,n.value,i),n=n.prev;return r},n.prototype.toArray=function(){for(var e=new Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},n.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},n.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var i=0,o=this.head;null!==o&&i<e;i++)o=o.next;for(;null!==o&&i<t;i++,o=o.next)r.push(o.value);return r},n.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var i=this.length,o=this.tail;null!==o&&i>t;i--)o=o.prev;for(;null!==o&&i>e;i--,o=o.prev)r.push(o.value);return r},n.prototype.splice=function(e,t,...r){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var n=0,i=this.head;null!==i&&n<e;n++)i=i.next;var o,a,u,l,c=[];for(n=0;i&&n<t;n++)c.push(i.value),i=this.removeNode(i);for(null===i&&(i=this.tail),i!==this.head&&i!==this.tail&&(i=i.prev),n=0;n<r.length;n++)o=this,a=i,u=r[n],l=void 0,null===(l=a===o.head?new s(u,null,a,o):new s(u,a,a.next,o)).next&&(o.tail=l),null===l.prev&&(o.head=l),o.length++,i=l;return c},n.prototype.reverse=function(){for(var e=this.head,t=this.tail,r=e;null!==r;r=r.prev){var n=r.prev;r.prev=r.next,r.next=n;}return this.head=t,this.tail=e,this};try{r(9602)(n);}catch(e){}},10:function(){},4995:function(){},2361:function(){},4616:function(){},3518:function(e,t,r){var n=r(4155);const i=r(7187).EventEmitter,o=r(2681),s=r(8254),a=r(226),u=r(1772),l=r(298),c=r(8473).Writable,h=r(5717),f=r(5408),p=r(1697),d=r(3380),y=r(7529),g=r(1227)("mqttjs:client"),b=n?n.nextTick:function(e){setTimeout(e,0);},m=r.g.setImmediate||function(e){b(e);},v={keepalive:60,reschedulePings:true,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:true,resubscribe:true},w=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],_={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function E(e,t){let r;t.properties&&(r=t.properties.topicAlias);let n=t.topic.toString();if(0===n.length){if(void 0===r)return new Error("Unregistered Topic Alias");if(n=e.topicAliasSend.getTopicByAlias(r),void 0===n)return new Error("Unregistered Topic Alias");t.topic=n;}r&&delete t.properties.topicAlias;}function k(e,t,r){g("sendPacket :: packet: %O",t),g("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),g("sendPacket :: writing to stream");const n=u.writeToStream(t,e.stream,e.options);g("sendPacket :: writeToStream result %s",n),!n&&r&&r!==T?(g("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",r)):r&&(g("sendPacket :: invoking cb"),r());}function S(e){e&&(g("flush: queue exists? %b",!!e),Object.keys(e).forEach((function(t){"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t]);})));}function C(e,t,r,n){g("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd);let i,o=t;if("publish"===o.cmd&&(o=p(t),i=E(e,o),i))return r&&r(i);e.outgoingStore.put(o,(function(i){if(i)return r&&r(i);n(),k(e,t,r);}));}function T(e){g("nop ::",e);}function A(e,t){let r;const n=this;if(!(this instanceof A))return new A(e,t);for(r in this.options=t||{},v) void 0===this.options[r]?this.options[r]=v[r]:this.options[r]=t[r];g("MqttClient :: options.protocol",t.protocol),g("MqttClient :: options.protocolVersion",t.protocolVersion),g("MqttClient :: options.username",t.username),g("MqttClient :: options.keepalive",t.keepalive),g("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),g("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),g("MqttClient :: options.topicAliasMaximum",t.topicAliasMaximum),this.options.clientId="string"==typeof t.clientId?t.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),g("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0);},this.streamBuilder=e,this.messageIdProvider=void 0===this.options.messageIdProvider?new l:this.options.messageIdProvider,this.outgoingStore=t.outgoingStore||new o,this.incomingStore=t.incomingStore||new o,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=false,this.disconnecting=false,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=false,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=true,t.topicAliasMaximum>0&&(t.topicAliasMaximum>65535?g("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new s(t.topicAliasMaximum)),this.on("connect",(function(){const e=this.queue;g("connect :: sending queued packets"),function t(){const r=e.shift();g("deliver :: entry %o",r);let i=null;if(!r)return void n._resubscribe();i=r.packet,g("deliver :: call _sendPacket for %o",i);let o=true;i.messageId&&0!==i.messageId&&(n.messageIdProvider.register(i.messageId)||(o=false)),o?n._sendPacket(i,(function(e){r.cb&&r.cb(e),t();})):(g("messageId: %d has already used. The message is skipped and removed.",i.messageId),t());}();})),this.on("close",(function(){g("close :: connected set to `false`"),this.connected=false,g("close :: clearing connackTimer"),clearTimeout(this.connackTimer),g("close :: clearing ping timer"),null!==n.pingTimer&&(n.pingTimer.clear(),n.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),g("close :: calling _setupReconnect"),this._setupReconnect();})),i.call(this),g("MqttClient :: setting up stream"),this._setupStream();}h(A,i),A.prototype._setupStream=function(){const e=this,t=new c,r=u.parser(this.options);let n=null;const i=[];function o(){if(i.length)b(s);else {const e=n;n=null,e();}}function s(){g("work :: getting next packet in queue");const t=i.shift();if(t)g("work :: packet pulled from queue"),e._handlePacket(t,o);else {g("work :: no packets in queue");const e=n;n=null,g("work :: done flag is %s",!!e),e&&e();}}g("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),g("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),r.on("packet",(function(e){g("parser :: on packet push to packets array."),i.push(e);})),t._write=function(e,t,i){n=i,g("writable stream :: parsing buffer"),r.parse(e),s();},g("_setupStream :: pipe stream to writable stream"),this.stream.pipe(t),this.stream.on("error",(function(t){g("streamErrorHandler :: error",t.message),w.includes(t.code)?(g("streamErrorHandler :: emitting error"),e.emit("error",t)):T(t);})),this.stream.on("close",(function(){var t;g("(%s)stream :: on close",e.options.clientId),(t=e.outgoing)&&(g("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(t).forEach((function(e){t[e].volatile&&"function"==typeof t[e].cb&&(t[e].cb(new Error("Connection closed")),delete t[e]);}))),g("stream: emit close to MqttClient"),e.emit("close");})),g("_setupStream: sending packet `connect`");const a=Object.create(this.options);if(a.cmd="connect",this.topicAliasRecv&&(a.properties||(a.properties={}),this.topicAliasRecv&&(a.properties.topicAliasMaximum=this.topicAliasRecv.max)),k(this,a),r.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return e.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket&&k(this,y({cmd:"auth",reasonCode:0},this.options.authPacket));}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){g("!!connectTimeout hit!! Calling _cleanUp with force `true`"),e._cleanUp(true);}),this.options.connectTimeout);},A.prototype._handlePacket=function(e,t){const r=this.options;if(5===r.protocolVersion&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(g("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case "publish":this._handlePublish(e,t);break;case "puback":case "pubrec":case "pubcomp":case "suback":case "unsuback":this._handleAck(e),t();break;case "pubrel":this._handlePubrel(e,t);break;case "connack":this._handleConnack(e),t();break;case "auth":this._handleAuth(e),t();break;case "pingresp":this._handlePingresp(e),t();break;case "disconnect":this._handleDisconnect(e),t();}},A.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e&&e!==T?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},A.prototype.publish=function(e,t,r,n){g("publish :: message `%s` to topic `%s`",t,e);const i=this.options;if("function"==typeof r&&(n=r,r=null),r=y({qos:0,retain:false,dup:false},r),this._checkDisconnecting(n))return this;const o=this,s=function(){let s=0;if((1===r.qos||2===r.qos)&&(s=o._nextId(),null===s))return g("No messageId left"),false;const a={cmd:"publish",topic:e,payload:t,qos:r.qos,retain:r.retain,messageId:s,dup:r.dup};switch(5===i.protocolVersion&&(a.properties=r.properties),g("publish :: qos",r.qos),r.qos){case 1:case 2:o.outgoing[a.messageId]={volatile:false,cb:n||T},g("MqttClient:publish: packet cmd: %s",a.cmd),o._sendPacket(a,void 0,r.cbStorePut);break;default:g("MqttClient:publish: packet cmd: %s",a.cmd),o._sendPacket(a,n,r.cbStorePut);}return  true};return (this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,cbStorePut:r.cbStorePut,callback:n}),this},A.prototype.subscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];const r=[];let n=t.shift();const i=n.resubscribe;let o=t.pop()||T,s=t.pop();const a=this.options.protocolVersion;delete n.resubscribe,"string"==typeof n&&(n=[n]),"function"!=typeof o&&(s=o,o=T);const u=d.validateTopics(n);if(null!==u)return m(o,new Error("Invalid topic "+u)),this;if(this._checkDisconnecting(o))return g("subscribe: discconecting true"),this;const l={qos:0};if(5===a&&(l.nl=false,l.rap=false,l.rh=0),s=y(l,s),Array.isArray(n)?n.forEach((function(t){if(g("subscribe: array topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<s.qos||i){const e={topic:t,qos:s.qos};5===a&&(e.nl=s.nl,e.rap=s.rap,e.rh=s.rh,e.properties=s.properties),g("subscribe: pushing topic `%s` and qos `%s` to subs list",e.topic,e.qos),r.push(e);}})):Object.keys(n).forEach((function(t){if(g("subscribe: object topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<n[t].qos||i){const e={topic:t,qos:n[t].qos};5===a&&(e.nl=n[t].nl,e.rap=n[t].rap,e.rh=n[t].rh,e.properties=s.properties),g("subscribe: pushing `%s` to subs list",e),r.push(e);}})),!r.length)return o(null,[]),this;const c=function(){const t=e._nextId();if(null===t)return g("No messageId left"),false;const n={cmd:"subscribe",subscriptions:r,qos:1,retain:false,dup:false,messageId:t};if(s.properties&&(n.properties=s.properties),e.options.resubscribe){g("subscribe :: resubscribe true");const t=[];r.forEach((function(r){if(e.options.reconnectPeriod>0){const n={qos:r.qos};5===a&&(n.nl=r.nl||false,n.rap=r.rap||false,n.rh=r.rh||0,n.properties=r.properties),e._resubscribeTopics[r.topic]=n,t.push(r.topic);}})),e.messageIdToTopic[n.messageId]=t;}return e.outgoing[n.messageId]={volatile:true,cb:function(e,t){if(!e){const e=t.granted;for(let t=0;t<e.length;t+=1)r[t].qos=e[t];}o(e,r);}},g("subscribe :: call _sendPacket"),e._sendPacket(n),true};return (this._storeProcessing||this._storeProcessingQueue.length>0||!c())&&this._storeProcessingQueue.push({invoke:c,callback:o}),this},A.prototype.unsubscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let r=t.shift(),n=t.pop()||T,i=t.pop();"string"==typeof r&&(r=[r]),"function"!=typeof n&&(i=n,n=T);const o=d.validateTopics(r);if(null!==o)return m(n,new Error("Invalid topic "+o)),this;if(e._checkDisconnecting(n))return this;const s=function(){const t=e._nextId();if(null===t)return g("No messageId left"),false;const o={cmd:"unsubscribe",qos:1,messageId:t};return "string"==typeof r?o.unsubscriptions=[r]:Array.isArray(r)&&(o.unsubscriptions=r),e.options.resubscribe&&o.unsubscriptions.forEach((function(t){delete e._resubscribeTopics[t];})),"object"==typeof i&&i.properties&&(o.properties=i.properties),e.outgoing[o.messageId]={volatile:true,cb:n},g("unsubscribe: call _sendPacket"),e._sendPacket(o),true};return (this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,callback:n}),this},A.prototype.end=function(e,t,r){const n=this;function i(){g("end :: closeStores: closing incoming and outgoing stores"),n.disconnected=true,n.incomingStore.close((function(e){n.outgoingStore.close((function(t){if(g("end :: closeStores: emitting end"),n.emit("end"),r){const n=e||t;g("end :: closeStores: invoking callback with args"),r(n);}}));})),n._deferredReconnect&&n._deferredReconnect();}function o(){g("end :: (%s) :: finish :: calling _cleanUp with force %s",n.options.clientId,e),n._cleanUp(e,(()=>{g("end :: finish :: calling process.nextTick on closeStores"),b(i.bind(n));}),t);}return g("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(r=t||T,t=e,e=false,"object"!=typeof t&&(r=t,t=null,"function"!=typeof r&&(r=T))),"object"!=typeof t&&(r=t,t=null),g("end :: cb? %s",!!r),r=r||T,this.disconnecting?(r(),this):(this._clearReconnect(),this.disconnecting=true,!e&&Object.keys(this.outgoing).length>0?(g("end :: (%s) :: calling finish in 10ms once outgoing is empty",n.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,o,10))):(g("end :: (%s) :: immediately calling finish",n.options.clientId),o()),this)},A.prototype.removeOutgoingMessage=function(e){const t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"));})),this},A.prototype.reconnect=function(e){g("client reconnect");const t=this,r=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new o,t.outgoingStore=t.options.outgoingStore||new o,t.disconnecting=false,t.disconnected=false,t._deferredReconnect=null,t._reconnect();};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this},A.prototype._reconnect=function(){g("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this._setupStream();})),g("client already connected. disconnecting first.")):(g("_reconnect: calling _setupStream"),this._setupStream());},A.prototype._setupReconnect=function(){const e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(g("_setupReconnect :: emit `offline` state"),this.emit("offline"),g("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=true),g("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){g("reconnectTimer :: reconnect triggered!"),e._reconnect();}),e.options.reconnectPeriod)):g("_setupReconnect :: doing nothing...");},A.prototype._clearReconnect=function(){g("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null);},A.prototype._cleanUp=function(e,t){const r=arguments[2];if(t&&(g("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),g("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&S(this.outgoing),g("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else {const e=y({cmd:"disconnect"},r);g("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(e,m.bind(null,this.stream.end.bind(this.stream)));}this.disconnecting||(g("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(g("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(g("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t());},A.prototype._sendPacket=function(e,t,r){g("_sendPacket :: (%s) ::  start",this.options.clientId),r=r||T,t=t||T;const n=function(e,t){if(5===e.options.protocolVersion&&"publish"===t.cmd){let r;t.properties&&(r=t.properties.topicAlias);const n=t.topic.toString();if(e.topicAliasSend)if(r){if(0!==n.length&&(g("applyTopicAlias :: register topic: %s - alias: %d",n,r),!e.topicAliasSend.put(n,r)))return g("applyTopicAlias :: error out of range. topic: %s - alias: %d",n,r),new Error("Sending Topic Alias out of range")}else 0!==n.length&&(e.options.autoAssignTopicAlias?(r=e.topicAliasSend.getAliasByTopic(n),r?(t.topic="",t.properties={...t.properties,topicAlias:r},g("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",n,r)):(r=e.topicAliasSend.getLruAlias(),e.topicAliasSend.put(n,r),t.properties={...t.properties,topicAlias:r},g("applyTopicAlias :: auto assign topic: %s - alias: %d",n,r))):e.options.autoUseTopicAlias&&(r=e.topicAliasSend.getAliasByTopic(n),r&&(t.topic="",t.properties={...t.properties,topicAlias:r},g("applyTopicAlias :: auto use topic: %s - alias: %d",n,r))));else if(r)return g("applyTopicAlias :: error out of range. topic: %s - alias: %d",n,r),new Error("Sending Topic Alias out of range")}}(this,e);if(n)t(n);else {if(!this.connected)return "auth"===e.cmd?(this._shiftPingInterval(),void k(this,e,t)):(g("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,r));switch(this._shiftPingInterval(),e.cmd){case "publish":break;case "pubrel":return void C(this,e,t,r);default:return void k(this,e,t)}switch(e.qos){case 2:case 1:C(this,e,t,r);break;default:k(this,e,t);}g("_sendPacket :: (%s) ::  end",this.options.clientId);}},A.prototype._storePacket=function(e,t,r){g("_storePacket :: packet: %o",e),g("_storePacket :: cb? %s",!!t),r=r||T;let n=e;if("publish"===n.cmd){n=p(e);const r=E(this,n);if(r)return t&&t(r)}0===(n.qos||0)&&this.queueQoSZero||"publish"!==n.cmd?this.queue.push({packet:n,cb:t}):n.qos>0?(t=this.outgoing[n.messageId]?this.outgoing[n.messageId].cb:null,this.outgoingStore.put(n,(function(e){if(e)return t&&t(e);r();}))):t&&t(new Error("No connection to broker"));},A.prototype._setupPingTimer=function(){g("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=true,this.pingTimer=f((function(){e._checkPing();}),1e3*this.options.keepalive));},A.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive);},A.prototype._checkPing=function(){g("_checkPing :: checking ping..."),this.pingResp?(g("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=false,this._sendPacket({cmd:"pingreq"})):(g("_checkPing :: calling _cleanUp with force true"),this._cleanUp(true));},A.prototype._handlePingresp=function(){this.pingResp=true;},A.prototype._handleConnack=function(e){g("_handleConnack");const t=this.options,r=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,e.properties){if(e.properties.topicAliasMaximum){if(e.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));e.properties.topicAliasMaximum>0&&(this.topicAliasSend=new a(e.properties.topicAliasMaximum));}e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize);}if(0===r)this.reconnecting=false,this._onConnect(e);else if(r>0){const e=new Error("Connection refused: "+_[r]);e.code=r,this.emit("error",e);}},A.prototype._handleAuth=function(e){const t=this.options.protocolVersion,r=5===t?e.reasonCode:e.returnCode;if(5!==t){const e=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+t);return e.code=r,void this.emit("error",e)}const n=this;this.handleAuth(e,(function(e,t){if(e)n.emit("error",e);else if(24===r)n.reconnecting=false,n._sendPacket(t);else {const t=new Error("Connection refused: "+_[r]);e.code=r,n.emit("error",t);}}));},A.prototype.handleAuth=function(e,t){t();},A.prototype._handlePublish=function(e,t){g("_handlePublish: packet %o",e),t=void 0!==t?t:T;let r=e.topic.toString();const n=e.payload,i=e.qos,o=e.messageId,s=this,a=this.options,u=[0,16,128,131,135,144,145,151,153];if(5===this.options.protocolVersion){let t;if(e.properties&&(t=e.properties.topicAlias),void 0!==t)if(0===r.length){if(!(t>0&&t<=65535))return g("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));{const e=this.topicAliasRecv.getTopicByAlias(t);if(!e)return g("_handlePublish :: unregistered topic alias. alias: %d",t),void this.emit("error",new Error("Received unregistered Topic Alias"));r=e,g("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",r,t);}}else {if(!this.topicAliasRecv.put(r,t))return g("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));g("_handlePublish :: registered topic: %s - alias: %d",r,t);}}switch(g("_handlePublish: qos %d",i),i){case 2:a.customHandleAcks(r,n,e,(function(r,n){return r instanceof Error||(n=r,r=null),r?s.emit("error",r):-1===u.indexOf(n)?s.emit("error",new Error("Wrong reason code for pubrec")):void(n?s._sendPacket({cmd:"pubrec",messageId:o,reasonCode:n},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:o},t);})))}));break;case 1:a.customHandleAcks(r,n,e,(function(i,a){return i instanceof Error||(a=i,i=null),i?s.emit("error",i):-1===u.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",r,n,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:o,reasonCode:a},t);})))}));break;case 0:this.emit("message",r,n,e),this.handleMessage(e,t);break;default:g("_handlePublish: unknown QoS. Doing nothing.");}},A.prototype.handleMessage=function(e,t){t();},A.prototype._handleAck=function(e){const t=e.messageId,r=e.cmd;let n=null;const i=this.outgoing[t]?this.outgoing[t].cb:null,o=this;let s;if(i){switch(g("_handleAck :: packet type",r),r){case "pubcomp":case "puback":{const r=e.reasonCode;r&&r>0&&16!==r&&(s=new Error("Publish error: "+_[r]),s.code=r,i(s,e)),delete this.outgoing[t],this.outgoingStore.del(e,i),this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue();break}case "pubrec":{n={cmd:"pubrel",qos:2,messageId:t};const r=e.reasonCode;r&&r>0&&16!==r?(s=new Error("Publish error: "+_[r]),s.code=r,i(s,e)):this._sendPacket(n);break}case "suback":delete this.outgoing[t],this.messageIdProvider.deallocate(t);for(let r=0;r<e.granted.length;r++)if(0!=(128&e.granted[r])){const e=this.messageIdToTopic[t];e&&e.forEach((function(e){delete o._resubscribeTopics[e];}));}this._invokeStoreProcessingQueue(),i(null,e);break;case "unsuback":delete this.outgoing[t],this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue(),i(null);break;default:o.emit("error",new Error("unrecognized packet type"));}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty");}else g("_handleAck :: Server sent an ack in error. Ignoring.");},A.prototype._handlePubrel=function(e,t){g("handling pubrel packet"),t=void 0!==t?t:T;const r=e.messageId,n=this,i={cmd:"pubcomp",messageId:r};n.incomingStore.get(e,(function(e,r){e?n._sendPacket(i,t):(n.emit("message",r.topic,r.payload,r),n.handleMessage(r,(function(e){if(e)return t(e);n.incomingStore.del(r,T),n._sendPacket(i,t);})));}));},A.prototype._handleDisconnect=function(e){this.emit("disconnect",e);},A.prototype._nextId=function(){return this.messageIdProvider.allocate()},A.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},A.prototype._resubscribe=function(){g("_resubscribe");const e=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!this.connackPacket.sessionPresent)&&e.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){g("_resubscribe: protocolVersion 5");for(let t=0;t<e.length;t++){const r={};r[e[t]]=this._resubscribeTopics[e[t]],r.resubscribe=true,this.subscribe(r,{properties:r[e[t]].properties});}}else this._resubscribeTopics.resubscribe=true,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=false;},A.prototype._onConnect=function(e){if(this.disconnected)return void this.emit("connect",e);const t=this;this.connackPacket=e,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=true,function r(){let n=t.outgoingStore.createStream();function i(){t._storeProcessing=false,t._packetIdsDuringStoreProcessing={};}function o(){n.destroy(),n=null,t._flushStoreProcessingQueue(),i();}t.once("close",o),n.on("error",(function(e){i(),t._flushStoreProcessingQueue(),t.removeListener("close",o),t.emit("error",e);})),n.on("end",(function(){let n=true;for(const e in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[e]){n=false;break}n?(i(),t.removeListener("close",o),t._invokeAllStoreProcessingQueue(),t.emit("connect",e)):r();})),function e(){if(!n)return;t._storeProcessing=true;const r=n.read(1);let i;r?t._packetIdsDuringStoreProcessing[r.messageId]?e():t.disconnecting||t.reconnectTimer?n.destroy&&n.destroy():(i=t.outgoing[r.messageId]?t.outgoing[r.messageId].cb:null,t.outgoing[r.messageId]={volatile:false,cb:function(t,r){i&&i(t,r),e();}},t._packetIdsDuringStoreProcessing[r.messageId]=true,t.messageIdProvider.register(r.messageId)?t._sendPacket(r):g("messageId: %d has already used.",r.messageId)):n.once("readable",e);}();}();},A.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const e=this._storeProcessingQueue[0];if(e&&e.invoke())return this._storeProcessingQueue.shift(),true}return  false},A.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},A.prototype._flushStoreProcessingQueue=function(){for(const e of this._storeProcessingQueue)e.cbStorePut&&e.cbStorePut(new Error("Connection closed")),e.callback&&e.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0);},e.exports=A;},9908:function(e,t,r){const{Buffer:n}=r(8764),i=r(8473).Transform,o=r(5981);let s,a,u,l=false;e.exports=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={});}(t);const c=function(e,t){const r="alis"===e.protocol?"wss":"ws";let n=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(n=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}(t,e);return s=t.my,s.connectSocket({url:c,protocols:r}),a=function(){const e=new i;return e._write=function(e,t,r){s.sendSocketMessage({data:e.buffer,success:function(){r();},fail:function(){r(new Error);}});},e._flush=function(e){s.closeSocket({success:function(){e();}});},e}(),u=o.obj(),l||(l=true,s.onSocketOpen((function(){u.setReadable(a),u.setWritable(a),u.emit("connect");})),s.onSocketMessage((function(e){if("string"==typeof e.data){const t=n.from(e.data,"base64");a.push(t);}else {const t=new FileReader;t.addEventListener("load",(function(){let e=t.result;e=e instanceof ArrayBuffer?n.from(e):n.from(e,"utf8"),a.push(e);})),t.readAsArrayBuffer(e.data);}})),s.onSocketClose((function(){u.end(),u.destroy();})),s.onSocketError((function(e){u.destroy(e);}))),u};},2878:function(e,t,r){var n=r(4155);const i=r(3518),o=r(2681),s=r(8575),a=r(7529),u=r(1227)("mqttjs"),l={};function c(e,t){if(u("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){const r=s.parse(e,true);if(null!=r.port&&(r.port=Number(r.port)),null===(t=a(r,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"");}if(function(e){let t;e.auth&&(t=e.auth.match(/^(.+):(.+)$/),t?(e.username=t[1],e.password=t[2]):e.username=e.auth);}(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case "mqtt":t.protocol="mqtts";break;case "ws":t.protocol="wss";break;case "wx":t.protocol="wxs";break;case "ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!l[t.protocol]){const e=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(t,r){return (!e||r%2!=0)&&"function"==typeof l[t]}))[0];}if(false===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");t.protocol&&(t.defaultProtocol=t.protocol);const r=new i((function(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),u("calling streambuilder for",t.protocol),l[t.protocol](e,t)}),t);return r.on("error",(function(){})),r} void 0!==n&&"browser"!==n.title||"function"!=typeof r?(l.mqtt=r(4983),l.tcp=r(4983),l.ssl=r(4606),l.tls=r(4606),l.mqtts=r(4606)):(l.wx=r(7465),l.wxs=r(7465),l.ali=r(9908),l.alis=r(9908)),l.ws=r(4574),l.wss=r(4574),e.exports=c,e.exports.connect=c,e.exports.MqttClient=i,e.exports.Store=o;},4983:function(e,t,r){const n=r(10),i=r(1227)("mqttjs:tcp");e.exports=function(e,t){t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost";const r=t.port,o=t.hostname;return i("port %d and host %s",r,o),n.createConnection(r,o)};},4606:function(e,t,r){const n=r(4995),i=r(10),o=r(1227)("mqttjs:tls");e.exports=function(e,t){t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",0===i.isIP(t.host)&&(t.servername=t.host),t.rejectUnauthorized=false!==t.rejectUnauthorized,delete t.path,o("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized);const r=n.connect(t);function s(n){t.rejectUnauthorized&&e.emit("error",n),r.end();}return r.on("secureConnect",(function(){t.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",s);})),r.on("error",s),r};},4574:function(e,t,r){var n=r(4155);const{Buffer:i}=r(8764),o=r(7026),s=r(1227)("mqttjs:ws"),a=r(5981),u=r(8473).Transform,l=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],c=void 0!==n&&"browser"===n.title||"function"==typeof r;function h(e,t){let r=e.protocol+"://"+e.hostname+":"+e.port+e.path;return "function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function f(e){const t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),c||"wss"!==e.protocol||l.forEach((function(r){Object.prototype.hasOwnProperty.call(e,r)&&!Object.prototype.hasOwnProperty.call(e.wsOptions,r)&&(t.wsOptions[r]=e[r]);})),t}e.exports=c?function(e,t){let r;s("browserStreamBuilder");const n=function(e){const t=f(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port);}return void 0===t.objectMode&&(t.objectMode=!(true===t.binary||void 0===t.binary)),t}(t),o=n.browserBufferSize||524288,l=t.browserBufferTimeout||1e3,c=!t.objectMode,p=function(e,t){const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt",n=h(t,e),i=new WebSocket(n,[r]);return i.binaryType="arraybuffer",i}(e,t),d=function(e,t,r){const n=new u({objectModeMode:e.objectMode});return n._write=function e(t,r,n){p.bufferedAmount>o&&setTimeout(e,l,t,r,n),c&&"string"==typeof t&&(t=i.from(t,"utf8"));try{p.send(t);}catch(e){return n(e)}n();},n._flush=function(e){p.close(),e();},n}(t);t.objectMode||(d._writev=w),d.on("close",(()=>{p.close();}));const y=void 0!==p.addEventListener;function g(){r.setReadable(d),r.setWritable(d),r.emit("connect");}function b(){r.end(),r.destroy();}function m(e){r.destroy(e);}function v(e){let t=e.data;t=t instanceof ArrayBuffer?i.from(t):i.from(t,"utf8"),d.push(t);}function w(e,t){const r=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?r[t]=i.from(e[t],"utf8"):r[t]=e[t].chunk;this._write(i.concat(r),"binary",t);}return p.readyState===p.OPEN?r=d:(r=r=a(void 0,void 0,t),t.objectMode||(r._writev=w),y?p.addEventListener("open",g):p.onopen=g),r.socket=p,y?(p.addEventListener("close",b),p.addEventListener("error",m),p.addEventListener("message",v)):(p.onclose=b,p.onerror=m,p.onmessage=v),r}:function(e,t){s("streamBuilder");const r=f(t),n=h(r,e),i=function(e,t,r){s("createWebSocket"),s("protocol: "+r.protocolId+" "+r.protocolVersion);const n="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";return s("creating new Websocket for url: "+t+" and protocol: "+n),new o(t,[n],r.wsOptions)}(0,n,r),a=o.createWebSocketStream(i,r.wsOptions);return a.url=n,i.on("close",(()=>{a.destroy();})),a};},7465:function(e,t,r){const{Buffer:n}=r(8764),i=r(8473).Transform,o=r(5981);let s,a,u;e.exports=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={});}(t);const l=function(e,t){const r="wxs"===e.protocol?"wss":"ws";let n=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(n=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}(t,e);s=wx.connectSocket({url:l,protocols:[r]}),a=function(){const e=new i;return e._write=function(e,t,r){s.send({data:e.buffer,success:function(){r();},fail:function(e){r(new Error(e));}});},e._flush=function(e){s.close({success:function(){e();}});},e}(),u=o.obj(),u._destroy=function(e,t){s.close({success:function(){t&&t(e);}});};const c=u.destroy;return u.destroy=function(){u.destroy=c;const e=this;setTimeout((function(){s.close({fail:function(){e._destroy(new Error);}});}),0);}.bind(u),s.onOpen((function(){u.setReadable(a),u.setWritable(a),u.emit("connect");})),s.onMessage((function(e){let t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),a.push(t);})),s.onClose((function(){u.end(),u.destroy();})),s.onError((function(e){u.destroy(new Error(e.errMsg));})),u};},298:function(e){function t(){if(!(this instanceof t))return new t;this.nextId=Math.max(1,Math.floor(65535*Math.random()));}t.prototype.allocate=function(){const e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},t.prototype.getLastAllocated=function(){return 1===this.nextId?65535:this.nextId-1},t.prototype.register=function(e){return  true},t.prototype.deallocate=function(e){},t.prototype.clear=function(){},e.exports=t;},2681:function(e,t,r){const n=r(7529),i=r(8473).Readable,o={objectMode:true},s={clean:true};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=n(s,e),this._inflights=new Map;}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){const e=new i(o),t=[];let r=false,n=0;return this._inflights.forEach((function(e,r){t.push(e);})),e._read=function(){!r&&n<t.length?this.push(t[n++]):this.push(null);},e.destroy=function(){if(r)return;const e=this;r=true,setTimeout((function(){e.emit("close");}),0);},e},a.prototype.del=function(e,t){return (e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},a.prototype.get=function(e,t){return (e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e();},e.exports=a;},8254:function(e){function t(e){if(!(this instanceof t))return new t(e);this.aliasToTopic={},this.max=e;}t.prototype.put=function(e,t){return !(0===t||t>this.max||(this.aliasToTopic[t]=e,this.length=Object.keys(this.aliasToTopic).length,0))},t.prototype.getTopicByAlias=function(e){return this.aliasToTopic[e]},t.prototype.clear=function(){this.aliasToTopic={};},e.exports=t;},226:function(e,t,r){const n=r(9593),i=r(423).Q;function o(e){if(!(this instanceof o))return new o(e);e>0&&(this.aliasToTopic=new n({max:e}),this.topicToAlias={},this.numberAllocator=new i(1,e),this.max=e,this.length=0);}o.prototype.put=function(e,t){if(0===t||t>this.max)return  false;const r=this.aliasToTopic.get(t);return r&&delete this.topicToAlias[r],this.aliasToTopic.set(t,e),this.topicToAlias[e]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.length,true},o.prototype.getTopicByAlias=function(e){return this.aliasToTopic.get(e)},o.prototype.getAliasByTopic=function(e){const t=this.topicToAlias[e];return void 0!==t&&this.aliasToTopic.get(t),t},o.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0;},o.prototype.getLruAlias=function(){return this.numberAllocator.firstVacant()||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},e.exports=o;},3380:function(e){function t(e){const t=e.split("/");for(let e=0;e<t.length;e++)if("+"!==t[e]){if("#"===t[e])return e===t.length-1;if(-1!==t[e].indexOf("+")||-1!==t[e].indexOf("#"))return  false}return  true}e.exports={validateTopics:function(e){if(0===e.length)return "empty_topic_list";for(let r=0;r<e.length;r++)if(!t(e[r]))return e[r];return null}};}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={id:n,loaded:false,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.loaded=true,o.exports}r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:true,get:t[n]});},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e};var n=r(2878);mqtt_browser.exports=n;}();
	return mqtt_browser.exports;
}

var mqtt_browserExports = requireMqtt_browser();
var mqtt = /*@__PURE__*/getDefaultExportFromCjs(mqtt_browserExports);

const CONNECTION_STATUS = {
    CONNECTING: "CONNECTING",
    RECONNECTING: "RECONNECTING",
    CONNECTED: "CONNECTED",
    OFFLINE: "OFFLINE",
    ERROR: "ERROR",
};
class Observable {
    constructor(value) {
        this.callbacks = [];
        this.value = value;
    }
    set(value) {
        if (this.value === value) {
            return this;
        }
        this.value = value;
        this.callbacks.forEach((callback) => callback(value));
        return this;
    }
    get() {
        return this.value;
    }
    subscribe(callback) {
        this.callbacks.push(callback);
        return () => {
            this.callbacks = this.callbacks.filter((cb) => cb !== callback);
            return this;
        };
    }
    destroy() {
        this.callbacks = [];
    }
}
class Connector {
    constructor() {
        this._status = new Observable(CONNECTION_STATUS.OFFLINE);
        this._messages = new Observable([]);
        this.onMessageReceived = (topic, message) => {
            var _a;
            try {
                const parsedMessage = JSON.parse(message.toString());
                if (topic === `short/${(_a = this.options) === null || _a === void 0 ? void 0 : _a.slug}/message/recv`) {
                    const currentMessages = this._messages.get();
                    this._messages.set([parsedMessage, ...currentMessages]);
                }
            }
            catch (error) {
                // Swallow parse errors to avoid breaking message flow
            }
        };
    }
    get status() {
        return this._status;
    }
    get messages() {
        return this._messages;
    }
    getTopics() {
        if (!this.options) {
            return [];
        }
        return [
            `short/${this.options.slug}/analytics/recv`,
            `short/${this.options.slug}/message/recv`,
        ];
    }
    /**
     * Safely remove the 'message' listener from an MQTT client instance.
     * Different client builds may expose different APIs (removeListener/off/removeEventListener).
     */
    removeMessageListenerSafe(client) {
        const anyClient = client;
        try {
            if (typeof anyClient["removeListener"] === "function") {
                anyClient["removeListener"]("message", this.onMessageReceived);
            }
            else if (typeof anyClient["off"] === "function") {
                anyClient["off"]("message", this.onMessageReceived);
            }
            else if (typeof anyClient["removeEventListener"] === "function") {
                anyClient["removeEventListener"]("message", this.onMessageReceived);
            }
        }
        catch (err) {
            // Swallow listener cleanup errors to avoid breaking disconnect flow
        }
    }
    /**
     * Safely unsubscribe from topics if supported by the client.
     */
    unsubscribeSafe(client, topics) {
        const anyClient = client;
        try {
            if (Array.isArray(topics) &&
                topics.length > 0 &&
                typeof anyClient["unsubscribe"] === "function") {
                anyClient["unsubscribe"](topics);
            }
        }
        catch (err) {
            // Swallow unsubscribe errors
        }
    }
    connect(options) {
        if (this.client || this.tempClient) {
            return;
        }
        this.options = options;
        this.tempClient = mqtt.connect(options.brokerUrl || "wss://messaging.interactify.live/mqtt", {
            keepalive: 5,
            protocolId: "MQTT",
            protocolVersion: 4,
            clean: true,
            reconnectPeriod: 1000,
            connectTimeout: 5 * 1000,
            clientId: `${options.space_slug}:${options.slug}:${options.user_id}:${options.session}:${options.scope}`,
            username: options.user_id,
            password: options.token,
            will: {
                topic: "WillMsg",
                payload: "Connection Closed abnormally..!",
                qos: 0,
                retain: false,
            },
            rejectUnauthorized: false,
        });
        this._status.set(CONNECTION_STATUS.CONNECTING);
        this.tempClient.once("connect", () => {
            this.client = this.tempClient;
            this.tempClient = undefined;
            // Set status to CONNECTED immediately since we're already connected
            this._status.set(CONNECTION_STATUS.CONNECTED);
            for (const topic of this.getTopics()) {
                console.log("[Interactify Connector] MQTT subscribing:", topic);
                this.client.subscribe(topic, (err, granted) => {
                    if (err) {
                        console.error("[Interactify Connector] MQTT subscribe failed:", topic, err);
                        return;
                    }
                    console.log("[Interactify Connector] MQTT subscribed:", topic, granted);
                });
            }
            this.client.on("message", this.onMessageReceived);
        });
        this.tempClient.on("reconnect", () => {
            this._status.set(CONNECTION_STATUS.RECONNECTING);
        });
        this.tempClient.on("error", () => {
            // TODO setStatus(err.message);
            this._status.set(CONNECTION_STATUS.ERROR);
        });
        this.tempClient.on("offline", () => {
            this._status.set(CONNECTION_STATUS.OFFLINE);
        });
        this.tempClient.on("end", () => {
            this._status.set(CONNECTION_STATUS.OFFLINE);
        });
    }
    disconnect() {
        if (this.tempClient) {
            this.removeMessageListenerSafe(this.tempClient);
            this.unsubscribeSafe(this.tempClient, this.getTopics());
            try {
                this.tempClient.end(true);
            }
            catch (err) {
                // Swallow end errors for temp client
            }
            this.tempClient = undefined;
        }
        if (this.client) {
            this.removeMessageListenerSafe(this.client);
            this.unsubscribeSafe(this.client, this.getTopics());
            try {
                this.client.end(true);
            }
            catch (err) {
                // Swallow end errors for main client
            }
            this.client = undefined;
        }
        this._status.set(CONNECTION_STATUS.OFFLINE);
    }
    publish(type) {
        if (!this.client || !this.options) {
            throw new Error("not connected");
        }
        this.client.publish(`${this.options.scope}/${this.options.slug}/analytics/send`, JSON.stringify({
            event_type: "ACTION_CLICK",
            value: {
                event_type: type,
                user_id: this.options.user_id,
            },
        }));
    }
    sendMessage(message) {
        if (!this.client || !this.options) {
            throw new Error("not connected");
        }
        const chatMessage = {
            avatar: message.avatar || "",
            text: message.text,
            created_at: new Date().toISOString(),
            user_id: this.options.user_id,
            display_name: this.options.display_name || this.options.user_id,
            live_slug: "",
            space_slug: this.options.space_slug,
            visible: message.visible !== false,
            slug: this.options.slug,
            reply_to: message.replyTo
                ? {
                    text: message.replyTo.text,
                    user_id: message.replyTo.userID,
                    display_name: message.replyTo.displayName,
                    slug: message.replyTo.slug,
                    avatar: message.replyTo.avatar || "",
                    created_at: message.replyTo.created_at || "",
                    short_slug: message.replyTo.short_slug || "",
                    space_slug: message.replyTo.space_slug || "",
                    visible: message.replyTo.visible !== false,
                }
                : undefined,
        };
        this.client.publish(`short/${this.options.slug}/message/send`, JSON.stringify(chatMessage));
    }
    sendLikeEvent(messageSlug, options) {
        if (!this.client || !this.options) {
            throw new Error("not connected");
        }
        const likeEvent = {
            messageSlug,
            user_id: this.options.user_id,
            space_slug: this.options.space_slug,
            slug: this.options.slug,
            like_type: (options === null || options === void 0 ? void 0 : options.like_type) || "like",
        };
        this.client.publish(`short/${this.options.slug}/like/send`, JSON.stringify(likeEvent));
    }
}
Connector.CONNECTION_STATUS = CONNECTION_STATUS;

exports.Connector = Connector;