import{A as St,Ba as jt,C as xt,Fa as Wt,Ha as Vt,Ka as qt,O as It,Oa as zt,P as Ct,Ra as Kt,S as At,T as Tt,Ta as Yt,U as Rt,V as Pt,Wa as Qt,_ as Ot,_a as Gt,ab as $t,ca as Bt,cb as Jt,e as yt,eb as Xt,gb as Zt,ib as er,j as _t,ka as Mt,n as wt,oa as kt,qa as Nt,sa as Lt,ta as Ut,u as bt,v as vt,va as Ft,xa as Dt,z as Et}from"./chunk-XXGLJ63T.js";import{Bb as ot,Cb as Fe,Db as De,De as ct,Ee as ft,Fe as pt,G as Qe,H as Ge,Hb as at,I as $e,Ia as _e,Je as dt,Lf as Ht,Ma as ge,Ra as Le,Ta as Ce,V as Je,W as Xe,a as Te,ac as ut,b as Re,bc as lt,c as Ie,e as ir,eb as Ae,fa as Ze,fb as Se,ff as gt,g as Ve,gb as tt,ha as Be,i as Ee,ia as Me,j as qe,jf as mt,k as ze,kb as rt,l as Ke,la as et,lc as ht,m as Oe,n as Ye,ob as it,qa as ke,qb as Ue,ra as Ne,rb as nt,sb as st}from"./chunk-TV7RDLL7.js";var We=ir((tr,je)=>{"use strict";(function(ue){if(typeof tr=="object"&&typeof je<"u")je.exports=ue();else if(typeof define=="function"&&define.amd)define([],ue);else{var he;typeof window<"u"?he=window:typeof global<"u"?he=global:typeof self<"u"?he=self:he=this,he.mqtt=ue()}})(function(){var ue,he,de;return function(){function y(k,x,d){function f(s,i){if(!x[s]){if(!k[s]){var r=typeof Ie=="function"&&Ie;if(!i&&r)return r(s,!0);if(m)return m(s,!0);var e=new Error("Cannot find module '"+s+"'");throw e.code="MODULE_NOT_FOUND",e}var t=x[s]={exports:{}};k[s][0].call(t.exports,function(o){var l=k[s][1][o];return f(l||o)},t,t.exports,y,k,x,d)}return x[s].exports}for(var m=typeof Ie=="function"&&Ie,h=0;h0)throw new Error("Invalid string. Length must be a multiple of 4");var v=_.indexOf("=");v===-1&&(v=c);var R=v===c?0:4-v%4;return[v,R]}function e(_){var c=r(_),v=c[0],R=c[1];return(v+R)*3/4-R}function t(_,c,v){return(c+v)*3/4-v}function o(_){var c,v=r(_),R=v[0],A=v[1],W=new m(t(_,R,A)),j=0,I=A>0?R-4:R,P;for(P=0;P>16&255,W[j++]=c>>8&255,W[j++]=c&255;return A===2&&(c=f[_.charCodeAt(P)]<<2|f[_.charCodeAt(P+1)]>>4,W[j++]=c&255),A===1&&(c=f[_.charCodeAt(P)]<<10|f[_.charCodeAt(P+1)]<<4|f[_.charCodeAt(P+2)]>>2,W[j++]=c>>8&255,W[j++]=c&255),W}function l(_){return d[_>>18&63]+d[_>>12&63]+d[_>>6&63]+d[_&63]}function p(_,c,v){for(var R,A=[],W=c;WI?I:j+W));return R===1?(c=_[v-1],A.push(d[c>>2]+d[c<<4&63]+"==")):R===2&&(c=(_[v-2]<<8)+_[v-1],A.push(d[c>>10]+d[c>>4&63]+d[c<<2&63]+"=")),A.join("")}},{}],2:[function(y,k,x){},{}],3:[function(y,k,x){(function(d){(function(){"use strict";var f=y("base64-js"),m=y("ieee754");x.Buffer=r,x.SlowBuffer=R,x.INSPECT_MAX_BYTES=50;var h=2147483647;x.kMaxLength=h,r.TYPED_ARRAY_SUPPORT=s(),!r.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&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.");function s(){try{var u=new Uint8Array(1);return u.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},u.foo()===42}catch{return!1}}Object.defineProperty(r.prototype,"parent",{enumerable:!0,get:function(){if(r.isBuffer(this))return this.buffer}}),Object.defineProperty(r.prototype,"offset",{enumerable:!0,get:function(){if(r.isBuffer(this))return this.byteOffset}});function i(u){if(u>h)throw new RangeError('The value "'+u+'" is invalid for option "size"');var n=new Uint8Array(u);return n.__proto__=r.prototype,n}function r(u,n,a){if(typeof u=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return l(u)}return e(u,n,a)}typeof Symbol<"u"&&Symbol.species!=null&&r[Symbol.species]===r&&Object.defineProperty(r,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),r.poolSize=8192;function e(u,n,a){if(typeof u=="string")return p(u,n);if(ArrayBuffer.isView(u))return g(u);if(u==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u);if(Q(u,ArrayBuffer)||u&&Q(u.buffer,ArrayBuffer))return _(u,n,a);if(typeof u=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var b=u.valueOf&&u.valueOf();if(b!=null&&b!==u)return r.from(b,n,a);var L=c(u);if(L)return L;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof u[Symbol.toPrimitive]=="function")return r.from(u[Symbol.toPrimitive]("string"),n,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u)}r.from=function(u,n,a){return e(u,n,a)},r.prototype.__proto__=Uint8Array.prototype,r.__proto__=Uint8Array;function t(u){if(typeof u!="number")throw new TypeError('"size" argument must be of type number');if(u<0)throw new RangeError('The value "'+u+'" is invalid for option "size"')}function o(u,n,a){return t(u),u<=0?i(u):n!==void 0?typeof a=="string"?i(u).fill(n,a):i(u).fill(n):i(u)}r.alloc=function(u,n,a){return o(u,n,a)};function l(u){return t(u),i(u<0?0:v(u)|0)}r.allocUnsafe=function(u){return l(u)},r.allocUnsafeSlow=function(u){return l(u)};function p(u,n){if((typeof n!="string"||n==="")&&(n="utf8"),!r.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var a=A(u,n)|0,b=i(a),L=b.write(u,n);return L!==a&&(b=b.slice(0,L)),b}function g(u){for(var n=u.length<0?0:v(u.length)|0,a=i(n),b=0;b=h)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+h.toString(16)+" bytes");return u|0}function R(u){return+u!=u&&(u=0),r.alloc(+u)}r.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==r.prototype},r.compare=function(n,a){if(Q(n,Uint8Array)&&(n=r.from(n,n.offset,n.byteLength)),Q(a,Uint8Array)&&(a=r.from(a,a.offset,a.byteLength)),!r.isBuffer(n)||!r.isBuffer(a))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===a)return 0;for(var b=n.length,L=a.length,K=0,J=Math.min(b,L);K2&&arguments[2]===!0;if(!b&&a===0)return 0;for(var L=!1;;)switch(n){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return te(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a*2;case"hex":return a>>>1;case"base64":return N(u).length;default:if(L)return b?-1:te(u).length;n=(""+n).toLowerCase(),L=!0}}r.byteLength=A;function W(u,n,a){var b=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((a===void 0||a>this.length)&&(a=this.length),a<=0)||(a>>>=0,n>>>=0,a<=n))return"";for(u||(u="utf8");;)switch(u){case"hex":return ee(this,n,a);case"utf8":case"utf-8":return E(this,n,a);case"ascii":return q(this,n,a);case"latin1":case"binary":return re(this,n,a);case"base64":return G(this,n,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return H(this,n,a);default:if(b)throw new TypeError("Unknown encoding: "+u);u=(u+"").toLowerCase(),b=!0}}r.prototype._isBuffer=!0;function j(u,n,a){var b=u[n];u[n]=u[a],u[a]=b}r.prototype.swap16=function(){var n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var a=0;aa&&(n+=" ... "),""},r.prototype.compare=function(n,a,b,L,K){if(Q(n,Uint8Array)&&(n=r.from(n,n.offset,n.byteLength)),!r.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(a===void 0&&(a=0),b===void 0&&(b=n?n.length:0),L===void 0&&(L=0),K===void 0&&(K=this.length),a<0||b>n.length||L<0||K>this.length)throw new RangeError("out of range index");if(L>=K&&a>=b)return 0;if(L>=K)return-1;if(a>=b)return 1;if(a>>>=0,b>>>=0,L>>>=0,K>>>=0,this===n)return 0;for(var J=K-L,ae=b-a,le=Math.min(J,ae),ce=this.slice(L,K),pe=n.slice(a,b),fe=0;fe2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),a=+a,w(a)&&(a=L?0:u.length-1),a<0&&(a=u.length+a),a>=u.length){if(L)return-1;a=u.length-1}else if(a<0)if(L)a=0;else return-1;if(typeof n=="string"&&(n=r.from(n,b)),r.isBuffer(n))return n.length===0?-1:P(u,n,a,b,L);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?L?Uint8Array.prototype.indexOf.call(u,n,a):Uint8Array.prototype.lastIndexOf.call(u,n,a):P(u,[n],a,b,L);throw new TypeError("val must be string, number or Buffer")}function P(u,n,a,b,L){var K=1,J=u.length,ae=n.length;if(b!==void 0&&(b=String(b).toLowerCase(),b==="ucs2"||b==="ucs-2"||b==="utf16le"||b==="utf-16le")){if(u.length<2||n.length<2)return-1;K=2,J/=2,ae/=2,a/=2}function le(we,ye){return K===1?we[ye]:we.readUInt16BE(ye*K)}var ce;if(L){var pe=-1;for(ce=a;ceJ&&(a=J-ae),ce=a;ce>=0;ce--){for(var fe=!0,me=0;meL&&(b=L)):b=L;var K=n.length;b>K/2&&(b=K/2);for(var J=0;J>>0,isFinite(b)?(b=b>>>0,L===void 0&&(L="utf8")):(L=b,b=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var K=this.length-a;if((b===void 0||b>K)&&(b=K),n.length>0&&(b<0||a<0)||a>this.length)throw new RangeError("Attempt to write outside buffer bounds");L||(L="utf8");for(var J=!1;;)switch(L){case"hex":return S(this,n,a,b);case"utf8":case"utf-8":return V(this,n,a,b);case"ascii":return M(this,n,a,b);case"latin1":case"binary":return ne(this,n,a,b);case"base64":return se(this,n,a,b);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,n,a,b);default:if(J)throw new TypeError("Unknown encoding: "+L);L=(""+L).toLowerCase(),J=!0}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function G(u,n,a){return n===0&&a===u.length?f.fromByteArray(u):f.fromByteArray(u.slice(n,a))}function E(u,n,a){a=Math.min(u.length,a);for(var b=[],L=n;L239?4:K>223?3:K>191?2:1;if(L+ae<=a){var le,ce,pe,fe;switch(ae){case 1:K<128&&(J=K);break;case 2:le=u[L+1],(le&192)===128&&(fe=(K&31)<<6|le&63,fe>127&&(J=fe));break;case 3:le=u[L+1],ce=u[L+2],(le&192)===128&&(ce&192)===128&&(fe=(K&15)<<12|(le&63)<<6|ce&63,fe>2047&&(fe<55296||fe>57343)&&(J=fe));break;case 4:le=u[L+1],ce=u[L+2],pe=u[L+3],(le&192)===128&&(ce&192)===128&&(pe&192)===128&&(fe=(K&15)<<18|(le&63)<<12|(ce&63)<<6|pe&63,fe>65535&&fe<1114112&&(J=fe))}}J===null?(J=65533,ae=1):J>65535&&(J-=65536,b.push(J>>>10&1023|55296),J=56320|J&1023),b.push(J),L+=ae}return U(b)}var T=4096;function U(u){var n=u.length;if(n<=T)return String.fromCharCode.apply(String,u);for(var a="",b=0;bb)&&(a=b);for(var L="",K=n;Kb&&(n=b),a<0?(a+=b,a<0&&(a=0)):a>b&&(a=b),aa)throw new RangeError("Trying to access beyond buffer length")}r.prototype.readUIntLE=function(n,a,b){n=n>>>0,a=a>>>0,b||D(n,a,this.length);for(var L=this[n],K=1,J=0;++J>>0,a=a>>>0,b||D(n,a,this.length);for(var L=this[n+--a],K=1;a>0&&(K*=256);)L+=this[n+--a]*K;return L},r.prototype.readUInt8=function(n,a){return n=n>>>0,a||D(n,1,this.length),this[n]},r.prototype.readUInt16LE=function(n,a){return n=n>>>0,a||D(n,2,this.length),this[n]|this[n+1]<<8},r.prototype.readUInt16BE=function(n,a){return n=n>>>0,a||D(n,2,this.length),this[n]<<8|this[n+1]},r.prototype.readUInt32LE=function(n,a){return n=n>>>0,a||D(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},r.prototype.readUInt32BE=function(n,a){return n=n>>>0,a||D(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},r.prototype.readIntLE=function(n,a,b){n=n>>>0,a=a>>>0,b||D(n,a,this.length);for(var L=this[n],K=1,J=0;++J=K&&(L-=Math.pow(2,8*a)),L},r.prototype.readIntBE=function(n,a,b){n=n>>>0,a=a>>>0,b||D(n,a,this.length);for(var L=a,K=1,J=this[n+--L];L>0&&(K*=256);)J+=this[n+--L]*K;return K*=128,J>=K&&(J-=Math.pow(2,8*a)),J},r.prototype.readInt8=function(n,a){return n=n>>>0,a||D(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},r.prototype.readInt16LE=function(n,a){n=n>>>0,a||D(n,2,this.length);var b=this[n]|this[n+1]<<8;return b&32768?b|4294901760:b},r.prototype.readInt16BE=function(n,a){n=n>>>0,a||D(n,2,this.length);var b=this[n+1]|this[n]<<8;return b&32768?b|4294901760:b},r.prototype.readInt32LE=function(n,a){return n=n>>>0,a||D(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},r.prototype.readInt32BE=function(n,a){return n=n>>>0,a||D(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},r.prototype.readFloatLE=function(n,a){return n=n>>>0,a||D(n,4,this.length),m.read(this,n,!0,23,4)},r.prototype.readFloatBE=function(n,a){return n=n>>>0,a||D(n,4,this.length),m.read(this,n,!1,23,4)},r.prototype.readDoubleLE=function(n,a){return n=n>>>0,a||D(n,8,this.length),m.read(this,n,!0,52,8)},r.prototype.readDoubleBE=function(n,a){return n=n>>>0,a||D(n,8,this.length),m.read(this,n,!1,52,8)};function X(u,n,a,b,L,K){if(!r.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>L||nu.length)throw new RangeError("Index out of range")}r.prototype.writeUIntLE=function(n,a,b,L){if(n=+n,a=a>>>0,b=b>>>0,!L){var K=Math.pow(2,8*b)-1;X(this,n,a,b,K,0)}var J=1,ae=0;for(this[a]=n&255;++ae>>0,b=b>>>0,!L){var K=Math.pow(2,8*b)-1;X(this,n,a,b,K,0)}var J=b-1,ae=1;for(this[a+J]=n&255;--J>=0&&(ae*=256);)this[a+J]=n/ae&255;return a+b},r.prototype.writeUInt8=function(n,a,b){return n=+n,a=a>>>0,b||X(this,n,a,1,255,0),this[a]=n&255,a+1},r.prototype.writeUInt16LE=function(n,a,b){return n=+n,a=a>>>0,b||X(this,n,a,2,65535,0),this[a]=n&255,this[a+1]=n>>>8,a+2},r.prototype.writeUInt16BE=function(n,a,b){return n=+n,a=a>>>0,b||X(this,n,a,2,65535,0),this[a]=n>>>8,this[a+1]=n&255,a+2},r.prototype.writeUInt32LE=function(n,a,b){return n=+n,a=a>>>0,b||X(this,n,a,4,4294967295,0),this[a+3]=n>>>24,this[a+2]=n>>>16,this[a+1]=n>>>8,this[a]=n&255,a+4},r.prototype.writeUInt32BE=function(n,a,b){return n=+n,a=a>>>0,b||X(this,n,a,4,4294967295,0),this[a]=n>>>24,this[a+1]=n>>>16,this[a+2]=n>>>8,this[a+3]=n&255,a+4},r.prototype.writeIntLE=function(n,a,b,L){if(n=+n,a=a>>>0,!L){var K=Math.pow(2,8*b-1);X(this,n,a,b,K-1,-K)}var J=0,ae=1,le=0;for(this[a]=n&255;++J>0)-le&255;return a+b},r.prototype.writeIntBE=function(n,a,b,L){if(n=+n,a=a>>>0,!L){var K=Math.pow(2,8*b-1);X(this,n,a,b,K-1,-K)}var J=b-1,ae=1,le=0;for(this[a+J]=n&255;--J>=0&&(ae*=256);)n<0&&le===0&&this[a+J+1]!==0&&(le=1),this[a+J]=(n/ae>>0)-le&255;return a+b},r.prototype.writeInt8=function(n,a,b){return n=+n,a=a>>>0,b||X(this,n,a,1,127,-128),n<0&&(n=255+n+1),this[a]=n&255,a+1},r.prototype.writeInt16LE=function(n,a,b){return n=+n,a=a>>>0,b||X(this,n,a,2,32767,-32768),this[a]=n&255,this[a+1]=n>>>8,a+2},r.prototype.writeInt16BE=function(n,a,b){return n=+n,a=a>>>0,b||X(this,n,a,2,32767,-32768),this[a]=n>>>8,this[a+1]=n&255,a+2},r.prototype.writeInt32LE=function(n,a,b){return n=+n,a=a>>>0,b||X(this,n,a,4,2147483647,-2147483648),this[a]=n&255,this[a+1]=n>>>8,this[a+2]=n>>>16,this[a+3]=n>>>24,a+4},r.prototype.writeInt32BE=function(n,a,b){return n=+n,a=a>>>0,b||X(this,n,a,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[a]=n>>>24,this[a+1]=n>>>16,this[a+2]=n>>>8,this[a+3]=n&255,a+4};function $(u,n,a,b,L,K){if(a+b>u.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function oe(u,n,a,b,L){return n=+n,a=a>>>0,L||$(u,n,a,4,34028234663852886e22,-34028234663852886e22),m.write(u,n,a,b,23,4),a+4}r.prototype.writeFloatLE=function(n,a,b){return oe(this,n,a,!0,b)},r.prototype.writeFloatBE=function(n,a,b){return oe(this,n,a,!1,b)};function Z(u,n,a,b,L){return n=+n,a=a>>>0,L||$(u,n,a,8,17976931348623157e292,-17976931348623157e292),m.write(u,n,a,b,52,8),a+8}r.prototype.writeDoubleLE=function(n,a,b){return Z(this,n,a,!0,b)},r.prototype.writeDoubleBE=function(n,a,b){return Z(this,n,a,!1,b)},r.prototype.copy=function(n,a,b,L){if(!r.isBuffer(n))throw new TypeError("argument should be a Buffer");if(b||(b=0),!L&&L!==0&&(L=this.length),a>=n.length&&(a=n.length),a||(a=0),L>0&&L=this.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("sourceEnd out of bounds");L>this.length&&(L=this.length),n.length-a=0;--J)n[J+a]=this[J+b];else Uint8Array.prototype.set.call(n,this.subarray(b,L),a);return K},r.prototype.fill=function(n,a,b,L){if(typeof n=="string"){if(typeof a=="string"?(L=a,a=0,b=this.length):typeof b=="string"&&(L=b,b=this.length),L!==void 0&&typeof L!="string")throw new TypeError("encoding must be a string");if(typeof L=="string"&&!r.isEncoding(L))throw new TypeError("Unknown encoding: "+L);if(n.length===1){var K=n.charCodeAt(0);(L==="utf8"&&K<128||L==="latin1")&&(n=K)}}else typeof n=="number"&&(n=n&255);if(a<0||this.length>>0,b=b===void 0?this.length:b>>>0,n||(n=0);var J;if(typeof n=="number")for(J=a;J55295&&a<57344){if(!L){if(a>56319){(n-=3)>-1&&K.push(239,191,189);continue}else if(J+1===b){(n-=3)>-1&&K.push(239,191,189);continue}L=a;continue}if(a<56320){(n-=3)>-1&&K.push(239,191,189),L=a;continue}a=(L-55296<<10|a-56320)+65536}else L&&(n-=3)>-1&&K.push(239,191,189);if(L=null,a<128){if((n-=1)<0)break;K.push(a)}else if(a<2048){if((n-=2)<0)break;K.push(a>>6|192,a&63|128)}else if(a<65536){if((n-=3)<0)break;K.push(a>>12|224,a>>6&63|128,a&63|128)}else if(a<1114112){if((n-=4)<0)break;K.push(a>>18|240,a>>12&63|128,a>>6&63|128,a&63|128)}else throw new Error("Invalid code point")}return K}function O(u){for(var n=[],a=0;a>8,L=a%256,K.push(L),K.push(b);return K}function N(u){return f.toByteArray(B(u))}function z(u,n,a,b){for(var L=0;L=n.length||L>=u.length);++L)n[L+a]=u[L];return L}function Q(u,n){return u instanceof n||u!=null&&u.constructor!=null&&u.constructor.name!=null&&u.constructor.name===n.name}function w(u){return u!==u}}).call(this)}).call(this,y("buffer").Buffer)},{"base64-js":1,buffer:3,ieee754:5}],4:[function(y,k,x){"use strict";var d=typeof Reflect=="object"?Reflect:null,f=d&&typeof d.apply=="function"?d.apply:function(P,S,V){return Function.prototype.apply.call(P,S,V)},m;d&&typeof d.ownKeys=="function"?m=d.ownKeys:Object.getOwnPropertySymbols?m=function(P){return Object.getOwnPropertyNames(P).concat(Object.getOwnPropertySymbols(P))}:m=function(P){return Object.getOwnPropertyNames(P)};function h(I){console&&console.warn&&console.warn(I)}var s=Number.isNaN||function(P){return P!==P};function i(){i.init.call(this)}k.exports=i,k.exports.once=A,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var r=10;function e(I){if(typeof I!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof I)}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return r},set:function(I){if(typeof I!="number"||I<0||s(I))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+I+".");r=I}}),i.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(P){if(typeof P!="number"||P<0||s(P))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+P+".");return this._maxListeners=P,this};function t(I){return I._maxListeners===void 0?i.defaultMaxListeners:I._maxListeners}i.prototype.getMaxListeners=function(){return t(this)},i.prototype.emit=function(P){for(var S=[],V=1;V0&&(se=S[0]),se instanceof Error)throw se;var ie=new Error("Unhandled error."+(se?" ("+se.message+")":""));throw ie.context=se,ie}var G=ne[P];if(G===void 0)return!1;if(typeof G=="function")f(G,this,S);else for(var E=G.length,T=c(G,E),V=0;V0&&se.length>M&&!se.warned){se.warned=!0;var ie=new Error("Possible EventEmitter memory leak detected. "+se.length+" "+String(P)+" listeners added. Use emitter.setMaxListeners() to increase limit");ie.name="MaxListenersExceededWarning",ie.emitter=I,ie.type=P,ie.count=se.length,h(ie)}return I}i.prototype.addListener=function(P,S){return o(this,P,S,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(P,S){return o(this,P,S,!0)};function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(I,P,S){var V={fired:!1,wrapFn:void 0,target:I,type:P,listener:S},M=l.bind(V);return M.listener=S,V.wrapFn=M,M}i.prototype.once=function(P,S){return e(S),this.on(P,p(this,P,S)),this},i.prototype.prependOnceListener=function(P,S){return e(S),this.prependListener(P,p(this,P,S)),this},i.prototype.removeListener=function(P,S){var V,M,ne,se,ie;if(e(S),M=this._events,M===void 0)return this;if(V=M[P],V===void 0)return this;if(V===S||V.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete M[P],M.removeListener&&this.emit("removeListener",P,V.listener||S));else if(typeof V!="function"){for(ne=-1,se=V.length-1;se>=0;se--)if(V[se]===S||V[se].listener===S){ie=V[se].listener,ne=se;break}if(ne<0)return this;ne===0?V.shift():v(V,ne),V.length===1&&(M[P]=V[0]),M.removeListener!==void 0&&this.emit("removeListener",P,ie||S)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(P){var S,V,M;if(V=this._events,V===void 0)return this;if(V.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):V[P]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete V[P]),this;if(arguments.length===0){var ne=Object.keys(V),se;for(M=0;M=0;M--)this.removeListener(P,S[M]);return this};function g(I,P,S){var V=I._events;if(V===void 0)return[];var M=V[P];return M===void 0?[]:typeof M=="function"?S?[M.listener||M]:[M]:S?R(M):c(M,M.length)}i.prototype.listeners=function(P){return g(this,P,!0)},i.prototype.rawListeners=function(P){return g(this,P,!1)},i.listenerCount=function(I,P){return typeof I.listenerCount=="function"?I.listenerCount(P):_.call(I,P)},i.prototype.listenerCount=_;function _(I){var P=this._events;if(P!==void 0){var S=P[I];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}i.prototype.eventNames=function(){return this._eventsCount>0?m(this._events):[]};function c(I,P){for(var S=new Array(P),V=0;V>1,l=-7,p=m?s-1:0,g=m?-1:1,_=d[f+p];for(p+=g,i=_&(1<<-l)-1,_>>=-l,l+=e;l>0;i=i*256+d[f+p],p+=g,l-=8);for(r=i&(1<<-l)-1,i>>=-l,l+=h;l>0;r=r*256+d[f+p],p+=g,l-=8);if(i===0)i=1-o;else{if(i===t)return r?NaN:(_?-1:1)*(1/0);r=r+Math.pow(2,h),i=i-o}return(_?-1:1)*r*Math.pow(2,i-h)},x.write=function(d,f,m,h,s,i){var r,e,t,o=i*8-s-1,l=(1<>1,g=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=h?0:i-1,c=h?1:-1,v=f<0||f===0&&1/f<0?1:0;for(f=Math.abs(f),isNaN(f)||f===1/0?(e=isNaN(f)?1:0,r=l):(r=Math.floor(Math.log(f)/Math.LN2),f*(t=Math.pow(2,-r))<1&&(r--,t*=2),r+p>=1?f+=g/t:f+=g*Math.pow(2,1-p),f*t>=2&&(r++,t/=2),r+p>=l?(e=0,r=l):r+p>=1?(e=(f*t-1)*Math.pow(2,s),r=r+p):(e=f*Math.pow(2,p-1)*Math.pow(2,s),r=0));s>=8;d[m+_]=e&255,_+=c,e/=256,s-=8);for(r=r<0;d[m+_]=r&255,_+=c,r/=256,o-=8);d[m+_-c]|=v*128}},{}],6:[function(y,k,x){(function(d,f){(function(){"use strict";let m=y("events").EventEmitter,h=y("./store"),s=y("./topic-alias-recv"),i=y("./topic-alias-send"),r=y("mqtt-packet"),e=y("./default-message-id-provider"),t=y("readable-stream").Writable,o=y("inherits"),l=y("reinterval"),p=y("rfdc/default"),g=y("./validations"),_=y("xtend"),c=y("debug")("mqttjs:client"),v=d?d.nextTick:function(E){setTimeout(E,0)},R=f.setImmediate||function(E){v(E)},A={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:30*1e3,clean:!0,resubscribe:!0},W=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],j={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 I(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function P(E,T){if(E.options.protocolVersion===5&&T.cmd==="publish"){let U;T.properties&&(U=T.properties.topicAlias);let q=T.topic.toString();if(E.topicAliasSend)if(U){if(q.length!==0&&(c("applyTopicAlias :: register topic: %s - alias: %d",q,U),!E.topicAliasSend.put(q,U)))return c("applyTopicAlias :: error out of range. topic: %s - alias: %d",q,U),new Error("Sending Topic Alias out of range")}else q.length!==0&&(E.options.autoAssignTopicAlias?(U=E.topicAliasSend.getAliasByTopic(q),U?(T.topic="",T.properties=Re(Te({},T.properties),{topicAlias:U}),c("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",q,U)):(U=E.topicAliasSend.getLruAlias(),E.topicAliasSend.put(q,U),T.properties=Re(Te({},T.properties),{topicAlias:U}),c("applyTopicAlias :: auto assign topic: %s - alias: %d",q,U))):E.options.autoUseTopicAlias&&(U=E.topicAliasSend.getAliasByTopic(q),U&&(T.topic="",T.properties=Re(Te({},T.properties),{topicAlias:U}),c("applyTopicAlias :: auto use topic: %s - alias: %d",q,U))));else if(U)return c("applyTopicAlias :: error out of range. topic: %s - alias: %d",q,U),new Error("Sending Topic Alias out of range")}}function S(E,T){let U;T.properties&&(U=T.properties.topicAlias);let q=T.topic.toString();if(q.length===0){if(typeof U>"u")return new Error("Unregistered Topic Alias");if(q=E.topicAliasSend.getTopicByAlias(U),typeof q>"u")return new Error("Unregistered Topic Alias");T.topic=q}U&&delete T.properties.topicAlias}function V(E,T,U){c("sendPacket :: packet: %O",T),c("sendPacket :: emitting `packetsend`"),E.emit("packetsend",T),c("sendPacket :: writing to stream");let q=r.writeToStream(T,E.stream,E.options);c("sendPacket :: writeToStream result %s",q),!q&&U&&U!==ie?(c("sendPacket :: handle events on `drain` once through callback."),E.stream.once("drain",U)):U&&(c("sendPacket :: invoking cb"),U())}function M(E){E&&(c("flush: queue exists? %b",!!E),Object.keys(E).forEach(function(T){typeof E[T].cb=="function"&&(E[T].cb(new Error("Connection closed")),delete E[T])}))}function ne(E){E&&(c("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(E).forEach(function(T){E[T].volatile&&typeof E[T].cb=="function"&&(E[T].cb(new Error("Connection closed")),delete E[T])}))}function se(E,T,U,q){c("storeAndSend :: store packet with cmd %s to outgoingStore",T.cmd);let re=T,ee;if(re.cmd==="publish"&&(re=p(T),ee=S(E,re),ee))return U&&U(ee);E.outgoingStore.put(re,function(D){if(D)return U&&U(D);q(),V(E,T,U)})}function ie(E){c("nop ::",E)}function G(E,T){let U,q=this;if(!(this instanceof G))return new G(E,T);this.options=T||{};for(U in A)typeof this.options[U]>"u"?this.options[U]=A[U]:this.options[U]=T[U];c("MqttClient :: options.protocol",T.protocol),c("MqttClient :: options.protocolVersion",T.protocolVersion),c("MqttClient :: options.username",T.username),c("MqttClient :: options.keepalive",T.keepalive),c("MqttClient :: options.reconnectPeriod",T.reconnectPeriod),c("MqttClient :: options.rejectUnauthorized",T.rejectUnauthorized),c("MqttClient :: options.topicAliasMaximum",T.topicAliasMaximum),this.options.clientId=typeof T.clientId=="string"?T.clientId:I(),c("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=T.protocolVersion===5&&T.customHandleAcks?T.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=E,this.messageIdProvider=typeof this.options.messageIdProvider>"u"?new e:this.options.messageIdProvider,this.outgoingStore=T.outgoingStore||new h,this.incomingStore=T.incomingStore||new h,this.queueQoSZero=T.queueQoSZero===void 0?!0:T.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,T.topicAliasMaximum>0&&(T.topicAliasMaximum>65535?c("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new s(T.topicAliasMaximum)),this.on("connect",function(){let re=this.queue;function ee(){let H=re.shift();c("deliver :: entry %o",H);let D=null;if(!H){q._resubscribe();return}D=H.packet,c("deliver :: call _sendPacket for %o",D);let X=!0;D.messageId&&D.messageId!==0&&(q.messageIdProvider.register(D.messageId)||(X=!1)),X?q._sendPacket(D,function($){H.cb&&H.cb($),ee()}):(c("messageId: %d has already used. The message is skipped and removed.",D.messageId),ee())}c("connect :: sending queued packets"),ee()}),this.on("close",function(){c("close :: connected set to `false`"),this.connected=!1,c("close :: clearing connackTimer"),clearTimeout(this.connackTimer),c("close :: clearing ping timer"),q.pingTimer!==null&&(q.pingTimer.clear(),q.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),c("close :: calling _setupReconnect"),this._setupReconnect()}),m.call(this),c("MqttClient :: setting up stream"),this._setupStream()}o(G,m),G.prototype._setupStream=function(){let E=this,T=new t,U=r.parser(this.options),q=null,re=[];c("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),c("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),U.on("packet",function($){c("parser :: on packet push to packets array."),re.push($)});function ee(){if(re.length)v(H);else{let $=q;q=null,$()}}function H(){c("work :: getting next packet in queue");let $=re.shift();if($)c("work :: packet pulled from queue"),E._handlePacket($,ee);else{c("work :: no packets in queue");let oe=q;q=null,c("work :: done flag is %s",!!oe),oe&&oe()}}T._write=function($,oe,Z){q=Z,c("writable stream :: parsing buffer"),U.parse($),H()};function D($){c("streamErrorHandler :: error",$.message),W.includes($.code)?(c("streamErrorHandler :: emitting error"),E.emit("error",$)):ie($)}c("_setupStream :: pipe stream to writable stream"),this.stream.pipe(T),this.stream.on("error",D),this.stream.on("close",function(){c("(%s)stream :: on close",E.options.clientId),ne(E.outgoing),c("stream: emit close to MqttClient"),E.emit("close")}),c("_setupStream: sending packet `connect`");let X=Object.create(this.options);if(X.cmd="connect",this.topicAliasRecv&&(X.properties||(X.properties={}),this.topicAliasRecv&&(X.properties.topicAliasMaximum=this.topicAliasRecv.max)),V(this,X),U.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;if(this.options.properties.authenticationMethod&&this.options.authPacket&&typeof this.options.authPacket=="object"){let $=_({cmd:"auth",reasonCode:0},this.options.authPacket);V(this,$)}}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){c("!!connectTimeout hit!! Calling _cleanUp with force `true`"),E._cleanUp(!0)},this.options.connectTimeout)},G.prototype._handlePacket=function(E,T){let U=this.options;if(U.protocolVersion===5&&U.properties&&U.properties.maximumPacketSize&&U.properties.maximumPacketSize0||!D())&&this._storeProcessingQueue.push({invoke:D,cbStorePut:U.cbStorePut,callback:q}),this},G.prototype.subscribe=function(){let E=this,T=new Array(arguments.length);for(let Z=0;Z0){let te={qos:Y.qos};D===5&&(te.nl=Y.nl||!1,te.rap=Y.rap||!1,te.rh=Y.rh||0,te.properties=Y.properties),E._resubscribeTopics[Y.topic]=te,B.push(Y.topic)}}),E.messageIdToTopic[F.messageId]=B}return E.outgoing[F.messageId]={volatile:!0,cb:function(B,Y){if(!B){let te=Y.granted;for(let O=0;O0||!oe())&&this._storeProcessingQueue.push({invoke:oe,callback:ee}),this},G.prototype.unsubscribe=function(){let E=this,T=new Array(arguments.length);for(let D=0;D0||!H())&&this._storeProcessingQueue.push({invoke:H,callback:q}),this},G.prototype.end=function(E,T,U){let q=this;c("end :: (%s)",this.options.clientId),(E==null||typeof E!="boolean")&&(U=T||ie,T=E,E=!1,typeof T!="object"&&(U=T,T=null,typeof U!="function"&&(U=ie))),typeof T!="object"&&(U=T,T=null),c("end :: cb? %s",!!U),U=U||ie;function re(){c("end :: closeStores: closing incoming and outgoing stores"),q.disconnected=!0,q.incomingStore.close(function(H){q.outgoingStore.close(function(D){if(c("end :: closeStores: emitting end"),q.emit("end"),U){let X=H||D;c("end :: closeStores: invoking callback with args"),U(X)}})}),q._deferredReconnect&&q._deferredReconnect()}function ee(){c("end :: (%s) :: finish :: calling _cleanUp with force %s",q.options.clientId,E),q._cleanUp(E,()=>{c("end :: finish :: calling process.nextTick on closeStores"),v(re.bind(q))},T)}return this.disconnecting?(U(),this):(this._clearReconnect(),this.disconnecting=!0,!E&&Object.keys(this.outgoing).length>0?(c("end :: (%s) :: calling finish in 10ms once outgoing is empty",q.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,ee,10))):(c("end :: (%s) :: immediately calling finish",q.options.clientId),ee()),this)},G.prototype.removeOutgoingMessage=function(E){let 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},G.prototype.reconnect=function(E){c("client reconnect");let T=this,U=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 h,T.outgoingStore=T.options.outgoingStore||new h,T.disconnecting=!1,T.disconnected=!1,T._deferredReconnect=null,T._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=U:U(),this},G.prototype._reconnect=function(){c("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),c("client already connected. disconnecting first.")):(c("_reconnect: calling _setupStream"),this._setupStream())},G.prototype._setupReconnect=function(){let E=this;!E.disconnecting&&!E.reconnectTimer&&E.options.reconnectPeriod>0?(this.reconnecting||(c("_setupReconnect :: emit `offline` state"),this.emit("offline"),c("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),c("_setupReconnect :: setting reconnectTimer for %d ms",E.options.reconnectPeriod),E.reconnectTimer=setInterval(function(){c("reconnectTimer :: reconnect triggered!"),E._reconnect()},E.options.reconnectPeriod)):c("_setupReconnect :: doing nothing...")},G.prototype._clearReconnect=function(){c("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},G.prototype._cleanUp=function(E,T){let U=arguments[2];if(T&&(c("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",T)),c("_cleanUp :: forced? %s",E),E)this.options.reconnectPeriod===0&&this.options.clean&&M(this.outgoing),c("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{let q=_({cmd:"disconnect"},U);c("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(q,R.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(c("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),this.pingTimer!==null&&(c("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),T&&!this.connected&&(c("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",T),T())},G.prototype._sendPacket=function(E,T,U){c("_sendPacket :: (%s) :: start",this.options.clientId),U=U||ie,T=T||ie;let q=P(this,E);if(q){T(q);return}if(!this.connected){if(E.cmd==="auth"){this._shiftPingInterval(),V(this,E,T);return}c("_sendPacket :: client not connected. Storing packet offline."),this._storePacket(E,T,U);return}switch(this._shiftPingInterval(),E.cmd){case"publish":break;case"pubrel":se(this,E,T,U);return;default:V(this,E,T);return}switch(E.qos){case 2:case 1:se(this,E,T,U);break;case 0:default:V(this,E,T);break}c("_sendPacket :: (%s) :: end",this.options.clientId)},G.prototype._storePacket=function(E,T,U){c("_storePacket :: packet: %o",E),c("_storePacket :: cb? %s",!!T),U=U||ie;let q=E;if(q.cmd==="publish"){q=p(E);let re=S(this,q);if(re)return T&&T(re)}(q.qos||0)===0&&this.queueQoSZero||q.cmd!=="publish"?this.queue.push({packet:q,cb:T}):q.qos>0?(T=this.outgoing[q.messageId]?this.outgoing[q.messageId].cb:null,this.outgoingStore.put(q,function(re){if(re)return T&&T(re);U()})):T&&T(new Error("No connection to broker"))},G.prototype._setupPingTimer=function(){c("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);let E=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=l(function(){E._checkPing()},this.options.keepalive*1e3))},G.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(this.options.keepalive*1e3)},G.prototype._checkPing=function(){c("_checkPing :: checking ping..."),this.pingResp?(c("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(c("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},G.prototype._handlePingresp=function(){this.pingResp=!0},G.prototype._handleConnack=function(E){c("_handleConnack");let T=this.options,q=T.protocolVersion===5?E.reasonCode:E.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,E.properties){if(E.properties.topicAliasMaximum){if(E.properties.topicAliasMaximum>65535){this.emit("error",new Error("topicAliasMaximum from broker is out of range"));return}E.properties.topicAliasMaximum>0&&(this.topicAliasSend=new i(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(q===0)this.reconnecting=!1,this._onConnect(E);else if(q>0){let re=new Error("Connection refused: "+j[q]);re.code=q,this.emit("error",re)}},G.prototype._handleAuth=function(E){let U=this.options.protocolVersion,q=U===5?E.reasonCode:E.returnCode;if(U!==5){let ee=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+U);ee.code=q,this.emit("error",ee);return}let re=this;this.handleAuth(E,function(ee,H){if(ee){re.emit("error",ee);return}if(q===24)re.reconnecting=!1,re._sendPacket(H);else{let D=new Error("Connection refused: "+j[q]);ee.code=q,re.emit("error",D)}})},G.prototype.handleAuth=function(E,T){T()},G.prototype._handlePublish=function(E,T){c("_handlePublish: packet %o",E),T=typeof T<"u"?T:ie;let U=E.topic.toString(),q=E.payload,re=E.qos,ee=E.messageId,H=this,D=this.options,X=[0,16,128,131,135,144,145,151,153];if(this.options.protocolVersion===5){let $;if(E.properties&&($=E.properties.topicAlias),typeof $<"u")if(U.length===0)if($>0&&$<=65535){let oe=this.topicAliasRecv.getTopicByAlias($);if(oe)U=oe,c("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",U,$);else{c("_handlePublish :: unregistered topic alias. alias: %d",$),this.emit("error",new Error("Received unregistered Topic Alias"));return}}else{c("_handlePublish :: topic alias out of range. alias: %d",$),this.emit("error",new Error("Received Topic Alias is out of range"));return}else if(this.topicAliasRecv.put(U,$))c("_handlePublish :: registered topic: %s - alias: %d",U,$);else{c("_handlePublish :: topic alias out of range. alias: %d",$),this.emit("error",new Error("Received Topic Alias is out of range"));return}}switch(c("_handlePublish: qos %d",re),re){case 2:{D.customHandleAcks(U,q,E,function($,oe){if($ instanceof Error||(oe=$,$=null),$)return H.emit("error",$);if(X.indexOf(oe)===-1)return H.emit("error",new Error("Wrong reason code for pubrec"));oe?H._sendPacket({cmd:"pubrec",messageId:ee,reasonCode:oe},T):H.incomingStore.put(E,function(){H._sendPacket({cmd:"pubrec",messageId:ee},T)})});break}case 1:{D.customHandleAcks(U,q,E,function($,oe){if($ instanceof Error||(oe=$,$=null),$)return H.emit("error",$);if(X.indexOf(oe)===-1)return H.emit("error",new Error("Wrong reason code for puback"));oe||H.emit("message",U,q,E),H.handleMessage(E,function(Z){if(Z)return T&&T(Z);H._sendPacket({cmd:"puback",messageId:ee,reasonCode:oe},T)})});break}case 0:this.emit("message",U,q,E),this.handleMessage(E,T);break;default:c("_handlePublish: unknown QoS. Doing nothing.");break}},G.prototype.handleMessage=function(E,T){T()},G.prototype._handleAck=function(E){let T=E.messageId,U=E.cmd,q=null,re=this.outgoing[T]?this.outgoing[T].cb:null,ee=this,H;if(!re){c("_handleAck :: Server sent an ack in error. Ignoring.");return}switch(c("_handleAck :: packet type",U),U){case"pubcomp":case"puback":{let D=E.reasonCode;D&&D>0&&D!==16&&(H=new Error("Publish error: "+j[D]),H.code=D,re(H,E)),delete this.outgoing[T],this.outgoingStore.del(E,re),this.messageIdProvider.deallocate(T),this._invokeStoreProcessingQueue();break}case"pubrec":{q={cmd:"pubrel",qos:2,messageId:T};let D=E.reasonCode;D&&D>0&&D!==16?(H=new Error("Publish error: "+j[D]),H.code=D,re(H,E)):this._sendPacket(q);break}case"suback":{delete this.outgoing[T],this.messageIdProvider.deallocate(T);for(let D=0;D0)if(this.options.resubscribe)if(this.options.protocolVersion===5){c("_resubscribe: protocolVersion 5");for(let T=0;T0){let E=this._storeProcessingQueue[0];if(E&&E.invoke())return this._storeProcessingQueue.shift(),!0}return!1},G.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},G.prototype._flushStoreProcessingQueue=function(){for(let E of this._storeProcessingQueue)E.cbStorePut&&E.cbStorePut(new Error("Connection closed")),E.callback&&E.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},k.exports=G}).call(this)}).call(this,y("_process"),typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{"./default-message-id-provider":12,"./store":13,"./topic-alias-recv":14,"./topic-alias-send":15,"./validations":16,_process:85,debug:20,events:4,inherits:24,"mqtt-packet":48,"readable-stream":72,reinterval:73,"rfdc/default":74,xtend:82}],7:[function(y,k,x){"use strict";let{Buffer:d}=y("buffer"),f=y("readable-stream").Transform,m=y("duplexify"),h,s,i,r=!1;function e(){let g=new f;return g._write=function(_,c,v){h.sendSocketMessage({data:_.buffer,success:function(){v()},fail:function(){v(new Error)}})},g._flush=function(c){h.closeSocket({success:function(){c()}})},g}function t(g){g.hostname||(g.hostname="localhost"),g.path||(g.path="/"),g.wsOptions||(g.wsOptions={})}function o(g,_){let c=g.protocol==="alis"?"wss":"ws",v=c+"://"+g.hostname+g.path;return g.port&&g.port!==80&&g.port!==443&&(v=c+"://"+g.hostname+":"+g.port+g.path),typeof g.transformWsUrl=="function"&&(v=g.transformWsUrl(v,g,_)),v}function l(){r||(r=!0,h.onSocketOpen(function(){i.setReadable(s),i.setWritable(s),i.emit("connect")}),h.onSocketMessage(function(g){if(typeof g.data=="string"){let _=d.from(g.data,"base64");s.push(_)}else{let _=new FileReader;_.addEventListener("load",function(){let c=_.result;c instanceof ArrayBuffer?c=d.from(c):c=d.from(c,"utf8"),s.push(c)}),_.readAsArrayBuffer(g.data)}}),h.onSocketClose(function(){i.end(),i.destroy()}),h.onSocketError(function(g){i.destroy(g)}))}function p(g,_){if(_.hostname=_.hostname||_.host,!_.hostname)throw new Error("Could not determine host. Specify host manually.");let c=_.protocolId==="MQIsdp"&&_.protocolVersion===3?"mqttv3.1":"mqtt";t(_);let v=o(_,g);return h=_.my,h.connectSocket({url:v,protocols:c}),s=e(),i=m.obj(),l(),i}k.exports=p},{buffer:3,duplexify:22,"readable-stream":72}],8:[function(y,k,x){"use strict";let d=y("net"),f=y("debug")("mqttjs:tcp");function m(h,s){s.port=s.port||1883,s.hostname=s.hostname||s.host||"localhost";let i=s.port,r=s.hostname;return f("port %d and host %s",i,r),d.createConnection(i,r)}k.exports=m},{debug:20,net:2}],9:[function(y,k,x){"use strict";let d=y("tls"),f=y("net"),m=y("debug")("mqttjs:tls");function h(s,i){i.port=i.port||8883,i.host=i.hostname||i.host||"localhost",f.isIP(i.host)===0&&(i.servername=i.host),i.rejectUnauthorized=i.rejectUnauthorized!==!1,delete i.path,m("port %d host %s rejectUnauthorized %b",i.port,i.host,i.rejectUnauthorized);let r=d.connect(i);r.on("secureConnect",function(){i.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",e)});function e(t){i.rejectUnauthorized&&s.emit("error",t),r.end()}return r.on("error",e),r}k.exports=h},{debug:20,net:2,tls:2}],10:[function(y,k,x){(function(d){(function(){"use strict";let{Buffer:f}=y("buffer"),m=y("ws"),h=y("debug")("mqttjs:ws"),s=y("duplexify"),i=y("readable-stream").Transform,r=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],e=typeof d<"u"&&d.title==="browser"||typeof __webpack_require__=="function";function t(v,R){let A=v.protocol+"://"+v.hostname+":"+v.port+v.path;return typeof v.transformWsUrl=="function"&&(A=v.transformWsUrl(A,v,R)),A}function o(v){let R=v;return v.hostname||(R.hostname="localhost"),v.port||(v.protocol==="wss"?R.port=443:R.port=80),v.path||(R.path="/"),v.wsOptions||(R.wsOptions={}),!e&&v.protocol==="wss"&&r.forEach(function(A){Object.prototype.hasOwnProperty.call(v,A)&&!Object.prototype.hasOwnProperty.call(v.wsOptions,A)&&(R.wsOptions[A]=v[A])}),R}function l(v){let R=o(v);if(R.hostname||(R.hostname=R.host),!R.hostname){if(typeof document>"u")throw new Error("Could not determine host. Specify host manually.");let A=new URL(document.URL);R.hostname=A.hostname,R.port||(R.port=A.port)}return R.objectMode===void 0&&(R.objectMode=!(R.binary===!0||R.binary===void 0)),R}function p(v,R,A){h("createWebSocket"),h("protocol: "+A.protocolId+" "+A.protocolVersion);let W=A.protocolId==="MQIsdp"&&A.protocolVersion===3?"mqttv3.1":"mqtt";return h("creating new Websocket for url: "+R+" and protocol: "+W),new m(R,[W],A.wsOptions)}function g(v,R){let A=R.protocolId==="MQIsdp"&&R.protocolVersion===3?"mqttv3.1":"mqtt",W=t(R,v),j=new WebSocket(W,[A]);return j.binaryType="arraybuffer",j}function _(v,R){h("streamBuilder");let A=o(R),W=t(A,v),j=p(v,W,A),I=m.createWebSocketStream(j,A.wsOptions);return I.url=W,j.on("close",()=>{I.destroy()}),I}function c(v,R){h("browserStreamBuilder");let A,j=l(R).browserBufferSize||1024*512,I=R.browserBufferTimeout||1e3,P=!R.objectMode,S=g(v,R),V=ne(R,U,q);R.objectMode||(V._writev=T),V.on("close",()=>{S.close()});let M=typeof S.addEventListener<"u";S.readyState===S.OPEN?A=V:(A=A=s(void 0,void 0,R),R.objectMode||(A._writev=T),M?S.addEventListener("open",se):S.onopen=se),A.socket=S,M?(S.addEventListener("close",ie),S.addEventListener("error",G),S.addEventListener("message",E)):(S.onclose=ie,S.onerror=G,S.onmessage=E);function ne(re,ee,H){let D=new i({objectModeMode:re.objectMode});return D._write=ee,D._flush=H,D}function se(){A.setReadable(V),A.setWritable(V),A.emit("connect")}function ie(){A.end(),A.destroy()}function G(re){A.destroy(re)}function E(re){let ee=re.data;ee instanceof ArrayBuffer?ee=f.from(ee):ee=f.from(ee,"utf8"),V.push(ee)}function T(re,ee){let H=new Array(re.length);for(let D=0;Dj&&setTimeout(U,I,re,ee,H),P&&typeof re=="string"&&(re=f.from(re,"utf8"));try{S.send(re)}catch(D){return H(D)}H()}function q(re){S.close(),re()}return A}e?k.exports=c:k.exports=_}).call(this)}).call(this,y("_process"))},{_process:85,buffer:3,debug:20,duplexify:22,"readable-stream":72,ws:81}],11:[function(y,k,x){"use strict";let{Buffer:d}=y("buffer"),f=y("readable-stream").Transform,m=y("duplexify"),h,s,i;function r(){let p=new f;return p._write=function(g,_,c){h.send({data:g.buffer,success:function(){c()},fail:function(v){c(new Error(v))}})},p._flush=function(_){h.close({success:function(){_()}})},p}function e(p){p.hostname||(p.hostname="localhost"),p.path||(p.path="/"),p.wsOptions||(p.wsOptions={})}function t(p,g){let _=p.protocol==="wxs"?"wss":"ws",c=_+"://"+p.hostname+p.path;return p.port&&p.port!==80&&p.port!==443&&(c=_+"://"+p.hostname+":"+p.port+p.path),typeof p.transformWsUrl=="function"&&(c=p.transformWsUrl(c,p,g)),c}function o(){h.onOpen(function(){i.setReadable(s),i.setWritable(s),i.emit("connect")}),h.onMessage(function(p){let g=p.data;g instanceof ArrayBuffer?g=d.from(g):g=d.from(g,"utf8"),s.push(g)}),h.onClose(function(){i.end(),i.destroy()}),h.onError(function(p){i.destroy(new Error(p.errMsg))})}function l(p,g){if(g.hostname=g.hostname||g.host,!g.hostname)throw new Error("Could not determine host. Specify host manually.");let _=g.protocolId==="MQIsdp"&&g.protocolVersion===3?"mqttv3.1":"mqtt";e(g);let c=t(g,p);h=wx.connectSocket({url:c,protocols:[_]}),s=r(),i=m.obj(),i._destroy=function(R,A){h.close({success:function(){A&&A(R)}})};let v=i.destroy;return i.destroy=(function(){i.destroy=v;let R=this;setTimeout(function(){h.close({fail:function(){R._destroy(new Error)}})},0)}).bind(i),o(),i}k.exports=l},{buffer:3,duplexify:22,"readable-stream":72}],12:[function(y,k,x){"use strict";function d(){if(!(this instanceof d))return new d;this.nextId=Math.max(1,Math.floor(Math.random()*65535))}d.prototype.allocate=function(){let f=this.nextId++;return this.nextId===65536&&(this.nextId=1),f},d.prototype.getLastAllocated=function(){return this.nextId===1?65535:this.nextId-1},d.prototype.register=function(f){return!0},d.prototype.deallocate=function(f){},d.prototype.clear=function(){},k.exports=d},{}],13:[function(y,k,x){"use strict";let d=y("xtend"),f=y("readable-stream").Readable,m={objectMode:!0},h={clean:!0};function s(i){if(!(this instanceof s))return new s(i);this.options=i||{},this.options=d(h,i),this._inflights=new Map}s.prototype.put=function(i,r){return this._inflights.set(i.messageId,i),r&&r(),this},s.prototype.createStream=function(){let i=new f(m),r=[],e=!1,t=0;return this._inflights.forEach(function(o,l){r.push(o)}),i._read=function(){!e&&tthis.max?!1:(this.aliasToTopic[m]=f,this.length=Object.keys(this.aliasToTopic).length,!0)},d.prototype.getTopicByAlias=function(f){return this.aliasToTopic[f]},d.prototype.clear=function(){this.aliasToTopic={}},k.exports=d},{}],15:[function(y,k,x){"use strict";let d=y("lru-cache"),f=y("number-allocator").NumberAllocator;function m(h){if(!(this instanceof m))return new m(h);h>0&&(this.aliasToTopic=new d({max:h}),this.topicToAlias={},this.numberAllocator=new f(1,h),this.max=h,this.length=0)}m.prototype.put=function(h,s){if(s===0||s>this.max)return!1;let i=this.aliasToTopic.get(s);return i&&delete this.topicToAlias[i],this.aliasToTopic.set(s,h),this.topicToAlias[h]=s,this.numberAllocator.use(s),this.length=this.aliasToTopic.length,!0},m.prototype.getTopicByAlias=function(h){return this.aliasToTopic.get(h)},m.prototype.getAliasByTopic=function(h){let s=this.topicToAlias[h];return typeof s<"u"&&this.aliasToTopic.get(s),s},m.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},m.prototype.getLruAlias=function(){let h=this.numberAllocator.firstVacant();return h||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},k.exports=m},{"lru-cache":45,"number-allocator":54}],16:[function(y,k,x){"use strict";function d(m){let h=m.split("/");for(let s=0;sthis.length||s<0)return;let i=this._offset(s);return this._bufs[i[0]][i[1]]},m.prototype.slice=function(s,i){return typeof s=="number"&&s<0&&(s+=this.length),typeof i=="number"&&i<0&&(i+=this.length),this.copy(null,0,s,i)},m.prototype.copy=function(s,i,r,e){if((typeof r!="number"||r<0)&&(r=0),(typeof e!="number"||e>this.length)&&(e=this.length),r>=this.length||e<=0)return s||d.alloc(0);let t=!!s,o=this._offset(r),l=e-r,p=l,g=t&&i||0,_=o[1];if(r===0&&e===this.length){if(!t)return this._bufs.length===1?this._bufs[0]:d.concat(this._bufs,this.length);for(let c=0;cv)this._bufs[c].copy(s,g,_),g+=v;else{this._bufs[c].copy(s,g,_,_+p),g+=v;break}p-=v,_&&(_=0)}return s.length>g?s.slice(0,g):s},m.prototype.shallowSlice=function(s,i){if(s=s||0,i=typeof i!="number"?this.length:i,s<0&&(s+=this.length),i<0&&(i+=this.length),s===i)return this._new();let r=this._offset(s),e=this._offset(i),t=this._bufs.slice(r[0],e[0]+1);return e[1]===0?t.pop():t[t.length-1]=t[t.length-1].slice(0,e[1]),r[1]!==0&&(t[0]=t[0].slice(r[1])),this._new(t)},m.prototype.toString=function(s,i,r){return this.slice(i,r).toString(s)},m.prototype.consume=function(s){if(s=Math.trunc(s),Number.isNaN(s)||s<=0)return this;for(;this._bufs.length;)if(s>=this._bufs[0].length)s-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();else{this._bufs[0]=this._bufs[0].slice(s),this.length-=s;break}return this},m.prototype.duplicate=function(){let s=this._new();for(let i=0;ithis.length?this.length:s;let r=this._offset(s),e=r[0],t=r[1];for(;e=h.length){let p=o.indexOf(h,t);if(p!==-1)return this._reverseOffset([e,p]);t=o.length-h.length+1}else{let p=this._reverseOffset([e,t]);if(this._match(p,h))return p;t++}t=0}return-1},m.prototype._match=function(h,s){if(this.length-h{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),x.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"];function f(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function m(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+k.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let o=0,l=0;e[0].replace(/%[a-zA-Z%]/g,p=>{p!=="%%"&&(o++,p==="%c"&&(l=o))}),e.splice(l,0,t)}x.log=console.debug||console.log||(()=>{});function h(e){try{e?x.storage.setItem("debug",e):x.storage.removeItem("debug")}catch{}}function s(){let e;try{e=x.storage.getItem("debug")}catch{}return!e&&typeof d<"u"&&"env"in d&&(e=d.env.DEBUG),e}function i(){try{return localStorage}catch{}}k.exports=y("./common")(x);let{formatters:r}=k.exports;r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}).call(this)}).call(this,y("_process"))},{"./common":21,_process:85}],21:[function(y,k,x){function d(f){h.debug=h,h.default=h,h.coerce=o,h.disable=r,h.enable=i,h.enabled=e,h.humanize=y("ms"),h.destroy=l,Object.keys(f).forEach(p=>{h[p]=f[p]}),h.names=[],h.skips=[],h.formatters={};function m(p){let g=0;for(let _=0;_{if(V==="%%")return"%";P++;let ne=h.formatters[M];if(typeof ne=="function"){let se=A[P];V=ne.call(W,se),A.splice(P,1),P--}return V}),h.formatArgs.call(W,A),(W.log||h.log).apply(W,A)}return R.namespace=p,R.useColors=h.useColors(),R.color=h.selectColor(p),R.extend=s,R.destroy=h.destroy,Object.defineProperty(R,"enabled",{enumerable:!0,configurable:!1,get:()=>_!==null?_:(c!==h.namespaces&&(c=h.namespaces,v=h.enabled(p)),v),set:A=>{_=A}}),typeof h.init=="function"&&h.init(R),R}function s(p,g){let _=h(this.namespace+(typeof g>"u"?":":g)+p);return _.log=this.log,_}function i(p){h.save(p),h.namespaces=p,h.names=[],h.skips=[];let g,_=(typeof p=="string"?p:"").split(/[\s,]+/),c=_.length;for(g=0;g"-"+g)].join(",");return h.enable(""),p}function e(p){if(p[p.length-1]==="*")return!0;let g,_;for(g=0,_=h.skips.length;g<_;g++)if(h.skips[g].test(p))return!1;for(g=0,_=h.names.length;g<_;g++)if(h.names[g].test(p))return!0;return!1}function t(p){return p.toString().substring(2,p.toString().length-2).replace(/\.\*\?$/,"*")}function o(p){return p instanceof Error?p.stack||p.message:p}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return h.enable(h.load()),h}k.exports=d},{ms:53}],22:[function(y,k,x){(function(d,f){(function(){var m=y("readable-stream"),h=y("end-of-stream"),s=y("inherits"),i=y("stream-shift"),r=f.from&&f.from!==Uint8Array.from?f.from([0]):new f([0]),e=function(c,v){c._corked?c.once("uncork",v):v()},t=function(c,v){c._autoDestroy&&c.destroy(v)},o=function(c,v){return function(R){R?t(c,R.message==="premature close"?null:R):v&&!c._ended&&c.end()}},l=function(c,v){if(!c||c._writableState&&c._writableState.finished)return v();if(c._writableState)return c.end(v);c.end(),v()},p=function(){},g=function(c){return new m.Readable({objectMode:!0,highWaterMark:16}).wrap(c)},_=function(c,v,R){if(!(this instanceof _))return new _(c,v,R);m.Duplex.call(this,R),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!R||R.autoDestroy!==!1,this._forwardDestroy=!R||R.destroy!==!1,this._forwardEnd=!R||R.end!==!1,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,c&&this.setWritable(c),v&&this.setReadable(v)};s(_,m.Duplex),_.obj=function(c,v,R){return R||(R={}),R.objectMode=!0,R.highWaterMark=16,new _(c,v,R)},_.prototype.cork=function(){++this._corked===1&&this.emit("cork")},_.prototype.uncork=function(){this._corked&&--this._corked===0&&this.emit("uncork")},_.prototype.setWritable=function(c){if(this._unwrite&&this._unwrite(),this.destroyed){c&&c.destroy&&c.destroy();return}if(c===null||c===!1){this.end();return}var v=this,R=h(c,{writable:!0,readable:!1},o(this,this._forwardEnd)),A=function(){var j=v._ondrain;v._ondrain=null,j&&j()},W=function(){v._writable.removeListener("drain",A),R()};this._unwrite&&d.nextTick(A),this._writable=c,this._writable.on("drain",A),this._unwrite=W,this.uncork()},_.prototype.setReadable=function(c){if(this._unread&&this._unread(),this.destroyed){c&&c.destroy&&c.destroy();return}if(c===null||c===!1){this.push(null),this.resume();return}var v=this,R=h(c,{writable:!1,readable:!0},o(this)),A=function(){v._forward()},W=function(){v.push(null)},j=function(){v._readable2.removeListener("readable",A),v._readable2.removeListener("end",W),R()};this._drained=!0,this._readable=c,this._readable2=c._readableState?c:g(c),this._readable2.on("readable",A),this._readable2.on("end",W),this._unread=j,this._forward()},_.prototype._read=function(){this._drained=!0,this._forward()},_.prototype._forward=function(){if(!(this._forwarding||!this._readable2||!this._drained)){this._forwarding=!0;for(var c;this._drained&&(c=i(this._readable2))!==null;)this.destroyed||(this._drained=this.push(c));this._forwarding=!1}},_.prototype.destroy=function(c,v){if(v||(v=p),this.destroyed)return v(null);this.destroyed=!0;var R=this;d.nextTick(function(){R._destroy(c),v(null)})},_.prototype._destroy=function(c){if(c){var v=this._ondrain;this._ondrain=null,v?v(c):this.emit("error",c)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},_.prototype._write=function(c,v,R){if(!this.destroyed){if(this._corked)return e(this,this._write.bind(this,c,v,R));if(c===r)return this._finish(R);if(!this._writable)return R();this._writable.write(c)===!1?this._ondrain=R:this.destroyed||R()}},_.prototype._finish=function(c){var v=this;this.emit("preend"),e(this,function(){l(v._forwardEnd&&v._writable,function(){v._writableState.prefinished===!1&&(v._writableState.prefinished=!0),v.emit("prefinish"),e(v,c)})})},_.prototype.end=function(c,v,R){return typeof c=="function"?this.end(null,null,c):typeof v=="function"?this.end(c,null,v):(this._ended=!0,c&&this.write(c),!this._writableState.ending&&!this._writableState.destroyed&&this.write(r),m.Writable.prototype.end.call(this,R))},k.exports=_}).call(this)}).call(this,y("_process"),y("buffer").Buffer)},{_process:85,buffer:3,"end-of-stream":23,inherits:24,"readable-stream":72,"stream-shift":77}],23:[function(y,k,x){(function(d){(function(){var f=y("once"),m=function(){},h=function(r){return r.setHeader&&typeof r.abort=="function"},s=function(r){return r.stdio&&Array.isArray(r.stdio)&&r.stdio.length===3},i=function(r,e,t){if(typeof e=="function")return i(r,null,e);e||(e={}),t=f(t||m);var o=r._writableState,l=r._readableState,p=e.readable||e.readable!==!1&&r.readable,g=e.writable||e.writable!==!1&&r.writable,_=!1,c=function(){r.writable||v()},v=function(){g=!1,p||t.call(r)},R=function(){p=!1,g||t.call(r)},A=function(S){t.call(r,S?new Error("exited with error code: "+S):null)},W=function(S){t.call(r,S)},j=function(){d.nextTick(I)},I=function(){if(!_){if(p&&!(l&&l.ended&&!l.destroyed))return t.call(r,new Error("premature close"));if(g&&!(o&&o.ended&&!o.destroyed))return t.call(r,new Error("premature close"))}},P=function(){r.req.on("finish",v)};return h(r)?(r.on("complete",v),r.on("abort",j),r.req?P():r.on("request",P)):g&&!o&&(r.on("end",c),r.on("close",c)),s(r)&&r.on("exit",A),r.on("end",R),r.on("finish",v),e.error!==!1&&r.on("error",W),r.on("close",j),function(){_=!0,r.removeListener("complete",v),r.removeListener("abort",j),r.removeListener("request",P),r.req&&r.req.removeListener("finish",v),r.removeListener("end",c),r.removeListener("close",c),r.removeListener("finish",v),r.removeListener("exit",A),r.removeListener("end",R),r.removeListener("error",W),r.removeListener("close",j)}};k.exports=i}).call(this)}).call(this,y("_process"))},{_process:85,once:56}],24:[function(y,k,x){typeof Object.create=="function"?k.exports=function(f,m){m&&(f.super_=m,f.prototype=Object.create(m.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}))}:k.exports=function(f,m){if(m){f.super_=m;var h=function(){};h.prototype=m.prototype,f.prototype=new h,f.prototype.constructor=f}}},{}],25:[function(y,k,x){"use strict";Object.defineProperty(x,"t",{value:!0}),x.ContainerIterator=x.Container=x.Base=void 0;class d{constructor(s=0){this.iteratorType=s}equals(s){return this.o===s.o}}x.ContainerIterator=d;class f{constructor(){this.i=0}get length(){return this.i}size(){return this.i}empty(){return this.i===0}}x.Base=f;class m extends f{}x.Container=m},{}],26:[function(y,k,x){"use strict";Object.defineProperty(x,"t",{value:!0}),x.HashContainerIterator=x.HashContainer=void 0;var d=y("../../ContainerBase"),f=h(y("../../../utils/checkObject")),m=y("../../../utils/throwError");function h(r){return r&&r.t?r:{default:r}}class s extends d.ContainerIterator{constructor(e,t,o){super(o),this.o=e,this.h=t,this.iteratorType===0?(this.pre=function(){return this.o.L===this.h&&(0,m.throwIteratorAccessError)(),this.o=this.o.L,this},this.next=function(){return this.o===this.h&&(0,m.throwIteratorAccessError)(),this.o=this.o.B,this}):(this.pre=function(){return this.o.B===this.h&&(0,m.throwIteratorAccessError)(),this.o=this.o.B,this},this.next=function(){return this.o===this.h&&(0,m.throwIteratorAccessError)(),this.o=this.o.L,this})}}x.HashContainerIterator=s;class i extends d.Container{constructor(){super(),this.H=[],this.g={},this.HASH_TAG=Symbol("@@HASH_TAG"),Object.setPrototypeOf(this.g,null),this.h={},this.h.L=this.h.B=this.p=this._=this.h}V(e){let{L:t,B:o}=e;t.B=o,o.L=t,e===this.p&&(this.p=o),e===this._&&(this._=t),this.i-=1}M(e,t,o){o===void 0&&(o=(0,f.default)(e));let l;if(o){let p=e[this.HASH_TAG];if(p!==void 0)return this.H[p].l=t,this.i;Object.defineProperty(e,this.HASH_TAG,{value:this.H.length,configurable:!0}),l={u:e,l:t,L:this._,B:this.h},this.H.push(l)}else{let p=this.g[e];if(p)return p.l=t,this.i;l={u:e,l:t,L:this._,B:this.h},this.g[e]=l}return this.i===0?(this.p=l,this.h.B=l):this._.B=l,this._=l,this.h.L=l,++this.i}I(e,t){if(t===void 0&&(t=(0,f.default)(e)),t){let o=e[this.HASH_TAG];return o===void 0?this.h:this.H[o]}else return this.g[e]||this.h}clear(){let e=this.HASH_TAG;this.H.forEach(function(t){delete t.u[e]}),this.H=[],this.g={},Object.setPrototypeOf(this.g,null),this.i=0,this.p=this._=this.h.L=this.h.B=this.h}eraseElementByKey(e,t){let o;if(t===void 0&&(t=(0,f.default)(e)),t){let l=e[this.HASH_TAG];if(l===void 0)return!1;delete e[this.HASH_TAG],o=this.H[l],delete this.H[l]}else{if(o=this.g[e],o===void 0)return!1;delete this.g[e]}return this.V(o),!0}eraseElementByIterator(e){let t=e.o;return t===this.h&&(0,m.throwIteratorAccessError)(),this.V(t),e.next()}eraseElementByPos(e){if(e<0||e>this.i-1)throw new RangeError;let t=this.p;for(;e--;)t=t.B;return this.V(t),this.i}}x.HashContainer=i},{"../../../utils/checkObject":43,"../../../utils/throwError":44,"../../ContainerBase":25}],27:[function(y,k,x){"use strict";Object.defineProperty(x,"t",{value:!0}),x.default=void 0;var d=y("./Base"),f=h(y("../../utils/checkObject")),m=y("../../utils/throwError");function h(e){return e&&e.t?e:{default:e}}class s extends d.HashContainerIterator{constructor(t,o,l,p){super(t,o,p),this.container=l}get pointer(){this.o===this.h&&(0,m.throwIteratorAccessError)();let t=this;return new Proxy([],{get(o,l){if(l==="0")return t.o.u;if(l==="1")return t.o.l},set(o,l,p){if(l!=="1")throw new TypeError("props must be 1");return t.o.l=p,!0}})}copy(){return new s(this.o,this.h,this.container,this.iteratorType)}}class i extends d.HashContainer{constructor(t=[]){super();let o=this;t.forEach(function(l){o.setElement(l[0],l[1])})}begin(){return new s(this.p,this.h,this)}end(){return new s(this.h,this.h,this)}rBegin(){return new s(this._,this.h,this,1)}rEnd(){return new s(this.h,this.h,this,1)}front(){if(this.i!==0)return[this.p.u,this.p.l]}back(){if(this.i!==0)return[this._.u,this._.l]}setElement(t,o,l){return this.M(t,o,l)}getElementByKey(t,o){if(o===void 0&&(o=(0,f.default)(t)),o){let p=t[this.HASH_TAG];return p!==void 0?this.H[p].l:void 0}let l=this.g[t];return l?l.l:void 0}getElementByPos(t){if(t<0||t>this.i-1)throw new RangeError;let o=this.p;for(;t--;)o=o.B;return[o.u,o.l]}find(t,o){let l=this.I(t,o);return new s(l,this.h,this)}forEach(t){let o=0,l=this.p;for(;l!==this.h;)t([l.u,l.l],o++,this),l=l.B}[Symbol.iterator](){return(function*(){let t=this.p;for(;t!==this.h;)yield[t.u,t.l],t=t.B}).bind(this)()}}var r=i;x.default=r},{"../../utils/checkObject":43,"../../utils/throwError":44,"./Base":26}],28:[function(y,k,x){"use strict";Object.defineProperty(x,"t",{value:!0}),x.default=void 0;var d=y("./Base"),f=y("../../utils/throwError");class m extends d.HashContainerIterator{constructor(r,e,t,o){super(r,e,o),this.container=t}get pointer(){return this.o===this.h&&(0,f.throwIteratorAccessError)(),this.o.u}copy(){return new m(this.o,this.h,this.container,this.iteratorType)}}class h extends d.HashContainer{constructor(r=[]){super();let e=this;r.forEach(function(t){e.insert(t)})}begin(){return new m(this.p,this.h,this)}end(){return new m(this.h,this.h,this)}rBegin(){return new m(this._,this.h,this,1)}rEnd(){return new m(this.h,this.h,this,1)}front(){return this.p.u}back(){return this._.u}insert(r,e){return this.M(r,void 0,e)}getElementByPos(r){if(r<0||r>this.i-1)throw new RangeError;let e=this.p;for(;r--;)e=e.B;return e.u}find(r,e){let t=this.I(r,e);return new m(t,this.h,this)}forEach(r){let e=0,t=this.p;for(;t!==this.h;)r(t.u,e++,this),t=t.B}[Symbol.iterator](){return(function*(){let r=this.p;for(;r!==this.h;)yield r.u,r=r.B}).bind(this)()}}var s=h;x.default=s},{"../../utils/throwError":44,"./Base":26}],29:[function(y,k,x){"use strict";Object.defineProperty(x,"t",{value:!0}),x.default=void 0;var d=y("../ContainerBase");class f extends d.Base{constructor(s=[],i=function(e,t){return e>t?-1:e>1;for(let t=this.i-1>>1;t>=0;--t)this.k(t,e)}m(s){let i=this.C[s];for(;s>0;){let r=s-1>>1,e=this.C[r];if(this.v(e,i)<=0)break;this.C[s]=e,s=r}this.C[s]=i}k(s,i){let r=this.C[s];for(;s0&&(e=t,o=this.C[t]),this.v(o,r)>=0)break;this.C[s]=o,s=e}this.C[s]=r}clear(){this.i=0,this.C.length=0}push(s){this.C.push(s),this.m(this.i),this.i+=1}pop(){if(this.i===0)return;let s=this.C[0],i=this.C.pop();return this.i-=1,this.i&&(this.C[0]=i,this.k(0,this.i>>1)),s}top(){return this.C[0]}find(s){return this.C.indexOf(s)>=0}remove(s){let i=this.C.indexOf(s);return i<0?!1:(i===0?this.pop():i===this.i-1?(this.C.pop(),this.i-=1):(this.C.splice(i,1,this.C.pop()),this.i-=1,this.m(i),this.k(i,this.i>>1)),!0)}updateItem(s){let i=this.C.indexOf(s);return i<0?!1:(this.m(i),this.k(i,this.i>>1),!0)}toArray(){return[...this.C]}}var m=f;x.default=m},{"../ContainerBase":25}],30:[function(y,k,x){"use strict";Object.defineProperty(x,"t",{value:!0}),x.default=void 0;var d=y("../ContainerBase");class f extends d.Base{constructor(s=[]){super(),this.j=0,this.q=[];let i=this;s.forEach(function(r){i.push(r)})}clear(){this.q=[],this.i=this.j=0}push(s){let i=this.q.length;if(this.j/i>.5&&this.j+this.i>=i&&i>4096){let r=this.i;for(let e=0;e{if(typeof e.length=="number")return e.length;if(typeof e.size=="number")return e.size;if(typeof e.size=="function")return e.size();throw new TypeError("Cannot get the length or size of the container")})();this.F=t,this.P=Math.max(Math.ceil(o/this.F),1);for(let g=0;g>1)-(l>>1),this.D=this.N=this.F-o%this.F>>1;let p=this;e.forEach(function(g){p.pushBack(g)})}T(){let e=[],t=Math.max(this.P>>1,1);for(let o=0;o>1}begin(){return new h(0,this)}end(){return new h(this.i,this)}rBegin(){return new h(this.i-1,this,1)}rEnd(){return new h(-1,this,1)}front(){if(this.i!==0)return this.A[this.j][this.D]}back(){if(this.i!==0)return this.A[this.R][this.N]}pushBack(e){return this.i&&(this.N0?this.N-=1:this.R>0?(this.R-=1,this.N=this.F-1):(this.R=this.P-1,this.N=this.F-1)),this.i-=1,e}pushFront(e){return this.i&&(this.D>0?this.D-=1:this.j>0?(this.j-=1,this.D=this.F-1):(this.j=this.P-1,this.D=this.F-1),this.j===this.R&&this.D===this.N&&this.T()),this.i+=1,this.A[this.j][this.D]=e,this.i}popFront(){if(this.i===0)return;let e=this.A[this.j][this.D];return this.i!==1&&(this.Dthis.i-1)throw new RangeError;let{curNodeBucketIndex:t,curNodePointerIndex:o}=this.O(e);return this.A[t][o]}setElementByPos(e,t){if(e<0||e>this.i-1)throw new RangeError;let{curNodeBucketIndex:o,curNodePointerIndex:l}=this.O(e);this.A[o][l]=t}insert(e,t,o=1){if(e<0||e>this.i)throw new RangeError;if(e===0)for(;o--;)this.pushFront(t);else if(e===this.i)for(;o--;)this.pushBack(t);else{let l=[];for(let p=e;pthis.i-1)throw new RangeError;if(e===0)this.popFront();else if(e===this.i-1)this.popBack();else{let t=[];for(let l=e+1;le;)this.popBack();return this.i}sort(e){let t=[];for(let o=0;othis.i-1)throw new RangeError;let o=this.p;for(;t--;)o=o.B;return o.l}eraseElementByPos(t){if(t<0||t>this.i-1)throw new RangeError;let o=this.p;for(;t--;)o=o.B;return this.V(o),this.i}eraseElementByValue(t){let o=this.p;for(;o!==this.h;)o.l===t&&this.V(o),o=o.B;return this.i}eraseElementByIterator(t){let o=t.o;return o===this.h&&(0,m.throwIteratorAccessError)(),t=t.next(),this.V(o),t}pushBack(t){return this.G(t,this._),this.i}popBack(){if(this.i===0)return;let t=this._.l;return this.V(this._),t}pushFront(t){return this.G(t,this.h),this.i}popFront(){if(this.i===0)return;let t=this.p.l;return this.V(this.p),t}setElementByPos(t,o){if(t<0||t>this.i-1)throw new RangeError;let l=this.p;for(;t--;)l=l.B;l.l=o}insert(t,o,l=1){if(t<0||t>this.i)throw new RangeError;if(l<=0)return this.i;if(t===0)for(;l--;)this.pushFront(o);else if(t===this.i)for(;l--;)this.pushBack(o);else{let p=this.p;for(let _=1;_this.i-1)throw new RangeError;return this.J[e]}eraseElementByPos(e){if(e<0||e>this.i-1)throw new RangeError;return this.J.splice(e,1),this.i-=1,this.i}eraseElementByValue(e){let t=0;for(let o=0;othis.i-1)throw new RangeError;this.J[e]=t}insert(e,t,o=1){if(e<0||e>this.i)throw new RangeError;return this.J.splice(e,0,...new Array(o).fill(t)),this.i+=o,this.i}find(e){for(let t=0;to?1:0},e=!1){super(),this.Y=void 0,this.v=r,e?(this.re=d.TreeNodeEnableIndex,this.M=function(t,o,l){let p=this.ne(t,o,l);if(p){let g=p.tt;for(;g!==this.h;)g.rt+=1,g=g.tt;let _=this.he(p);if(_){let{parentNode:c,grandParent:v,curNode:R}=_;c.ie(),v.ie(),R.ie()}}return this.i},this.V=function(t){let o=this.fe(t);for(;o!==this.h;)o.rt-=1,o=o.tt}):(this.re=d.TreeNode,this.M=function(t,o,l){let p=this.ne(t,o,l);return p&&this.he(p),this.i},this.V=this.fe),this.h=new this.re}X(r,e){let t=this.h;for(;r;){let o=this.v(r.u,e);if(o<0)r=r.W;else if(o>0)t=r,r=r.U;else return r}return t}Z(r,e){let t=this.h;for(;r;)this.v(r.u,e)<=0?r=r.W:(t=r,r=r.U);return t}$(r,e){let t=this.h;for(;r;){let o=this.v(r.u,e);if(o<0)t=r,r=r.W;else if(o>0)r=r.U;else return r}return t}rr(r,e){let t=this.h;for(;r;)this.v(r.u,e)<0?(t=r,r=r.W):r=r.U;return t}ue(r){for(;;){let e=r.tt;if(e===this.h)return;if(r.ee===1){r.ee=0;return}if(r===e.U){let t=e.W;if(t.ee===1)t.ee=0,e.ee=1,e===this.Y?this.Y=e.te():e.te();else if(t.W&&t.W.ee===1){t.ee=e.ee,e.ee=0,t.W.ee=0,e===this.Y?this.Y=e.te():e.te();return}else t.U&&t.U.ee===1?(t.ee=1,t.U.ee=0,t.se()):(t.ee=1,r=e)}else{let t=e.U;if(t.ee===1)t.ee=0,e.ee=1,e===this.Y?this.Y=e.se():e.se();else if(t.U&&t.U.ee===1){t.ee=e.ee,e.ee=0,t.U.ee=0,e===this.Y?this.Y=e.se():e.se();return}else t.W&&t.W.ee===1?(t.ee=1,t.W.ee=0,t.te()):(t.ee=1,r=e)}}}fe(r){if(this.i===1)return this.clear(),this.h;let e=r;for(;e.U||e.W;){if(e.W)for(e=e.W;e.U;)e=e.U;else e=e.U;[r.u,e.u]=[e.u,r.u],[r.l,e.l]=[e.l,r.l],r=e}this.h.U===e?this.h.U=e.tt:this.h.W===e&&(this.h.W=e.tt),this.ue(e);let t=e.tt;return e===t.U?t.U=void 0:t.W=void 0,this.i-=1,this.Y.ee=0,t}oe(r,e){return r===void 0?!1:this.oe(r.U,e)||e(r)?!0:this.oe(r.W,e)}he(r){for(;;){let e=r.tt;if(e.ee===0)return;let t=e.tt;if(e===t.U){let o=t.W;if(o&&o.ee===1){if(o.ee=e.ee=0,t===this.Y)return;t.ee=1,r=t;continue}else if(r===e.W){if(r.ee=0,r.U&&(r.U.tt=e),r.W&&(r.W.tt=t),e.W=r.U,t.U=r.W,r.U=e,r.W=t,t===this.Y)this.Y=r,this.h.tt=r;else{let l=t.tt;l.U===t?l.U=r:l.W=r}return r.tt=t.tt,e.tt=r,t.tt=r,t.ee=1,{parentNode:e,grandParent:t,curNode:r}}else e.ee=0,t===this.Y?this.Y=t.se():t.se(),t.ee=1}else{let o=t.U;if(o&&o.ee===1){if(o.ee=e.ee=0,t===this.Y)return;t.ee=1,r=t;continue}else if(r===e.U){if(r.ee=0,r.U&&(r.U.tt=t),r.W&&(r.W.tt=e),t.W=r.U,e.U=r.W,r.U=t,r.W=e,t===this.Y)this.Y=r,this.h.tt=r;else{let l=t.tt;l.U===t?l.U=r:l.W=r}return r.tt=t.tt,e.tt=r,t.tt=r,t.ee=1,{parentNode:e,grandParent:t,curNode:r}}else e.ee=0,t===this.Y?this.Y=t.te():t.te(),t.ee=1}return}}ne(r,e,t){if(this.Y===void 0){this.i+=1,this.Y=new this.re(r,e),this.Y.ee=0,this.Y.tt=this.h,this.h.tt=this.Y,this.h.U=this.Y,this.h.W=this.Y;return}let o,l=this.h.U,p=this.v(l.u,r);if(p===0){l.l=e;return}else if(p>0)l.U=new this.re(r,e),l.U.tt=l,o=l.U,this.h.U=o;else{let g=this.h.W,_=this.v(g.u,r);if(_===0){g.l=e;return}else if(_<0)g.W=new this.re(r,e),g.W.tt=g,o=g.W,this.h.W=o;else{if(t!==void 0){let c=t.o;if(c!==this.h){let v=this.v(c.u,r);if(v===0){c.l=e;return}else if(v>0){let R=c.L(),A=this.v(R.u,r);if(A===0){R.l=e;return}else A<0&&(o=new this.re(r,e),R.W===void 0?(R.W=o,o.tt=R):(c.U=o,o.tt=c))}}}if(o===void 0)for(o=this.Y;;){let c=this.v(o.u,r);if(c>0){if(o.U===void 0){o.U=new this.re(r,e),o.U.tt=o,o=o.U;break}o=o.U}else if(c<0){if(o.W===void 0){o.W=new this.re(r,e),o.W.tt=o,o=o.W;break}o=o.W}else{o.l=e;return}}}}return this.i+=1,o}I(r,e){for(;r;){let t=this.v(r.u,e);if(t<0)r=r.W;else if(t>0)r=r.U;else return r}return r||this.h}clear(){this.i=0,this.Y=void 0,this.h.tt=void 0,this.h.U=this.h.W=void 0}updateKeyByIterator(r,e){let t=r.o;if(t===this.h&&(0,m.throwIteratorAccessError)(),this.i===1)return t.u=e,!0;if(t===this.h.U)return this.v(t.B().u,e)>0?(t.u=e,!0):!1;if(t===this.h.W)return this.v(t.L().u,e)<0?(t.u=e,!0):!1;let o=t.L().u;if(this.v(o,e)>=0)return!1;let l=t.B().u;return this.v(l,e)<=0?!1:(t.u=e,!0)}eraseElementByPos(r){if(r<0||r>this.i-1)throw new RangeError;let e=0,t=this;return this.oe(this.Y,function(o){return r===e?(t.V(o),!0):(e+=1,!1)}),this.i}eraseElementByKey(r){if(this.i===0)return!1;let e=this.I(this.Y,r);return e===this.h?!1:(this.V(e),!0)}eraseElementByIterator(r){let e=r.o;e===this.h&&(0,m.throwIteratorAccessError)();let t=e.W===void 0;return r.iteratorType===0?t&&r.next():(!t||e.U===void 0)&&r.next(),this.V(e),r}forEach(r){let e=0;for(let t of this)r(t,e++,this)}getElementByPos(r){if(r<0||r>this.i-1)throw new RangeError;let e,t=0;for(let o of this){if(t===r){e=o;break}t+=1}return e}getHeight(){if(this.i===0)return 0;let r=function(e){return e?Math.max(r(e.U),r(e.W))+1:0};return r(this.Y)}}var s=h;x.default=s},{"../../../utils/throwError":44,"../../ContainerBase":25,"./TreeNode":38}],40:[function(y,k,x){"use strict";Object.defineProperty(x,"t",{value:!0}),x.default=void 0;var d=h(y("./Base")),f=h(y("./Base/TreeIterator")),m=y("../../utils/throwError");function h(e){return e&&e.t?e:{default:e}}class s extends f.default{constructor(t,o,l,p){super(t,o,p),this.container=l}get pointer(){this.o===this.h&&(0,m.throwIteratorAccessError)();let t=this;return new Proxy([],{get(o,l){if(l==="0")return t.o.u;if(l==="1")return t.o.l},set(o,l,p){if(l!=="1")throw new TypeError("props must be 1");return t.o.l=p,!0}})}copy(){return new s(this.o,this.h,this.container,this.iteratorType)}}class i extends d.default{constructor(t=[],o,l){super(o,l);let p=this;t.forEach(function(g){p.setElement(g[0],g[1])})}*K(t){t!==void 0&&(yield*Ee(this.K(t.U)),yield[t.u,t.l],yield*Ee(this.K(t.W)))}begin(){return new s(this.h.U||this.h,this.h,this)}end(){return new s(this.h,this.h,this)}rBegin(){return new s(this.h.W||this.h,this.h,this,1)}rEnd(){return new s(this.h,this.h,this,1)}front(){if(this.i===0)return;let t=this.h.U;return[t.u,t.l]}back(){if(this.i===0)return;let t=this.h.W;return[t.u,t.l]}lowerBound(t){let o=this.X(this.Y,t);return new s(o,this.h,this)}upperBound(t){let o=this.Z(this.Y,t);return new s(o,this.h,this)}reverseLowerBound(t){let o=this.$(this.Y,t);return new s(o,this.h,this)}reverseUpperBound(t){let o=this.rr(this.Y,t);return new s(o,this.h,this)}setElement(t,o,l){return this.M(t,o,l)}find(t){let o=this.I(this.Y,t);return new s(o,this.h,this)}getElementByKey(t){return this.I(this.Y,t).l}union(t){let o=this;return t.forEach(function(l){o.setElement(l[0],l[1])}),this.i}[Symbol.iterator](){return this.K(this.Y)}}var r=i;x.default=r},{"../../utils/throwError":44,"./Base":39,"./Base/TreeIterator":37}],41:[function(y,k,x){"use strict";Object.defineProperty(x,"t",{value:!0}),x.default=void 0;var d=h(y("./Base")),f=h(y("./Base/TreeIterator")),m=y("../../utils/throwError");function h(e){return e&&e.t?e:{default:e}}class s extends f.default{constructor(t,o,l,p){super(t,o,p),this.container=l}get pointer(){return this.o===this.h&&(0,m.throwIteratorAccessError)(),this.o.u}copy(){return new s(this.o,this.h,this.container,this.iteratorType)}}class i extends d.default{constructor(t=[],o,l){super(o,l);let p=this;t.forEach(function(g){p.insert(g)})}*K(t){t!==void 0&&(yield*Ee(this.K(t.U)),yield t.u,yield*Ee(this.K(t.W)))}begin(){return new s(this.h.U||this.h,this.h,this)}end(){return new s(this.h,this.h,this)}rBegin(){return new s(this.h.W||this.h,this.h,this,1)}rEnd(){return new s(this.h,this.h,this,1)}front(){return this.h.U?this.h.U.u:void 0}back(){return this.h.W?this.h.W.u:void 0}insert(t,o){return this.M(t,void 0,o)}find(t){let o=this.I(this.Y,t);return new s(o,this.h,this)}lowerBound(t){let o=this.X(this.Y,t);return new s(o,this.h,this)}upperBound(t){let o=this.Z(this.Y,t);return new s(o,this.h,this)}reverseLowerBound(t){let o=this.$(this.Y,t);return new s(o,this.h,this)}reverseUpperBound(t){let o=this.rr(this.Y,t);return new s(o,this.h,this)}union(t){let o=this;return t.forEach(function(l){o.insert(l)}),this.i}[Symbol.iterator](){return this.K(this.Y)}}var r=i;x.default=r},{"../../utils/throwError":44,"./Base":39,"./Base/TreeIterator":37}],42:[function(y,k,x){"use strict";Object.defineProperty(x,"t",{value:!0}),Object.defineProperty(x,"Deque",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(x,"HashMap",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(x,"HashSet",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(x,"LinkList",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(x,"OrderedMap",{enumerable:!0,get:function(){return e.default}}),Object.defineProperty(x,"OrderedSet",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(x,"PriorityQueue",{enumerable:!0,get:function(){return m.default}}),Object.defineProperty(x,"Queue",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(x,"Stack",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(x,"Vector",{enumerable:!0,get:function(){return h.default}});var d=l(y("./container/OtherContainer/Stack")),f=l(y("./container/OtherContainer/Queue")),m=l(y("./container/OtherContainer/PriorityQueue")),h=l(y("./container/SequentialContainer/Vector")),s=l(y("./container/SequentialContainer/LinkList")),i=l(y("./container/SequentialContainer/Deque")),r=l(y("./container/TreeContainer/OrderedSet")),e=l(y("./container/TreeContainer/OrderedMap")),t=l(y("./container/HashContainer/HashSet")),o=l(y("./container/HashContainer/HashMap"));function l(p){return p&&p.t?p:{default:p}}},{"./container/HashContainer/HashMap":27,"./container/HashContainer/HashSet":28,"./container/OtherContainer/PriorityQueue":29,"./container/OtherContainer/Queue":30,"./container/OtherContainer/Stack":31,"./container/SequentialContainer/Deque":34,"./container/SequentialContainer/LinkList":35,"./container/SequentialContainer/Vector":36,"./container/TreeContainer/OrderedMap":40,"./container/TreeContainer/OrderedSet":41}],43:[function(y,k,x){"use strict";Object.defineProperty(x,"t",{value:!0}),x.default=d;function d(f){let m=typeof f;return m==="object"&&f!==null||m==="function"}},{}],44:[function(y,k,x){"use strict";Object.defineProperty(x,"t",{value:!0}),x.throwIteratorAccessError=d;function d(){throw new RangeError("Iterator access denied!")}},{}],45:[function(y,k,x){"use strict";let d=y("yallist"),f=Symbol("max"),m=Symbol("length"),h=Symbol("lengthCalculator"),s=Symbol("allowStale"),i=Symbol("maxAge"),r=Symbol("dispose"),e=Symbol("noDisposeOnSet"),t=Symbol("lruList"),o=Symbol("cache"),l=Symbol("updateAgeOnGet"),p=()=>1;class g{constructor(I){if(typeof I=="number"&&(I={max:I}),I||(I={}),I.max&&(typeof I.max!="number"||I.max<0))throw new TypeError("max must be a non-negative number");let P=this[f]=I.max||1/0,S=I.length||p;if(this[h]=typeof S!="function"?p:S,this[s]=I.stale||!1,I.maxAge&&typeof I.maxAge!="number")throw new TypeError("maxAge must be a number");this[i]=I.maxAge||0,this[r]=I.dispose,this[e]=I.noDisposeOnSet||!1,this[l]=I.updateAgeOnGet||!1,this.reset()}set max(I){if(typeof I!="number"||I<0)throw new TypeError("max must be a non-negative number");this[f]=I||1/0,v(this)}get max(){return this[f]}set allowStale(I){this[s]=!!I}get allowStale(){return this[s]}set maxAge(I){if(typeof I!="number")throw new TypeError("maxAge must be a non-negative number");this[i]=I,v(this)}get maxAge(){return this[i]}set lengthCalculator(I){typeof I!="function"&&(I=p),I!==this[h]&&(this[h]=I,this[m]=0,this[t].forEach(P=>{P.length=this[h](P.value,P.key),this[m]+=P.length})),v(this)}get lengthCalculator(){return this[h]}get length(){return this[m]}get itemCount(){return this[t].length}rforEach(I,P){P=P||this;for(let S=this[t].tail;S!==null;){let V=S.prev;W(this,I,S,P),S=V}}forEach(I,P){P=P||this;for(let S=this[t].head;S!==null;){let V=S.next;W(this,I,S,P),S=V}}keys(){return this[t].toArray().map(I=>I.key)}values(){return this[t].toArray().map(I=>I.value)}reset(){this[r]&&this[t]&&this[t].length&&this[t].forEach(I=>this[r](I.key,I.value)),this[o]=new Map,this[t]=new d,this[m]=0}dump(){return this[t].map(I=>c(this,I)?!1:{k:I.key,v:I.value,e:I.now+(I.maxAge||0)}).toArray().filter(I=>I)}dumpLru(){return this[t]}set(I,P,S){if(S=S||this[i],S&&typeof S!="number")throw new TypeError("maxAge must be a number");let V=S?Date.now():0,M=this[h](P,I);if(this[o].has(I)){if(M>this[f])return R(this,this[o].get(I)),!1;let ie=this[o].get(I).value;return this[r]&&(this[e]||this[r](I,ie.value)),ie.now=V,ie.maxAge=S,ie.value=P,this[m]+=M-ie.length,ie.length=M,this.get(I),v(this),!0}let ne=new A(I,P,M,V,S);return ne.length>this[f]?(this[r]&&this[r](I,P),!1):(this[m]+=ne.length,this[t].unshift(ne),this[o].set(I,this[t].head),v(this),!0)}has(I){if(!this[o].has(I))return!1;let P=this[o].get(I).value;return!c(this,P)}get(I){return _(this,I,!0)}peek(I){return _(this,I,!1)}pop(){let I=this[t].tail;return I?(R(this,I),I.value):null}del(I){R(this,this[o].get(I))}load(I){this.reset();let P=Date.now();for(let S=I.length-1;S>=0;S--){let V=I[S],M=V.e||0;if(M===0)this.set(V.k,V.v);else{let ne=M-P;ne>0&&this.set(V.k,V.v,ne)}}}prune(){this[o].forEach((I,P)=>_(this,P,!1))}}let _=(j,I,P)=>{let S=j[o].get(I);if(S){let V=S.value;if(c(j,V)){if(R(j,S),!j[s])return}else P&&(j[l]&&(S.value.now=Date.now()),j[t].unshiftNode(S));return V.value}},c=(j,I)=>{if(!I||!I.maxAge&&!j[i])return!1;let P=Date.now()-I.now;return I.maxAge?P>I.maxAge:j[i]&&P>j[i]},v=j=>{if(j[m]>j[f])for(let I=j[t].tail;j[m]>j[f]&&I!==null;){let P=I.prev;R(j,I),I=P}},R=(j,I)=>{if(I){let P=I.value;j[r]&&j[r](P.key,P.value),j[m]-=P.length,j[o].delete(P.key),j[t].removeNode(I)}};class A{constructor(I,P,S,V,M){this.key=I,this.value=P,this.length=S,this.now=V,this.maxAge=M||0}}let W=(j,I,P,S)=>{let V=P.value;c(j,V)&&(R(j,P),j[s]||(V=void 0)),V&&I.call(S,V.value,V.key,j)};k.exports=g},{yallist:84}],46:[function(y,k,x){(function(d){(function(){let f=k.exports;f.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"},f.codes={};for(let h in f.types){let s=f.types[h];f.codes[s]=h}f.CMD_SHIFT=4,f.CMD_MASK=240,f.DUP_MASK=8,f.QOS_MASK=3,f.QOS_SHIFT=1,f.RETAIN_MASK=1,f.VARBYTEINT_MASK=127,f.VARBYTEINT_FIN_MASK=128,f.VARBYTEINT_MAX=268435455,f.SESSIONPRESENT_MASK=1,f.SESSIONPRESENT_HEADER=d.from([f.SESSIONPRESENT_MASK]),f.CONNACK_HEADER=d.from([f.codes.connack<[0,1].map(i=>[0,1].map(r=>{let e=d.alloc(1);return e.writeUInt8(f.codes[h]<d.from([h])),f.EMPTY={pingreq:d.from([f.codes.pingreq<<4,0]),pingresp:d.from([f.codes.pingresp<<4,0]),disconnect:d.from([f.codes.disconnect<<4,0])}}).call(this)}).call(this,y("buffer").Buffer)},{buffer:3}],47:[function(y,k,x){(function(d){(function(){let f=y("./writeToStream"),m=y("events");function h(i,r){let e=new s;return f(i,e,r),e.concat()}class s extends m{constructor(){super(),this._array=new Array(20),this._i=0}write(r){return this._array[this._i++]=r,!0}concat(){let r=0,e=new Array(this._array.length),t=this._array,o=0,l;for(l=0;l>8,0),o.writeUInt8(t&255,1),o}function i(){for(let t=0;t<65536;t++)m[t]=s(t)}function r(t){let l=0,p=0,g=d.allocUnsafe(4);do l=t%128|0,t=t/128|0,t>0&&(l=l|128),g.writeUInt8(l,p++);while(t>0&&p<4);return t>0&&(p=0),h?g.subarray(0,p):g.slice(0,p)}function e(t){let o=d.allocUnsafe(4);return o.writeUInt32BE(t,0),o}k.exports={cache:m,generateCache:i,generateNumber:s,genBufVariableByteInt:r,generate4ByteBuffer:e}}).call(this)}).call(this,y("buffer").Buffer)},{buffer:3}],50:[function(y,k,x){class d{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}k.exports=d},{}],51:[function(y,k,x){let d=y("bl"),f=y("events"),m=y("./packet"),h=y("./constants"),s=y("debug")("mqtt-packet:parser");class i extends f{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof i?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new i().parser(e)}_resetState(){s("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new m,this.error=null,this._list=d(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),s("parse: current state: %s",this._states[this._stateCounter]);(this.packet.length!==-1||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,s("parse: state complete. _stateCounter is now: %d",this._stateCounter),s("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return s("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){let e=this._list.readUInt8(0);return this.packet.cmd=h.types[e>>h.CMD_SHIFT],this.packet.retain=(e&h.RETAIN_MASK)!==0,this.packet.qos=e>>h.QOS_SHIFT&h.QOS_MASK,this.packet.dup=(e&h.DUP_MASK)!==0,s("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){let e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),s("_parseLength %d",e.value),!!e}_parsePayload(){s("_parsePayload: payload %O",this._list);let e=!1;if(this.packet.length===0||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=!0}return s("_parsePayload complete result: %s",e),e}_parseConnect(){s("_parseConnect");let e,t,o,l,p={},g=this.packet,_=this._parseString();if(_===null)return this._emitError(new Error("Cannot parse protocolId"));if(_!=="MQTT"&&_!=="MQIsdp")return this._emitError(new Error("Invalid protocolId"));if(g.protocolId=_,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(g.protocolVersion=this._list.readUInt8(this._pos),g.protocolVersion>=128&&(g.bridgeMode=!0,g.protocolVersion=g.protocolVersion-128),g.protocolVersion!==3&&g.protocolVersion!==4&&g.protocolVersion!==5)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(p.username=this._list.readUInt8(this._pos)&h.USERNAME_MASK,p.password=this._list.readUInt8(this._pos)&h.PASSWORD_MASK,p.will=this._list.readUInt8(this._pos)&h.WILL_FLAG_MASK,p.will&&(g.will={},g.will.retain=(this._list.readUInt8(this._pos)&h.WILL_RETAIN_MASK)!==0,g.will.qos=(this._list.readUInt8(this._pos)&h.WILL_QOS_MASK)>>h.WILL_QOS_SHIFT),g.clean=(this._list.readUInt8(this._pos)&h.CLEAN_SESSION_MASK)!==0,this._pos++,g.keepalive=this._parseNum(),g.keepalive===-1)return this._emitError(new Error("Packet too short"));if(g.protocolVersion===5){let v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}let c=this._parseString();if(c===null)return this._emitError(new Error("Packet too short"));if(g.clientId=c,s("_parseConnect: packet.clientId: %s",g.clientId),p.will){if(g.protocolVersion===5){let v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.will.properties=v)}if(e=this._parseString(),e===null)return this._emitError(new Error("Cannot parse will topic"));if(g.will.topic=e,s("_parseConnect: packet.will.topic: %s",g.will.topic),t=this._parseBuffer(),t===null)return this._emitError(new Error("Cannot parse will payload"));g.will.payload=t,s("_parseConnect: packet.will.paylaod: %s",g.will.payload)}if(p.username){if(l=this._parseString(),l===null)return this._emitError(new Error("Cannot parse username"));g.username=l,s("_parseConnect: packet.username: %s",g.username)}if(p.password){if(o=this._parseBuffer(),o===null)return this._emitError(new Error("Cannot parse password"));g.password=o}return this.settings=g,s("_parseConnect: complete"),g}_parseConnack(){s("_parseConnack");let e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&h.SESSIONPRESENT_MASK),this.settings.protocolVersion===5)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(e.returnCode===-1||e.reasonCode===-1)return this._emitError(new Error("Cannot parse return code"));if(this.settings.protocolVersion===5){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}s("_parseConnack: complete")}_parsePublish(){s("_parsePublish");let e=this.packet;if(e.topic=this._parseString(),e.topic===null)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0&&!this._parseMessageId())){if(this.settings.protocolVersion===5){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),s("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){s("_parseSubscribe");let e=this.packet,t,o,l,p,g,_,c;if(e.qos!==1)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(e.properties=v)}for(;this._pos=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));o=this._parseByte(),l=o&h.SUBSCRIBE_OPTIONS_QOS_MASK,_=(o>>h.SUBSCRIBE_OPTIONS_NL_SHIFT&h.SUBSCRIBE_OPTIONS_NL_MASK)!==0,g=(o>>h.SUBSCRIBE_OPTIONS_RAP_SHIFT&h.SUBSCRIBE_OPTIONS_RAP_MASK)!==0,p=o>>h.SUBSCRIBE_OPTIONS_RH_SHIFT&h.SUBSCRIBE_OPTIONS_RH_MASK,c={topic:t,qos:l},this.settings.protocolVersion===5?(c.nl=_,c.rap=g,c.rh=p):this.settings.bridgeMode&&(c.rh=0,c.rap=!0,c.nl=!0),s("_parseSubscribe: push subscription `%s` to subscription",c),e.subscriptions.push(c)}}}_parseSuback(){s("_parseSuback");let e=this.packet;if(this.packet.granted=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos2?(e.reasonCode=this._parseByte(),s("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){let e=this.packet;if(s("_parseDisconnect"),this.settings.protocolVersion===5){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return s("_parseDisconnect result: true"),!0}_parseAuth(){s("_parseAuth");let e=this.packet;if(this.settings.protocolVersion!==5)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();let t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),s("_parseAuth: result: true"),!0}_parseMessageId(){let e=this.packet;return e.messageId=this._parseNum(),e.messageId===null?(this._emitError(new Error("Cannot parse messageId")),!1):(s("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){let t=this._parseNum(),o=t+this._pos;if(t===-1||o>this._list.length||o>this.packet.length)return null;let l=this._list.toString("utf8",this._pos,o);return this._pos+=t,s("_parseString: result: %s",l),l}_parseStringPair(){return s("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){let e=this._parseNum(),t=e+this._pos;if(e===-1||t>this._list.length||t>this.packet.length)return null;let o=this._list.slice(this._pos,t);return this._pos+=e,s("_parseBuffer: result: %o",o),o}_parseNum(){if(this._list.length-this._pos<2)return-1;let e=this._list.readUInt16BE(this._pos);return this._pos+=2,s("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;let e=this._list.readUInt32BE(this._pos);return this._pos+=4,s("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){s("_parseVarByteNum");let t=4,o=0,l=1,p=0,g=!1,_,c=this._pos?this._pos:0;for(;o=o&&this._emitError(new Error("Invalid variable byte integer")),c&&(this._pos+=o),g=g?e?{bytes:o,value:p}:p:!1,s("_parseVarByteNum: result: %o",g),g}_parseByte(){let e;return this._pos=4)&&(w||z))b+=d.byteLength(w)+2;else{if(C<4)return B.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(z*1===0)return B.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if(typeof Q!="number"||Q<0||Q>65535||Q%1!==0)return B.emit("error",new Error("Invalid keepalive")),!1;if(b+=2,b+=1,C===5){var L=H(B,a);if(!L)return!1;b+=L.length}if(N){if(typeof N!="object")return B.emit("error",new Error("Invalid will")),!1;if(!N.topic||typeof N.topic!="string")return B.emit("error",new Error("Invalid will topic")),!1;if(b+=d.byteLength(N.topic)+2,b+=2,N.payload)if(N.payload.length>=0)typeof N.payload=="string"?b+=d.byteLength(N.payload):b+=N.payload.length;else return B.emit("error",new Error("Invalid will payload")),!1;var K={};if(C===5){if(K=H(B,N.properties),!K)return!1;b+=K.length}}let J=!1;if(u!=null)if(Z(u))J=!0,b+=d.byteLength(u)+2;else return B.emit("error",new Error("Invalid username")),!1;if(n!=null){if(!J)return B.emit("error",new Error("Username is required to use password")),!1;if(Z(n))b+=oe(n)+2;else return B.emit("error",new Error("Invalid password")),!1}B.write(f.CONNECT_HEADER),G(B,b),ee(B,O),te.bridgeMode&&(C+=128),B.write(C===131?f.VERSION131:C===132?f.VERSION132:C===4?f.VERSION4:C===5?f.VERSION5:f.VERSION3);let ae=0;return ae|=u!=null?f.USERNAME_MASK:0,ae|=n!=null?f.PASSWORD_MASK:0,ae|=N&&N.retain?f.WILL_RETAIN_MASK:0,ae|=N&&N.qos?N.qos<0&&g(B,w),a?.write(),r("publish: payload: %o",Q),B.write(Q)}function j(F,B,Y){let te=Y?Y.protocolVersion:4,O=F||{},C=O.cmd||"puback",N=O.messageId,z=O.dup&&C==="pubrel"?f.DUP_MASK:0,Q=0,w=O.reasonCode,u=O.properties,n=te===5?3:2;if(C==="pubrel"&&(Q=1),typeof N!="number")return B.emit("error",new Error("Invalid messageId")),!1;let a=null;if(te===5&&typeof u=="object"){if(a=D(B,u,Y,n),!a)return!1;n+=a.length}return B.write(f.ACKS[C][Q][z][0]),G(B,n),g(B,N),te===5&&B.write(d.from([w])),a!==null&&a.write(),!0}function I(F,B,Y){r("subscribe: packet: ");let te=Y?Y.protocolVersion:4,O=F||{},C=O.dup?f.DUP_MASK:0,N=O.messageId,z=O.subscriptions,Q=O.properties,w=0;if(typeof N!="number")return B.emit("error",new Error("Invalid messageId")),!1;w+=2;let u=null;if(te===5){if(u=H(B,Q),!u)return!1;w+=u.length}if(typeof z=="object"&&z.length)for(let a=0;a2)return B.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}w+=d.byteLength(b)+2+1}else return B.emit("error",new Error("Invalid subscriptions")),!1;r("subscribe: writing to stream: %o",f.SUBSCRIBE_HEADER),B.write(f.SUBSCRIBE_HEADER[1][C?1:0][0]),G(B,w),g(B,N),u!==null&&u.write();let n=!0;for(let a of z){let b=a.topic,L=a.qos,K=+a.nl,J=+a.rap,ae=a.rh,le;E(B,b),le=f.SUBSCRIBE_OPTIONS_QOS[L],te===5&&(le|=K?f.SUBSCRIBE_OPTIONS_NL:0,le|=J?f.SUBSCRIBE_OPTIONS_RAP:0,le|=ae?f.SUBSCRIBE_OPTIONS_RH[ae]:0),n=B.write(d.from([le]))}return n}function P(F,B,Y){let te=Y?Y.protocolVersion:4,O=F||{},C=O.messageId,N=O.granted,z=O.properties,Q=0;if(typeof C!="number")return B.emit("error",new Error("Invalid messageId")),!1;if(Q+=2,typeof N=="object"&&N.length)for(let u=0;uf.VARBYTEINT_MAX)return F.emit("error",new Error(`Invalid variable byte integer: ${B}`)),!1;let Y=ie[B];return Y||(Y=l(B),B<16384&&(ie[B]=Y)),r("writeVarByteInt: writing to stream: %o",Y),F.write(Y)}function E(F,B){let Y=d.byteLength(B);return g(F,Y),r("writeString: %s",B),F.write(B,"utf8")}function T(F,B,Y){E(F,B),E(F,Y)}function U(F,B){return r("writeNumberCached: number: %d",B),r("writeNumberCached: %o",e[B]),F.write(e[B])}function q(F,B){let Y=t(B);return r("writeNumberGenerated: %o",Y),F.write(Y)}function re(F,B){let Y=p(B);return r("write4ByteNumber: %o",Y),F.write(Y)}function ee(F,B){typeof B=="string"?E(F,B):B?(g(F,B.length),F.write(B)):g(F,0)}function H(F,B){if(typeof B!="object"||B.length!=null)return{length:1,write(){$(F,{},0)}};let Y=0;function te(C,N){let z=f.propertiesTypes[C],Q=0;switch(z){case"byte":{if(typeof N!="boolean")return F.emit("error",new Error(`Invalid ${C}: ${N}`)),!1;Q+=2;break}case"int8":{if(typeof N!="number"||N<0||N>255)return F.emit("error",new Error(`Invalid ${C}: ${N}`)),!1;Q+=2;break}case"binary":{if(N&&N===null)return F.emit("error",new Error(`Invalid ${C}: ${N}`)),!1;Q+=1+d.byteLength(N)+2;break}case"int16":{if(typeof N!="number"||N<0||N>65535)return F.emit("error",new Error(`Invalid ${C}: ${N}`)),!1;Q+=3;break}case"int32":{if(typeof N!="number"||N<0||N>4294967295)return F.emit("error",new Error(`Invalid ${C}: ${N}`)),!1;Q+=5;break}case"var":{if(typeof N!="number"||N<0||N>268435455)return F.emit("error",new Error(`Invalid ${C}: ${N}`)),!1;Q+=1+d.byteLength(l(N));break}case"string":{if(typeof N!="string")return F.emit("error",new Error(`Invalid ${C}: ${N}`)),!1;Q+=3+d.byteLength(N.toString());break}case"pair":{if(typeof N!="object")return F.emit("error",new Error(`Invalid ${C}: ${N}`)),!1;Q+=Object.getOwnPropertyNames(N).reduce((w,u)=>{let n=N[u];return Array.isArray(n)?w+=n.reduce((a,b)=>(a+=3+d.byteLength(u.toString())+2+d.byteLength(b.toString()),a),0):w+=3+d.byteLength(u.toString())+2+d.byteLength(N[u].toString()),w},0);break}default:return F.emit("error",new Error(`Invalid property ${C}: ${N}`)),!1}return Q}if(B)for(let C in B){let N=0,z=0,Q=B[C];if(Array.isArray(Q))for(let w=0;wC;){let z=O.shift();if(z&&B[z])delete B[z],N=H(F,B);else return!1}return N}function X(F,B,Y){switch(f.propertiesTypes[B]){case"byte":{F.write(d.from([f.properties[B]])),F.write(d.from([+Y]));break}case"int8":{F.write(d.from([f.properties[B]])),F.write(d.from([Y]));break}case"binary":{F.write(d.from([f.properties[B]])),ee(F,Y);break}case"int16":{F.write(d.from([f.properties[B]])),g(F,Y);break}case"int32":{F.write(d.from([f.properties[B]])),re(F,Y);break}case"var":{F.write(d.from([f.properties[B]])),G(F,Y);break}case"string":{F.write(d.from([f.properties[B]])),E(F,Y);break}case"pair":{Object.getOwnPropertyNames(Y).forEach(O=>{let C=Y[O];Array.isArray(C)?C.forEach(N=>{F.write(d.from([f.properties[B]])),T(F,O.toString(),N.toString())}):(F.write(d.from([f.properties[B]])),T(F,O.toString(),C.toString()))});break}default:return F.emit("error",new Error(`Invalid property ${B} value: ${Y}`)),!1}}function $(F,B,Y){G(F,Y);for(let te in B)if(Object.prototype.hasOwnProperty.call(B,te)&&B[te]!==null){let O=B[te];if(Array.isArray(O))for(let C=0;C0)return r(l);if(g==="number"&&isFinite(l))return p.long?t(l):e(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function r(l){if(l=String(l),!(l.length>100)){var p=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(p){var g=parseFloat(p[1]),_=(p[2]||"ms").toLowerCase();switch(_){case"years":case"year":case"yrs":case"yr":case"y":return g*i;case"weeks":case"week":case"w":return g*s;case"days":case"day":case"d":return g*h;case"hours":case"hour":case"hrs":case"hr":case"h":return g*m;case"minutes":case"minute":case"mins":case"min":case"m":return g*f;case"seconds":case"second":case"secs":case"sec":case"s":return g*d;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return g;default:return}}}}function e(l){var p=Math.abs(l);return p>=h?Math.round(l/h)+"d":p>=m?Math.round(l/m)+"h":p>=f?Math.round(l/f)+"m":p>=d?Math.round(l/d)+"s":l+"ms"}function t(l){var p=Math.abs(l);return p>=h?o(l,p,h,"day"):p>=m?o(l,p,m,"hour"):p>=f?o(l,p,f,"minute"):p>=d?o(l,p,d,"second"):l+" ms"}function o(l,p,g,_){var c=p>=g*1.5;return Math.round(l/g)+" "+_+(c?"s":"")}},{}],54:[function(y,k,x){let d=y("./lib/number-allocator.js");k.exports.NumberAllocator=d},{"./lib/number-allocator.js":55}],55:[function(y,k,x){"use strict";let d=y("js-sdsl").OrderedSet,f=y("debug")("number-allocator:trace"),m=y("debug")("number-allocator:error");function h(i,r){this.low=i,this.high=r}h.prototype.equals=function(i){return this.low===i.low&&this.high===i.high},h.prototype.compare=function(i){return this.lowe.compare(t)),f("Create"),this.clear()}s.prototype.firstVacant=function(){return this.ss.size()===0?null:this.ss.front().low},s.prototype.alloc=function(){if(this.ss.size()===0)return f("alloc():empty"),null;let i=this.ss.begin(),r=i.pointer.low,e=i.pointer.high,t=r;return t+1<=e?this.ss.updateKeyByIterator(i,new h(r+1,e)):this.ss.eraseElementByPos(0),f("alloc():"+t),t},s.prototype.use=function(i){let r=new h(i,i),e=this.ss.lowerBound(r);if(!e.equals(this.ss.end())){let t=e.pointer.low,o=e.pointer.high;return e.pointer.equals(r)?(this.ss.eraseElementByIterator(e),f("use():"+i),!0):t>i?!1:t===i?(this.ss.updateKeyByIterator(e,new h(t+1,o)),f("use():"+i),!0):o===i?(this.ss.updateKeyByIterator(e,new h(t,o-1)),f("use():"+i),!0):(this.ss.updateKeyByIterator(e,new h(i+1,o)),this.ss.insert(new h(t,i-1)),f("use():"+i),!0)}return f("use():failed"),!1},s.prototype.free=function(i){if(ithis.max){m("free():"+i+" is out of range");return}let r=new h(i,i),e=this.ss.upperBound(r);if(e.equals(this.ss.end())){if(e.equals(this.ss.begin())){this.ss.insert(r);return}e.pre();let t=e.pointer.high;e.pointer.high+1===i?this.ss.updateKeyByIterator(e,new h(t,i)):this.ss.insert(r)}else if(e.equals(this.ss.begin()))if(i+1===e.pointer.low){let t=e.pointer.high;this.ss.updateKeyByIterator(e,new h(i,t))}else this.ss.insert(r);else{let t=e.pointer.low,o=e.pointer.high;e.pre();let l=e.pointer.low;e.pointer.high+1===i?i+1===t?(this.ss.eraseElementByIterator(e),this.ss.updateKeyByIterator(e,new h(l,o))):this.ss.updateKeyByIterator(e,new h(l,i)):i+1===t?(this.ss.eraseElementByIterator(e.next()),this.ss.insert(new h(i,o))):this.ss.insert(r)}f("free():"+i)},s.prototype.clear=function(){f("clear()"),this.ss.clear(),this.ss.insert(new h(this.min,this.max))},s.prototype.intervalCount=function(){return this.ss.size()},s.prototype.dump=function(){console.log("length:"+this.ss.size());for(let i of this.ss)console.log(i)},k.exports=s},{debug:20,"js-sdsl":42}],56:[function(y,k,x){var d=y("wrappy");k.exports=d(f),k.exports.strict=d(m),f.proto=f(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return f(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return m(this)},configurable:!0})});function f(h){var s=function(){return s.called?s.value:(s.called=!0,s.value=h.apply(this,arguments))};return s.called=!1,s}function m(h){var s=function(){if(s.called)throw new Error(s.onceError);return s.called=!0,s.value=h.apply(this,arguments)},i=h.name||"Function wrapped with `once`";return s.onceError=i+" shouldn't be called more than once",s.called=!1,s}},{wrappy:80}],57:[function(y,k,x){(function(d){(function(){"use strict";typeof d>"u"||!d.version||d.version.indexOf("v0.")===0||d.version.indexOf("v1.")===0&&d.version.indexOf("v1.8.")!==0?k.exports={nextTick:f}:k.exports=d;function f(m,h,s,i){if(typeof m!="function")throw new TypeError('"callback" argument must be a function');var r=arguments.length,e,t;switch(r){case 0:case 1:return d.nextTick(m);case 2:return d.nextTick(function(){m.call(null,h)});case 3:return d.nextTick(function(){m.call(null,h,s)});case 4:return d.nextTick(function(){m.call(null,h,s,i)});default:for(e=new Array(r-1),t=0;t2?"one of ".concat(t," ").concat(e.slice(0,o-1).join(", "),", or ")+e[o-1]:o===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function s(e,t,o){return e.substr(!o||o<0?0:+o,t.length)===t}function i(e,t,o){return(o===void 0||o>e.length)&&(o=e.length),e.substring(o-t.length,o)===t}function r(e,t,o){return typeof o!="number"&&(o=0),o+t.length>e.length?!1:e.indexOf(t,o)!==-1}m("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),m("ERR_INVALID_ARG_TYPE",function(e,t,o){var l;typeof t=="string"&&s(t,"not ")?(l="must not be",t=t.replace(/^not /,"")):l="must be";var p;if(i(e," argument"))p="The ".concat(e," ").concat(l," ").concat(h(t,"type"));else{var g=r(e,".")?"property":"argument";p='The "'.concat(e,'" ').concat(g," ").concat(l," ").concat(h(t,"type"))}return p+=". Received type ".concat(typeof o),p},TypeError),m("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),m("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),m("ERR_STREAM_PREMATURE_CLOSE","Premature close"),m("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),m("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),m("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),m("ERR_STREAM_WRITE_AFTER_END","write after end"),m("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),m("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),m("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),k.exports.codes=f},{}],59:[function(y,k,x){(function(d){(function(){"use strict";var f=Object.keys||function(l){var p=[];for(var g in l)p.push(g);return p};k.exports=e;var m=y("./_stream_readable"),h=y("./_stream_writable");y("inherits")(e,m);for(var s=f(h.prototype),i=0;i0)if(typeof u!="string"&&!L.objectMode&&Object.getPrototypeOf(u)!==r.prototype&&(u=t(u)),a)L.endEmitted?M(w,new I):T(w,L,u,!0);else if(L.ended)M(w,new W);else{if(L.destroyed)return!1;L.reading=!1,L.decoder&&!n?(u=L.decoder.write(u),L.objectMode||u.length!==0?T(w,L,u,!1):$(w,L)):T(w,L,u,!1)}else a||(L.reading=!1,$(w,L))}return!L.ended&&(L.length=q?w=q:(w--,w|=w>>>1,w|=w>>>2,w|=w>>>4,w|=w>>>8,w|=w>>>16,w++),w}function ee(w,u){return w<=0||u.length===0&&u.ended?0:u.objectMode?1:w!==w?u.flowing&&u.length?u.buffer.head.data.length:u.length:(w>u.highWaterMark&&(u.highWaterMark=re(w)),w<=u.length?w:u.ended?u.length:(u.needReadable=!0,0))}G.prototype.read=function(w){p("read",w),w=parseInt(w,10);var u=this._readableState,n=w;if(w!==0&&(u.emittedReadable=!1),w===0&&u.needReadable&&((u.highWaterMark!==0?u.length>=u.highWaterMark:u.length>0)||u.ended))return p("read: emitReadable",u.length,u.ended),u.length===0&&u.ended?N(this):D(this),null;if(w=ee(w,u),w===0&&u.ended)return u.length===0&&N(this),null;var a=u.needReadable;p("need readable",a),(u.length===0||u.length-w0?b=C(w,u):b=null,b===null?(u.needReadable=u.length<=u.highWaterMark,w=0):(u.length-=w,u.awaitDrain=0),u.length===0&&(u.ended||(u.needReadable=!0),n!==w&&u.ended&&N(this)),b!==null&&this.emit("data",b),b};function H(w,u){if(p("onEofChunk"),!u.ended){if(u.decoder){var n=u.decoder.end();n&&n.length&&(u.buffer.push(n),u.length+=u.objectMode?1:n.length)}u.ended=!0,u.sync?D(w):(u.needReadable=!1,u.emittedReadable||(u.emittedReadable=!0,X(w)))}}function D(w){var u=w._readableState;p("emitReadable",u.needReadable,u.emittedReadable),u.needReadable=!1,u.emittedReadable||(p("emitReadable",u.flowing),u.emittedReadable=!0,d.nextTick(X,w))}function X(w){var u=w._readableState;p("emitReadable_",u.destroyed,u.length,u.ended),!u.destroyed&&(u.length||u.ended)&&(w.emit("readable"),u.emittedReadable=!1),u.needReadable=!u.flowing&&!u.ended&&u.length<=u.highWaterMark,O(w)}function $(w,u){u.readingMore||(u.readingMore=!0,d.nextTick(oe,w,u))}function oe(w,u){for(;!u.reading&&!u.ended&&(u.length1&&Q(a.pipes,w)!==-1)&&!le&&(p("false write response, pause",a.awaitDrain),a.awaitDrain++),n.pause())}function fe(be){p("onerror",be),ye(),w.removeListener("error",fe),s(w,"error")===0&&M(w,be)}se(w,"error",fe);function me(){w.removeListener("finish",we),ye()}w.once("close",me);function we(){p("onfinish"),w.removeListener("close",me),ye()}w.once("finish",we);function ye(){p("unpipe"),n.unpipe(w)}return w.emit("pipe",n),a.flowing||(p("pipe resume"),n.resume()),w};function Z(w){return function(){var n=w._readableState;p("pipeOnDrain",n.awaitDrain),n.awaitDrain&&n.awaitDrain--,n.awaitDrain===0&&s(w,"data")&&(n.flowing=!0,O(w))}}G.prototype.unpipe=function(w){var u=this._readableState,n={hasUnpiped:!1};if(u.pipesCount===0)return this;if(u.pipesCount===1)return w&&w!==u.pipes?this:(w||(w=u.pipes),u.pipes=null,u.pipesCount=0,u.flowing=!1,w&&w.emit("unpipe",this,n),this);if(!w){var a=u.pipes,b=u.pipesCount;u.pipes=null,u.pipesCount=0,u.flowing=!1;for(var L=0;L0,a.flowing!==!1&&this.resume()):w==="readable"&&!a.endEmitted&&!a.readableListening&&(a.readableListening=a.needReadable=!0,a.flowing=!1,a.emittedReadable=!1,p("on readable",a.length,a.reading),a.length?D(this):a.reading||d.nextTick(B,this)),n},G.prototype.addListener=G.prototype.on,G.prototype.removeListener=function(w,u){var n=i.prototype.removeListener.call(this,w,u);return w==="readable"&&d.nextTick(F,this),n},G.prototype.removeAllListeners=function(w){var u=i.prototype.removeAllListeners.apply(this,arguments);return(w==="readable"||w===void 0)&&d.nextTick(F,this),u};function F(w){var u=w._readableState;u.readableListening=w.listenerCount("readable")>0,u.resumeScheduled&&!u.paused?u.flowing=!0:w.listenerCount("data")>0&&w.resume()}function B(w){p("readable nexttick read 0"),w.read(0)}G.prototype.resume=function(){var w=this._readableState;return w.flowing||(p("resume"),w.flowing=!w.readableListening,Y(this,w)),w.paused=!1,this};function Y(w,u){u.resumeScheduled||(u.resumeScheduled=!0,d.nextTick(te,w,u))}function te(w,u){p("resume",u.reading),u.reading||w.read(0),u.resumeScheduled=!1,w.emit("resume"),O(w),u.flowing&&!u.reading&&w.read(0)}G.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function O(w){var u=w._readableState;for(p("flow",u.flowing);u.flowing&&w.read()!==null;);}G.prototype.wrap=function(w){var u=this,n=this._readableState,a=!1;w.on("end",function(){if(p("wrapped end"),n.decoder&&!n.ended){var K=n.decoder.end();K&&K.length&&u.push(K)}u.push(null)}),w.on("data",function(K){if(p("wrapped data"),n.decoder&&(K=n.decoder.write(K)),!(n.objectMode&&K==null)&&!(!n.objectMode&&(!K||!K.length))){var J=u.push(K);J||(a=!0,w.pause())}});for(var b in w)this[b]===void 0&&typeof w[b]=="function"&&(this[b]=function(J){return function(){return w[J].apply(w,arguments)}}(b));for(var L=0;L=u.length?(u.decoder?n=u.buffer.join(""):u.buffer.length===1?n=u.buffer.first():n=u.buffer.concat(u.length),u.buffer.clear()):n=u.buffer.consume(w,u.decoder),n}function N(w){var u=w._readableState;p("endReadable",u.endEmitted),u.endEmitted||(u.ended=!0,d.nextTick(z,u,w))}function z(w,u){if(p("endReadableNT",w.endEmitted,w.length),!w.endEmitted&&w.length===0&&(w.endEmitted=!0,u.readable=!1,u.emit("end"),w.autoDestroy)){var n=u._writableState;(!n||n.autoDestroy&&n.finished)&&u.destroy()}}typeof Symbol=="function"&&(G.from=function(w,u){return V===void 0&&(V=y("./internal/streams/from")),V(G,w,u)});function Q(w,u){for(var n=0,a=w.length;n-1))throw new S(C);return this._writableState.defaultEncoding=C,this},Object.defineProperty(ie.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function T(O,C,N){return!O.objectMode&&O.decodeStrings!==!1&&typeof C=="string"&&(C=e.from(C,N)),C}Object.defineProperty(ie.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function U(O,C,N,z,Q,w){if(!N){var u=T(C,z,Q);z!==u&&(N=!0,Q="buffer",z=u)}var n=C.objectMode?1:z.length;C.length+=n;var a=C.length0?this.tail.next=v:this.head=v,this.tail=v,++this.length}},{key:"unshift",value:function(c){var v={data:c,next:this.head};this.length===0&&(this.tail=v),this.head=v,++this.length}},{key:"shift",value:function(){if(this.length!==0){var c=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,c}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(c){if(this.length===0)return"";for(var v=this.head,R=""+v.data;v=v.next;)R+=c+v.data;return R}},{key:"concat",value:function(c){if(this.length===0)return e.alloc(0);for(var v=e.allocUnsafe(c>>>0),R=this.head,A=0;R;)p(R.data,v,A),A+=R.data.length,R=R.next;return v}},{key:"consume",value:function(c,v){var R;return cW.length?W.length:c;if(j===W.length?A+=W:A+=W.slice(0,c),c-=j,c===0){j===W.length?(++R,v.next?this.head=v.next:this.head=this.tail=null):(this.head=v,v.data=W.slice(j));break}++R}return this.length-=R,A}},{key:"_getBuffer",value:function(c){var v=e.allocUnsafe(c),R=this.head,A=1;for(R.data.copy(v),c-=R.data.length;R=R.next;){var W=R.data,j=c>W.length?W.length:c;if(W.copy(v,v.length-c,0,j),c-=j,c===0){j===W.length?(++A,R.next?this.head=R.next:this.head=this.tail=null):(this.head=R,R.data=W.slice(j));break}++A}return this.length-=A,v}},{key:l,value:function(c,v){return o(this,f({},v,{depth:0,customInspect:!1}))}}]),g}()},{buffer:3,util:2}],66:[function(y,k,x){(function(d){(function(){"use strict";function f(e,t){var o=this,l=this._readableState&&this._readableState.destroyed,p=this._writableState&&this._writableState.destroyed;return l||p?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,d.nextTick(i,this,e)):d.nextTick(i,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(g){!t&&g?o._writableState?o._writableState.errorEmitted?d.nextTick(h,o):(o._writableState.errorEmitted=!0,d.nextTick(m,o,g)):d.nextTick(m,o,g):t?(d.nextTick(h,o),t(g)):d.nextTick(h,o)}),this)}function m(e,t){i(e,t),h(e)}function h(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function s(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function i(e,t){e.emit("error",t)}function r(e,t){var o=e._readableState,l=e._writableState;o&&o.autoDestroy||l&&l.autoDestroy?e.destroy(t):e.emit("error",t)}k.exports={destroy:f,undestroy:s,errorOrDestroy:r}}).call(this)}).call(this,y("_process"))},{_process:85}],67:[function(y,k,x){"use strict";var d=y("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function f(i){var r=!1;return function(){if(!r){r=!0;for(var e=arguments.length,t=new Array(e),o=0;o0;return e(W,I,P,function(S){R||(R=S),S&&A.forEach(t),!I&&(A.forEach(t),v(R))})});return _.reduce(o)}k.exports=p},{"../../../errors":58,"./end-of-stream":67}],70:[function(y,k,x){"use strict";var d=y("../../../errors").codes.ERR_INVALID_OPT_VALUE;function f(h,s,i){return h.highWaterMark!=null?h.highWaterMark:s?h[i]:null}function m(h,s,i,r){var e=f(s,r,i);if(e!=null){if(!(isFinite(e)&&Math.floor(e)===e)||e<0){var t=r?i:"highWaterMark";throw new d(t,e)}return Math.floor(e)}return h.objectMode?16:16*1024}k.exports={getHighWaterMark:m}},{"../../../errors":58}],71:[function(y,k,x){k.exports=y("events").EventEmitter},{events:4}],72:[function(y,k,x){x=k.exports=y("./lib/_stream_readable.js"),x.Stream=x,x.Readable=x,x.Writable=y("./lib/_stream_writable.js"),x.Duplex=y("./lib/_stream_duplex.js"),x.Transform=y("./lib/_stream_transform.js"),x.PassThrough=y("./lib/_stream_passthrough.js"),x.finished=y("./lib/internal/streams/end-of-stream.js"),x.pipeline=y("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":59,"./lib/_stream_passthrough.js":60,"./lib/_stream_readable.js":61,"./lib/_stream_transform.js":62,"./lib/_stream_writable.js":63,"./lib/internal/streams/end-of-stream.js":67,"./lib/internal/streams/pipeline.js":69}],73:[function(y,k,x){"use strict";function d(m,h,s){var i=this;this._callback=m,this._args=s,this._interval=setInterval(m,h,this._args),this.reschedule=function(r){r||(r=i._interval),i._interval&&clearInterval(i._interval),i._interval=setInterval(i._callback,r,i._args)},this.clear=function(){i._interval&&(clearInterval(i._interval),i._interval=void 0)},this.destroy=function(){i._interval&&clearInterval(i._interval),i._callback=void 0,i._interval=void 0,i._args=void 0}}function f(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("interval needed");var m;if(arguments.length>0){m=new Array(arguments.length-2);for(var h=0;h>5===6?2:A>>4===14?3:A>>3===30?4:A>>6===2?-1:-2}function r(A,W,j){var I=W.length-1;if(I=0?(P>0&&(A.lastNeed=P-1),P):--I=0?(P>0&&(A.lastNeed=P-2),P):--I=0?(P>0&&(P===2?P=0:A.lastNeed=P-3),P):0))}function e(A,W,j){if((W[0]&192)!==128)return A.lastNeed=0,"\uFFFD";if(A.lastNeed>1&&W.length>1){if((W[1]&192)!==128)return A.lastNeed=1,"\uFFFD";if(A.lastNeed>2&&W.length>2&&(W[2]&192)!==128)return A.lastNeed=2,"\uFFFD"}}function t(A){var W=this.lastTotal-this.lastNeed,j=e(this,A,W);if(j!==void 0)return j;if(this.lastNeed<=A.length)return A.copy(this.lastChar,W,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);A.copy(this.lastChar,W,0,A.length),this.lastNeed-=A.length}function o(A,W){var j=r(this,A,W);if(!this.lastNeed)return A.toString("utf8",W);this.lastTotal=j;var I=A.length-(j-this.lastNeed);return A.copy(this.lastChar,0,I),A.toString("utf8",W,I)}function l(A){var W=A&&A.length?this.write(A):"";return this.lastNeed?W+"\uFFFD":W}function p(A,W){if((A.length-W)%2===0){var j=A.toString("utf16le",W);if(j){var I=j.charCodeAt(j.length-1);if(I>=55296&&I<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=A[A.length-2],this.lastChar[1]=A[A.length-1],j.slice(0,-1)}return j}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=A[A.length-1],A.toString("utf16le",W,A.length-1)}function g(A){var W=A&&A.length?this.write(A):"";if(this.lastNeed){var j=this.lastTotal-this.lastNeed;return W+this.lastChar.toString("utf16le",0,j)}return W}function _(A,W){var j=(A.length-W)%3;return j===0?A.toString("base64",W):(this.lastNeed=3-j,this.lastTotal=3,j===1?this.lastChar[0]=A[A.length-1]:(this.lastChar[0]=A[A.length-2],this.lastChar[1]=A[A.length-1]),A.toString("base64",W,A.length-j))}function c(A){var W=A&&A.length?this.write(A):"";return this.lastNeed?W+this.lastChar.toString("base64",0,3-this.lastNeed):W}function v(A){return A.toString(this.encoding)}function R(A){return A&&A.length?this.write(A):""}},{"safe-buffer":76}],79:[function(y,k,x){(function(d){(function(){k.exports=f;function f(h,s){if(m("noDeprecation"))return h;var i=!1;function r(){if(!i){if(m("throwDeprecation"))throw new Error(s);m("traceDeprecation")?console.trace(s):console.warn(s),i=!0}return h.apply(this,arguments)}return r}function m(h){try{if(!d.localStorage)return!1}catch{return!1}var s=d.localStorage[h];return s==null?!1:String(s).toLowerCase()==="true"}}).call(this)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],80:[function(y,k,x){k.exports=d;function d(f,m){if(f&&m)return d(f)(m);if(typeof f!="function")throw new TypeError("need wrapper function");return Object.keys(f).forEach(function(s){h[s]=f[s]}),h;function h(){for(var s=new Array(arguments.length),i=0;i0)for(var e=0,t=arguments.length;e1)e=r;else if(this.head)t=this.head.next,e=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=0;t!==null;o++)e=i(e,t.value,o),t=t.next;return e},d.prototype.reduceReverse=function(i,r){var e,t=this.tail;if(arguments.length>1)e=r;else if(this.tail)t=this.tail.prev,e=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=this.length-1;t!==null;o--)e=i(e,t.value,o),t=t.prev;return e},d.prototype.toArray=function(){for(var i=new Array(this.length),r=0,e=this.head;e!==null;r++)i[r]=e.value,e=e.next;return i},d.prototype.toArrayReverse=function(){for(var i=new Array(this.length),r=0,e=this.tail;e!==null;r++)i[r]=e.value,e=e.prev;return i},d.prototype.slice=function(i,r){r=r||this.length,r<0&&(r+=this.length),i=i||0,i<0&&(i+=this.length);var e=new d;if(rthis.length&&(r=this.length);for(var t=0,o=this.head;o!==null&&tthis.length&&(r=this.length);for(var t=this.length,o=this.tail;o!==null&&t>r;t--)o=o.prev;for(;o!==null&&t>i;t--,o=o.prev)e.push(o.value);return e},d.prototype.splice=function(i,r,...e){i>this.length&&(i=this.length-1),i<0&&(i=this.length+i);for(var t=0,o=this.head;o!==null&&t1)for(var A=1;A= 0x80 (not a basic code point)","invalid-input":"Invalid input"},j=e-t,I=Math.floor,P=String.fromCharCode,S;function V(H){throw new RangeError(W[H])}function M(H,D){for(var X=H.length,$=[];X--;)$[X]=D(H[X]);return $}function ne(H,D){var X=H.split("@"),$="";X.length>1&&($=X[0]+"@",H=X[1]),H=H.replace(A,".");var oe=H.split("."),Z=M(oe,D).join(".");return $+Z}function se(H){for(var D=[],X=0,$=H.length,oe,Z;X<$;)oe=H.charCodeAt(X++),oe>=55296&&oe<=56319&&X<$?(Z=H.charCodeAt(X++),(Z&64512)==56320?D.push(((oe&1023)<<10)+(Z&1023)+65536):(D.push(oe),X--)):D.push(oe);return D}function ie(H){return M(H,function(D){var X="";return D>65535&&(D-=65536,X+=P(D>>>10&1023|55296),D=56320|D&1023),X+=P(D),X}).join("")}function G(H){return H-48<10?H-22:H-65<26?H-65:H-97<26?H-97:e}function E(H,D){return H+22+75*(H<26)-((D!=0)<<5)}function T(H,D,X){var $=0;for(H=X?I(H/p):H>>1,H+=I(H/D);H>j*o>>1;$+=e)H=I(H/j);return I($+(j+1)*H/(H+l))}function U(H){var D=[],X=H.length,$,oe=0,Z=_,F=g,B,Y,te,O,C,N,z,Q,w;for(B=H.lastIndexOf(c),B<0&&(B=0),Y=0;Y=128&&V("not-basic"),D.push(H.charCodeAt(Y));for(te=B>0?B+1:0;te=X&&V("invalid-input"),z=G(H.charCodeAt(te++)),(z>=e||z>I((r-oe)/C))&&V("overflow"),oe+=z*C,Q=N<=F?t:N>=F+o?o:N-F,!(zI(r/w)&&V("overflow"),C*=w;$=D.length+1,F=T(oe-O,$,O==0),I(oe/$)>r-Z&&V("overflow"),Z+=I(oe/$),oe%=$,D.splice(oe++,0,Z)}return ie(D)}function q(H){var D,X,$,oe,Z,F,B,Y,te,O,C,N=[],z,Q,w,u;for(H=se(H),z=H.length,D=_,X=0,Z=g,F=0;F=D&&CI((r-X)/Q)&&V("overflow"),X+=(B-D)*Q,D=B,F=0;Fr&&V("overflow"),C==D){for(Y=X,te=e;O=te<=Z?t:te>=Z+o?o:te-Z,!(Y0&&o>t&&(o=t);for(var l=0;l=0?(_=p.substr(0,g),c=p.substr(g+1)):(_=p,c=""),v=decodeURIComponent(_),R=decodeURIComponent(c),d(r,v)?f(r[v])?r[v].push(R):r[v]=[r[v],R]:r[v]=R}return r};var f=Array.isArray||function(m){return Object.prototype.toString.call(m)==="[object Array]"}},{}],88:[function(y,k,x){"use strict";var d=function(s){switch(typeof s){case"string":return s;case"boolean":return s?"true":"false";case"number":return isFinite(s)?s:"";default:return""}};k.exports=function(s,i,r,e){return i=i||"&",r=r||"=",s===null&&(s=void 0),typeof s=="object"?m(h(s),function(t){var o=encodeURIComponent(d(t))+r;return f(s[t])?m(s[t],function(l){return o+encodeURIComponent(d(l))}).join(i):o+encodeURIComponent(d(s[t]))}).join(i):e?encodeURIComponent(d(e))+r+encodeURIComponent(d(s)):""};var f=Array.isArray||function(s){return Object.prototype.toString.call(s)==="[object Array]"};function m(s,i){if(s.map)return s.map(i);for(var r=[],e=0;e",'"',"`"," ","\r",` `," "],e=["{","}","|","\\","^","`"].concat(r),t=["'"].concat(e),o=["%","/","?",";","#"].concat(t),l=["/","?","#"],p=255,g=/^[+a-z0-9A-Z_-]{0,63}$/,_=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,c={javascript:!0,"javascript:":!0},v={javascript:!0,"javascript:":!0},R={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},A=y("querystring");function W(S,V,M){if(S&&f.isObject(S)&&S instanceof m)return S;var ne=new m;return ne.parse(S,V,M),ne}m.prototype.parse=function(S,V,M){if(!f.isString(S))throw new TypeError("Parameter 'url' must be a string, not "+typeof S);var ne=S.indexOf("?"),se=ne!==-1&&ne127?Y+="x":Y+=B[te];if(!Y.match(g)){var C=Z.slice(0,H),N=Z.slice(H+1),z=B.match(_);z&&(C.push(z[1]),N.unshift(z[2])),N.length&&(E="/"+N.join(".")+E),this.hostname=C.join(".");break}}}this.hostname.length>p?this.hostname="":this.hostname=this.hostname.toLowerCase(),oe||(this.hostname=d.toASCII(this.hostname));var Q=this.port?":"+this.port:"",w=this.hostname||"";this.host=w+Q,this.href+=this.host,oe&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),E[0]!=="/"&&(E="/"+E))}if(!c[q])for(var H=0,F=t.length;H0?M.host.split("@"):!1;Y&&(M.auth=Y.shift(),M.host=M.hostname=Y.shift())}return M.search=S.search,M.query=S.query,(!f.isNull(M.pathname)||!f.isNull(M.search))&&(M.path=(M.pathname?M.pathname:"")+(M.search?M.search:"")),M.href=M.format(),M}if(!Z.length)return M.pathname=null,M.search?M.path="/"+M.search:M.path=null,M.href=M.format(),M;for(var te=Z.slice(-1)[0],O=(M.host||S.host||Z.length>1)&&(te==="."||te==="..")||te==="",C=0,N=Z.length;N>=0;N--)te=Z[N],te==="."?Z.splice(N,1):te===".."?(Z.splice(N,1),C++):C&&(Z.splice(N,1),C--);if(!$&&!oe)for(;C--;C)Z.unshift("..");$&&Z[0]!==""&&(!Z[0]||Z[0].charAt(0)!=="/")&&Z.unshift(""),O&&Z.join("/").substr(-1)!=="/"&&Z.push("");var z=Z[0]===""||Z[0]&&Z[0].charAt(0)==="/";if(B){M.hostname=M.host=z?"":Z.length?Z.shift():"";var Y=M.host&&M.host.indexOf("@")>0?M.host.split("@"):!1;Y&&(M.auth=Y.shift(),M.host=M.hostname=Y.shift())}return $=$||M.host&&Z.length,$&&!z&&Z.unshift(""),Z.length?M.pathname=Z.join("/"):(M.pathname=null,M.path=null),(!f.isNull(M.pathname)||!f.isNull(M.search))&&(M.path=(M.pathname?M.pathname:"")+(M.search?M.search:"")),M.auth=S.auth||M.auth,M.slashes=M.slashes||S.slashes,M.href=M.format(),M},m.prototype.parseHost=function(){var S=this.host,V=s.exec(S);V&&(V=V[0],V!==":"&&(this.port=V.substr(1)),S=S.substr(0,S.length-V.length)),S&&(this.hostname=S)}},{"./util":91,punycode:86,querystring:89}],91:[function(y,k,x){"use strict";k.exports={isString:function(d){return typeof d=="string"},isObject:function(d){return typeof d=="object"&&d!==null},isNull:function(d){return d===null},isNullOrUndefined:function(d){return d==null}}},{}]},{},[17])(17)})});function sr(ue,he){if(ue&1){let de=rt();Ae(0,"li",9)(1,"label",10),it("ngModelChange",function(k){let d=ke(de).$implicit;return Ne(d.checked=k)})("ngModelChange",function(){ke(de);let k=Ue(2);return Ne(k.onCheckChange())}),Fe(2),Se()()}if(ue&2){let de=he.$implicit;_e(),Ce("ngModel",de.checked),_e(),De(de.label)}}function or(ue,he){if(ue&1&&(Ae(0,"div",4),tt(1,"a",5),Ae(2,"nz-dropdown-menu",null,6)(4,"ul",7),Le(5,sr,3,2,"li",8),Se()()()),ue&2){let de=ot(3),y=Ue();_e(),Ce("nzDropdownMenu",de),_e(4),Ce("ngForOf",y.optionsList)}}var ar=["*"],ti=(()=>{let he=class he{constructor(){this.showSetting=!1,this.optionsList=[],this.onCheckedItemsChange=new ge,this.title=""}getCheckedItems(){return this.optionsList.filter(y=>y.checked)}onCheckChange(){let y=this.getCheckedItems();this.onCheckedItemsChange.emit(y)}};he.\u0275fac=function(k){return new(k||he)},he.\u0275cmp=et({type:he,selectors:[["data-v-card"]],inputs:{showSetting:"showSetting",optionsList:"optionsList",title:"title"},outputs:{onCheckedItemsChange:"onCheckedItemsChange"},standalone:!0,features:[at],ngContentSelectors:ar,decls:6,vars:2,consts:[[1,"card-content"],[1,"card-content-title"],[1,"card-content-l"],["class","card-content-r",4,"ngIf"],[1,"card-content-r"],["nz-dropdown","","nz-icon","","nzType","setting","nzTrigger","click","nzTheme","outline",3,"nzDropdownMenu"],["menu","nzDropdownMenu"],["nz-menu","","nzSelectable",""],["nz-menu-item","",4,"ngFor","ngForOf"],["nz-menu-item",""],["nz-checkbox","",3,"ngModel","ngModelChange"]],template:function(k,x){k&1&&(nt(),Ae(0,"div",0)(1,"div",1)(2,"div",2),Fe(3),Se(),Le(4,or,6,2,"div",3),Se(),st(5),Se()),k&2&&(_e(3),De(x.title),_e(),Ce("ngIf",x.showSetting))},dependencies:[ft,ct,ht,ut,lt,Pt,Ct,It,At,Tt,Rt,bt,_t,wt,vt,Kt,Dt,Qt,Gt,Yt,qt,yt,Lt,Ft,er,Vt,Wt,jt,dt,pt,kt,Nt,$t,Zt,Ot,Jt,Ht,Ut,Mt,Xt,mt,gt,zt,xt,St,Et,Bt],styles:['.card-content[_ngcontent-%COMP%]{overflow:hidden;padding:1rem 1.5rem;background-image:url("./media/dashboard_card_bg-2QFDBQFD.jpg");background-position:top;background-size:cover;margin-bottom:.5rem}.card-content[_ngcontent-%COMP%] .card-content-title[_ngcontent-%COMP%]{display:flex;margin-bottom:.5rem;font-size:18px;font-weight:600;color:#74fafb}.card-content[_ngcontent-%COMP%] .card-content-title[_ngcontent-%COMP%] .card-content-l[_ngcontent-%COMP%]{align-self:flex-start;flex:1}.card-content[_ngcontent-%COMP%] .card-content-title[_ngcontent-%COMP%] .card-content-r[_ngcontent-%COMP%]{align-self:flex-end}']});let ue=he;return ue})();var ci=Ve(We(),1),rr=Ve(We(),1);var xe=function(ue){return ue[ue.CLOSED=0]="CLOSED",ue[ue.CONNECTING=1]="CONNECTING",ue[ue.CONNECTED=2]="CONNECTED",ue}(xe||{});var ur=new Be("NgxMqttServiceConfig"),lr=new Be("NgxMqttClientService");function Pe(ue,...he){if(!he.length)return ue;let de=he.shift();if(He(ue)&&He(de))for(let y in de)He(de[y])?(ue[y]||Object.assign(ue,{[y]:{}}),Pe(ue[y],de[y])):Object.assign(ue,{[y]:de[y]});return Pe(ue,...he)}function He(ue){return ue&&typeof ue=="object"&&!Array.isArray(ue)}var di=(()=>{let he=class he{constructor(y,k){this.options=y,this.observables={},this.state=new Ye(xe.CLOSED),this.messages=new Oe,this._clientId=this._generateClientId(),this._connectTimeout=1e4,this._reconnectPeriod=1e4,this._onConnect=new ge,this._onReconnect=new ge,this._onClose=new ge,this._onOffline=new ge,this._onError=new ge,this._onEnd=new ge,this._onMessage=new ge,this._onSuback=new ge,this._onPacketsend=new ge,this._onPacketreceive=new ge,this._handleOnConnect=x=>{this.options.connectOnCreate===!0&&Object.keys(this.observables).forEach(d=>{this.client.subscribe(d)}),this.state.next(xe.CONNECTED),this._onConnect.emit(x)},this._handleOnReconnect=()=>{this.options.connectOnCreate===!0&&Object.keys(this.observables).forEach(x=>{this.client.subscribe(x)}),this.state.next(xe.CONNECTING),this._onReconnect.emit()},this._handleOnClose=()=>{this.state.next(xe.CLOSED),this._onClose.emit()},this._handleOnOffline=()=>{this._onOffline.emit()},this._handleOnError=x=>{this._onError.emit(x),console.error(x)},this._handleOnEnd=()=>{this._onEnd.emit()},this._handleOnMessage=(x,d,f)=>{this._onMessage.emit(f),f.cmd==="publish"&&this.messages.next(f)},this._handleOnPacketsend=x=>{this._onPacketsend.emit(x)},this._handleOnPacketreceive=x=>{this._onPacketreceive.emit(x)},y.connectOnCreate!==!1&&this.connect({},k),this.state.subscribe()}get clientId(){return this._clientId}get onConnect(){return this._onConnect}get onReconnect(){return this._onReconnect}get onClose(){return this._onClose}get onOffline(){return this._onOffline}get onError(){return this._onError}get onEnd(){return this._onEnd}get onMessage(){return this._onMessage}get onPacketsend(){return this._onPacketsend}get onPacketreceive(){return this._onPacketreceive}get onSuback(){return this._onSuback}static filterMatchesTopic(y,k){if(y[0]==="#"&&k[0]==="$")return!1;let x=(y||"").split("/").reverse(),d=(k||"").split("/").reverse(),f=()=>{let m=x.pop(),h=d.pop();switch(m){case"#":return!0;case"+":return h?f():!1;default:return m===h&&(m===void 0?!0:f())}};return f()}connect(y,k){let x=Pe(this.options||{},y),d=x.protocol||"ws",f=x.hostname||"localhost";x.url?this._url=x.url:(this._url=`${d}://${f}`,this._url+=x.port?`:${x.port}`:"",this._url+=x.path?`${x.path}`:""),this.state.next(xe.CONNECTING);let m=Pe({clientId:this._clientId,reconnectPeriod:this._reconnectPeriod,connectTimeout:this._connectTimeout},x);this.client&&this.client.end(!0),k?this.client=k:this.client=(0,rr.connect)(this._url,m),this._clientId=m.clientId,this.client.on("connect",this._handleOnConnect),this.client.on("reconnect",this._handleOnReconnect),this.client.on("close",this._handleOnClose),this.client.on("offline",this._handleOnOffline),this.client.on("error",this._handleOnError),this.client.stream.on("error",this._handleOnError),this.client.on("end",this._handleOnEnd),this.client.on("message",this._handleOnMessage),this.client.on("packetsend",this._handleOnPacketsend),this.client.on("packetreceive",this._handleOnPacketreceive)}disconnect(y=!0){if(!this.client)throw new Error("mqtt client not connected");this.client.end(y)}observeRetained(y,k={qos:1}){return this._generalObserve(y,()=>Xe(1),k)}observe(y,k={qos:1}){return this._generalObserve(y,()=>Je(),k)}_generalObserve(y,k,x){if(!this.client)throw new Error("mqtt client not connected");if(!this.observables[y]){let d=new Oe;this.observables[y]=$e(()=>{let f=new qe;return this.client.subscribe(y,x,(m,h)=>{h&&h.forEach(s=>{s.qos===128&&(delete this.observables[s.topic],this.client.unsubscribe(s.topic),d.error(`subscription for '${s.topic}' rejected!`)),this._onSuback.emit({filter:y,granted:s.qos!==128})})}),f.add(()=>{delete this.observables[y],this.client.unsubscribe(y)}),f},f=>Qe(d,this.messages)).pipe(Ge(f=>he.filterMatchesTopic(y,f.topic)),k(),Ke())}return this.observables[y]}publish(y,k,x={}){if(!this.client)throw new Error("mqtt client not connected");return ze.create(d=>{this.client.publish(y,k,x,f=>{f?d.error(f):(d.next(),d.complete())})})}unsafePublish(y,k,x={}){if(!this.client)throw new Error("mqtt client not connected");this.client.publish(y,k,x,d=>{if(d)throw d})}_generateClientId(){return"client-"+Math.random().toString(36).substr(2,19)}};he.\u0275fac=function(k){return new(k||he)(Me(ur),Me(lr))},he.\u0275prov=Ze({token:he,factory:he.\u0275fac,providedIn:"root"});let ue=he;return ue})();export{ti as a,di as b};