qiscus-sdk-core 2.16.0 → 2.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,27 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("QiscusSDKCore",[],t):"object"==typeof exports?exports.QiscusSDKCore=t():e.QiscusSDKCore=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=127)}([function(e,t,r){var n=r(132)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},function(e,t,r){var n=r(141),o=r(33),i=/[T ]/,s=/:/,a=/^(\d{2})$/,u=[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],c=/^(\d{4})/,l=[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],f=/^-(\d{2})$/,p=/^-?(\d{3})$/,h=/^-?(\d{2})-?(\d{2})$/,d=/^-?W(\d{2})$/,m=/^-?W(\d{2})-?(\d{1})$/,y=/^(\d{2}([.,]\d*)?)$/,g=/^(\d{2}):?(\d{2}([.,]\d*)?)$/,v=/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,b=/([Z+-].*)$/,_=/^(Z)$/,w=/^([+-])(\d{2})$/,k=/^([+-])(\d{2}):?(\d{2})$/;function S(e,t,r){t=t||0,r=r||0;var n=new Date(0);n.setUTCFullYear(e,0,4);var o=7*t+r+1-(n.getUTCDay()||7);return n.setUTCDate(n.getUTCDate()+o),n}e.exports=function(e,t){if(o(e))return new Date(e.getTime());if("string"!=typeof e)return new Date(e);var r=(t||{}).additionalDigits;r=null==r?2:Number(r);var x=function(e){var t,r={},n=e.split(i);s.test(n[0])?(r.date=null,t=n[0]):(r.date=n[0],t=n[1]);if(t){var o=b.exec(t);o?(r.time=t.replace(o[1],""),r.timezone=o[1]):r.time=t}return r}(e),E=function(e,t){var r,n=u[t],o=l[t];if(r=c.exec(e)||o.exec(e)){var i=r[1];return{year:parseInt(i,10),restDateString:e.slice(i.length)}}if(r=a.exec(e)||n.exec(e)){var s=r[1];return{year:100*parseInt(s,10),restDateString:e.slice(s.length)}}return{year:null}}(x.date,r),T=E.year,A=function(e,t){if(null===t)return null;var r,n,o,i;if(0===e.length)return(n=new Date(0)).setUTCFullYear(t),n;if(r=f.exec(e))return n=new Date(0),o=parseInt(r[1],10)-1,n.setUTCFullYear(t,o),n;if(r=p.exec(e)){n=new Date(0);var s=parseInt(r[1],10);return n.setUTCFullYear(t,0,s),n}if(r=h.exec(e)){n=new Date(0),o=parseInt(r[1],10)-1;var a=parseInt(r[2],10);return n.setUTCFullYear(t,o,a),n}if(r=d.exec(e))return i=parseInt(r[1],10)-1,S(t,i);if(r=m.exec(e)){i=parseInt(r[1],10)-1;var u=parseInt(r[2],10)-1;return S(t,i,u)}return null}(E.restDateString,T);if(A){var I,C=A.getTime(),O=0;if(x.time&&(O=function(e){var t,r,n;if(t=y.exec(e))return(r=parseFloat(t[1].replace(",",".")))%24*36e5;if(t=g.exec(e))return r=parseInt(t[1],10),n=parseFloat(t[2].replace(",",".")),r%24*36e5+6e4*n;if(t=v.exec(e)){r=parseInt(t[1],10),n=parseInt(t[2],10);var o=parseFloat(t[3].replace(",","."));return r%24*36e5+6e4*n+1e3*o}return null}(x.time)),x.timezone)I=6e4*function(e){var t,r;if(t=_.exec(e))return 0;if(t=w.exec(e))return r=60*parseInt(t[2],10),"+"===t[1]?-r:r;if(t=k.exec(e))return r=60*parseInt(t[2],10)+parseInt(t[3],10),"+"===t[1]?-r:r;return 0}(x.timezone);else{var R=C+O,P=new Date(R);I=n(P);var M=new Date(R);M.setDate(P.getDate()+1);var D=n(M)-n(P);D>0&&(I+=D)}return new Date(C+O+I)}return new Date(e)}},function(e,t){function r(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var s=e.apply(t,n);function a(e){r(s,o,i,a,u,"next",e)}function u(e){r(s,o,i,a,u,"throw",e)}a(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(57);e.exports=function(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(57);function o(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,n(o.key),o)}}e.exports=function(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n;"undefined"!=typeof window?n=window:"undefined"!=typeof self?n=self:(console.warn("Using browser-only version of superagent in non-browser environment"),n=this);var o=r(136),i=r(137),s=r(62),a=r(138),u=r(140);function c(){}var l=t=e.exports=function(e,r){return"function"==typeof r?new t.Request("GET",e).end(r):1==arguments.length?new t.Request("GET",e):new t.Request(e,r)};t.Request=g,l.getXHR=function(){if(!(!n.XMLHttpRequest||n.location&&"file:"==n.location.protocol&&n.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}throw Error("Browser-only version of superagent could not find XHR")};var f="".trim?function(e){return e.trim()}:function(e){return e.replace(/(^\s*|\s*$)/g,"")};function p(e){if(!s(e))return e;var t=[];for(var r in e)h(t,r,e[r]);return t.join("&")}function h(e,t,r){if(null!=r)if(Array.isArray(r))r.forEach((function(r){h(e,t,r)}));else if(s(r))for(var n in r)h(e,t+"["+n+"]",r[n]);else e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));else null===r&&e.push(encodeURIComponent(t))}function d(e){for(var t,r,n={},o=e.split("&"),i=0,s=o.length;i<s;++i)-1==(r=(t=o[i]).indexOf("="))?n[decodeURIComponent(t)]="":n[decodeURIComponent(t.slice(0,r))]=decodeURIComponent(t.slice(r+1));return n}function m(e){return/[\/+]json($|[^-\w])/.test(e)}function y(e){this.req=e,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var t=this.xhr.status;1223===t&&(t=204),this._setStatusProperties(t),this.header=this.headers=function(e){for(var t,r,n,o,i=e.split(/\r?\n/),s={},a=0,u=i.length;a<u;++a)-1!==(t=(r=i[a]).indexOf(":"))&&(n=r.slice(0,t).toLowerCase(),o=f(r.slice(t+1)),s[n]=o);return s}(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&e._responseType?this.body=this.xhr.response:this.body="HEAD"!=this.req.method?this._parseBody(this.text?this.text:this.xhr.response):null}function g(e,t){var r=this;this._query=this._query||[],this.method=e,this.url=t,this.header={},this._header={},this.on("end",(function(){var e,t=null,n=null;try{n=new y(r)}catch(e){return(t=new Error("Parser is unable to parse the response")).parse=!0,t.original=e,r.xhr?(t.rawResponse=void 0===r.xhr.responseType?r.xhr.responseText:r.xhr.response,t.status=r.xhr.status?r.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),r.callback(t)}r.emit("response",n);try{r._isResponseOK(n)||(e=new Error(n.statusText||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=n,e.status=n.status,r.callback(e,n)):r.callback(null,n)}))}function v(e,t,r){var n=l("DELETE",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}l.serializeObject=p,l.parseString=d,l.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},l.serialize={"application/x-www-form-urlencoded":p,"application/json":JSON.stringify},l.parse={"application/x-www-form-urlencoded":d,"application/json":JSON.parse},a(y.prototype),y.prototype._parseBody=function(e){var t=l.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&m(this.type)&&(t=l.parse["application/json"]),t&&e&&(e.length||e instanceof Object)?t(e):null)},y.prototype.toError=function(){var e=this.req,t=e.method,r=e.url,n="cannot "+t+" "+r+" ("+this.status+")",o=new Error(n);return o.status=this.status,o.method=t,o.url=r,o},l.Response=y,o(g.prototype),i(g.prototype),g.prototype.type=function(e){return this.set("Content-Type",l.types[e]||e),this},g.prototype.accept=function(e){return this.set("Accept",l.types[e]||e),this},g.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var n=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,n)},g.prototype.query=function(e){return"string"!=typeof e&&(e=p(e)),e&&this._query.push(e),this},g.prototype.attach=function(e,t,r){if(t){if(this._data)throw Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,r||t.name)}return this},g.prototype._getFormData=function(){return this._formData||(this._formData=new n.FormData),this._formData},g.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var r=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),r(e,t)},g.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},g.prototype.buffer=g.prototype.ca=g.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},g.prototype.pipe=g.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},g.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},g.prototype.end=function(e){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||c,this._finalizeQueryString(),this._end()},g.prototype._end=function(){var e=this,t=this.xhr=l.getXHR(),r=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var r=t.readyState;if(r>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4==r){var n;try{n=t.status}catch(e){n=0}if(!n){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var n=function(t,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=t,e.emit("progress",r)};if(this.hasListeners("progress"))try{t.onprogress=n.bind(null,"download"),t.upload&&(t.upload.onprogress=n.bind(null,"upload"))}catch(e){}try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var o=this._header["content-type"],i=this._serializer||l.serialize[o?o.split(";")[0]:""];!i&&m(o)&&(i=l.serialize["application/json"]),i&&(r=i(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&t.setRequestHeader(s,this.header[s]);return this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0!==r?r:null),this},l.agent=function(){return new u},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){u.prototype[e.toLowerCase()]=function(t,r){var n=new l.Request(e,t);return this._setDefaults(n),r&&n.end(r),n}})),u.prototype.del=u.prototype.delete,l.get=function(e,t,r){var n=l("GET",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},l.head=function(e,t,r){var n=l("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},l.options=function(e,t,r){var n=l("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},l.del=v,l.delete=v,l.patch=function(e,t,r){var n=l("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},l.post=function(e,t,r){var n=l("POST",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},l.put=function(e,t,r){var n=l("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}},function(e,t,r){"use strict";(function(e){
2
- /*!
1
+ (function(Le,Me){typeof exports=="object"&&typeof module!="undefined"?module.exports=Me():typeof define=="function"&&define.amd?define("QiscusSDKCore",Me):(Le=typeof globalThis!="undefined"?globalThis:Le||self,Le.QiscusSDKCore=Me())})(this,(function(){"use strict";var uv=Object.defineProperty,fv=Object.defineProperties;var lv=Object.getOwnPropertyDescriptors;var Vp=Object.getOwnPropertySymbols;var cv=Object.prototype.hasOwnProperty,hv=Object.prototype.propertyIsEnumerable;var Za=(Le,Me)=>(Me=Symbol[Le])?Me:Symbol.for("Symbol."+Le);var Oe=Math.pow,eu=(Le,Me,xe)=>Me in Le?uv(Le,Me,{enumerable:!0,configurable:!0,writable:!0,value:xe}):Le[Me]=xe,br=(Le,Me)=>{for(var xe in Me||(Me={}))cv.call(Me,xe)&&eu(Le,xe,Me[xe]);if(Vp)for(var xe of Vp(Me))hv.call(Me,xe)&&eu(Le,xe,Me[xe]);return Le},wr=(Le,Me)=>fv(Le,lv(Me));var He=(Le,Me,xe)=>eu(Le,typeof Me!="symbol"?Me+"":Me,xe);var ke=(Le,Me,xe)=>new Promise((rt,ut)=>{var et=Xe=>{try{tt(xe.next(Xe))}catch(nt){ut(nt)}},it=Xe=>{try{tt(xe.throw(Xe))}catch(nt){ut(nt)}},tt=Xe=>Xe.done?rt(Xe.value):Promise.resolve(Xe.value).then(et,it);tt((xe=xe.apply(Le,Me)).next())}),Sr=function(Le,Me){this[0]=Le,this[1]=Me},tu=(Le,Me,xe)=>{var rt=(it,tt,Xe,nt)=>{try{var Lt=xe[it](tt),Ft=(tt=Lt.value)instanceof Sr,Ut=Lt.done;Promise.resolve(Ft?tt[0]:tt).then(ft=>Ft?rt(it==="return"?it:"next",tt[1]?{done:ft.done,value:ft.value}:ft,Xe,nt):Xe({value:ft,done:Ut})).catch(ft=>rt("throw",ft,Xe,nt))}catch(ft){nt(ft)}},ut=it=>et[it]=tt=>new Promise((Xe,nt)=>rt(it,tt,Xe,nt)),et={};return xe=xe.apply(Le,Me),et[Za("asyncIterator")]=()=>et,ut("next"),ut("throw"),ut("return"),et};var ru=(Le,Me,xe)=>(Me=Le[Za("asyncIterator")])?Me.call(Le):(Le=Le[Za("iterator")](),Me={},xe=(rt,ut)=>(ut=Le[rt])&&(Me[rt]=et=>new Promise((it,tt,Xe)=>(et=ut.call(Le,et),Xe=et.done,Promise.resolve(et.value).then(nt=>it({value:nt,done:Xe}),tt)))),xe("next"),xe("return"),Me);let Le="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Me=(i=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(i|=0));for(;i--;)e+=Le[t[i]&63];return e};var xe=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function rt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function ut(i){if(Object.prototype.hasOwnProperty.call(i,"__esModule"))return i;var e=i.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(i).forEach(function(r){var n=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return i[r]}})}),t}var et={exports:{}},it={exports:{}},tt;function Xe(){return tt||(tt=1,(function(i){i.exports=e;function e(r){if(r)return t(r)}function t(r){for(var n in e.prototype)r[n]=e.prototype[n];return r}e.prototype.on=e.prototype.addEventListener=function(r,n){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(n),this},e.prototype.once=function(r,n){function o(){this.off(r,o),n.apply(this,arguments)}return o.fn=n,this.on(r,o),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(r,n){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var o=this._callbacks["$"+r];if(!o)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var u,a=0;a<o.length;a++)if(u=o[a],u===n||u.fn===n){o.splice(a,1);break}return o.length===0&&delete this._callbacks["$"+r],this},e.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var n=new Array(arguments.length-1),o=this._callbacks["$"+r],u=1;u<arguments.length;u++)n[u-1]=arguments[u];if(o){o=o.slice(0);for(var u=0,a=o.length;u<a;++u)o[u].apply(this,n)}return this},e.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]},e.prototype.hasListeners=function(r){return!!this.listeners(r).length}})(it)),it.exports}var nt,Lt;function Ft(){if(Lt)return nt;Lt=1;function i(e){return e!==null&&typeof e=="object"}return nt=i,nt}var Ut,ft;function Kp(){if(ft)return Ut;ft=1;var i=Ft();Ut=e;function e(n){if(n)return t(n)}function t(n){for(var o in e.prototype)n[o]=e.prototype[o];return n}e.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},e.prototype.parse=function(o){return this._parser=o,this},e.prototype.responseType=function(n){return this._responseType=n,this},e.prototype.serialize=function(o){return this._serializer=o,this},e.prototype.timeout=function(o){if(!o||typeof o!="object")return this._timeout=o,this._responseTimeout=0,this;for(var u in o)switch(u){case"deadline":this._timeout=o.deadline;break;case"response":this._responseTimeout=o.response;break;default:console.warn("Unknown timeout option",u)}return this},e.prototype.retry=function(o,u){return(arguments.length===0||o===!0)&&(o=1),o<=0&&(o=0),this._maxRetries=o,this._retries=0,this._retryCallback=u,this};var r=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];return e.prototype._shouldRetry=function(n,o){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var u=this._retryCallback(n,o);if(u===!0)return!0;if(u===!1)return!1}catch(a){console.error(a)}return!!(o&&o.status&&o.status>=500&&o.status!=501||n&&(n.code&&~r.indexOf(n.code)||n.timeout&&n.code=="ECONNABORTED"||n.crossDomain))},e.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},e.prototype.then=function(o,u){if(!this._fullfilledPromise){var a=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(s,l){a.end(function(d,_){d?l(d):s(_)})})}return this._fullfilledPromise.then(o,u)},e.prototype.catch=function(n){return this.then(void 0,n)},e.prototype.use=function(o){return o(this),this},e.prototype.ok=function(n){if(typeof n!="function")throw Error("Callback required");return this._okCallback=n,this},e.prototype._isResponseOK=function(n){return n?this._okCallback?this._okCallback(n):n.status>=200&&n.status<300:!1},e.prototype.get=function(n){return this._header[n.toLowerCase()]},e.prototype.getHeader=e.prototype.get,e.prototype.set=function(n,o){if(i(n)){for(var u in n)this.set(u,n[u]);return this}return this._header[n.toLowerCase()]=o,this.header[n]=o,this},e.prototype.unset=function(n){return delete this._header[n.toLowerCase()],delete this.header[n],this},e.prototype.field=function(n,o){if(n==null)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),i(n)){for(var u in n)this.field(u,n[u]);return this}if(Array.isArray(o)){for(var a in o)this.field(n,o[a]);return this}if(o==null)throw new Error(".field(name, val) val can not be empty");return typeof o=="boolean"&&(o=""+o),this._getFormData().append(n,o),this},e.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},e.prototype._auth=function(n,o,u,a){switch(u.type){case"basic":this.set("Authorization","Basic "+a(n+":"+o));break;case"auto":this.username=n,this.password=o;break;case"bearer":this.set("Authorization","Bearer "+n);break}return this},e.prototype.withCredentials=function(n){return n==null&&(n=!0),this._withCredentials=n,this},e.prototype.redirects=function(n){return this._maxRedirects=n,this},e.prototype.maxResponseSize=function(n){if(typeof n!="number")throw TypeError("Invalid argument");return this._maxResponseSize=n,this},e.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},e.prototype.send=function(n){var o=i(n),u=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),o&&!this._data)Array.isArray(n)?this._data=[]:this._isHost(n)||(this._data={});else if(n&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(o&&i(this._data))for(var a in n)this._data[a]=n[a];else typeof n=="string"?(u||this.type("form"),u=this._header["content-type"],u=="application/x-www-form-urlencoded"?this._data=this._data?this._data+"&"+n:n:this._data=(this._data||"")+n):this._data=n;return!o||this._isHost(n)?this:(u||this.type("json"),this)},e.prototype.sortQuery=function(n){return this._sort=typeof n=="undefined"?!0:n,this},e.prototype._finalizeQueryString=function(){var n=this._query.join("&");if(n&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+n),this._query.length=0,this._sort){var o=this.url.indexOf("?");if(o>=0){var u=this.url.substring(o+1).split("&");typeof this._sort=="function"?u.sort(this._sort):u.sort(),this.url=this.url.substring(0,o)+"?"+u.join("&")}}},e.prototype._appendQueryString=function(){console.trace("Unsupported")},e.prototype._timeoutError=function(n,o,u){if(!this._aborted){var a=new Error(n+o+"ms exceeded");a.timeout=o,a.code="ECONNABORTED",a.errno=u,this.timedout=!0,this.abort(),this.callback(a)}},e.prototype._setTimeouts=function(){var n=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){n._timeoutError("Timeout of ",n._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){n._timeoutError("Response timeout of ",n._responseTimeout,"ETIMEDOUT")},this._responseTimeout))},Ut}var At={},nu;function Qp(){return nu||(nu=1,At.type=function(i){return i.split(/ *; */).shift()},At.params=function(i){return i.split(/ *; */).reduce(function(e,t){var r=t.split(/ *= */),n=r.shift(),o=r.shift();return n&&o&&(e[n]=o),e},{})},At.parseLinks=function(i){return i.split(/ *, */).reduce(function(e,t){var r=t.split(/ *; */),n=r[0].slice(1,-1),o=r[1].split(/ *= */)[1].slice(1,-1);return e[o]=n,e},{})},At.cleanHeader=function(i,e){return delete i["content-type"],delete i["content-length"],delete i["transfer-encoding"],delete i.host,e&&(delete i.authorization,delete i.cookie),i}),At}var Er,iu;function Jp(){if(iu)return Er;iu=1;var i=Qp();Er=e;function e(r){if(r)return t(r)}function t(r){for(var n in e.prototype)r[n]=e.prototype[n];return r}return e.prototype.get=function(r){return this.header[r.toLowerCase()]},e.prototype._setHeaderProperties=function(r){var n=r["content-type"]||"";this.type=i.type(n);var o=i.params(n);for(var u in o)this[u]=o[u];this.links={};try{r.link&&(this.links=i.parseLinks(r.link))}catch(a){}},e.prototype._setStatusProperties=function(r){var n=r/100|0;this.status=this.statusCode=r,this.statusType=n,this.info=n==1,this.ok=n==2,this.redirect=n==3,this.clientError=n==4,this.serverError=n==5,this.error=n==4||n==5?this.toError():!1,this.created=r==201,this.accepted=r==202,this.noContent=r==204,this.badRequest=r==400,this.unauthorized=r==401,this.notAcceptable=r==406,this.forbidden=r==403,this.notFound=r==404,this.unprocessableEntity=r==422},Er}var Ir,ou;function Xp(){if(ou)return Ir;ou=1;function i(){this._defaults=[]}return["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach(function(e){i.prototype[e]=function(){return this._defaults.push({fn:e,arguments}),this}}),i.prototype._setDefaults=function(e){this._defaults.forEach(function(t){e[t.fn].apply(e,t.arguments)})},Ir=i,Ir}var Zp=et.exports,su;function em(){return su||(su=1,(function(i,e){var t;typeof window!="undefined"?t=window:typeof self!="undefined"?t=self:(console.warn("Using browser-only version of superagent in non-browser environment"),t=Zp);var r=Xe(),n=Kp(),o=Ft(),u=Jp(),a=Xp();function s(){}var l=e=i.exports=function(S,b){return typeof b=="function"?new e.Request("GET",S).end(b):arguments.length==1?new e.Request("GET",S):new e.Request(S,b)};e.Request=A,l.getXHR=function(){if(t.XMLHttpRequest&&(!t.location||t.location.protocol!="file:"||!t.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(S){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(S){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(S){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(S){}throw Error("Browser-only version of superagent could not find XHR")};var d="".trim?function(S){return S.trim()}:function(S){return S.replace(/(^\s*|\s*$)/g,"")};function _(S){if(!o(S))return S;var b=[];for(var h in S)g(b,h,S[h]);return b.join("&")}function g(S,b,h){if(h!=null)if(Array.isArray(h))h.forEach(function(v){g(S,b,v)});else if(o(h))for(var p in h)g(S,b+"["+p+"]",h[p]);else S.push(encodeURIComponent(b)+"="+encodeURIComponent(h));else h===null&&S.push(encodeURIComponent(b))}l.serializeObject=_;function E(S){for(var b={},h=S.split("&"),p,v,I=0,B=h.length;I<B;++I)p=h[I],v=p.indexOf("="),v==-1?b[decodeURIComponent(p)]="":b[decodeURIComponent(p.slice(0,v))]=decodeURIComponent(p.slice(v+1));return b}l.parseString=E,l.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},l.serialize={"application/x-www-form-urlencoded":_,"application/json":JSON.stringify},l.parse={"application/x-www-form-urlencoded":E,"application/json":JSON.parse};function w(S){for(var b=S.split(/\r?\n/),h={},p,v,I,B,H=0,V=b.length;H<V;++H)v=b[H],p=v.indexOf(":"),p!==-1&&(I=v.slice(0,p).toLowerCase(),B=d(v.slice(p+1)),h[I]=B);return h}function q(S){return/[\/+]json($|[^-\w])/.test(S)}function k(S){this.req=S,this.xhr=this.req.xhr,this.text=this.req.method!="HEAD"&&(this.xhr.responseType===""||this.xhr.responseType==="text")||typeof this.xhr.responseType=="undefined"?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var b=this.xhr.status;b===1223&&(b=204),this._setStatusProperties(b),this.header=this.headers=w(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),this.text===null&&S._responseType?this.body=this.xhr.response:this.body=this.req.method!="HEAD"?this._parseBody(this.text?this.text:this.xhr.response):null}u(k.prototype),k.prototype._parseBody=function(S){var b=l.parse[this.type];return this.req._parser?this.req._parser(this,S):(!b&&q(this.type)&&(b=l.parse["application/json"]),b&&S&&(S.length||S instanceof Object)?b(S):null)},k.prototype.toError=function(){var S=this.req,b=S.method,h=S.url,p="cannot "+b+" "+h+" ("+this.status+")",v=new Error(p);return v.status=this.status,v.method=b,v.url=h,v},l.Response=k;function A(S,b){var h=this;this._query=this._query||[],this.method=S,this.url=b,this.header={},this._header={},this.on("end",function(){var p=null,v=null;try{v=new k(h)}catch(B){return p=new Error("Parser is unable to parse the response"),p.parse=!0,p.original=B,h.xhr?(p.rawResponse=typeof h.xhr.responseType=="undefined"?h.xhr.responseText:h.xhr.response,p.status=h.xhr.status?h.xhr.status:null,p.statusCode=p.status):(p.rawResponse=null,p.status=null),h.callback(p)}h.emit("response",v);var I;try{h._isResponseOK(v)||(I=new Error(v.statusText||"Unsuccessful HTTP response"))}catch(B){I=B}I?(I.original=p,I.response=v,I.status=v.status,h.callback(I,v)):h.callback(null,v)})}r(A.prototype),n(A.prototype),A.prototype.type=function(S){return this.set("Content-Type",l.types[S]||S),this},A.prototype.accept=function(S){return this.set("Accept",l.types[S]||S),this},A.prototype.auth=function(S,b,h){arguments.length===1&&(b=""),typeof b=="object"&&b!==null&&(h=b,b=""),h||(h={type:typeof btoa=="function"?"basic":"auto"});var p=function(v){if(typeof btoa=="function")return btoa(v);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(S,b,h,p)},A.prototype.query=function(S){return typeof S!="string"&&(S=_(S)),S&&this._query.push(S),this},A.prototype.attach=function(S,b,h){if(b){if(this._data)throw Error("superagent can't mix .send() and .attach()");this._getFormData().append(S,b,h||b.name)}return this},A.prototype._getFormData=function(){return this._formData||(this._formData=new t.FormData),this._formData},A.prototype.callback=function(S,b){if(this._shouldRetry(S,b))return this._retry();var h=this._callback;this.clearTimeout(),S&&(this._maxRetries&&(S.retries=this._retries-1),this.emit("error",S)),h(S,b)},A.prototype.crossDomainError=function(){var S=new Error(`Request has been terminated
2
+ Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.`);S.crossDomain=!0,S.status=this.status,S.method=this.method,S.url=this.url,this.callback(S)},A.prototype.buffer=A.prototype.ca=A.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},A.prototype.pipe=A.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},A.prototype._isHost=function(b){return b&&typeof b=="object"&&!Array.isArray(b)&&Object.prototype.toString.call(b)!=="[object Object]"},A.prototype.end=function(S){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=S||s,this._finalizeQueryString(),this._end()},A.prototype._end=function(){var S=this,b=this.xhr=l.getXHR(),h=this._formData||this._data;this._setTimeouts(),b.onreadystatechange=function(){var H=b.readyState;if(H>=2&&S._responseTimeoutTimer&&clearTimeout(S._responseTimeoutTimer),H==4){var V;try{V=b.status}catch(P){V=0}if(!V)return S.timedout||S._aborted?void 0:S.crossDomainError();S.emit("end")}};var p=function(H,V){V.total>0&&(V.percent=V.loaded/V.total*100),V.direction=H,S.emit("progress",V)};if(this.hasListeners("progress"))try{b.onprogress=p.bind(null,"download"),b.upload&&(b.upload.onprogress=p.bind(null,"upload"))}catch(H){}try{this.username&&this.password?b.open(this.method,this.url,!0,this.username,this.password):b.open(this.method,this.url,!0)}catch(H){return this.callback(H)}if(this._withCredentials&&(b.withCredentials=!0),!this._formData&&this.method!="GET"&&this.method!="HEAD"&&typeof h!="string"&&!this._isHost(h)){var v=this._header["content-type"],I=this._serializer||l.serialize[v?v.split(";")[0]:""];!I&&q(v)&&(I=l.serialize["application/json"]),I&&(h=I(h))}for(var B in this.header)this.header[B]!=null&&this.header.hasOwnProperty(B)&&b.setRequestHeader(B,this.header[B]);return this._responseType&&(b.responseType=this._responseType),this.emit("request",this),b.send(typeof h!="undefined"?h:null),this},l.agent=function(){return new a},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(S){a.prototype[S.toLowerCase()]=function(b,h){var p=new l.Request(S,b);return this._setDefaults(p),h&&p.end(h),p}}),a.prototype.del=a.prototype.delete,l.get=function(S,b,h){var p=l("GET",S);return typeof b=="function"&&(h=b,b=null),b&&p.query(b),h&&p.end(h),p},l.head=function(S,b,h){var p=l("HEAD",S);return typeof b=="function"&&(h=b,b=null),b&&p.query(b),h&&p.end(h),p},l.options=function(S,b,h){var p=l("OPTIONS",S);return typeof b=="function"&&(h=b,b=null),b&&p.send(b),h&&p.end(h),p};function R(S,b,h){var p=l("DELETE",S);return typeof b=="function"&&(h=b,b=null),b&&p.send(b),h&&p.end(h),p}l.del=R,l.delete=R,l.patch=function(S,b,h){var p=l("PATCH",S);return typeof b=="function"&&(h=b,b=null),b&&p.send(b),h&&p.end(h),p},l.post=function(S,b,h){var p=l("POST",S);return typeof b=="function"&&(h=b,b=null),b&&p.send(b),h&&p.end(h),p},l.put=function(S,b,h){var p=l("PUT",S);return typeof b=="function"&&(h=b,b=null),b&&p.send(b),h&&p.end(h),p}})(et,et.exports)),et.exports}var tm=em();const st=rt(tm);function Ot(i){return i=i||Object.create(null),{on:function(t,r){(i[t]||(i[t]=[])).push(r)},off:function(t,r){i[t]&&i[t].splice(i[t].indexOf(r)>>>0,1)},emit:function(t,r){(i[t]||[]).slice().map(function(n){n(r)}),(i["*"]||[]).slice().map(function(n){n(t,r)})}}}const Tr=Object.prototype.toString,Ye={};Ye.array=Array.isArray,Ye.undefined=i=>i===void 0,Ye.string=i=>Tr.call(i)==="[object String]",Ye.object=i=>Object(i)===i,Ye.function=i=>Tr.call(i)==="[object Function]"||typeof i=="function",Ye.json=i=>Tr.call(i)==="[object Object]",Ye.not={array:i=>!Ye.array(i),string:i=>!Ye.string(i),object:i=>!Ye.object(i),function:i=>!Ye.function(i),json:i=>!Ye.json(i)};var Rr,au;function rm(){if(au)return Rr;au=1;var i=6e4;return Rr=function(t){var r=new Date(t.getTime()),n=r.getTimezoneOffset();r.setSeconds(0,0);var o=r.getTime()%i;return n*i+o},Rr}var Ar,uu;function Or(){if(uu)return Ar;uu=1;function i(e){return e instanceof Date}return Ar=i,Ar}var xr,fu;function ge(){if(fu)return xr;fu=1;var i=rm(),e=Or(),t=36e5,r=6e4,n=2,o=/[T ]/,u=/:/,a=/^(\d{2})$/,s=[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],l=/^(\d{4})/,d=[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],_=/^-(\d{2})$/,g=/^-?(\d{3})$/,E=/^-?(\d{2})-?(\d{2})$/,w=/^-?W(\d{2})$/,q=/^-?W(\d{2})-?(\d{1})$/,k=/^(\d{2}([.,]\d*)?)$/,A=/^(\d{2}):?(\d{2}([.,]\d*)?)$/,R=/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,S=/([Z+-].*)$/,b=/^(Z)$/,h=/^([+-])(\d{2})$/,p=/^([+-])(\d{2}):?(\d{2})$/;function v(oe,ne){if(e(oe))return new Date(oe.getTime());if(typeof oe!="string")return new Date(oe);var se=ne||{},he=se.additionalDigits;he==null?he=n:he=Number(he);var J=I(oe),me=B(J.date,he),de=me.year,be=me.restDateString,G=H(be,de);if(G){var re=G.getTime(),j=0,L;if(J.time&&(j=V(J.time)),J.timezone)L=P(J.timezone)*r;else{var M=re+j,D=new Date(M);L=i(D);var $=new Date(M);$.setDate(D.getDate()+1);var z=i($)-i(D);z>0&&(L+=z)}return new Date(re+j+L)}else return new Date(oe)}function I(oe){var ne={},se=oe.split(o),he;if(u.test(se[0])?(ne.date=null,he=se[0]):(ne.date=se[0],he=se[1]),he){var J=S.exec(he);J?(ne.time=he.replace(J[1],""),ne.timezone=J[1]):ne.time=he}return ne}function B(oe,ne){var se=s[ne],he=d[ne],J;if(J=l.exec(oe)||he.exec(oe),J){var me=J[1];return{year:parseInt(me,10),restDateString:oe.slice(me.length)}}if(J=a.exec(oe)||se.exec(oe),J){var de=J[1];return{year:parseInt(de,10)*100,restDateString:oe.slice(de.length)}}return{year:null}}function H(oe,ne){if(ne===null)return null;var se,he,J,me;if(oe.length===0)return he=new Date(0),he.setUTCFullYear(ne),he;if(se=_.exec(oe),se)return he=new Date(0),J=parseInt(se[1],10)-1,he.setUTCFullYear(ne,J),he;if(se=g.exec(oe),se){he=new Date(0);var de=parseInt(se[1],10);return he.setUTCFullYear(ne,0,de),he}if(se=E.exec(oe),se){he=new Date(0),J=parseInt(se[1],10)-1;var be=parseInt(se[2],10);return he.setUTCFullYear(ne,J,be),he}if(se=w.exec(oe),se)return me=parseInt(se[1],10)-1,ce(ne,me);if(se=q.exec(oe),se){me=parseInt(se[1],10)-1;var G=parseInt(se[2],10)-1;return ce(ne,me,G)}return null}function V(oe){var ne,se,he;if(ne=k.exec(oe),ne)return se=parseFloat(ne[1].replace(",",".")),se%24*t;if(ne=A.exec(oe),ne)return se=parseInt(ne[1],10),he=parseFloat(ne[2].replace(",",".")),se%24*t+he*r;if(ne=R.exec(oe),ne){se=parseInt(ne[1],10),he=parseInt(ne[2],10);var J=parseFloat(ne[3].replace(",","."));return se%24*t+he*r+J*1e3}return null}function P(oe){var ne,se;return ne=b.exec(oe),ne?0:(ne=h.exec(oe),ne?(se=parseInt(ne[2],10)*60,ne[1]==="+"?-se:se):(ne=p.exec(oe),ne?(se=parseInt(ne[2],10)*60+parseInt(ne[3],10),ne[1]==="+"?-se:se):0))}function ce(oe,ne,se){ne=ne||0,se=se||0;var he=new Date(0);he.setUTCFullYear(oe,0,4);var J=he.getUTCDay()||7,me=ne*7+se+1-J;return he.setUTCDate(he.getUTCDate()+me),he}return xr=v,xr}var Cr,lu;function cu(){if(lu)return Cr;lu=1;var i=ge();function e(t){var r=i(t),n=new Date(0);return n.setFullYear(r.getFullYear(),0,1),n.setHours(0,0,0,0),n}return Cr=e,Cr}var kr,hu;function bt(){if(hu)return kr;hu=1;var i=ge();function e(t){var r=i(t);return r.setHours(0,0,0,0),r}return kr=e,kr}var qr,du;function Xt(){if(du)return qr;du=1;var i=bt(),e=6e4,t=864e5;function r(n,o){var u=i(n),a=i(o),s=u.getTime()-u.getTimezoneOffset()*e,l=a.getTime()-a.getTimezoneOffset()*e;return Math.round((s-l)/t)}return qr=r,qr}var Mr,pu;function mu(){if(pu)return Mr;pu=1;var i=ge(),e=cu(),t=Xt();function r(n){var o=i(n),u=t(o,e(o)),a=u+1;return a}return Mr=r,Mr}var Pr,yu;function Zt(){if(yu)return Pr;yu=1;var i=ge();function e(t,r){var n=r&&Number(r.weekStartsOn)||0,o=i(t),u=o.getDay(),a=(u<n?7:0)+u-n;return o.setDate(o.getDate()-a),o.setHours(0,0,0,0),o}return Pr=e,Pr}var Br,gu;function wt(){if(gu)return Br;gu=1;var i=Zt();function e(t){return i(t,{weekStartsOn:1})}return Br=e,Br}var Dr,_u;function St(){if(_u)return Dr;_u=1;var i=ge(),e=wt();function t(r){var n=i(r),o=n.getFullYear(),u=new Date(0);u.setFullYear(o+1,0,4),u.setHours(0,0,0,0);var a=e(u),s=new Date(0);s.setFullYear(o,0,4),s.setHours(0,0,0,0);var l=e(s);return n.getTime()>=a.getTime()?o+1:n.getTime()>=l.getTime()?o:o-1}return Dr=t,Dr}var Lr,vu;function Nt(){if(vu)return Lr;vu=1;var i=St(),e=wt();function t(r){var n=i(r),o=new Date(0);o.setFullYear(n,0,4),o.setHours(0,0,0,0);var u=e(o);return u}return Lr=t,Lr}var Fr,bu;function Ur(){if(bu)return Fr;bu=1;var i=ge(),e=wt(),t=Nt(),r=6048e5;function n(o){var u=i(o),a=e(u).getTime()-t(u).getTime();return Math.round(a/r)+1}return Fr=n,Fr}var Nr,wu;function Su(){if(wu)return Nr;wu=1;var i=Or();function e(t){if(i(t))return!isNaN(t);throw new TypeError(toString.call(t)+" is not an instance of Date")}return Nr=e,Nr}var jr,Eu;function nm(){if(Eu)return jr;Eu=1;function i(){var e={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function t(r,n,o){o=o||{};var u;return typeof e[r]=="string"?u=e[r]:n===1?u=e[r].one:u=e[r].other.replace("{{count}}",n),o.addSuffix?o.comparison>0?"in "+u:u+" ago":u}return{localize:t}}return jr=i,jr}var $r,Iu;function im(){if(Iu)return $r;Iu=1;var i=["M","MM","Q","D","DD","DDD","DDDD","d","E","W","WW","YY","YYYY","GG","GGGG","H","HH","h","hh","m","mm","s","ss","S","SS","SSS","Z","ZZ","X","x"];function e(t){var r=[];for(var n in t)t.hasOwnProperty(n)&&r.push(n);var o=i.concat(r).sort().reverse(),u=new RegExp("(\\[[^\\[]*\\])|(\\\\)?("+o.join("|")+"|.)","g");return u}return $r=e,$r}var Hr,Tu;function om(){if(Tu)return Hr;Tu=1;var i=im();function e(){var r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],o=["Su","Mo","Tu","We","Th","Fr","Sa"],u=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],a=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],s=["AM","PM"],l=["am","pm"],d=["a.m.","p.m."],_={MMM:function(E){return r[E.getMonth()]},MMMM:function(E){return n[E.getMonth()]},dd:function(E){return o[E.getDay()]},ddd:function(E){return u[E.getDay()]},dddd:function(E){return a[E.getDay()]},A:function(E){return E.getHours()/12>=1?s[1]:s[0]},a:function(E){return E.getHours()/12>=1?l[1]:l[0]},aa:function(E){return E.getHours()/12>=1?d[1]:d[0]}},g=["M","D","DDD","d","Q","W"];return g.forEach(function(E){_[E+"o"]=function(w,q){return t(q[E](w))}}),{formatters:_,formattingTokensRegExp:i(_)}}function t(r){var n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"}return Hr=e,Hr}var Wr,Ru;function Yr(){if(Ru)return Wr;Ru=1;var i=nm(),e=om();return Wr={distanceInWords:i(),format:e()},Wr}var Gr,Au;function Ou(){if(Au)return Gr;Au=1;var i=mu(),e=Ur(),t=St(),r=ge(),n=Su(),o=Yr();function u(g,E,w){var q=E?String(E):"YYYY-MM-DDTHH:mm:ss.SSSZ",k=w||{},A=k.locale,R=o.format.formatters,S=o.format.formattingTokensRegExp;A&&A.format&&A.format.formatters&&(R=A.format.formatters,A.format.formattingTokensRegExp&&(S=A.format.formattingTokensRegExp));var b=r(g);if(!n(b))return"Invalid Date";var h=s(q,R,S);return h(b)}var a={M:function(g){return g.getMonth()+1},MM:function(g){return _(g.getMonth()+1,2)},Q:function(g){return Math.ceil((g.getMonth()+1)/3)},D:function(g){return g.getDate()},DD:function(g){return _(g.getDate(),2)},DDD:function(g){return i(g)},DDDD:function(g){return _(i(g),3)},d:function(g){return g.getDay()},E:function(g){return g.getDay()||7},W:function(g){return e(g)},WW:function(g){return _(e(g),2)},YY:function(g){return _(g.getFullYear(),4).substr(2)},YYYY:function(g){return _(g.getFullYear(),4)},GG:function(g){return String(t(g)).substr(2)},GGGG:function(g){return t(g)},H:function(g){return g.getHours()},HH:function(g){return _(g.getHours(),2)},h:function(g){var E=g.getHours();return E===0?12:E>12?E%12:E},hh:function(g){return _(a.h(g),2)},m:function(g){return g.getMinutes()},mm:function(g){return _(g.getMinutes(),2)},s:function(g){return g.getSeconds()},ss:function(g){return _(g.getSeconds(),2)},S:function(g){return Math.floor(g.getMilliseconds()/100)},SS:function(g){return _(Math.floor(g.getMilliseconds()/10),2)},SSS:function(g){return _(g.getMilliseconds(),3)},Z:function(g){return d(g.getTimezoneOffset(),":")},ZZ:function(g){return d(g.getTimezoneOffset())},X:function(g){return Math.floor(g.getTime()/1e3)},x:function(g){return g.getTime()}};function s(g,E,w){var q=g.match(w),k=q.length,A,R;for(A=0;A<k;A++)R=E[q[A]]||a[q[A]],R?q[A]=R:q[A]=l(q[A]);return function(S){for(var b="",h=0;h<k;h++)q[h]instanceof Function?b+=q[h](S,a):b+=q[h];return b}}function l(g){return g.match(/\[[\s\S]/)?g.replace(/^\[|]$/g,""):g.replace(/\\/g,"")}function d(g,E){E=E||"";var w=g>0?"-":"+",q=Math.abs(g),k=Math.floor(q/60),A=q%60;return w+_(k,2)+E+_(A,2)}function _(g,E){for(var w=Math.abs(g).toString();w.length<E;)w="0"+w;return w}return Gr=u,Gr}var sm=Ou();const am=rt(sm);var zr,xu;function Vr(){if(xu)return zr;xu=1;var i=ge();function e(t,r){var n=i(t),o=n.getTime(),u=i(r),a=u.getTime();return o>a?-1:o<a?1:0}return zr=e,zr}var Kr,Cu;function er(){if(Cu)return Kr;Cu=1;var i=ge();function e(t,r){var n=i(t),o=i(r);return n.getTime()-o.getTime()}return Kr=e,Kr}var Qr,ku;function Jr(){if(ku)return Qr;ku=1;var i=er();function e(t,r){var n=i(t,r)/1e3;return n>0?Math.floor(n):Math.ceil(n)}return Qr=e,Qr}var Xr,qu;function Mu(){if(qu)return Xr;qu=1;var i=ge();function e(t,r){var n=i(t),o=i(r),u=n.getFullYear()-o.getFullYear(),a=n.getMonth()-o.getMonth();return u*12+a}return Xr=e,Xr}var Zr,Pu;function jt(){if(Pu)return Zr;Pu=1;var i=ge();function e(t,r){var n=i(t),o=n.getTime(),u=i(r),a=u.getTime();return o<a?-1:o>a?1:0}return Zr=e,Zr}var en,Bu;function tn(){if(Bu)return en;Bu=1;var i=ge(),e=Mu(),t=jt();function r(n,o){var u=i(n),a=i(o),s=t(u,a),l=Math.abs(e(u,a));u.setMonth(u.getMonth()-s*l);var d=t(u,a)===-s;return s*(l-d)}return en=r,en}var rn,Du;function Lu(){if(Du)return rn;Du=1;var i=Vr(),e=ge(),t=Jr(),r=tn(),n=Yr(),o=1440,u=2520,a=43200,s=86400;function l(d,_,g){var E=g||{},w=i(d,_),q=E.locale,k=n.distanceInWords.localize;q&&q.distanceInWords&&q.distanceInWords.localize&&(k=q.distanceInWords.localize);var A={addSuffix:!!E.addSuffix,comparison:w},R,S;w>0?(R=e(d),S=e(_)):(R=e(_),S=e(d));var b=t(S,R),h=S.getTimezoneOffset()-R.getTimezoneOffset(),p=Math.round(b/60)-h,v;if(p<2)return E.includeSeconds?b<5?k("lessThanXSeconds",5,A):b<10?k("lessThanXSeconds",10,A):b<20?k("lessThanXSeconds",20,A):b<40?k("halfAMinute",null,A):b<60?k("lessThanXMinutes",1,A):k("xMinutes",1,A):p===0?k("lessThanXMinutes",1,A):k("xMinutes",p,A);if(p<45)return k("xMinutes",p,A);if(p<90)return k("aboutXHours",1,A);if(p<o){var I=Math.round(p/60);return k("aboutXHours",I,A)}else{if(p<u)return k("xDays",1,A);if(p<a){var B=Math.round(p/o);return k("xDays",B,A)}else if(p<s)return v=Math.round(p/a),k("aboutXMonths",v,A)}if(v=r(S,R),v<12){var H=Math.round(p/a);return k("xMonths",H,A)}else{var V=v%12,P=Math.floor(v/12);return V<3?k("aboutXYears",P,A):V<9?k("overXYears",P,A):k("almostXYears",P+1,A)}}return rn=l,rn}var nn,Fu;function Uu(){if(Fu)return nn;Fu=1;var i=Lu();function e(t,r){return i(Date.now(),t,r)}return nn=e,nn}var um=Uu();const fm=rt(um);var on,Nu;function $t(){if(Nu)return on;Nu=1;var i=ge();function e(t,r){var n=i(t),o=Number(r);return n.setDate(n.getDate()+o),n}return on=e,on}var sn,ju;function Ht(){if(ju)return sn;ju=1;var i=ge();function e(t,r){var n=i(t).getTime(),o=Number(r);return new Date(n+o)}return sn=e,sn}var an,$u;function Hu(){if($u)return an;$u=1;var i=Ht(),e=36e5;function t(r,n){var o=Number(n);return i(r,o*e)}return an=t,an}var un,Wu;function Yu(){if(Wu)return un;Wu=1;var i=ge(),e=Nt(),t=Xt();function r(n,o){var u=i(n),a=Number(o),s=t(u,e(u)),l=new Date(0);return l.setFullYear(a,0,4),l.setHours(0,0,0,0),u=e(l),u.setDate(u.getDate()+s),u}return un=r,un}var fn,Gu;function zu(){if(Gu)return fn;Gu=1;var i=St(),e=Yu();function t(r,n){var o=Number(n);return e(r,i(r)+o)}return fn=t,fn}var ln,Vu;function Ku(){if(Vu)return ln;Vu=1;var i=Ht(),e=6e4;function t(r,n){var o=Number(n);return i(r,o*e)}return ln=t,ln}var cn,Qu;function hn(){if(Qu)return cn;Qu=1;var i=ge();function e(t){var r=i(t),n=r.getFullYear(),o=r.getMonth(),u=new Date(0);return u.setFullYear(n,o+1,0),u.setHours(0,0,0,0),u.getDate()}return cn=e,cn}var dn,Ju;function tr(){if(Ju)return dn;Ju=1;var i=ge(),e=hn();function t(r,n){var o=i(r),u=Number(n),a=o.getMonth()+u,s=new Date(0);s.setFullYear(o.getFullYear(),a,1),s.setHours(0,0,0,0);var l=e(s);return o.setMonth(a,Math.min(l,o.getDate())),o}return dn=t,dn}var pn,Xu;function Zu(){if(Xu)return pn;Xu=1;var i=tr();function e(t,r){var n=Number(r),o=n*3;return i(t,o)}return pn=e,pn}var mn,ef;function tf(){if(ef)return mn;ef=1;var i=Ht();function e(t,r){var n=Number(r);return i(t,n*1e3)}return mn=e,mn}var yn,rf;function gn(){if(rf)return yn;rf=1;var i=$t();function e(t,r){var n=Number(r),o=n*7;return i(t,o)}return yn=e,yn}var _n,nf;function of(){if(nf)return _n;nf=1;var i=tr();function e(t,r){var n=Number(r);return i(t,n*12)}return _n=e,_n}var vn,sf;function lm(){if(sf)return vn;sf=1;var i=ge();function e(t,r,n,o){var u=i(t).getTime(),a=i(r).getTime(),s=i(n).getTime(),l=i(o).getTime();if(u>a||s>l)throw new Error("The start of the range cannot be after the end of the range");return u<l&&s<a}return vn=e,vn}var bn,af;function cm(){if(af)return bn;af=1;var i=ge();function e(t,r){if(!(r instanceof Array))throw new TypeError(toString.call(r)+" is not an instance of Array");var n=i(t),o=n.getTime(),u,a;return r.forEach(function(s,l){var d=i(s),_=Math.abs(o-d.getTime());(u===void 0||_<a)&&(u=l,a=_)}),u}return bn=e,bn}var wn,uf;function hm(){if(uf)return wn;uf=1;var i=ge();function e(t,r){if(!(r instanceof Array))throw new TypeError(toString.call(r)+" is not an instance of Array");var n=i(t),o=n.getTime(),u,a;return r.forEach(function(s){var l=i(s),d=Math.abs(o-l.getTime());(u===void 0||d<a)&&(u=l,a=d)}),u}return wn=e,wn}var Sn,ff;function dm(){if(ff)return Sn;ff=1;var i=wt(),e=6e4,t=6048e5;function r(n,o){var u=i(n),a=i(o),s=u.getTime()-u.getTimezoneOffset()*e,l=a.getTime()-a.getTimezoneOffset()*e;return Math.round((s-l)/t)}return Sn=r,Sn}var En,lf;function cf(){if(lf)return En;lf=1;var i=St();function e(t,r){return i(t)-i(r)}return En=e,En}var In,hf;function df(){if(hf)return In;hf=1;var i=ge();function e(t){var r=i(t),n=Math.floor(r.getMonth()/3)+1;return n}return In=e,In}var Tn,pf;function pm(){if(pf)return Tn;pf=1;var i=df(),e=ge();function t(r,n){var o=e(r),u=e(n),a=o.getFullYear()-u.getFullYear(),s=i(o)-i(u);return a*4+s}return Tn=t,Tn}var Rn,mf;function mm(){if(mf)return Rn;mf=1;var i=Zt(),e=6e4,t=6048e5;function r(n,o,u){var a=i(n,u),s=i(o,u),l=a.getTime()-a.getTimezoneOffset()*e,d=s.getTime()-s.getTimezoneOffset()*e;return Math.round((l-d)/t)}return Rn=r,Rn}var An,yf;function gf(){if(yf)return An;yf=1;var i=ge();function e(t,r){var n=i(t),o=i(r);return n.getFullYear()-o.getFullYear()}return An=e,An}var On,_f;function vf(){if(_f)return On;_f=1;var i=ge(),e=Xt(),t=jt();function r(n,o){var u=i(n),a=i(o),s=t(u,a),l=Math.abs(e(u,a));u.setDate(u.getDate()-s*l);var d=t(u,a)===-s;return s*(l-d)}return On=r,On}var xn,bf;function ym(){if(bf)return xn;bf=1;var i=er(),e=36e5;function t(r,n){var o=i(r,n)/e;return o>0?Math.floor(o):Math.ceil(o)}return xn=t,xn}var Cn,wf;function Sf(){if(wf)return Cn;wf=1;var i=zu();function e(t,r){var n=Number(r);return i(t,-n)}return Cn=e,Cn}var kn,Ef;function gm(){if(Ef)return kn;Ef=1;var i=ge(),e=cf(),t=jt(),r=Sf();function n(o,u){var a=i(o),s=i(u),l=t(a,s),d=Math.abs(e(a,s));a=r(a,l*d);var _=t(a,s)===-l;return l*(d-_)}return kn=n,kn}var qn,If;function _m(){if(If)return qn;If=1;var i=er(),e=6e4;function t(r,n){var o=i(r,n)/e;return o>0?Math.floor(o):Math.ceil(o)}return qn=t,qn}var Mn,Tf;function vm(){if(Tf)return Mn;Tf=1;var i=tn();function e(t,r){var n=i(t,r)/3;return n>0?Math.floor(n):Math.ceil(n)}return Mn=e,Mn}var Pn,Rf;function bm(){if(Rf)return Pn;Rf=1;var i=vf();function e(t,r){var n=i(t,r)/7;return n>0?Math.floor(n):Math.ceil(n)}return Pn=e,Pn}var Bn,Af;function wm(){if(Af)return Bn;Af=1;var i=ge(),e=gf(),t=jt();function r(n,o){var u=i(n),a=i(o),s=t(u,a),l=Math.abs(e(u,a));u.setFullYear(u.getFullYear()-s*l);var d=t(u,a)===-s;return s*(l-d)}return Bn=r,Bn}var Dn,Of;function Sm(){if(Of)return Dn;Of=1;var i=Vr(),e=ge(),t=Jr(),r=Yr(),n=1440,o=43200,u=525600;function a(s,l,d){var _=d||{},g=i(s,l),E=_.locale,w=r.distanceInWords.localize;E&&E.distanceInWords&&E.distanceInWords.localize&&(w=E.distanceInWords.localize);var q={addSuffix:!!_.addSuffix,comparison:g},k,A;g>0?(k=e(s),A=e(l)):(k=e(l),A=e(s));var R,S=Math[_.partialMethod?String(_.partialMethod):"floor"],b=t(A,k),h=A.getTimezoneOffset()-k.getTimezoneOffset(),p=S(b/60)-h,v,I,B,H;if(_.unit?R=String(_.unit):p<1?R="s":p<60?R="m":p<n?R="h":p<o?R="d":p<u?R="M":R="Y",R==="s")return w("xSeconds",b,q);if(R==="m")return w("xMinutes",p,q);if(R==="h")return v=S(p/60),w("xHours",v,q);if(R==="d")return I=S(p/n),w("xDays",I,q);if(R==="M")return B=S(p/o),w("xMonths",B,q);if(R==="Y")return H=S(p/u),w("xYears",H,q);throw new Error("Unknown unit: "+R)}return Dn=a,Dn}var Ln,xf;function Em(){if(xf)return Ln;xf=1;var i=ge();function e(t,r,n){var o=i(t),u=i(r),a=n!==void 0?n:1,s=u.getTime();if(o.getTime()>s)throw new Error("The first date cannot be after the second date");var l=[],d=o;for(d.setHours(0,0,0,0);d.getTime()<=s;)l.push(i(d)),d.setDate(d.getDate()+a);return l}return Ln=e,Ln}var Fn,Cf;function Un(){if(Cf)return Fn;Cf=1;var i=ge();function e(t){var r=i(t);return r.setHours(23,59,59,999),r}return Fn=e,Fn}var Nn,kf;function Im(){if(kf)return Nn;kf=1;var i=ge();function e(t){var r=i(t);return r.setMinutes(59,59,999),r}return Nn=e,Nn}var jn,qf;function Mf(){if(qf)return jn;qf=1;var i=ge();function e(t,r){var n=r&&Number(r.weekStartsOn)||0,o=i(t),u=o.getDay(),a=(u<n?-7:0)+6-(u-n);return o.setDate(o.getDate()+a),o.setHours(23,59,59,999),o}return jn=e,jn}var $n,Pf;function Tm(){if(Pf)return $n;Pf=1;var i=Mf();function e(t){return i(t,{weekStartsOn:1})}return $n=e,$n}var Hn,Bf;function Rm(){if(Bf)return Hn;Bf=1;var i=St(),e=wt();function t(r){var n=i(r),o=new Date(0);o.setFullYear(n+1,0,4),o.setHours(0,0,0,0);var u=e(o);return u.setMilliseconds(u.getMilliseconds()-1),u}return Hn=t,Hn}var Wn,Df;function Am(){if(Df)return Wn;Df=1;var i=ge();function e(t){var r=i(t);return r.setSeconds(59,999),r}return Wn=e,Wn}var Yn,Lf;function Ff(){if(Lf)return Yn;Lf=1;var i=ge();function e(t){var r=i(t),n=r.getMonth();return r.setFullYear(r.getFullYear(),n+1,0),r.setHours(23,59,59,999),r}return Yn=e,Yn}var Gn,Uf;function Om(){if(Uf)return Gn;Uf=1;var i=ge();function e(t){var r=i(t),n=r.getMonth(),o=n-n%3+3;return r.setMonth(o,0),r.setHours(23,59,59,999),r}return Gn=e,Gn}var zn,Nf;function xm(){if(Nf)return zn;Nf=1;var i=ge();function e(t){var r=i(t);return r.setMilliseconds(999),r}return zn=e,zn}var Vn,jf;function Cm(){if(jf)return Vn;jf=1;var i=Un();function e(){return i(new Date)}return Vn=e,Vn}var Kn,$f;function km(){if($f)return Kn;$f=1;function i(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n+1),o.setHours(23,59,59,999),o}return Kn=i,Kn}var Qn,Hf;function qm(){if(Hf)return Qn;Hf=1;var i=ge();function e(t){var r=i(t),n=r.getFullYear();return r.setFullYear(n+1,0,0),r.setHours(23,59,59,999),r}return Qn=e,Qn}var Jn,Wf;function Mm(){if(Wf)return Jn;Wf=1;function i(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n-1),o.setHours(23,59,59,999),o}return Jn=i,Jn}var Xn,Yf;function Pm(){if(Yf)return Xn;Yf=1;var i=ge();function e(t){var r=i(t),n=r.getDate();return n}return Xn=e,Xn}var Zn,Gf;function Bm(){if(Gf)return Zn;Gf=1;var i=ge();function e(t){var r=i(t),n=r.getDay();return n}return Zn=e,Zn}var ei,zf;function Vf(){if(zf)return ei;zf=1;var i=ge();function e(t){var r=i(t),n=r.getFullYear();return n%400===0||n%4===0&&n%100!==0}return ei=e,ei}var ti,Kf;function Dm(){if(Kf)return ti;Kf=1;var i=Vf();function e(t){return i(t)?366:365}return ti=e,ti}var ri,Qf;function Lm(){if(Qf)return ri;Qf=1;var i=ge();function e(t){var r=i(t),n=r.getHours();return n}return ri=e,ri}var ni,Jf;function Xf(){if(Jf)return ni;Jf=1;var i=ge();function e(t){var r=i(t),n=r.getDay();return n===0&&(n=7),n}return ni=e,ni}var ii,Zf;function Fm(){if(Zf)return ii;Zf=1;var i=Nt(),e=gn(),t=6048e5;function r(n){var o=i(n),u=i(e(o,60)),a=u.valueOf()-o.valueOf();return Math.round(a/t)}return ii=r,ii}var oi,el;function Um(){if(el)return oi;el=1;var i=ge();function e(t){var r=i(t),n=r.getMilliseconds();return n}return oi=e,oi}var si,tl;function Nm(){if(tl)return si;tl=1;var i=ge();function e(t){var r=i(t),n=r.getMinutes();return n}return si=e,si}var ai,rl;function jm(){if(rl)return ai;rl=1;var i=ge();function e(t){var r=i(t),n=r.getMonth();return n}return ai=e,ai}var ui,nl;function $m(){if(nl)return ui;nl=1;var i=ge(),e=1440*60*1e3;function t(r,n,o,u){var a=i(r).getTime(),s=i(n).getTime(),l=i(o).getTime(),d=i(u).getTime();if(a>s||l>d)throw new Error("The start of the range cannot be after the end of the range");var _=a<d&&l<s;if(!_)return 0;var g=l<a?a:l,E=d>s?s:d,w=E-g;return Math.ceil(w/e)}return ui=t,ui}var fi,il;function Hm(){if(il)return fi;il=1;var i=ge();function e(t){var r=i(t),n=r.getSeconds();return n}return fi=e,fi}var li,ol;function Wm(){if(ol)return li;ol=1;var i=ge();function e(t){var r=i(t),n=r.getTime();return n}return li=e,li}var ci,sl;function Ym(){if(sl)return ci;sl=1;var i=ge();function e(t){var r=i(t),n=r.getFullYear();return n}return ci=e,ci}var hi,al;function Gm(){if(al)return hi;al=1;var i=ge();function e(t,r){var n=i(t),o=i(r);return n.getTime()>o.getTime()}return hi=e,hi}var di,ul;function zm(){if(ul)return di;ul=1;var i=ge();function e(t,r){var n=i(t),o=i(r);return n.getTime()<o.getTime()}return di=e,di}var pi,fl;function Vm(){if(fl)return pi;fl=1;var i=ge();function e(t,r){var n=i(t),o=i(r);return n.getTime()===o.getTime()}return pi=e,pi}var mi,ll;function Km(){if(ll)return mi;ll=1;var i=ge();function e(t){return i(t).getDate()===1}return mi=e,mi}var yi,cl;function Qm(){if(cl)return yi;cl=1;var i=ge();function e(t){return i(t).getDay()===5}return yi=e,yi}var gi,hl;function Jm(){if(hl)return gi;hl=1;var i=ge();function e(t){return i(t).getTime()>new Date().getTime()}return gi=e,gi}var _i,dl;function Xm(){if(dl)return _i;dl=1;var i=ge(),e=Un(),t=Ff();function r(n){var o=i(n);return e(o).getTime()===t(o).getTime()}return _i=r,_i}var vi,pl;function Zm(){if(pl)return vi;pl=1;var i=ge();function e(t){return i(t).getDay()===1}return vi=e,vi}var bi,ml;function ey(){if(ml)return bi;ml=1;var i=ge();function e(t){return i(t).getTime()<new Date().getTime()}return bi=e,bi}var wi,yl;function ty(){if(yl)return wi;yl=1;var i=bt();function e(t,r){var n=i(t),o=i(r);return n.getTime()===o.getTime()}return wi=e,wi}var Si,gl;function _l(){if(gl)return Si;gl=1;var i=ge();function e(t){var r=i(t);return r.setMinutes(0,0,0),r}return Si=e,Si}var Ei,vl;function bl(){if(vl)return Ei;vl=1;var i=_l();function e(t,r){var n=i(t),o=i(r);return n.getTime()===o.getTime()}return Ei=e,Ei}var Ii,wl;function Ti(){if(wl)return Ii;wl=1;var i=Zt();function e(t,r,n){var o=i(t,n),u=i(r,n);return o.getTime()===u.getTime()}return Ii=e,Ii}var Ri,Sl;function El(){if(Sl)return Ri;Sl=1;var i=Ti();function e(t,r){return i(t,r,{weekStartsOn:1})}return Ri=e,Ri}var Ai,Il;function Tl(){if(Il)return Ai;Il=1;var i=Nt();function e(t,r){var n=i(t),o=i(r);return n.getTime()===o.getTime()}return Ai=e,Ai}var Oi,Rl;function Al(){if(Rl)return Oi;Rl=1;var i=ge();function e(t){var r=i(t);return r.setSeconds(0,0),r}return Oi=e,Oi}var xi,Ol;function xl(){if(Ol)return xi;Ol=1;var i=Al();function e(t,r){var n=i(t),o=i(r);return n.getTime()===o.getTime()}return xi=e,xi}var Ci,Cl;function kl(){if(Cl)return Ci;Cl=1;var i=ge();function e(t,r){var n=i(t),o=i(r);return n.getFullYear()===o.getFullYear()&&n.getMonth()===o.getMonth()}return Ci=e,Ci}var ki,ql;function Ml(){if(ql)return ki;ql=1;var i=ge();function e(t){var r=i(t),n=r.getMonth(),o=n-n%3;return r.setMonth(o,1),r.setHours(0,0,0,0),r}return ki=e,ki}var qi,Pl;function Bl(){if(Pl)return qi;Pl=1;var i=Ml();function e(t,r){var n=i(t),o=i(r);return n.getTime()===o.getTime()}return qi=e,qi}var Mi,Dl;function Ll(){if(Dl)return Mi;Dl=1;var i=ge();function e(t){var r=i(t);return r.setMilliseconds(0),r}return Mi=e,Mi}var Pi,Fl;function Ul(){if(Fl)return Pi;Fl=1;var i=Ll();function e(t,r){var n=i(t),o=i(r);return n.getTime()===o.getTime()}return Pi=e,Pi}var Bi,Nl;function jl(){if(Nl)return Bi;Nl=1;var i=ge();function e(t,r){var n=i(t),o=i(r);return n.getFullYear()===o.getFullYear()}return Bi=e,Bi}var Di,$l;function ry(){if($l)return Di;$l=1;var i=ge();function e(t){return i(t).getDay()===6}return Di=e,Di}var Li,Hl;function ny(){if(Hl)return Li;Hl=1;var i=ge();function e(t){return i(t).getDay()===0}return Li=e,Li}var Fi,Wl;function iy(){if(Wl)return Fi;Wl=1;var i=bl();function e(t){return i(new Date,t)}return Fi=e,Fi}var Ui,Yl;function oy(){if(Yl)return Ui;Yl=1;var i=El();function e(t){return i(new Date,t)}return Ui=e,Ui}var Ni,Gl;function sy(){if(Gl)return Ni;Gl=1;var i=Tl();function e(t){return i(new Date,t)}return Ni=e,Ni}var ji,zl;function ay(){if(zl)return ji;zl=1;var i=xl();function e(t){return i(new Date,t)}return ji=e,ji}var $i,Vl;function uy(){if(Vl)return $i;Vl=1;var i=kl();function e(t){return i(new Date,t)}return $i=e,$i}var Hi,Kl;function fy(){if(Kl)return Hi;Kl=1;var i=Bl();function e(t){return i(new Date,t)}return Hi=e,Hi}var Wi,Ql;function ly(){if(Ql)return Wi;Ql=1;var i=Ul();function e(t){return i(new Date,t)}return Wi=e,Wi}var Yi,Jl;function cy(){if(Jl)return Yi;Jl=1;var i=Ti();function e(t,r){return i(new Date,t,r)}return Yi=e,Yi}var Gi,Xl;function hy(){if(Xl)return Gi;Xl=1;var i=jl();function e(t){return i(new Date,t)}return Gi=e,Gi}var zi,Zl;function dy(){if(Zl)return zi;Zl=1;var i=ge();function e(t){return i(t).getDay()===4}return zi=e,zi}var Vi,ec;function py(){if(ec)return Vi;ec=1;var i=bt();function e(t){return i(t).getTime()===i(new Date).getTime()}return Vi=e,Vi}var Ki,tc;function my(){if(tc)return Ki;tc=1;var i=bt();function e(t){var r=new Date;return r.setDate(r.getDate()+1),i(t).getTime()===i(r).getTime()}return Ki=e,Ki}var Qi,rc;function yy(){if(rc)return Qi;rc=1;var i=ge();function e(t){return i(t).getDay()===2}return Qi=e,Qi}var Ji,nc;function gy(){if(nc)return Ji;nc=1;var i=ge();function e(t){return i(t).getDay()===3}return Ji=e,Ji}var Xi,ic;function _y(){if(ic)return Xi;ic=1;var i=ge();function e(t){var r=i(t),n=r.getDay();return n===0||n===6}return Xi=e,Xi}var Zi,oc;function vy(){if(oc)return Zi;oc=1;var i=ge();function e(t,r,n){var o=i(t).getTime(),u=i(r).getTime(),a=i(n).getTime();if(u>a)throw new Error("The start of the range cannot be after the end of the range");return o>=u&&o<=a}return Zi=e,Zi}var eo,sc;function by(){if(sc)return eo;sc=1;var i=bt();function e(t){var r=new Date;return r.setDate(r.getDate()-1),i(t).getTime()===i(r).getTime()}return eo=e,eo}var to,ac;function uc(){if(ac)return to;ac=1;var i=ge();function e(t,r){var n=r&&Number(r.weekStartsOn)||0,o=i(t),u=o.getDay(),a=(u<n?-7:0)+6-(u-n);return o.setHours(0,0,0,0),o.setDate(o.getDate()+a),o}return to=e,to}var ro,fc;function wy(){if(fc)return ro;fc=1;var i=uc();function e(t){return i(t,{weekStartsOn:1})}return ro=e,ro}var no,lc;function Sy(){if(lc)return no;lc=1;var i=St(),e=wt();function t(r){var n=i(r),o=new Date(0);o.setFullYear(n+1,0,4),o.setHours(0,0,0,0);var u=e(o);return u.setDate(u.getDate()-1),u}return no=t,no}var io,cc;function Ey(){if(cc)return io;cc=1;var i=ge();function e(t){var r=i(t),n=r.getMonth();return r.setFullYear(r.getFullYear(),n+1,0),r.setHours(0,0,0,0),r}return io=e,io}var oo,hc;function Iy(){if(hc)return oo;hc=1;var i=ge();function e(t){var r=i(t),n=r.getMonth(),o=n-n%3+3;return r.setMonth(o,0),r.setHours(0,0,0,0),r}return oo=e,oo}var so,dc;function Ty(){if(dc)return so;dc=1;var i=ge();function e(t){var r=i(t),n=r.getFullYear();return r.setFullYear(n+1,0,0),r.setHours(0,0,0,0),r}return so=e,so}var ao,pc;function Ry(){if(pc)return ao;pc=1;var i=ge();function e(){var t=Array.prototype.slice.call(arguments),r=t.map(function(o){return i(o)}),n=Math.max.apply(null,r);return new Date(n)}return ao=e,ao}var uo,mc;function Ay(){if(mc)return uo;mc=1;var i=ge();function e(){var t=Array.prototype.slice.call(arguments),r=t.map(function(o){return i(o)}),n=Math.min.apply(null,r);return new Date(n)}return uo=e,uo}var fo,yc;function Oy(){if(yc)return fo;yc=1;var i=ge();function e(t,r){var n=i(t),o=Number(r);return n.setDate(o),n}return fo=e,fo}var lo,gc;function xy(){if(gc)return lo;gc=1;var i=ge(),e=$t();function t(r,n,o){var u=o&&Number(o.weekStartsOn)||0,a=i(r),s=Number(n),l=a.getDay(),d=s%7,_=(d+7)%7,g=(_<u?7:0)+s-l;return e(a,g)}return lo=t,lo}var co,_c;function Cy(){if(_c)return co;_c=1;var i=ge();function e(t,r){var n=i(t),o=Number(r);return n.setMonth(0),n.setDate(o),n}return co=e,co}var ho,vc;function ky(){if(vc)return ho;vc=1;var i=ge();function e(t,r){var n=i(t),o=Number(r);return n.setHours(o),n}return ho=e,ho}var po,bc;function qy(){if(bc)return po;bc=1;var i=ge(),e=$t(),t=Xf();function r(n,o){var u=i(n),a=Number(o),s=t(u),l=a-s;return e(u,l)}return po=r,po}var mo,wc;function My(){if(wc)return mo;wc=1;var i=ge(),e=Ur();function t(r,n){var o=i(r),u=Number(n),a=e(o)-u;return o.setDate(o.getDate()-a*7),o}return mo=t,mo}var yo,Sc;function Py(){if(Sc)return yo;Sc=1;var i=ge();function e(t,r){var n=i(t),o=Number(r);return n.setMilliseconds(o),n}return yo=e,yo}var go,Ec;function By(){if(Ec)return go;Ec=1;var i=ge();function e(t,r){var n=i(t),o=Number(r);return n.setMinutes(o),n}return go=e,go}var _o,Ic;function Tc(){if(Ic)return _o;Ic=1;var i=ge(),e=hn();function t(r,n){var o=i(r),u=Number(n),a=o.getFullYear(),s=o.getDate(),l=new Date(0);l.setFullYear(a,u,15),l.setHours(0,0,0,0);var d=e(l);return o.setMonth(u,Math.min(s,d)),o}return _o=t,_o}var vo,Rc;function Dy(){if(Rc)return vo;Rc=1;var i=ge(),e=Tc();function t(r,n){var o=i(r),u=Number(n),a=Math.floor(o.getMonth()/3)+1,s=u-a;return e(o,o.getMonth()+s*3)}return vo=t,vo}var bo,Ac;function Ly(){if(Ac)return bo;Ac=1;var i=ge();function e(t,r){var n=i(t),o=Number(r);return n.setSeconds(o),n}return bo=e,bo}var wo,Oc;function Fy(){if(Oc)return wo;Oc=1;var i=ge();function e(t,r){var n=i(t),o=Number(r);return n.setFullYear(o),n}return wo=e,wo}var So,xc;function Uy(){if(xc)return So;xc=1;var i=ge();function e(t){var r=i(t);return r.setDate(1),r.setHours(0,0,0,0),r}return So=e,So}var Eo,Cc;function Ny(){if(Cc)return Eo;Cc=1;var i=bt();function e(){return i(new Date)}return Eo=e,Eo}var Io,kc;function jy(){if(kc)return Io;kc=1;function i(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n+1),o.setHours(0,0,0,0),o}return Io=i,Io}var To,qc;function $y(){if(qc)return To;qc=1;function i(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n-1),o.setHours(0,0,0,0),o}return To=i,To}var Ro,Mc;function Hy(){if(Mc)return Ro;Mc=1;var i=$t();function e(t,r){var n=Number(r);return i(t,-n)}return Ro=e,Ro}var Ao,Pc;function Wy(){if(Pc)return Ao;Pc=1;var i=Hu();function e(t,r){var n=Number(r);return i(t,-n)}return Ao=e,Ao}var Oo,Bc;function Yy(){if(Bc)return Oo;Bc=1;var i=Ht();function e(t,r){var n=Number(r);return i(t,-n)}return Oo=e,Oo}var xo,Dc;function Gy(){if(Dc)return xo;Dc=1;var i=Ku();function e(t,r){var n=Number(r);return i(t,-n)}return xo=e,xo}var Co,Lc;function zy(){if(Lc)return Co;Lc=1;var i=tr();function e(t,r){var n=Number(r);return i(t,-n)}return Co=e,Co}var ko,Fc;function Vy(){if(Fc)return ko;Fc=1;var i=Zu();function e(t,r){var n=Number(r);return i(t,-n)}return ko=e,ko}var qo,Uc;function Ky(){if(Uc)return qo;Uc=1;var i=tf();function e(t,r){var n=Number(r);return i(t,-n)}return qo=e,qo}var Mo,Nc;function Qy(){if(Nc)return Mo;Nc=1;var i=gn();function e(t,r){var n=Number(r);return i(t,-n)}return Mo=e,Mo}var Po,jc;function Jy(){if(jc)return Po;jc=1;var i=of();function e(t,r){var n=Number(r);return i(t,-n)}return Po=e,Po}var Bo,$c;function Xy(){return $c||($c=1,Bo={addDays:$t(),addHours:Hu(),addISOYears:zu(),addMilliseconds:Ht(),addMinutes:Ku(),addMonths:tr(),addQuarters:Zu(),addSeconds:tf(),addWeeks:gn(),addYears:of(),areRangesOverlapping:lm(),closestIndexTo:cm(),closestTo:hm(),compareAsc:jt(),compareDesc:Vr(),differenceInCalendarDays:Xt(),differenceInCalendarISOWeeks:dm(),differenceInCalendarISOYears:cf(),differenceInCalendarMonths:Mu(),differenceInCalendarQuarters:pm(),differenceInCalendarWeeks:mm(),differenceInCalendarYears:gf(),differenceInDays:vf(),differenceInHours:ym(),differenceInISOYears:gm(),differenceInMilliseconds:er(),differenceInMinutes:_m(),differenceInMonths:tn(),differenceInQuarters:vm(),differenceInSeconds:Jr(),differenceInWeeks:bm(),differenceInYears:wm(),distanceInWords:Lu(),distanceInWordsStrict:Sm(),distanceInWordsToNow:Uu(),eachDay:Em(),endOfDay:Un(),endOfHour:Im(),endOfISOWeek:Tm(),endOfISOYear:Rm(),endOfMinute:Am(),endOfMonth:Ff(),endOfQuarter:Om(),endOfSecond:xm(),endOfToday:Cm(),endOfTomorrow:km(),endOfWeek:Mf(),endOfYear:qm(),endOfYesterday:Mm(),format:Ou(),getDate:Pm(),getDay:Bm(),getDayOfYear:mu(),getDaysInMonth:hn(),getDaysInYear:Dm(),getHours:Lm(),getISODay:Xf(),getISOWeek:Ur(),getISOWeeksInYear:Fm(),getISOYear:St(),getMilliseconds:Um(),getMinutes:Nm(),getMonth:jm(),getOverlappingDaysInRanges:$m(),getQuarter:df(),getSeconds:Hm(),getTime:Wm(),getYear:Ym(),isAfter:Gm(),isBefore:zm(),isDate:Or(),isEqual:Vm(),isFirstDayOfMonth:Km(),isFriday:Qm(),isFuture:Jm(),isLastDayOfMonth:Xm(),isLeapYear:Vf(),isMonday:Zm(),isPast:ey(),isSameDay:ty(),isSameHour:bl(),isSameISOWeek:El(),isSameISOYear:Tl(),isSameMinute:xl(),isSameMonth:kl(),isSameQuarter:Bl(),isSameSecond:Ul(),isSameWeek:Ti(),isSameYear:jl(),isSaturday:ry(),isSunday:ny(),isThisHour:iy(),isThisISOWeek:oy(),isThisISOYear:sy(),isThisMinute:ay(),isThisMonth:uy(),isThisQuarter:fy(),isThisSecond:ly(),isThisWeek:cy(),isThisYear:hy(),isThursday:dy(),isToday:py(),isTomorrow:my(),isTuesday:yy(),isValid:Su(),isWednesday:gy(),isWeekend:_y(),isWithinRange:vy(),isYesterday:by(),lastDayOfISOWeek:wy(),lastDayOfISOYear:Sy(),lastDayOfMonth:Ey(),lastDayOfQuarter:Iy(),lastDayOfWeek:uc(),lastDayOfYear:Ty(),max:Ry(),min:Ay(),parse:ge(),setDate:Oy(),setDay:xy(),setDayOfYear:Cy(),setHours:ky(),setISODay:qy(),setISOWeek:My(),setISOYear:Yu(),setMilliseconds:Py(),setMinutes:By(),setMonth:Tc(),setQuarter:Dy(),setSeconds:Ly(),setYear:Fy(),startOfDay:bt(),startOfHour:_l(),startOfISOWeek:wt(),startOfISOYear:Nt(),startOfMinute:Al(),startOfMonth:Uy(),startOfQuarter:Ml(),startOfSecond:Ll(),startOfToday:Ny(),startOfTomorrow:jy(),startOfWeek:Zt(),startOfYear:cu(),startOfYesterday:$y(),subDays:Hy(),subHours:Wy(),subISOYears:Sf(),subMilliseconds:Yy(),subMinutes:Gy(),subMonths:zy(),subQuarters:Vy(),subSeconds:Ky(),subWeeks:Qy(),subYears:Jy()}),Bo}var Hc=Xy();function xt(i){return i.replace(/<[^>]*\/?>([\s\S]*)?<\/.*?>/gi,function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")})}class Zy{constructor(e){this.roomAdapter=e,this.name=null,this.emails=[],this.options={}}withName(e){return this.name=e,this}withOptions(e){return this.options=e,this}addParticipants(...e){return this.emails=this.emails.filter(t=>e.indexOf(t)===-1).concat(...e),this}create(){const e=this.name,t=this.emails,r=this.options;return this.roomAdapter.createRoom(e,t,{avatarURL:r.avatarURL},r)}}function eg(i,e){let t=null;return function(...r){t!=null&&clearTimeout(t),t=setTimeout(()=>{i(...r),t=null},e)}}class pt{constructor(e){this.id=e.id,this.before_id=e.comment_before_id,this.message=xt(e.message),this.username_as=e.username_as||e.username,this.username_real=e.username_real||e.email,this.email=this.username_real,this.user_extras=e.user_extras,this.date=Hc.format(e.timestamp,"YYYY-MM-DD"),this.time=Hc.format(e.timestamp,"HH:mm"),this.timestamp=e.timestamp,this.unique_id=e.unique_temp_id||e.unique_id,this.unique_temp_id=e.unique_temp_id||e.unique_id,this.avatar=e.user_avatar_url,this.room_id=e.room_id,this.isChannel=e.is_public_channel,this.unix_timestamp=e.unix_timestamp,this.unix_nano_timestamp=e.unix_nano_timestamp,this.extras=e.extras,this.is_deleted=e.is_deleted,this.isPending=!1,this.isFailed=!1,this.isDelivered=!1,this.isRead=!1,this.isSent=!1,this.attachment=null,this.payload=e.payload,this.status=e.status,e.type==="reply"&&(e.payload.replied_comment_message=xt(e.payload.replied_comment_message),e.payload.text=xt(e.payload.text)),this.type=e.type,this.subtype=e.type==="custom"?e.payload.type:null,e.status==="sent"?this.markAsSent():e.status==="delivered"?this.markAsDelivered():e.status==="read"&&this.markAsRead()}isAttachment(e){return e.substring(0,6)==="[file]"}isImageAttachment(e){return this.isAttachment(e)&&e.match(/\.(jpg|jpeg|gif|png)/i)!=null}attachUniqueId(e){this.unique_id=e}getAttachmentURI(e){if(!this.isAttachment(e))return;const t=e.length,r=6,n=t-7;return e.substring(r,n).trim()}setAttachment(e){this.attachment=e}markAsPending(){this.isPending=!0,this.isDelivered=!1,this.status="pending"}markAsSent(){this.isSent=!0,this.isPending=!1,this.isFailed=!1,this.status="sent"}markAsDelivered({actor:e,activeActorId:t}={}){e!==t&&(this.isRead||this.status==="read"||(this.isSent=!0,this.isRead=!1,this.isDelivered=!0,this.status="delivered"))}markAsRead({actor:e,activeActorId:t}={}){e!==t&&(this.isPending=!1,this.isSent=!0,this.isDelivered=!0,this.isRead=!0,this.status="read")}markAsFailed(){this.isFailed=!0,this.isPending=!1,this.isStatus="failed"}update(e){this.id=e.id,this.before_id=e.comment_before_id,this.message=xt(e.message),e.payload&&(this.payload=e.payload),e.status&&(this.status=e.status),e.type==="reply"&&(this.payload.replied_comment_message=xt(e.payload.replied_comment_message),this.payload.text=xt(e.payload.text)),e.status==="sent"?this.markAsSent():e.status==="delivered"?this.markAsDelivered():e.status==="read"&&this.markAsRead()}}class rr{constructor(e){this.id=e.id,this.last_comment_id=e.last_comment_id,this.last_comment_message=e.last_comment_message,this.last_comment_message_created_at=e.last_comment_message_created_at,this.last_comment_topic_title=e.last_comment_topic_title,this.avatar=e.room_avatar||e.avatarURL||e.avatar_url,this.name=e.room_name,this.room_type=e.room_type||e.chat_type,this.secret_code=e.secret_code,this.participants=e.participants,this.options=e.options,this.topics=[],this.last_comment=e.last_comment,this.comments=[],this.count_notif=e.unread_count,this.isLoaded=!1,this.custom_title=null,this.custom_subtitle=null,this.options=e.options,this.unique_id=e.unique_id,this.isChannel=e.is_public_channel,this.participantNumber=e.room_total_participants,e.comments&&this.receiveComments(e.comments)}isCurrentlySelected(e){return this.id===e.id}getParticipantCount(){return this.participants==null?this.participantNumber:this.participants.length}setTitle(e){this.custom_title=e}setSubTitle(e){this.custom_subtitle=e}receiveComment(e){if(e.room_id!==this.id)return;const t=this.comments.find(r=>r.unique_id===e.unique_id);t?(t.id=e.id,t.message=e.message,t.date=e.date,t.time=e.time,t.unix_timestamp=e.unix_timestamp):this.comments=[...this.comments,e]}receiveComments(e){e.forEach(t=>{this.receiveComment(new pt(t))})}getParticipant(e){return this.participants.find(t=>t.email===e)||null}addParticipant(e){this.getParticipant(e.email)||this.participants.push(e)}}class Do{constructor({baseURL:e,AppId:t,userId:r,version:n,getCustomHeader:o,expiredTokenAdapterGetter:u}){this.baseURL=e,this.token=null,this.userId=r,this.AppId=t,this.version=n,this.getCustomHeader=o,this._expiredTokenAdapterGetter=u}setToken(e){this.token=e}get(e,t={},r){return this._retryHelper(()=>ke(this,null,function*(){var n=st.get(`${this.baseURL}/${e}`);return r&&r.baseURL&&(n=st.get(`${r.baseURL}/${e}`)),n=this.setupHeaders(n,t),n}))}get_request(e){return this._retryHelper(()=>ke(this,null,function*(){let t=st.get(`${this.baseURL}/${e}`);return t=this.setupHeaders(t,{}),t}))}post(e,t={},r={}){return this._retryHelper(()=>ke(this,null,function*(){let n=st.post(`${this.baseURL}/${e}`);return n=this.setupHeaders(n,r),n.send(t).set("Content-Type","application/x-www-form-urlencoded")}))}post_json(e,t={},r={}){return this._retryHelper(()=>ke(this,null,function*(){let n=st.post(`${this.baseURL}/${e}`);return n=this.setupHeaders(n,r),n.send(t),n}))}put(e,t={},r={}){return this._retryHelper(()=>ke(this,null,function*(){let n=st.put(`${this.baseURL}/${e}`);return n=this.setupHeaders(n,r),n.send(t).set("Content-Type","application/x-www-form-urlencoded")}))}patch(e,t={},r={}){return this._retryHelper(()=>ke(this,null,function*(){let n=st.patch(`${this.baseURL}/${e}`);return n=this.setupHeaders(n,r),n.send(t).set("Content-Type","application/x-www-form-urlencoded")}))}del(e,t={},r={}){return this._retryHelper(()=>ke(this,null,function*(){let n=st.del(`${this.baseURL}/${e}`);return n=this.setupHeaders(n,r),n.send(t).set("Content-Type","application/json")}))}setupHeaders(e,t={}){if(e.set("QISCUS-SDK-PLATFORM","javascript"),this.AppId!=null&&e.set("QISCUS-SDK-APP-ID",`${this.AppId}`),this.userId!=null&&e.set("QISCUS-SDK-USER-ID",`${this.userId}`),this.token!=null&&e.set("QISCUS-SDK-TOKEN",`${this.token}`),this.version!=null&&e.set("QISCUS-SDK-VERSION",`${this.version}`),this.getCustomHeader!=null){const r=this.getCustomHeader();Object.keys(r).filter(n=>r[n]!=null).forEach(n=>{e.set(n,r[n])})}if(Object.keys(t).length<1)return e;for(let r in t)t.hasOwnProperty(r)&&e.set(r,t[r]);return e}_retryHelper(e){return ke(this,null,function*(){var t,r,n,o;try{return yield e()}catch(u){const a=(t=u==null?void 0:u.response)==null?void 0:t.status,s=(r=u==null?void 0:u.response)==null?void 0:r.body;if(a===403&&((o=(n=s.error)==null?void 0:n.message)==null?void 0:o.toLowerCase())==="unauthorized. token is expired")return yield this._expiredTokenAdapterGetter().refreshAuthToken(),yield e();throw u}})}}class tg{constructor(e){this.HTTPAdapter=e,this.refreshToken=null,this.userId=null,this.autoRefreshToken=!1}getNonce(){return this.HTTPAdapter.post("api/v2/sdk/auth/nonce").then(e=>e.body.results)}loginOrRegister(e){return this.HTTPAdapter.post("api/v2/sdk/login_or_register",e).then(t=>{if(t.body.status!==200)return Promise.reject(t);let r=t.body.results;return this.userId=r.user.email,this.refreshToken=r.user.refresh_token,r})}verifyIdentityToken(e){return this.HTTPAdapter.post("api/v2/sdk/auth/verify_identity_token",{identity_token:e}).then(t=>{let r=t.body.results;return this.userId=r.user.email,this.refreshToken=r.user.refresh_token,r})}refreshAuthToken(){return this.HTTPAdapter.post("api/v2/sdk/refresh_user_token",{user_id:this.userId,refresh_token:this.refreshToken}).then(e=>{let t=e.body.results;return this.refreshToken=t.refresh_token,this.HTTPAdapter.token=t.token,t})}expiredAuthToken(){return this.HTTPAdapter.post("api/v2/sdk/expire_user_token",{user_id:this.userId}).then(e=>e.body.results)}}var Lo,Wc;function rg(){if(Wc)return Lo;Wc=1;var i="Expected a function",e=NaN,t="[object Symbol]",r=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,u=/^0o[0-7]+$/i,a=parseInt,s=typeof xe=="object"&&xe&&xe.Object===Object&&xe,l=typeof self=="object"&&self&&self.Object===Object&&self,d=s||l||Function("return this")(),_=Object.prototype,g=_.toString,E=Math.max,w=Math.min,q=function(){return d.Date.now()};function k(p,v,I){var B,H,V,P,ce,oe,ne=0,se=!1,he=!1,J=!0;if(typeof p!="function")throw new TypeError(i);v=h(v)||0,R(I)&&(se=!!I.leading,he="maxWait"in I,V=he?E(h(I.maxWait)||0,v):V,J="trailing"in I?!!I.trailing:J);function me($){var z=B,Y=H;return B=H=void 0,ne=$,P=p.apply(Y,z),P}function de($){return ne=$,ce=setTimeout(re,v),se?me($):P}function be($){var z=$-oe,Y=$-ne,T=v-z;return he?w(T,V-Y):T}function G($){var z=$-oe,Y=$-ne;return oe===void 0||z>=v||z<0||he&&Y>=V}function re(){var $=q();if(G($))return j($);ce=setTimeout(re,be($))}function j($){return ce=void 0,J&&B?me($):(B=H=void 0,P)}function L(){ce!==void 0&&clearTimeout(ce),ne=0,B=oe=H=ce=void 0}function M(){return ce===void 0?P:j(q())}function D(){var $=q(),z=G($);if(B=arguments,H=this,oe=$,z){if(ce===void 0)return de(oe);if(he)return ce=setTimeout(re,v),me(oe)}return ce===void 0&&(ce=setTimeout(re,v)),P}return D.cancel=L,D.flush=M,D}function A(p,v,I){var B=!0,H=!0;if(typeof p!="function")throw new TypeError(i);return R(I)&&(B="leading"in I?!!I.leading:B,H="trailing"in I?!!I.trailing:H),k(p,v,{leading:B,maxWait:v,trailing:H})}function R(p){var v=typeof p;return!!p&&(v=="object"||v=="function")}function S(p){return!!p&&typeof p=="object"}function b(p){return typeof p=="symbol"||S(p)&&g.call(p)==t}function h(p){if(typeof p=="number")return p;if(b(p))return e;if(R(p)){var v=typeof p.valueOf=="function"?p.valueOf():p;p=R(v)?v+"":v}if(typeof p!="string")return p===0?p:+p;p=p.replace(r,"");var I=o.test(p);return I||u.test(p)?a(p.slice(2),I?2:8):n.test(p)?e:+p}return Lo=A,Lo}var ng=rg();const ig=rt(ng);function nr(i){const e={},t=(r,n)=>`${r}=${n}`;return{param(r,n){return e[r]=n,this},build(){const r=Object.keys(e).filter(n=>e[n]!=null).map(n=>Array.isArray(e[n])?e[n].map(o=>t(`${n}[]`,o)).join("&"):t(n,e[n])).join("&");return[i].concat(r).join("?")}}}class og{constructor(e){He(this,"updateCommentStatus",ig((e,t,r)=>{const n={room_id:e};return t&&(n.last_comment_read_id=t),r&&(n.last_comment_received_id=r),this.HTTPAdapter.post("api/v2/sdk/update_comment_status",n)},500));this.HTTPAdapter=e,this.token=e.token}postComment(e,t,r,n,o,u){return this.HTTPAdapter.post_json("api/v2/sdk/post_comment",{comment:t,topic_id:e,unique_temp_id:r,type:n,payload:o,extras:u}).then(a=>a.body.status!==200?Promise.reject(a):Promise.resolve(a.body.results.comment))}loadRoomList(e={}){var r;const t=nr("api/v2/sdk/user_rooms").param("page",e.page).param("show_participants",e.show_participants||!0).param("limit",e.limit).param("show_empty",e.show_empty).param("room_type",(r=e.room_type)!=null?r:"default").build();return this.HTTPAdapter.get(t).then(n=>n.body.status!==200?Promise.reject(n):Promise.resolve(n.body.results.rooms_info))}searchMessages(e){const t={query:e.query||null,room_id:e.room_id||null,last_comment_id:e.last_comment_id||null};return this.HTTPAdapter.post("api/v2/sdk/search_messages",t).then(r=>r.body.results.comments)}updateProfile(e){const t={name:e.name||null,avatar_url:e.avatar_url||null,extras:e.extras?JSON.stringify(e.extras):null};return this.HTTPAdapter.patch("api/v2/sdk/my_profile",t).then(r=>r.body.results.user)}uploadFile(e){const t={file:e};return this.HTTPAdapter.post("api/v2/sdk/upload",t).then(r=>r.body)}getRoomsInfo(e){const t={show_participants:!0,show_removed:!1};return e.room_ids&&(t.room_id=e.room_ids),e.room_unique_ids&&(t.room_unique_id=e.room_unique_ids),e.show_participants&&(t.show_participants=e.show_participants),e.show_removed&&(t.show_removed=e.show_removed),this.HTTPAdapter.post_json("api/v2/sdk/rooms_info",t).then(r=>r.body)}loadComments(e,t){const r=nr("api/v2/sdk/load_comments").param("topic_id",e).param("last_comment_id",t.last_comment_id).param("timestamp",t.timestamp).param("after",t.after).param("limit",t.limit).build();return this.HTTPAdapter.get(r).then(n=>n.status!==200?Promise.reject(n):Promise.resolve(n.body.results.comments))}deleteComment(e,t,r=!0,n=!0){r===!1&&console.warn("Deprecated: delete comment for me will be removed on next release"),n===!1&&console.warn("Deprecated: soft delete will be removed on next release");const o={unique_ids:t,is_delete_for_everyone:r,is_hard_delete:n};return this.HTTPAdapter.del("api/v2/sdk/delete_messages",o).then(u=>u.body)}clearRoomMessages(e){const t={room_channel_ids:e};return this.HTTPAdapter.del("api/v2/sdk/clear_room_messages",t).then(r=>r.body)}getCommentReceiptStatus(e){return this.HTTPAdapter.get(`api/v2/sdk/comment_receipt?comment_id=${e}`).then(t=>t.body)}getBlockedUser(e=1,t=20){const r=`api/v2/sdk/get_blocked_users?page=${e}&limit=${t}`;return this.HTTPAdapter.get(r).then(n=>n.body.status!==200?Promise.reject(n):Promise.resolve(n.body.results.blocked_users))}blockUser(e){if(!e)throw new Error("email is required");let t={user_email:e};return this.HTTPAdapter.post("api/v2/sdk/block_user",t).then(r=>r.body.status!==200?Promise.reject(r):Promise.resolve(r.body.results.user))}unblockUser(e){if(!e)throw new Error("email is required");const t={user_email:e};return this.HTTPAdapter.post("api/v2/sdk/unblock_user",t).then(r=>r.body.status!==200?Promise.reject(r):Promise.resolve(r.body.results.user))}getProfile(){return this.HTTPAdapter.get("api/v2/sdk/my_profile").then(e=>e.body.results.user)}getUserPresences(e){let t={user_ids:e};return this.HTTPAdapter.post_json("api/v2/sdk/users/status",t).then(r=>r.body.status!==200?Promise.reject(r):Promise.resolve(r.body.results.user_status))}updateMessage(e){const t={token:this.token,comment:e.message,unique_id:e.unique_id||e.unique_temp_id};return e.extras!=null&&(t.extras=e.extras),e.payload!=null&&(t.payload=e.payload),this.HTTPAdapter.post_json("api/v2/sdk/update_message",t).then(r=>r.body.results.comment)}}class sg{constructor(e){this.HTTPAdapter=e,this.token=e.token}getOrCreateRoom(e,t,r){let n={emails:e};return r&&(n[r]=r),t&&(n.options=JSON.stringify(t)),this.HTTPAdapter.post("api/v2/sdk/get_or_create_room_with_target",n).then(o=>{if(o.body.status!==200)return Promise.reject(o);const u=o.body.results.room;u.avatar=u.avatar_url,u.comments=o.body.results.comments.reverse();const a=u.participants.find(s=>s.email===e);return u.name=a?a.username:"Room name",Promise.resolve(u)})}getRoomById(e){return this.HTTPAdapter.get(`api/v2/sdk/get_room_by_id?id=${e}`).then(t=>t.body)}getOrCreateRoomByUniqueId(e,t,r){let n={unique_id:e,name:t,avatar_url:r};return this.HTTPAdapter.post("api/v2/sdk/get_or_create_room_with_unique_id",n).then(o=>{if(o.body.status!==200)return Promise.reject(o);const u=o.body.results.room;return u.avatar=u.avatar_url,u.comments=o.body.results.comments.reverse(),u.name=u.room_name,Promise.resolve(u)})}createRoom(e,t,r={},n={}){const o=Object.keys(n).length<=0?null:JSON.stringify(n),u={name:e,"participants[]":t,avatar_url:r.avatarURL,options:o};return this.HTTPAdapter.post("api/v2/sdk/create_room",u).then(a=>{if(a.body.status!==200)return Promise.reject(a);const s=a.body.results.room;return s.comments=a.body.results.comments,Promise.resolve({id:s.id,name:s.room_name,lastCommentId:s.last_comment_id,lastCommentMessage:s.last_comment_message,lastTopicId:s.last_topic_id,avatarURL:s.avatar_url,options:s.options,participants:s.participants.map(l=>({id:l.id,email:l.email,username:l.username,avatarURL:l.avatar_url}))})})}updateRoom(e){if(!e.id)throw new Error("id is required");let t={id:e.id};return e.room_name&&(t.room_name=e.room_name),e.avatar_url&&(t.avatar_url=e.avatar_url),e.options&&(t.options=JSON.stringify(e.options)),this.HTTPAdapter.post("api/v2/sdk/update_room",t).then(r=>r.body.status!==200?Promise.reject(r):Promise.resolve(r.body.results.room))}getTotalUnreadCount(){return this.HTTPAdapter.get("api/v2/sdk/total_unread_count").then(e=>e.body.results.total_unread_count)}getRoomUnreadCount(){return this.HTTPAdapter.get("api/v2/sdk/get_room_unread_count").then(e=>e.body.results.total_unread_count)}addParticipantsToGroup(e,t=[]){if(!e||!t)throw new Error("room_id and emails is required");let r={room_id:e,"emails[]":t};return this.HTTPAdapter.post("api/v2/sdk/add_room_participants",r).then(n=>n.body.status!==200?Promise.reject(n):Promise.resolve(n.body.results.participants_added))}removeParticipantsFromGroup(e,t=[]){if(!e||!t)throw new Error("room_id and emails is required");let r={room_id:e,"emails[]":t};return this.HTTPAdapter.post("api/v2/sdk/remove_room_participants",r).then(n=>n.body.status!==200?Promise.reject(n):Promise.resolve(n.body.results.participants_removed))}}const Wt="match.pattern.catchAll",Yc="match.pattern.OR",ag=Yc.toString(),Gc="match.pattern.AND",ug=Gc.toString(),zc="match.pattern.RANGE",fg=zc.toString(),Vc="match.pattern.REGEXP",lg=Vc.toString(),cg=/\/(.*)\/(.*)/;function Kc(){Error.call(this,"Missing when() catch-all pattern as last match argument, add [when()]: void 0"),"stack"in this||(this.stack=new Error().stack)}Kc.prototype=Object.create(Error.prototype);function hg(...i){const e=i[i.length-1];let t=[];for(let n in e)t.push(Ze.unserialize(n,e[n]));t.sort(function(n,o){return n.position<o.position?-1:1}),Object.getOwnPropertySymbols(e).indexOf(Wt)!==-1&&t.push(Ze.unserialize(Wt,e[Wt]));const r=function(n){const o=t.find(u=>u.match(n));if(!o)throw new Kc;return typeof o.result=="function"?o.result(n):o.result};return i.length===2?r(i[0]):r}function Ze(i){return i===void 0?Wt:i instanceof RegExp?Yt([Vc.toString(),i.toString()]):Yt(i)}Ze.__uid=0;function Yt(i){return JSON.stringify([Ze.__uid++,i])}function dg(i){return JSON.parse(i)}function pg(){return!0}function mg(i){if(Array.isArray(i)){if(i[0]===ag)return i.shift(),function(t){return i[0].some(r=>e(r,t))};if(i[0]===ug)return i.shift(),function(t){return i[0].every(r=>e(r,t))};if(i[0]===fg)return i.shift(),function(t){return i[0]<=t&&t<=i[1]};if(i[0]===lg){const t=cg.exec(i[1]);return e.bind(null,new RegExp(t[1],t[2]))}}function e(t,r){if(Array.isArray(r))return JSON.stringify(t)===JSON.stringify(r);if(t instanceof RegExp)return t.test(r);if(typeof r=="object"){for(let n in t)if(r[n]!==t[n])return!1;return!0}return t===r}return t=>e(i,t)}Ze.or=function(...i){return Yt([Yc.toString(),i])},Ze.and=function(...i){return Yt([Gc.toString(),i])},Ze.range=function(i,e){return Yt([zc.toString(),i,e])},Ze.unserialize=function(i,e){if(i===Wt)return{match:pg,result:e,position:1/0};const t=dg(i),r=t[1],n=t[0];return{match:mg(r),result:e,position:n}};function yg(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Qc={exports:{}},Ke=Qc.exports={},lt,ct;function Fo(){throw new Error("setTimeout has not been defined")}function Uo(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?lt=setTimeout:lt=Fo}catch(i){lt=Fo}try{typeof clearTimeout=="function"?ct=clearTimeout:ct=Uo}catch(i){ct=Uo}})();function Jc(i){if(lt===setTimeout)return setTimeout(i,0);if((lt===Fo||!lt)&&setTimeout)return lt=setTimeout,setTimeout(i,0);try{return lt(i,0)}catch(e){try{return lt.call(null,i,0)}catch(t){return lt.call(this,i,0)}}}function gg(i){if(ct===clearTimeout)return clearTimeout(i);if((ct===Uo||!ct)&&clearTimeout)return ct=clearTimeout,clearTimeout(i);try{return ct(i)}catch(e){try{return ct.call(null,i)}catch(t){return ct.call(this,i)}}}var mt=[],Ct=!1,Et,ir=-1;function _g(){!Ct||!Et||(Ct=!1,Et.length?mt=Et.concat(mt):ir=-1,mt.length&&Xc())}function Xc(){if(!Ct){var i=Jc(_g);Ct=!0;for(var e=mt.length;e;){for(Et=mt,mt=[];++ir<e;)Et&&Et[ir].run();ir=-1,e=mt.length}Et=null,Ct=!1,gg(i)}}Ke.nextTick=function(i){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];mt.push(new Zc(i,e)),mt.length===1&&!Ct&&Jc(Xc)};function Zc(i,e){this.fun=i,this.array=e}Zc.prototype.run=function(){this.fun.apply(null,this.array)},Ke.title="browser",Ke.browser=!0,Ke.env={},Ke.argv=[],Ke.version="",Ke.versions={};function yt(){}Ke.on=yt,Ke.addListener=yt,Ke.once=yt,Ke.off=yt,Ke.removeListener=yt,Ke.removeAllListeners=yt,Ke.emit=yt,Ke.prependListener=yt,Ke.prependOnceListener=yt,Ke.listeners=function(i){return[]},Ke.binding=function(i){throw new Error("process.binding is not supported")},Ke.cwd=function(){return"/"},Ke.chdir=function(i){throw new Error("process.chdir is not supported")},Ke.umask=function(){return 0};var vg=Qc.exports;const Re=yg(vg);var kt={exports:{}},or={exports:{}},eh;function Gt(){if(eh)return or.exports;eh=1;var i=typeof Reflect=="object"?Reflect:null,e=i&&typeof i.apply=="function"?i.apply:function(h,p,v){return Function.prototype.apply.call(h,p,v)},t;i&&typeof i.ownKeys=="function"?t=i.ownKeys:Object.getOwnPropertySymbols?t=function(h){return Object.getOwnPropertyNames(h).concat(Object.getOwnPropertySymbols(h))}:t=function(h){return Object.getOwnPropertyNames(h)};function r(b){console&&console.warn&&console.warn(b)}var n=Number.isNaN||function(h){return h!==h};function o(){o.init.call(this)}or.exports=o,or.exports.once=A,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var u=10;function a(b){if(typeof b!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof b)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(b){if(typeof b!="number"||b<0||n(b))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+b+".");u=b}}),o.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},o.prototype.setMaxListeners=function(h){if(typeof h!="number"||h<0||n(h))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+h+".");return this._maxListeners=h,this};function s(b){return b._maxListeners===void 0?o.defaultMaxListeners:b._maxListeners}o.prototype.getMaxListeners=function(){return s(this)},o.prototype.emit=function(h){for(var p=[],v=1;v<arguments.length;v++)p.push(arguments[v]);var I=h==="error",B=this._events;if(B!==void 0)I=I&&B.error===void 0;else if(!I)return!1;if(I){var H;if(p.length>0&&(H=p[0]),H instanceof Error)throw H;var V=new Error("Unhandled error."+(H?" ("+H.message+")":""));throw V.context=H,V}var P=B[h];if(P===void 0)return!1;if(typeof P=="function")e(P,this,p);else for(var ce=P.length,oe=w(P,ce),v=0;v<ce;++v)e(oe[v],this,p);return!0};function l(b,h,p,v){var I,B,H;if(a(p),B=b._events,B===void 0?(B=b._events=Object.create(null),b._eventsCount=0):(B.newListener!==void 0&&(b.emit("newListener",h,p.listener?p.listener:p),B=b._events),H=B[h]),H===void 0)H=B[h]=p,++b._eventsCount;else if(typeof H=="function"?H=B[h]=v?[p,H]:[H,p]:v?H.unshift(p):H.push(p),I=s(b),I>0&&H.length>I&&!H.warned){H.warned=!0;var V=new Error("Possible EventEmitter memory leak detected. "+H.length+" "+String(h)+" listeners added. Use emitter.setMaxListeners() to increase limit");V.name="MaxListenersExceededWarning",V.emitter=b,V.type=h,V.count=H.length,r(V)}return b}o.prototype.addListener=function(h,p){return l(this,h,p,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(h,p){return l(this,h,p,!0)};function d(){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 _(b,h,p){var v={fired:!1,wrapFn:void 0,target:b,type:h,listener:p},I=d.bind(v);return I.listener=p,v.wrapFn=I,I}o.prototype.once=function(h,p){return a(p),this.on(h,_(this,h,p)),this},o.prototype.prependOnceListener=function(h,p){return a(p),this.prependListener(h,_(this,h,p)),this},o.prototype.removeListener=function(h,p){var v,I,B,H,V;if(a(p),I=this._events,I===void 0)return this;if(v=I[h],v===void 0)return this;if(v===p||v.listener===p)--this._eventsCount===0?this._events=Object.create(null):(delete I[h],I.removeListener&&this.emit("removeListener",h,v.listener||p));else if(typeof v!="function"){for(B=-1,H=v.length-1;H>=0;H--)if(v[H]===p||v[H].listener===p){V=v[H].listener,B=H;break}if(B<0)return this;B===0?v.shift():q(v,B),v.length===1&&(I[h]=v[0]),I.removeListener!==void 0&&this.emit("removeListener",h,V||p)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(h){var p,v,I;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[h]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete v[h]),this;if(arguments.length===0){var B=Object.keys(v),H;for(I=0;I<B.length;++I)H=B[I],H!=="removeListener"&&this.removeAllListeners(H);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(p=v[h],typeof p=="function")this.removeListener(h,p);else if(p!==void 0)for(I=p.length-1;I>=0;I--)this.removeListener(h,p[I]);return this};function g(b,h,p){var v=b._events;if(v===void 0)return[];var I=v[h];return I===void 0?[]:typeof I=="function"?p?[I.listener||I]:[I]:p?k(I):w(I,I.length)}o.prototype.listeners=function(h){return g(this,h,!0)},o.prototype.rawListeners=function(h){return g(this,h,!1)},o.listenerCount=function(b,h){return typeof b.listenerCount=="function"?b.listenerCount(h):E.call(b,h)},o.prototype.listenerCount=E;function E(b){var h=this._events;if(h!==void 0){var p=h[b];if(typeof p=="function")return 1;if(p!==void 0)return p.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function w(b,h){for(var p=new Array(h),v=0;v<h;++v)p[v]=b[v];return p}function q(b,h){for(;h+1<b.length;h++)b[h]=b[h+1];b.pop()}function k(b){for(var h=new Array(b.length),p=0;p<h.length;++p)h[p]=b[p].listener||b[p];return h}function A(b,h){return new Promise(function(p,v){function I(H){b.removeListener(h,B),v(H)}function B(){typeof b.removeListener=="function"&&b.removeListener("error",I),p([].slice.call(arguments))}S(b,h,B,{once:!0}),h!=="error"&&R(b,I,{once:!0})})}function R(b,h,p){typeof b.on=="function"&&S(b,"error",h,p)}function S(b,h,p,v){if(typeof b.on=="function")v.once?b.once(h,p):b.on(h,p);else if(typeof b.addEventListener=="function")b.addEventListener(h,function I(B){v.once&&b.removeEventListener(h,I),p(B)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof b)}return or.exports}var No,th;function jo(){if(th)return No;th=1,No=e;var i=Object.prototype.hasOwnProperty;function e(){for(var t={},r=0;r<arguments.length;r++){var n=arguments[r];for(var o in n)i.call(n,o)&&(t[o]=n[o])}return t}return No}var sr={exports:{}},$o,rh;function nh(){return rh||(rh=1,$o=Gt().EventEmitter),$o}var Ho={},ih;function zt(){return ih||(ih=1,(function(i){Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e={},t={};t.byteLength=d,t.toByteArray=g,t.fromByteArray=q;for(var r=[],n=[],o=typeof Uint8Array!="undefined"?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=u.length;a<s;++a)r[a]=u[a],n[u.charCodeAt(a)]=a;n[45]=62,n[95]=63;function l(R){var S=R.length;if(S%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var b=R.indexOf("=");b===-1&&(b=S);var h=b===S?0:4-b%4;return[b,h]}function d(R){var S=l(R),b=S[0],h=S[1];return(b+h)*3/4-h}function _(R,S,b){return(S+b)*3/4-b}function g(R){var S,b=l(R),h=b[0],p=b[1],v=new o(_(R,h,p)),I=0,B=p>0?h-4:h,H;for(H=0;H<B;H+=4)S=n[R.charCodeAt(H)]<<18|n[R.charCodeAt(H+1)]<<12|n[R.charCodeAt(H+2)]<<6|n[R.charCodeAt(H+3)],v[I++]=S>>16&255,v[I++]=S>>8&255,v[I++]=S&255;return p===2&&(S=n[R.charCodeAt(H)]<<2|n[R.charCodeAt(H+1)]>>4,v[I++]=S&255),p===1&&(S=n[R.charCodeAt(H)]<<10|n[R.charCodeAt(H+1)]<<4|n[R.charCodeAt(H+2)]>>2,v[I++]=S>>8&255,v[I++]=S&255),v}function E(R){return r[R>>18&63]+r[R>>12&63]+r[R>>6&63]+r[R&63]}function w(R,S,b){for(var h,p=[],v=S;v<b;v+=3)h=(R[v]<<16&16711680)+(R[v+1]<<8&65280)+(R[v+2]&255),p.push(E(h));return p.join("")}function q(R){for(var S,b=R.length,h=b%3,p=[],v=16383,I=0,B=b-h;I<B;I+=v)p.push(w(R,I,I+v>B?B:I+v));return h===1?(S=R[b-1],p.push(r[S>>2]+r[S<<4&63]+"==")):h===2&&(S=(R[b-2]<<8)+R[b-1],p.push(r[S>>10]+r[S>>4&63]+r[S<<2&63]+"=")),p.join("")}var k={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */k.read=function(R,S,b,h,p){var v,I,B=p*8-h-1,H=(1<<B)-1,V=H>>1,P=-7,ce=b?p-1:0,oe=b?-1:1,ne=R[S+ce];for(ce+=oe,v=ne&(1<<-P)-1,ne>>=-P,P+=B;P>0;v=v*256+R[S+ce],ce+=oe,P-=8);for(I=v&(1<<-P)-1,v>>=-P,P+=h;P>0;I=I*256+R[S+ce],ce+=oe,P-=8);if(v===0)v=1-V;else{if(v===H)return I?NaN:(ne?-1:1)*(1/0);I=I+Math.pow(2,h),v=v-V}return(ne?-1:1)*I*Math.pow(2,v-h)},k.write=function(R,S,b,h,p,v){var I,B,H,V=v*8-p-1,P=(1<<V)-1,ce=P>>1,oe=p===23?Math.pow(2,-24)-Math.pow(2,-77):0,ne=h?0:v-1,se=h?1:-1,he=S<0||S===0&&1/S<0?1:0;for(S=Math.abs(S),isNaN(S)||S===1/0?(B=isNaN(S)?1:0,I=P):(I=Math.floor(Math.log(S)/Math.LN2),S*(H=Math.pow(2,-I))<1&&(I--,H*=2),I+ce>=1?S+=oe/H:S+=oe*Math.pow(2,1-ce),S*H>=2&&(I++,H/=2),I+ce>=P?(B=0,I=P):I+ce>=1?(B=(S*H-1)*Math.pow(2,p),I=I+ce):(B=S*Math.pow(2,ce-1)*Math.pow(2,p),I=0));p>=8;R[b+ne]=B&255,ne+=se,B/=256,p-=8);for(I=I<<p|B,V+=p;V>0;R[b+ne]=I&255,ne+=se,I/=256,V-=8);R[b+ne-se]|=he*128};/*!
3
3
  * The buffer module from node.js, for the browser.
4
4
  *
5
- * @author Feross Aboukhadijeh <http://feross.org>
5
+ * @author Feross Aboukhadijeh <https://feross.org>
6
6
  * @license MIT
7
- */
8
- var n=r(245),o=r(246),i=r(247);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(this,e)}return c(this,e,t,r)}function c(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=p(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(t,r),o=(e=a(e,n)).write(t,r);o!==n&&(e=e.slice(0,o));return e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|h(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):p(e,t);if("Buffer"===t.type&&i(t.data))return p(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function f(e,t){if(l(t),e=a(e,t<0?0:0|h(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function p(e,t){var r=t.length<0?0:0|h(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function h(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(n)return B(e).length;t=(""+t).toLowerCase(),n=!0}}function m(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return A(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,o);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,o){var i,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var l=-1;for(i=r;i<a;i++)if(c(e,i)===c(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===u)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var f=!0,p=0;p<u;p++)if(c(e,i+p)!==c(t,p)){f=!1;break}if(f)return i}return-1}function b(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function _(e,t,r,n){return H(B(t,e.length-r),e,r,n)}function w(e,t,r,n){return H(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function k(e,t,r,n){return w(e,t,r,n)}function S(e,t,r,n){return H(F(t),e,r,n)}function x(e,t,r,n){return H(function(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i,s,a,u,c=e[o],l=null,f=c>239?4:c>223?3:c>191?2:1;if(o+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(l=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=f}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return c(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return function(e,t,r,n){return l(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},u.allocUnsafe=function(e){return f(null,e)},u.allocUnsafeSlow=function(e){return f(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o<i;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var s=e[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?T(this,0,e):m.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,r,n,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(i,s),c=this.slice(n,o),l=e.slice(t,r),f=0;f<a;++f)if(c[f]!==l[f]){i=c[f],s=l[f];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return g(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return g(this,e,t,r,!1)},u.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return k(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function A(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function I(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function C(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=q(e[i]);return o}function O(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function R(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,n,o,i){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function M(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);o<i;++o)e[r+o]=(t&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function D(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);o<i;++o)e[r+o]=t>>>8*(n?o:3-o)&255}function j(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,r,n,i){return i||j(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function U(e,t,r,n,i){return i||j(e,0,r,8),o.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=u.prototype;else{var o=t-e;r=new u(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+e]}return r},u.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},u.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},u.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},u.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},u.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);P(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);P(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return U(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return U(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o,i=n-r;if(this===e&&r<t&&t<n)for(o=i-1;o>=0;--o)e[o+t]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+i),t);return i},u.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var s=u.isBuffer(e)?e:B(new u(e,n).toString()),a=s.length;for(i=0;i<r-t;++i)this[i+t]=s[i%a]}return this};var N=/[^+\/0-9A-Za-z-_]/g;function q(e){return e<16?"0"+e.toString(16):e.toString(16)}function B(e,t){var r;t=t||1/0;for(var n=e.length,o=null,i=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}}).call(this,r(9))},function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var u,c=[],l=!1,f=-1;function p(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&h())}function h(){if(!l){var e=a(p);l=!0;for(var t=c.length;t;){for(u=c,c=[];++f<t;)u&&u[f].run();f=-1,t=c.length}u=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function m(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new d(e,t)),1!==c.length||l||a(h)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e);return t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(28);e.exports=function(e){return n(e,{weekStartsOn:1})}},function(e,t,r){var n=r(1),o=r(12);e.exports=function(e){var t=n(e),r=t.getFullYear(),i=new Date(0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);var s=o(i),a=new Date(0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);var u=o(a);return t.getTime()>=s.getTime()?r+1:t.getTime()>=u.getTime()?r:r-1}},function(e,t,r){(t=e.exports=r(99)).Stream=t,t.Readable=t,t.Writable=r(103),t.Duplex=r(18),t.Transform=r(105),t.PassThrough=r(255),t.finished=r(44),t.pipeline=r(256)},function(e,t,r){(function(n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))}),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!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`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(262)(t);const{formatters:o}=e.exports;o.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(8))},function(e,t,r){var n=r(128),o=r(129),i=r(56),s=r(130);e.exports=function(e){return n(e)||o(e)||i(e)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";var n={};function o(e,t,r){r||(r=Error);var o=function(e){var r,n;function o(r,n,o){return e.call(this,function(e,r,n){return"string"==typeof t?t:t(e,r,n)}(r,n,o))||this}return n=e,(r=o).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,o}(r);o.prototype.name=r.name,o.prototype.code=e,n[e]=o}function i(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}o("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),o("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,o,s,a;if("string"==typeof t&&(o="not ",t.substr(!s||s<0?0:+s,o.length)===o)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))a="The ".concat(e," ").concat(n," ").concat(i(t,"type"));else{var u=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(u," ").concat(n," ").concat(i(t,"type"))}return a+=". Received type ".concat(typeof r)}),TypeError),o("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),o("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),o("ERR_STREAM_PREMATURE_CLOSE","Premature close"),o("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),o("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),o("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),o("ERR_STREAM_WRITE_AFTER_END","write after end"),o("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),o("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),o("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){"use strict";(function(t){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=c;var o=r(99),i=r(103);r(10)(c,o);for(var s=n(i.prototype),a=0;a<s.length;a++){var u=s[a];c.prototype[u]||(c.prototype[u]=i.prototype[u])}function c(e){if(!(this instanceof c))return new c(e);o.call(this,e),i.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||t.nextTick(f,this)}function f(e){e.end()}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this,r(8))},function(e,t,r){"use strict";e.exports=TypeError},function(e,t,r){var n=r(13),o=r(12);e.exports=function(e){var t=n(e),r=new Date(0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),o(r)}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e).getTime(),o=n(t).getTime();return r<o?-1:r>o?1:0}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setDate(r.getDate()+o),r}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e).getTime(),o=Number(t);return new Date(r+o)}},function(e,t,r){"use strict";var n,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,e.exports.once=function(e,t){return new Promise((function(r,n){function o(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}g(e,t,i,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&g(e,"error",t,r)}(e,o,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function c(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function f(e,t,r,n){var o,i,s,a;if(c(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]),void 0===s)s=i[t]=r,++e._eventsCount;else if("function"==typeof s?s=i[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=l(e))>0&&s.length>o&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return e}function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=p.bind(n);return o.listener=r,n.wrapFn=o,o}function d(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(o):y(o,o.length)}function m(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function y(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function g(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){n.once&&e.removeEventListener(t,o),r(i)}))}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return l(this)},a.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[e];if(void 0===u)return!1;if("function"==typeof u)i(u,this,t);else{var c=u.length,l=y(u,c);for(r=0;r<c;++r)i(l[r],this,t)}return!0},a.prototype.addListener=function(e,t){return f(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return f(this,e,t,!0)},a.prototype.once=function(e,t){return c(t),this.on(e,h(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return c(t),this.prependListener(e,h(this,e,t)),this},a.prototype.removeListener=function(e,t){var r,n,o,i,s;if(c(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===t||r[i].listener===t){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},a.prototype.listeners=function(e){return d(this,e,!0)},a.prototype.rawListeners=function(e){return d(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t){function r(t){return e.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){this.v=e,this.k=t},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(11);e.exports=function(e,t){var r=n(e),o=n(t),i=r.getTime()-6e4*r.getTimezoneOffset(),s=o.getTime()-6e4*o.getTimezoneOffset();return Math.round((i-s)/864e5)}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=t&&Number(t.weekStartsOn)||0,o=n(e),i=o.getDay(),s=(i<r?7:0)+i-r;return o.setDate(o.getDate()-s),o.setHours(0,0,0,0),o}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()-o.getTime()}},function(e,t,r){var n=r(1),o=r(39);e.exports=function(e,t){var r=n(e),i=Number(t),s=r.getMonth()+i,a=new Date(0);a.setFullYear(r.getFullYear(),s,1),a.setHours(0,0,0,0);var u=o(a);return r.setMonth(s,Math.min(u,r.getDate())),r}},function(e,t,r){(function(t){var n="function"==typeof Map&&Map.prototype,o=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,i=n&&o&&"function"==typeof o.get?o.get:null,s=n&&Map.prototype.forEach,a="function"==typeof Set&&Set.prototype,u=Object.getOwnPropertyDescriptor&&a?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,c=a&&u&&"function"==typeof u.get?u.get:null,l=a&&Set.prototype.forEach,f="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,p="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,h="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,d=Boolean.prototype.valueOf,m=Object.prototype.toString,y=Function.prototype.toString,g=String.prototype.match,v=String.prototype.slice,b=String.prototype.replace,_=String.prototype.toUpperCase,w=String.prototype.toLowerCase,k=RegExp.prototype.test,S=Array.prototype.concat,x=Array.prototype.join,E=Array.prototype.slice,T=Math.floor,A="function"==typeof BigInt?BigInt.prototype.valueOf:null,I=Object.getOwnPropertySymbols,C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,O="function"==typeof Symbol&&"object"==typeof Symbol.iterator,R="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===O||"symbol")?Symbol.toStringTag:null,P=Object.prototype.propertyIsEnumerable,M=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function D(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||k.call(/e/,t))return t;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var n=e<0?-T(-e):T(e);if(n!==e){var o=String(n),i=v.call(t,o.length+1);return b.call(o,r,"$&_")+"."+b.call(b.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return b.call(t,r,"$&_")}var j=r(274),L=j.custom,U=z(L)?L:null,N={__proto__:null,double:'"',single:"'"},q={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};function B(e,t,r){var n=r.quoteStyle||t,o=N[n];return o+e+o}function F(e){return b.call(String(e),/"/g,"&quot;")}function H(e){return!R||!("object"==typeof e&&(R in e||void 0!==e[R]))}function Y(e){return"[object Array]"===$(e)&&H(e)}function W(e){return"[object RegExp]"===$(e)&&H(e)}function z(e){if(O)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!C)return!1;try{return C.call(e),!0}catch(e){}return!1}e.exports=function e(r,n,o,a){var u=n||{};if(K(u,"quoteStyle")&&!K(N,u.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(K(u,"maxStringLength")&&("number"==typeof u.maxStringLength?u.maxStringLength<0&&u.maxStringLength!==1/0:null!==u.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var m=!K(u,"customInspect")||u.customInspect;if("boolean"!=typeof m&&"symbol"!==m)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(K(u,"indent")&&null!==u.indent&&"\t"!==u.indent&&!(parseInt(u.indent,10)===u.indent&&u.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(K(u,"numericSeparator")&&"boolean"!=typeof u.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var _=u.numericSeparator;if(void 0===r)return"undefined";if(null===r)return"null";if("boolean"==typeof r)return r?"true":"false";if("string"==typeof r)return function e(t,r){if(t.length>r.maxStringLength){var n=t.length-r.maxStringLength,o="... "+n+" more character"+(n>1?"s":"");return e(v.call(t,0,r.maxStringLength),r)+o}var i=q[r.quoteStyle||"single"];return i.lastIndex=0,B(b.call(b.call(t,i,"\\$1"),/[\x00-\x1f]/g,G),"single",r)}(r,u);if("number"==typeof r){if(0===r)return 1/0/r>0?"0":"-0";var k=String(r);return _?D(r,k):k}if("bigint"==typeof r){var T=String(r)+"n";return _?D(r,T):T}var I=void 0===u.depth?5:u.depth;if(void 0===o&&(o=0),o>=I&&I>0&&"object"==typeof r)return Y(r)?"[Array]":"[Object]";var L=function(e,t){var r;if("\t"===e.indent)r="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;r=x.call(Array(e.indent+1)," ")}return{base:r,prev:x.call(Array(t+1),r)}}(u,o);if(void 0===a)a=[];else if(Q(a,r)>=0)return"[Circular]";function V(t,r,n){if(r&&(a=E.call(a)).push(r),n){var i={depth:u.depth};return K(u,"quoteStyle")&&(i.quoteStyle=u.quoteStyle),e(t,i,o+1,a)}return e(t,u,o+1,a)}if("function"==typeof r&&!W(r)){var re=function(e){if(e.name)return e.name;var t=g.call(y.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(r),ne=te(r,V);return"[Function"+(re?": "+re:" (anonymous)")+"]"+(ne.length>0?" { "+x.call(ne,", ")+" }":"")}if(z(r)){var oe=O?b.call(String(r),/^(Symbol\(.*\))_[^)]*$/,"$1"):C.call(r);return"object"!=typeof r||O?oe:J(oe)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(r)){for(var ie="<"+w.call(String(r.nodeName)),se=r.attributes||[],ae=0;ae<se.length;ae++)ie+=" "+se[ae].name+"="+B(F(se[ae].value),"double",u);return ie+=">",r.childNodes&&r.childNodes.length&&(ie+="..."),ie+="</"+w.call(String(r.nodeName))+">"}if(Y(r)){if(0===r.length)return"[]";var ue=te(r,V);return L&&!function(e){for(var t=0;t<e.length;t++)if(Q(e[t],"\n")>=0)return!1;return!0}(ue)?"["+ee(ue,L)+"]":"[ "+x.call(ue,", ")+" ]"}if(function(e){return"[object Error]"===$(e)&&H(e)}(r)){var ce=te(r,V);return"cause"in Error.prototype||!("cause"in r)||P.call(r,"cause")?0===ce.length?"["+String(r)+"]":"{ ["+String(r)+"] "+x.call(ce,", ")+" }":"{ ["+String(r)+"] "+x.call(S.call("[cause]: "+V(r.cause),ce),", ")+" }"}if("object"==typeof r&&m){if(U&&"function"==typeof r[U]&&j)return j(r,{depth:I-o});if("symbol"!==m&&"function"==typeof r.inspect)return r.inspect()}if(function(e){if(!i||!e||"object"!=typeof e)return!1;try{i.call(e);try{c.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(r)){var le=[];return s&&s.call(r,(function(e,t){le.push(V(t,r,!0)+" => "+V(e,r))})),Z("Map",i.call(r),le,L)}if(function(e){if(!c||!e||"object"!=typeof e)return!1;try{c.call(e);try{i.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(r)){var fe=[];return l&&l.call(r,(function(e){fe.push(V(e,r))})),Z("Set",c.call(r),fe,L)}if(function(e){if(!f||!e||"object"!=typeof e)return!1;try{f.call(e,f);try{p.call(e,p)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(r))return X("WeakMap");if(function(e){if(!p||!e||"object"!=typeof e)return!1;try{p.call(e,p);try{f.call(e,f)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(r))return X("WeakSet");if(function(e){if(!h||!e||"object"!=typeof e)return!1;try{return h.call(e),!0}catch(e){}return!1}(r))return X("WeakRef");if(function(e){return"[object Number]"===$(e)&&H(e)}(r))return J(V(Number(r)));if(function(e){if(!e||"object"!=typeof e||!A)return!1;try{return A.call(e),!0}catch(e){}return!1}(r))return J(V(A.call(r)));if(function(e){return"[object Boolean]"===$(e)&&H(e)}(r))return J(d.call(r));if(function(e){return"[object String]"===$(e)&&H(e)}(r))return J(V(String(r)));if("undefined"!=typeof window&&r===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&r===globalThis||void 0!==t&&r===t)return"{ [object globalThis] }";if(!function(e){return"[object Date]"===$(e)&&H(e)}(r)&&!W(r)){var pe=te(r,V),he=M?M(r)===Object.prototype:r instanceof Object||r.constructor===Object,de=r instanceof Object?"":"null prototype",me=!he&&R&&Object(r)===r&&R in r?v.call($(r),8,-1):de?"Object":"",ye=(he||"function"!=typeof r.constructor?"":r.constructor.name?r.constructor.name+" ":"")+(me||de?"["+x.call(S.call([],me||[],de||[]),": ")+"] ":"");return 0===pe.length?ye+"{}":L?ye+"{"+ee(pe,L)+"}":ye+"{ "+x.call(pe,", ")+" }"}return String(r)};var V=Object.prototype.hasOwnProperty||function(e){return e in this};function K(e,t){return V.call(e,t)}function $(e){return m.call(e)}function Q(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}function G(e){var t=e.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return r?"\\"+r:"\\x"+(t<16?"0":"")+_.call(t.toString(16))}function J(e){return"Object("+e+")"}function X(e){return e+" { ? }"}function Z(e,t,r,n){return e+" ("+t+") {"+(n?ee(r,n):x.call(r,", "))+"}"}function ee(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+x.call(e,","+r)+"\n"+t.prev}function te(e,t){var r=Y(e),n=[];if(r){n.length=e.length;for(var o=0;o<e.length;o++)n[o]=K(e,o)?t(e[o],e):""}var i,s="function"==typeof I?I(e):[];if(O){i={};for(var a=0;a<s.length;a++)i["$"+s[a]]=s[a]}for(var u in e)K(e,u)&&(r&&String(Number(u))===u&&u<e.length||O&&i["$"+u]instanceof Symbol||(k.call(/[^\w$]/,u)?n.push(t(u,e)+": "+t(e[u],e)):n.push(u+": "+t(e[u],e))));if("function"==typeof I)for(var c=0;c<s.length;c++)P.call(e,s[c])&&n.push("["+t(s[c])+"]: "+t(e[s[c]],e));return n}}).call(this,r(9))},function(e,t,r){"use strict";var n=r(296);e.exports=Function.prototype.bind||n},function(e,t){e.exports=function(e){return e instanceof Date}},function(e,t,r){var n=r(1),o=r(12),i=r(20);e.exports=function(e){var t=n(e),r=o(t).getTime()-i(t).getTime();return Math.round(r/6048e5)+1}},function(e,t,r){var n=r(142),o=r(143);e.exports={distanceInWords:n(),format:o()}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e).getTime(),o=n(t).getTime();return r>o?-1:r<o?1:0}},function(e,t,r){var n=r(29);e.exports=function(e,t){var r=n(e,t)/1e3;return r>0?Math.floor(r):Math.ceil(r)}},function(e,t,r){var n=r(1),o=r(67),i=r(21);e.exports=function(e,t){var r=n(e),s=n(t),a=i(r,s),u=Math.abs(o(r,s));return r.setMonth(r.getMonth()-a*u),a*(u-(i(r,s)===-a))}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e),r=t.getFullYear(),o=t.getMonth(),i=new Date(0);return i.setFullYear(r,o+1,0),i.setHours(0,0,0,0),i.getDate()}},function(e,t,r){var n=r(22);e.exports=function(e,t){var r=Number(t);return n(e,7*r)}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e);return t.setHours(23,59,59,999),t}},function(e,t,r){var n=r(28);e.exports=function(e,t,r){var o=n(e,r),i=n(t,r);return o.getTime()===i.getTime()}},function(e,t){e.exports=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)r.call(n,o)&&(e[o]=n[o])}return e};var r=Object.prototype.hasOwnProperty},function(e,t,r){"use strict";var n=r(17).codes.ERR_STREAM_PREMATURE_CLOSE;function o(){}e.exports=function e(t,r,i){if("function"==typeof r)return e(t,null,r);r||(r={}),i=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];e.apply(this,n)}}}(i||o);var s=r.readable||!1!==r.readable&&t.readable,a=r.writable||!1!==r.writable&&t.writable,u=function(){t.writable||l()},c=t._writableState&&t._writableState.finished,l=function(){a=!1,c=!0,s||i.call(t)},f=t._readableState&&t._readableState.endEmitted,p=function(){s=!1,f=!0,a||i.call(t)},h=function(e){i.call(t,e)},d=function(){var e;return s&&!f?(t._readableState&&t._readableState.ended||(e=new n),i.call(t,e)):a&&!c?(t._writableState&&t._writableState.ended||(e=new n),i.call(t,e)):void 0},m=function(){t.req.on("finish",l)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(t)?a&&!t._writableState&&(t.on("end",u),t.on("close",u)):(t.on("complete",l),t.on("abort",d),t.req?m():t.on("request",m)),t.on("end",p),t.on("finish",l),!1!==r.error&&t.on("error",h),t.on("close",d),function(){t.removeListener("complete",l),t.removeListener("abort",d),t.removeListener("request",m),t.req&&t.req.removeListener("finish",l),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",l),t.removeListener("end",p),t.removeListener("error",h),t.removeListener("close",d)}}},function(e,t,r){"use strict";var n=r(110),o=r(276),i=r(277),s=r(278),a=r(279),u=r(280),c=r(19),l=r(281),f=r(282),p=r(283),h=r(284),d=r(285),m=r(286),y=r(287),g=r(288),v=Function,b=function(e){try{return v('"use strict"; return ('+e+").constructor;")()}catch(e){}},_=r(111),w=r(291),k=function(){throw new c},S=_?function(){try{return k}catch(e){try{return _(arguments,"callee").get}catch(e){return k}}}():k,x=r(292)(),E=r(294),T=r(113),A=r(112),I=r(115),C=r(46),O={},R="undefined"!=typeof Uint8Array&&E?E(Uint8Array):void 0,P={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":x&&E?E([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":O,"%AsyncGenerator%":O,"%AsyncGeneratorFunction%":O,"%AsyncIteratorPrototype%":O,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%BigInt%":"undefined"==typeof BigInt?void 0:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?void 0:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?void 0:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":o,"%eval%":eval,"%EvalError%":i,"%Float16Array%":"undefined"==typeof Float16Array?void 0:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":O,"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":x&&E?E(E([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&x&&E?E((new Map)[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":n,"%Object.getOwnPropertyDescriptor%":_,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":s,"%ReferenceError%":a,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&x&&E?E((new Set)[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":x&&E?E(""[Symbol.iterator]()):void 0,"%Symbol%":x?Symbol:void 0,"%SyntaxError%":u,"%ThrowTypeError%":S,"%TypedArray%":R,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%URIError%":l,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?void 0:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet,"%Function.prototype.call%":C,"%Function.prototype.apply%":I,"%Object.defineProperty%":w,"%Object.getPrototypeOf%":T,"%Math.abs%":f,"%Math.floor%":p,"%Math.max%":h,"%Math.min%":d,"%Math.pow%":m,"%Math.round%":y,"%Math.sign%":g,"%Reflect.getPrototypeOf%":A};if(E)try{null.error}catch(e){var M=E(E(e));P["%Error.prototype%"]=M}var D={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},j=r(32),L=r(299),U=j.call(C,Array.prototype.concat),N=j.call(I,Array.prototype.splice),q=j.call(C,String.prototype.replace),B=j.call(C,String.prototype.slice),F=j.call(C,RegExp.prototype.exec),H=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Y=/\\(\\)?/g,W=function(e){var t=B(e,0,1),r=B(e,-1);if("%"===t&&"%"!==r)throw new u("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new u("invalid intrinsic syntax, expected opening `%`");var n=[];return q(e,H,(function(e,t,r,o){n[n.length]=r?q(o,Y,"$1"):t||e})),n},z=function(e,t){var r,n=e;if(L(D,n)&&(n="%"+(r=D[n])[0]+"%"),L(P,n)){var o=P[n];if(o===O&&(o=function e(t){var r;if("%AsyncFunction%"===t)r=b("async function () {}");else if("%GeneratorFunction%"===t)r=b("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=b("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var o=e("%AsyncGenerator%");o&&E&&(r=E(o.prototype))}return P[t]=r,r}(n)),void 0===o&&!t)throw new c("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:o}}throw new u("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new c('"allowMissing" argument must be a boolean');if(null===F(/^%?[^%]*%?$/,e))throw new u("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=W(e),n=r.length>0?r[0]:"",o=z("%"+n+"%",t),i=o.name,s=o.value,a=!1,l=o.alias;l&&(n=l[0],N(r,U([0,1],l)));for(var f=1,p=!0;f<r.length;f+=1){var h=r[f],d=B(h,0,1),m=B(h,-1);if(('"'===d||"'"===d||"`"===d||'"'===m||"'"===m||"`"===m)&&d!==m)throw new u("property names with quotes must have matching quotes");if("constructor"!==h&&p||(a=!0),L(P,i="%"+(n+="."+h)+"%"))s=P[i];else if(null!=s){if(!(h in s)){if(!t)throw new c("base intrinsic for "+e+" exists, but the property is not available.");return}if(_&&f+1>=r.length){var y=_(s,h);s=(p=!!y)&&"get"in y&&!("originalValue"in y.get)?y.get:s[h]}else p=L(s,h),s=s[h];p&&!a&&(P[i]=s)}}return s}},function(e,t,r){"use strict";e.exports=Function.prototype.call},function(e,t,r){"use strict";var n=String.prototype.replace,o=/%20/g,i="RFC1738",s="RFC3986";e.exports={default:s,formatters:{RFC1738:function(e){return n.call(e,o,"+")},RFC3986:function(e){return String(e)}},RFC1738:i,RFC3986:s}},function(e,t,r){"use strict";var n=r(303),o=r(15)("mqttjs:tls");e.exports=function(e,t){var r;function i(n){t.rejectUnauthorized&&e.emit("error",n),r.end()}return t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",t.servername=t.host,t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,o("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized),(r=n.connect(t)).on("secureConnect",(function(){t.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",i)})),r.on("error",i),r}},function(e,t,r){(function(t,n){var o=r(14),i=r(304),s=r(10),a=r(307),u=t.from&&t.from!==Uint8Array.from?t.from([0]):new t([0]),c=function(e,t){e._corked?e.once("uncork",t):t()},l=function(e,t){return function(r){r?function(e,t){e._autoDestroy&&e.destroy(t)}(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},f=function(){},p=function(e,t,r){if(!(this instanceof p))return new p(e,t,r);o.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(p,o.Duplex),p.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new p(e,t,r)},p.prototype.cork=function(){1==++this._corked&&this.emit("cork")},p.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},p.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,r=i(e,{writable:!0,readable:!1},l(this,this._forwardEnd)),o=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&n.nextTick(o),this._writable=e,this._writable.on("drain",o),this._unwrite=function(){t._writable.removeListener("drain",o),r()},this.uncork()}else this.end()},p.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t,r=this,n=i(e,{writable:!1,readable:!0},l(this)),s=function(){r._forward()},a=function(){r.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:(t=e,new o.Readable({objectMode:!0,highWaterMark:16}).wrap(t)),this._readable2.on("readable",s),this._readable2.on("end",a),this._unread=function(){r._readable2.removeListener("readable",s),r._readable2.removeListener("end",a),n()},this._forward()}},p.prototype._read=function(){this._drained=!0,this._forward()},p.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=a(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},p.prototype.destroy=function(e,t){if(t||(t=f),this.destroyed)return t(null);this.destroyed=!0;var r=this;n.nextTick((function(){r._destroy(e),t(null)}))},p.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},p.prototype._write=function(e,t,r){if(!this.destroyed)return this._corked?c(this,this._write.bind(this,e,t,r)):e===u?this._finish(r):this._writable?void(!1===this._writable.write(e)?this._ondrain=r:this.destroyed||r()):r()},p.prototype._finish=function(e){var t=this;this.emit("preend"),c(this,(function(){var r,n;r=t._forwardEnd&&t._writable,n=function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),c(t,e)},r?r._writableState&&r._writableState.finished?n():r._writableState?r.end(n):(r.end(),n()):n()}))},p.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(u),o.Writable.prototype.end.call(this,r))},e.exports=p}).call(this,r(7).Buffer,r(8))},function(e,t,r){var n=r(63),o=r(34),i=r(13),s=r(1),a=r(65),u=r(35);var c={M:function(e){return e.getMonth()+1},MM:function(e){return p(e.getMonth()+1,2)},Q:function(e){return Math.ceil((e.getMonth()+1)/3)},D:function(e){return e.getDate()},DD:function(e){return p(e.getDate(),2)},DDD:function(e){return n(e)},DDDD:function(e){return p(n(e),3)},d:function(e){return e.getDay()},E:function(e){return e.getDay()||7},W:function(e){return o(e)},WW:function(e){return p(o(e),2)},YY:function(e){return p(e.getFullYear(),4).substr(2)},YYYY:function(e){return p(e.getFullYear(),4)},GG:function(e){return String(i(e)).substr(2)},GGGG:function(e){return i(e)},H:function(e){return e.getHours()},HH:function(e){return p(e.getHours(),2)},h:function(e){var t=e.getHours();return 0===t?12:t>12?t%12:t},hh:function(e){return p(c.h(e),2)},m:function(e){return e.getMinutes()},mm:function(e){return p(e.getMinutes(),2)},s:function(e){return e.getSeconds()},ss:function(e){return p(e.getSeconds(),2)},S:function(e){return Math.floor(e.getMilliseconds()/100)},SS:function(e){return p(Math.floor(e.getMilliseconds()/10),2)},SSS:function(e){return p(e.getMilliseconds(),3)},Z:function(e){return f(e.getTimezoneOffset(),":")},ZZ:function(e){return f(e.getTimezoneOffset())},X:function(e){return Math.floor(e.getTime()/1e3)},x:function(e){return e.getTime()}};function l(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|]$/g,""):e.replace(/\\/g,"")}function f(e,t){t=t||"";var r=e>0?"-":"+",n=Math.abs(e),o=n%60;return r+p(Math.floor(n/60),2)+t+p(o,2)}function p(e,t){for(var r=Math.abs(e).toString();r.length<t;)r="0"+r;return r}e.exports=function(e,t,r){var n=t?String(t):"YYYY-MM-DDTHH:mm:ss.SSSZ",o=(r||{}).locale,i=u.format.formatters,f=u.format.formattingTokensRegExp;o&&o.format&&o.format.formatters&&(i=o.format.formatters,o.format.formattingTokensRegExp&&(f=o.format.formattingTokensRegExp));var p=s(e);return a(p)?function(e,t,r){var n,o,i=e.match(r),s=i.length;for(n=0;n<s;n++)o=t[i[n]]||c[i[n]],i[n]=o||l(i[n]);return function(e){for(var t="",r=0;r<s;r++)i[r]instanceof Function?t+=i[r](e,c):t+=i[r];return t}}(n,i,f)(p):"Invalid Date"}},function(e,t,r){var n=r(66);e.exports=function(e,t){return n(Date.now(),e,t)}},function(e,t,r){e.exports={addDays:r(22),addHours:r(68),addISOYears:r(69),addMilliseconds:r(23),addMinutes:r(71),addMonths:r(30),addQuarters:r(72),addSeconds:r(73),addWeeks:r(40),addYears:r(74),areRangesOverlapping:r(145),closestIndexTo:r(146),closestTo:r(147),compareAsc:r(21),compareDesc:r(36),differenceInCalendarDays:r(27),differenceInCalendarISOWeeks:r(148),differenceInCalendarISOYears:r(75),differenceInCalendarMonths:r(67),differenceInCalendarQuarters:r(149),differenceInCalendarWeeks:r(150),differenceInCalendarYears:r(77),differenceInDays:r(78),differenceInHours:r(151),differenceInISOYears:r(152),differenceInMilliseconds:r(29),differenceInMinutes:r(153),differenceInMonths:r(38),differenceInQuarters:r(154),differenceInSeconds:r(37),differenceInWeeks:r(155),differenceInYears:r(156),distanceInWords:r(66),distanceInWordsStrict:r(157),distanceInWordsToNow:r(51),eachDay:r(158),endOfDay:r(41),endOfHour:r(159),endOfISOWeek:r(160),endOfISOYear:r(161),endOfMinute:r(162),endOfMonth:r(81),endOfQuarter:r(163),endOfSecond:r(164),endOfToday:r(165),endOfTomorrow:r(166),endOfWeek:r(80),endOfYear:r(167),endOfYesterday:r(168),format:r(50),getDate:r(169),getDay:r(170),getDayOfYear:r(63),getDaysInMonth:r(39),getDaysInYear:r(171),getHours:r(172),getISODay:r(83),getISOWeek:r(34),getISOWeeksInYear:r(173),getISOYear:r(13),getMilliseconds:r(174),getMinutes:r(175),getMonth:r(176),getOverlappingDaysInRanges:r(177),getQuarter:r(76),getSeconds:r(178),getTime:r(179),getYear:r(180),isAfter:r(181),isBefore:r(182),isDate:r(33),isEqual:r(183),isFirstDayOfMonth:r(184),isFriday:r(185),isFuture:r(186),isLastDayOfMonth:r(187),isLeapYear:r(82),isMonday:r(188),isPast:r(189),isSameDay:r(190),isSameHour:r(84),isSameISOWeek:r(86),isSameISOYear:r(87),isSameMinute:r(88),isSameMonth:r(90),isSameQuarter:r(91),isSameSecond:r(93),isSameWeek:r(42),isSameYear:r(95),isSaturday:r(191),isSunday:r(192),isThisHour:r(193),isThisISOWeek:r(194),isThisISOYear:r(195),isThisMinute:r(196),isThisMonth:r(197),isThisQuarter:r(198),isThisSecond:r(199),isThisWeek:r(200),isThisYear:r(201),isThursday:r(202),isToday:r(203),isTomorrow:r(204),isTuesday:r(205),isValid:r(65),isWednesday:r(206),isWeekend:r(207),isWithinRange:r(208),isYesterday:r(209),lastDayOfISOWeek:r(210),lastDayOfISOYear:r(211),lastDayOfMonth:r(212),lastDayOfQuarter:r(213),lastDayOfWeek:r(96),lastDayOfYear:r(214),max:r(215),min:r(216),parse:r(1),setDate:r(217),setDay:r(218),setDayOfYear:r(219),setHours:r(220),setISODay:r(221),setISOWeek:r(222),setISOYear:r(70),setMilliseconds:r(223),setMinutes:r(224),setMonth:r(97),setQuarter:r(225),setSeconds:r(226),setYear:r(227),startOfDay:r(11),startOfHour:r(85),startOfISOWeek:r(12),startOfISOYear:r(20),startOfMinute:r(89),startOfMonth:r(228),startOfQuarter:r(92),startOfSecond:r(94),startOfToday:r(229),startOfTomorrow:r(230),startOfWeek:r(28),startOfYear:r(64),startOfYesterday:r(231),subDays:r(232),subHours:r(233),subISOYears:r(79),subMilliseconds:r(234),subMinutes:r(235),subMonths:r(236),subQuarters:r(237),subSeconds:r(238),subWeeks:r(239),subYears:r(240)}},function(e,t,r){var n=r(26);e.exports=function(e){return new n(e,0)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(26);function o(e){var t,r;function o(t,r){try{var s=e[t](r),a=s.value,u=a instanceof n;Promise.resolve(u?a.v:a).then((function(r){if(u){var n="return"===t?"return":"next";if(!a.k||r.done)return o(n,r);r=e[n](r).value}i(s.done?"return":"normal",r)}),(function(e){o("throw",e)}))}catch(e){i("throw",e)}}function i(e,n){switch(e){case"return":t.resolve({value:n,done:!0});break;case"throw":t.reject(n);break;default:t.resolve({value:n,done:!1})}(t=t.next)?o(t.key,t.arg):r=null}this._invoke=function(e,n){return new Promise((function(i,s){var a={key:e,arg:n,resolve:i,reject:s,next:null};r?r=r.next=a:(t=r=a,o(e,n))}))},"function"!=typeof e.return&&(this.return=void 0)}o.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},o.prototype.next=function(e){return this._invoke("next",e)},o.prototype.throw=function(e){return this._invoke("throw",e)},o.prototype.return=function(e){return this._invoke("return",e)},e.exports=function(e){return function(){return new o(e.apply(this,arguments))}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(55);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(25).default,o=r(131);e.exports=function(e){var t=o(e,"string");return"symbol"==n(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(59);function o(){
9
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
10
- var t,r,i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.toStringTag||"@@toStringTag";function u(e,o,i,s){var a=o&&o.prototype instanceof l?o:l,u=Object.create(a.prototype);return n(u,"_invoke",function(e,n,o){var i,s,a,u=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,r){return i=e,s=0,a=t,p.n=r,c}};function h(e,n){for(s=e,a=n,r=0;!f&&u&&!o&&r<l.length;r++){var o,i=l[r],h=p.p,d=i[2];e>3?(o=d===n)&&(a=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=e<2&&h<i[1])?(s=0,p.v=n,p.n=i[1]):h<d&&(o=e<3||i[0]>n||n>d)&&(i[4]=e,i[5]=n,p.n=d,s=0))}if(o||e>1)return c;throw f=!0,n}return function(o,l,d){if(u>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,d),s=l,a=d;(r=s<2?t:a)||!f;){i||(s?s<3?(s>1&&(p.n=-1),h(s,a)):p.n=a:p.v=a);try{if(u=2,i){if(s||(o="next"),r=i[o]){if(!(r=r.call(i,a)))throw TypeError("iterator result is not an object");if(!r.done)return r;a=r.value,s<2&&(s=0)}else 1===s&&(r=i.return)&&r.call(i),s<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=t}else if((r=(f=p.n<0)?a:e.call(n,p))!==c)break}catch(e){i=t,s=1,a=e}finally{u=1}}return{value:r,done:f}}}(e,i,s),!0),u}var c={};function l(){}function f(){}function p(){}r=Object.getPrototypeOf;var h=[][s]?r(r([][s]())):(n(r={},s,(function(){return this})),r),d=p.prototype=l.prototype=Object.create(h);function m(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,n(e,a,"GeneratorFunction")),e.prototype=Object.create(d),e}return f.prototype=p,n(d,"constructor",p),n(p,"constructor",f),f.displayName="GeneratorFunction",n(p,a,"GeneratorFunction"),n(d),n(d,a,"Generator"),n(d,s,(function(){return this})),n(d,"toString",(function(){return"[object Generator]"})),(e.exports=o=function(){return{w:u,m:m}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){function r(t,n,o,i){var s=Object.defineProperty;try{s({},"",{})}catch(t){s=0}e.exports=r=function(e,t,n,o){function i(t,n){r(e,t,(function(e){return this._invoke(t,n,e)}))}t?s?s(e,t,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},e.exports.__esModule=!0,e.exports.default=e.exports,r(t,n,o,i)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(58),o=r(61);e.exports=function(e,t,r,i,s){return new o(n().w(e,t,r,i),s||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(26),o=r(59);e.exports=function e(t,r){function i(e,o,s,a){try{var u=t[e](o),c=u.value;return c instanceof n?r.resolve(c.v).then((function(e){i("next",e,s,a)}),(function(e){i("throw",e,s,a)})):r.resolve(c).then((function(e){u.value=e,s(u)}),(function(e){return i("throw",e,s,a)}))}catch(e){a(e)}}var s;this.next||(o(e.prototype),o(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",(function(){return this}))),o(this,"_invoke",(function(e,t,n){function o(){return new r((function(t,r){i(e,n,t,r)}))}return s=s?s.then(o,o):o()}),!0)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";e.exports=function(e){return null!==e&&"object"==typeof e}},function(e,t,r){var n=r(1),o=r(64),i=r(27);e.exports=function(e){var t=n(e);return i(t,o(t))+1}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e),r=new Date(0);return r.setFullYear(t.getFullYear(),0,1),r.setHours(0,0,0,0),r}},function(e,t,r){var n=r(33);e.exports=function(e){if(n(e))return!isNaN(e);throw new TypeError(toString.call(e)+" is not an instance of Date")}},function(e,t,r){var n=r(36),o=r(1),i=r(37),s=r(38),a=r(35);e.exports=function(e,t,r){var u=r||{},c=n(e,t),l=u.locale,f=a.distanceInWords.localize;l&&l.distanceInWords&&l.distanceInWords.localize&&(f=l.distanceInWords.localize);var p,h,d={addSuffix:Boolean(u.addSuffix),comparison:c};c>0?(p=o(e),h=o(t)):(p=o(t),h=o(e));var m,y=i(h,p),g=h.getTimezoneOffset()-p.getTimezoneOffset(),v=Math.round(y/60)-g;if(v<2)return u.includeSeconds?y<5?f("lessThanXSeconds",5,d):y<10?f("lessThanXSeconds",10,d):y<20?f("lessThanXSeconds",20,d):y<40?f("halfAMinute",null,d):f(y<60?"lessThanXMinutes":"xMinutes",1,d):0===v?f("lessThanXMinutes",1,d):f("xMinutes",v,d);if(v<45)return f("xMinutes",v,d);if(v<90)return f("aboutXHours",1,d);if(v<1440)return f("aboutXHours",Math.round(v/60),d);if(v<2520)return f("xDays",1,d);if(v<43200)return f("xDays",Math.round(v/1440),d);if(v<86400)return f("aboutXMonths",m=Math.round(v/43200),d);if((m=s(h,p))<12)return f("xMonths",Math.round(v/43200),d);var b=m%12,_=Math.floor(m/12);return b<3?f("aboutXYears",_,d):b<9?f("overXYears",_,d):f("almostXYears",_+1,d)}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=n(t);return 12*(r.getFullYear()-o.getFullYear())+(r.getMonth()-o.getMonth())}},function(e,t,r){var n=r(23);e.exports=function(e,t){var r=Number(t);return n(e,36e5*r)}},function(e,t,r){var n=r(13),o=r(70);e.exports=function(e,t){var r=Number(t);return o(e,n(e)+r)}},function(e,t,r){var n=r(1),o=r(20),i=r(27);e.exports=function(e,t){var r=n(e),s=Number(t),a=i(r,o(r)),u=new Date(0);return u.setFullYear(s,0,4),u.setHours(0,0,0,0),(r=o(u)).setDate(r.getDate()+a),r}},function(e,t,r){var n=r(23);e.exports=function(e,t){var r=Number(t);return n(e,6e4*r)}},function(e,t,r){var n=r(30);e.exports=function(e,t){var r=Number(t);return n(e,3*r)}},function(e,t,r){var n=r(23);e.exports=function(e,t){var r=Number(t);return n(e,1e3*r)}},function(e,t,r){var n=r(30);e.exports=function(e,t){var r=Number(t);return n(e,12*r)}},function(e,t,r){var n=r(13);e.exports=function(e,t){return n(e)-n(t)}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e);return Math.floor(t.getMonth()/3)+1}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=n(t);return r.getFullYear()-o.getFullYear()}},function(e,t,r){var n=r(1),o=r(27),i=r(21);e.exports=function(e,t){var r=n(e),s=n(t),a=i(r,s),u=Math.abs(o(r,s));return r.setDate(r.getDate()-a*u),a*(u-(i(r,s)===-a))}},function(e,t,r){var n=r(69);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=t&&Number(t.weekStartsOn)||0,o=n(e),i=o.getDay(),s=6+(i<r?-7:0)-(i-r);return o.setDate(o.getDate()+s),o.setHours(23,59,59,999),o}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e).getFullYear();return t%400==0||t%4==0&&t%100!=0}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e).getDay();return 0===t&&(t=7),t}},function(e,t,r){var n=r(85);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e);return t.setMinutes(0,0,0),t}},function(e,t,r){var n=r(42);e.exports=function(e,t){return n(e,t,{weekStartsOn:1})}},function(e,t,r){var n=r(20);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(89);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e);return t.setSeconds(0,0),t}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=n(t);return r.getFullYear()===o.getFullYear()&&r.getMonth()===o.getMonth()}},function(e,t,r){var n=r(92);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e),r=t.getMonth(),o=r-r%3;return t.setMonth(o,1),t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(94);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e);return t.setMilliseconds(0),t}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=n(t);return r.getFullYear()===o.getFullYear()}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=t&&Number(t.weekStartsOn)||0,o=n(e),i=o.getDay(),s=6+(i<r?-7:0)-(i-r);return o.setHours(0,0,0,0),o.setDate(o.getDate()+s),o}},function(e,t,r){var n=r(1),o=r(39);e.exports=function(e,t){var r=n(e),i=Number(t),s=r.getFullYear(),a=r.getDate(),u=new Date(0);u.setFullYear(s,i,15),u.setHours(0,0,0,0);var c=o(u);return r.setMonth(i,Math.min(a,c)),r}},function(e,t,r){"use strict";var n=r(43),o=r(14).Readable,i={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=n(s,e),this._inflights=new Map}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){var e=new o(i),t=!1,r=[],n=0;return this._inflights.forEach((function(e,t){r.push(e)})),e._read=function(){!t&&n<r.length?this.push(r[n++]):this.push(null)},e.destroy=function(){if(!t){var e=this;t=!0,setTimeout((function(){e.emit("close")}),0)}},e},a.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},a.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},e.exports=a},function(e,t,r){"use strict";(function(t,n){var o;e.exports=E,E.ReadableState=x;r(24).EventEmitter;var i=function(e,t){return e.listeners(t).length},s=r(100),a=r(7).Buffer,u=t.Uint8Array||function(){};var c,l=r(248);c=l&&l.debuglog?l.debuglog("stream"):function(){};var f,p,h,d=r(249),m=r(101),y=r(102).getHighWaterMark,g=r(17).codes,v=g.ERR_INVALID_ARG_TYPE,b=g.ERR_STREAM_PUSH_AFTER_EOF,_=g.ERR_METHOD_NOT_IMPLEMENTED,w=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(10)(E,s);var k=m.errorOrDestroy,S=["error","close","destroy","pause","resume"];function x(e,t,n){o=o||r(18),e=e||{},"boolean"!=typeof n&&(n=t instanceof o),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=y(this,e,"readableHighWaterMark",n),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(f||(f=r(104).StringDecoder),this.decoder=new f(e.encoding),this.encoding=e.encoding)}function E(e){if(o=o||r(18),!(this instanceof E))return new E(e);var t=this instanceof o;this._readableState=new x(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),s.call(this)}function T(e,t,r,n,o){c("readableAddChunk",t);var i,s=e._readableState;if(null===t)s.reading=!1,function(e,t){if(c("onEofChunk"),t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?C(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,O(e)))}(e,s);else if(o||(i=function(e,t){var r;n=t,a.isBuffer(n)||n instanceof u||"string"==typeof t||void 0===t||e.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],t));var n;return r}(s,t)),i)k(e,i);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),n)s.endEmitted?k(e,new w):A(e,s,t,!0);else if(s.ended)k(e,new b);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?A(e,s,t,!1):R(e,s)):A(e,s,t,!1)}else n||(s.reading=!1,R(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function A(e,t,r,n){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&C(e)),R(e,t)}Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),E.prototype.destroy=m.destroy,E.prototype._undestroy=m.undestroy,E.prototype._destroy=function(e,t){t(e)},E.prototype.push=function(e,t){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof e&&((t=t||n.defaultEncoding)!==n.encoding&&(e=a.from(e,t),t=""),r=!0),T(this,e,t,!1,r)},E.prototype.unshift=function(e){return T(this,e,null,!0,!1)},E.prototype.isPaused=function(){return!1===this._readableState.flowing},E.prototype.setEncoding=function(e){f||(f=r(104).StringDecoder);var t=new f(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,o="";null!==n;)o+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==o&&this._readableState.buffer.push(o),this._readableState.length=o.length,this};function I(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function C(e){var t=e._readableState;c("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(c("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(O,e))}function O(e){var t=e._readableState;c("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,L(e)}function R(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(P,e,t))}function P(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(c("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function M(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function D(e){c("readable nexttick read 0"),e.read(0)}function j(e,t){c("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),L(e),t.flowing&&!t.reading&&e.read(0)}function L(e){var t=e._readableState;for(c("flow",t.flowing);t.flowing&&null!==e.read(););}function U(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function N(e){var t=e._readableState;c("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(q,t,e))}function q(e,t){if(c("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function B(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}E.prototype.read=function(e){c("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return c("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?N(this):C(this),null;if(0===(e=I(e,t))&&t.ended)return 0===t.length&&N(this),null;var n,o=t.needReadable;return c("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&c("length less than watermark",o=!0),t.ended||t.reading?c("reading or ended",o=!1):o&&(c("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=I(r,t))),null===(n=e>0?U(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&N(this)),null!==n&&this.emit("data",n),n},E.prototype._read=function(e){k(this,new _("_read()"))},E.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,c("pipe count=%d opts=%j",o.pipesCount,t);var s=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?u:y;function a(t,n){c("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,c("cleanup"),e.removeListener("close",d),e.removeListener("finish",m),e.removeListener("drain",l),e.removeListener("error",h),e.removeListener("unpipe",a),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",p),f=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function u(){c("onend"),e.end()}o.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var l=function(e){return function(){var t=e._readableState;c("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&i(e,"data")&&(t.flowing=!0,L(e))}}(r);e.on("drain",l);var f=!1;function p(t){c("ondata");var n=e.write(t);c("dest.write",n),!1===n&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==B(o.pipes,e))&&!f&&(c("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function h(t){c("onerror",t),y(),e.removeListener("error",h),0===i(e,"error")&&k(e,t)}function d(){e.removeListener("finish",m),y()}function m(){c("onfinish"),e.removeListener("close",d),y()}function y(){c("unpipe"),r.unpipe(e)}return r.on("data",p),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",h),e.once("close",d),e.once("finish",m),e.emit("pipe",r),o.flowing||(c("pipe resume"),r.resume()),e},E.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<o;i++)n[i].emit("unpipe",this,{hasUnpiped:!1});return this}var s=B(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},E.prototype.on=function(e,t){var r=s.prototype.on.call(this,e,t),o=this._readableState;return"data"===e?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===e&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,c("on readable",o.length,o.reading),o.length?C(this):o.reading||n.nextTick(D,this))),r},E.prototype.addListener=E.prototype.on,E.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(M,this),r},E.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(M,this),t},E.prototype.resume=function(){var e=this._readableState;return e.flowing||(c("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(j,e,t))}(this,e)),e.paused=!1,this},E.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},E.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var o in e.on("end",(function(){if(c("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(o){(c("wrapped data"),r.decoder&&(o=r.decoder.write(o)),r.objectMode&&null==o)||(r.objectMode||o&&o.length)&&(t.push(o)||(n=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var i=0;i<S.length;i++)e.on(S[i],this.emit.bind(this,S[i]));return this._read=function(t){c("wrapped _read",t),n&&(n=!1,e.resume())},this},"function"==typeof Symbol&&(E.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=r(253)),p(this)}),Object.defineProperty(E.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(E.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(E.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),E._fromList=U,Object.defineProperty(E.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(E.from=function(e,t){return void 0===h&&(h=r(254)),h(E,e,t)})}).call(this,r(9),r(8))},function(e,t,r){e.exports=r(24).EventEmitter},function(e,t,r){"use strict";(function(t){function r(e,t){o(e,t),n(e)}function n(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function o(e,t){e.emit("error",t)}e.exports={destroy:function(e,i){var s=this,a=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return a||u?(i?i(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,t.nextTick(o,this,e)):t.nextTick(o,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!i&&e?s._writableState?s._writableState.errorEmitted?t.nextTick(n,s):(s._writableState.errorEmitted=!0,t.nextTick(r,s,e)):t.nextTick(r,s,e):i?(t.nextTick(n,s),i(e)):t.nextTick(n,s)})),this)},undestroy:function(){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)},errorOrDestroy:function(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}}}).call(this,r(8))},function(e,t,r){"use strict";var n=r(17).codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(e,t,r,o){var i=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,o,r);if(null!=i){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new n(o?r:"highWaterMark",i);return Math.floor(i)}return e.objectMode?16:16384}}},function(e,t,r){"use strict";(function(t,n){function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var o=n.callback;t.pendingcb--,o(r),n=n.next}t.corkedRequestsFree.next=e}(t,e)}}var i;e.exports=E,E.WritableState=x;var s={deprecate:r(251)},a=r(100),u=r(7).Buffer,c=t.Uint8Array||function(){};var l,f=r(101),p=r(102).getHighWaterMark,h=r(17).codes,d=h.ERR_INVALID_ARG_TYPE,m=h.ERR_METHOD_NOT_IMPLEMENTED,y=h.ERR_MULTIPLE_CALLBACK,g=h.ERR_STREAM_CANNOT_PIPE,v=h.ERR_STREAM_DESTROYED,b=h.ERR_STREAM_NULL_VALUES,_=h.ERR_STREAM_WRITE_AFTER_END,w=h.ERR_UNKNOWN_ENCODING,k=f.errorOrDestroy;function S(){}function x(e,t,s){i=i||r(18),e=e||{},"boolean"!=typeof s&&(s=t instanceof i),this.objectMode=!!e.objectMode,s&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=p(this,e,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===e.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,o=r.sync,i=r.writecb;if("function"!=typeof i)throw new y;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick(R,e,t),e._writableState.errorEmitted=!0,k(e,o)):(i(o),e._writableState.errorEmitted=!0,k(e,o),R(e,t))}(e,r,o,t,i);else{var s=C(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||I(e,r),o?n.nextTick(A,e,r,s,i):A(e,r,s,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function E(e){var t=this instanceof(i=i||r(18));if(!t&&!l.call(E,this))return new E(e);this._writableState=new x(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),a.call(this)}function T(e,t,r,n,o,i,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new v("write")):r?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function A(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),R(e,t)}function I(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),s=t.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,T(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,f=r.callback;if(T(e,t,!1,t.objectMode?1:c.length,c,l,f),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function C(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function O(e,t){e._final((function(r){t.pendingcb--,r&&k(e,r),t.prefinished=!0,e.emit("prefinish"),R(e,t)}))}function R(e,t){var r=C(t);if(r&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(O,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var o=e._readableState;(!o||o.autoDestroy&&o.endEmitted)&&e.destroy()}return r}r(10)(E,a),x.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(x.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(l=Function.prototype[Symbol.hasInstance],Object.defineProperty(E,Symbol.hasInstance,{value:function(e){return!!l.call(this,e)||this===E&&(e&&e._writableState instanceof x)}})):l=function(e){return e instanceof this},E.prototype.pipe=function(){k(this,new g)},E.prototype.write=function(e,t,r){var o,i=this._writableState,s=!1,a=!i.objectMode&&(o=e,u.isBuffer(o)||o instanceof c);return a&&!u.isBuffer(e)&&(e=function(e){return u.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=S),i.ending?function(e,t){var r=new _;k(e,r),n.nextTick(t,r)}(this,r):(a||function(e,t,r,o){var i;return null===r?i=new b:"string"==typeof r||t.objectMode||(i=new d("chunk",["string","Buffer"],r)),!i||(k(e,i),n.nextTick(o,i),!1)}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,o,i){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=u.from(t,r));return t}(t,n,o);n!==s&&(r=!0,o="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:o,isBuf:r,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else T(e,t,!1,a,n,o,i);return c}(this,i,a,e,t,r)),s},E.prototype.cork=function(){this._writableState.corked++},E.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||I(this,e))},E.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new w(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(e,t,r){r(new m("_write()"))},E.prototype._writev=null,E.prototype.end=function(e,t,r){var o=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),o.corked&&(o.corked=1,this.uncork()),o.ending||function(e,t,r){t.ending=!0,R(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,o,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),E.prototype.destroy=f.destroy,E.prototype._undestroy=f.undestroy,E.prototype._destroy=function(e,t){t(e)}}).call(this,r(9),r(8))},function(e,t,r){"use strict";var n=r(252).Buffer,o=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=f,t=3;break;default:return this.write=p,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}t.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},i.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},i.prototype.text=function(e,t){var r=function(e,t,r){var n=t.length-1;if(n<r)return 0;var o=s(t[n]);if(o>=0)return o>0&&(e.lastNeed=o-1),o;if(--n<r||-2===o)return 0;if((o=s(t[n]))>=0)return o>0&&(e.lastNeed=o-2),o;if(--n<r||-2===o)return 0;if((o=s(t[n]))>=0)return o>0&&(2===o?o=0:e.lastNeed=o-3),o;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){"use strict";e.exports=l;var n=r(17).codes,o=n.ERR_METHOD_NOT_IMPLEMENTED,i=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(18);function c(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new i);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function l(e){if(!(this instanceof l))return new l(e);u.call(this,e),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",f)}function f(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(t,r){p(e,t,r)}))}function p(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}r(10)(l,u),l.prototype.push=function(e,t){return this._transformState.needTransform=!1,u.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,r){r(new o("_transform()"))},l.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var o=this._readableState;(n.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},l.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},l.prototype._destroy=function(e,t){u.prototype._destroy.call(this,e,(function(e){t(e)}))}},function(e,t,r){(function(t){const r=e.exports;r.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"},r.codes={};for(const e in r.types){const t=r.types[e];r.codes[t]=e}r.CMD_SHIFT=4,r.CMD_MASK=240,r.DUP_MASK=8,r.QOS_MASK=3,r.QOS_SHIFT=1,r.RETAIN_MASK=1,r.VARBYTEINT_MASK=127,r.VARBYTEINT_FIN_MASK=128,r.VARBYTEINT_MAX=268435455,r.SESSIONPRESENT_MASK=1,r.SESSIONPRESENT_HEADER=t.from([r.SESSIONPRESENT_MASK]),r.CONNACK_HEADER=t.from([r.codes.connack<<r.CMD_SHIFT]),r.USERNAME_MASK=128,r.PASSWORD_MASK=64,r.WILL_RETAIN_MASK=32,r.WILL_QOS_MASK=24,r.WILL_QOS_SHIFT=3,r.WILL_FLAG_MASK=4,r.CLEAN_SESSION_MASK=2,r.CONNECT_HEADER=t.from([r.codes.connect<<r.CMD_SHIFT]),r.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},r.propertiesCodes={};for(const e in r.properties){const t=r.properties[e];r.propertiesCodes[t]=e}function n(e){return[0,1,2].map(n=>[0,1].map(o=>[0,1].map(i=>{const s=t.alloc(1);return s.writeUInt8(r.codes[e]<<r.CMD_SHIFT|(o?r.DUP_MASK:0)|n<<r.QOS_SHIFT|i,0,!0),s})))}r.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},r.PUBLISH_HEADER=n("publish"),r.SUBSCRIBE_HEADER=n("subscribe"),r.SUBSCRIBE_OPTIONS_QOS_MASK=3,r.SUBSCRIBE_OPTIONS_NL_MASK=1,r.SUBSCRIBE_OPTIONS_NL_SHIFT=2,r.SUBSCRIBE_OPTIONS_RAP_MASK=1,r.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,r.SUBSCRIBE_OPTIONS_RH_MASK=3,r.SUBSCRIBE_OPTIONS_RH_SHIFT=4,r.SUBSCRIBE_OPTIONS_RH=[0,16,32],r.SUBSCRIBE_OPTIONS_NL=4,r.SUBSCRIBE_OPTIONS_RAP=8,r.SUBSCRIBE_OPTIONS_QOS=[0,1,2],r.UNSUBSCRIBE_HEADER=n("unsubscribe"),r.ACKS={unsuback:n("unsuback"),puback:n("puback"),pubcomp:n("pubcomp"),pubrel:n("pubrel"),pubrec:n("pubrec")},r.SUBACK_HEADER=t.from([r.codes.suback<<r.CMD_SHIFT]),r.VERSION3=t.from([3]),r.VERSION4=t.from([4]),r.VERSION5=t.from([5]),r.VERSION131=t.from([131]),r.VERSION132=t.from([132]),r.QOS=[0,1,2].map(e=>t.from([e])),r.EMPTY={pingreq:t.from([r.codes.pingreq<<4,0]),pingresp:t.from([r.codes.pingresp<<4,0]),disconnect:t.from([r.codes.disconnect<<4,0])}}).call(this,r(7).Buffer)},function(e,t,r){(function(t){const n=r(106),o=t.allocUnsafe(0),i=t.from([0]),s=r(265),a=r(266).nextTick,u=r(15)("mqtt-packet:writeToStream"),c=s.cache,l=s.generateNumber,f=s.generateCache,p=s.genBufVariableByteInt,h=s.generate4ByteBuffer;let d=k,m=!0;function y(e,r,s){switch(u("generate called"),r.cork&&(r.cork(),a(g,r)),m&&(m=!1,f()),u("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return function(e,r,o){const i=e||{},s=i.protocolId||"MQTT";let a=i.protocolVersion||4;const u=i.will;let c=i.clean;const l=i.keepalive||0,f=i.clientId||"",p=i.username,h=i.password,m=i.properties;void 0===c&&(c=!0);let y=0;if(!s||"string"!=typeof s&&!t.isBuffer(s))return r.emit("error",new Error("Invalid protocolId")),!1;y+=s.length+2;if(3!==a&&4!==a&&5!==a)return r.emit("error",new Error("Invalid protocol version")),!1;y+=1;if(("string"==typeof f||t.isBuffer(f))&&(f||a>=4)&&(f||c))y+=t.byteLength(f)+2;else{if(a<4)return r.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*c==0)return r.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof l||l<0||l>65535||l%1!=0)return r.emit("error",new Error("Invalid keepalive")),!1;y+=2;if(y+=1,5===a){var g=E(r,m);if(!g)return!1;y+=g.length}if(u){if("object"!=typeof u)return r.emit("error",new Error("Invalid will")),!1;if(!u.topic||"string"!=typeof u.topic)return r.emit("error",new Error("Invalid will topic")),!1;if(y+=t.byteLength(u.topic)+2,y+=2,u.payload){if(!(u.payload.length>=0))return r.emit("error",new Error("Invalid will payload")),!1;"string"==typeof u.payload?y+=t.byteLength(u.payload):y+=u.payload.length}var v={};if(5===a){if(!(v=E(r,u.properties)))return!1;y+=v.length}}let w=!1;if(null!=p){if(!O(p))return r.emit("error",new Error("Invalid username")),!1;w=!0,y+=t.byteLength(p)+2}if(null!=h){if(!w)return r.emit("error",new Error("Username is required to use password")),!1;if(!O(h))return r.emit("error",new Error("Invalid password")),!1;y+=C(h)+2}r.write(n.CONNECT_HEADER),b(r,y),x(r,s),i.bridgeMode&&(a+=128);r.write(131===a?n.VERSION131:132===a?n.VERSION132:4===a?n.VERSION4:5===a?n.VERSION5:n.VERSION3);let k=0;k|=null!=p?n.USERNAME_MASK:0,k|=null!=h?n.PASSWORD_MASK:0,k|=u&&u.retain?n.WILL_RETAIN_MASK:0,k|=u&&u.qos?u.qos<<n.WILL_QOS_SHIFT:0,k|=u?n.WILL_FLAG_MASK:0,k|=c?n.CLEAN_SESSION_MASK:0,r.write(t.from([k])),d(r,l),5===a&&g.write();x(r,f),u&&(5===a&&v.write(),_(r,u.topic),x(r,u.payload));null!=p&&x(r,p);null!=h&&x(r,h);return!0}(e,r);case"connack":return function(e,r,o){const s=o?o.protocolVersion:4,a=e||{},u=5===s?a.reasonCode:a.returnCode,c=a.properties;let l=2;if("number"!=typeof u)return r.emit("error",new Error("Invalid return code")),!1;let f=null;if(5===s){if(f=E(r,c),!f)return!1;l+=f.length}r.write(n.CONNACK_HEADER),b(r,l),r.write(a.sessionPresent?n.SESSIONPRESENT_HEADER:i),r.write(t.from([u])),null!=f&&f.write();return!0}(e,r,s);case"publish":return function(e,r,i){u("publish: packet: %o",e);const s=i?i.protocolVersion:4,a=e||{},c=a.qos||0,l=a.retain?n.RETAIN_MASK:0,f=a.topic,p=a.payload||o,h=a.messageId,m=a.properties;let y=0;if("string"==typeof f)y+=t.byteLength(f)+2;else{if(!t.isBuffer(f))return r.emit("error",new Error("Invalid topic")),!1;y+=f.length+2}t.isBuffer(p)?y+=p.length:y+=t.byteLength(p);if(c&&"number"!=typeof h)return r.emit("error",new Error("Invalid messageId")),!1;c&&(y+=2);let g=null;if(5===s){if(g=E(r,m),!g)return!1;y+=g.length}r.write(n.PUBLISH_HEADER[c][a.dup?1:0][l?1:0]),b(r,y),d(r,C(f)),r.write(f),c>0&&d(r,h);null!=g&&g.write();return u("publish: payload: %o",p),r.write(p)}(e,r,s);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.cmd||"puback",u=s.messageId,c=s.dup&&"pubrel"===a?n.DUP_MASK:0;let l=0;const f=s.reasonCode,p=s.properties;let h=5===i?3:2;"pubrel"===a&&(l=1);if("number"!=typeof u)return r.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===i&&"object"==typeof p){if(m=T(r,p,o,h),!m)return!1;h+=m.length}r.write(n.ACKS[a][l][c][0]),b(r,h),d(r,u),5===i&&r.write(t.from([f]));null!==m&&m.write();return!0}(e,r,s);case"subscribe":return function(e,r,o){u("subscribe: packet: ");const i=o?o.protocolVersion:4,s=e||{},a=s.dup?n.DUP_MASK:0,c=s.messageId,l=s.subscriptions,f=s.properties;let p=0;if("number"!=typeof c)return r.emit("error",new Error("Invalid messageId")),!1;p+=2;let h=null;if(5===i){if(h=E(r,f),!h)return!1;p+=h.length}if("object"!=typeof l||!l.length)return r.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<l.length;e+=1){const n=l[e].topic,o=l[e].qos;if("string"!=typeof n)return r.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return r.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===i){if("boolean"!=typeof(l[e].nl||!1))return r.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(l[e].rap||!1))return r.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const t=l[e].rh||0;if("number"!=typeof t||t>2)return r.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}p+=t.byteLength(n)+2+1}u("subscribe: writing to stream: %o",n.SUBSCRIBE_HEADER),r.write(n.SUBSCRIBE_HEADER[1][a?1:0][0]),b(r,p),d(r,c),null!==h&&h.write();let m=!0;for(const e of l){const o=e.topic,s=e.qos,a=+e.nl,u=+e.rap,c=e.rh;let l;_(r,o),l=n.SUBSCRIBE_OPTIONS_QOS[s],5===i&&(l|=a?n.SUBSCRIBE_OPTIONS_NL:0,l|=u?n.SUBSCRIBE_OPTIONS_RAP:0,l|=c?n.SUBSCRIBE_OPTIONS_RH[c]:0),m=r.write(t.from([l]))}return m}(e,r,s);case"suback":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,u=s.granted,c=s.properties;let l=0;if("number"!=typeof a)return r.emit("error",new Error("Invalid messageId")),!1;l+=2;if("object"!=typeof u||!u.length)return r.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<u.length;e+=1){if("number"!=typeof u[e])return r.emit("error",new Error("Invalid qos vector")),!1;l+=1}let f=null;if(5===i){if(f=T(r,c,o,l),!f)return!1;l+=f.length}r.write(n.SUBACK_HEADER),b(r,l),d(r,a),null!==f&&f.write();return r.write(t.from(u))}(e,r,s);case"unsubscribe":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,u=s.dup?n.DUP_MASK:0,c=s.unsubscriptions,l=s.properties;let f=0;if("number"!=typeof a)return r.emit("error",new Error("Invalid messageId")),!1;f+=2;if("object"!=typeof c||!c.length)return r.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<c.length;e+=1){if("string"!=typeof c[e])return r.emit("error",new Error("Invalid unsubscriptions")),!1;f+=t.byteLength(c[e])+2}let p=null;if(5===i){if(p=E(r,l),!p)return!1;f+=p.length}r.write(n.UNSUBSCRIBE_HEADER[1][u?1:0][0]),b(r,f),d(r,a),null!==p&&p.write();let h=!0;for(let e=0;e<c.length;e++)h=_(r,c[e]);return h}(e,r,s);case"unsuback":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,u=s.dup?n.DUP_MASK:0,c=s.granted,l=s.properties,f=s.cmd;let p=2;if("number"!=typeof a)return r.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof c||!c.length)return r.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return r.emit("error",new Error("Invalid qos vector")),!1;p+=1}}let h=null;if(5===i){if(h=T(r,l,o,p),!h)return!1;p+=h.length}r.write(n.ACKS[f][0][u][0]),b(r,p),d(r,a),null!==h&&h.write();5===i&&r.write(t.from(c));return!0}(e,r,s);case"pingreq":case"pingresp":return function(e,t,r){return t.write(n.EMPTY[e.cmd])}(e,r);case"disconnect":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,u=s.properties;let c=5===i?1:0,l=null;if(5===i){if(l=T(r,u,o,c),!l)return!1;c+=l.length}r.write(t.from([n.codes.disconnect<<4])),b(r,c),5===i&&r.write(t.from([a]));null!==l&&l.write();return!0}(e,r,s);case"auth":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,u=s.properties;let c=5===i?1:0;5!==i&&r.emit("error",new Error("Invalid mqtt version for auth packet"));const l=T(r,u,o,c);if(!l)return!1;c+=l.length,r.write(t.from([n.codes.auth<<4])),b(r,c),r.write(t.from([a])),null!==l&&l.write();return!0}(e,r,s);default:return r.emit("error",new Error("Unknown command")),!1}}function g(e){e.uncork()}Object.defineProperty(y,"cacheNumbers",{get:()=>d===k,set(e){e?(c&&0!==Object.keys(c).length||(m=!0),d=k):(m=!1,d=S)}});const v={};function b(e,t){if(t>n.VARBYTEINT_MAX)return e.emit("error",new Error("Invalid variable byte integer: "+t)),!1;let r=v[t];return r||(r=p(t),t<16384&&(v[t]=r)),u("writeVarByteInt: writing to stream: %o",r),e.write(r)}function _(e,r){const n=t.byteLength(r);return d(e,n),u("writeString: %s",r),e.write(r,"utf8")}function w(e,t,r){_(e,t),_(e,r)}function k(e,t){return u("writeNumberCached: number: %d",t),u("writeNumberCached: %o",c[t]),e.write(c[t])}function S(e,t){const r=l(t);return u("writeNumberGenerated: %o",r),e.write(r)}function x(e,t){"string"==typeof t?_(e,t):t?(d(e,t.length),e.write(t)):d(e,0)}function E(e,r){if("object"!=typeof r||null!=r.length)return{length:1,write(){I(e,{},0)}};let o=0;function i(r,o){let i=0;switch(n.propertiesTypes[r]){case"byte":if("boolean"!=typeof o)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=2;break;case"int8":if("number"!=typeof o||o<0||o>255)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=2;break;case"binary":if(o&&null===o)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=1+t.byteLength(o)+2;break;case"int16":if("number"!=typeof o||o<0||o>65535)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=3;break;case"int32":if("number"!=typeof o||o<0||o>4294967295)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=5;break;case"var":if("number"!=typeof o||o<0||o>268435455)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=1+t.byteLength(p(o));break;case"string":if("string"!=typeof o)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=3+t.byteLength(o.toString());break;case"pair":if("object"!=typeof o)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=Object.getOwnPropertyNames(o).reduce((e,r)=>{const n=o[r];return Array.isArray(n)?e+=n.reduce((e,n)=>e+=3+t.byteLength(r.toString())+2+t.byteLength(n.toString()),0):e+=3+t.byteLength(r.toString())+2+t.byteLength(o[r].toString()),e},0);break;default:return e.emit("error",new Error(`Invalid property ${r}: ${o}`)),!1}return i}if(r)for(const e in r){let t=0,n=0;const s=r[e];if(Array.isArray(s))for(let r=0;r<s.length;r++){if(n=i(e,s[r]),!n)return!1;t+=n}else{if(n=i(e,s),!n)return!1;t=n}if(!t)return!1;o+=t}return{length:t.byteLength(p(o))+o,write(){I(e,r,o)}}}function T(e,t,r,n){const o=["reasonString","userProperties"],i=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0;let s=E(e,t);if(i)for(;n+s.length>i;){const r=o.shift();if(!r||!t[r])return!1;delete t[r],s=E(e,t)}return s}function A(e,r,o){switch(n.propertiesTypes[r]){case"byte":e.write(t.from([n.properties[r]])),e.write(t.from([+o]));break;case"int8":e.write(t.from([n.properties[r]])),e.write(t.from([o]));break;case"binary":e.write(t.from([n.properties[r]])),x(e,o);break;case"int16":e.write(t.from([n.properties[r]])),d(e,o);break;case"int32":e.write(t.from([n.properties[r]])),function(e,t){const r=h(t);u("write4ByteNumber: %o",r),e.write(r)}(e,o);break;case"var":e.write(t.from([n.properties[r]])),b(e,o);break;case"string":e.write(t.from([n.properties[r]])),_(e,o);break;case"pair":Object.getOwnPropertyNames(o).forEach(i=>{const s=o[i];Array.isArray(s)?s.forEach(o=>{e.write(t.from([n.properties[r]])),w(e,i.toString(),o.toString())}):(e.write(t.from([n.properties[r]])),w(e,i.toString(),s.toString()))});break;default:return e.emit("error",new Error(`Invalid property ${r} value: ${o}`)),!1}}function I(e,t,r){b(e,r);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&null!==t[r]){const n=t[r];if(Array.isArray(n))for(let t=0;t<n.length;t++)A(e,r,n[t]);else A(e,r,n)}}function C(e){return e?e instanceof t?e.length:t.byteLength(e):0}function O(e){return"string"==typeof e||e instanceof t}e.exports=y}).call(this,r(7).Buffer)},function(e,t,r){"use strict";var n=r(19),o=r(31),i=r(275),s=r(109),a=r(300)||s||i;e.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new n("Side channel does not contain "+o(e))},delete:function(t){return!!e&&e.delete(t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,r){e||(e=a()),e.set(t,r)}};return t}},function(e,t,r){"use strict";var n=r(45),o=r(116),i=r(31),s=r(19),a=n("%Map%",!0),u=o("Map.prototype.get",!0),c=o("Map.prototype.set",!0),l=o("Map.prototype.has",!0),f=o("Map.prototype.delete",!0),p=o("Map.prototype.size",!0);e.exports=!!a&&function(){var e,t={assert:function(e){if(!t.has(e))throw new s("Side channel does not contain "+i(e))},delete:function(t){if(e){var r=f(e,t);return 0===p(e)&&(e=void 0),r}return!1},get:function(t){if(e)return u(e,t)},has:function(t){return!!e&&l(e,t)},set:function(t,r){e||(e=new a),c(e,t,r)}};return t}},function(e,t,r){"use strict";e.exports=Object},function(e,t,r){"use strict";var n=r(290);if(n)try{n([],"length")}catch(e){n=null}e.exports=n},function(e,t,r){"use strict";e.exports="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null},function(e,t,r){"use strict";var n=r(110);e.exports=n.getPrototypeOf||null},function(e,t,r){"use strict";var n=r(32),o=r(19),i=r(46),s=r(297);e.exports=function(e){if(e.length<1||"function"!=typeof e[0])throw new o("a function is required");return s(n,i,e)}},function(e,t,r){"use strict";e.exports=Function.prototype.apply},function(e,t,r){"use strict";var n=r(45),o=r(114),i=o([n("%String.prototype.indexOf%")]);e.exports=function(e,t){var r=n(e,!!t);return"function"==typeof r&&i(e,".prototype.")>-1?o([r]):r}},function(e,t,r){"use strict";var n=r(47),o=r(108),i=Object.prototype.hasOwnProperty,s=Array.isArray,a=o(),u=function(e,t){return a.set(e,t),e},c=function(e){return a.has(e)},l=function(e){return a.get(e)},f=function(e,t){a.set(e,t)},p=function(){for(var e=[],t=0;t<256;++t)e[e.length]="%"+((t<16?"0":"")+t.toString(16)).toUpperCase();return e}(),h=function(e,t){for(var r=t&&t.plainObjects?{__proto__:null}:{},n=0;n<e.length;++n)void 0!==e[n]&&(r[n]=e[n]);return r};e.exports={arrayToObject:h,assign:function(e,t){return Object.keys(t).reduce((function(e,r){return e[r]=t[r],e}),e)},combine:function(e,t,r,n){if(c(e)){var o=l(e)+1;return e[o]=t,f(e,o),e}var i=[].concat(e,t);return i.length>r?u(h(i,{plainObjects:n}),i.length-1):i},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],n=0;n<t.length;++n)for(var o=t[n],i=o.obj[o.prop],a=Object.keys(i),u=0;u<a.length;++u){var c=a[u],l=i[c];"object"==typeof l&&null!==l&&-1===r.indexOf(l)&&(t[t.length]={obj:i,prop:c},r[r.length]=l)}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(s(r)){for(var n=[],o=0;o<r.length;++o)void 0!==r[o]&&(n[n.length]=r[o]);t.obj[t.prop]=n}}}(t),e},decode:function(e,t,r){var n=e.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(e){return n}},encode:function(e,t,r,o,i){if(0===e.length)return e;var s=e;if("symbol"==typeof e?s=Symbol.prototype.toString.call(e):"string"!=typeof e&&(s=String(e)),"iso-8859-1"===r)return escape(s).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var a="",u=0;u<s.length;u+=1024){for(var c=s.length>=1024?s.slice(u,u+1024):s,l=[],f=0;f<c.length;++f){var h=c.charCodeAt(f);45===h||46===h||95===h||126===h||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||i===n.RFC1738&&(40===h||41===h)?l[l.length]=c.charAt(f):h<128?l[l.length]=p[h]:h<2048?l[l.length]=p[192|h>>6]+p[128|63&h]:h<55296||h>=57344?l[l.length]=p[224|h>>12]+p[128|h>>6&63]+p[128|63&h]:(f+=1,h=65536+((1023&h)<<10|1023&c.charCodeAt(f)),l[l.length]=p[240|h>>18]+p[128|h>>12&63]+p[128|h>>6&63]+p[128|63&h])}a+=l.join("")}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isOverflow:c,isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},markOverflow:u,maybeMap:function(e,t){if(s(e)){for(var r=[],n=0;n<e.length;n+=1)r[r.length]=t(e[n]);return r}return t(e)},merge:function e(t,r,n){if(!r)return t;if("object"!=typeof r&&"function"!=typeof r){if(s(t)){var o=t.length;if(n&&"number"==typeof n.arrayLimit&&o>n.arrayLimit)return u(h(t.concat(r),n),o);t[o]=r}else{if(!t||"object"!=typeof t)return[t,r];if(c(t)){var a=l(t)+1;t[a]=r,f(t,a)}else{if(n&&n.strictMerge)return[t,r];(n&&(n.plainObjects||n.allowPrototypes)||!i.call(Object.prototype,r))&&(t[r]=!0)}}return t}if(!t||"object"!=typeof t){if(c(r)){for(var p=Object.keys(r),d=n&&n.plainObjects?{__proto__:null,0:t}:{0:t},m=0;m<p.length;m++){d[parseInt(p[m],10)+1]=r[p[m]]}return u(d,l(r)+1)}var y=[t].concat(r);return n&&"number"==typeof n.arrayLimit&&y.length>n.arrayLimit?u(h(y,n),y.length-1):y}var g=t;return s(t)&&!s(r)&&(g=h(t,n)),s(t)&&s(r)?(r.forEach((function(r,o){if(i.call(t,o)){var s=t[o];s&&"object"==typeof s&&r&&"object"==typeof r?t[o]=e(s,r,n):t[t.length]=r}else t[o]=r})),t):Object.keys(r).reduce((function(t,o){var s=r[o];if(i.call(t,o)?t[o]=e(t[o],s,n):t[o]=s,c(r)&&!c(t)&&u(t,l(r)),c(t)){var a=parseInt(o,10);String(a)===o&&a>=0&&a>l(t)&&f(t,a)}return t}),g)}}},function(e,t,r){"use strict";var n=r(302),o=r(15)("mqttjs:tcp");e.exports=function(e,t){var r,i;return t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost",r=t.port,i=t.hostname,o("port %d and host %s",r,i),n.createConnection(r,i)}},function(e,t,r){"use strict";(function(t){var n,o,i,s=r(14).Transform,a=r(49);e.exports=function(e,r){if(r.hostname=r.hostname||r.host,!r.hostname)throw new Error("Could not determine host. Specify host manually.");var u="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(r);var c=function(e,t){var r="wxs"===e.protocol?"wss":"ws",n=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(n=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}(r,e);n=wx.connectSocket({url:c,protocols:[u]}),o=function(){var e=new s;return e._write=function(e,t,r){n.send({data:e.buffer,success:function(){r()},fail:function(e){r(new Error(e))}})},e._flush=function(e){n.close({success:function(){e()}})},e}(),(i=a.obj())._destroy=function(e,t){n.close({success:function(){t&&t(e)}})};var l=i.destroy;return i.destroy=function(){i.destroy=l;var e=this;setTimeout((function(){n.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(i),n.onOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),n.onMessage((function(e){var r=e.data;r=r instanceof ArrayBuffer?t.from(r):t.from(r,"utf8"),o.push(r)})),n.onClose((function(){i.end(),i.destroy()})),n.onError((function(e){i.destroy(new Error(e.errMsg))})),i}}).call(this,r(7).Buffer)},function(e,t,r){"use strict";(function(t){var n,o,i,s=r(14).Transform,a=r(49),u=!1;e.exports=function(e,r){if(r.hostname=r.hostname||r.host,!r.hostname)throw new Error("Could not determine host. Specify host manually.");var c="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(r);var l=function(e,t){var r="alis"===e.protocol?"wss":"ws",n=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(n=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}(r,e);return(n=r.my).connectSocket({url:l,protocols:c}),o=function(){var e=new s;return e._write=function(e,t,r){n.sendSocketMessage({data:e.buffer,success:function(){r()},fail:function(){r(new Error)}})},e._flush=function(e){n.closeSocket({success:function(){e()}})},e}(),i=a.obj(),u||(u=!0,n.onSocketOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),n.onSocketMessage((function(e){if("string"==typeof e.data){var r=t.from(e.data,"base64");o.push(r)}else{var n=new FileReader;n.addEventListener("load",(function(){var e=n.result;e=e instanceof ArrayBuffer?t.from(e):t.from(e,"utf8"),o.push(e)})),n.readAsArrayBuffer(e.data)}})),n.onSocketClose((function(){i.end(),i.destroy()})),n.onSocketError((function(e){i.destroy(e)}))),i}}).call(this,r(7).Buffer)},function(e,t,r){"use strict";(function(t,n){const o=r(308),i=r(15)("mqttjs:ws"),s=r(49),a=r(14).Transform;let u=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];const c=void 0!==t&&"browser"===t.title||"function"==typeof r;function l(e,t){let r=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function f(e){let t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),c||"wss"!==e.protocol||u.forEach((function(r){e.hasOwnProperty(r)&&!e.wsOptions.hasOwnProperty(r)&&(t.wsOptions[r]=e[r])})),t}e.exports=c?function(e,t){let r;i("browserStreamBuilder");const o=function(e){let t=f(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port)}return void 0===t.objectMode&&(t.objectMode=!(!0===t.binary||void 0===t.binary)),t}(t).browserBufferSize||524288,u=t.browserBufferTimeout||1e3,c=!t.objectMode;let p=function(e,t){const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";let n=l(t,e),o=new WebSocket(n,[r]);return o.binaryType="arraybuffer",o}(e,t),h=function(e,t,r){let n=new a({objectModeMode:e.objectMode});return n._write=t,n._flush=r,n}(t,(function e(t,r,i){p.bufferedAmount>o&&setTimeout(e,u,t,r,i);c&&"string"==typeof t&&(t=n.from(t,"utf8"));try{p.send(t)}catch(e){return i(e)}i()}),(function(e){p.close(),e()}));t.objectMode||(h._writev=b),h.on("close",()=>{p.close()});const d=void 0!==p.addEventListener;function m(){r.setReadable(h),r.setWritable(h),r.emit("connect")}function y(){r.end(),r.destroy()}function g(e){r.destroy(e)}function v(e){let t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),h.push(t)}function b(e,t){const r=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?r[t]=n.from(e[t],"utf8"):r[t]=e[t].chunk;this._write(n.concat(r),"binary",t)}return p.readyState===p.OPEN?r=h:(r=r=s(void 0,void 0,t),t.objectMode||(r._writev=b),d?p.addEventListener("open",m):p.onopen=m),r.socket=p,d?(p.addEventListener("close",y),p.addEventListener("error",g),p.addEventListener("message",v)):(p.onclose=y,p.onerror=g,p.onmessage=v),r}:function(e,t){i("streamBuilder");let r=f(t);const n=l(r,e);let s=function(e,t,r){i("createWebSocket"),i("protocol: "+r.protocolId+" "+r.protocolVersion);const n="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";return i("creating new Websocket for url: "+t+" and protocol: "+n),new o(t,[n],r.wsOptions)}(0,n,r),a=o.createWebSocketStream(s,r.wsOptions);return a.url=n,s.on("close",()=>{a.destroy()}),a}}).call(this,r(8),r(7).Buffer)},function(e,t,r){(function(t){var r=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt,a="object"==typeof t&&t&&t.Object===Object&&t,u="object"==typeof self&&self&&self.Object===Object&&self,c=a||u||Function("return this")(),l=Object.prototype.toString,f=Math.max,p=Math.min,h=function(){return c.Date.now()};function d(e,t,r){var n,o,i,s,a,u,c=0,l=!1,d=!1,g=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function v(t){var r=n,i=o;return n=o=void 0,c=t,s=e.apply(i,r)}function b(e){return c=e,a=setTimeout(w,t),l?v(e):s}function _(e){var r=e-u;return void 0===u||r>=t||r<0||d&&e-c>=i}function w(){var e=h();if(_(e))return k(e);a=setTimeout(w,function(e){var r=t-(e-u);return d?p(r,i-(e-c)):r}(e))}function k(e){return a=void 0,g&&n?v(e):(n=o=void 0,s)}function S(){var e=h(),r=_(e);if(n=arguments,o=this,u=e,r){if(void 0===a)return b(u);if(d)return a=setTimeout(w,t),v(u)}return void 0===a&&(a=setTimeout(w,t)),s}return t=y(t)||0,m(r)&&(l=!!r.leading,i=(d="maxWait"in r)?f(y(r.maxWait)||0,t):i,g="trailing"in r?!!r.trailing:g),S.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=u=o=a=void 0},S.flush=function(){return void 0===a?s:k(h())},S}function m(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function y(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==l.call(e)}(e))return NaN;if(m(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=m(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var a=o.test(e);return a||i.test(e)?s(e.slice(2),a?2:8):n.test(e)?NaN:+e}e.exports=function(e,t,r){var n=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return m(r)&&(n="leading"in r?!!r.leading:n,o="trailing"in r?!!r.trailing:o),d(e,t,{leading:n,maxWait:t,trailing:o})}}).call(this,r(9))},function(e,t,r){var n=r(241),o=r(242),i=r(56),s=r(243);e.exports=function(e,t){return n(e)||o(e,t)||i(e,t)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";(function(t){var n=r(244),o=r(98),i=r(269),s=r(43),a=r(15)("mqttjs"),u={};function c(e,t){if(a("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){var r=i.parse(e,!0);if(null!=r.port&&(r.port=Number(r.port)),null===(t=s(r,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(function(e){var t;e.auth&&((t=e.auth.match(/^(.+):(.+)$/))?(e.username=t[1],e.password=t[2]):e.username=e.auth)}(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!u[t.protocol]){var o=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(e,t){return(!o||t%2!=0)&&"function"==typeof u[e]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");t.protocol&&(t.defaultProtocol=t.protocol);var c=new n((function(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),a("calling streambuilder for",t.protocol),u[t.protocol](e,t)}),t);return c.on("error",(function(){})),c}void 0!==t&&"browser"!==t.title||"function"!=typeof r?(u.mqtt=r(118),u.tcp=r(118),u.ssl=r(48),u.tls=r(48),u.mqtts=r(48)):(u.wx=r(119),u.wxs=r(119),u.ali=r(120),u.alis=r(120)),u.ws=r(121),u.wss=r(121),e.exports=c,e.exports.connect=c,e.exports.MqttClient=n,e.exports.Store=o}).call(this,r(8))},function(e,t,r){(function(t){var r=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt,a="object"==typeof t&&t&&t.Object===Object&&t,u="object"==typeof self&&self&&self.Object===Object&&self,c=a||u||Function("return this")(),l=Object.prototype.toString,f=Math.max,p=Math.min,h=function(){return c.Date.now()};function d(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function m(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==l.call(e)}(e))return NaN;if(d(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=d(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var a=o.test(e);return a||i.test(e)?s(e.slice(2),a?2:8):n.test(e)?NaN:+e}e.exports=function(e,t,r){var n,o,i,s,a,u,c=0,l=!1,y=!1,g=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function v(t){var r=n,i=o;return n=o=void 0,c=t,s=e.apply(i,r)}function b(e){return c=e,a=setTimeout(w,t),l?v(e):s}function _(e){var r=e-u;return void 0===u||r>=t||r<0||y&&e-c>=i}function w(){var e=h();if(_(e))return k(e);a=setTimeout(w,function(e){var r=t-(e-u);return y?p(r,i-(e-c)):r}(e))}function k(e){return a=void 0,g&&n?v(e):(n=o=void 0,s)}function S(){var e=h(),r=_(e);if(n=arguments,o=this,u=e,r){if(void 0===a)return b(u);if(y)return a=setTimeout(w,t),v(u)}return void 0===a&&(a=setTimeout(w,t)),s}return t=m(t)||0,d(r)&&(l=!!r.leading,i=(y="maxWait"in r)?f(m(r.maxWait)||0,t):i,g="trailing"in r?!!r.trailing:g),S.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=u=o=a=void 0},S.flush=function(){return void 0===a?s:k(h())},S}}).call(this,r(9))},function(e){e.exports=JSON.parse('{"name":"qiscus-sdk-core","version":"2.16.0","description":"Qiscus Web SDK Core","license":"MIT","main":"lib/index.js","browser":"dist/qiscus-sdk-core.min.js","unpkg":"dist/qiscus-sdk-core.min.js","files":["lib","dist"],"scripts":{"build":"npm-run-all --parallel build:node build:web build:web:dev","build:dev":"npm-run-all --parallel build:node build:web:dev","build:dev:watch":"npm-run-all --parallel build:web:watch serve","build:node":"babel -d lib src","build:node:watch":"babel -w -d lib src","build:web":"webpack --env.production --env.target=web","build:web:dev":"webpack --env.development --env.target=web","build:web:watch":"webpack --env.development --env.target=web --watch","dev":"webpack --env.development --progress --colors --watch","watch":"npm-run-all build:web:watch build:node:watch","test":"mocha --require @babel/register --colors \'test/**/*test.js\'","test:watch":"npm run test -- -w","clean":"rimraf dist lib","preversion":"npm-run-all clean build","prepublishOnly":"npm-run-all clean build","serve":"http-server -p 1234 -c-1 dist","dev:serve":"run-p serve watch","release:patch":"np patch --any-branch --yolo"},"devDependencies":{"@babel/cli":"^7.10.5","@babel/core":"^7.11.4","@babel/plugin-proposal-class-properties":"^7.10.4","@babel/plugin-transform-runtime":"^7.11.0","@babel/polyfill":"^7.10.4","@babel/preset-env":"^7.11.0","@babel/register":"^7.10.5","@commitlint/cli":"^8.3.5","@commitlint/config-conventional":"^8.3.4","babel-eslint":"^8.2.6","babel-loader":"^8.0.6","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-date-fns":"^0.1.0","chai":"^4.2.0","chai-spies":"^1.0.0","eslint":"5.0.0","eslint-config-standard":"^12.0.0","eslint-loader":"^2.2.1","eslint-plugin-import":"^2.22.0","eslint-plugin-node":"^8.0.1","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","http-server":"^0.12.3","mocha":"^5.2.0","np":"^8.0.4","npm-run-all":"^4.1.5","rimraf":"^2.7.1","serve":"^12.0.0","webpack":"^4.44.1","webpack-cli":"^3.3.12"},"dependencies":{"@babel/runtime":"^7.11.2","date-fns":"^1.30.1","lodash.debounce":"^4.0.8","lodash.throttle":"^4.1.1","mitt":"^1.2.0","mqtt":"~4.2.6","superagent":"^3.8.3"},"babel":{"presets":[["@babel/preset-env",{"modules":"auto"}]],"plugins":["@babel/plugin-transform-runtime","@babel/plugin-proposal-class-properties","babel-plugin-add-module-exports"]},"prettier":{"semi":false,"singleQuote":true,"trailingComma":"es5"},"engines":{"node":"16.15.1"},"packageManager":"pnpm@8.15.9"}')},function(e,t,r){e.exports=r(309)},function(e,t,r){var n=r(55);e.exports=function(e){if(Array.isArray(e))return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(25).default;e.exports=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(26),o=r(58),i=r(133),s=r(60),a=r(61),u=r(134),c=r(135);function l(){"use strict";var t=o(),r=t.m(l),f=(Object.getPrototypeOf?Object.getPrototypeOf(r):r.__proto__).constructor;function p(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))}var h={throw:1,return:2,break:3,continue:3};function d(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,h[e],t)},delegateYield:function(e,o,i){return t.resultName=o,r(n.d,c(e),i)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(e.exports=l=function(){return{wrap:function(e,r,n,o){return t.w(d(e),r,n,o&&o.reverse())},isGeneratorFunction:p,mark:t.m,awrap:function(e,t){return new n(e,t)},AsyncIterator:a,async:function(e,t,r,n,o){return(p(t)?s:i)(d(e),t,r,n,o)},keys:u,values:c}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=l,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(60);e.exports=function(e,t,r,o,i){var s=n(e,t,r,o,i);return s.next().then((function(e){return e.done?e.value:s.next()}))},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(25).default;e.exports=function(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(n(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}e.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<n.length;o++)if((r=n[o])===t||r.fn===t){n.splice(o,1);break}return 0===n.length&&delete this._callbacks["$"+e],this},n.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){n=0;for(var o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,t)}return this},n.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},n.prototype.hasListeners=function(e){return!!this.listeners(e).length}},function(e,t,r){"use strict";var n=r(62);function o(e){if(e)return function(e){for(var t in o.prototype)e[t]=o.prototype[t];return e}(e)}e.exports=o,o.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},o.prototype.parse=function(e){return this._parser=e,this},o.prototype.responseType=function(e){return this._responseType=e,this},o.prototype.serialize=function(e){return this._serializer=e,this},o.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this;for(var t in e)switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;default:console.warn("Unknown timeout option",t)}return this},o.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var i=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];o.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(e,t);if(!0===r)return!0;if(!1===r)return!1}catch(e){console.error(e)}if(t&&t.status&&t.status>=500&&501!=t.status)return!0;if(e){if(e.code&&~i.indexOf(e.code))return!0;if(e.timeout&&"ECONNABORTED"==e.code)return!0;if(e.crossDomain)return!0}return!1},o.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},o.prototype.then=function(e,t){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.end((function(r,n){r?t(r):e(n)}))}))}return this._fullfilledPromise.then(e,t)},o.prototype.catch=function(e){return this.then(void 0,e)},o.prototype.use=function(e){return e(this),this},o.prototype.ok=function(e){if("function"!=typeof e)throw Error("Callback required");return this._okCallback=e,this},o.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},o.prototype.get=function(e){return this._header[e.toLowerCase()]},o.prototype.getHeader=o.prototype.get,o.prototype.set=function(e,t){if(n(e)){for(var r in e)this.set(r,e[r]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},o.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},o.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(e)){for(var r in e)this.field(r,e[r]);return this}if(Array.isArray(t)){for(var o in t)this.field(e,t[o]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=""+t),this._getFormData().append(e,t),this},o.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},o.prototype._auth=function(e,t,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(e+":"+t));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer "+e)}return this},o.prototype.withCredentials=function(e){return null==e&&(e=!0),this._withCredentials=e,this},o.prototype.redirects=function(e){return this._maxRedirects=e,this},o.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw TypeError("Invalid argument");return this._maxResponseSize=e,this},o.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},o.prototype.send=function(e){var t=n(e),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(t&&n(this._data))for(var o in e)this._data[o]=e[o];else"string"==typeof e?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+e:e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||r||this.type("json"),this},o.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},o.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var r=this.url.substring(t+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,t)+"?"+r.join("&")}}},o.prototype._appendQueryString=function(){console.trace("Unsupported")},o.prototype._timeoutError=function(e,t,r){if(!this._aborted){var n=new Error(e+t+"ms exceeded");n.timeout=t,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},o.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))}},function(e,t,r){"use strict";var n=r(139);function o(e){if(e)return function(e){for(var t in o.prototype)e[t]=o.prototype[t];return e}(e)}e.exports=o,o.prototype.get=function(e){return this.header[e.toLowerCase()]},o.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"";this.type=n.type(t);var r=n.params(t);for(var o in r)this[o]=r[o];this.links={};try{e.link&&(this.links=n.parseLinks(e.link))}catch(e){}},o.prototype._setStatusProperties=function(e){var t=e/100|0;this.status=this.statusCode=e,this.statusType=t,this.info=1==t,this.ok=2==t,this.redirect=3==t,this.clientError=4==t,this.serverError=5==t,this.error=(4==t||5==t)&&this.toError(),this.created=201==e,this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.forbidden=403==e,this.notFound=404==e,this.unprocessableEntity=422==e}},function(e,t,r){"use strict";t.type=function(e){return e.split(/ *; */).shift()},t.params=function(e){return e.split(/ *; */).reduce((function(e,t){var r=t.split(/ *= */),n=r.shift(),o=r.shift();return n&&o&&(e[n]=o),e}),{})},t.parseLinks=function(e){return e.split(/ *, */).reduce((function(e,t){var r=t.split(/ *; */),n=r[0].slice(1,-1);return e[r[1].split(/ *= */)[1].slice(1,-1)]=n,e}),{})},t.cleanHeader=function(e,t){return delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e}},function(e,t){function r(){this._defaults=[]}["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach((function(e){r.prototype[e]=function(){return this._defaults.push({fn:e,arguments:arguments}),this}})),r.prototype._setDefaults=function(e){this._defaults.forEach((function(t){e[t.fn].apply(e,t.arguments)}))},e.exports=r},function(e,t){e.exports=function(e){var t=new Date(e.getTime()),r=t.getTimezoneOffset();return t.setSeconds(0,0),6e4*r+t.getTime()%6e4}},function(e,t){e.exports=function(){var e={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};return{localize:function(t,r,n){var o;return n=n||{},o="string"==typeof e[t]?e[t]:1===r?e[t].one:e[t].other.replace("{{count}}",r),n.addSuffix?n.comparison>0?"in "+o:o+" ago":o}}}},function(e,t,r){var n=r(144);e.exports=function(){var e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],t=["January","February","March","April","May","June","July","August","September","October","November","December"],r=["Su","Mo","Tu","We","Th","Fr","Sa"],o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],s=["AM","PM"],a=["am","pm"],u=["a.m.","p.m."],c={MMM:function(t){return e[t.getMonth()]},MMMM:function(e){return t[e.getMonth()]},dd:function(e){return r[e.getDay()]},ddd:function(e){return o[e.getDay()]},dddd:function(e){return i[e.getDay()]},A:function(e){return e.getHours()/12>=1?s[1]:s[0]},a:function(e){return e.getHours()/12>=1?a[1]:a[0]},aa:function(e){return e.getHours()/12>=1?u[1]:u[0]}};return["M","D","DDD","d","Q","W"].forEach((function(e){c[e+"o"]=function(t,r){return function(e){var t=e%100;if(t>20||t<10)switch(t%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"}(r[e](t))}})),{formatters:c,formattingTokensRegExp:n(c)}}},function(e,t){var r=["M","MM","Q","D","DD","DDD","DDDD","d","E","W","WW","YY","YYYY","GG","GGGG","H","HH","h","hh","m","mm","s","ss","S","SS","SSS","Z","ZZ","X","x"];e.exports=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);var o=r.concat(t).sort().reverse();return new RegExp("(\\[[^\\[]*\\])|(\\\\)?("+o.join("|")+"|.)","g")}},function(e,t,r){var n=r(1);e.exports=function(e,t,r,o){var i=n(e).getTime(),s=n(t).getTime(),a=n(r).getTime(),u=n(o).getTime();if(i>s||a>u)throw new Error("The start of the range cannot be after the end of the range");return i<u&&a<s}},function(e,t,r){var n=r(1);e.exports=function(e,t){if(!(t instanceof Array))throw new TypeError(toString.call(t)+" is not an instance of Array");var r,o,i=n(e).getTime();return t.forEach((function(e,t){var s=n(e),a=Math.abs(i-s.getTime());(void 0===r||a<o)&&(r=t,o=a)})),r}},function(e,t,r){var n=r(1);e.exports=function(e,t){if(!(t instanceof Array))throw new TypeError(toString.call(t)+" is not an instance of Array");var r,o,i=n(e).getTime();return t.forEach((function(e){var t=n(e),s=Math.abs(i-t.getTime());(void 0===r||s<o)&&(r=t,o=s)})),r}},function(e,t,r){var n=r(12);e.exports=function(e,t){var r=n(e),o=n(t),i=r.getTime()-6e4*r.getTimezoneOffset(),s=o.getTime()-6e4*o.getTimezoneOffset();return Math.round((i-s)/6048e5)}},function(e,t,r){var n=r(76),o=r(1);e.exports=function(e,t){var r=o(e),i=o(t);return 4*(r.getFullYear()-i.getFullYear())+(n(r)-n(i))}},function(e,t,r){var n=r(28);e.exports=function(e,t,r){var o=n(e,r),i=n(t,r),s=o.getTime()-6e4*o.getTimezoneOffset(),a=i.getTime()-6e4*i.getTimezoneOffset();return Math.round((s-a)/6048e5)}},function(e,t,r){var n=r(29);e.exports=function(e,t){var r=n(e,t)/36e5;return r>0?Math.floor(r):Math.ceil(r)}},function(e,t,r){var n=r(1),o=r(75),i=r(21),s=r(79);e.exports=function(e,t){var r=n(e),a=n(t),u=i(r,a),c=Math.abs(o(r,a));return r=s(r,u*c),u*(c-(i(r,a)===-u))}},function(e,t,r){var n=r(29);e.exports=function(e,t){var r=n(e,t)/6e4;return r>0?Math.floor(r):Math.ceil(r)}},function(e,t,r){var n=r(38);e.exports=function(e,t){var r=n(e,t)/3;return r>0?Math.floor(r):Math.ceil(r)}},function(e,t,r){var n=r(78);e.exports=function(e,t){var r=n(e,t)/7;return r>0?Math.floor(r):Math.ceil(r)}},function(e,t,r){var n=r(1),o=r(77),i=r(21);e.exports=function(e,t){var r=n(e),s=n(t),a=i(r,s),u=Math.abs(o(r,s));return r.setFullYear(r.getFullYear()-a*u),a*(u-(i(r,s)===-a))}},function(e,t,r){var n=r(36),o=r(1),i=r(37),s=r(35);e.exports=function(e,t,r){var a=r||{},u=n(e,t),c=a.locale,l=s.distanceInWords.localize;c&&c.distanceInWords&&c.distanceInWords.localize&&(l=c.distanceInWords.localize);var f,p,h,d={addSuffix:Boolean(a.addSuffix),comparison:u};u>0?(f=o(e),p=o(t)):(f=o(t),p=o(e));var m=Math[a.partialMethod?String(a.partialMethod):"floor"],y=i(p,f),g=p.getTimezoneOffset()-f.getTimezoneOffset(),v=m(y/60)-g;if("s"===(h=a.unit?String(a.unit):v<1?"s":v<60?"m":v<1440?"h":v<43200?"d":v<525600?"M":"Y"))return l("xSeconds",y,d);if("m"===h)return l("xMinutes",v,d);if("h"===h)return l("xHours",m(v/60),d);if("d"===h)return l("xDays",m(v/1440),d);if("M"===h)return l("xMonths",m(v/43200),d);if("Y"===h)return l("xYears",m(v/525600),d);throw new Error("Unknown unit: "+h)}},function(e,t,r){var n=r(1);e.exports=function(e,t,r){var o=n(e),i=void 0!==r?r:1,s=n(t).getTime();if(o.getTime()>s)throw new Error("The first date cannot be after the second date");var a=[],u=o;for(u.setHours(0,0,0,0);u.getTime()<=s;)a.push(n(u)),u.setDate(u.getDate()+i);return a}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e);return t.setMinutes(59,59,999),t}},function(e,t,r){var n=r(80);e.exports=function(e){return n(e,{weekStartsOn:1})}},function(e,t,r){var n=r(13),o=r(12);e.exports=function(e){var t=n(e),r=new Date(0);r.setFullYear(t+1,0,4),r.setHours(0,0,0,0);var i=o(r);return i.setMilliseconds(i.getMilliseconds()-1),i}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e);return t.setSeconds(59,999),t}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e),r=t.getMonth(),o=r-r%3+3;return t.setMonth(o,0),t.setHours(23,59,59,999),t}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e);return t.setMilliseconds(999),t}},function(e,t,r){var n=r(41);e.exports=function(){return n(new Date)}},function(e,t){e.exports=function(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n+1),o.setHours(23,59,59,999),o}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e),r=t.getFullYear();return t.setFullYear(r+1,0,0),t.setHours(23,59,59,999),t}},function(e,t){e.exports=function(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n-1),o.setHours(23,59,59,999),o}},function(e,t,r){var n=r(1);e.exports=function(e){return n(e).getDate()}},function(e,t,r){var n=r(1);e.exports=function(e){return n(e).getDay()}},function(e,t,r){var n=r(82);e.exports=function(e){return n(e)?366:365}},function(e,t,r){var n=r(1);e.exports=function(e){return n(e).getHours()}},function(e,t,r){var n=r(20),o=r(40);e.exports=function(e){var t=n(e),r=n(o(t,60)).valueOf()-t.valueOf();return Math.round(r/6048e5)}},function(e,t,r){var n=r(1);e.exports=function(e){return n(e).getMilliseconds()}},function(e,t,r){var n=r(1);e.exports=function(e){return n(e).getMinutes()}},function(e,t,r){var n=r(1);e.exports=function(e){return n(e).getMonth()}},function(e,t,r){var n=r(1);e.exports=function(e,t,r,o){var i=n(e).getTime(),s=n(t).getTime(),a=n(r).getTime(),u=n(o).getTime();if(i>s||a>u)throw new Error("The start of the range cannot be after the end of the range");if(!(i<u&&a<s))return 0;var c=(u>s?s:u)-(a<i?i:a);return Math.ceil(c/864e5)}},function(e,t,r){var n=r(1);e.exports=function(e){return n(e).getSeconds()}},function(e,t,r){var n=r(1);e.exports=function(e){return n(e).getTime()}},function(e,t,r){var n=r(1);e.exports=function(e){return n(e).getFullYear()}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()>o.getTime()}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()<o.getTime()}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(1);e.exports=function(e){return 1===n(e).getDate()}},function(e,t,r){var n=r(1);e.exports=function(e){return 5===n(e).getDay()}},function(e,t,r){var n=r(1);e.exports=function(e){return n(e).getTime()>(new Date).getTime()}},function(e,t,r){var n=r(1),o=r(41),i=r(81);e.exports=function(e){var t=n(e);return o(t).getTime()===i(t).getTime()}},function(e,t,r){var n=r(1);e.exports=function(e){return 1===n(e).getDay()}},function(e,t,r){var n=r(1);e.exports=function(e){return n(e).getTime()<(new Date).getTime()}},function(e,t,r){var n=r(11);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(1);e.exports=function(e){return 6===n(e).getDay()}},function(e,t,r){var n=r(1);e.exports=function(e){return 0===n(e).getDay()}},function(e,t,r){var n=r(84);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(86);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(87);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(88);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(90);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(91);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(93);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(42);e.exports=function(e,t){return n(new Date,e,t)}},function(e,t,r){var n=r(95);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(1);e.exports=function(e){return 4===n(e).getDay()}},function(e,t,r){var n=r(11);e.exports=function(e){return n(e).getTime()===n(new Date).getTime()}},function(e,t,r){var n=r(11);e.exports=function(e){var t=new Date;return t.setDate(t.getDate()+1),n(e).getTime()===n(t).getTime()}},function(e,t,r){var n=r(1);e.exports=function(e){return 2===n(e).getDay()}},function(e,t,r){var n=r(1);e.exports=function(e){return 3===n(e).getDay()}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e).getDay();return 0===t||6===t}},function(e,t,r){var n=r(1);e.exports=function(e,t,r){var o=n(e).getTime(),i=n(t).getTime(),s=n(r).getTime();if(i>s)throw new Error("The start of the range cannot be after the end of the range");return o>=i&&o<=s}},function(e,t,r){var n=r(11);e.exports=function(e){var t=new Date;return t.setDate(t.getDate()-1),n(e).getTime()===n(t).getTime()}},function(e,t,r){var n=r(96);e.exports=function(e){return n(e,{weekStartsOn:1})}},function(e,t,r){var n=r(13),o=r(12);e.exports=function(e){var t=n(e),r=new Date(0);r.setFullYear(t+1,0,4),r.setHours(0,0,0,0);var i=o(r);return i.setDate(i.getDate()-1),i}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e),r=t.getMonth(),o=r-r%3+3;return t.setMonth(o,0),t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e),r=t.getFullYear();return t.setFullYear(r+1,0,0),t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(1);e.exports=function(){var e=Array.prototype.slice.call(arguments),t=e.map((function(e){return n(e)})),r=Math.max.apply(null,t);return new Date(r)}},function(e,t,r){var n=r(1);e.exports=function(){var e=Array.prototype.slice.call(arguments),t=e.map((function(e){return n(e)})),r=Math.min.apply(null,t);return new Date(r)}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setDate(o),r}},function(e,t,r){var n=r(1),o=r(22);e.exports=function(e,t,r){var i=r&&Number(r.weekStartsOn)||0,s=n(e),a=Number(t),u=s.getDay();return o(s,((a%7+7)%7<i?7:0)+a-u)}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setMonth(0),r.setDate(o),r}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setHours(o),r}},function(e,t,r){var n=r(1),o=r(22),i=r(83);e.exports=function(e,t){var r=n(e),s=Number(t),a=i(r);return o(r,s-a)}},function(e,t,r){var n=r(1),o=r(34);e.exports=function(e,t){var r=n(e),i=Number(t),s=o(r)-i;return r.setDate(r.getDate()-7*s),r}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setMilliseconds(o),r}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setMinutes(o),r}},function(e,t,r){var n=r(1),o=r(97);e.exports=function(e,t){var r=n(e),i=Number(t)-(Math.floor(r.getMonth()/3)+1);return o(r,r.getMonth()+3*i)}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setSeconds(o),r}},function(e,t,r){var n=r(1);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setFullYear(o),r}},function(e,t,r){var n=r(1);e.exports=function(e){var t=n(e);return t.setDate(1),t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(11);e.exports=function(){return n(new Date)}},function(e,t){e.exports=function(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n+1),o.setHours(0,0,0,0),o}},function(e,t){e.exports=function(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n-1),o.setHours(0,0,0,0),o}},function(e,t,r){var n=r(22);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(68);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(23);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(71);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(30);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(72);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(73);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(40);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(74);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";(function(t,n){var o=r(24).EventEmitter,i=r(98),s=r(257),a=r(14).Writable,u=r(10),c=r(267),l=r(268),f=r(43),p=r(15)("mqttjs:client"),h=t?t.nextTick:function(e){setTimeout(e,0)},d=n.setImmediate||function(e){h(e)},m={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},y=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],g={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 v(e,t,r){p("sendPacket :: packet: %O",t),p("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),p("sendPacket :: writing to stream");var n=s.writeToStream(t,e.stream,e.options);p("sendPacket :: writeToStream result %s",n),!n&&r?(p("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",r)):r&&(p("sendPacket :: invoking cb"),r())}function b(e){e&&(p("flush: queue exists? %b",!!e),Object.keys(e).forEach((function(t){"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function _(e,t,r,n){p("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd),e.outgoingStore.put(t,(function(o){if(o)return r&&r(o);n(),v(e,t,r)}))}function w(e){p("nop ::",e)}function k(e,t){var r,n=this;if(!(this instanceof k))return new k(e,t);for(r in this.options=t||{},m)void 0===this.options[r]?this.options[r]=m[r]:this.options[r]=t[r];p("MqttClient :: options.protocol",t.protocol),p("MqttClient :: options.protocolVersion",t.protocolVersion),p("MqttClient :: options.username",t.username),p("MqttClient :: options.keepalive",t.keepalive),p("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),p("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),this.options.clientId="string"==typeof t.clientId?t.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),p("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.outgoingStore=t.outgoingStore||new i,this.incomingStore=t.incomingStore||new i,this.queueQoSZero=void 0===t.queueQoSZero||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.nextId=Math.max(1,Math.floor(65535*Math.random())),this.outgoing={},this._firstConnection=!0,this.on("connect",(function(){var e=this.queue;p("connect :: sending queued packets"),function t(){var r,o=e.shift();p("deliver :: entry %o",o),o&&(r=o.packet,p("deliver :: call _sendPacket for %o",r),n._sendPacket(r,(function(e){o.cb&&o.cb(e),t()})))}()})),this.on("close",(function(){p("close :: connected set to `false`"),this.connected=!1,p("close :: clearing connackTimer"),clearTimeout(this.connackTimer),p("close :: clearing ping timer"),null!==n.pingTimer&&(n.pingTimer.clear(),n.pingTimer=null),p("close :: calling _setupReconnect"),this._setupReconnect()})),o.call(this),p("MqttClient :: setting up stream"),this._setupStream()}u(k,o),k.prototype._setupStream=function(){var e,t=this,r=new a,n=s.parser(this.options),o=null,i=[];function u(){if(i.length)h(c);else{var e=o;o=null,e()}}function c(){p("work :: getting next packet in queue");var e=i.shift();if(e)p("work :: packet pulled from queue"),t._handlePacket(e,u);else{p("work :: no packets in queue");var r=o;o=null,p("work :: done flag is %s",!!r),r&&r()}}if(p("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),p("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),n.on("packet",(function(e){p("parser :: on packet push to packets array."),i.push(e)})),r._write=function(e,t,r){o=r,p("writable stream :: parsing buffer"),n.parse(e),c()},p("_setupStream :: pipe stream to writable stream"),this.stream.pipe(r),this.stream.on("error",(function(e){p("streamErrorHandler :: error",e.message),y.includes(e.code)?(p("streamErrorHandler :: emitting error"),t.emit("error",e)):w(e)})),this.stream.on("close",(function(){var e;p("(%s)stream :: on close",t.options.clientId),(e=t.outgoing)&&(p("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(e).forEach((function(t){e[t].volatile&&"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])}))),p("stream: emit close to MqttClient"),t.emit("close")})),p("_setupStream: sending packet `connect`"),(e=Object.create(this.options)).cmd="connect",v(this,e),n.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return t.end(()=>this.emit("error",new Error("Packet has no Authentication Method"))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket)v(this,f({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){p("!!connectTimeout hit!! Calling _cleanUp with force `true`"),t._cleanUp(!0)}),this.options.connectTimeout)},k.prototype._handlePacket=function(e,t){var r=this.options;if(5===r.protocolVersion&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(p("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},k.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},k.prototype.publish=function(e,t,r,n){var o;p("publish :: message `%s` to topic `%s`",t,e);var i=this.options;"function"==typeof r&&(n=r,r=null);if(r=f({qos:0,retain:!1,dup:!1},r),this._checkDisconnecting(n))return this;switch(o={cmd:"publish",topic:e,payload:t,qos:r.qos,retain:r.retain,messageId:this._nextId(),dup:r.dup},5===i.protocolVersion&&(o.properties=r.properties,(!i.properties&&o.properties&&o.properties.topicAlias||r.properties&&i.properties&&(r.properties.topicAlias&&i.properties.topicAliasMaximum&&r.properties.topicAlias>i.properties.topicAliasMaximum||!i.properties.topicAliasMaximum&&r.properties.topicAlias))&&delete o.properties.topicAlias),p("publish :: qos",r.qos),r.qos){case 1:case 2:this.outgoing[o.messageId]={volatile:!1,cb:n||w},this._storeProcessing?(p("_storeProcessing enabled"),this._packetIdsDuringStoreProcessing[o.messageId]=!1,this._storePacket(o,void 0,r.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,void 0,r.cbStorePut));break;default:this._storeProcessing?(p("_storeProcessing enabled"),this._storePacket(o,n,r.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,n,r.cbStorePut))}return this},k.prototype.subscribe=function(){for(var e,t=new Array(arguments.length),r=0;r<arguments.length;r++)t[r]=arguments[r];var n,o=[],i=t.shift(),s=i.resubscribe,a=t.pop()||w,u=t.pop(),c=this,h=this.options.protocolVersion;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof a&&(u=a,a=w),null!==(n=l.validateTopics(i)))return d(a,new Error("Invalid topic "+n)),this;if(this._checkDisconnecting(a))return p("subscribe: discconecting true"),this;var m={qos:0};if(5===h&&(m.nl=!1,m.rap=!1,m.rh=0),u=f(m,u),Array.isArray(i)?i.forEach((function(e){if(p("subscribe: array topic %s",e),!c._resubscribeTopics.hasOwnProperty(e)||c._resubscribeTopics[e].qos<u.qos||s){var t={topic:e,qos:u.qos};5===h&&(t.nl=u.nl,t.rap=u.rap,t.rh=u.rh,t.properties=u.properties),p("subscribe: pushing topic `%s` and qos `%s` to subs list",t.topic,t.qos),o.push(t)}})):Object.keys(i).forEach((function(e){if(p("subscribe: object topic %s",e),!c._resubscribeTopics.hasOwnProperty(e)||c._resubscribeTopics[e].qos<i[e].qos||s){var t={topic:e,qos:i[e].qos};5===h&&(t.nl=i[e].nl,t.rap=i[e].rap,t.rh=i[e].rh,t.properties=u.properties),p("subscribe: pushing `%s` to subs list",t),o.push(t)}})),e={cmd:"subscribe",subscriptions:o,qos:1,retain:!1,dup:!1,messageId:this._nextId()},u.properties&&(e.properties=u.properties),o.length){if(this.options.resubscribe){p("subscribe :: resubscribe true");var y=[];o.forEach((function(e){if(c.options.reconnectPeriod>0){var t={qos:e.qos};5===h&&(t.nl=e.nl||!1,t.rap=e.rap||!1,t.rh=e.rh||0,t.properties=e.properties),c._resubscribeTopics[e.topic]=t,y.push(e.topic)}})),c.messageIdToTopic[e.messageId]=y}return this.outgoing[e.messageId]={volatile:!0,cb:function(e,t){if(!e)for(var r=t.granted,n=0;n<r.length;n+=1)o[n].qos=r[n];a(e,o)}},p("subscribe :: call _sendPacket"),this._sendPacket(e),this}a(null,[])},k.prototype.unsubscribe=function(){for(var e={cmd:"unsubscribe",qos:1,messageId:this._nextId()},t=this,r=new Array(arguments.length),n=0;n<arguments.length;n++)r[n]=arguments[n];var o=r.shift(),i=r.pop()||w,s=r.pop();return"string"==typeof o&&(o=[o]),"function"!=typeof i&&(s=i,i=w),this._checkDisconnecting(i)||("string"==typeof o?e.unsubscriptions=[o]:Array.isArray(o)&&(e.unsubscriptions=o),this.options.resubscribe&&e.unsubscriptions.forEach((function(e){delete t._resubscribeTopics[e]})),"object"==typeof s&&s.properties&&(e.properties=s.properties),this.outgoing[e.messageId]={volatile:!0,cb:i},p("unsubscribe: call _sendPacket"),this._sendPacket(e)),this},k.prototype.end=function(e,t,r){var n=this;function o(){p("end :: closeStores: closing incoming and outgoing stores"),n.disconnected=!0,n.incomingStore.close((function(e){n.outgoingStore.close((function(t){if(p("end :: closeStores: emitting end"),n.emit("end"),r){let n=e||t;p("end :: closeStores: invoking callback with args"),r(n)}}))})),n._deferredReconnect&&n._deferredReconnect()}function i(){p("end :: (%s) :: finish :: calling _cleanUp with force %s",n.options.clientId,e),n._cleanUp(e,()=>{p("end :: finish :: calling process.nextTick on closeStores"),h(o.bind(n))},t)}return p("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(r=t||w,t=e,e=!1,"object"!=typeof t&&(r=t,t=null,"function"!=typeof r&&(r=w))),"object"!=typeof t&&(r=t,t=null),p("end :: cb? %s",!!r),r=r||w,this.disconnecting?(r(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(p("end :: (%s) :: calling finish in 10ms once outgoing is empty",n.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(p("end :: (%s) :: immediately calling finish",n.options.clientId),i()),this)},k.prototype.removeOutgoingMessage=function(e){var 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},k.prototype.reconnect=function(e){p("client reconnect");var t=this,r=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new i,t.outgoingStore=t.options.outgoingStore||new i,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this},k.prototype._reconnect=function(){p("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),p("client already connected. disconnecting first.")):(p("_reconnect: calling _setupStream"),this._setupStream())},k.prototype._setupReconnect=function(){var e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(p("_setupReconnect :: emit `offline` state"),this.emit("offline"),p("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),p("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){p("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):p("_setupReconnect :: doing nothing...")},k.prototype._clearReconnect=function(){p("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},k.prototype._cleanUp=function(e,t){var r=arguments[2];if(t&&(p("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),p("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&b(this.outgoing),p("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{var n=f({cmd:"disconnect"},r);p("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(n,d.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(p("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(p("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(p("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},k.prototype._sendPacket=function(e,t,r){if(p("_sendPacket :: (%s) :: start",this.options.clientId),r=r||w,!this.connected)return p("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,r);switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void _(this,e,t,r);default:return void v(this,e,t)}switch(e.qos){case 2:case 1:_(this,e,t,r);break;case 0:default:v(this,e,t)}p("_sendPacket :: (%s) :: end",this.options.clientId)},k.prototype._storePacket=function(e,t,r){p("_storePacket :: packet: %o",e),p("_storePacket :: cb? %s",!!t),r=r||w,0===(e.qos||0)&&this.queueQoSZero||"publish"!==e.cmd?this.queue.push({packet:e,cb:t}):e.qos>0?(t=this.outgoing[e.messageId]?this.outgoing[e.messageId].cb:null,this.outgoingStore.put(e,(function(e){if(e)return t&&t(e);r()}))):t&&t(new Error("No connection to broker"))},k.prototype._setupPingTimer=function(){p("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);var e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=c((function(){e._checkPing()}),1e3*this.options.keepalive))},k.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},k.prototype._checkPing=function(){p("_checkPing :: checking ping..."),this.pingResp?(p("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(p("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},k.prototype._handlePingresp=function(){this.pingResp=!0},k.prototype._handleConnack=function(e){p("_handleConnack");var t=this.options,r=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),e.properties&&(e.properties.topicAliasMaximum&&(t.properties||(t.properties={}),t.properties.topicAliasMaximum=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)),0===r)this.reconnecting=!1,this._onConnect(e);else if(r>0){var n=new Error("Connection refused: "+g[r]);n.code=r,this.emit("error",n)}},k.prototype._handlePublish=function(e,t){p("_handlePublish: packet %o",e),t=void 0!==t?t:w;var r=e.topic.toString(),n=e.payload,o=e.qos,i=e.messageId,s=this,a=this.options,u=[0,16,128,131,135,144,145,151,153];switch(p("_handlePublish: qos %d",o),o){case 2:a.customHandleAcks(r,n,e,(function(r,n){return r instanceof Error||(n=r,r=null),r?s.emit("error",r):-1===u.indexOf(n)?s.emit("error",new Error("Wrong reason code for pubrec")):void(n?s._sendPacket({cmd:"pubrec",messageId:i,reasonCode:n},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:i},t)})))}));break;case 1:a.customHandleAcks(r,n,e,(function(o,a){return o instanceof Error||(a=o,o=null),o?s.emit("error",o):-1===u.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",r,n,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:i,reasonCode:a},t)})))}));break;case 0:this.emit("message",r,n,e),this.handleMessage(e,t);break;default:p("_handlePublish: unknown QoS. Doing nothing.")}},k.prototype.handleMessage=function(e,t){t()},k.prototype._handleAck=function(e){var t,r=e.messageId,n=e.cmd,o=null,i=this.outgoing[r]?this.outgoing[r].cb:null,s=this;if(i){switch(p("_handleAck :: packet type",n),n){case"pubcomp":case"puback":var a=e.reasonCode;a&&a>0&&16!==a&&((t=new Error("Publish error: "+g[a])).code=a,i(t,e)),delete this.outgoing[r],this.outgoingStore.del(e,i);break;case"pubrec":o={cmd:"pubrel",qos:2,messageId:r};var u=e.reasonCode;u&&u>0&&16!==u?((t=new Error("Publish error: "+g[u])).code=u,i(t,e)):this._sendPacket(o);break;case"suback":delete this.outgoing[r];for(var c=0;c<e.granted.length;c++)if(0!=(128&e.granted[c])){var l=this.messageIdToTopic[r];l&&l.forEach((function(e){delete s._resubscribeTopics[e]}))}i(null,e);break;case"unsuback":delete this.outgoing[r],i(null);break;default:s.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else p("_handleAck :: Server sent an ack in error. Ignoring.")},k.prototype._handlePubrel=function(e,t){p("handling pubrel packet"),t=void 0!==t?t:w;var r=e.messageId,n=this,o={cmd:"pubcomp",messageId:r};n.incomingStore.get(e,(function(e,r){e?n._sendPacket(o,t):(n.emit("message",r.topic,r.payload,r),n.handleMessage(r,(function(e){if(e)return t(e);n.incomingStore.del(r,w),n._sendPacket(o,t)})))}))},k.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},k.prototype._nextId=function(){var e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},k.prototype.getLastMessageId=function(){return 1===this.nextId?65535:this.nextId-1},k.prototype._resubscribe=function(e){p("_resubscribe");var t=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!e.sessionPresent)&&t.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){p("_resubscribe: protocolVersion 5");for(var r=0;r<t.length;r++){var n={};n[t[r]]=this._resubscribeTopics[t[r]],n.resubscribe=!0,this.subscribe(n,{properties:n[t[r]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},k.prototype._onConnect=function(e){if(this.disconnected)this.emit("connect",e);else{var t=this;this._setupPingTimer(),this._resubscribe(e),this.connected=!0,function r(){var n=t.outgoingStore.createStream();function o(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function i(){n.destroy(),n=null,o()}t.once("close",i),n.on("error",(function(e){o(),t.removeListener("close",i),t.emit("error",e)})),n.on("end",(function(){var n=!0;for(var s in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[s]){n=!1;break}n?(o(),t.removeListener("close",i),t.emit("connect",e)):r()})),function e(){if(n){t._storeProcessing=!0;var r,o=n.read(1);o?t._packetIdsDuringStoreProcessing[o.messageId]?e():t.disconnecting||t.reconnectTimer?n.destroy&&n.destroy():(r=t.outgoing[o.messageId]?t.outgoing[o.messageId].cb:null,t.outgoing[o.messageId]={volatile:!1,cb:function(t,n){r&&r(t,n),e()}},t._packetIdsDuringStoreProcessing[o.messageId]=!0,t._sendPacket(o)):n.once("readable",e)}}()}()}},e.exports=k}).call(this,r(8),r(9))},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=c(e),s=n[0],a=n[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),l=0,f=a>0?s-4:s;for(r=0;r<f;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],u[l++]=t>>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,u[l++]=255&t);1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(l(e,s,s+16383>a?a:s+16383));1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var o,i,s=[],a=t;a<r;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,l=-7,f=r?o-1:0,p=r?-1:1,h=e[t+f];for(f+=p,i=h&(1<<-l)-1,h>>=-l,l+=a;l>0;i=256*i+e[t+f],f+=p,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+e[t+f],f+=p,l-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),i-=c}return(h?-1:1)*s*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,l=(1<<c)-1,f=l>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:i-1,d=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+f>=1?p/u:p*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*u-1)*Math.pow(2,o),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;e[r+h]=255&a,h+=d,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[r+h]=255&s,h+=d,s/=256,c-=8);e[r+h-d]|=128*m}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t){},function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var s=r(7).Buffer,a=r(250).inspect,u=a&&a.custom||"inspect";e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}var t,r,c;return t=e,(r=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return s.alloc(0);for(var t,r,n,o=s.allocUnsafe(e>>>0),i=this.head,a=0;i;)t=i.data,r=o,n=a,s.prototype.copy.call(t,r,n),a+=i.data.length,i=i.next;return o}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,n=t.data;for(e-=n.length;t=t.next;){var o=t.data,i=e>o.length?o.length:e;if(i===o.length?n+=o:n+=o.slice(0,e),0==(e-=i)){i===o.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(i));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var o=r.data,i=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,i),0==(e-=i)){i===o.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=o.slice(i));break}++n}return this.length-=n,t}},{key:u,value:function(e,t){return a(this,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},t,{depth:0,customInspect:!1}))}}])&&i(t.prototype,r),c&&i(t,c),e}()},function(e,t){},function(e,t,r){(function(t){function r(e){try{if(!t.localStorage)return!1}catch(e){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,r(9))},function(e,t,r){var n=r(7),o=n.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return o(e,t,r)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=n:(i(n,t),t.Buffer=s),i(o,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=o(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";(function(t){var n;function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=r(44),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),l=Symbol("lastPromise"),f=Symbol("handlePromise"),p=Symbol("stream");function h(e,t){return{value:e,done:t}}function d(e){var t=e[s];if(null!==t){var r=e[p].read();null!==r&&(e[l]=null,e[s]=null,e[a]=null,t(h(r,!1)))}}function m(e){t.nextTick(d,e)}var y=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var e=this,r=this[u];if(null!==r)return Promise.reject(r);if(this[c])return Promise.resolve(h(void 0,!0));if(this[p].destroyed)return new Promise((function(r,n){t.nextTick((function(){e[u]?n(e[u]):r(h(void 0,!0))}))}));var n,o=this[l];if(o)n=new Promise(function(e,t){return function(r,n){e.then((function(){t[c]?r(h(void 0,!0)):t[f](r,n)}),n)}}(o,this));else{var i=this[p].read();if(null!==i)return Promise.resolve(h(i,!1));n=new Promise(this[f])}return this[l]=n,n}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var e=this;return new Promise((function(t,r){e[p].destroy(null,(function(e){e?r(e):t(h(void 0,!0))}))}))})),n),y);e.exports=function(e){var t,r=Object.create(g,(o(t={},p,{value:e,writable:!0}),o(t,s,{value:null,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,u,{value:null,writable:!0}),o(t,c,{value:e._readableState.endEmitted,writable:!0}),o(t,f,{value:function(e,t){var n=r[p].read();n?(r[l]=null,r[s]=null,r[a]=null,e(h(n,!1))):(r[s]=e,r[a]=t)},writable:!0}),t));return r[l]=null,i(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[a];return null!==t&&(r[l]=null,r[s]=null,r[a]=null,t(e)),void(r[u]=e)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[a]=null,n(h(void 0,!0))),r[c]=!0})),e.on("readable",m.bind(null,r)),r}}).call(this,r(8))},function(e,t){e.exports=function(){throw new Error("Readable.from is not available in the browser")}},function(e,t,r){"use strict";e.exports=o;var n=r(105);function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}r(10)(o,n),o.prototype._transform=function(e,t,r){r(null,e)}},function(e,t,r){"use strict";var n;var o=r(17).codes,i=o.ERR_MISSING_ARGS,s=o.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function u(e,t,o,i){i=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(i);var a=!1;e.on("close",(function(){a=!0})),void 0===n&&(n=r(44)),n(e,{readable:t,writable:o},(function(e){if(e)return i(e);a=!0,i()}));var u=!1;return function(t){if(!a&&!u)return u=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void i(t||new s("pipe"))}}function c(e){e()}function l(e,t){return e.pipe(t)}function f(e){return e.length?"function"!=typeof e[e.length-1]?a:e.pop():a}e.exports=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,o=f(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new i("streams");var s=t.map((function(e,r){var i=r<t.length-1;return u(e,i,r>0,(function(e){n||(n=e),e&&s.forEach(c),i||(s.forEach(c),o(n))}))}));return t.reduce(l)}},function(e,t,r){t.parser=r(258).parser,t.generate=r(264),t.writeToStream=r(107)},function(e,t,r){const n=r(259),o=r(24),i=r(261),s=r(106),a=r(15)("mqtt-packet:parser");class u extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof u?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new u).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new i,this.error=null,this._list=n(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=s.types[e>>s.CMD_SHIFT],this.packet.retain=0!=(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(e&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,r,n;a("_parseConnect");const o={},i=this.packet,u=this._parseString();if(null===u)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==u&&"MQIsdp"!==u)return this._emitError(new Error("Invalid protocolId"));if(i.protocolId=u,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.protocolVersion=this._list.readUInt8(this._pos),i.protocolVersion>=128&&(i.bridgeMode=!0,i.protocolVersion=i.protocolVersion-128),3!==i.protocolVersion&&4!==i.protocolVersion&&5!==i.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,o.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,o.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,o.will&&(i.will={},i.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),i.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),i.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,i.keepalive=this._parseNum(),-1===i.keepalive)return this._emitError(new Error("Packet too short"));if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.properties=e)}const c=this._parseString();if(null===c)return this._emitError(new Error("Packet too short"));if(i.clientId=c,a("_parseConnect: packet.clientId: %s",i.clientId),o.will){if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(i.will.topic=e,a("_parseConnect: packet.will.topic: %s",i.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));i.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",i.will.payload)}if(o.username){if(n=this._parseString(),null===n)return this._emitError(new Error("Cannot parse username"));i.username=n,a("_parseConnect: packet.username: %s",i.username)}if(o.password){if(r=this._parseBuffer(),null===r)return this._emitError(new Error("Cannot parse password"));i.password=r}return this.settings=i,a("_parseConnect: complete"),i}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,r,n,o,i,u,c;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));r=this._parseByte(),n=r&s.SUBSCRIBE_OPTIONS_QOS_MASK,u=0!=(r>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(r>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),o=r>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,c={topic:t,qos:n},5===this.settings.protocolVersion?(c.nl=u,c.rap=i,c.rh=o):this.settings.bridgeMode&&(c.rh=0,c.rap=!0,c.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",c),e.subscriptions.push(c)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),r=t+this._pos;if(-1===t||r>this._list.length||r>this.packet.length)return null;const n=this._list.toString("utf8",this._pos,r);return this._pos+=t,a("_parseString: result: %s",n),n}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const r=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",r),r}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");let t,r=0,n=1,o=0,i=!1;const u=this._pos?this._pos:0;for(;r<4&&u+r<this._list.length;){if(t=this._list.readUInt8(u+r++),o+=n*(t&s.VARBYTEINT_MASK),n*=128,0==(t&s.VARBYTEINT_FIN_MASK)){i=!0;break}if(this._list.length<=r)break}return!i&&4===r&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),u&&(this._pos+=r),i=!!i&&(e?{bytes:r,value:o}:o),a("_parseVarByteNum: result: %o",i),i}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){a("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,r={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),!1;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)r[t]?(Array.isArray(r[t])||(r[t]=[r[t]]),r[t].push(this._parseByType(s.propertiesTypes[t]))):r[t]=this._parseByType(s.propertiesTypes[t]);else{r[t]||(r[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(r[t][e.name])if(Array.isArray(r[t][e.name]))r[t][e.name].push(e.value);else{const n=r[t][e.name];r[t][e.name]=[n],r[t][e.name].push(e.value)}else r[t][e.name]=e.value}}return r}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),a("_newPacket: new packet"),this.packet=new i,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}e.exports=u},function(e,t,r){"use strict";const n=r(14).Duplex,o=r(10),i=r(260);function s(e){if(!(this instanceof s))return new s(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)})),e=null}i._init.call(this,e),n.call(this)}o(s,n),Object.assign(s.prototype,i.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,r){this._appendBuffer(e),"function"==typeof r&&r()},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},s.prototype.end=function(e){n.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof i||s.isBufferList(e)},s.isBufferList=i.isBufferList,e.exports=s,e.exports.BufferListStream=s,e.exports.BufferList=i},function(e,t,r){"use strict";const{Buffer:n}=r(7),o=Symbol.for("BufferList");function i(e){if(!(this instanceof i))return new i(e);i._init.call(this,e)}i._init=function(e){Object.defineProperty(this,o,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},i.prototype._new=function(e){return new i(e)},i.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let r=0;r<this._bufs.length;r++){const n=t+this._bufs[r].length;if(e<n||r===this._bufs.length-1)return[r,e-t];t=n}},i.prototype._reverseOffset=function(e){const t=e[0];let r=e[1];for(let e=0;e<t;e++)r+=this._bufs[e].length;return r},i.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},i.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},i.prototype.copy=function(e,t,r,o){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof o||o>this.length)&&(o=this.length),r>=this.length)return e||n.alloc(0);if(o<=0)return e||n.alloc(0);const i=!!e,s=this._offset(r),a=o-r;let u=a,c=i&&t||0,l=s[1];if(0===r&&o===this.length){if(!i)return 1===this._bufs.length?this._bufs[0]:n.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,c),c+=this._bufs[t].length;return e}if(u<=this._bufs[s[0]].length-l)return i?this._bufs[s[0]].copy(e,t,l,l+u):this._bufs[s[0]].slice(l,l+u);i||(e=n.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const r=this._bufs[t].length-l;if(!(u>r)){this._bufs[t].copy(e,c,l,l+u),c+=r;break}this._bufs[t].copy(e,c,l),c+=r,u-=r,l&&(l=0)}return e.length>c?e.slice(0,c):e},i.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const r=this._offset(e),n=this._offset(t),o=this._bufs.slice(r[0],n[0]+1);return 0===n[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,n[1]),0!==r[1]&&(o[0]=o[0].slice(r[1])),this._new(o)},i.prototype.toString=function(e,t,r){return this.slice(t,r).toString(e)},i.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},i.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},i.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(n.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(n.from(e));return this},i.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},i.prototype.indexOf=function(e,t,r){if(void 0===r&&"string"==typeof t&&(r=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=n.from([e]):"string"==typeof e?e=n.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=n.from(e.buffer,e.byteOffset,e.byteLength):n.isBuffer(e)||(e=n.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const o=this._offset(t);let i=o[0],s=o[1];for(;i<this._bufs.length;i++){const t=this._bufs[i];for(;s<t.length;){if(t.length-s>=e.length){const r=t.indexOf(e,s);if(-1!==r)return this._reverseOffset([i,r]);s=t.length-e.length+1}else{const t=this._reverseOffset([i,s]);if(this._match(t,e))return t;s++}}s=0}return-1},i.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let r=0;r<t.length;r++)if(this.get(e+r)!==t[r])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){i.prototype[t]=null===e[t]?function(e,r){return this.slice(e,e+r)[t](0,r)}:function(r=0){return this.slice(r,r+e[t])[t](0)}}(t)}(),i.prototype._isBufferList=function(e){return e instanceof i||i.isBufferList(e)},i.isBufferList=function(e){return null!=e&&e[o]},e.exports=i},function(e,t){e.exports=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}},function(e,t,r){e.exports=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(263),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(r=>{t[r]=e[r]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},function(e,t){var r=1e3,n=6e4,o=60*n,i=24*o;function s(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}e.exports=function(e,t){t=t||{};var a=typeof e;if("string"===a&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var s=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return 6048e5*s;case"days":case"day":case"d":return s*i;case"hours":case"hour":case"hrs":case"hr":case"h":return s*o;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(e);if("number"===a&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=i)return s(e,t,i,"day");if(t>=o)return s(e,t,o,"hour");if(t>=n)return s(e,t,n,"minute");if(t>=r)return s(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=i)return Math.round(e/i)+"d";if(t>=o)return Math.round(e/o)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){(function(t){const n=r(107),o=r(24);class i extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const r=new Array(this._array.length),n=this._array;let o,i=0;for(o=0;o<n.length&&void 0!==n[o];o++)"string"!=typeof n[o]?r[o]=n[o].length:r[o]=t.byteLength(n[o]),e+=r[o];const s=t.allocUnsafe(e);for(o=0;o<n.length&&void 0!==n[o];o++)"string"!=typeof n[o]?(n[o].copy(s,i),i+=r[o]):(s.write(n[o],i),i+=r[o]);return s}}e.exports=function(e,t){const r=new i;return n(e,r,t),r.concat()}}).call(this,r(7).Buffer)},function(e,t,r){(function(t){const r={},n=t.isBuffer(t.from([1,2]).subarray(0,1));function o(e){const r=t.allocUnsafe(2);return r.writeUInt8(e>>8,0),r.writeUInt8(255&e,1),r}e.exports={cache:r,generateCache:function(){for(let e=0;e<65536;e++)r[e]=o(e)},generateNumber:o,genBufVariableByteInt:function(e){let r=0,o=0;const i=t.allocUnsafe(4);do{r=e%128|0,(e=e/128|0)>0&&(r|=128),i.writeUInt8(r,o++)}while(e>0&&o<4);return e>0&&(o=0),n?i.subarray(0,o):i.slice(0,o)},generate4ByteBuffer:function(e){const r=t.allocUnsafe(4);return r.writeUInt32BE(e,0),r}}}).call(this,r(7).Buffer)},function(e,t,r){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,o){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,r)}));case 3:return t.nextTick((function(){e.call(null,r,n)}));case 4:return t.nextTick((function(){e.call(null,r,n,o)}));default:for(i=new Array(a-1),s=0;s<i.length;)i[s++]=arguments[s];return t.nextTick((function(){e.apply(null,i)}))}}}:e.exports=t}).call(this,r(8))},function(e,t,r){"use strict";function n(e,t,r){var n=this;this._callback=e,this._args=r,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=n._interval),n._interval&&clearInterval(n._interval),n._interval=setInterval(n._callback,e,n._args)},this.clear=function(){n._interval&&(clearInterval(n._interval),n._interval=void 0)},this.destroy=function(){n._interval&&clearInterval(n._interval),n._callback=void 0,n._interval=void 0,n._args=void 0}}e.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new n(arguments[0],arguments[1],e)}},function(e,t,r){"use strict";function n(e){for(var t=e.split("/"),r=0;r<t.length;r++)if("+"!==t[r]){if("#"===t[r])return r===t.length-1;if(-1!==t[r].indexOf("+")||-1!==t[r].indexOf("#"))return!1}return!0}e.exports={validateTopics:function(e){if(0===e.length)return"empty_topic_list";for(var t=0;t<e.length;t++)if(!n(e[t]))return e[t];return null}}},function(e,t,r){"use strict";var n=r(270);function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var i=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,a=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(u),l=["%","/","?",";","#"].concat(c),f=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,h=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,d={javascript:!0,"javascript:":!0},m={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=r(272);function v(e,t,r){if(e&&"object"==typeof e&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if("string"!=typeof e)throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o<e.indexOf("#")?"?":"#",u=e.split(s);u[0]=u[0].replace(/\\/g,"/");var v=e=u.join(s);if(v=v.trim(),!r&&1===e.split("#").length){var b=a.exec(v);if(b)return this.path=v,this.href=v,this.pathname=b[1],b[2]?(this.search=b[2],this.query=t?g.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var _=i.exec(v);if(_){var w=(_=_[0]).toLowerCase();this.protocol=w,v=v.substr(_.length)}if(r||_||v.match(/^\/\/[^@/]+@[^@/]+/)){var k="//"===v.substr(0,2);!k||_&&m[_]||(v=v.substr(2),this.slashes=!0)}if(!m[_]&&(k||_&&!y[_])){for(var S,x,E=-1,T=0;T<f.length;T++){-1!==(A=v.indexOf(f[T]))&&(-1===E||A<E)&&(E=A)}-1!==(x=-1===E?v.lastIndexOf("@"):v.lastIndexOf("@",E))&&(S=v.slice(0,x),v=v.slice(x+1),this.auth=decodeURIComponent(S)),E=-1;for(T=0;T<l.length;T++){var A;-1!==(A=v.indexOf(l[T]))&&(-1===E||A<E)&&(E=A)}-1===E&&(E=v.length),this.host=v.slice(0,E),v=v.slice(E),this.parseHost(),this.hostname=this.hostname||"";var I="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!I)for(var C=this.hostname.split(/\./),O=(T=0,C.length);T<O;T++){var R=C[T];if(R&&!R.match(p)){for(var P="",M=0,D=R.length;M<D;M++)R.charCodeAt(M)>127?P+="x":P+=R[M];if(!P.match(p)){var j=C.slice(0,T),L=C.slice(T+1),U=R.match(h);U&&(j.push(U[1]),L.unshift(U[2])),L.length&&(v="/"+L.join(".")+v),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),I||(this.hostname=n.toASCII(this.hostname));var N=this.port?":"+this.port:"",q=this.hostname||"";this.host=q+N,this.href+=this.host,I&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!d[w])for(T=0,O=c.length;T<O;T++){var B=c[T];if(-1!==v.indexOf(B)){var F=encodeURIComponent(B);F===B&&(F=escape(B)),v=v.split(B).join(F)}}var H=v.indexOf("#");-1!==H&&(this.hash=v.substr(H),v=v.slice(0,H));var Y=v.indexOf("?");if(-1!==Y?(this.search=v.substr(Y),this.query=v.substr(Y+1),t&&(this.query=g.parse(this.query)),v=v.slice(0,Y)):t&&(this.search="",this.query={}),v&&(this.pathname=v),y[w]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){N=this.pathname||"";var W=this.search||"";this.path=N+W}return this.href=this.format(),this},o.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",r=this.pathname||"",n=this.hash||"",o=!1,i="";this.host?o=e+this.host:this.hostname&&(o=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&"object"==typeof this.query&&Object.keys(this.query).length&&(i=g.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var s=this.search||i&&"?"+i||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||y[t])&&!1!==o?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),n&&"#"!==n.charAt(0)&&(n="#"+n),s&&"?"!==s.charAt(0)&&(s="?"+s),t+o+(r=r.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(s=s.replace("#","%23"))+n},o.prototype.resolve=function(e){return this.resolveObject(v(e,!1,!0)).format()},o.prototype.resolveObject=function(e){if("string"==typeof e){var t=new o;t.parse(e,!1,!0),e=t}for(var r=new o,n=Object.keys(this),i=0;i<n.length;i++){var s=n[i];r[s]=this[s]}if(r.hash=e.hash,""===e.href)return r.href=r.format(),r;if(e.slashes&&!e.protocol){for(var a=Object.keys(e),u=0;u<a.length;u++){var c=a[u];"protocol"!==c&&(r[c]=e[c])}return y[r.protocol]&&r.hostname&&!r.pathname&&(r.pathname="/",r.path=r.pathname),r.href=r.format(),r}if(e.protocol&&e.protocol!==r.protocol){if(!y[e.protocol]){for(var l=Object.keys(e),f=0;f<l.length;f++){var p=l[f];r[p]=e[p]}return r.href=r.format(),r}if(r.protocol=e.protocol,e.host||m[e.protocol])r.pathname=e.pathname;else{for(var h=(e.pathname||"").split("/");h.length&&!(e.host=h.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==h[0]&&h.unshift(""),h.length<2&&h.unshift(""),r.pathname=h.join("/")}if(r.search=e.search,r.query=e.query,r.host=e.host||"",r.auth=e.auth,r.hostname=e.hostname||e.host,r.port=e.port,r.pathname||r.search){var d=r.pathname||"",g=r.search||"";r.path=d+g}return r.slashes=r.slashes||e.slashes,r.href=r.format(),r}var v=r.pathname&&"/"===r.pathname.charAt(0),b=e.host||e.pathname&&"/"===e.pathname.charAt(0),_=b||v||r.host&&e.pathname,w=_,k=r.pathname&&r.pathname.split("/")||[],S=(h=e.pathname&&e.pathname.split("/")||[],r.protocol&&!y[r.protocol]);if(S&&(r.hostname="",r.port=null,r.host&&(""===k[0]?k[0]=r.host:k.unshift(r.host)),r.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===h[0]?h[0]=e.host:h.unshift(e.host)),e.host=null),_=_&&(""===h[0]||""===k[0])),b)r.host=e.host||""===e.host?e.host:r.host,r.hostname=e.hostname||""===e.hostname?e.hostname:r.hostname,r.search=e.search,r.query=e.query,k=h;else if(h.length)k||(k=[]),k.pop(),k=k.concat(h),r.search=e.search,r.query=e.query;else if(null!=e.search){if(S)r.host=k.shift(),r.hostname=r.host,(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.hostname=I.shift(),r.host=r.hostname);return r.search=e.search,r.query=e.query,null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!k.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var x=k.slice(-1)[0],E=(r.host||e.host||k.length>1)&&("."===x||".."===x)||""===x,T=0,A=k.length;A>=0;A--)"."===(x=k[A])?k.splice(A,1):".."===x?(k.splice(A,1),T++):T&&(k.splice(A,1),T--);if(!_&&!w)for(;T--;T)k.unshift("..");!_||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),E&&"/"!==k.join("/").substr(-1)&&k.push("");var I,C=""===k[0]||k[0]&&"/"===k[0].charAt(0);S&&(r.hostname=C?"":k.length?k.shift():"",r.host=r.hostname,(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.hostname=I.shift(),r.host=r.hostname));return(_=_||r.host&&k.length)&&!C&&k.unshift(""),k.length>0?r.pathname=k.join("/"):(r.pathname=null,r.path=null),null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)},t.parse=v,t.resolve=function(e,t){return v(e,!1,!0).resolve(t)},t.resolveObject=function(e,t){return e?v(e,!1,!0).resolveObject(t):t},t.format=function(e){return"string"==typeof e&&(e=v(e)),e instanceof o?e.format():o.prototype.format.call(e)},t.Url=o},function(e,t,r){(function(e,n){var o;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(i){t&&t.nodeType,e&&e.nodeType;var s="object"==typeof n&&n;s.global!==s&&s.window!==s&&s.self;var a,u=2147483647,c=/^xn--/,l=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,p={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},h=Math.floor,d=String.fromCharCode;function m(e){throw new RangeError(p[e])}function y(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function g(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+y((e=e.replace(f,".")).split("."),t).join(".")}function v(e){for(var t,r,n=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(r=e.charCodeAt(o++)))?n.push(((1023&t)<<10)+(1023&r)+65536):(n.push(t),o--):n.push(t);return n}function b(e){return y(e,(function(e){var t="";return e>65535&&(t+=d((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=d(e)})).join("")}function _(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function w(e,t,r){var n=0;for(e=r?h(e/700):e>>1,e+=h(e/t);e>455;n+=36)e=h(e/35);return h(n+36*e/(e+38))}function k(e){var t,r,n,o,i,s,a,c,l,f,p,d=[],y=e.length,g=0,v=128,_=72;for((r=e.lastIndexOf("-"))<0&&(r=0),n=0;n<r;++n)e.charCodeAt(n)>=128&&m("not-basic"),d.push(e.charCodeAt(n));for(o=r>0?r+1:0;o<y;){for(i=g,s=1,a=36;o>=y&&m("invalid-input"),((c=(p=e.charCodeAt(o++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:36)>=36||c>h((u-g)/s))&&m("overflow"),g+=c*s,!(c<(l=a<=_?1:a>=_+26?26:a-_));a+=36)s>h(u/(f=36-l))&&m("overflow"),s*=f;_=w(g-i,t=d.length+1,0==i),h(g/t)>u-v&&m("overflow"),v+=h(g/t),g%=t,d.splice(g++,0,v)}return b(d)}function S(e){var t,r,n,o,i,s,a,c,l,f,p,y,g,b,k,S=[];for(y=(e=v(e)).length,t=128,r=0,i=72,s=0;s<y;++s)(p=e[s])<128&&S.push(d(p));for(n=o=S.length,o&&S.push("-");n<y;){for(a=u,s=0;s<y;++s)(p=e[s])>=t&&p<a&&(a=p);for(a-t>h((u-r)/(g=n+1))&&m("overflow"),r+=(a-t)*g,t=a,s=0;s<y;++s)if((p=e[s])<t&&++r>u&&m("overflow"),p==t){for(c=r,l=36;!(c<(f=l<=i?1:l>=i+26?26:l-i));l+=36)k=c-f,b=36-f,S.push(d(_(f+k%b,0))),c=h(k/b);S.push(d(_(c,0))),i=w(r,g,n==o),r=0,++n}++r,++t}return S.join("")}a={version:"1.4.1",ucs2:{decode:v,encode:b},decode:k,encode:S,toASCII:function(e){return g(e,(function(e){return l.test(e)?"xn--"+S(e):e}))},toUnicode:function(e){return g(e,(function(e){return c.test(e)?k(e.slice(4).toLowerCase()):e}))}},void 0===(o=function(){return a}.call(t,r,t,e))||(e.exports=o)}()}).call(this,r(271)(e),r(9))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,r){"use strict";var n=r(273),o=r(301),i=r(47);e.exports={formats:i,parse:o,stringify:n}},function(e,t,r){"use strict";var n=r(108),o=r(117),i=r(47),s=Object.prototype.hasOwnProperty,a={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},u=Array.isArray,c=Array.prototype.push,l=function(e,t){c.apply(e,u(t)?t:[t])},f=Date.prototype.toISOString,p=i.default,h={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:o.encode,encodeValuesOnly:!1,filter:void 0,format:p,formatter:i.formatters[p],indices:!1,serializeDate:function(e){return f.call(e)},skipNulls:!1,strictNullHandling:!1},d={},m=function e(t,r,i,s,a,c,f,p,m,y,g,v,b,_,w,k,S,x){for(var E,T=t,A=x,I=0,C=!1;void 0!==(A=A.get(d))&&!C;){var O=A.get(t);if(I+=1,void 0!==O){if(O===I)throw new RangeError("Cyclic object value");C=!0}void 0===A.get(d)&&(I=0)}if("function"==typeof y?T=y(r,T):T instanceof Date?T=b(T):"comma"===i&&u(T)&&(T=o.maybeMap(T,(function(e){return e instanceof Date?b(e):e}))),null===T){if(c)return m&&!k?m(r,h.encoder,S,"key",_):r;T=""}if("string"==typeof(E=T)||"number"==typeof E||"boolean"==typeof E||"symbol"==typeof E||"bigint"==typeof E||o.isBuffer(T))return m?[w(k?r:m(r,h.encoder,S,"key",_))+"="+w(m(T,h.encoder,S,"value",_))]:[w(r)+"="+w(String(T))];var R,P=[];if(void 0===T)return P;if("comma"===i&&u(T))k&&m&&(T=o.maybeMap(T,m)),R=[{value:T.length>0?T.join(",")||null:void 0}];else if(u(y))R=y;else{var M=Object.keys(T);R=g?M.sort(g):M}var D=p?String(r).replace(/\./g,"%2E"):String(r),j=s&&u(T)&&1===T.length?D+"[]":D;if(a&&u(T)&&0===T.length)return j+"[]";for(var L=0;L<R.length;++L){var U=R[L],N="object"==typeof U&&U&&void 0!==U.value?U.value:T[U];if(!f||null!==N){var q=v&&p?String(U).replace(/\./g,"%2E"):String(U),B=u(T)?"function"==typeof i?i(j,q):j:j+(v?"."+q:"["+q+"]");x.set(t,I);var F=n();F.set(d,x),l(P,e(N,B,i,s,a,c,f,p,"comma"===i&&k&&u(T)?null:m,y,g,v,b,_,w,k,S,F))}}return P};e.exports=function(e,t){var r,o=e,c=function(e){if(!e)return h;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||h.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=i.default;if(void 0!==e.format){if(!s.call(i.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n,o=i.formatters[r],c=h.filter;if(("function"==typeof e.filter||u(e.filter))&&(c=e.filter),n=e.arrayFormat in a?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":h.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var l=void 0===e.allowDots?!0===e.encodeDotInKeys||h.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:h.addQueryPrefix,allowDots:l,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:h.allowEmptyArrays,arrayFormat:n,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:h.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?h.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:h.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:h.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:h.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:h.encodeValuesOnly,filter:c,format:r,formatter:o,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:h.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:h.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:h.strictNullHandling}}(t);"function"==typeof c.filter?o=(0,c.filter)("",o):u(c.filter)&&(r=c.filter);var f=[];if("object"!=typeof o||null===o)return"";var p=a[c.arrayFormat],d="comma"===p&&c.commaRoundTrip;r||(r=Object.keys(o)),c.sort&&r.sort(c.sort);for(var y=n(),g=0;g<r.length;++g){var v=r[g],b=o[v];c.skipNulls&&null===b||l(f,m(b,v,p,d,c.allowEmptyArrays,c.strictNullHandling,c.skipNulls,c.encodeDotInKeys,c.encode?c.encoder:null,c.filter,c.sort,c.allowDots,c.serializeDate,c.format,c.formatter,c.encodeValuesOnly,c.charset,y))}var _=f.join(c.delimiter),w=!0===c.addQueryPrefix?"?":"";return c.charsetSentinel&&("iso-8859-1"===c.charset?w+="utf8=%26%2310003%3B&":w+="utf8=%E2%9C%93&"),_.length>0?w+_:""}},function(e,t){},function(e,t,r){"use strict";var n=r(31),o=r(19),i=function(e,t,r){for(var n,o=e;null!=(n=o.next);o=n)if(n.key===t)return o.next=n.next,r||(n.next=e.next,e.next=n),n};e.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new o("Side channel does not contain "+n(e))},delete:function(t){var r=e&&e.next,n=function(e,t){if(e)return i(e,t,!0)}(e,t);return n&&r&&r===n&&(e=void 0),!!n},get:function(t){return function(e,t){if(e){var r=i(e,t);return r&&r.value}}(e,t)},has:function(t){return function(e,t){return!!e&&!!i(e,t)}(e,t)},set:function(t,r){e||(e={next:void 0}),function(e,t,r){var n=i(e,t);n?n.value=r:e.next={key:t,next:e.next,value:r}}(e,t,r)}};return t}},function(e,t,r){"use strict";e.exports=Error},function(e,t,r){"use strict";e.exports=EvalError},function(e,t,r){"use strict";e.exports=RangeError},function(e,t,r){"use strict";e.exports=ReferenceError},function(e,t,r){"use strict";e.exports=SyntaxError},function(e,t,r){"use strict";e.exports=URIError},function(e,t,r){"use strict";e.exports=Math.abs},function(e,t,r){"use strict";e.exports=Math.floor},function(e,t,r){"use strict";e.exports=Math.max},function(e,t,r){"use strict";e.exports=Math.min},function(e,t,r){"use strict";e.exports=Math.pow},function(e,t,r){"use strict";e.exports=Math.round},function(e,t,r){"use strict";var n=r(289);e.exports=function(e){return n(e)||0===e?e:e<0?-1:1}},function(e,t,r){"use strict";e.exports=Number.isNaN||function(e){return e!=e}},function(e,t,r){"use strict";e.exports=Object.getOwnPropertyDescriptor},function(e,t,r){"use strict";var n=Object.defineProperty||!1;if(n)try{n({},"a",{value:1})}catch(e){n=!1}e.exports=n},function(e,t,r){"use strict";var n="undefined"!=typeof Symbol&&Symbol,o=r(293);e.exports=function(){return"function"==typeof n&&("function"==typeof Symbol&&("symbol"==typeof n("foo")&&("symbol"==typeof Symbol("bar")&&o())))}},function(e,t,r){"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var o=Object.getOwnPropertySymbols(e);if(1!==o.length||o[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},function(e,t,r){"use strict";var n=r(112),o=r(113),i=r(295);e.exports=n?function(e){return n(e)}:o?function(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("getProto: not an object");return o(e)}:i?function(e){return i(e)}:null},function(e,t,r){"use strict";var n,o=r(114),i=r(111);try{n=[].__proto__===Array.prototype}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"ERR_PROTO_ACCESS"!==e.code)throw e}var s=!!n&&i&&i(Object.prototype,"__proto__"),a=Object,u=a.getPrototypeOf;e.exports=s&&"function"==typeof s.get?o([s.get]):"function"==typeof u&&function(e){return u(null==e?e:a(e))}},function(e,t,r){"use strict";var n="Function.prototype.bind called on incompatible ",o=Object.prototype.toString,i=Math.max,s=function(e,t){for(var r=[],n=0;n<e.length;n+=1)r[n]=e[n];for(var o=0;o<t.length;o+=1)r[o+e.length]=t[o];return r},a=function(e,t){for(var r=[],n=t||0,o=0;n<e.length;n+=1,o+=1)r[o]=e[n];return r},u=function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r};e.exports=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==o.apply(t))throw new TypeError(n+t);for(var r,c=a(arguments,1),l=function(){if(this instanceof r){var n=t.apply(this,s(c,arguments));return Object(n)===n?n:this}return t.apply(e,s(c,arguments))},f=i(0,t.length-c.length),p=[],h=0;h<f;h++)p[h]="$"+h;if(r=Function("binder","return function ("+u(p,",")+"){ return binder.apply(this,arguments); }")(l),t.prototype){var d=function(){};d.prototype=t.prototype,r.prototype=new d,d.prototype=null}return r}},function(e,t,r){"use strict";var n=r(32),o=r(115),i=r(46),s=r(298);e.exports=s||n.call(i,o)},function(e,t,r){"use strict";e.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},function(e,t,r){"use strict";var n=Function.prototype.call,o=Object.prototype.hasOwnProperty,i=r(32);e.exports=i.call(n,o)},function(e,t,r){"use strict";var n=r(45),o=r(116),i=r(31),s=r(109),a=r(19),u=n("%WeakMap%",!0),c=o("WeakMap.prototype.get",!0),l=o("WeakMap.prototype.set",!0),f=o("WeakMap.prototype.has",!0),p=o("WeakMap.prototype.delete",!0);e.exports=u?function(){var e,t,r={assert:function(e){if(!r.has(e))throw new a("Side channel does not contain "+i(e))},delete:function(r){if(u&&r&&("object"==typeof r||"function"==typeof r)){if(e)return p(e,r)}else if(s&&t)return t.delete(r);return!1},get:function(r){return u&&r&&("object"==typeof r||"function"==typeof r)&&e?c(e,r):t&&t.get(r)},has:function(r){return u&&r&&("object"==typeof r||"function"==typeof r)&&e?f(e,r):!!t&&t.has(r)},set:function(r,n){u&&r&&("object"==typeof r||"function"==typeof r)?(e||(e=new u),l(e,r,n)):s&&(t||(t=s()),t.set(r,n))}};return r}:s},function(e,t,r){"use strict";var n=r(117),o=Object.prototype.hasOwnProperty,i=Array.isArray,s={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:n.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictMerge:!0,strictNullHandling:!1,throwOnLimitExceeded:!1},a=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},u=function(e,t,r){if(e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1)return e.split(",");if(t.throwOnLimitExceeded&&r>=t.arrayLimit)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(1===t.arrayLimit?"":"s")+" allowed in an array.");return e},c=function(e,t,r,i){if(e){var s=function(e,t){var r=t.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e;if(t.depth<=0){if(!t.plainObjects&&o.call(Object.prototype,r)&&!t.allowPrototypes)return;return[r]}var n=/(\[[^[\]]*])/g,i=/(\[[^[\]]*])/.exec(r),s=i?r.slice(0,i.index):r,a=[];if(s){if(!t.plainObjects&&o.call(Object.prototype,s)&&!t.allowPrototypes)return;a[a.length]=s}for(var u=0;null!==(i=n.exec(r))&&u<t.depth;){u+=1;var c=i[1].slice(1,-1);if(!t.plainObjects&&o.call(Object.prototype,c)&&!t.allowPrototypes)return;a[a.length]=i[1]}if(i){if(!0===t.strictDepth)throw new RangeError("Input depth exceeded depth option of "+t.depth+" and strictDepth is true");a[a.length]="["+r.slice(i.index)+"]"}return a}(e,r);if(s)return function(e,t,r,o){var i=0;if(e.length>0&&"[]"===e[e.length-1]){var s=e.slice(0,-1).join("");i=Array.isArray(t)&&t[s]?t[s].length:0}for(var a=o?t:u(t,r,i),c=e.length-1;c>=0;--c){var l,f=e[c];if("[]"===f&&r.parseArrays)l=n.isOverflow(a)?a:r.allowEmptyArrays&&(""===a||r.strictNullHandling&&null===a)?[]:n.combine([],a,r.arrayLimit,r.plainObjects);else{l=r.plainObjects?{__proto__:null}:{};var p="["===f.charAt(0)&&"]"===f.charAt(f.length-1)?f.slice(1,-1):f,h=r.decodeDotInKeys?p.replace(/%2E/g,"."):p,d=parseInt(h,10),m=!isNaN(d)&&f!==h&&String(d)===h&&d>=0&&r.parseArrays;if(r.parseArrays||""!==h)if(m&&d<r.arrayLimit)(l=[])[d]=a;else{if(m&&r.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+r.arrayLimit+" element"+(1===r.arrayLimit?"":"s")+" allowed in an array.");m?(l[d]=a,n.markOverflow(l,d)):"__proto__"!==h&&(l[h]=a)}else l={0:a}}a=l}return a}(s,t,r,i)}};e.exports=function(e,t){var r=function(e){if(!e)return s;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.decodeDotInKeys&&"boolean"!=typeof e.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0!==e.throwOnLimitExceeded&&"boolean"!=typeof e.throwOnLimitExceeded)throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var t=void 0===e.charset?s.charset:e.charset,r=void 0===e.duplicates?s.duplicates:e.duplicates;if("combine"!==r&&"first"!==r&&"last"!==r)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===e.allowDots?!0===e.decodeDotInKeys||s.allowDots:!!e.allowDots,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:s.allowEmptyArrays,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:s.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:s.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:s.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:s.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:s.comma,decodeDotInKeys:"boolean"==typeof e.decodeDotInKeys?e.decodeDotInKeys:s.decodeDotInKeys,decoder:"function"==typeof e.decoder?e.decoder:s.decoder,delimiter:"string"==typeof e.delimiter||n.isRegExp(e.delimiter)?e.delimiter:s.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:s.depth,duplicates:r,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:s.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:s.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:s.plainObjects,strictDepth:"boolean"==typeof e.strictDepth?!!e.strictDepth:s.strictDepth,strictMerge:"boolean"==typeof e.strictMerge?!!e.strictMerge:s.strictMerge,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:s.strictNullHandling,throwOnLimitExceeded:"boolean"==typeof e.throwOnLimitExceeded&&e.throwOnLimitExceeded}}(t);if(""===e||null==e)return r.plainObjects?{__proto__:null}:{};for(var l="string"==typeof e?function(e,t){var r={__proto__:null},c=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;c=c.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var l=t.parameterLimit===1/0?void 0:t.parameterLimit,f=c.split(t.delimiter,t.throwOnLimitExceeded?l+1:l);if(t.throwOnLimitExceeded&&f.length>l)throw new RangeError("Parameter limit exceeded. Only "+l+" parameter"+(1===l?"":"s")+" allowed.");var p,h=-1,d=t.charset;if(t.charsetSentinel)for(p=0;p<f.length;++p)0===f[p].indexOf("utf8=")&&("utf8=%E2%9C%93"===f[p]?d="utf-8":"utf8=%26%2310003%3B"===f[p]&&(d="iso-8859-1"),h=p,p=f.length);for(p=0;p<f.length;++p)if(p!==h){var m,y,g=f[p],v=g.indexOf("]="),b=-1===v?g.indexOf("="):v+1;if(-1===b?(m=t.decoder(g,s.decoder,d,"key"),y=t.strictNullHandling?null:""):null!==(m=t.decoder(g.slice(0,b),s.decoder,d,"key"))&&(y=n.maybeMap(u(g.slice(b+1),t,i(r[m])?r[m].length:0),(function(e){return t.decoder(e,s.decoder,d,"value")}))),y&&t.interpretNumericEntities&&"iso-8859-1"===d&&(y=a(String(y))),g.indexOf("[]=")>-1&&(y=i(y)?[y]:y),t.comma&&i(y)&&y.length>t.arrayLimit){if(t.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(1===t.arrayLimit?"":"s")+" allowed in an array.");y=n.combine([],y,t.arrayLimit,t.plainObjects)}if(null!==m){var _=o.call(r,m);_&&("combine"===t.duplicates||g.indexOf("[]=")>-1)?r[m]=n.combine(r[m],y,t.arrayLimit,t.plainObjects):_&&"last"!==t.duplicates||(r[m]=y)}}return r}(e,r):e,f=r.plainObjects?{__proto__:null}:{},p=Object.keys(l),h=0;h<p.length;++h){var d=p[h],m=c(d,l[d],r,"string"==typeof e);f=n.merge(f,m,r)}return!0===r.allowSparse?f:n.compact(f)}},function(e,t){},function(e,t){},function(e,t,r){(function(t){var n=r(305),o=function(){},i=function(e,r,s){if("function"==typeof r)return i(e,null,r);r||(r={}),s=n(s||o);var a=e._writableState,u=e._readableState,c=r.readable||!1!==r.readable&&e.readable,l=r.writable||!1!==r.writable&&e.writable,f=!1,p=function(){e.writable||h()},h=function(){l=!1,c||s.call(e)},d=function(){c=!1,l||s.call(e)},m=function(t){s.call(e,t?new Error("exited with error code: "+t):null)},y=function(t){s.call(e,t)},g=function(){t.nextTick(v)},v=function(){if(!f)return(!c||u&&u.ended&&!u.destroyed)&&(!l||a&&a.ended&&!a.destroyed)?void 0:s.call(e,new Error("premature close"))},b=function(){e.req.on("finish",h)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?l&&!a&&(e.on("end",p),e.on("close",p)):(e.on("complete",h),e.on("abort",g),e.req?b():e.on("request",b)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",m),e.on("end",d),e.on("finish",h),!1!==r.error&&e.on("error",y),e.on("close",g),function(){f=!0,e.removeListener("complete",h),e.removeListener("abort",g),e.removeListener("request",b),e.req&&e.req.removeListener("finish",h),e.removeListener("end",p),e.removeListener("close",p),e.removeListener("finish",h),e.removeListener("exit",m),e.removeListener("end",d),e.removeListener("error",y),e.removeListener("close",g)}};e.exports=i}).call(this,r(8))},function(e,t,r){var n=r(306);function o(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function i(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}e.exports=n(o),e.exports.strict=n(i),o.proto=o((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return o(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return i(this)},configurable:!0})}))},function(e,t){e.exports=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){n[e]=t[e]})),n;function n(){for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var n=t.apply(this,e),o=e[e.length-1];return"function"==typeof n&&n!==o&&Object.keys(o).forEach((function(e){n[e]=o[e]})),n}}},function(e,t){e.exports=function(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(function(e){if(e.buffer.length)return e.buffer.head?e.buffer.head.data.length:e.buffer[0].length;return e.length}(t)):null}},function(e,t,r){"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},function(e,t,r){"use strict";r.r(t);var n=r(16),o=r.n(n),i=r(2),s=r.n(i),a=r(4),u=r.n(a),c=r(5),l=r.n(c),f=r(3),p=r.n(f),h=r(0),d=r.n(h),m=r(6),y=r.n(m);var g=function(e){return e=e||Object.create(null),{on:function(t,r){(e[t]||(e[t]=[])).push(r)},off:function(t,r){e[t]&&e[t].splice(e[t].indexOf(r)>>>0,1)},emit:function(t,r){(e[t]||[]).slice().map((function(e){e(r)})),(e["*"]||[]).slice().map((function(e){e(t,r)}))}}},v=Object.prototype.toString,b={};b.array=Array.isArray,b.undefined=function(e){return void 0===e},b.string=function(e){return"[object String]"===v.call(e)},b.object=function(e){return Object(e)===e},b.function=function(e){return"[object Function]"===v.call(e)||"function"==typeof e},b.json=function(e){return"[object Object]"===v.call(e)},b.not={array:function(e){return!b.array(e)},string:function(e){return!b.string(e)},object:function(e){return!b.object(e)},function:function(e){return!b.function(e)},json:function(e){return!b.json(e)}};var _=b,w=r(50),k=r.n(w),S=r(51),x=r.n(S),E=r(52);function T(e){return e.replace(/<[^>]*\/?>([\s\S]*)?<\/.*?>/gi,(function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}))}var A=function(){return l()((function e(t){u()(this,e),this.roomAdapter=t,this.name=null,this.emails=[],this.options={}}),[{key:"withName",value:function(e){return this.name=e,this}},{key:"withOptions",value:function(e){return this.options=e,this}},{key:"addParticipants",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return this.emails=(e=this.emails.filter((function(e){return-1===r.indexOf(e)}))).concat.apply(e,r),this}},{key:"create",value:function(){var e=this.name,t=this.emails,r=this.options;return this.roomAdapter.createRoom(e,t,{avatarURL:r.avatarURL},r)}}])}();var I=function(){return l()((function e(t){u()(this,e),this.id=t.id,this.before_id=t.comment_before_id,this.message=T(t.message),this.username_as=t.username_as||t.username,this.username_real=t.username_real||t.email,this.email=this.username_real,this.user_extras=t.user_extras,this.date=Object(E.format)(t.timestamp,"YYYY-MM-DD"),this.time=Object(E.format)(t.timestamp,"HH:mm"),this.timestamp=t.timestamp,this.unique_id=t.unique_temp_id||t.unique_id,this.unique_temp_id=t.unique_temp_id||t.unique_id,this.avatar=t.user_avatar_url,this.room_id=t.room_id,this.isChannel=t.is_public_channel,this.unix_timestamp=t.unix_timestamp,this.unix_nano_timestamp=t.unix_nano_timestamp,this.extras=t.extras,this.is_deleted=t.is_deleted,this.isPending=!1,this.isFailed=!1,this.isDelivered=!1,this.isRead=!1,this.isSent=!1,this.attachment=null,this.payload=t.payload,this.status=t.status,"reply"===t.type&&(t.payload.replied_comment_message=T(t.payload.replied_comment_message),t.payload.text=T(t.payload.text)),this.type=t.type,this.subtype="custom"===t.type?t.payload.type:null,"sent"===t.status?this.markAsSent():"delivered"===t.status?this.markAsDelivered():"read"===t.status&&this.markAsRead()}),[{key:"isAttachment",value:function(e){return"[file]"===e.substring(0,"[file]".length)}},{key:"isImageAttachment",value:function(e){return this.isAttachment(e)&&null!=e.match(/\.(jpg|jpeg|gif|png)/i)}},{key:"attachUniqueId",value:function(e){this.unique_id=e}},{key:"getAttachmentURI",value:function(e){if(this.isAttachment(e)){var t=e.length,r="[file]".length,n=t-"[/file]".length;return e.substring(r,n).trim()}}},{key:"setAttachment",value:function(e){this.attachment=e}},{key:"markAsPending",value:function(){this.isPending=!0,this.isDelivered=!1,this.status="pending"}},{key:"markAsSent",value:function(){this.isSent=!0,this.isPending=!1,this.isFailed=!1,this.status="sent"}},{key:"markAsDelivered",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.actor,r=e.activeActorId;t!==r&&(this.isRead||"read"===this.status||(this.isSent=!0,this.isRead=!1,this.isDelivered=!0,this.status="delivered"))}},{key:"markAsRead",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.actor,r=e.activeActorId;t!==r&&(this.isPending=!1,this.isSent=!0,this.isDelivered=!0,this.isRead=!0,this.status="read")}},{key:"markAsFailed",value:function(){this.isFailed=!0,this.isPending=!1,this.isStatus="failed"}},{key:"update",value:function(e){this.id=e.id,this.before_id=e.comment_before_id,this.message=T(e.message),e.payload&&(this.payload=e.payload),e.status&&(this.status=e.status),"reply"===e.type&&(this.payload.replied_comment_message=T(e.payload.replied_comment_message),this.payload.text=T(e.payload.text)),"sent"===e.status?this.markAsSent():"delivered"===e.status?this.markAsDelivered():"read"===e.status&&this.markAsRead()}}])}(),C=function(){return l()((function e(t){u()(this,e),this.id=t.id,this.last_comment_id=t.last_comment_id,this.last_comment_message=t.last_comment_message,this.last_comment_message_created_at=t.last_comment_message_created_at,this.last_comment_topic_title=t.last_comment_topic_title,this.avatar=t.room_avatar||t.avatarURL||t.avatar_url,this.name=t.room_name,this.room_type=t.room_type||t.chat_type,this.secret_code=t.secret_code,this.participants=t.participants,this.options=t.options,this.topics=[],this.last_comment=t.last_comment,this.comments=[],this.count_notif=t.unread_count,this.isLoaded=!1,this.custom_title=null,this.custom_subtitle=null,this.options=t.options,this.unique_id=t.unique_id,this.isChannel=t.is_public_channel,this.participantNumber=t.room_total_participants,t.comments&&this.receiveComments(t.comments)}),[{key:"isCurrentlySelected",value:function(e){return this.id===e.id}},{key:"getParticipantCount",value:function(){return null==this.participants?this.participantNumber:this.participants.length}},{key:"setTitle",value:function(e){this.custom_title=e}},{key:"setSubTitle",value:function(e){this.custom_subtitle=e}},{key:"receiveComment",value:function(e){if(e.room_id===this.id){var t=this.comments.find((function(t){return t.unique_id===e.unique_id}));t?(t.id=e.id,t.message=e.message,t.date=e.date,t.time=e.time,t.unix_timestamp=e.unix_timestamp):this.comments=[].concat(o()(this.comments),[e])}}},{key:"receiveComments",value:function(e){var t=this;e.forEach((function(e){t.receiveComment(new I(e))}))}},{key:"getParticipant",value:function(e){return this.participants.find((function(t){return t.email===e}))||null}},{key:"addParticipant",value:function(e){this.getParticipant(e.email)||this.participants.push(e)}}])}(),O=function(){return l()((function e(t){var r=t.baseURL,n=t.AppId,o=t.userId,i=t.version,s=t.getCustomHeader,a=t.expiredTokenAdapterGetter;u()(this,e),this.baseURL=r,this.token=null,this.userId=o,this.AppId=n,this.version=i,this.getCustomHeader=s,this._expiredTokenAdapterGetter=a}),[{key:"setToken",value:function(e){this.token=e}},{key:"get",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return this._retryHelper(s()(d.a.mark((function o(){var i;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return i=y.a.get("".concat(t.baseURL,"/").concat(e)),n&&n.baseURL&&(i=y.a.get("".concat(n.baseURL,"/").concat(e))),i=t.setupHeaders(i,r),o.abrupt("return",i);case 1:case"end":return o.stop()}}),o)}))))}},{key:"get_request",value:function(e){var t=this;return this._retryHelper(s()(d.a.mark((function r(){var n;return d.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=y.a.get("".concat(t.baseURL,"/").concat(e)),n=t.setupHeaders(n,{}),r.abrupt("return",n);case 1:case"end":return r.stop()}}),r)}))))}},{key:"post",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._retryHelper(s()(d.a.mark((function o(){var i;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return i=y.a.post("".concat(t.baseURL,"/").concat(e)),i=t.setupHeaders(i,n),o.abrupt("return",i.send(r).set("Content-Type","application/x-www-form-urlencoded"));case 1:case"end":return o.stop()}}),o)}))))}},{key:"post_json",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._retryHelper(s()(d.a.mark((function o(){var i;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return i=y.a.post("".concat(t.baseURL,"/").concat(e)),(i=t.setupHeaders(i,n)).send(r),o.abrupt("return",i);case 1:case"end":return o.stop()}}),o)}))))}},{key:"put",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._retryHelper(s()(d.a.mark((function o(){var i;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return i=y.a.put("".concat(t.baseURL,"/").concat(e)),i=t.setupHeaders(i,n),o.abrupt("return",i.send(r).set("Content-Type","application/x-www-form-urlencoded"));case 1:case"end":return o.stop()}}),o)}))))}},{key:"patch",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._retryHelper(s()(d.a.mark((function o(){var i;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return i=y.a.patch("".concat(t.baseURL,"/").concat(e)),i=t.setupHeaders(i,n),o.abrupt("return",i.send(r).set("Content-Type","application/x-www-form-urlencoded"));case 1:case"end":return o.stop()}}),o)}))))}},{key:"del",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._retryHelper(s()(d.a.mark((function o(){var i;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return i=y.a.del("".concat(t.baseURL,"/").concat(e)),i=t.setupHeaders(i,n),o.abrupt("return",i.send(r).set("Content-Type","application/json"));case 1:case"end":return o.stop()}}),o)}))))}},{key:"setupHeaders",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.set("QISCUS-SDK-PLATFORM","javascript"),null!=this.AppId&&e.set("QISCUS-SDK-APP-ID","".concat(this.AppId)),null!=this.userId&&e.set("QISCUS-SDK-USER-ID","".concat(this.userId)),null!=this.token&&e.set("QISCUS-SDK-TOKEN","".concat(this.token)),null!=this.version&&e.set("QISCUS-SDK-VERSION","".concat(this.version)),null!=this.getCustomHeader){var r=this.getCustomHeader();Object.keys(r).filter((function(e){return null!=r[e]})).forEach((function(t){e.set(t,r[t])}))}if(Object.keys(t).length<1)return e;for(var n in t)t.hasOwnProperty(n)&&e.set(n,t[n]);return e}},{key:"_retryHelper",value:(e=s()(d.a.mark((function e(t){var r,n,o,i,s,a;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,t();case 1:return e.abrupt("return",e.sent);case 2:if(e.prev=2,a=e.catch(0),i=null==a||null===(r=a.response)||void 0===r?void 0:r.status,s=null==a||null===(n=a.response)||void 0===n?void 0:n.body,403!==i||"unauthorized. token is expired"!==(null===(o=s.error)||void 0===o||null===(o=o.message)||void 0===o?void 0:o.toLowerCase())){e.next=5;break}return e.next=3,this._expiredTokenAdapterGetter().refreshAuthToken();case 3:return e.next=4,t();case 4:return e.abrupt("return",e.sent);case 5:throw a;case 6:case"end":return e.stop()}}),e,this,[[0,2]])}))),function(t){return e.apply(this,arguments)})}]);var e}(),R=function(){return l()((function e(t){u()(this,e),this.HTTPAdapter=t,this.refreshToken=null,this.userId=null,this.autoRefreshToken=!1}),[{key:"getNonce",value:function(){return this.HTTPAdapter.post("api/v2/sdk/auth/nonce").then((function(e){return e.body.results}))}},{key:"loginOrRegister",value:function(e){var t=this;return this.HTTPAdapter.post("api/v2/sdk/login_or_register",e).then((function(e){if(200!==e.body.status)return Promise.reject(e);var r=e.body.results;return t.userId=r.user.email,t.refreshToken=r.user.refresh_token,r}))}},{key:"verifyIdentityToken",value:function(e){var t=this;return this.HTTPAdapter.post("api/v2/sdk/auth/verify_identity_token",{identity_token:e}).then((function(e){var r=e.body.results;return t.userId=r.user.email,t.refreshToken=r.user.refresh_token,r}))}},{key:"refreshAuthToken",value:function(){var e=this;return this.HTTPAdapter.post("api/v2/sdk/refresh_user_token",{user_id:this.userId,refresh_token:this.refreshToken}).then((function(t){var r=t.body.results;return e.refreshToken=r.refresh_token,e.HTTPAdapter.token=r.token,r}))}},{key:"expiredAuthToken",value:function(){return this.HTTPAdapter.post("api/v2/sdk/expire_user_token",{user_id:this.userId}).then((function(e){return e.body.results}))}}])}(),P=r(122),M=r.n(P);function D(e){var t={},r=function(e,t){return"".concat(e,"=").concat(t)};return{param:function(e,r){return t[e]=r,this},build:function(){var n=Object.keys(t).filter((function(e){return null!=t[e]})).map((function(e){return Array.isArray(t[e])?t[e].map((function(t){return r("".concat(e,"[]"),t)})).join("&"):r(e,t[e])})).join("&");return[e].concat(n).join("?")}}}var j=function(){return l()((function e(t){var r=this;u()(this,e),p()(this,"updateCommentStatus",M()((function(e,t,n){var o={room_id:e};return t&&(o.last_comment_read_id=t),n&&(o.last_comment_received_id=n),r.HTTPAdapter.post("api/v2/sdk/update_comment_status",o)}),500)),this.HTTPAdapter=t,this.token=t.token}),[{key:"postComment",value:function(e,t,r,n,o,i){return this.HTTPAdapter.post_json("api/v2/sdk/post_comment",{comment:t,topic_id:e,unique_temp_id:r,type:n,payload:o,extras:i}).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.comment)}))}},{key:"loadRoomList",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=D("api/v2/sdk/user_rooms").param("page",t.page).param("show_participants",t.show_participants||!0).param("limit",t.limit).param("show_empty",t.show_empty).param("room_type",null!==(e=t.room_type)&&void 0!==e?e:"default").build();return this.HTTPAdapter.get(r).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.rooms_info)}))}},{key:"searchMessages",value:function(e){var t={query:e.query||null,room_id:e.room_id||null,last_comment_id:e.last_comment_id||null};return this.HTTPAdapter.post("api/v2/sdk/search_messages",t).then((function(e){return e.body.results.comments}))}},{key:"updateProfile",value:function(e){var t={name:e.name||null,avatar_url:e.avatar_url||null,extras:e.extras?JSON.stringify(e.extras):null};return this.HTTPAdapter.patch("api/v2/sdk/my_profile",t).then((function(e){return e.body.results.user}))}},{key:"uploadFile",value:function(e){var t={file:e};return this.HTTPAdapter.post("api/v2/sdk/upload",t).then((function(e){return e.body}))}},{key:"getRoomsInfo",value:function(e){var t={show_participants:!0,show_removed:!1};return e.room_ids&&(t.room_id=e.room_ids),e.room_unique_ids&&(t.room_unique_id=e.room_unique_ids),e.show_participants&&(t.show_participants=e.show_participants),e.show_removed&&(t.show_removed=e.show_removed),this.HTTPAdapter.post_json("api/v2/sdk/rooms_info",t).then((function(e){return e.body}))}},{key:"loadComments",value:function(e,t){var r=D("api/v2/sdk/load_comments").param("topic_id",e).param("last_comment_id",t.last_comment_id).param("timestamp",t.timestamp).param("after",t.after).param("limit",t.limit).build();return this.HTTPAdapter.get(r).then((function(e){return 200!==e.status?Promise.reject(e):Promise.resolve(e.body.results.comments)}))}},{key:"deleteComment",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];!1===r&&console.warn("Deprecated: delete comment for me will be removed on next release"),!1===n&&console.warn("Deprecated: soft delete will be removed on next release");var o={unique_ids:t,is_delete_for_everyone:r,is_hard_delete:n};return this.HTTPAdapter.del("api/v2/sdk/delete_messages",o).then((function(e){return e.body}))}},{key:"clearRoomMessages",value:function(e){var t={room_channel_ids:e};return this.HTTPAdapter.del("api/v2/sdk/clear_room_messages",t).then((function(e){return e.body}))}},{key:"getCommentReceiptStatus",value:function(e){return this.HTTPAdapter.get("api/v2/sdk/comment_receipt?comment_id=".concat(e)).then((function(e){return e.body}))}},{key:"getBlockedUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r="api/v2/sdk/get_blocked_users?page=".concat(e,"&limit=").concat(t);return this.HTTPAdapter.get(r).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.blocked_users)}))}},{key:"blockUser",value:function(e){if(!e)throw new Error("email is required");var t={user_email:e};return this.HTTPAdapter.post("api/v2/sdk/block_user",t).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.user)}))}},{key:"unblockUser",value:function(e){if(!e)throw new Error("email is required");var t={user_email:e};return this.HTTPAdapter.post("api/v2/sdk/unblock_user",t).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.user)}))}},{key:"getProfile",value:function(){return this.HTTPAdapter.get("api/v2/sdk/my_profile").then((function(e){return e.body.results.user}))}},{key:"getUserPresences",value:function(e){var t={user_ids:e};return this.HTTPAdapter.post_json("api/v2/sdk/users/status",t).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.user_status)}))}},{key:"updateMessage",value:function(e){var t={token:this.token,comment:e.message,unique_id:e.unique_id||e.unique_temp_id};return null!=e.extras&&(t.extras=e.extras),null!=e.payload&&(t.payload=e.payload),this.HTTPAdapter.post_json("api/v2/sdk/update_message",t).then((function(e){return e.body.results.comment}))}}])}(),L=function(){return l()((function e(t){u()(this,e),this.HTTPAdapter=t,this.token=t.token}),[{key:"getOrCreateRoom",value:function(e,t,r){var n={emails:e};return r&&(n[r]=r),t&&(n.options=JSON.stringify(t)),this.HTTPAdapter.post("api/v2/sdk/get_or_create_room_with_target",n).then((function(t){if(200!==t.body.status)return Promise.reject(t);var r=t.body.results.room;r.avatar=r.avatar_url,r.comments=t.body.results.comments.reverse();var n=r.participants.find((function(t){return t.email===e}));return r.name=n?n.username:"Room name",Promise.resolve(r)}))}},{key:"getRoomById",value:function(e){return this.HTTPAdapter.get("api/v2/sdk/get_room_by_id?id=".concat(e)).then((function(e){return e.body}))}},{key:"getOrCreateRoomByUniqueId",value:function(e,t,r){var n={unique_id:e,name:t,avatar_url:r};return this.HTTPAdapter.post("api/v2/sdk/get_or_create_room_with_unique_id",n).then((function(e){if(200!==e.body.status)return Promise.reject(e);var t=e.body.results.room;return t.avatar=t.avatar_url,t.comments=e.body.results.comments.reverse(),t.name=t.room_name,Promise.resolve(t)}))}},{key:"createRoom",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=Object.keys(n).length<=0?null:JSON.stringify(n),i={name:e,"participants[]":t,avatar_url:r.avatarURL,options:o};return this.HTTPAdapter.post("api/v2/sdk/create_room",i).then((function(e){if(200!==e.body.status)return Promise.reject(e);var t=e.body.results.room;return t.comments=e.body.results.comments,Promise.resolve({id:t.id,name:t.room_name,lastCommentId:t.last_comment_id,lastCommentMessage:t.last_comment_message,lastTopicId:t.last_topic_id,avatarURL:t.avatar_url,options:t.options,participants:t.participants.map((function(e){return{id:e.id,email:e.email,username:e.username,avatarURL:e.avatar_url}}))})}))}},{key:"updateRoom",value:function(e){if(!e.id)throw new Error("id is required");var t={id:e.id};return e.room_name&&(t.room_name=e.room_name),e.avatar_url&&(t.avatar_url=e.avatar_url),e.options&&(t.options=JSON.stringify(e.options)),this.HTTPAdapter.post("api/v2/sdk/update_room",t).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.room)}))}},{key:"getTotalUnreadCount",value:function(){return this.HTTPAdapter.get("api/v2/sdk/total_unread_count").then((function(e){return e.body.results.total_unread_count}))}},{key:"getRoomUnreadCount",value:function(){return this.HTTPAdapter.get("api/v2/sdk/get_room_unread_count").then((function(e){return e.body.results.total_unread_count}))}},{key:"addParticipantsToGroup",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e||!t)throw new Error("room_id and emails is required");var r={room_id:e,"emails[]":t};return this.HTTPAdapter.post("api/v2/sdk/add_room_participants",r).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.participants_added)}))}},{key:"removeParticipantsFromGroup",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e||!t)throw new Error("room_id and emails is required");var r={room_id:e,"emails[]":t};return this.HTTPAdapter.post("api/v2/sdk/remove_room_participants",r).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.participants_removed)}))}}])}(),U=r(123),N=r.n(U),q=r(25),B=r.n(q),F=String("match.pattern.catchAll"),H=String("match.pattern.OR"),Y=H.toString(),W=String("match.pattern.AND"),z=W.toString(),V=String("match.pattern.RANGE"),K=V.toString(),$=String("match.pattern.REGEXP"),Q=$.toString(),G=/\/(.*)\/(.*)/;function J(){Error.call(this,"Missing when() catch-all pattern as last match argument, add [when()]: void 0"),"stack"in this||(this.stack=(new Error).stack)}function X(e){return void 0===e?F:e instanceof RegExp?Z([$.toString(),e.toString()]):Z(e)}function Z(e){return JSON.stringify([X.__uid++,e])}function ee(){return!0}function te(e){if(Array.isArray(e)){if(e[0]===Y)return e.shift(),function(t){return e[0].some((function(e){return r(e,t)}))};if(e[0]===z)return e.shift(),function(t){return e[0].every((function(e){return r(e,t)}))};if(e[0]===K)return e.shift(),function(t){return e[0]<=t&&t<=e[1]};if(e[0]===Q){var t=G.exec(e[1]);return r.bind(null,new RegExp(t[1],t[2]))}}function r(e,t){if(Array.isArray(t))return JSON.stringify(e)===JSON.stringify(t);if(e instanceof RegExp)return e.test(t);if("object"===B()(t)){for(var r in e)if(t[r]!==e[r])return!1;return!0}return e===t}return function(t){return r(e,t)}}J.prototype=Object.create(Error.prototype),X.__uid=0,X.or=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Z([H.toString(),t])},X.and=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Z([W.toString(),t])},X.range=function(e,t){return Z([V.toString(),e,t])},X.unserialize=function(e,t){if(e===F)return{match:ee,result:t,position:1/0};var r,n=(r=e,JSON.parse(r)),o=n[1],i=n[0];return{match:te(o),result:t,position:i}};var re=r(124),ne=r.n(re),oe=r(125),ie=r.n(oe),se=function(e,t,r,n){try{var o=e();return null!=n&&n(o),o}catch(e){return null!=r&&r(e),t}};function ae(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ue(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ae(Object(r),!0).forEach((function(t){p()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ae(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ce=function(){return l()((function e(t,r,n,o){var i=this,a=o.shouldConnect,c=void 0===a||a,l=o.brokerLbUrl,f=o.enableLb,h=o.getClientId;u()(this,e),p()(this,"_getClientId",(function(){return null==i.getClientId?"".concat(i.core.AppId,"_").concat(i.core.user_id,"_").concat(Date.now()):i.getClientId()})),p()(this,"__mqtt_connected_handler",(function(){i.emitter.emit("connected")})),p()(this,"__mqtt_reconnect_handler",(function(){i.emitter.emit("reconnect")})),p()(this,"__mqtt_closed_handler",(function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];i.emitter.emit("close",t)})),p()(this,"__mqtt_message_handler",(function(e,t){var r=t.toString(),n=i.matcher(e);i.logger("message",e,t),null!=n&&n(r)})),p()(this,"__mqtt_error_handler",(function(e){e&&"client disconnecting"===e.message||(i.emitter.emit("error",e.message),i.logger("error",e.message))})),p()(this,"__mqtt_conneck",(function(e){var t=[],r={will:{topic:"u/".concat(i.core.user_id,"/s"),payload:0,retain:!0},clientId:i._getClientId()};if(null==e&&(e=i.cacheRealtimeURL),null!=i.mqtt){var n=Object.keys(i.mqtt._resubscribeTopics);t.push.apply(t,n),i.mqtt.removeAllListeners(),i.mqtt.end(!0),delete i.mqtt,i.mqtt=null}var o=ne()(e,r);return o.addListener("connect",i.__mqtt_connected_handler),o.addListener("reconnect",i.__mqtt_reconnect_handler),o.addListener("close",i.__mqtt_closed_handler),o.addListener("error",i.__mqtt_error_handler),o.addListener("message",i.__mqtt_message_handler),i.logger("resubscribe to old topics ".concat(t)),t.forEach((function(e){return o.subscribe(e)})),o})),p()(this,"_on_close_handler",ie()(s()(d.a.mark((function e(){var t,r,n,o;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=!0===i.enableLb&&!0===i.core.isLogin&&!0===i.shouldConnect&&!i.willConnectToRealtime,i.logEnabled&&(console.group("@mqtt.closed"),console.log("this.enableLb(".concat(i.enableLb,")")),console.log("this.core.isLogin(".concat(i.core.isLogin,")")),console.log("this.shouldConnect(".concat(i.shouldConnect,")")),console.log("this.willConnectToRealtime(".concat(i.willConnectToRealtime,")")),console.log("shouldReconnect(".concat(t,")")),console.groupEnd()),t){e.next=1;break}return e.abrupt("return");case 1:return i.willConnectToRealtime=!0,e.next=2,i.getMqttNode().then((function(e){return[e,null]})).catch((function(e){return[null,e]}));case 2:r=e.sent,n=N()(r,2),o=n[0],n[1]?(i.logger("cannot get new brokerURL, using old url instead (".concat(i.cacheRealtimeURL,")")),i.mqtt=i.__mqtt_conneck(i.cacheRealtimeURL)):(i.cacheRealtimeURL=o,i.logger("trying to reconnect to",o),i.mqtt=i.__mqtt_conneck(o)),i.willConnectToRealtime=!1;case 3:case"end":return e.stop()}}),e)}))),1e3)),p()(this,"subscribtionBuffer",[]),p()(this,"unsubscribtionBuffer",[]),p()(this,"publishBuffer",[]),this.emitter=g(),this.core=r,this.mqtt=null,this.brokerLbUrl=l,this.getClientId=h,this.enableLb=f,this.shouldConnect=c,this.matcher=function(){var e,t=(e=arguments.length-1)<0||arguments.length<=e?void 0:arguments[e],r=[];for(var n in t)r.push(X.unserialize(n,t[n]));r.sort((function(e,t){return e.position<t.position?-1:1})),-1!==Object.getOwnPropertySymbols(t).indexOf(F)&&r.push(X.unserialize(F,t[F]));var o=function(e){var t=r.find((function(t){return t.match(e)}));if(!t)throw new J;return"function"==typeof t.result?t.result(e):t.result};return 2===arguments.length?o(arguments.length<=0?void 0:arguments[0]):o}(p()(p()(p()(p()(p()(p()(p()(p()(p()(p()({},X(this.reNewMessage),(function(e){return i.newMessageHandler.bind(i,e)})),X(this.reNotification),(function(e){return i.notificationHandler.bind(i,e)})),X(this.reTyping),(function(e){return i.typingHandler.bind(i,e)})),X(this.reRoomTyping),(function(e){return i.roomTypingHandler.bind(i,e)})),X(this.reDelivery),(function(e){return i.deliveryReceiptHandler.bind(i,e)})),X(this.reRead),(function(e){return i.readReceiptHandler.bind(i,e)})),X(this.reOnlineStatus),(function(e){return i.onlinePresenceHandler.bind(i,e)})),X(this.reChannelMessage),(function(e){return i.channelMessageHandler.bind(i,e)})),X(this.reMessageUpdated),(function(e){return i.messageUpdatedHandler.bind(i,e)})),X(),(function(e){return i.logger("topic not handled",e)})));var m=this.__mqtt_conneck(t);this.mqtt=m,c||m.end(!0),this.willConnectToRealtime=!1,this.emitter.on("close",this._on_close_handler)}),[{key:"cacheRealtimeURL",get:function(){return this.core.mqttURL},set:function(e){this.core.mqttURL=e}},{key:"connect",value:function(){this.mqtt=this.__mqtt_conneck()}},{key:"openConnection",value:(r=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.shouldConnect=!0,this.mqtt=this.__mqtt_conneck();case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"closeConnection",value:(t=s()(d.a.mark((function e(){var t=this;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.shouldConnect=!1,this.mqtt.end(!0,(function(e){e&&t.logger("error when close connection",e.message)})),this.mqtt=null;case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getMqttNode",value:(e=s()(d.a.mark((function e(){var t,r,n;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,y.a.get(this.brokerLbUrl);case 1:return t=e.sent,r=t.body.data.url,n=t.body.data.wss_port,e.abrupt("return","wss://".concat(r,":").concat(n,"/mqtt"));case 2:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"connected",get:function(){return null!=this.mqtt&&this.mqtt.connected}},{key:"subscribe",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(this.subscribtionBuffer.push(t);null!=this.mqtt&&this.subscribtionBuffer.length>0;){var n,i=this.subscribtionBuffer.shift();if(null!=i)this.logger("subscribe topic",i),(n=this.mqtt).subscribe.apply(n,o()(i))}}},{key:"unsubscribe",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(this.unsubscribtionBuffer.push(t);null!=this.mqtt&&this.unsubscribtionBuffer.length>0;){var n,i=this.unsubscribtionBuffer.shift();if(null!=i)this.logger("unsubscribe topic",i),(n=this.mqtt).unsubscribe.apply(n,o()(i))}}},{key:"publish",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};for(this.publishBuffer.push({topic:e,payload:t,options:r});null!=this.mqtt&&this.publishBuffer.length>0;){var n=this.publishBuffer.shift();null!=n&&(this.logger("publish to",n.topic,n.payload,n.options),this.mqtt.publish(n.topic,n.payload.toString(),n.options))}}},{key:"emit",value:function(){var e;(e=this.emitter).emit.apply(e,arguments)}},{key:"on",value:function(){var e;(e=this.emitter).on.apply(e,arguments)}},{key:"off",value:function(){var e;(e=this.emitter).off.apply(e,arguments)}},{key:"logEnabled",get:function(){return this.core.debugMQTTMode}},{key:"logger",get:function(){return this.core.debugMQTTMode?console.log.bind(console,"QRealtime ->"):this.noop}},{key:"reNewMessage",get:function(){return/^(.+)\/c$/i}},{key:"reNotification",get:function(){return/^(.+)\/n$/i}},{key:"reTyping",get:function(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/t$/i}},{key:"reRoomTyping",get:function(){return/^r\/(.+)\/typing$/i}},{key:"reDelivery",get:function(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/d$/i}},{key:"reRead",get:function(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/r$/i}},{key:"reOnlineStatus",get:function(){return/^u\/(.+)\/s$/i}},{key:"reChannelMessage",get:function(){return/^(.+)\/(.+)\/c$/i}},{key:"reMessageUpdated",get:function(){return/^(.+)\/update$/i}},{key:"noop",value:function(){}},{key:"newMessageHandler",value:function(e,t){t=JSON.parse(t),this.logger("on:new-message",t),this.emit("new-message",t)}},{key:"notificationHandler",value:function(e,t){var r=this;this.logger("on:notification",t);var n=(t=JSON.parse(t)).payload.data;"deleted_messages"in n&&n.deleted_messages.forEach((function(e){r.emit("comment-deleted",{roomId:e.room_id,commentUniqueIds:e.message_unique_ids,isForEveryone:!0,isHard:!0})})),"deleted_rooms"in n&&n.deleted_rooms.forEach((function(e){r.emit("room-cleared",e)}))}},{key:"roomTypingHandler",value:function(e,t){var r;this.logger("on:room-typing",e);var n=null===(r=e.match(this.reRoomTyping))||void 0===r?void 0:r[1],o=JSON.parse(t);this.emit("room-typing",ue(ue({},o),{},{room_id:n}))}},{key:"typingHandler",value:function(e,t){this.logger("on:typing",e);var r=e.match(this.reTyping);if(r[3]!==this.core.user_id){var n=r[3],o=r[1];if(this.emit("typing",{message:t,userId:n,roomId:o}),null!=this.core.selected)if("1"===t&&o===this.core.selected.id){var i=this.core.selected.participants.find((function(e){return e.email===n}));if(null==i)return;var s=i.username;this.core.isTypingStatus="".concat(s," is typing ...")}else this.core.isTypingStatus=null}}},{key:"deliveryReceiptHandler",value:function(e,t){this.logger("on:delivered",e,t);var r=e.match(this.reDelivery),n=t.split(":"),o=Number(n[0]),i=n[1],s=r[3];this.emit("message-delivered",{commentId:o,commentUniqueId:i,userId:s})}},{key:"readReceiptHandler",value:function(e,t){this.logger("on:read",e,t);var r=e.match(this.reRead),n=t.split(":"),o=Number(n[0]),i=n[1],s=r[3];this.emit("message-read",{commentId:o,commentUniqueId:i,userId:s})}},{key:"onlinePresenceHandler",value:function(e,t){this.logger("on:online-presence",e,t);var r=this.reOnlineStatus.exec(e)[1];this.emit("presence",{message:t,userId:r})}},{key:"channelMessageHandler",value:function(e,t){this.logger("on:channel-message",e,t),this.emit("new-message",JSON.parse(t))}},{key:"messageUpdatedHandler",value:function(e,t){t=JSON.parse(t),this.logger("on:message-updated",e,t),this.emit("message:updated",t)}},{key:"subscribeChannel",value:function(e,t){this.subscribe("".concat(e,"/").concat(t,"/c"))}},{key:"subscribeRoom",value:function(e){null!=this.core.selected&&(e=e||this.core.selected.id,this.subscribe("r/".concat(e,"/typing")),this.subscribe("r/".concat(e,"/").concat(e,"/+/t")),this.subscribe("r/".concat(e,"/").concat(e,"/+/d")),this.subscribe("r/".concat(e,"/").concat(e,"/+/r")))}},{key:"unsubscribeRoom",value:function(e){null!=this.core.selected&&(e=e||this.core.selected.id,this.unsubscribe("r/".concat(e,"/typing")),this.unsubscribe("r/".concat(e,"/").concat(e,"/+/t")),this.unsubscribe("r/".concat(e,"/").concat(e,"/+/d")),this.unsubscribe("r/".concat(e,"/").concat(e,"/+/r")))}},{key:"subscribeTyping",get:function(){return this.subscribeRoom.bind(this)}},{key:"unsubscribeTyping",get:function(){return this.unsubscribeRoom.bind(this)}},{key:"subscribeUserChannel",value:function(){this.subscribe("".concat(this.core.userData.token,"/c")),this.subscribe("".concat(this.core.userData.token,"/n")),this.subscribe("".concat(this.core.userData.token,"/update"))}},{key:"subscribeUserChannelByToken",value:function(e){this.subscribe("".concat(e,"/c")),this.subscribe("".concat(e,"/n")),this.subscribe("".concat(e,"/update"))}},{key:"unsubscribeUserChannel",value:function(){this.unsubscribe("".concat(this.core.userData.token,"/c")),this.unsubscribe("".concat(this.core.userData.token,"/n")),this.unsubscribe("".concat(this.core.userData.token,"/update"))}},{key:"unsusbcribeUserChannelByToken",value:function(e){this.unsubscribe("".concat(e,"/c")),this.unsubscribe("".concat(e,"/n")),this.unsubscribe("".concat(e,"/update"))}},{key:"publishPresence",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];t?this.publish("u/".concat(e,"/s"),1,{retain:!0}):this.publish("u/".concat(e,"/s"),0,{retain:!0})}},{key:"disconnect",value:function(){this.publishPresence(this.core.userData.email,!1),this.unsubscribe(Object.keys(this.mqtt._resubscribeTopics))}},{key:"subscribeUserPresence",value:function(e){this.subscribe("u/".concat(e,"/s"))}},{key:"unsubscribeUserPresence",value:function(e){this.unsubscribe("u/".concat(e,"/s"))}},{key:"subscribeRoomPresence",get:function(){return this.subscribeUserPresence.bind(this)}},{key:"unsubscribeRoomPresence",get:function(){return this.unsubscribeUserPresence.bind(this)}},{key:"publishTyping",value:function(e){if(null!=this.core.selected){var t=this.core.selected.id,r=this.core.user_id;this.publish("r/".concat(t,"/").concat(t,"/").concat(r,"/t"),e)}}}]);var e,t,r}();function le(e,t){var r=g(),n={},o=/^r\/[\w]+\/[\w]+\/e$/i;e.mqtt.on("message",(function(e,t){o.test(e)&&r.emit(e,t)}));var i=function(e){return"r/".concat(e,"/").concat(e,"/e")};return{publishEvent:function(r,n){if(_.undefined(r))throw new Error("`roomId` required");if(_.not.string(r))throw new TypeError("`roomId` must have type of string");if(_.undefined(n))throw new Error("`payload` required");if(_.not.object(n))throw new TypeError("`payload` must have type of object");var o=JSON.stringify({sender:t,data:n});e.publish(i(r),o)},subscribeEvent:function(t,o){if(_.undefined(t))throw new Error("`roomId` required");if(_.not.string(t))throw new TypeError("`roomId` must have type of string");if(_.undefined(o))throw new Error("`callback` required");if(_.not.function(o))throw new TypeError("`callback` must have type of function");var s=i(t);if(!n[s]){e.subscribe(s);var a=function(e){var t=JSON.parse(e);o(t)};r.on(s,a),n[s]=a}},unsubscribeEvent:function(t){if(_.undefined(t))throw new Error("`roomId` required");if(_.not.string(t))throw new TypeError("`roomId` must have type of string");var o=i(t);n[o]&&(e.unsubscribe(o),r.off(o,n[o]),n[o]=null,delete n[o])}}}var fe=r(53),pe=r.n(fe),he=r(54),de=r.n(he);function me(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return ye(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ye(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function ye(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function ge(e){var t,r,n,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new ve(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function ve(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(ve=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new ve(e)}var be=function(){},_e=function(e){return new Promise((function(t){return setTimeout(t,e)}))};function we(e,t){var r=t.isDebug,n=void 0!==r&&r,o=t.syncInterval,i=t.getShouldSync,a=t.syncOnConnect,u=t.lastCommentId,c=t.statusLogin,l=t.enableSync,f=t.enableSyncEvent,p=g(),h=function(){for(var e,t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return n?(e=console).log.apply(e,["QSync:"].concat(r)):{}},m=0,y=function(){return c()?i()?o():a():0},v=function(e,t,r,n,o){var i=g(),a=function(r){var n=D("api/v2/sdk/sync").param("last_received_comment_id",r).build();return e().get(n).then((function(e){var r=e.body.results,n=r.comments,o=r.meta.last_received_comment_id;return n.sort((function(e,t){return e.id-t.id})),Promise.resolve({lastMessageId:o,messages:n,interval:t()})})).catch(be)};function u(){return c.apply(this,arguments)}function c(){return(c=de()(d.a.mark((function o(){var i,s,u;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:i=0,s=100,u=function(){return null!=e()&&r()};case 1:if(!((i+=s)>=t()&&u())){o.next=2;break}return i=0,o.next=2,a(n());case 2:return o.next=3,pe()(_e(s));case 3:o.next=1;break;case 4:case"end":return o.stop()}}),o)})))).apply(this,arguments)}return{get synchronize(){return a},get on(){return i.on},get off(){return i.off},run:function(){return s()(d.a.mark((function e(){var t,r,s,a,c,l,f,p,h;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=!1,r=!1,e.prev=1,a=ge(u());case 2:return e.next=3,a.next();case 3:if(!(t=!(c=e.sent).done)){e.next=5;break}l=c.value;try{i.emit("synchronize",Date.now()),null!=(null==l?void 0:l.lastMessageId)&&null!=(null==l?void 0:l.messages)&&(f=l.lastMessageId,p=l.messages,f>n()&&(p.forEach((function(e){return i.emit("message.new",e)})),i.emit("last-message-id.new",f)))}catch(e){o("error when sync",e.message),console.log("error when sync",e)}case 4:t=!1,e.next=2;break;case 5:e.next=7;break;case 6:e.prev=6,h=e.catch(1),r=!0,s=h;case 7:if(e.prev=7,e.prev=8,!t||null==a.return){e.next=9;break}return e.next=9,a.return();case 9:if(e.prev=9,!r){e.next=10;break}throw s;case 10:return e.finish(9);case 11:return e.finish(7);case 12:case"end":return e.stop()}}),e,null,[[1,6,7,12],[8,,9,11]])})))()}}}(e,y,(function(){return i()&&l()}),u,h);v.on("last-message-id.new",(function(e){return e})),v.on("message.new",(function(e){return p.emit("message.new",e)})),v.on("synchronize",(function(e){return p.emit("synchronize",e)})),v.run().catch((function(e){return h("got error when sync",e)}));var b=function(e,t,r,n,o){var i=g(),a=function(r){var n=D("api/v2/sdk/sync_event").param("start_event_id",r).build();return e().get(n).then((function(e){var r=e.body.events,n=r.map((function(e){return e.id})).sort((function(e,t){return e-t})).pop(),o=r.filter((function(e){return"delivered"===e.action_topic})).map((function(e){return e.payload.data})),i=r.filter((function(e){return"read"===e.action_topic})).map((function(e){return e.payload.data})),s=r.filter((function(e){return"delete_message"===e.action_topic})).map((function(e){return e.payload.data})),a=r.filter((function(e){return"clear_room"===e.action_topic})).map((function(e){return e.payload.data}));return Promise.resolve({lastId:n,messageDelivered:o,messageRead:i,messageDeleted:s,roomCleared:a,interval:t()})})).catch(be)};function u(){return c.apply(this,arguments)}function c(){return(c=de()(d.a.mark((function o(){var i,s,u;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:i=0,s=100,u=function(){return null!=e()&&r()};case 1:if(!((i+=s)>=t()&&u())){o.next=2;break}return i=0,o.next=2,a(n());case 2:return o.next=3,pe()(_e(s));case 3:o.next=1;break;case 4:case"end":return o.stop()}}),o)})))).apply(this,arguments)}return{get synchronize(){return a},get on(){return i.on},get off(){return i.off},run:function(){return s()(d.a.mark((function e(){var t,r,s,a,c,l,f,p;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=!1,r=!1,e.prev=1,a=ge(u());case 2:return e.next=3,a.next();case 3:if(!(t=!(c=e.sent).done)){e.next=5;break}l=c.value;try{(f=l.lastId)>n()&&(i.emit("last-event-id.new",f),l.messageDelivered.forEach((function(e){return i.emit("message.delivered",e)})),l.messageDeleted.forEach((function(e){return i.emit("message.deleted",e)})),l.messageRead.forEach((function(e){return i.emit("message.read",e)})),l.roomCleared.forEach((function(e){return i.emit("room.cleared",e)})))}catch(e){o("error when sync event",e.message)}case 4:t=!1,e.next=2;break;case 5:e.next=7;break;case 6:e.prev=6,p=e.catch(1),r=!0,s=p;case 7:if(e.prev=7,e.prev=8,!t||null==a.return){e.next=9;break}return e.next=9,a.return();case 9:if(e.prev=9,!r){e.next=10;break}throw s;case 10:return e.finish(9);case 11:return e.finish(7);case 12:case"end":return e.stop()}}),e,null,[[1,6,7,12],[8,,9,11]])})))()}}}(e,y,(function(){return i()&&f()}),(function(){return m}),h);return b.on("last-event-id.new",(function(e){m=e})),b.on("message.read",(function(e){p.emit("message.read",e)})),b.on("message.delivered",(function(e){return p.emit("message.delivered",e)})),b.on("message.deleted",(function(e){return p.emit("message.deleted",e)})),b.on("room.cleared",(function(e){return p.emit("room.cleared",e)})),b.run().catch((function(e){return h("got error when sync event",e)})),{get on(){return p.on},get off(){return p.off},get interval(){return y()},get enabled(){return l()},synchronize:function(){return s()(d.a.mark((function e(){var t,r,n,o,i,s,a,c,l;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=u(),e.next=1,v.synchronize(n);case 1:o=e.sent,i=null!==(t=null==o?void 0:o.messages)&&void 0!==t?t:[],s=null!==(r=null==o?void 0:o.lastMessageId)&&void 0!==r?r:-1,a=me(i);try{for(a.s();!(c=a.n()).done;)l=c.value,p.emit("message.new",l)}catch(e){a.e(e)}finally{a.f()}s>0&&p.emit("last-message-id.new",s);case 2:case"end":return e.stop()}}),e)})))()},synchronizeEvent:function(){return s()(d.a.mark((function e(){var t,r;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,b.synchronize(m);case 1:t=e.sent;try{(r=t.lastId)>getId()&&(p.emit("last-event-id.new",r),t.messageDelivered.forEach((function(e){return p.emit("message.delivered",e)})),t.messageDeleted.forEach((function(e){return p.emit("message.deleted",e)})),t.messageRead.forEach((function(e){return p.emit("message.read",e)})),t.roomCleared.forEach((function(e){return p.emit("room.cleared",e)})))}catch(e){h("error when sync event",e.message)}case 2:case"end":return e.stop()}}),e)})))()}}}var ke=r(126),Se={MESSAGE_BEFORE_SENT:"message::before-sent",MESSAGE_BEFORE_RECEIVED:"message::before-received"};var xe,Ee=function(){return l()((function e(t){var r=t.httpAdapter,n=t.refreshToken,o=t.expiredAt,i=t.userId,s=t.onTokenRefreshed,a=t.getAuthenticationStatus;u()(this,e),p()(this,"_isExpiredTokenEnabled",!1),p()(this,"_refreshToken",null),p()(this,"_expiredAt",null),p()(this,"_http",void 0),p()(this,"_onTokenRefreshed",void 0),p()(this,"_timerId",void 0),p()(this,"_getAuthenticationStatus",void 0),this._http=r,this._refreshToken=n,this._userId=i,this._onTokenRefreshed=s,this._getAuthenticationStatus=a,null!=this._refreshToken&&""===this._refreshToken&&(this._refreshToken=null),null!=o&&""!==o&&(this._expiredAt=new Date(o)),this._isExpiredTokenEnabled=null!=this._refreshToken&&null!=this._expiredAt,this._setTimer(this._expiredAt)}),[{key:"_setTimer",value:function(e){var t,r=this;null!=this._timerId&&(clearTimeout(this._timerId),this._timerId=null);var n=Math.floor((null!==(t=null==e?void 0:e.getTime())&&void 0!==t?t:NaN)-Date.now());!isNaN(n)&&n>0&&(this._timerId=setTimeout((function(){r.refreshAuthToken()}),n))}},{key:"refreshAuthToken",value:(t=s()(d.a.mark((function e(){var t=this;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!=this._getAuthenticationStatus()&&null!=this._refreshToken){e.next=1;break}return e.abrupt("return");case 1:return e.abrupt("return",this._http.post("api/v2/sdk/refresh_user_token",{user_id:this._userId,refresh_token:this._refreshToken}).then((function(e){var r,n=e.body.results,o=n.token;return t._refreshToken=n.refresh_token,null===(r=t._onTokenRefreshed)||void 0===r||r.call(t,o,t._refreshToken,t._expiredAt,t._http.token),t._http.setToken(n.token),null!=n.token_expires_at&&(t._expiredAt=new Date(n.token_expires_at)),t._setTimer(t._expiredAt),n})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"logout",value:(e=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._http.post("api/v2/sdk/logout",{user_id:this._userId,token:this._http.token}));case 1:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,t}();function Te(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ae(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Te(Object(r),!0).forEach((function(t){p()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Te(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ie(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Ce(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ce(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function Ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Oe=Object.freeze({disabled:"UpdateCommentStatusMode.disabled",throttled:"UpdateCommentStatusMode.throttled",enabled:"UpdateCommentStatusMode.enabled"}),Re=function(){function e(){var t,r,n=this;u()(this,e),p()(this,"_pendingComments",[]),p()(this,"_pendingCommentsCount",{}),p()(this,"_readComment",(function(e,t){return n._updateStatus(e,t)})),p()(this,"_readCommentT",this._throttle((function(e,t){n._updateStatus(e,t)}),(function(){return n._throttleDelay}))),p()(this,"_deliverComment",(function(e,t){return n._updateStatus(e,void 0,t)})),p()(this,"_deliverCommentT",this._throttle((function(e,t){n._updateStatus(e,void 0,t)}),(function(){return n._throttleDelay}))),this.events=g(),this.rooms=[],this.selected=null,this.room_name_id_map={},this.pendingCommentId=0,this.uploadedFiles=[],this.chatmateStatus=null,this.version="WEB_".concat(ke.version),this.userData={},this.AppId=null,this.baseURL="https://api.qiscus.com",this.mqttURL="wss://realtime-jogja.qiscus.com:1886/mqtt",this.brokerLbUrl="https://realtime-lb.qiscus.com",this.syncOnConnect=1e4,this.enableEventReport=!1,this.enableRealtime=!0,this.enableRealtimeCheck=!0,this.enableSync=!0,this.enableSyncEvent=!1,this.HTTPAdapter=null,this.expiredTokenAdapter=null,this.realtimeAdapter=null,this.customEventAdapter=null,this.isInit=!1,this.isSynced=!1,this.syncInterval=5e3,this.sync="socket",this.enableLb=!0,this.httpsync=null,this.eventsync=null,this.extras=null,this.last_received_comment_id=0,this.googleMapKey="",this.options={avatar:!0},this.isConfigLoaded=!1,this.updateCommentStatusMode=e.UpdateCommentStatusMode.enabled,this.updateCommentStatusThrottleDelay=300,this.UI={},this.mode="widget",this.avatar=!0,this.plugins=[],this.isLogin=!1,this.isLoading=!1,this.isInit=!1,this.emoji=!1,this.isTypingStatus="",this.customTemplate=!1,this.templateFunction=null,this.debugMode=!1,this.debugMQTTMode=!1,this._customHeader={},this._forceEnableSync=!0,this.lastReceiveMessages=[],this._hookAdapter=(t={},r=function(e){return Array.isArray(t[e])||(t[e]=[]),t[e]},{trigger:function(e,t){return r(e).reduce((function(e,t){return Promise.resolve(e).then(t)}),Promise.resolve(t))},intercept:function(e,t){r(e).push(t);var n=r(e).length;return function(){return r(e).splice(n,1)}}}),this._uploadURL=null,this._autoRefreshToken=!1}return l()(e,[{key:"uploadURL",get:function(){return this._uploadURL||"".concat(this.baseURL,"/api/v2/sdk/upload")},set:function(e){this._uploadURL=e}},{key:"init",value:(T=s()(d.a.mark((function e(t){var r,n,o,i,a,u,c=this;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.AppId){e.next=1;break}throw new Error("Please provide valid AppId");case 1:if(this.AppId=t.AppId,n=null!=t.baseURL&&this.baseURL!==t.baseURL,o=null!=t.mqttURL&&this.mqttURL!==t.mqttURL,i=null!=t.brokerLbURL&&this.brokerLbUrl!==t.brokerLbURL,!n&&!o||i?null!=t.enableRealtimeLB&&(this.enableLb=t.enableRealtimeLB):(this.logger("force disable load balancing for realtime server, because `baseURL` or `mqttURL` get changed but did not provide `brokerLbURL`"),this.enableLb=!1),null!=t.updateCommentStatusMode&&(this.updateCommentStatusMode=t.updateCommentStatusMode),null!=t.updateCommentStatusThrottleDelay&&(this.updateCommentStatusThrottleDelay=t.updateCommentStatusThrottleDelay),t.baseURL&&(this.baseURL=t.baseURL),t.mqttURL&&(this.mqttURL=t.brokerUrl||t.mqttURL),t.mqttURL&&(this.brokerUrl=t.brokerUrl||t.mqttURL),t.brokerLbURL&&(this.brokerLbUrl=t.brokerLbURL),t.uploadURL&&(this.uploadURL=t.uploadURL),t.sync&&(this.sync=t.sync),t.mode&&(this.mode=t.mode),t.syncInterval&&(this.syncInterval=t.syncInterval||5e3),t.googleMapKey&&(this.googleMapKey=t.googleMapKey),t.allowedFileTypes&&(this.allowedFileTypes=t.allowedFileTypes),t.options&&(this.options=Object.assign({},this.options,t.options)),t.customTemplate&&(this.customTemplate=t.customTemplate),t.templateFunction&&(this.templateFunction=t.templateFunction),null!=t.syncInterval&&(this.syncInterval=t.syncInterval),this.HTTPAdapter=new O({baseURL:this.baseURL,AppId:this.AppId,userId:this.user_id,version:this.version,getCustomHeader:function(){return c._customHeader}}),a=function(e,t,r){if(""===t&&null!=e){if("string"!=typeof e)return e;if(e.length>0)return e}if(null!=t){if(t.length>0)return t;if("string"!=typeof t)return t}return r},u=function(e){return e.includes("wss://")?e:"wss://".concat(e,":1886/mqtt")},this.withConfig=null===(r=t.withConfig)||void 0===r||r,!0!==this.withConfig){e.next=3;break}return e.next=2,this.HTTPAdapter.get_request("api/v2/sdk/config").then((function(e){return 200==e.status?c.isConfigLoaded=!0:c.isConfigLoaded=!1,e.body.results})).then((function(e){var r=c.baseURL,n=c.brokerLbUrl,o=c.mqttURL,i=c.enableRealtime,s=c.enableRealtimeCheck,l=c.syncInterval,f=c.syncOnConnect,p=c.enableEventReport;c.baseURL=a(t.baseURL,e.base_url,r),c.brokerLbUrl=a(t.brokerLbURL,e.broker_lb_url,n),c.mqttURL=u(a(t.mqttURL,e.broker_url,o)),c.enableRealtime=a(t.enableRealtime,e.enable_realtime,i),c.syncInterval=a(t.syncInterval,e.sync_interval,l),c.syncOnConnect=a(t.syncOnConnect,e.sync_on_connect,f),c.enableRealtimeCheck=a(null,e.enable_realtime_check,s),c.enableEventReport=a(null,e.enable_event_report,p),c.extras=a(null,e.extras,{}),c.enableSync=a(null,e.enable_sync,c.enableSync),c.enableSyncEvent=a(null,e.enable_sync_event,c.enableSyncEvent),c._autoRefreshToken=a(null,e.auto_refresh_token,!1)})).catch((function(e){c.logger("got error when trying to get app config",e),c.isConfigLoaded=!0}));case 2:e.next=4;break;case 3:this.isConfigLoaded=!0;case 4:this._getMqttClientId=function(){return"".concat(c.AppId,"_").concat(c.user_id,"_").concat(Date.now())},this.realtimeAdapter=new ce(this.mqttURL,this,this.isLogin,{brokerLbUrl:this.brokerLbUrl,enableLb:this.enableLb,shouldConnect:this.enableRealtime,getClientId:this._getMqttClientId}),this.realtimeAdapter.on("connected",(function(){!c.isLogin&&c.realtimeAdapter.connected||(c.last_received_comment_id=c.userData.last_comment_id,c.updateLastReceivedComment(c.last_received_comment_id))})),this.realtimeAdapter.on("close",(function(){})),this.realtimeAdapter.on("reconnect",(function(){var e,t;null===(e=(t=c.options).onReconnectCallback)||void 0===e||e.call(t)})),this.realtimeAdapter.on("message-delivered",(function(e){var t=e.commentId,r=e.commentUniqueId,n=e.userId;return c._setDelivered(t,r,n)})),this.realtimeAdapter.on("message-read",(function(e){var t=e.commentId,r=e.commentUniqueId,n=e.userId;return c._setRead(t,r,n)})),this.realtimeAdapter.on("new-message",function(){var e=s()(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,c._hookAdapter.trigger(Se.MESSAGE_BEFORE_RECEIVED,t);case 1:t=e.sent,c.events.emit("newmessages",[t]);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),this.realtimeAdapter.on("presence",(function(e){return c.events.emit("presence",e)})),this.realtimeAdapter.on("comment-deleted",(function(e){return c.events.emit("comment-deleted",e)})),this.realtimeAdapter.on("room-cleared",(function(e){return c.events.emit("room-cleared",e)})),this.realtimeAdapter.on("typing",(function(e){return c.events.emit("typing",{message:e.message,username:e.userId,room_id:e.roomId})})),this.realtimeAdapter.on("message:updated",(function(e){null!=c.options.messageUpdatedCallback&&c.options.messageUpdatedCallback(e)})),this.realtimeAdapter.on("room-typing",(function(e){c.events.emit("typing",{message:e.text,username:e.sender_name,email:e.sender_id,room_id:e.room_id}),null!=c.options.onRoomTypingCallback&&(c.events.emit("room-typing",e),c.options.onRoomTypingCallback(e))})),this.syncAdapter=we((function(){return c.HTTPAdapter}),{getToken:function(){return c.userData.token},syncInterval:function(){return c.syncInterval},getShouldSync:function(){return c._forceEnableSync&&c.isLogin&&!c.realtimeAdapter.connected},syncOnConnect:function(){return c.syncOnConnect},lastCommentId:function(){return c.last_received_comment_id},statusLogin:function(){return c.isLogin},enableSync:function(){return c.enableSync},enableSyncEvent:function(){return c.enableSyncEvent}}),this.syncAdapter.on("message.new",function(){var e=s()(d.a.mark((function e(t){var r;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,c._hookAdapter.trigger(Se.MESSAGE_BEFORE_RECEIVED,t);case 1:t=e.sent,null!=c.selected?-1===c.selected.comments.findIndex((function(e){return e.id===t.id||e.unique_id===t.unique_temp_id}))&&((r=new I(t)).room_id===c.selected.id&&(c.selected.comments.push(r),c.sortComments()),c.events.emit("newmessages",[t])):c.events.emit("newmessages",[t]);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),this.syncAdapter.on("message.delivered",(function(e){c._setDelivered(e.comment_id,e.comment_unique_id,e.email)})),this.syncAdapter.on("message.read",(function(e){c._setRead(e.comment_id,e.comment_unique_id,e.email)})),this.syncAdapter.on("message.deleted",(function(e){e.deleted_messages.forEach((function(e){c.events.emit("comment-deleted",{roomId:e.room_id,commentUniqueIds:e.message_unique_ids,isForEveryone:!0,isHard:!0})}))})),this.syncAdapter.on("room.cleared",(function(e){e.deleted_rooms.forEach((function(e){c.events.emit("room-cleared",e)}))})),this.syncAdapter.on("synchronize",(function(){c._pendingComments.forEach((function(e){return c._retrySendComment(e)}))})),this.syncAdapter.on("last-message-id.new",(function(e){c.last_received_comment_id=e})),this.customEventAdapter=le(this.realtimeAdapter,this.user_id),this.setEventListeners();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"_setRead",value:function(e,t,r){if(null!=this.selected){var n=this.selected,o=n.comments.find((function(r){return r.id===e||r.unique_id===t}));if(null!=o&&"read"!==o.status){var i={participants:n.participants,actor:r,comment_id:e,activeActorId:this.user_id};n.comments.forEach((function(e){e.id<=o.id&&e.markAsRead(i)})),o.isRead&&this.events.emit("comment-read",{comment:o,userId:r})}}}},{key:"_setDelivered",value:function(e,t,r){if(null!=this.selected){var n=this.selected,o=n.comments.find((function(r){return r.id===e||r.unique_id===t}));if(null!=o&&"read"!==o.status){var i={participants:n.participants,actor:r,comment_id:e,activeActorId:this.user_id};n.comments.forEach((function(e){e.id<=o.id&&e.markAsDelivered(i)})),o.isDelivered&&this.events.emit("comment-delivered",{comment:o,userId:r})}}}},{key:"setEventListeners",value:function(){var e=this,t=this;this.authAdapter=new R(t.HTTPAdapter),null!=this.userData.email&&(this.authAdapter.userId=this.userData.email),t.events.on("start-init",(function(){t.HTTPAdapter=new O({baseURL:t.baseURL,AppId:t.AppId,userId:t.user_id,version:t.version,getCustomHeader:function(){return e._customHeader}}),t.HTTPAdapter.setToken(t.userData.token)})),t.events.on("room-changed",(function(r){e.logging("room changed",r),t.options.roomChangedCallback&&t.options.roomChangedCallback(r)})),t.events.on("file-uploaded",(function(e){t.options.fileUploadedCallback&&t.options.fileUploadedCallback(e)})),t.events.on("profile-updated",(function(e){t.username=e.name,t.avatar_url=e.avatar_url,t.options.updateProfileCallback&&t.options.updateProfileCallback(e)})),t.events.on("newmessages",(function(r){e.logging("newmessages",r),e.lastReceiveMessages.length>0&&e.lastReceiveMessages[0].unique_temp_id===r[0].unique_temp_id?e.logging("lastReceiveMessages double",r):(e.lastReceiveMessages=r,t._callNewMessagesCallback(r),r.forEach((function(r){t.receiveComment(r.room_id,r.id);var n=!!t.selected&&r.room_id===t.selected.id,o=r.id<=t.last_received_comment_id;if(n){var i=t.selected,s=t.selected.comments[t.selected.comments.length-1];s.isPending||o||t.user_id===r.email||t.readComment(r.room_id,r.id);var a=s.id,u=t.selected.comments.find((function(e){return e.id===s.comment_before_id}));s.isPending||u||(e.logging("comment before id not found! ",r.comment_before_id),t.synchronize(a));var c=new I(r);i.receiveComment(c),i.last_comment_id=c.id,i.last_comment_message=c.message}t.updateLastReceivedComment(r.id),e.sortComments()})))})),this.events.on("login-success",(function(t){e.isLogin=!0,e.userData=t.user,e.last_received_comment_id=e.userData.last_comment_id,e.realtimeAdapter.connected||e.updateLastReceivedComment(e.last_received_comment_id),e.HTTPAdapter=new O({baseURL:e.baseURL,AppId:e.AppId,userId:e.user_id,version:e.version,getCustomHeader:function(){return e._customHeader},expiredTokenAdapterGetter:function(){return e.expiredTokenAdapter}}),e.HTTPAdapter.setToken(e.userData.token);var r,n,o,i=t.user;e._delayedSync=(r=function(){e.synchronize(),e.synchronizeEvent()},n=500,o=null,function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];null!=o&&clearTimeout(o),o=setTimeout((function(){r.apply(void 0,t),o=null}),n)}),e.expiredTokenAdapter=new Ee({httpAdapter:e.HTTPAdapter,refreshToken:i.refresh_token,expiredAt:i.token_expires_at,userId:e.user_id,onTokenRefreshed:function(t,r,n,o){e.userData.token=t,e.userData.refresh_token=r,e.userData.token_expires_at=null==n?void 0:n.toJSON(),e.events.emit("token-refreshed",{token:t,refreshToken:r,expiredAt:n,oldToken:o}),e.realtimeAdapter.unsusbcribeUserChannelByToken(o),e.realtimeAdapter.subscribeUserChannelByToken(t),e._delayedSync()},getAuthenticationStatus:function(){return null!=e.user_id&&e.isLogin}}),e.userAdapter=new j(e.HTTPAdapter),e.roomAdapter=new L(e.HTTPAdapter),e.realtimeAdapter.subscribeUserChannel(),null!=e.presensePublisherId&&-1!==e.presensePublisherId&&clearInterval(e.presensePublisherId),e.presensePublisherId=setInterval((function(){e.realtimeAdapter.publishPresence(e.user_id,!0)}),3500),e.options.loginSuccessCallback&&e.options.loginSuccessCallback(t),e.authAdapter.userId=e.userData.email,e.authAdapter.refreshToken=e.userData.refresh_token,e.authAdapter.autoRefreshToken=e._autoRefreshToken})),t.events.on("login-error",(function(e){t.options.loginErrorCallback&&t.options.loginErrorCallback(e)})),t.events.on("token-refreshed",(function(t){var r,n;null===(r=(n=e.options).authTokenRefreshedCallback)||void 0===r||r.call(n,t)})),t.events.on("room-cleared",(function(e){if(t.selected){var r=t.selected;t.selected.unique_id===e.unique_id&&(t.selected=null,t.selected=r)}t.options.roomClearedCallback&&t.options.roomClearedCallback(e)})),t.events.on("comment-deleted",(function(e){var r=e.roomId,n=e.commentUniqueIds,o=(e.isForEveryone,e.isHard);t.selected&&t.selected.id==r&&n.map((function(e){var r=t.selected.comments.findIndex((function(t){return t.unique_id===e}));r>-1&&(o?t.selected.comments.splice(r,1):t.selected.comments[r].message="this message has been deleted");var n=t.selected.comments[t.selected.comments.length-1];t.selected.last_comment_id=n.id,t.selected.last_comment_message=n.message})),t.options.commentDeletedCallback&&t.options.commentDeletedCallback(e)})),t.events.on("comment-delivered",(function(e){return t.logging("comment-delivered",e),!!e&&(t.options.commentDeliveredCallback?t.options.commentDeliveredCallback(e):void 0)})),t.events.on("chat-room-created",(function(e){t.isLoading=!1,t.options.chatRoomCreatedCallback&&t.options.chatRoomCreatedCallback(e)})),t.events.on("group-room-created",(function(e){t.isLoading=!1,t.options.groupRoomCreatedCallback&&t.options.groupRoomCreatedCallback(e)})),t.events.on("header-clicked",(function(e){t.options.headerClickedCallback&&t.options.headerClickedCallback(e)})),t.events.on("comment-read",(function(e){t.logging("comment-read",e),t.options.commentReadCallback&&t.options.commentReadCallback(e)})),t.events.on("presence",(function(r){var n=r.message,o=r.userId,i=n.split(":");e.chatmateStatus!==i[0]&&(e.chatmateStatus=1===i[0]?"Online":"Last seen ".concat(x()(Number(i[1].substring(0,13))))),t.options.presenceCallback&&t.options.presenceCallback(n,o)})),t.events.on("typing",(function(e){t.options.typingCallback&&t.options.typingCallback(e)})),t.events.on("message-info",(function(e){t.options.messageInfoCallback&&t.options.messageInfoCallback(e)})),t.events.on("participants-added",(function(t){var r;null!=t&&null!=e.selected&&(r=e.selected.participants).push.apply(r,o()(t))})),t.events.on("participants-removed",(function(t){if(null!=t&&null!=e.selected){var r=e.selected.participants.filter((function(e){return t.indexOf(e.email)<=-1}));e.selected.participants=r}})),t.events.on("block-user",(function(e){t.options.blockUserCallback&&t.options.blockUserCallback(e)})),t.events.on("unblock-user",(function(e){t.options.unblockUserCallback&&t.options.unblockUserCallback(e)}))}},{key:"onReconnectMqtt",value:function(){this.options.onReconnectCallback&&this.options.onReconnectedCallback(),this.selected&&this.loadComments(this.selected.id)}},{key:"_callNewMessagesCallback",value:function(e){this.options.newMessagesCallback&&this.options.newMessagesCallback(e)}},{key:"updateLastReceivedComment",value:function(e){this.last_received_comment_id<e&&(this.last_received_comment_id=e)}},{key:"setUser",value:function(e,t,r,n,o){var i=this,s=this;s.user_id=e,s.key=t,s.username=r,s.avatar_url=n;var a={email:this.user_id,password:this.key,username:this.username,extras:o?JSON.stringify(o):null};return this.avatar_url&&(a.avatar_url=this.avatar_url),new Promise((function(e,t){var r=setInterval((function(){if(i.isConfigLoaded)return clearInterval(r),i.logger("Config Success!"),s.events.emit("start-init"),s.authAdapter.loginOrRegister(a).then((function(t){s.isInit=!0,s.refresh_token=t.user.refresh_token,s.events.emit("login-success",t),i.realtimeAdapter.connect(),e(t)}),(function(e){s.events.emit("login-error",e),t(e)}));i.debugMode&&i.logger("Waiting for init config...")}),300)}))}},{key:"setUserWithIdentityToken",value:function(e){var t=this;if(!e||!("user"in e))return this.events.emit("login-error",e);this.email=e.user.email,this.user_id=e.user.email,this.key=e.identity_token,this.username=e.user.username,this.avatar_url=e.user.avatar_url,this.isInit=!0;var r=setInterval((function(){t.isConfigLoaded?(clearInterval(r),t.logger("Config Success!"),t.events.emit("login-success",e)):t.debugMode&&t.logger("Waiting for init config...")}),300)}},{key:"refreshAuthToken",value:function(){return this.expiredTokenAdapter.refreshAuthToken()}},{key:"publishOnlinePresence",value:function(e){var t=this;!0===e?xe=setInterval((function(){t.realtimeAdapter.publishPresence(t.user_id,!0)}),3500):(clearInterval(this.presensePublisherId),clearInterval(xe),setTimeout((function(){t.realtimeAdapter.publishPresence(t.user_id,!1)}),3500))}},{key:"subscribeUserPresence",value:function(e){this.realtimeAdapter.subscribeUserPresence(e)}},{key:"unsubscribeUserPresence",value:function(e){this.realtimeAdapter.unsubscribeUserPresence(e)}},{key:"logout",value:(E=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.expiredTokenAdapter.logout();case 1:clearInterval(this.presensePublisherId),this.publishOnlinePresence(!1),this.selected=null,this.isInit=!1,this.isLogin=!1,this.realtimeAdapter.disconnect(),this.userData={};case 2:case"end":return e.stop()}}),e,this)}))),function(){return E.apply(this,arguments)})},{key:"synchronize",get:function(){return this.syncAdapter.synchronize}},{key:"synchronizeEvent",get:function(){return this.syncAdapter.synchronizeEvent}},{key:"disconnect",value:function(){this.logout()}},{key:"setActiveRoom",value:function(e){var t=this;if(this.selected&&(this.realtimeAdapter.unsubscribeTyping(),"single"===this.selected.room_type)){var r=this.selected.participants.filter((function(e){return e.email!==t.user_id}));r.length>0&&this.realtimeAdapter.unsubscribeRoomPresence(r[0].email)}null==e.participants&&(e.participants=[]);var n=e.participants.find((function(e){return e.email!==t.user_id}));this.chatmateStatus=null,this.isTypingStatus=null,this.selected=e;var o=setInterval((function(){t.debugMode&&t.logger("Trying Initial Subscribe"),null!=t.realtimeAdapter?(t.debugMode&&t.logger("MQTT Connected"),clearInterval(o),"single"===e.room_type&&null!=n&&t.realtimeAdapter.subscribeRoomPresence(n.email),null==t.selected||t.selected.isChannel||(t.realtimeAdapter.subscribeTyping(e.id),t.events.emit("room-changed",t.selected)),t.debugMode&&null==t.realtimeAdapter&&t.logger("Retry")):t.debugMode&&t.logger("MQTT Not Connected, yet")}),3e3)}},{key:"chatTarget",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=this.userData.length)return!1;var n=r?r.message:null,o=r.distinctId;return this.isLoading=!0,this.isTypingStatus="",this.roomAdapter.getOrCreateRoom(e,r,o).then(function(){var e=s()(d.a.mark((function e(r){var o,i,a,u;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new C(r),t.updateLastReceivedComment(o.last_comment_id),t.isLoading=!1,i=function(){var e=s()(d.a.mark((function e(r){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,t._hookAdapter.trigger(Se.MESSAGE_BEFORE_RECEIVED,r);case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=1,Promise.all(o.comments.map((function(e){return i(e)})));case 1:if(o.comments=e.sent,t.setActiveRoom(o),(a=o.comments[o.comments.length-1])&&t.readComment(o.id,a.id),t.events.emit("chat-room-created",{room:o}),n){e.next=2;break}return e.abrupt("return",o);case 2:return u=o.id,e.abrupt("return",t.sendComment(u,n).then((function(){return Promise.resolve(o)})).catch((function(e){console.error("Error when submit comment",e)})));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return console.error("Error when creating room",e),t.isLoading=!1,Promise.reject(e)}))}},{key:"chatGroup",value:function(e){if(this.isInit)return this.getRoomById(e).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"getRoomById",value:function(e){var t=this;if(this.isInit){var r=this;return r.isLoading=!0,r.isTypingStatus="",r.roomAdapter.getRoomById(e).then(function(){var e=s()(d.a.mark((function e(n){var o,i,s,a,u,c,l,f,p;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=n.results.room,i=[],s=Ie(n.results.comments.reverse()),e.prev=1,s.s();case 2:if((a=s.n()).done){e.next=5;break}return u=a.value,e.next=3,t._hookAdapter.trigger(Se.MESSAGE_BEFORE_RECEIVED,u);case 3:c=e.sent,i.push(c);case 4:e.next=2;break;case 5:e.next=7;break;case 6:e.prev=6,p=e.catch(1),s.e(p);case 7:return e.prev=7,s.f(),e.finish(7);case 8:return l=new C(Ae(Ae({},o),{},{comments:i,name:o.room_name})),r.updateLastReceivedComment(l.last_comment_id),r.setActiveRoom(l),r.isLoading=!1,(f=l.comments[l.comments.length-1])&&r.readComment(l.id,f.id),l.isChannel&&t.realtimeAdapter.subscribeChannel(t.AppId,l.unique_id),e.abrupt("return",l);case 9:case"end":return e.stop()}}),e,null,[[1,6,7,8]])})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return console.error("Error getting room by id",e),Promise.reject(e)}))}}},{key:"getOrCreateRoomByUniqueId",value:function(e,t,r){var n=this,o=this;return o.isLoading=!0,o.isTypingStatus="",o.roomAdapter.getOrCreateRoomByUniqueId(e,t,r).then(function(){var e=s()(d.a.mark((function e(t){var r,i,a;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new C(t),o.updateLastReceivedComment(r.last_comment_id),i=function(){var e=s()(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,n._hookAdapter.trigger(Se.MESSAGE_BEFORE_RECEIVED,t);case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=1,Promise.all(r.comments.map((function(e){return i(e)})));case 1:return r.comments=e.sent,o.setActiveRoom(r),o.isLoading=!1,(a=r.comments[r.comments.length-1])&&o.readComment(r.id,a.id),n.realtimeAdapter.subscribeChannel(n.AppId,r.unique_id),e.abrupt("return",Promise.resolve(r));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return Promise.reject(e)}))}},{key:"getOrCreateRoomByChannel",value:function(e,t,r){return this.getOrCreateRoomByUniqueId(e,t,r)}},{key:"sortComments",value:function(){this.selected&&this.selected.comments.sort((function(e,t){return e.unix_timestamp-t.unix_timestamp}))}},{key:"loadRoomList",value:(S=s()(d.a.mark((function e(){var t,r,n=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},e.next=1,this.userAdapter.loadRoomList(t);case 1:return r=e.sent,e.abrupt("return",r.map((function(e){return e.last_comment_id=e.last_comment.id,e.last_comment_message=e.last_comment.message,e.last_comment_message_created_at=e.last_comment.timestamp,e.room_type=e.chat_type,e.comments=[],new C(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return S.apply(this,arguments)})},{key:"loadComments",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.userAdapter.loadComments(e,r).then(function(){var e=s()(d.a.mark((function e(r){var n,o,i,s,a,u;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=[],o=Ie(r),e.prev=1,o.s();case 2:if((i=o.n()).done){e.next=5;break}return s=i.value,a=n,e.next=3,t._hookAdapter.trigger(Se.MESSAGE_BEFORE_RECEIVED,s);case 3:a.push.call(a,e.sent);case 4:e.next=2;break;case 5:e.next=7;break;case 6:e.prev=6,u=e.catch(1),o.e(u);case 7:return e.prev=7,o.f(),e.finish(7);case 8:return null!=t.selected&&(t.selected.receiveComments(n.reverse()),t.sortComments()),e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,null,[[1,6,7,8]])})));return function(t){return e.apply(this,arguments)}}())}},{key:"loadMore",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=this.selected)return t.last_comment_id=e,t.after=!1,this.loadComments(this.selected.id,t)}},{key:"registerDeviceToken",value:(w=s()(d.a.mark((function e(t){var r,n,o=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.length>1&&void 0!==o[1]&&o[1],e.next=1,this.HTTPAdapter.post("api/v2/sdk/set_user_device_token",{device_token:t,device_platform:"rn",is_development:r});case 1:return n=e.sent,e.abrupt("return",n.body.results);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"removeDeviceToken",value:(b=s()(d.a.mark((function e(t){var r,n,o=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.length>1&&void 0!==o[1]&&o[1],e.next=1,this.HTTPAdapter.post("api/v2/sdk/remove_user_device_token",{device_token:t,device_platform:"rn",is_development:r});case 1:return n=e.sent,e.abrupt("return",n.body.results);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"searchMessages",value:(v=s()(d.a.mark((function e(){var t,r,n=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},console.warn("Deprecated: search message will be removed on next release"),e.next=1,this.userAdapter.searchMessages(t);case 1:return r=e.sent,e.abrupt("return",r.map((function(e){return new I(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"updateProfile",value:function(e){var t=this;return this.userAdapter.updateProfile(e).then((function(r){return t.events.emit("profile-updated",e),t.userData=r,Promise.resolve(r)}),(function(e){return t.logger(e)}))}},{key:"getNonce",value:function(){return y.a.post("".concat(this.baseURL,"/api/v2/sdk/auth/nonce")).send().set("qiscus_sdk_app_id","".concat(this.AppId)).set("qiscus_sdk_version","".concat(this.version)).then((function(e){return Promise.resolve(e.body.results)}),(function(e){return Promise.reject(e)}))}},{key:"verifyIdentityToken",value:function(e){return y.a.post("".concat(this.baseURL,"/api/v2/sdk/auth/verify_identity_token")).send({identity_token:e}).set("qiscus_sdk_app_id","".concat(this.AppId)).set("qiscus_sdk_version","".concat(this.version)).then((function(e){return Promise.resolve(e.body.results)}),(function(e){return Promise.reject(e)}))}},{key:"sendComment",value:(m=s()(d.a.mark((function e(t,r,n){var o,i,s,a,u,c,l,f,p,h,m,y,g,v,b,_,w,S,x,E,T,A=this,I=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=I.length>3&&void 0!==I[3]?I[3]:"text",i=I.length>4?I[4]:void 0,s=I.length>5?I[5]:void 0,(a=this).options.prePostCommentCallback&&a.options.prePostCommentCallback(r),a.options.commentFormaterCallback&&(r=a.options.commentFormaterCallback(r)),a.pendingCommentId--,u={room_id:t,message:r,username_as:this.username,username_real:this.user_id,user_avatar_url:this.userData.avatar_url,user_extras:this.userData.user_extras,id:Math.round(1e6*Date.now()+Date.now()),type:o||"text",timestamp:k()(new Date),unique_id:n?String(n):null,payload:se((function(){return JSON.parse(i)}),i,(function(e){return A.logger("Error when parsing payload",e.message)}))},c=a.prepareCommentToBeSubmitted(u),"reply"===o&&(l=JSON.parse(i),f=a.selected.comments.find((function(e){return e.id===l.replied_comment_id})),l.replied_comment_message="reply"===f.type?f.payload.text:f.message,l.replied_comment_sender_username=f.username_as,c.payload=l),p=s||a.extras,e.next=1,this._hookAdapter.trigger(Se.MESSAGE_BEFORE_SENT,Ae(Ae({},c),{},{extras:p}));case 1:return h=e.sent,h=a.prepareCommentToBeSubmitted(h),a.selected&&a.selected.comments.push(h),m=function(){return A.userAdapter.postComment(""+t,h.message,h.unique_id,h.type,h.payload,h.extras)},e.prev=2,e.next=3,m();case 3:return v=e.sent,e.next=4,this._hookAdapter.trigger(Se.MESSAGE_BEFORE_RECEIVED,v);case 4:if(v=e.sent,Object.assign(h,v),a.selected){e.next=5;break}return e.abrupt("return",Promise.resolve(h));case 5:return h.markAsSent(),h.id=v.id,h.before_id=v.comment_before_id,h.unix_timestamp=v.unix_timestamp,null===(y=(g=this.options).commentSentCallback)||void 0===y||y.call(g,{comment:h}),a.events.emit("comment-sent",h),a.sortComments(),(b=a._pendingComments.findIndex((function(e){return e.unique_id===h.unique_id})))>-1&&a._pendingComments.splice(b,1),e.abrupt("return",h);case 6:return e.prev=6,T=e.catch(2),h.markAsFailed(),S=[void 0,408,413,429,500,502,503,504,521,522,524],x=null!==(_=null===(w=T.message)||void 0===w?void 0:w.toLowerCase())&&void 0!==_?_:"",E=x.includes("offline"),(S.includes(T.status)||E)&&(this._pendingComments.push(h),this.logger("Failed sending comment",T)),e.abrupt("return",Promise.reject(T));case 7:case"end":return e.stop()}}),e,this,[[2,6]])}))),function(e,t,r){return m.apply(this,arguments)})},{key:"_retrySendComment",value:(h=s()(d.a.mark((function e(t){var r,n,o,i,a=this;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger("Retrying send comment",t),this._pendingCommentsCount[t.unique_id]=(null!==(r=this._pendingCommentsCount[t.unique_id])&&void 0!==r?r:0)+1,!(this._pendingCommentsCount[t.unique_id]>10)){e.next=1;break}return this.logger("Exceeding maximum retry count for comment ".concat(t.unique_id,", not retrying anymore")),null===(n=(o=this.options).commentRetryExceedCallback)||void 0===n||n.call(o,t),(i=this._pendingComments.findIndex((function(e){return e.unique_id===t.unique_id})))>-1&&this._pendingComments.splice(i,1),t.markAsFailed(),this.events.emit("comment-retry-exceed",t),e.abrupt("return",Promise.reject(new Error("Exceeding maximum retry count")));case 1:return e.abrupt("return",this.userAdapter.postComment(""+t.room_id,t.message,t.unique_id,t.type,t.payload,t.extras).then(function(){var e=s()(d.a.mark((function e(r){var n,o,i,s,u,c;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((null===(n=a.selected)||void 0===n?void 0:n.id)===t.room_id){e.next=1;break}return e.abrupt("return",r);case 1:return Object.assign(t,r),t.markAsSent(),t.id=r.id,t.before_id=r.comment_before_id,t.unix_timestamp=r.unix_timestamp,(u=null===(o=a.selected)||void 0===o?void 0:o.comments.findIndex((function(e){return e.unique_id===t.unique_id})))>-1&&(a.selected.comments[u]=t),a.sortComments(),null===(i=(s=a.options).commentSentCallback)||void 0===i||i.call(s,{comment:t}),a.events.emit("comment-sent",t),(c=a._pendingComments.findIndex((function(e){return e.unique_id===t.unique_id})))>-1&&a._pendingComments.splice(c,1),e.abrupt("return",t);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return t.markAsFailed(),Promise.reject(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"getUsers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return this.HTTPAdapter.get_request("api/v2/sdk/get_user_list").query({query:e,page:t,limit:r}).then((function(e){return Promise.resolve(e.body.results)}))}},{key:"getParticipants",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return this.HTTPAdapter.get_request("api/v2/sdk/room_participants").query({room_unique_id:e,page:t,limit:r}).then((function(e){return e.body.results}))}},{key:"getRoomParticipants",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return console.warn("`getRoomParticipants` are deprecated, use `getParticipants` instead."),this.HTTPAdapter.get_request("api/v2/sdk/room_participants").query({room_unique_id:e,offset:t}).then((function(e){return Promise.resolve(e.body.results)}))}},{key:"resendComment",value:function(e){if(null!=this.selected){var t=this,r=t.selected,n=r.comments.find((function(t){return t.id===e.id})),o=t.extras;return this.userAdapter.postComment(""+r.id,n.message,n.unique_id,e.type,e.payload,o).then((function(e){return n.markAsSent(),n.id=e.id,n.before_id=e.comment_before_id,new Promise((function(e,r){return e(t.selected)}))}),(function(e){return n.markAsFailed(),new Promise((function(t,r){return r(e)}))}))}}},{key:"prepareCommentToBeSubmitted",value:function(e){var t,r;return t=new I(e),r="bq"+Date.now(),e.unique_id&&(r=e.unique_id),t.attachUniqueId(r),t.markAsPending(),t.isDelivered=!1,t.isSent=!1,t.isRead=!1,t.unix_timestamp=Math.round((new Date).getTime()/1e3),t}},{key:"updateRoom",value:function(e){return this.roomAdapter.updateRoom(e)}},{key:"removeSelectedRoomParticipants",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"id";if(_.not.array(e))return Promise.reject(new Error("`values` must have type of array"));var r=this.selected.participants;if(!r)return Promise.reject(new Error("Nothing selected room chat."));var n=r;return"id"===t&&(n=r.filter((function(t){return e.indexOf(t.id)<=-1}))),"email"===t&&(n=r.filter((function(t){return e.indexOf(t.email)<=-1}))),"username"===t&&(n=r.filter((function(t){return e.indexOf(t.username)<=-1}))),this.selected.participants=n,Promise.resolve(r)}},{key:"createGroupRoom",value:function(e,t,r){var n=this;if(!this.isLogin)throw new Error("Please initiate qiscus SDK first");return new A(this.roomAdapter).withName(e).withOptions(r).addParticipants(t).create().then((function(e){return n.events.emit("group-room-created",e),Promise.resolve(e)}))}},{key:"addParticipantsToGroup",value:function(e,t){var r=this;if(!Array.isArray(t))throw new Error("emails' must be type of Array");return r.roomAdapter.addParticipantsToGroup(e,t).then((function(e){return r.events.emit("participants-added",e),Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"removeParticipantsFromGroup",value:function(e,t){var r=this;return _.not.array(t)?Promise.reject(new Error("`emails` must have type of array")):this.roomAdapter.removeParticipantsFromGroup(e,t).then((function(e){return r.events.emit("participants-removed",t),Promise.resolve(e)}))}},{key:"getBlockedUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=this;return r.userAdapter.getBlockedUser(e,t).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"blockUser",value:function(e){var t=this;return t.userAdapter.blockUser(e).then((function(e){return t.events.emit("block-user",e),Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"unblockUser",value:function(e){var t=this;return t.userAdapter.unblockUser(e).then((function(e){return t.events.emit("unblock-user",e),Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"getUserPresences",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(_.not.array(e))return Promise.reject(new Error("`email` must have type of array"));var t=this;return t.userAdapter.getUserPresences(e).then((function(e){return t.events.emit("user-status",e),Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"upload",value:function(e,t){var r=y.a.post(this.uploadURL);return(r=this.HTTPAdapter.setupHeaders(r)).attach("file",e).on("progress",(function(e){"upload"===e.direction&&t(null,e)})).then((function(e){var r=e.body.results.file.url;return t(null,null,e.body.results.file.url),Promise.resolve(r)})).catch((function(e){return t(e),Promise.reject(e)}))}},{key:"uploadFile",value:function(e,t){var r=this,n=new FormData;n.append("file",t);var o=new XMLHttpRequest;o.open("POST","".concat(r.baseURL,"/api/v2/sdk/upload"),!0),o.setRequestHeader("qiscus_sdk_app_id","".concat(r.AppId)),o.setRequestHeader("qiscus_sdk_user_id","".concat(r.user_id)),o.setRequestHeader("qiscus_sdk_token","".concat(r.userData.token)),o.onload=function(){if(200===o.status){var t=JSON.parse(o.response).results.file.url;return r.events.emit("fileupload",t),r.sendComment(e,"[file] ".concat(t," [/file]"))}return Promise.reject(o)},o.send(n)}},{key:"addUploadedFile",value:function(e,t){this.uploadedFiles.push(new Pe(e,t))}},{key:"removeUploadedFile",value:function(e,t){var r=this.uploadedFiles.findIndex((function(r){return r.name===e&&r.roomId===t}));this.uploadedFiles.splice(r,1)}},{key:"publishTyping",value:function(e){this.realtimeAdapter.publishTyping(e)}},{key:"getRoomsInfo",value:function(e){return this.userAdapter.getRoomsInfo(e)}},{key:"deleteComment",value:function(e,t,r,n){var o=this;if(!Array.isArray(t))throw new Error("unique ids' must be type of Array");return this.userAdapter.deleteComment(e,t,r,n).then((function(i){return o.events.emit("comment-deleted",{roomId:e,commentUniqueIds:t,isForEveryone:r,isHard:n}),Promise.resolve(i)}),(function(e){return Promise.reject(e)}))}},{key:"clearRoomsCache",value:function(){var e=this;if(this.selected){this.room_name_id_map=p()({},this.selected.name,this.selected.id);var t=this.rooms.length,r=this.rooms.findIndex((function(t){return t.id===e.selected.id}));r+1!==t&&this.rooms.splice(r+1,t-(r+1)),(r=this.rooms.findIndex((function(t){return t.id===e.selected.id})))>0&&this.rooms.length>1&&this.rooms.splice(1,this.rooms.length-1)}}},{key:"exitChatRoom",value:function(){var e=this;this.realtimeAdapter.unsubscribeTyping(),se((function(){return e.selected.participants.filter((function(t){return t.email!==e.user_id})).map((function(e){return e.email}))}),null,this.noop,(function(t){return t.forEach((function(t){return e.realtimeAdapter.unsubscribeRoomPresence(t)}))})),this.selected=null}},{key:"clearRoomMessages",value:function(e){if(!Array.isArray(e))throw new Error("room_ids must be type of array");return this.userAdapter.clearRoomMessages(e)}},{key:"logging",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.debugMode&&console.log(e,t)}},{key:"getTotalUnreadCount",value:function(){return this.roomAdapter.getTotalUnreadCount().then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"getRoomUnreadCount",value:function(){return this.roomAdapter.getRoomUnreadCount()}},{key:"publishEvent",value:function(){var e;(e=this.customEventAdapter).publishEvent.apply(e,arguments)}},{key:"subscribeEvent",value:function(){var e;(e=this.customEventAdapter).subscribeEvent.apply(e,arguments)}},{key:"unsubscribeEvent",value:function(){var e;(e=this.customEventAdapter).unsubscribeEvent.apply(e,arguments)}},{key:"setCustomHeader",value:function(e){if(_.not.json(e))throw new TypeError("`headers` must have type of object");this._customHeader=e}},{key:"getUserProfile",value:function(){return this.userAdapter.getProfile()}},{key:"Interceptor",get:function(){return Se}},{key:"intercept",value:function(e,t){return this._hookAdapter.intercept(e,t)}},{key:"getThumbnailURL",value:function(e){return e.replace(/^https?:\/\/\S+(\/upload\/)\S+(\.\w+)$/i,(function(e,t,r){return e.replace(t,"/upload/w_320,h_320,c_limit/").replace(r,".png")}))}},{key:"getBlurryThumbnailURL",value:function(e){return e.replace(/^https?:\/\/\S+(\/upload\/)\S+(\.\w+)$/i,(function(e,t,r){return e.replace(t,"/upload/w_320,h_320,c_limit,e_blur:300/").replace(r,".png")}))}},{key:"logger",get:function(){return this.debugMode?console.log.bind(console,"Qiscus ->"):this.noop}},{key:"noop",value:function(){}},{key:"_throttleDelay",get:function(){return this.updateCommentStatusMode===e.UpdateCommentStatusMode.enabled?0:this.updateCommentStatusThrottleDelay||300}},{key:"_updateStatusEnabled",get:function(){return this.updateCommentStatusMode!==e.UpdateCommentStatusMode.disabled}},{key:"_updateStatus",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=null!=r,o=null!=t,i=(null!=this.selected&&this.selected.id,null!=this.selected&&this.selected.isChannel||!1),s=!this._updateStatusEnabled,a=o?"read":n?"receive":void 0,u=!(i||n&&s);if(this.debugMode&&(console.group("update-command-status"),console.log("run:",a,"on: roomId(".concat(e,") commentId(").concat(t||r,")")),console.log("is able to run command?",u),console.groupEnd()),!u)return!1;this.userAdapter.updateCommentStatus(e,t,r).catch((function(e){}))}},{key:"readComment",value:function(t,r){return this.updateCommentStatusMode===e.UpdateCommentStatusMode.enabled?this._readComment(t,r):this._readCommentT(t,r)}},{key:"receiveComment",value:function(t,r){return this.updateCommentStatusMode===e.UpdateCommentStatusMode.enabled?this._deliverComment(t,r):this._deliverCommentT(t,r)}},{key:"_throttle",value:function(e,t){var r=!1;return function(){var n=t();r||(e.apply(void 0,arguments),r=!0,setTimeout((function(){return r=!1}),n))}}},{key:"searchMessage",value:(f=s()(d.a.mark((function e(){var t,r,n,o,i,s,a,u,c,l,f,p,h=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=h.length>0&&void 0!==h[0]?h[0]:{},r=t.query,n=t.roomIds,o=void 0===n?[]:n,i=t.userId,s=t.type,a=t.roomType,u=t.page,c=t.limit,l="api/v2/sdk/search",f=["group","single","channel"].some((function(e){return e===a})),null==a||f){e.next=1;break}return e.abrupt("return",Promise.reject("Invalid room type, valid room type are: `group`, `single`, and `channel`"));case 1:return p=function(e){return{type:null==e?void 0:"single"===e?"single":"group",isPublic:null==e?void 0:"channel"===e}}(a),e.abrupt("return",this.HTTPAdapter.post_json(l,{token:this.token,query:r,sender:i,type:s,room_ids:o.map((function(e){return String(e)})),room_type:p.type||void 0,is_public:p.isPublic||void 0,page:u,limit:c}).then((function(e){return e.body})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"getFileList",value:(c=s()(d.a.mark((function e(){var t,r,n,o,i,s,a,u,c,l,f,p,h=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=h.length>0&&void 0!==h[0]?h[0]:{},r=t.roomIds,n=void 0===r?[]:r,o=t.fileType,i=t.page,s=t.limit,a=t.sender,u=t.userId,c=t.includeExtensions,l=t.excludeExtensions,f="api/v2/sdk/file_list",this.isLogin){e.next=1;break}return e.abrupt("return",Promise.reject("You need to login to use this method"));case 1:return void 0===a&&(a=this.user_id),void 0===u&&(a=u=this.user_id),p={room_ids:n.map((function(e){return String(e)})),file_type:o,page:i,limit:s,include_extensions:c,exclude_extensions:l},null!=a&&(p.sender=a),e.abrupt("return",this.HTTPAdapter.post_json(f,p).then((function(e){return e.body})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"_generateUniqueId",value:function(){return"javascript-".concat(Date.now())}},{key:"generateMessage",value:function(e){var t=e.roomId,r=e.text,n=e.extras,o=Date.now();return new I({id:o,message:r,room_id:t,extras:n,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"text"})}},{key:"generateFileAttachmentMessage",value:function(e){var t=e.roomId,r=e.caption,n=e.url,o=e.text,i=void 0===o?"File attachment":o,s=e.extras,a=e.filename,u=e.size,c=Date.now();return new I({id:c,message:i,room_id:t,extras:s,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"file_attachment",payload:{url:n,file_name:a,size:u,caption:r}})}},{key:"generateCustomMessage",value:function(e){var t=e.roomId,r=e.text,n=e.type,o=e.payload,i=e.extras,s=Date.now();return new I({id:s,message:r,room_id:t,extras:i,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"custom",payload:{type:n,content:o}})}},{key:"generateReplyMessage",value:function(e){var t=e.roomId,r=e.text,n=e.repliedMessage,o=e.extras,i=Date.now();return new I({id:i,message:r,room_id:t,extras:o,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"reply",payload:{text:r,replied_comment_id:n.id,replied_comment_message:n.message,replied_comment_type:n.type,replied_comment_payload:n.payload,replied_comment_sender_username:n.username_as,replied_comment_sender_email:n.username_real}})}},{key:"updateMessage",value:(a=s()(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.userAdapter.updateMessage(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"onMessageUpdated",value:function(e){var t=this;return this.realtimeAdapter.on("message:updated",e),function(){return t.realtimeAdapter.off("message:updated",e)}}},{key:"closeRealtimeConnection",value:(i=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.realtimeAdapter.closeConnection());case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"openRealtimeConnection",value:(n=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.realtimeAdapter.openConnection());case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startSync",value:(r=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._forceEnableSync=!0;case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"stopSync",value:(t=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._forceEnableSync=!1;case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]);var t,r,n,i,a,c,f,h,m,v,b,w,S,E,T}();p()(Re,"UpdateCommentStatusMode",Oe),p()(Re,"Interceptor",Se);var Pe=l()((function e(t,r){u()(this,e),this.name=t,this.roomId=r,this.progress=0}));t.default=Re}]).default}));
11
- //# sourceMappingURL=qiscus-sdk-core.min.js.map
7
+ */(function(R){const S=t,b=k,h=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;R.Buffer=P,R.SlowBuffer=re,R.INSPECT_MAX_BYTES=50;const p=2147483647;R.kMaxLength=p;const{Uint8Array:v,ArrayBuffer:I,SharedArrayBuffer:B}=globalThis;P.TYPED_ARRAY_SUPPORT=H(),!P.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&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 H(){try{const C=new v(1),c={foo:function(){return 42}};return Object.setPrototypeOf(c,v.prototype),Object.setPrototypeOf(C,c),C.foo()===42}catch(C){return!1}}Object.defineProperty(P.prototype,"parent",{enumerable:!0,get:function(){if(P.isBuffer(this))return this.buffer}}),Object.defineProperty(P.prototype,"offset",{enumerable:!0,get:function(){if(P.isBuffer(this))return this.byteOffset}});function V(C){if(C>p)throw new RangeError('The value "'+C+'" is invalid for option "size"');const c=new v(C);return Object.setPrototypeOf(c,P.prototype),c}function P(C,c,y){if(typeof C=="number"){if(typeof c=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return se(C)}return ce(C,c,y)}P.poolSize=8192;function ce(C,c,y){if(typeof C=="string")return he(C,c);if(I.isView(C))return me(C);if(C==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof C);if(Ue(C,I)||C&&Ue(C.buffer,I)||typeof B!="undefined"&&(Ue(C,B)||C&&Ue(C.buffer,B)))return de(C,c,y);if(typeof C=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const U=C.valueOf&&C.valueOf();if(U!=null&&U!==C)return P.from(U,c,y);const Q=be(C);if(Q)return Q;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof C[Symbol.toPrimitive]=="function")return P.from(C[Symbol.toPrimitive]("string"),c,y);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof C)}P.from=function(C,c,y){return ce(C,c,y)},Object.setPrototypeOf(P.prototype,v.prototype),Object.setPrototypeOf(P,v);function oe(C){if(typeof C!="number")throw new TypeError('"size" argument must be of type number');if(C<0)throw new RangeError('The value "'+C+'" is invalid for option "size"')}function ne(C,c,y){return oe(C),C<=0?V(C):c!==void 0?typeof y=="string"?V(C).fill(c,y):V(C).fill(c):V(C)}P.alloc=function(C,c,y){return ne(C,c,y)};function se(C){return oe(C),V(C<0?0:G(C)|0)}P.allocUnsafe=function(C){return se(C)},P.allocUnsafeSlow=function(C){return se(C)};function he(C,c){if((typeof c!="string"||c==="")&&(c="utf8"),!P.isEncoding(c))throw new TypeError("Unknown encoding: "+c);const y=j(C,c)|0;let U=V(y);const Q=U.write(C,c);return Q!==y&&(U=U.slice(0,Q)),U}function J(C){const c=C.length<0?0:G(C.length)|0,y=V(c);for(let U=0;U<c;U+=1)y[U]=C[U]&255;return y}function me(C){if(Ue(C,v)){const c=new v(C);return de(c.buffer,c.byteOffset,c.byteLength)}return J(C)}function de(C,c,y){if(c<0||C.byteLength<c)throw new RangeError('"offset" is outside of buffer bounds');if(C.byteLength<c+(y||0))throw new RangeError('"length" is outside of buffer bounds');let U;return c===void 0&&y===void 0?U=new v(C):y===void 0?U=new v(C,c):U=new v(C,c,y),Object.setPrototypeOf(U,P.prototype),U}function be(C){if(P.isBuffer(C)){const c=G(C.length)|0,y=V(c);return y.length===0||C.copy(y,0,0,c),y}if(C.length!==void 0)return typeof C.length!="number"||Ne(C.length)?V(0):J(C);if(C.type==="Buffer"&&Array.isArray(C.data))return J(C.data)}function G(C){if(C>=p)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+p.toString(16)+" bytes");return C|0}function re(C){return+C!=C&&(C=0),P.alloc(+C)}P.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==P.prototype},P.compare=function(c,y){if(Ue(c,v)&&(c=P.from(c,c.offset,c.byteLength)),Ue(y,v)&&(y=P.from(y,y.offset,y.byteLength)),!P.isBuffer(c)||!P.isBuffer(y))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===y)return 0;let U=c.length,Q=y.length;for(let ie=0,fe=Math.min(U,Q);ie<fe;++ie)if(c[ie]!==y[ie]){U=c[ie],Q=y[ie];break}return U<Q?-1:Q<U?1:0},P.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},P.concat=function(c,y){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return P.alloc(0);let U;if(y===void 0)for(y=0,U=0;U<c.length;++U)y+=c[U].length;const Q=P.allocUnsafe(y);let ie=0;for(U=0;U<c.length;++U){let fe=c[U];if(Ue(fe,v))ie+fe.length>Q.length?(P.isBuffer(fe)||(fe=P.from(fe)),fe.copy(Q,ie)):v.prototype.set.call(Q,fe,ie);else if(P.isBuffer(fe))fe.copy(Q,ie);else throw new TypeError('"list" argument must be an Array of Buffers');ie+=fe.length}return Q};function j(C,c){if(P.isBuffer(C))return C.length;if(I.isView(C)||Ue(C,I))return C.byteLength;if(typeof C!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof C);const y=C.length,U=arguments.length>2&&arguments[2]===!0;if(!U&&y===0)return 0;let Q=!1;for(;;)switch(c){case"ascii":case"latin1":case"binary":return y;case"utf8":case"utf-8":return Ee(C).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y*2;case"hex":return y>>>1;case"base64":return ve(C).length;default:if(Q)return U?-1:Ee(C).length;c=(""+c).toLowerCase(),Q=!0}}P.byteLength=j;function L(C,c,y){let U=!1;if((c===void 0||c<0)&&(c=0),c>this.length||((y===void 0||y>this.length)&&(y=this.length),y<=0)||(y>>>=0,c>>>=0,y<=c))return"";for(C||(C="utf8");;)switch(C){case"hex":return je(this,c,y);case"utf8":case"utf-8":return ye(this,c,y);case"ascii":return Pe(this,c,y);case"latin1":case"binary":return ue(this,c,y);case"base64":return ae(this,c,y);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return De(this,c,y);default:if(U)throw new TypeError("Unknown encoding: "+C);C=(C+"").toLowerCase(),U=!0}}P.prototype._isBuffer=!0;function M(C,c,y){const U=C[c];C[c]=C[y],C[y]=U}P.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let y=0;y<c;y+=2)M(this,y,y+1);return this},P.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let y=0;y<c;y+=4)M(this,y,y+3),M(this,y+1,y+2);return this},P.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let y=0;y<c;y+=8)M(this,y,y+7),M(this,y+1,y+6),M(this,y+2,y+5),M(this,y+3,y+4);return this},P.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?ye(this,0,c):L.apply(this,arguments)},P.prototype.toLocaleString=P.prototype.toString,P.prototype.equals=function(c){if(!P.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:P.compare(this,c)===0},P.prototype.inspect=function(){let c="";const y=R.INSPECT_MAX_BYTES;return c=this.toString("hex",0,y).replace(/(.{2})/g,"$1 ").trim(),this.length>y&&(c+=" ... "),"<Buffer "+c+">"},h&&(P.prototype[h]=P.prototype.inspect),P.prototype.compare=function(c,y,U,Q,ie){if(Ue(c,v)&&(c=P.from(c,c.offset,c.byteLength)),!P.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(y===void 0&&(y=0),U===void 0&&(U=c?c.length:0),Q===void 0&&(Q=0),ie===void 0&&(ie=this.length),y<0||U>c.length||Q<0||ie>this.length)throw new RangeError("out of range index");if(Q>=ie&&y>=U)return 0;if(Q>=ie)return-1;if(y>=U)return 1;if(y>>>=0,U>>>=0,Q>>>=0,ie>>>=0,this===c)return 0;let fe=ie-Q,Ce=U-y;const Ge=Math.min(fe,Ce),We=this.slice(Q,ie),ze=c.slice(y,U);for(let Fe=0;Fe<Ge;++Fe)if(We[Fe]!==ze[Fe]){fe=We[Fe],Ce=ze[Fe];break}return fe<Ce?-1:Ce<fe?1:0};function D(C,c,y,U,Q){if(C.length===0)return-1;if(typeof y=="string"?(U=y,y=0):y>2147483647?y=2147483647:y<-2147483648&&(y=-2147483648),y=+y,Ne(y)&&(y=Q?0:C.length-1),y<0&&(y=C.length+y),y>=C.length){if(Q)return-1;y=C.length-1}else if(y<0)if(Q)y=0;else return-1;if(typeof c=="string"&&(c=P.from(c,U)),P.isBuffer(c))return c.length===0?-1:$(C,c,y,U,Q);if(typeof c=="number")return c=c&255,typeof v.prototype.indexOf=="function"?Q?v.prototype.indexOf.call(C,c,y):v.prototype.lastIndexOf.call(C,c,y):$(C,[c],y,U,Q);throw new TypeError("val must be string, number or Buffer")}function $(C,c,y,U,Q){let ie=1,fe=C.length,Ce=c.length;if(U!==void 0&&(U=String(U).toLowerCase(),U==="ucs2"||U==="ucs-2"||U==="utf16le"||U==="utf-16le")){if(C.length<2||c.length<2)return-1;ie=2,fe/=2,Ce/=2,y/=2}function Ge(ze,Fe){return ie===1?ze[Fe]:ze.readUInt16BE(Fe*ie)}let We;if(Q){let ze=-1;for(We=y;We<fe;We++)if(Ge(C,We)===Ge(c,ze===-1?0:We-ze)){if(ze===-1&&(ze=We),We-ze+1===Ce)return ze*ie}else ze!==-1&&(We-=We-ze),ze=-1}else for(y+Ce>fe&&(y=fe-Ce),We=y;We>=0;We--){let ze=!0;for(let Fe=0;Fe<Ce;Fe++)if(Ge(C,We+Fe)!==Ge(c,Fe)){ze=!1;break}if(ze)return We}return-1}P.prototype.includes=function(c,y,U){return this.indexOf(c,y,U)!==-1},P.prototype.indexOf=function(c,y,U){return D(this,c,y,U,!0)},P.prototype.lastIndexOf=function(c,y,U){return D(this,c,y,U,!1)};function z(C,c,y,U){y=Number(y)||0;const Q=C.length-y;U?(U=Number(U),U>Q&&(U=Q)):U=Q;const ie=c.length;U>ie/2&&(U=ie/2);let fe;for(fe=0;fe<U;++fe){const Ce=parseInt(c.substr(fe*2,2),16);if(Ne(Ce))return fe;C[y+fe]=Ce}return fe}function Y(C,c,y,U){return Ve(Ee(c,C.length-y),C,y,U)}function T(C,c,y,U){return Ve(Ae(c),C,y,U)}function O(C,c,y,U){return Ve(ve(c),C,y,U)}function ee(C,c,y,U){return Ve(_e(c,C.length-y),C,y,U)}P.prototype.write=function(c,y,U,Q){if(y===void 0)Q="utf8",U=this.length,y=0;else if(U===void 0&&typeof y=="string")Q=y,U=this.length,y=0;else if(isFinite(y))y=y>>>0,isFinite(U)?(U=U>>>0,Q===void 0&&(Q="utf8")):(Q=U,U=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ie=this.length-y;if((U===void 0||U>ie)&&(U=ie),c.length>0&&(U<0||y<0)||y>this.length)throw new RangeError("Attempt to write outside buffer bounds");Q||(Q="utf8");let fe=!1;for(;;)switch(Q){case"hex":return z(this,c,y,U);case"utf8":case"utf-8":return Y(this,c,y,U);case"ascii":case"latin1":case"binary":return T(this,c,y,U);case"base64":return O(this,c,y,U);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ee(this,c,y,U);default:if(fe)throw new TypeError("Unknown encoding: "+Q);Q=(""+Q).toLowerCase(),fe=!0}},P.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ae(C,c,y){return c===0&&y===C.length?S.fromByteArray(C):S.fromByteArray(C.slice(c,y))}function ye(C,c,y){y=Math.min(C.length,y);const U=[];let Q=c;for(;Q<y;){const ie=C[Q];let fe=null,Ce=ie>239?4:ie>223?3:ie>191?2:1;if(Q+Ce<=y){let Ge,We,ze,Fe;switch(Ce){case 1:ie<128&&(fe=ie);break;case 2:Ge=C[Q+1],(Ge&192)===128&&(Fe=(ie&31)<<6|Ge&63,Fe>127&&(fe=Fe));break;case 3:Ge=C[Q+1],We=C[Q+2],(Ge&192)===128&&(We&192)===128&&(Fe=(ie&15)<<12|(Ge&63)<<6|We&63,Fe>2047&&(Fe<55296||Fe>57343)&&(fe=Fe));break;case 4:Ge=C[Q+1],We=C[Q+2],ze=C[Q+3],(Ge&192)===128&&(We&192)===128&&(ze&192)===128&&(Fe=(ie&15)<<18|(Ge&63)<<12|(We&63)<<6|ze&63,Fe>65535&&Fe<1114112&&(fe=Fe))}}fe===null?(fe=65533,Ce=1):fe>65535&&(fe-=65536,U.push(fe>>>10&1023|55296),fe=56320|fe&1023),U.push(fe),Q+=Ce}return Se(U)}const le=4096;function Se(C){const c=C.length;if(c<=le)return String.fromCharCode.apply(String,C);let y="",U=0;for(;U<c;)y+=String.fromCharCode.apply(String,C.slice(U,U+=le));return y}function Pe(C,c,y){let U="";y=Math.min(C.length,y);for(let Q=c;Q<y;++Q)U+=String.fromCharCode(C[Q]&127);return U}function ue(C,c,y){let U="";y=Math.min(C.length,y);for(let Q=c;Q<y;++Q)U+=String.fromCharCode(C[Q]);return U}function je(C,c,y){const U=C.length;(!c||c<0)&&(c=0),(!y||y<0||y>U)&&(y=U);let Q="";for(let ie=c;ie<y;++ie)Q+=ot[C[ie]];return Q}function De(C,c,y){const U=C.slice(c,y);let Q="";for(let ie=0;ie<U.length-1;ie+=2)Q+=String.fromCharCode(U[ie]+U[ie+1]*256);return Q}P.prototype.slice=function(c,y){const U=this.length;c=~~c,y=y===void 0?U:~~y,c<0?(c+=U,c<0&&(c=0)):c>U&&(c=U),y<0?(y+=U,y<0&&(y=0)):y>U&&(y=U),y<c&&(y=c);const Q=this.subarray(c,y);return Object.setPrototypeOf(Q,P.prototype),Q};function K(C,c,y){if(C%1!==0||C<0)throw new RangeError("offset is not uint");if(C+c>y)throw new RangeError("Trying to access beyond buffer length")}P.prototype.readUintLE=P.prototype.readUIntLE=function(c,y,U){c=c>>>0,y=y>>>0,U||K(c,y,this.length);let Q=this[c],ie=1,fe=0;for(;++fe<y&&(ie*=256);)Q+=this[c+fe]*ie;return Q},P.prototype.readUintBE=P.prototype.readUIntBE=function(c,y,U){c=c>>>0,y=y>>>0,U||K(c,y,this.length);let Q=this[c+--y],ie=1;for(;y>0&&(ie*=256);)Q+=this[c+--y]*ie;return Q},P.prototype.readUint8=P.prototype.readUInt8=function(c,y){return c=c>>>0,y||K(c,1,this.length),this[c]},P.prototype.readUint16LE=P.prototype.readUInt16LE=function(c,y){return c=c>>>0,y||K(c,2,this.length),this[c]|this[c+1]<<8},P.prototype.readUint16BE=P.prototype.readUInt16BE=function(c,y){return c=c>>>0,y||K(c,2,this.length),this[c]<<8|this[c+1]},P.prototype.readUint32LE=P.prototype.readUInt32LE=function(c,y){return c=c>>>0,y||K(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},P.prototype.readUint32BE=P.prototype.readUInt32BE=function(c,y){return c=c>>>0,y||K(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},P.prototype.readBigUInt64LE=Qe(function(c){c=c>>>0,W(c,"offset");const y=this[c],U=this[c+7];(y===void 0||U===void 0)&&te(c,this.length-8);const Q=y+this[++c]*Oe(2,8)+this[++c]*Oe(2,16)+this[++c]*Oe(2,24),ie=this[++c]+this[++c]*Oe(2,8)+this[++c]*Oe(2,16)+U*Oe(2,24);return BigInt(Q)+(BigInt(ie)<<BigInt(32))}),P.prototype.readBigUInt64BE=Qe(function(c){c=c>>>0,W(c,"offset");const y=this[c],U=this[c+7];(y===void 0||U===void 0)&&te(c,this.length-8);const Q=y*Oe(2,24)+this[++c]*Oe(2,16)+this[++c]*Oe(2,8)+this[++c],ie=this[++c]*Oe(2,24)+this[++c]*Oe(2,16)+this[++c]*Oe(2,8)+U;return(BigInt(Q)<<BigInt(32))+BigInt(ie)}),P.prototype.readIntLE=function(c,y,U){c=c>>>0,y=y>>>0,U||K(c,y,this.length);let Q=this[c],ie=1,fe=0;for(;++fe<y&&(ie*=256);)Q+=this[c+fe]*ie;return ie*=128,Q>=ie&&(Q-=Math.pow(2,8*y)),Q},P.prototype.readIntBE=function(c,y,U){c=c>>>0,y=y>>>0,U||K(c,y,this.length);let Q=y,ie=1,fe=this[c+--Q];for(;Q>0&&(ie*=256);)fe+=this[c+--Q]*ie;return ie*=128,fe>=ie&&(fe-=Math.pow(2,8*y)),fe},P.prototype.readInt8=function(c,y){return c=c>>>0,y||K(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},P.prototype.readInt16LE=function(c,y){c=c>>>0,y||K(c,2,this.length);const U=this[c]|this[c+1]<<8;return U&32768?U|4294901760:U},P.prototype.readInt16BE=function(c,y){c=c>>>0,y||K(c,2,this.length);const U=this[c+1]|this[c]<<8;return U&32768?U|4294901760:U},P.prototype.readInt32LE=function(c,y){return c=c>>>0,y||K(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},P.prototype.readInt32BE=function(c,y){return c=c>>>0,y||K(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},P.prototype.readBigInt64LE=Qe(function(c){c=c>>>0,W(c,"offset");const y=this[c],U=this[c+7];(y===void 0||U===void 0)&&te(c,this.length-8);const Q=this[c+4]+this[c+5]*Oe(2,8)+this[c+6]*Oe(2,16)+(U<<24);return(BigInt(Q)<<BigInt(32))+BigInt(y+this[++c]*Oe(2,8)+this[++c]*Oe(2,16)+this[++c]*Oe(2,24))}),P.prototype.readBigInt64BE=Qe(function(c){c=c>>>0,W(c,"offset");const y=this[c],U=this[c+7];(y===void 0||U===void 0)&&te(c,this.length-8);const Q=(y<<24)+this[++c]*Oe(2,16)+this[++c]*Oe(2,8)+this[++c];return(BigInt(Q)<<BigInt(32))+BigInt(this[++c]*Oe(2,24)+this[++c]*Oe(2,16)+this[++c]*Oe(2,8)+U)}),P.prototype.readFloatLE=function(c,y){return c=c>>>0,y||K(c,4,this.length),b.read(this,c,!0,23,4)},P.prototype.readFloatBE=function(c,y){return c=c>>>0,y||K(c,4,this.length),b.read(this,c,!1,23,4)},P.prototype.readDoubleLE=function(c,y){return c=c>>>0,y||K(c,8,this.length),b.read(this,c,!0,52,8)},P.prototype.readDoubleBE=function(c,y){return c=c>>>0,y||K(c,8,this.length),b.read(this,c,!1,52,8)};function pe(C,c,y,U,Q,ie){if(!P.isBuffer(C))throw new TypeError('"buffer" argument must be a Buffer instance');if(c>Q||c<ie)throw new RangeError('"value" argument is out of bounds');if(y+U>C.length)throw new RangeError("Index out of range")}P.prototype.writeUintLE=P.prototype.writeUIntLE=function(c,y,U,Q){if(c=+c,y=y>>>0,U=U>>>0,!Q){const Ce=Math.pow(2,8*U)-1;pe(this,c,y,U,Ce,0)}let ie=1,fe=0;for(this[y]=c&255;++fe<U&&(ie*=256);)this[y+fe]=c/ie&255;return y+U},P.prototype.writeUintBE=P.prototype.writeUIntBE=function(c,y,U,Q){if(c=+c,y=y>>>0,U=U>>>0,!Q){const Ce=Math.pow(2,8*U)-1;pe(this,c,y,U,Ce,0)}let ie=U-1,fe=1;for(this[y+ie]=c&255;--ie>=0&&(fe*=256);)this[y+ie]=c/fe&255;return y+U},P.prototype.writeUint8=P.prototype.writeUInt8=function(c,y,U){return c=+c,y=y>>>0,U||pe(this,c,y,1,255,0),this[y]=c&255,y+1},P.prototype.writeUint16LE=P.prototype.writeUInt16LE=function(c,y,U){return c=+c,y=y>>>0,U||pe(this,c,y,2,65535,0),this[y]=c&255,this[y+1]=c>>>8,y+2},P.prototype.writeUint16BE=P.prototype.writeUInt16BE=function(c,y,U){return c=+c,y=y>>>0,U||pe(this,c,y,2,65535,0),this[y]=c>>>8,this[y+1]=c&255,y+2},P.prototype.writeUint32LE=P.prototype.writeUInt32LE=function(c,y,U){return c=+c,y=y>>>0,U||pe(this,c,y,4,4294967295,0),this[y+3]=c>>>24,this[y+2]=c>>>16,this[y+1]=c>>>8,this[y]=c&255,y+4},P.prototype.writeUint32BE=P.prototype.writeUInt32BE=function(c,y,U){return c=+c,y=y>>>0,U||pe(this,c,y,4,4294967295,0),this[y]=c>>>24,this[y+1]=c>>>16,this[y+2]=c>>>8,this[y+3]=c&255,y+4};function X(C,c,y,U,Q){F(c,U,Q,C,y,7);let ie=Number(c&BigInt(4294967295));C[y++]=ie,ie=ie>>8,C[y++]=ie,ie=ie>>8,C[y++]=ie,ie=ie>>8,C[y++]=ie;let fe=Number(c>>BigInt(32)&BigInt(4294967295));return C[y++]=fe,fe=fe>>8,C[y++]=fe,fe=fe>>8,C[y++]=fe,fe=fe>>8,C[y++]=fe,y}function Te(C,c,y,U,Q){F(c,U,Q,C,y,7);let ie=Number(c&BigInt(4294967295));C[y+7]=ie,ie=ie>>8,C[y+6]=ie,ie=ie>>8,C[y+5]=ie,ie=ie>>8,C[y+4]=ie;let fe=Number(c>>BigInt(32)&BigInt(4294967295));return C[y+3]=fe,fe=fe>>8,C[y+2]=fe,fe=fe>>8,C[y+1]=fe,fe=fe>>8,C[y]=fe,y+8}P.prototype.writeBigUInt64LE=Qe(function(c,y=0){return X(this,c,y,BigInt(0),BigInt("0xffffffffffffffff"))}),P.prototype.writeBigUInt64BE=Qe(function(c,y=0){return Te(this,c,y,BigInt(0),BigInt("0xffffffffffffffff"))}),P.prototype.writeIntLE=function(c,y,U,Q){if(c=+c,y=y>>>0,!Q){const Ge=Math.pow(2,8*U-1);pe(this,c,y,U,Ge-1,-Ge)}let ie=0,fe=1,Ce=0;for(this[y]=c&255;++ie<U&&(fe*=256);)c<0&&Ce===0&&this[y+ie-1]!==0&&(Ce=1),this[y+ie]=(c/fe>>0)-Ce&255;return y+U},P.prototype.writeIntBE=function(c,y,U,Q){if(c=+c,y=y>>>0,!Q){const Ge=Math.pow(2,8*U-1);pe(this,c,y,U,Ge-1,-Ge)}let ie=U-1,fe=1,Ce=0;for(this[y+ie]=c&255;--ie>=0&&(fe*=256);)c<0&&Ce===0&&this[y+ie+1]!==0&&(Ce=1),this[y+ie]=(c/fe>>0)-Ce&255;return y+U},P.prototype.writeInt8=function(c,y,U){return c=+c,y=y>>>0,U||pe(this,c,y,1,127,-128),c<0&&(c=255+c+1),this[y]=c&255,y+1},P.prototype.writeInt16LE=function(c,y,U){return c=+c,y=y>>>0,U||pe(this,c,y,2,32767,-32768),this[y]=c&255,this[y+1]=c>>>8,y+2},P.prototype.writeInt16BE=function(c,y,U){return c=+c,y=y>>>0,U||pe(this,c,y,2,32767,-32768),this[y]=c>>>8,this[y+1]=c&255,y+2},P.prototype.writeInt32LE=function(c,y,U){return c=+c,y=y>>>0,U||pe(this,c,y,4,2147483647,-2147483648),this[y]=c&255,this[y+1]=c>>>8,this[y+2]=c>>>16,this[y+3]=c>>>24,y+4},P.prototype.writeInt32BE=function(c,y,U){return c=+c,y=y>>>0,U||pe(this,c,y,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[y]=c>>>24,this[y+1]=c>>>16,this[y+2]=c>>>8,this[y+3]=c&255,y+4},P.prototype.writeBigInt64LE=Qe(function(c,y=0){return X(this,c,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),P.prototype.writeBigInt64BE=Qe(function(c,y=0){return Te(this,c,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function qe(C,c,y,U,Q,ie){if(y+U>C.length)throw new RangeError("Index out of range");if(y<0)throw new RangeError("Index out of range")}function $e(C,c,y,U,Q){return c=+c,y=y>>>0,Q||qe(C,c,y,4),b.write(C,c,y,U,23,4),y+4}P.prototype.writeFloatLE=function(c,y,U){return $e(this,c,y,!0,U)},P.prototype.writeFloatBE=function(c,y,U){return $e(this,c,y,!1,U)};function Be(C,c,y,U,Q){return c=+c,y=y>>>0,Q||qe(C,c,y,8),b.write(C,c,y,U,52,8),y+8}P.prototype.writeDoubleLE=function(c,y,U){return Be(this,c,y,!0,U)},P.prototype.writeDoubleBE=function(c,y,U){return Be(this,c,y,!1,U)},P.prototype.copy=function(c,y,U,Q){if(!P.isBuffer(c))throw new TypeError("argument should be a Buffer");if(U||(U=0),!Q&&Q!==0&&(Q=this.length),y>=c.length&&(y=c.length),y||(y=0),Q>0&&Q<U&&(Q=U),Q===U||c.length===0||this.length===0)return 0;if(y<0)throw new RangeError("targetStart out of bounds");if(U<0||U>=this.length)throw new RangeError("Index out of range");if(Q<0)throw new RangeError("sourceEnd out of bounds");Q>this.length&&(Q=this.length),c.length-y<Q-U&&(Q=c.length-y+U);const ie=Q-U;return this===c&&typeof v.prototype.copyWithin=="function"?this.copyWithin(y,U,Q):v.prototype.set.call(c,this.subarray(U,Q),y),ie},P.prototype.fill=function(c,y,U,Q){if(typeof c=="string"){if(typeof y=="string"?(Q=y,y=0,U=this.length):typeof U=="string"&&(Q=U,U=this.length),Q!==void 0&&typeof Q!="string")throw new TypeError("encoding must be a string");if(typeof Q=="string"&&!P.isEncoding(Q))throw new TypeError("Unknown encoding: "+Q);if(c.length===1){const fe=c.charCodeAt(0);(Q==="utf8"&&fe<128||Q==="latin1")&&(c=fe)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(y<0||this.length<y||this.length<U)throw new RangeError("Out of range index");if(U<=y)return this;y=y>>>0,U=U===void 0?this.length:U>>>0,c||(c=0);let ie;if(typeof c=="number")for(ie=y;ie<U;++ie)this[ie]=c;else{const fe=P.isBuffer(c)?c:P.from(c,Q),Ce=fe.length;if(Ce===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(ie=0;ie<U-y;++ie)this[ie+y]=fe[ie%Ce]}return this};const Ie={};function x(C,c,y){Ie[C]=class extends y{constructor(){super(),Object.defineProperty(this,"message",{value:c.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${C}]`,this.stack,delete this.name}get code(){return C}set code(Q){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:Q,writable:!0})}toString(){return`${this.name} [${C}]: ${this.message}`}}}x("ERR_BUFFER_OUT_OF_BOUNDS",function(C){return C?`${C} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),x("ERR_INVALID_ARG_TYPE",function(C,c){return`The "${C}" argument must be of type number. Received type ${typeof c}`},TypeError),x("ERR_OUT_OF_RANGE",function(C,c,y){let U=`The value of "${C}" is out of range.`,Q=y;return Number.isInteger(y)&&Math.abs(y)>Oe(2,32)?Q=f(String(y)):typeof y=="bigint"&&(Q=String(y),(y>Oe(BigInt(2),BigInt(32))||y<-Oe(BigInt(2),BigInt(32)))&&(Q=f(Q)),Q+="n"),U+=` It must be ${c}. Received ${Q}`,U},RangeError);function f(C){let c="",y=C.length;const U=C[0]==="-"?1:0;for(;y>=U+4;y-=3)c=`_${C.slice(y-3,y)}${c}`;return`${C.slice(0,y)}${c}`}function m(C,c,y){W(c,"offset"),(C[c]===void 0||C[c+y]===void 0)&&te(c,C.length-(y+1))}function F(C,c,y,U,Q,ie){if(C>y||C<c){const fe=typeof c=="bigint"?"n":"";let Ce;throw c===0||c===BigInt(0)?Ce=`>= 0${fe} and < 2${fe} ** ${(ie+1)*8}${fe}`:Ce=`>= -(2${fe} ** ${(ie+1)*8-1}${fe}) and < 2 ** ${(ie+1)*8-1}${fe}`,new Ie.ERR_OUT_OF_RANGE("value",Ce,C)}m(U,Q,ie)}function W(C,c){if(typeof C!="number")throw new Ie.ERR_INVALID_ARG_TYPE(c,"number",C)}function te(C,c,y){throw Math.floor(C)!==C?(W(C,y),new Ie.ERR_OUT_OF_RANGE("offset","an integer",C)):c<0?new Ie.ERR_BUFFER_OUT_OF_BOUNDS:new Ie.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${c}`,C)}const N=/[^+/0-9A-Za-z-_]/g;function Z(C){if(C=C.split("=")[0],C=C.trim().replace(N,""),C.length<2)return"";for(;C.length%4!==0;)C=C+"=";return C}function Ee(C,c){c=c||1/0;let y;const U=C.length;let Q=null;const ie=[];for(let fe=0;fe<U;++fe){if(y=C.charCodeAt(fe),y>55295&&y<57344){if(!Q){if(y>56319){(c-=3)>-1&&ie.push(239,191,189);continue}else if(fe+1===U){(c-=3)>-1&&ie.push(239,191,189);continue}Q=y;continue}if(y<56320){(c-=3)>-1&&ie.push(239,191,189),Q=y;continue}y=(Q-55296<<10|y-56320)+65536}else Q&&(c-=3)>-1&&ie.push(239,191,189);if(Q=null,y<128){if((c-=1)<0)break;ie.push(y)}else if(y<2048){if((c-=2)<0)break;ie.push(y>>6|192,y&63|128)}else if(y<65536){if((c-=3)<0)break;ie.push(y>>12|224,y>>6&63|128,y&63|128)}else if(y<1114112){if((c-=4)<0)break;ie.push(y>>18|240,y>>12&63|128,y>>6&63|128,y&63|128)}else throw new Error("Invalid code point")}return ie}function Ae(C){const c=[];for(let y=0;y<C.length;++y)c.push(C.charCodeAt(y)&255);return c}function _e(C,c){let y,U,Q;const ie=[];for(let fe=0;fe<C.length&&!((c-=2)<0);++fe)y=C.charCodeAt(fe),U=y>>8,Q=y%256,ie.push(Q),ie.push(U);return ie}function ve(C){return S.toByteArray(Z(C))}function Ve(C,c,y,U){let Q;for(Q=0;Q<U&&!(Q+y>=c.length||Q>=C.length);++Q)c[Q+y]=C[Q];return Q}function Ue(C,c){return C instanceof c||C!=null&&C.constructor!=null&&C.constructor.name!=null&&C.constructor.name===c.name}function Ne(C){return C!==C}const ot=(function(){const C="0123456789abcdef",c=new Array(256);for(let y=0;y<16;++y){const U=y*16;for(let Q=0;Q<16;++Q)c[U+Q]=C[y]+C[Q]}return c})();function Qe(C){return typeof BigInt=="undefined"?Je:C}function Je(){throw new Error("BigInt not supported")}})(e);const A=e.Buffer;i.Blob=e.Blob,i.BlobOptions=e.BlobOptions,i.Buffer=e.Buffer,i.File=e.File,i.FileOptions=e.FileOptions,i.INSPECT_MAX_BYTES=e.INSPECT_MAX_BYTES,i.SlowBuffer=e.SlowBuffer,i.TranscodeEncoding=e.TranscodeEncoding,i.atob=e.atob,i.btoa=e.btoa,i.constants=e.constants,i.default=A,i.isAscii=e.isAscii,i.isUtf8=e.isUtf8,i.kMaxLength=e.kMaxLength,i.kStringMaxLength=e.kStringMaxLength,i.resolveObjectURL=e.resolveObjectURL,i.transcode=e.transcode})(Ho)),Ho}var Wo={},Yo={},Go,oh;function sh(){return oh||(oh=1,Go=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var n=42;e[t]=n;for(var o in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var u=Object.getOwnPropertySymbols(e);if(u.length!==1||u[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==n||a.enumerable!==!0)return!1}return!0}),Go}var zo,ah;function ar(){if(ah)return zo;ah=1;var i=sh();return zo=function(){return i()&&!!Symbol.toStringTag},zo}var Vo,uh;function fh(){return uh||(uh=1,Vo=Object),Vo}var Ko,lh;function bg(){return lh||(lh=1,Ko=Error),Ko}var Qo,ch;function wg(){return ch||(ch=1,Qo=EvalError),Qo}var Jo,hh;function Sg(){return hh||(hh=1,Jo=RangeError),Jo}var Xo,dh;function Eg(){return dh||(dh=1,Xo=ReferenceError),Xo}var Zo,ph;function mh(){return ph||(ph=1,Zo=SyntaxError),Zo}var es,yh;function gt(){return yh||(yh=1,es=TypeError),es}var ts,gh;function Ig(){return gh||(gh=1,ts=URIError),ts}var rs,_h;function Tg(){return _h||(_h=1,rs=Math.abs),rs}var ns,vh;function Rg(){return vh||(vh=1,ns=Math.floor),ns}var is,bh;function Ag(){return bh||(bh=1,is=Math.max),is}var os,wh;function Og(){return wh||(wh=1,os=Math.min),os}var ss,Sh;function xg(){return Sh||(Sh=1,ss=Math.pow),ss}var as,Eh;function Cg(){return Eh||(Eh=1,as=Math.round),as}var us,Ih;function kg(){return Ih||(Ih=1,us=Number.isNaN||function(e){return e!==e}),us}var fs,Th;function qg(){if(Th)return fs;Th=1;var i=kg();return fs=function(t){return i(t)||t===0?t:t<0?-1:1},fs}var ls,Rh;function Mg(){return Rh||(Rh=1,ls=Object.getOwnPropertyDescriptor),ls}var cs,Ah;function qt(){if(Ah)return cs;Ah=1;var i=Mg();if(i)try{i([],"length")}catch(e){i=null}return cs=i,cs}var hs,Oh;function ur(){if(Oh)return hs;Oh=1;var i=Object.defineProperty||!1;if(i)try{i({},"a",{value:1})}catch(e){i=!1}return hs=i,hs}var ds,xh;function Pg(){if(xh)return ds;xh=1;var i=typeof Symbol!="undefined"&&Symbol,e=sh();return ds=function(){return typeof i!="function"||typeof Symbol!="function"||typeof i("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},ds}var ps,Ch;function kh(){return Ch||(Ch=1,ps=typeof Reflect!="undefined"&&Reflect.getPrototypeOf||null),ps}var ms,qh;function Mh(){if(qh)return ms;qh=1;var i=fh();return ms=i.getPrototypeOf||null,ms}var ys,Ph;function Bg(){if(Ph)return ys;Ph=1;var i="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,t=Math.max,r="[object Function]",n=function(s,l){for(var d=[],_=0;_<s.length;_+=1)d[_]=s[_];for(var g=0;g<l.length;g+=1)d[g+s.length]=l[g];return d},o=function(s,l){for(var d=[],_=l,g=0;_<s.length;_+=1,g+=1)d[g]=s[_];return d},u=function(a,s){for(var l="",d=0;d<a.length;d+=1)l+=a[d],d+1<a.length&&(l+=s);return l};return ys=function(s){var l=this;if(typeof l!="function"||e.apply(l)!==r)throw new TypeError(i+l);for(var d=o(arguments,1),_,g=function(){if(this instanceof _){var A=l.apply(this,n(d,arguments));return Object(A)===A?A:this}return l.apply(s,n(d,arguments))},E=t(0,l.length-d.length),w=[],q=0;q<E;q++)w[q]="$"+q;if(_=Function("binder","return function ("+u(w,",")+"){ return binder.apply(this,arguments); }")(g),l.prototype){var k=function(){};k.prototype=l.prototype,_.prototype=new k,k.prototype=null}return _},ys}var gs,Bh;function Vt(){if(Bh)return gs;Bh=1;var i=Bg();return gs=Function.prototype.bind||i,gs}var _s,Dh;function vs(){return Dh||(Dh=1,_s=Function.prototype.call),_s}var bs,Lh;function ws(){return Lh||(Lh=1,bs=Function.prototype.apply),bs}var Ss,Fh;function Dg(){return Fh||(Fh=1,Ss=typeof Reflect!="undefined"&&Reflect&&Reflect.apply),Ss}var Es,Uh;function Nh(){if(Uh)return Es;Uh=1;var i=Vt(),e=ws(),t=vs(),r=Dg();return Es=r||i.call(t,e),Es}var Is,jh;function Ts(){if(jh)return Is;jh=1;var i=Vt(),e=gt(),t=vs(),r=Nh();return Is=function(o){if(o.length<1||typeof o[0]!="function")throw new e("a function is required");return r(i,t,o)},Is}var Rs,$h;function Lg(){if($h)return Rs;$h=1;var i=Ts(),e=qt(),t;try{t=[].__proto__===Array.prototype}catch(u){if(!u||typeof u!="object"||!("code"in u)||u.code!=="ERR_PROTO_ACCESS")throw u}var r=!!t&&e&&e(Object.prototype,"__proto__"),n=Object,o=n.getPrototypeOf;return Rs=r&&typeof r.get=="function"?i([r.get]):typeof o=="function"?function(a){return o(a==null?a:n(a))}:!1,Rs}var As,Hh;function Os(){if(Hh)return As;Hh=1;var i=kh(),e=Mh(),t=Lg();return As=i?function(n){return i(n)}:e?function(n){if(!n||typeof n!="object"&&typeof n!="function")throw new TypeError("getProto: not an object");return e(n)}:t?function(n){return t(n)}:null,As}var xs,Wh;function Yh(){if(Wh)return xs;Wh=1;var i=Function.prototype.call,e=Object.prototype.hasOwnProperty,t=Vt();return xs=t.call(i,e),xs}var Cs,Gh;function fr(){if(Gh)return Cs;Gh=1;var i,e=fh(),t=bg(),r=wg(),n=Sg(),o=Eg(),u=mh(),a=gt(),s=Ig(),l=Tg(),d=Rg(),_=Ag(),g=Og(),E=xg(),w=Cg(),q=qg(),k=Function,A=function(z){try{return k('"use strict"; return ('+z+").constructor;")()}catch(Y){}},R=qt(),S=ur(),b=function(){throw new a},h=R?(function(){try{return arguments.callee,b}catch(z){try{return R(arguments,"callee").get}catch(Y){return b}}})():b,p=Pg()(),v=Os(),I=Mh(),B=kh(),H=ws(),V=vs(),P={},ce=typeof Uint8Array=="undefined"||!v?i:v(Uint8Array),oe={__proto__:null,"%AggregateError%":typeof AggregateError=="undefined"?i:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?i:ArrayBuffer,"%ArrayIteratorPrototype%":p&&v?v([][Symbol.iterator]()):i,"%AsyncFromSyncIteratorPrototype%":i,"%AsyncFunction%":P,"%AsyncGenerator%":P,"%AsyncGeneratorFunction%":P,"%AsyncIteratorPrototype%":P,"%Atomics%":typeof Atomics=="undefined"?i:Atomics,"%BigInt%":typeof BigInt=="undefined"?i:BigInt,"%BigInt64Array%":typeof BigInt64Array=="undefined"?i:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array=="undefined"?i:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?i:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":r,"%Float16Array%":typeof Float16Array=="undefined"?i:Float16Array,"%Float32Array%":typeof Float32Array=="undefined"?i:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?i:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?i:FinalizationRegistry,"%Function%":k,"%GeneratorFunction%":P,"%Int8Array%":typeof Int8Array=="undefined"?i:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?i:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?i:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":p&&v?v(v([][Symbol.iterator]())):i,"%JSON%":typeof JSON=="object"?JSON:i,"%Map%":typeof Map=="undefined"?i:Map,"%MapIteratorPrototype%":typeof Map=="undefined"||!p||!v?i:v(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":R,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?i:Promise,"%Proxy%":typeof Proxy=="undefined"?i:Proxy,"%RangeError%":n,"%ReferenceError%":o,"%Reflect%":typeof Reflect=="undefined"?i:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?i:Set,"%SetIteratorPrototype%":typeof Set=="undefined"||!p||!v?i:v(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?i:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":p&&v?v(""[Symbol.iterator]()):i,"%Symbol%":p?Symbol:i,"%SyntaxError%":u,"%ThrowTypeError%":h,"%TypedArray%":ce,"%TypeError%":a,"%Uint8Array%":typeof Uint8Array=="undefined"?i:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?i:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?i:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?i:Uint32Array,"%URIError%":s,"%WeakMap%":typeof WeakMap=="undefined"?i:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?i:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?i:WeakSet,"%Function.prototype.call%":V,"%Function.prototype.apply%":H,"%Object.defineProperty%":S,"%Object.getPrototypeOf%":I,"%Math.abs%":l,"%Math.floor%":d,"%Math.max%":_,"%Math.min%":g,"%Math.pow%":E,"%Math.round%":w,"%Math.sign%":q,"%Reflect.getPrototypeOf%":B};if(v)try{null.error}catch(z){var ne=v(v(z));oe["%Error.prototype%"]=ne}var se=function z(Y){var T;if(Y==="%AsyncFunction%")T=A("async function () {}");else if(Y==="%GeneratorFunction%")T=A("function* () {}");else if(Y==="%AsyncGeneratorFunction%")T=A("async function* () {}");else if(Y==="%AsyncGenerator%"){var O=z("%AsyncGeneratorFunction%");O&&(T=O.prototype)}else if(Y==="%AsyncIteratorPrototype%"){var ee=z("%AsyncGenerator%");ee&&v&&(T=v(ee.prototype))}return oe[Y]=T,T},he={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},J=Vt(),me=Yh(),de=J.call(V,Array.prototype.concat),be=J.call(H,Array.prototype.splice),G=J.call(V,String.prototype.replace),re=J.call(V,String.prototype.slice),j=J.call(V,RegExp.prototype.exec),L=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,M=/\\(\\)?/g,D=function(Y){var T=re(Y,0,1),O=re(Y,-1);if(T==="%"&&O!=="%")throw new u("invalid intrinsic syntax, expected closing `%`");if(O==="%"&&T!=="%")throw new u("invalid intrinsic syntax, expected opening `%`");var ee=[];return G(Y,L,function(ae,ye,le,Se){ee[ee.length]=le?G(Se,M,"$1"):ye||ae}),ee},$=function(Y,T){var O=Y,ee;if(me(he,O)&&(ee=he[O],O="%"+ee[0]+"%"),me(oe,O)){var ae=oe[O];if(ae===P&&(ae=se(O)),typeof ae=="undefined"&&!T)throw new a("intrinsic "+Y+" exists, but is not available. Please file an issue!");return{alias:ee,name:O,value:ae}}throw new u("intrinsic "+Y+" does not exist!")};return Cs=function(Y,T){if(typeof Y!="string"||Y.length===0)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof T!="boolean")throw new a('"allowMissing" argument must be a boolean');if(j(/^%?[^%]*%?$/,Y)===null)throw new u("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var O=D(Y),ee=O.length>0?O[0]:"",ae=$("%"+ee+"%",T),ye=ae.name,le=ae.value,Se=!1,Pe=ae.alias;Pe&&(ee=Pe[0],be(O,de([0,1],Pe)));for(var ue=1,je=!0;ue<O.length;ue+=1){var De=O[ue],K=re(De,0,1),pe=re(De,-1);if((K==='"'||K==="'"||K==="`"||pe==='"'||pe==="'"||pe==="`")&&K!==pe)throw new u("property names with quotes must have matching quotes");if((De==="constructor"||!je)&&(Se=!0),ee+="."+De,ye="%"+ee+"%",me(oe,ye))le=oe[ye];else if(le!=null){if(!(De in le)){if(!T)throw new a("base intrinsic for "+Y+" exists, but the property is not available.");return}if(R&&ue+1>=O.length){var X=R(le,De);je=!!X,je&&"get"in X&&!("originalValue"in X.get)?le=X.get:le=le[De]}else je=me(le,De),le=le[De];je&&!Se&&(oe[ye]=le)}}return le},Cs}var ks,zh;function It(){if(zh)return ks;zh=1;var i=fr(),e=Ts(),t=e([i("%String.prototype.indexOf%")]);return ks=function(n,o){var u=i(n,!!o);return typeof u=="function"&&t(n,".prototype.")>-1?e([u]):u},ks}var qs,Vh;function Fg(){if(Vh)return qs;Vh=1;var i=ar()(),e=It(),t=e("Object.prototype.toString"),r=function(a){return i&&a&&typeof a=="object"&&Symbol.toStringTag in a?!1:t(a)==="[object Arguments]"},n=function(a){return r(a)?!0:a!==null&&typeof a=="object"&&"length"in a&&typeof a.length=="number"&&a.length>=0&&t(a)!=="[object Array]"&&"callee"in a&&t(a.callee)==="[object Function]"},o=(function(){return r(arguments)})();return r.isLegacyArguments=n,qs=o?r:n,qs}var Ms,Kh;function Ug(){if(Kh)return Ms;Kh=1;var i=It(),e=ar()(),t=Yh(),r=qt(),n;if(e){var o=i("RegExp.prototype.exec"),u={},a=function(){throw u},s={toString:a,valueOf:a};typeof Symbol.toPrimitive=="symbol"&&(s[Symbol.toPrimitive]=a),n=function(g){if(!g||typeof g!="object")return!1;var E=r(g,"lastIndex"),w=E&&t(E,"value");if(!w)return!1;try{o(g,s)}catch(q){return q===u}}}else{var l=i("Object.prototype.toString"),d="[object RegExp]";n=function(g){return!g||typeof g!="object"&&typeof g!="function"?!1:l(g)===d}}return Ms=n,Ms}var Ps,Qh;function Ng(){if(Qh)return Ps;Qh=1;var i=It(),e=Ug(),t=i("RegExp.prototype.exec"),r=gt();return Ps=function(o){if(!e(o))throw new r("`regex` must be a RegExp");return function(a){return t(o,a)!==null}},Ps}var Bs,Jh;function jg(){if(Jh)return Bs;Jh=1;const i=function*(){}.constructor;return Bs=()=>i,Bs}var Ds,Xh;function $g(){if(Xh)return Ds;Xh=1;var i=It(),e=Ng(),t=e(/^\s*(?:function)?\*/),r=ar()(),n=Os(),o=i("Object.prototype.toString"),u=i("Function.prototype.toString"),a=jg();return Ds=function(l){if(typeof l!="function")return!1;if(t(u(l)))return!0;if(!r){var d=o(l);return d==="[object GeneratorFunction]"}if(!n)return!1;var _=a();return _&&n(l)===_.prototype},Ds}var Ls,Zh;function Hg(){if(Zh)return Ls;Zh=1;var i=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,t,r;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{t=Object.defineProperty({},"length",{get:function(){throw r}}),r={},e(function(){throw 42},null,t)}catch(R){R!==r&&(e=null)}else e=null;var n=/^\s*class\b/,o=function(S){try{var b=i.call(S);return n.test(b)}catch(h){return!1}},u=function(S){try{return o(S)?!1:(i.call(S),!0)}catch(b){return!1}},a=Object.prototype.toString,s="[object Object]",l="[object Function]",d="[object GeneratorFunction]",_="[object HTMLAllCollection]",g="[object HTML document.all class]",E="[object HTMLCollection]",w=typeof Symbol=="function"&&!!Symbol.toStringTag,q=!(0 in[,]),k=function(){return!1};if(typeof document=="object"){var A=document.all;a.call(A)===a.call(document.all)&&(k=function(S){if((q||!S)&&(typeof S=="undefined"||typeof S=="object"))try{var b=a.call(S);return(b===_||b===g||b===E||b===s)&&S("")==null}catch(h){}return!1})}return Ls=e?function(S){if(k(S))return!0;if(!S||typeof S!="function"&&typeof S!="object")return!1;try{e(S,null,t)}catch(b){if(b!==r)return!1}return!o(S)&&u(S)}:function(S){if(k(S))return!0;if(!S||typeof S!="function"&&typeof S!="object")return!1;if(w)return u(S);if(o(S))return!1;var b=a.call(S);return b!==l&&b!==d&&!/^\[object HTML/.test(b)?!1:u(S)},Ls}var Fs,ed;function Wg(){if(ed)return Fs;ed=1;var i=Hg(),e=Object.prototype.toString,t=Object.prototype.hasOwnProperty,r=function(s,l,d){for(var _=0,g=s.length;_<g;_++)t.call(s,_)&&(d==null?l(s[_],_,s):l.call(d,s[_],_,s))},n=function(s,l,d){for(var _=0,g=s.length;_<g;_++)d==null?l(s.charAt(_),_,s):l.call(d,s.charAt(_),_,s)},o=function(s,l,d){for(var _ in s)t.call(s,_)&&(d==null?l(s[_],_,s):l.call(d,s[_],_,s))};function u(a){return e.call(a)==="[object Array]"}return Fs=function(s,l,d){if(!i(l))throw new TypeError("iterator must be a function");var _;arguments.length>=3&&(_=d),u(s)?r(s,l,_):typeof s=="string"?n(s,l,_):o(s,l,_)},Fs}var Us,td;function Yg(){return td||(td=1,Us=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),Us}var Ns,rd;function Gg(){if(rd)return Ns;rd=1;var i=Yg(),e=typeof globalThis=="undefined"?xe:globalThis;return Ns=function(){for(var r=[],n=0;n<i.length;n++)typeof e[i[n]]=="function"&&(r[r.length]=i[n]);return r},Ns}var js={exports:{}},$s,nd;function zg(){if(nd)return $s;nd=1;var i=ur(),e=mh(),t=gt(),r=qt();return $s=function(o,u,a){if(!o||typeof o!="object"&&typeof o!="function")throw new t("`obj` must be an object or a function`");if(typeof u!="string"&&typeof u!="symbol")throw new t("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new t("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new t("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new t("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new t("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,l=arguments.length>4?arguments[4]:null,d=arguments.length>5?arguments[5]:null,_=arguments.length>6?arguments[6]:!1,g=!!r&&r(o,u);if(i)i(o,u,{configurable:d===null&&g?g.configurable:!d,enumerable:s===null&&g?g.enumerable:!s,value:a,writable:l===null&&g?g.writable:!l});else if(_||!s&&!l&&!d)o[u]=a;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},$s}var Hs,id;function Vg(){if(id)return Hs;id=1;var i=ur(),e=function(){return!!i};return e.hasArrayLengthDefineBug=function(){if(!i)return null;try{return i([],"length",{value:1}).length!==1}catch(r){return!0}},Hs=e,Hs}var Ws,od;function Kg(){if(od)return Ws;od=1;var i=fr(),e=zg(),t=Vg()(),r=qt(),n=gt(),o=i("%Math.floor%");return Ws=function(a,s){if(typeof a!="function")throw new n("`fn` is not a function");if(typeof s!="number"||s<0||s>4294967295||o(s)!==s)throw new n("`length` must be a positive 32-bit integer");var l=arguments.length>2&&!!arguments[2],d=!0,_=!0;if("length"in a&&r){var g=r(a,"length");g&&!g.configurable&&(d=!1),g&&!g.writable&&(_=!1)}return(d||_||!l)&&(t?e(a,"length",s,!0,!0):e(a,"length",s)),a},Ws}var Ys,sd;function Qg(){if(sd)return Ys;sd=1;var i=Vt(),e=ws(),t=Nh();return Ys=function(){return t(i,e,arguments)},Ys}var ad;function Jg(){return ad||(ad=1,(function(i){var e=Kg(),t=ur(),r=Ts(),n=Qg();i.exports=function(u){var a=r(arguments),s=1+u.length-(arguments.length-1);return e(a,s>0?s:0,!0)},t?t(i.exports,"apply",{value:n}):i.exports.apply=n})(js)),js.exports}var Gs,ud;function fd(){if(ud)return Gs;ud=1;var i=Wg(),e=Gg(),t=Jg(),r=It(),n=qt(),o=Os(),u=r("Object.prototype.toString"),a=ar()(),s=typeof globalThis=="undefined"?xe:globalThis,l=e(),d=r("String.prototype.slice"),_=r("Array.prototype.indexOf",!0)||function(A,R){for(var S=0;S<A.length;S+=1)if(A[S]===R)return S;return-1},g={__proto__:null};a&&n&&o?i(l,function(k){var A=new s[k];if(Symbol.toStringTag in A&&o){var R=o(A),S=n(R,Symbol.toStringTag);if(!S&&R){var b=o(R);S=n(b,Symbol.toStringTag)}if(S&&S.get){var h=t(S.get);g["$"+k]=h}}}):i(l,function(k){var A=new s[k],R=A.slice||A.set;if(R){var S=t(R);g["$"+k]=S}});function E(k){var A=!1;return i(g,function(R,S){if(!A)try{"$"+R(k)===S&&(A=d(S,1))}catch(b){}}),A}function w(k){var A=!1;return i(g,function(R,S){if(!A)try{R(k),A=d(S,1)}catch(b){}}),A}function q(k){return _(l,k)>-1}return Gs=function(A){if(!A||typeof A!="object")return!1;if(!a){var R=d(u(A),8,-1);return q(R)?R:R!=="Object"?!1:w(A)}return n?E(A):null},Gs}var zs,ld;function Xg(){if(ld)return zs;ld=1;var i=fd();return zs=function(t){return!!i(t)},zs}var cd;function Zg(){return cd||(cd=1,(function(i){var e=Fg(),t=$g(),r=fd(),n=Xg();function o(ue){return ue.call.bind(ue)}var u=typeof BigInt!="undefined",a=typeof Symbol!="undefined",s=o(Object.prototype.toString),l=o(Number.prototype.valueOf),d=o(String.prototype.valueOf),_=o(Boolean.prototype.valueOf);if(u)var g=o(BigInt.prototype.valueOf);if(a)var E=o(Symbol.prototype.valueOf);function w(ue,je){if(typeof ue!="object")return!1;try{return je(ue),!0}catch(De){return!1}}i.isArgumentsObject=e,i.isGeneratorFunction=t,i.isTypedArray=n;function q(ue){return typeof Promise!="undefined"&&ue instanceof Promise||ue!==null&&typeof ue=="object"&&typeof ue.then=="function"&&typeof ue.catch=="function"}i.isPromise=q;function k(ue){return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?ArrayBuffer.isView(ue):n(ue)||re(ue)}i.isArrayBufferView=k;function A(ue){return r(ue)==="Uint8Array"}i.isUint8Array=A;function R(ue){return r(ue)==="Uint8ClampedArray"}i.isUint8ClampedArray=R;function S(ue){return r(ue)==="Uint16Array"}i.isUint16Array=S;function b(ue){return r(ue)==="Uint32Array"}i.isUint32Array=b;function h(ue){return r(ue)==="Int8Array"}i.isInt8Array=h;function p(ue){return r(ue)==="Int16Array"}i.isInt16Array=p;function v(ue){return r(ue)==="Int32Array"}i.isInt32Array=v;function I(ue){return r(ue)==="Float32Array"}i.isFloat32Array=I;function B(ue){return r(ue)==="Float64Array"}i.isFloat64Array=B;function H(ue){return r(ue)==="BigInt64Array"}i.isBigInt64Array=H;function V(ue){return r(ue)==="BigUint64Array"}i.isBigUint64Array=V;function P(ue){return s(ue)==="[object Map]"}P.working=typeof Map!="undefined"&&P(new Map);function ce(ue){return typeof Map=="undefined"?!1:P.working?P(ue):ue instanceof Map}i.isMap=ce;function oe(ue){return s(ue)==="[object Set]"}oe.working=typeof Set!="undefined"&&oe(new Set);function ne(ue){return typeof Set=="undefined"?!1:oe.working?oe(ue):ue instanceof Set}i.isSet=ne;function se(ue){return s(ue)==="[object WeakMap]"}se.working=typeof WeakMap!="undefined"&&se(new WeakMap);function he(ue){return typeof WeakMap=="undefined"?!1:se.working?se(ue):ue instanceof WeakMap}i.isWeakMap=he;function J(ue){return s(ue)==="[object WeakSet]"}J.working=typeof WeakSet!="undefined"&&J(new WeakSet);function me(ue){return J(ue)}i.isWeakSet=me;function de(ue){return s(ue)==="[object ArrayBuffer]"}de.working=typeof ArrayBuffer!="undefined"&&de(new ArrayBuffer);function be(ue){return typeof ArrayBuffer=="undefined"?!1:de.working?de(ue):ue instanceof ArrayBuffer}i.isArrayBuffer=be;function G(ue){return s(ue)==="[object DataView]"}G.working=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined"&&G(new DataView(new ArrayBuffer(1),0,1));function re(ue){return typeof DataView=="undefined"?!1:G.working?G(ue):ue instanceof DataView}i.isDataView=re;var j=typeof SharedArrayBuffer!="undefined"?SharedArrayBuffer:void 0;function L(ue){return s(ue)==="[object SharedArrayBuffer]"}function M(ue){return typeof j=="undefined"?!1:(typeof L.working=="undefined"&&(L.working=L(new j)),L.working?L(ue):ue instanceof j)}i.isSharedArrayBuffer=M;function D(ue){return s(ue)==="[object AsyncFunction]"}i.isAsyncFunction=D;function $(ue){return s(ue)==="[object Map Iterator]"}i.isMapIterator=$;function z(ue){return s(ue)==="[object Set Iterator]"}i.isSetIterator=z;function Y(ue){return s(ue)==="[object Generator]"}i.isGeneratorObject=Y;function T(ue){return s(ue)==="[object WebAssembly.Module]"}i.isWebAssemblyCompiledModule=T;function O(ue){return w(ue,l)}i.isNumberObject=O;function ee(ue){return w(ue,d)}i.isStringObject=ee;function ae(ue){return w(ue,_)}i.isBooleanObject=ae;function ye(ue){return u&&w(ue,g)}i.isBigIntObject=ye;function le(ue){return a&&w(ue,E)}i.isSymbolObject=le;function Se(ue){return O(ue)||ee(ue)||ae(ue)||ye(ue)||le(ue)}i.isBoxedPrimitive=Se;function Pe(ue){return typeof Uint8Array!="undefined"&&(be(ue)||M(ue))}i.isAnyArrayBuffer=Pe,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(ue){Object.defineProperty(i,ue,{enumerable:!1,value:function(){throw new Error(ue+" is not supported in userland")}})})})(Yo)),Yo}var Vs,hd;function e_(){return hd||(hd=1,Vs=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),Vs}var lr={exports:{}},dd;function _t(){return dd||(dd=1,typeof Object.create=="function"?lr.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:lr.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}),lr.exports}var pd;function md(){return pd||(pd=1,(function(i){var e=Object.getOwnPropertyDescriptors||function(re){for(var j=Object.keys(re),L={},M=0;M<j.length;M++)L[j[M]]=Object.getOwnPropertyDescriptor(re,j[M]);return L},t=/%[sdj%]/g;i.format=function(G){if(!h(G)){for(var re=[],j=0;j<arguments.length;j++)re.push(u(arguments[j]));return re.join(" ")}for(var j=1,L=arguments,M=L.length,D=String(G).replace(t,function(z){if(z==="%%")return"%";if(j>=M)return z;switch(z){case"%s":return String(L[j++]);case"%d":return Number(L[j++]);case"%j":try{return JSON.stringify(L[j++])}catch(Y){return"[Circular]"}default:return z}}),$=L[j];j<M;$=L[++j])R($)||!B($)?D+=" "+$:D+=" "+u($);return D},i.deprecate=function(G,re){if(typeof Re!="undefined"&&Re.noDeprecation===!0)return G;if(typeof Re=="undefined")return function(){return i.deprecate(G,re).apply(this,arguments)};var j=!1;function L(){if(!j){if(Re.throwDeprecation)throw new Error(re);Re.traceDeprecation?console.trace(re):console.error(re),j=!0}return G.apply(this,arguments)}return L};var r={},n=/^$/;if(Re.env.NODE_DEBUG){var o=Re.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),n=new RegExp("^"+o+"$","i")}i.debuglog=function(G){if(G=G.toUpperCase(),!r[G])if(n.test(G)){var re=Re.pid;r[G]=function(){var j=i.format.apply(i,arguments);console.error("%s %d: %s",G,re,j)}}else r[G]=function(){};return r[G]};function u(G,re){var j={seen:[],stylize:s};return arguments.length>=3&&(j.depth=arguments[2]),arguments.length>=4&&(j.colors=arguments[3]),A(re)?j.showHidden=re:re&&i._extend(j,re),v(j.showHidden)&&(j.showHidden=!1),v(j.depth)&&(j.depth=2),v(j.colors)&&(j.colors=!1),v(j.customInspect)&&(j.customInspect=!0),j.colors&&(j.stylize=a),d(j,G,j.depth)}i.inspect=u,u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function a(G,re){var j=u.styles[re];return j?"\x1B["+u.colors[j][0]+"m"+G+"\x1B["+u.colors[j][1]+"m":G}function s(G,re){return G}function l(G){var re={};return G.forEach(function(j,L){re[j]=!0}),re}function d(G,re,j){if(G.customInspect&&re&&P(re.inspect)&&re.inspect!==i.inspect&&!(re.constructor&&re.constructor.prototype===re)){var L=re.inspect(j,G);return h(L)||(L=d(G,L,j)),L}var M=_(G,re);if(M)return M;var D=Object.keys(re),$=l(D);if(G.showHidden&&(D=Object.getOwnPropertyNames(re)),V(re)&&(D.indexOf("message")>=0||D.indexOf("description")>=0))return g(re);if(D.length===0){if(P(re)){var z=re.name?": "+re.name:"";return G.stylize("[Function"+z+"]","special")}if(I(re))return G.stylize(RegExp.prototype.toString.call(re),"regexp");if(H(re))return G.stylize(Date.prototype.toString.call(re),"date");if(V(re))return g(re)}var Y="",T=!1,O=["{","}"];if(k(re)&&(T=!0,O=["[","]"]),P(re)){var ee=re.name?": "+re.name:"";Y=" [Function"+ee+"]"}if(I(re)&&(Y=" "+RegExp.prototype.toString.call(re)),H(re)&&(Y=" "+Date.prototype.toUTCString.call(re)),V(re)&&(Y=" "+g(re)),D.length===0&&(!T||re.length==0))return O[0]+Y+O[1];if(j<0)return I(re)?G.stylize(RegExp.prototype.toString.call(re),"regexp"):G.stylize("[Object]","special");G.seen.push(re);var ae;return T?ae=E(G,re,j,$,D):ae=D.map(function(ye){return w(G,re,j,$,ye,T)}),G.seen.pop(),q(ae,Y,O)}function _(G,re){if(v(re))return G.stylize("undefined","undefined");if(h(re)){var j="'"+JSON.stringify(re).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return G.stylize(j,"string")}if(b(re))return G.stylize(""+re,"number");if(A(re))return G.stylize(""+re,"boolean");if(R(re))return G.stylize("null","null")}function g(G){return"["+Error.prototype.toString.call(G)+"]"}function E(G,re,j,L,M){for(var D=[],$=0,z=re.length;$<z;++$)J(re,String($))?D.push(w(G,re,j,L,String($),!0)):D.push("");return M.forEach(function(Y){Y.match(/^\d+$/)||D.push(w(G,re,j,L,Y,!0))}),D}function w(G,re,j,L,M,D){var $,z,Y;if(Y=Object.getOwnPropertyDescriptor(re,M)||{value:re[M]},Y.get?Y.set?z=G.stylize("[Getter/Setter]","special"):z=G.stylize("[Getter]","special"):Y.set&&(z=G.stylize("[Setter]","special")),J(L,M)||($="["+M+"]"),z||(G.seen.indexOf(Y.value)<0?(R(j)?z=d(G,Y.value,null):z=d(G,Y.value,j-1),z.indexOf(`
8
+ `)>-1&&(D?z=z.split(`
9
+ `).map(function(T){return" "+T}).join(`
10
+ `).slice(2):z=`
11
+ `+z.split(`
12
+ `).map(function(T){return" "+T}).join(`
13
+ `))):z=G.stylize("[Circular]","special")),v($)){if(D&&M.match(/^\d+$/))return z;$=JSON.stringify(""+M),$.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?($=$.slice(1,-1),$=G.stylize($,"name")):($=$.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),$=G.stylize($,"string"))}return $+": "+z}function q(G,re,j){var L=G.reduce(function(M,D){return D.indexOf(`
14
+ `)>=0,M+D.replace(/\u001b\[\d\d?m/g,"").length+1},0);return L>60?j[0]+(re===""?"":re+`
15
+ `)+" "+G.join(`,
16
+ `)+" "+j[1]:j[0]+re+" "+G.join(", ")+" "+j[1]}i.types=Zg();function k(G){return Array.isArray(G)}i.isArray=k;function A(G){return typeof G=="boolean"}i.isBoolean=A;function R(G){return G===null}i.isNull=R;function S(G){return G==null}i.isNullOrUndefined=S;function b(G){return typeof G=="number"}i.isNumber=b;function h(G){return typeof G=="string"}i.isString=h;function p(G){return typeof G=="symbol"}i.isSymbol=p;function v(G){return G===void 0}i.isUndefined=v;function I(G){return B(G)&&oe(G)==="[object RegExp]"}i.isRegExp=I,i.types.isRegExp=I;function B(G){return typeof G=="object"&&G!==null}i.isObject=B;function H(G){return B(G)&&oe(G)==="[object Date]"}i.isDate=H,i.types.isDate=H;function V(G){return B(G)&&(oe(G)==="[object Error]"||G instanceof Error)}i.isError=V,i.types.isNativeError=V;function P(G){return typeof G=="function"}i.isFunction=P;function ce(G){return G===null||typeof G=="boolean"||typeof G=="number"||typeof G=="string"||typeof G=="symbol"||typeof G=="undefined"}i.isPrimitive=ce,i.isBuffer=e_();function oe(G){return Object.prototype.toString.call(G)}function ne(G){return G<10?"0"+G.toString(10):G.toString(10)}var se=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function he(){var G=new Date,re=[ne(G.getHours()),ne(G.getMinutes()),ne(G.getSeconds())].join(":");return[G.getDate(),se[G.getMonth()],re].join(" ")}i.log=function(){console.log("%s - %s",he(),i.format.apply(i,arguments))},i.inherits=_t(),i._extend=function(G,re){if(!re||!B(re))return G;for(var j=Object.keys(re),L=j.length;L--;)G[j[L]]=re[j[L]];return G};function J(G,re){return Object.prototype.hasOwnProperty.call(G,re)}var me=typeof Symbol!="undefined"?Symbol("util.promisify.custom"):void 0;i.promisify=function(re){if(typeof re!="function")throw new TypeError('The "original" argument must be of type Function');if(me&&re[me]){var j=re[me];if(typeof j!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(j,me,{value:j,enumerable:!1,writable:!1,configurable:!0}),j}function j(){for(var L,M,D=new Promise(function(Y,T){L=Y,M=T}),$=[],z=0;z<arguments.length;z++)$.push(arguments[z]);$.push(function(Y,T){Y?M(Y):L(T)});try{re.apply(this,$)}catch(Y){M(Y)}return D}return Object.setPrototypeOf(j,Object.getPrototypeOf(re)),me&&Object.defineProperty(j,me,{value:j,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(j,e(re))},i.promisify.custom=me;function de(G,re){if(!G){var j=new Error("Promise was rejected with a falsy value");j.reason=G,G=j}return re(G)}function be(G){if(typeof G!="function")throw new TypeError('The "original" argument must be of type Function');function re(){for(var j=[],L=0;L<arguments.length;L++)j.push(arguments[L]);var M=j.pop();if(typeof M!="function")throw new TypeError("The last argument must be of type Function");var D=this,$=function(){return M.apply(D,arguments)};G.apply(this,j).then(function(z){Re.nextTick($.bind(null,null,z))},function(z){Re.nextTick(de.bind(null,z,$))})}return Object.setPrototypeOf(re,Object.getPrototypeOf(G)),Object.defineProperties(re,e(G)),re}i.callbackify=be})(Wo)),Wo}var Ks,yd;function t_(){if(yd)return Ks;yd=1;function i(w,q){var k=Object.keys(w);if(Object.getOwnPropertySymbols){var A=Object.getOwnPropertySymbols(w);q&&(A=A.filter(function(R){return Object.getOwnPropertyDescriptor(w,R).enumerable})),k.push.apply(k,A)}return k}function e(w){for(var q=1;q<arguments.length;q++){var k=arguments[q]!=null?arguments[q]:{};q%2?i(Object(k),!0).forEach(function(A){t(w,A,k[A])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(k)):i(Object(k)).forEach(function(A){Object.defineProperty(w,A,Object.getOwnPropertyDescriptor(k,A))})}return w}function t(w,q,k){return q=u(q),q in w?Object.defineProperty(w,q,{value:k,enumerable:!0,configurable:!0,writable:!0}):w[q]=k,w}function r(w,q){if(!(w instanceof q))throw new TypeError("Cannot call a class as a function")}function n(w,q){for(var k=0;k<q.length;k++){var A=q[k];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(w,u(A.key),A)}}function o(w,q,k){return q&&n(w.prototype,q),Object.defineProperty(w,"prototype",{writable:!1}),w}function u(w){var q=a(w,"string");return typeof q=="symbol"?q:String(q)}function a(w,q){if(typeof w!="object"||w===null)return w;var k=w[Symbol.toPrimitive];if(k!==void 0){var A=k.call(w,q);if(typeof A!="object")return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(w)}var s=zt(),l=s.Buffer,d=md(),_=d.inspect,g=_&&_.custom||"inspect";function E(w,q,k){l.prototype.copy.call(w,q,k)}return Ks=(function(){function w(){r(this,w),this.head=null,this.tail=null,this.length=0}return o(w,[{key:"push",value:function(k){var A={data:k,next:null};this.length>0?this.tail.next=A:this.head=A,this.tail=A,++this.length}},{key:"unshift",value:function(k){var A={data:k,next:this.head};this.length===0&&(this.tail=A),this.head=A,++this.length}},{key:"shift",value:function(){if(this.length!==0){var k=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,k}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(k){if(this.length===0)return"";for(var A=this.head,R=""+A.data;A=A.next;)R+=k+A.data;return R}},{key:"concat",value:function(k){if(this.length===0)return l.alloc(0);for(var A=l.allocUnsafe(k>>>0),R=this.head,S=0;R;)E(R.data,A,S),S+=R.data.length,R=R.next;return A}},{key:"consume",value:function(k,A){var R;return k<this.head.data.length?(R=this.head.data.slice(0,k),this.head.data=this.head.data.slice(k)):k===this.head.data.length?R=this.shift():R=A?this._getString(k):this._getBuffer(k),R}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(k){var A=this.head,R=1,S=A.data;for(k-=S.length;A=A.next;){var b=A.data,h=k>b.length?b.length:k;if(h===b.length?S+=b:S+=b.slice(0,k),k-=h,k===0){h===b.length?(++R,A.next?this.head=A.next:this.head=this.tail=null):(this.head=A,A.data=b.slice(h));break}++R}return this.length-=R,S}},{key:"_getBuffer",value:function(k){var A=l.allocUnsafe(k),R=this.head,S=1;for(R.data.copy(A),k-=R.data.length;R=R.next;){var b=R.data,h=k>b.length?b.length:k;if(b.copy(A,A.length-k,0,h),k-=h,k===0){h===b.length?(++S,R.next?this.head=R.next:this.head=this.tail=null):(this.head=R,R.data=b.slice(h));break}++S}return this.length-=S,A}},{key:g,value:function(k,A){return _(this,e(e({},A),{},{depth:0,customInspect:!1}))}}]),w})(),Ks}var Qs,gd;function _d(){if(gd)return Qs;gd=1;function i(u,a){var s=this,l=this._readableState&&this._readableState.destroyed,d=this._writableState&&this._writableState.destroyed;return l||d?(a?a(u):u&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,Re.nextTick(n,this,u)):Re.nextTick(n,this,u)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(u||null,function(_){!a&&_?s._writableState?s._writableState.errorEmitted?Re.nextTick(t,s):(s._writableState.errorEmitted=!0,Re.nextTick(e,s,_)):Re.nextTick(e,s,_):a?(Re.nextTick(t,s),a(_)):Re.nextTick(t,s)}),this)}function e(u,a){n(u,a),t(u)}function t(u){u._writableState&&!u._writableState.emitClose||u._readableState&&!u._readableState.emitClose||u.emit("close")}function r(){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 n(u,a){u.emit("error",a)}function o(u,a){var s=u._readableState,l=u._writableState;s&&s.autoDestroy||l&&l.autoDestroy?u.destroy(a):u.emit("error",a)}return Qs={destroy:i,undestroy:r,errorOrDestroy:o},Qs}var Js={},vd;function Mt(){if(vd)return Js;vd=1;function i(a,s){a.prototype=Object.create(s.prototype),a.prototype.constructor=a,a.__proto__=s}var e={};function t(a,s,l){l||(l=Error);function d(g,E,w){return typeof s=="string"?s:s(g,E,w)}var _=(function(g){i(E,g);function E(w,q,k){return g.call(this,d(w,q,k))||this}return E})(l);_.prototype.name=l.name,_.prototype.code=a,e[a]=_}function r(a,s){if(Array.isArray(a)){var l=a.length;return a=a.map(function(d){return String(d)}),l>2?"one of ".concat(s," ").concat(a.slice(0,l-1).join(", "),", or ")+a[l-1]:l===2?"one of ".concat(s," ").concat(a[0]," or ").concat(a[1]):"of ".concat(s," ").concat(a[0])}else return"of ".concat(s," ").concat(String(a))}function n(a,s,l){return a.substr(0,s.length)===s}function o(a,s,l){return(l===void 0||l>a.length)&&(l=a.length),a.substring(l-s.length,l)===s}function u(a,s,l){return typeof l!="number"&&(l=0),l+s.length>a.length?!1:a.indexOf(s,l)!==-1}return t("ERR_INVALID_OPT_VALUE",function(a,s){return'The value "'+s+'" is invalid for option "'+a+'"'},TypeError),t("ERR_INVALID_ARG_TYPE",function(a,s,l){var d;typeof s=="string"&&n(s,"not ")?(d="must not be",s=s.replace(/^not /,"")):d="must be";var _;if(o(a," argument"))_="The ".concat(a," ").concat(d," ").concat(r(s,"type"));else{var g=u(a,".")?"property":"argument";_='The "'.concat(a,'" ').concat(g," ").concat(d," ").concat(r(s,"type"))}return _+=". Received type ".concat(typeof l),_},TypeError),t("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),t("ERR_METHOD_NOT_IMPLEMENTED",function(a){return"The "+a+" method is not implemented"}),t("ERR_STREAM_PREMATURE_CLOSE","Premature close"),t("ERR_STREAM_DESTROYED",function(a){return"Cannot call "+a+" after a stream was destroyed"}),t("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),t("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),t("ERR_STREAM_WRITE_AFTER_END","write after end"),t("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),t("ERR_UNKNOWN_ENCODING",function(a){return"Unknown encoding: "+a},TypeError),t("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Js.codes=e,Js}var Xs,bd;function wd(){if(bd)return Xs;bd=1;var i=Mt().codes.ERR_INVALID_OPT_VALUE;function e(r,n,o){return r.highWaterMark!=null?r.highWaterMark:n?r[o]:null}function t(r,n,o,u){var a=e(n,u,o);if(a!=null){if(!(isFinite(a)&&Math.floor(a)===a)||a<0){var s=u?o:"highWaterMark";throw new i(s,a)}return Math.floor(a)}return r.objectMode?16:16*1024}return Xs={getHighWaterMark:t},Xs}var Zs,Sd;function r_(){if(Sd)return Zs;Sd=1,Zs=i;function i(t,r){if(e("noDeprecation"))return t;var n=!1;function o(){if(!n){if(e("throwDeprecation"))throw new Error(r);e("traceDeprecation")?console.trace(r):console.warn(r),n=!0}return t.apply(this,arguments)}return o}function e(t){try{if(!xe.localStorage)return!1}catch(n){return!1}var r=xe.localStorage[t];return r==null?!1:String(r).toLowerCase()==="true"}return Zs}var ea,Ed;function Id(){if(Ed)return ea;Ed=1,ea=I;function i(M){var D=this;this.next=null,this.entry=null,this.finish=function(){L(D,M)}}var e;I.WritableState=p;var t={deprecate:r_()},r=nh(),n=zt().Buffer,o=(typeof xe!="undefined"?xe:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function u(M){return n.from(M)}function a(M){return n.isBuffer(M)||M instanceof o}var s=_d(),l=wd(),d=l.getHighWaterMark,_=Mt().codes,g=_.ERR_INVALID_ARG_TYPE,E=_.ERR_METHOD_NOT_IMPLEMENTED,w=_.ERR_MULTIPLE_CALLBACK,q=_.ERR_STREAM_CANNOT_PIPE,k=_.ERR_STREAM_DESTROYED,A=_.ERR_STREAM_NULL_VALUES,R=_.ERR_STREAM_WRITE_AFTER_END,S=_.ERR_UNKNOWN_ENCODING,b=s.errorOrDestroy;_t()(I,r);function h(){}function p(M,D,$){e=e||Pt(),M=M||{},typeof $!="boolean"&&($=D instanceof e),this.objectMode=!!M.objectMode,$&&(this.objectMode=this.objectMode||!!M.writableObjectMode),this.highWaterMark=d(this,M,"writableHighWaterMark",$),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var z=M.decodeStrings===!1;this.decodeStrings=!z,this.defaultEncoding=M.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(Y){se(D,Y)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=M.emitClose!==!1,this.autoDestroy=!!M.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new i(this)}p.prototype.getBuffer=function(){for(var D=this.bufferedRequest,$=[];D;)$.push(D),D=D.next;return $},(function(){try{Object.defineProperty(p.prototype,"buffer",{get:t.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(M){}})();var v;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(v=Function.prototype[Symbol.hasInstance],Object.defineProperty(I,Symbol.hasInstance,{value:function(D){return v.call(this,D)?!0:this!==I?!1:D&&D._writableState instanceof p}})):v=function(D){return D instanceof this};function I(M){e=e||Pt();var D=this instanceof e;if(!D&&!v.call(I,this))return new I(M);this._writableState=new p(M,this,D),this.writable=!0,M&&(typeof M.write=="function"&&(this._write=M.write),typeof M.writev=="function"&&(this._writev=M.writev),typeof M.destroy=="function"&&(this._destroy=M.destroy),typeof M.final=="function"&&(this._final=M.final)),r.call(this)}I.prototype.pipe=function(){b(this,new q)};function B(M,D){var $=new R;b(M,$),Re.nextTick(D,$)}function H(M,D,$,z){var Y;return $===null?Y=new A:typeof $!="string"&&!D.objectMode&&(Y=new g("chunk",["string","Buffer"],$)),Y?(b(M,Y),Re.nextTick(z,Y),!1):!0}I.prototype.write=function(M,D,$){var z=this._writableState,Y=!1,T=!z.objectMode&&a(M);return T&&!n.isBuffer(M)&&(M=u(M)),typeof D=="function"&&($=D,D=null),T?D="buffer":D||(D=z.defaultEncoding),typeof $!="function"&&($=h),z.ending?B(this,$):(T||H(this,z,M,$))&&(z.pendingcb++,Y=P(this,z,T,M,D,$)),Y},I.prototype.cork=function(){this._writableState.corked++},I.prototype.uncork=function(){var M=this._writableState;M.corked&&(M.corked--,!M.writing&&!M.corked&&!M.bufferProcessing&&M.bufferedRequest&&me(this,M))},I.prototype.setDefaultEncoding=function(D){if(typeof D=="string"&&(D=D.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((D+"").toLowerCase())>-1))throw new S(D);return this._writableState.defaultEncoding=D,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function V(M,D,$){return!M.objectMode&&M.decodeStrings!==!1&&typeof D=="string"&&(D=n.from(D,$)),D}Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function P(M,D,$,z,Y,T){if(!$){var O=V(D,z,Y);z!==O&&($=!0,Y="buffer",z=O)}var ee=D.objectMode?1:z.length;D.length+=ee;var ae=D.length<D.highWaterMark;if(ae||(D.needDrain=!0),D.writing||D.corked){var ye=D.lastBufferedRequest;D.lastBufferedRequest={chunk:z,encoding:Y,isBuf:$,callback:T,next:null},ye?ye.next=D.lastBufferedRequest:D.bufferedRequest=D.lastBufferedRequest,D.bufferedRequestCount+=1}else ce(M,D,!1,ee,z,Y,T);return ae}function ce(M,D,$,z,Y,T,O){D.writelen=z,D.writecb=O,D.writing=!0,D.sync=!0,D.destroyed?D.onwrite(new k("write")):$?M._writev(Y,D.onwrite):M._write(Y,T,D.onwrite),D.sync=!1}function oe(M,D,$,z,Y){--D.pendingcb,$?(Re.nextTick(Y,z),Re.nextTick(re,M,D),M._writableState.errorEmitted=!0,b(M,z)):(Y(z),M._writableState.errorEmitted=!0,b(M,z),re(M,D))}function ne(M){M.writing=!1,M.writecb=null,M.length-=M.writelen,M.writelen=0}function se(M,D){var $=M._writableState,z=$.sync,Y=$.writecb;if(typeof Y!="function")throw new w;if(ne($),D)oe(M,$,z,D,Y);else{var T=de($)||M.destroyed;!T&&!$.corked&&!$.bufferProcessing&&$.bufferedRequest&&me(M,$),z?Re.nextTick(he,M,$,T,Y):he(M,$,T,Y)}}function he(M,D,$,z){$||J(M,D),D.pendingcb--,z(),re(M,D)}function J(M,D){D.length===0&&D.needDrain&&(D.needDrain=!1,M.emit("drain"))}function me(M,D){D.bufferProcessing=!0;var $=D.bufferedRequest;if(M._writev&&$&&$.next){var z=D.bufferedRequestCount,Y=new Array(z),T=D.corkedRequestsFree;T.entry=$;for(var O=0,ee=!0;$;)Y[O]=$,$.isBuf||(ee=!1),$=$.next,O+=1;Y.allBuffers=ee,ce(M,D,!0,D.length,Y,"",T.finish),D.pendingcb++,D.lastBufferedRequest=null,T.next?(D.corkedRequestsFree=T.next,T.next=null):D.corkedRequestsFree=new i(D),D.bufferedRequestCount=0}else{for(;$;){var ae=$.chunk,ye=$.encoding,le=$.callback,Se=D.objectMode?1:ae.length;if(ce(M,D,!1,Se,ae,ye,le),$=$.next,D.bufferedRequestCount--,D.writing)break}$===null&&(D.lastBufferedRequest=null)}D.bufferedRequest=$,D.bufferProcessing=!1}I.prototype._write=function(M,D,$){$(new E("_write()"))},I.prototype._writev=null,I.prototype.end=function(M,D,$){var z=this._writableState;return typeof M=="function"?($=M,M=null,D=null):typeof D=="function"&&($=D,D=null),M!=null&&this.write(M,D),z.corked&&(z.corked=1,this.uncork()),z.ending||j(this,z,$),this},Object.defineProperty(I.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function de(M){return M.ending&&M.length===0&&M.bufferedRequest===null&&!M.finished&&!M.writing}function be(M,D){M._final(function($){D.pendingcb--,$&&b(M,$),D.prefinished=!0,M.emit("prefinish"),re(M,D)})}function G(M,D){!D.prefinished&&!D.finalCalled&&(typeof M._final=="function"&&!D.destroyed?(D.pendingcb++,D.finalCalled=!0,Re.nextTick(be,M,D)):(D.prefinished=!0,M.emit("prefinish")))}function re(M,D){var $=de(D);if($&&(G(M,D),D.pendingcb===0&&(D.finished=!0,M.emit("finish"),D.autoDestroy))){var z=M._readableState;(!z||z.autoDestroy&&z.endEmitted)&&M.destroy()}return $}function j(M,D,$){D.ending=!0,re(M,D),$&&(D.finished?Re.nextTick($):M.once("finish",$)),D.ended=!0,M.writable=!1}function L(M,D,$){var z=M.entry;for(M.entry=null;z;){var Y=z.callback;D.pendingcb--,Y($),z=z.next}D.corkedRequestsFree.next=M}return Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(D){this._writableState&&(this._writableState.destroyed=D)}}),I.prototype.destroy=s.destroy,I.prototype._undestroy=s.undestroy,I.prototype._destroy=function(M,D){D(M)},ea}var ta,Td;function Pt(){if(Td)return ta;Td=1;var i=Object.keys||function(l){var d=[];for(var _ in l)d.push(_);return d};ta=u;var e=Md(),t=Id();_t()(u,e);for(var r=i(t.prototype),n=0;n<r.length;n++){var o=r[n];u.prototype[o]||(u.prototype[o]=t.prototype[o])}function u(l){if(!(this instanceof u))return new u(l);e.call(this,l),t.call(this,l),this.allowHalfOpen=!0,l&&(l.readable===!1&&(this.readable=!1),l.writable===!1&&(this.writable=!1),l.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",a)))}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function a(){this._writableState.ended||Re.nextTick(s,this)}function s(l){l.end()}return Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(d){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=d,this._writableState.destroyed=d)}}),ta}var ra={},cr={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Rd;function n_(){return Rd||(Rd=1,(function(i,e){var t=zt(),r=t.Buffer;function n(u,a){for(var s in u)a[s]=u[s]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?i.exports=t:(n(t,e),e.Buffer=o);function o(u,a,s){return r(u,a,s)}o.prototype=Object.create(r.prototype),n(r,o),o.from=function(u,a,s){if(typeof u=="number")throw new TypeError("Argument must not be a number");return r(u,a,s)},o.alloc=function(u,a,s){if(typeof u!="number")throw new TypeError("Argument must be a number");var l=r(u);return a!==void 0?typeof s=="string"?l.fill(a,s):l.fill(a):l.fill(0),l},o.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return r(u)},o.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(u)}})(cr,cr.exports)),cr.exports}var Ad;function Od(){if(Ad)return ra;Ad=1;var i=n_().Buffer,e=i.isEncoding||function(A){switch(A=""+A,A&&A.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function t(A){if(!A)return"utf8";for(var R;;)switch(A){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return A;default:if(R)return;A=(""+A).toLowerCase(),R=!0}}function r(A){var R=t(A);if(typeof R!="string"&&(i.isEncoding===e||!e(A)))throw new Error("Unknown encoding: "+A);return R||A}ra.StringDecoder=n;function n(A){this.encoding=r(A);var R;switch(this.encoding){case"utf16le":this.text=_,this.end=g,R=4;break;case"utf8":this.fillLast=s,R=4;break;case"base64":this.text=E,this.end=w,R=3;break;default:this.write=q,this.end=k;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(R)}n.prototype.write=function(A){if(A.length===0)return"";var R,S;if(this.lastNeed){if(R=this.fillLast(A),R===void 0)return"";S=this.lastNeed,this.lastNeed=0}else S=0;return S<A.length?R?R+this.text(A,S):this.text(A,S):R||""},n.prototype.end=d,n.prototype.text=l,n.prototype.fillLast=function(A){if(this.lastNeed<=A.length)return A.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);A.copy(this.lastChar,this.lastTotal-this.lastNeed,0,A.length),this.lastNeed-=A.length};function o(A){return A<=127?0:A>>5===6?2:A>>4===14?3:A>>3===30?4:A>>6===2?-1:-2}function u(A,R,S){var b=R.length-1;if(b<S)return 0;var h=o(R[b]);return h>=0?(h>0&&(A.lastNeed=h-1),h):--b<S||h===-2?0:(h=o(R[b]),h>=0?(h>0&&(A.lastNeed=h-2),h):--b<S||h===-2?0:(h=o(R[b]),h>=0?(h>0&&(h===2?h=0:A.lastNeed=h-3),h):0))}function a(A,R,S){if((R[0]&192)!==128)return A.lastNeed=0,"�";if(A.lastNeed>1&&R.length>1){if((R[1]&192)!==128)return A.lastNeed=1,"�";if(A.lastNeed>2&&R.length>2&&(R[2]&192)!==128)return A.lastNeed=2,"�"}}function s(A){var R=this.lastTotal-this.lastNeed,S=a(this,A);if(S!==void 0)return S;if(this.lastNeed<=A.length)return A.copy(this.lastChar,R,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);A.copy(this.lastChar,R,0,A.length),this.lastNeed-=A.length}function l(A,R){var S=u(this,A,R);if(!this.lastNeed)return A.toString("utf8",R);this.lastTotal=S;var b=A.length-(S-this.lastNeed);return A.copy(this.lastChar,0,b),A.toString("utf8",R,b)}function d(A){var R=A&&A.length?this.write(A):"";return this.lastNeed?R+"�":R}function _(A,R){if((A.length-R)%2===0){var S=A.toString("utf16le",R);if(S){var b=S.charCodeAt(S.length-1);if(b>=55296&&b<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=A[A.length-2],this.lastChar[1]=A[A.length-1],S.slice(0,-1)}return S}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=A[A.length-1],A.toString("utf16le",R,A.length-1)}function g(A){var R=A&&A.length?this.write(A):"";if(this.lastNeed){var S=this.lastTotal-this.lastNeed;return R+this.lastChar.toString("utf16le",0,S)}return R}function E(A,R){var S=(A.length-R)%3;return S===0?A.toString("base64",R):(this.lastNeed=3-S,this.lastTotal=3,S===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",R,A.length-S))}function w(A){var R=A&&A.length?this.write(A):"";return this.lastNeed?R+this.lastChar.toString("base64",0,3-this.lastNeed):R}function q(A){return A.toString(this.encoding)}function k(A){return A&&A.length?this.write(A):""}return ra}var na,xd;function ia(){if(xd)return na;xd=1;var i=Mt().codes.ERR_STREAM_PREMATURE_CLOSE;function e(o){var u=!1;return function(){if(!u){u=!0;for(var a=arguments.length,s=new Array(a),l=0;l<a;l++)s[l]=arguments[l];o.apply(this,s)}}}function t(){}function r(o){return o.setHeader&&typeof o.abort=="function"}function n(o,u,a){if(typeof u=="function")return n(o,null,u);u||(u={}),a=e(a||t);var s=u.readable||u.readable!==!1&&o.readable,l=u.writable||u.writable!==!1&&o.writable,d=function(){o.writable||g()},_=o._writableState&&o._writableState.finished,g=function(){l=!1,_=!0,s||a.call(o)},E=o._readableState&&o._readableState.endEmitted,w=function(){s=!1,E=!0,l||a.call(o)},q=function(S){a.call(o,S)},k=function(){var S;if(s&&!E)return(!o._readableState||!o._readableState.ended)&&(S=new i),a.call(o,S);if(l&&!_)return(!o._writableState||!o._writableState.ended)&&(S=new i),a.call(o,S)},A=function(){o.req.on("finish",g)};return r(o)?(o.on("complete",g),o.on("abort",k),o.req?A():o.on("request",A)):l&&!o._writableState&&(o.on("end",d),o.on("close",d)),o.on("end",w),o.on("finish",g),u.error!==!1&&o.on("error",q),o.on("close",k),function(){o.removeListener("complete",g),o.removeListener("abort",k),o.removeListener("request",A),o.req&&o.req.removeListener("finish",g),o.removeListener("end",d),o.removeListener("close",d),o.removeListener("finish",g),o.removeListener("end",w),o.removeListener("error",q),o.removeListener("close",k)}}return na=n,na}var oa,Cd;function i_(){if(Cd)return oa;Cd=1;var i;function e(S,b,h){return b=t(b),b in S?Object.defineProperty(S,b,{value:h,enumerable:!0,configurable:!0,writable:!0}):S[b]=h,S}function t(S){var b=r(S,"string");return typeof b=="symbol"?b:String(b)}function r(S,b){if(typeof S!="object"||S===null)return S;var h=S[Symbol.toPrimitive];if(h!==void 0){var p=h.call(S,b);if(typeof p!="object")return p;throw new TypeError("@@toPrimitive must return a primitive value.")}return(b==="string"?String:Number)(S)}var n=ia(),o=Symbol("lastResolve"),u=Symbol("lastReject"),a=Symbol("error"),s=Symbol("ended"),l=Symbol("lastPromise"),d=Symbol("handlePromise"),_=Symbol("stream");function g(S,b){return{value:S,done:b}}function E(S){var b=S[o];if(b!==null){var h=S[_].read();h!==null&&(S[l]=null,S[o]=null,S[u]=null,b(g(h,!1)))}}function w(S){Re.nextTick(E,S)}function q(S,b){return function(h,p){S.then(function(){if(b[s]){h(g(void 0,!0));return}b[d](h,p)},p)}}var k=Object.getPrototypeOf(function(){}),A=Object.setPrototypeOf((i={get stream(){return this[_]},next:function(){var b=this,h=this[a];if(h!==null)return Promise.reject(h);if(this[s])return Promise.resolve(g(void 0,!0));if(this[_].destroyed)return new Promise(function(B,H){Re.nextTick(function(){b[a]?H(b[a]):B(g(void 0,!0))})});var p=this[l],v;if(p)v=new Promise(q(p,this));else{var I=this[_].read();if(I!==null)return Promise.resolve(g(I,!1));v=new Promise(this[d])}return this[l]=v,v}},e(i,Symbol.asyncIterator,function(){return this}),e(i,"return",function(){var b=this;return new Promise(function(h,p){b[_].destroy(null,function(v){if(v){p(v);return}h(g(void 0,!0))})})}),i),k),R=function(b){var h,p=Object.create(A,(h={},e(h,_,{value:b,writable:!0}),e(h,o,{value:null,writable:!0}),e(h,u,{value:null,writable:!0}),e(h,a,{value:null,writable:!0}),e(h,s,{value:b._readableState.endEmitted,writable:!0}),e(h,d,{value:function(I,B){var H=p[_].read();H?(p[l]=null,p[o]=null,p[u]=null,I(g(H,!1))):(p[o]=I,p[u]=B)},writable:!0}),h));return p[l]=null,n(b,function(v){if(v&&v.code!=="ERR_STREAM_PREMATURE_CLOSE"){var I=p[u];I!==null&&(p[l]=null,p[o]=null,p[u]=null,I(v)),p[a]=v;return}var B=p[o];B!==null&&(p[l]=null,p[o]=null,p[u]=null,B(g(void 0,!0))),p[s]=!0}),b.on("readable",w.bind(null,p)),p};return oa=R,oa}var sa,kd;function o_(){return kd||(kd=1,sa=function(){throw new Error("Readable.from is not available in the browser")}),sa}var aa,qd;function Md(){if(qd)return aa;qd=1,aa=B;var i;B.ReadableState=I,Gt().EventEmitter;var e=function(O,ee){return O.listeners(ee).length},t=nh(),r=zt().Buffer,n=(typeof xe!="undefined"?xe:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function o(T){return r.from(T)}function u(T){return r.isBuffer(T)||T instanceof n}var a=md(),s;a&&a.debuglog?s=a.debuglog("stream"):s=function(){};var l=t_(),d=_d(),_=wd(),g=_.getHighWaterMark,E=Mt().codes,w=E.ERR_INVALID_ARG_TYPE,q=E.ERR_STREAM_PUSH_AFTER_EOF,k=E.ERR_METHOD_NOT_IMPLEMENTED,A=E.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,R,S,b;_t()(B,t);var h=d.errorOrDestroy,p=["error","close","destroy","pause","resume"];function v(T,O,ee){if(typeof T.prependListener=="function")return T.prependListener(O,ee);!T._events||!T._events[O]?T.on(O,ee):Array.isArray(T._events[O])?T._events[O].unshift(ee):T._events[O]=[ee,T._events[O]]}function I(T,O,ee){i=i||Pt(),T=T||{},typeof ee!="boolean"&&(ee=O instanceof i),this.objectMode=!!T.objectMode,ee&&(this.objectMode=this.objectMode||!!T.readableObjectMode),this.highWaterMark=g(this,T,"readableHighWaterMark",ee),this.buffer=new l,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=T.emitClose!==!1,this.autoDestroy=!!T.autoDestroy,this.destroyed=!1,this.defaultEncoding=T.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,T.encoding&&(R||(R=Od().StringDecoder),this.decoder=new R(T.encoding),this.encoding=T.encoding)}function B(T){if(i=i||Pt(),!(this instanceof B))return new B(T);var O=this instanceof i;this._readableState=new I(T,this,O),this.readable=!0,T&&(typeof T.read=="function"&&(this._read=T.read),typeof T.destroy=="function"&&(this._destroy=T.destroy)),t.call(this)}Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(O){this._readableState&&(this._readableState.destroyed=O)}}),B.prototype.destroy=d.destroy,B.prototype._undestroy=d.undestroy,B.prototype._destroy=function(T,O){O(T)},B.prototype.push=function(T,O){var ee=this._readableState,ae;return ee.objectMode?ae=!0:typeof T=="string"&&(O=O||ee.defaultEncoding,O!==ee.encoding&&(T=r.from(T,O),O=""),ae=!0),H(this,T,O,!1,ae)},B.prototype.unshift=function(T){return H(this,T,null,!0,!1)};function H(T,O,ee,ae,ye){s("readableAddChunk",O);var le=T._readableState;if(O===null)le.reading=!1,se(T,le);else{var Se;if(ye||(Se=P(le,O)),Se)h(T,Se);else if(le.objectMode||O&&O.length>0)if(typeof O!="string"&&!le.objectMode&&Object.getPrototypeOf(O)!==r.prototype&&(O=o(O)),ae)le.endEmitted?h(T,new A):V(T,le,O,!0);else if(le.ended)h(T,new q);else{if(le.destroyed)return!1;le.reading=!1,le.decoder&&!ee?(O=le.decoder.write(O),le.objectMode||O.length!==0?V(T,le,O,!1):me(T,le)):V(T,le,O,!1)}else ae||(le.reading=!1,me(T,le))}return!le.ended&&(le.length<le.highWaterMark||le.length===0)}function V(T,O,ee,ae){O.flowing&&O.length===0&&!O.sync?(O.awaitDrain=0,T.emit("data",ee)):(O.length+=O.objectMode?1:ee.length,ae?O.buffer.unshift(ee):O.buffer.push(ee),O.needReadable&&he(T)),me(T,O)}function P(T,O){var ee;return!u(O)&&typeof O!="string"&&O!==void 0&&!T.objectMode&&(ee=new w("chunk",["string","Buffer","Uint8Array"],O)),ee}B.prototype.isPaused=function(){return this._readableState.flowing===!1},B.prototype.setEncoding=function(T){R||(R=Od().StringDecoder);var O=new R(T);this._readableState.decoder=O,this._readableState.encoding=this._readableState.decoder.encoding;for(var ee=this._readableState.buffer.head,ae="";ee!==null;)ae+=O.write(ee.data),ee=ee.next;return this._readableState.buffer.clear(),ae!==""&&this._readableState.buffer.push(ae),this._readableState.length=ae.length,this};var ce=1073741824;function oe(T){return T>=ce?T=ce:(T--,T|=T>>>1,T|=T>>>2,T|=T>>>4,T|=T>>>8,T|=T>>>16,T++),T}function ne(T,O){return T<=0||O.length===0&&O.ended?0:O.objectMode?1:T!==T?O.flowing&&O.length?O.buffer.head.data.length:O.length:(T>O.highWaterMark&&(O.highWaterMark=oe(T)),T<=O.length?T:O.ended?O.length:(O.needReadable=!0,0))}B.prototype.read=function(T){s("read",T),T=parseInt(T,10);var O=this._readableState,ee=T;if(T!==0&&(O.emittedReadable=!1),T===0&&O.needReadable&&((O.highWaterMark!==0?O.length>=O.highWaterMark:O.length>0)||O.ended))return s("read: emitReadable",O.length,O.ended),O.length===0&&O.ended?$(this):he(this),null;if(T=ne(T,O),T===0&&O.ended)return O.length===0&&$(this),null;var ae=O.needReadable;s("need readable",ae),(O.length===0||O.length-T<O.highWaterMark)&&(ae=!0,s("length less than watermark",ae)),O.ended||O.reading?(ae=!1,s("reading or ended",ae)):ae&&(s("do read"),O.reading=!0,O.sync=!0,O.length===0&&(O.needReadable=!0),this._read(O.highWaterMark),O.sync=!1,O.reading||(T=ne(ee,O)));var ye;return T>0?ye=D(T,O):ye=null,ye===null?(O.needReadable=O.length<=O.highWaterMark,T=0):(O.length-=T,O.awaitDrain=0),O.length===0&&(O.ended||(O.needReadable=!0),ee!==T&&O.ended&&$(this)),ye!==null&&this.emit("data",ye),ye};function se(T,O){if(s("onEofChunk"),!O.ended){if(O.decoder){var ee=O.decoder.end();ee&&ee.length&&(O.buffer.push(ee),O.length+=O.objectMode?1:ee.length)}O.ended=!0,O.sync?he(T):(O.needReadable=!1,O.emittedReadable||(O.emittedReadable=!0,J(T)))}}function he(T){var O=T._readableState;s("emitReadable",O.needReadable,O.emittedReadable),O.needReadable=!1,O.emittedReadable||(s("emitReadable",O.flowing),O.emittedReadable=!0,Re.nextTick(J,T))}function J(T){var O=T._readableState;s("emitReadable_",O.destroyed,O.length,O.ended),!O.destroyed&&(O.length||O.ended)&&(T.emit("readable"),O.emittedReadable=!1),O.needReadable=!O.flowing&&!O.ended&&O.length<=O.highWaterMark,M(T)}function me(T,O){O.readingMore||(O.readingMore=!0,Re.nextTick(de,T,O))}function de(T,O){for(;!O.reading&&!O.ended&&(O.length<O.highWaterMark||O.flowing&&O.length===0);){var ee=O.length;if(s("maybeReadMore read 0"),T.read(0),ee===O.length)break}O.readingMore=!1}B.prototype._read=function(T){h(this,new k("_read()"))},B.prototype.pipe=function(T,O){var ee=this,ae=this._readableState;switch(ae.pipesCount){case 0:ae.pipes=T;break;case 1:ae.pipes=[ae.pipes,T];break;default:ae.pipes.push(T);break}ae.pipesCount+=1,s("pipe count=%d opts=%j",ae.pipesCount,O);var ye=(!O||O.end!==!1)&&T!==Re.stdout&&T!==Re.stderr,le=ye?Pe:qe;ae.endEmitted?Re.nextTick(le):ee.once("end",le),T.on("unpipe",Se);function Se($e,Be){s("onunpipe"),$e===ee&&Be&&Be.hasUnpiped===!1&&(Be.hasUnpiped=!0,De())}function Pe(){s("onend"),T.end()}var ue=be(ee);T.on("drain",ue);var je=!1;function De(){s("cleanup"),T.removeListener("close",X),T.removeListener("finish",Te),T.removeListener("drain",ue),T.removeListener("error",pe),T.removeListener("unpipe",Se),ee.removeListener("end",Pe),ee.removeListener("end",qe),ee.removeListener("data",K),je=!0,ae.awaitDrain&&(!T._writableState||T._writableState.needDrain)&&ue()}ee.on("data",K);function K($e){s("ondata");var Be=T.write($e);s("dest.write",Be),Be===!1&&((ae.pipesCount===1&&ae.pipes===T||ae.pipesCount>1&&Y(ae.pipes,T)!==-1)&&!je&&(s("false write response, pause",ae.awaitDrain),ae.awaitDrain++),ee.pause())}function pe($e){s("onerror",$e),qe(),T.removeListener("error",pe),e(T,"error")===0&&h(T,$e)}v(T,"error",pe);function X(){T.removeListener("finish",Te),qe()}T.once("close",X);function Te(){s("onfinish"),T.removeListener("close",X),qe()}T.once("finish",Te);function qe(){s("unpipe"),ee.unpipe(T)}return T.emit("pipe",ee),ae.flowing||(s("pipe resume"),ee.resume()),T};function be(T){return function(){var ee=T._readableState;s("pipeOnDrain",ee.awaitDrain),ee.awaitDrain&&ee.awaitDrain--,ee.awaitDrain===0&&e(T,"data")&&(ee.flowing=!0,M(T))}}B.prototype.unpipe=function(T){var O=this._readableState,ee={hasUnpiped:!1};if(O.pipesCount===0)return this;if(O.pipesCount===1)return T&&T!==O.pipes?this:(T||(T=O.pipes),O.pipes=null,O.pipesCount=0,O.flowing=!1,T&&T.emit("unpipe",this,ee),this);if(!T){var ae=O.pipes,ye=O.pipesCount;O.pipes=null,O.pipesCount=0,O.flowing=!1;for(var le=0;le<ye;le++)ae[le].emit("unpipe",this,{hasUnpiped:!1});return this}var Se=Y(O.pipes,T);return Se===-1?this:(O.pipes.splice(Se,1),O.pipesCount-=1,O.pipesCount===1&&(O.pipes=O.pipes[0]),T.emit("unpipe",this,ee),this)},B.prototype.on=function(T,O){var ee=t.prototype.on.call(this,T,O),ae=this._readableState;return T==="data"?(ae.readableListening=this.listenerCount("readable")>0,ae.flowing!==!1&&this.resume()):T==="readable"&&!ae.endEmitted&&!ae.readableListening&&(ae.readableListening=ae.needReadable=!0,ae.flowing=!1,ae.emittedReadable=!1,s("on readable",ae.length,ae.reading),ae.length?he(this):ae.reading||Re.nextTick(re,this)),ee},B.prototype.addListener=B.prototype.on,B.prototype.removeListener=function(T,O){var ee=t.prototype.removeListener.call(this,T,O);return T==="readable"&&Re.nextTick(G,this),ee},B.prototype.removeAllListeners=function(T){var O=t.prototype.removeAllListeners.apply(this,arguments);return(T==="readable"||T===void 0)&&Re.nextTick(G,this),O};function G(T){var O=T._readableState;O.readableListening=T.listenerCount("readable")>0,O.resumeScheduled&&!O.paused?O.flowing=!0:T.listenerCount("data")>0&&T.resume()}function re(T){s("readable nexttick read 0"),T.read(0)}B.prototype.resume=function(){var T=this._readableState;return T.flowing||(s("resume"),T.flowing=!T.readableListening,j(this,T)),T.paused=!1,this};function j(T,O){O.resumeScheduled||(O.resumeScheduled=!0,Re.nextTick(L,T,O))}function L(T,O){s("resume",O.reading),O.reading||T.read(0),O.resumeScheduled=!1,T.emit("resume"),M(T),O.flowing&&!O.reading&&T.read(0)}B.prototype.pause=function(){return s("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(s("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function M(T){var O=T._readableState;for(s("flow",O.flowing);O.flowing&&T.read()!==null;);}B.prototype.wrap=function(T){var O=this,ee=this._readableState,ae=!1;T.on("end",function(){if(s("wrapped end"),ee.decoder&&!ee.ended){var Se=ee.decoder.end();Se&&Se.length&&O.push(Se)}O.push(null)}),T.on("data",function(Se){if(s("wrapped data"),ee.decoder&&(Se=ee.decoder.write(Se)),!(ee.objectMode&&Se==null)&&!(!ee.objectMode&&(!Se||!Se.length))){var Pe=O.push(Se);Pe||(ae=!0,T.pause())}});for(var ye in T)this[ye]===void 0&&typeof T[ye]=="function"&&(this[ye]=(function(Pe){return function(){return T[Pe].apply(T,arguments)}})(ye));for(var le=0;le<p.length;le++)T.on(p[le],this.emit.bind(this,p[le]));return this._read=function(Se){s("wrapped _read",Se),ae&&(ae=!1,T.resume())},this},typeof Symbol=="function"&&(B.prototype[Symbol.asyncIterator]=function(){return S===void 0&&(S=i_()),S(this)}),Object.defineProperty(B.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(B.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(B.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(O){this._readableState&&(this._readableState.flowing=O)}}),B._fromList=D,Object.defineProperty(B.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function D(T,O){if(O.length===0)return null;var ee;return O.objectMode?ee=O.buffer.shift():!T||T>=O.length?(O.decoder?ee=O.buffer.join(""):O.buffer.length===1?ee=O.buffer.first():ee=O.buffer.concat(O.length),O.buffer.clear()):ee=O.buffer.consume(T,O.decoder),ee}function $(T){var O=T._readableState;s("endReadable",O.endEmitted),O.endEmitted||(O.ended=!0,Re.nextTick(z,O,T))}function z(T,O){if(s("endReadableNT",T.endEmitted,T.length),!T.endEmitted&&T.length===0&&(T.endEmitted=!0,O.readable=!1,O.emit("end"),T.autoDestroy)){var ee=O._writableState;(!ee||ee.autoDestroy&&ee.finished)&&O.destroy()}}typeof Symbol=="function"&&(B.from=function(T,O){return b===void 0&&(b=o_()),b(B,T,O)});function Y(T,O){for(var ee=0,ae=T.length;ee<ae;ee++)if(T[ee]===O)return ee;return-1}return aa}var ua,Pd;function Bd(){if(Pd)return ua;Pd=1,ua=a;var i=Mt().codes,e=i.ERR_METHOD_NOT_IMPLEMENTED,t=i.ERR_MULTIPLE_CALLBACK,r=i.ERR_TRANSFORM_ALREADY_TRANSFORMING,n=i.ERR_TRANSFORM_WITH_LENGTH_0,o=Pt();_t()(a,o);function u(d,_){var g=this._transformState;g.transforming=!1;var E=g.writecb;if(E===null)return this.emit("error",new t);g.writechunk=null,g.writecb=null,_!=null&&this.push(_),E(d);var w=this._readableState;w.reading=!1,(w.needReadable||w.length<w.highWaterMark)&&this._read(w.highWaterMark)}function a(d){if(!(this instanceof a))return new a(d);o.call(this,d),this._transformState={afterTransform:u.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,d&&(typeof d.transform=="function"&&(this._transform=d.transform),typeof d.flush=="function"&&(this._flush=d.flush)),this.on("prefinish",s)}function s(){var d=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(_,g){l(d,_,g)}):l(this,null,null)}a.prototype.push=function(d,_){return this._transformState.needTransform=!1,o.prototype.push.call(this,d,_)},a.prototype._transform=function(d,_,g){g(new e("_transform()"))},a.prototype._write=function(d,_,g){var E=this._transformState;if(E.writecb=g,E.writechunk=d,E.writeencoding=_,!E.transforming){var w=this._readableState;(E.needTransform||w.needReadable||w.length<w.highWaterMark)&&this._read(w.highWaterMark)}},a.prototype._read=function(d){var _=this._transformState;_.writechunk!==null&&!_.transforming?(_.transforming=!0,this._transform(_.writechunk,_.writeencoding,_.afterTransform)):_.needTransform=!0},a.prototype._destroy=function(d,_){o.prototype._destroy.call(this,d,function(g){_(g)})};function l(d,_,g){if(_)return d.emit("error",_);if(g!=null&&d.push(g),d._writableState.length)throw new n;if(d._transformState.transforming)throw new r;return d.push(null)}return ua}var fa,Dd;function s_(){if(Dd)return fa;Dd=1,fa=e;var i=Bd();_t()(e,i);function e(t){if(!(this instanceof e))return new e(t);i.call(this,t)}return e.prototype._transform=function(t,r,n){n(null,t)},fa}var la,Ld;function a_(){if(Ld)return la;Ld=1;var i;function e(g){var E=!1;return function(){E||(E=!0,g.apply(void 0,arguments))}}var t=Mt().codes,r=t.ERR_MISSING_ARGS,n=t.ERR_STREAM_DESTROYED;function o(g){if(g)throw g}function u(g){return g.setHeader&&typeof g.abort=="function"}function a(g,E,w,q){q=e(q);var k=!1;g.on("close",function(){k=!0}),i===void 0&&(i=ia()),i(g,{readable:E,writable:w},function(R){if(R)return q(R);k=!0,q()});var A=!1;return function(R){if(!k&&!A){if(A=!0,u(g))return g.abort();if(typeof g.destroy=="function")return g.destroy();q(R||new n("pipe"))}}}function s(g){g()}function l(g,E){return g.pipe(E)}function d(g){return!g.length||typeof g[g.length-1]!="function"?o:g.pop()}function _(){for(var g=arguments.length,E=new Array(g),w=0;w<g;w++)E[w]=arguments[w];var q=d(E);if(Array.isArray(E[0])&&(E=E[0]),E.length<2)throw new r("streams");var k,A=E.map(function(R,S){var b=S<E.length-1,h=S>0;return a(R,b,h,function(p){k||(k=p),p&&A.forEach(s),!b&&(A.forEach(s),q(k))})});return E.reduce(l)}return la=_,la}var Fd;function Tt(){return Fd||(Fd=1,(function(i,e){e=i.exports=Md(),e.Stream=e,e.Readable=e,e.Writable=Id(),e.Duplex=Pt(),e.Transform=Bd(),e.PassThrough=s_(),e.finished=ia(),e.pipeline=a_()})(sr,sr.exports)),sr.exports}var ca,Ud;function Nd(){if(Ud)return ca;Ud=1;var i=jo(),e=Tt().Readable,t={objectMode:!0},r={clean:!0};function n(o){if(!(this instanceof n))return new n(o);this.options=o||{},this.options=i(r,o),this._inflights=new Map}return n.prototype.put=function(o,u){return this._inflights.set(o.messageId,o),u&&u(),this},n.prototype.createStream=function(){var o=new e(t),u=!1,a=[],s=0;return this._inflights.forEach(function(l,d){a.push(l)}),o._read=function(){!u&&s<a.length?this.push(a[s++]):this.push(null)},o.destroy=function(){if(!u){var l=this;u=!0,setTimeout(function(){l.emit("close")},0)}},o},n.prototype.del=function(o,u){return o=this._inflights.get(o.messageId),o?(this._inflights.delete(o.messageId),u(null,o)):u&&u(new Error("missing packet")),this},n.prototype.get=function(o,u){return o=this._inflights.get(o.messageId),o?u(null,o):u&&u(new Error("missing packet")),this},n.prototype.close=function(o){this.options.clean&&(this._inflights=null),o&&o()},ca=n,ca}var Kt={},Qt={exports:{}},ha,jd;function u_(){if(jd)return ha;jd=1;const{Buffer:i}=zt(),e=Symbol.for("BufferList");function t(r){if(!(this instanceof t))return new t(r);t._init.call(this,r)}return t._init=function(n){Object.defineProperty(this,e,{value:!0}),this._bufs=[],this.length=0,n&&this.append(n)},t.prototype._new=function(n){return new t(n)},t.prototype._offset=function(n){if(n===0)return[0,0];let o=0;for(let u=0;u<this._bufs.length;u++){const a=o+this._bufs[u].length;if(n<a||u===this._bufs.length-1)return[u,n-o];o=a}},t.prototype._reverseOffset=function(r){const n=r[0];let o=r[1];for(let u=0;u<n;u++)o+=this._bufs[u].length;return o},t.prototype.get=function(n){if(n>this.length||n<0)return;const o=this._offset(n);return this._bufs[o[0]][o[1]]},t.prototype.slice=function(n,o){return typeof n=="number"&&n<0&&(n+=this.length),typeof o=="number"&&o<0&&(o+=this.length),this.copy(null,0,n,o)},t.prototype.copy=function(n,o,u,a){if((typeof u!="number"||u<0)&&(u=0),(typeof a!="number"||a>this.length)&&(a=this.length),u>=this.length||a<=0)return n||i.alloc(0);const s=!!n,l=this._offset(u),d=a-u;let _=d,g=s&&o||0,E=l[1];if(u===0&&a===this.length){if(!s)return this._bufs.length===1?this._bufs[0]:i.concat(this._bufs,this.length);for(let w=0;w<this._bufs.length;w++)this._bufs[w].copy(n,g),g+=this._bufs[w].length;return n}if(_<=this._bufs[l[0]].length-E)return s?this._bufs[l[0]].copy(n,o,E,E+_):this._bufs[l[0]].slice(E,E+_);s||(n=i.allocUnsafe(d));for(let w=l[0];w<this._bufs.length;w++){const q=this._bufs[w].length-E;if(_>q)this._bufs[w].copy(n,g,E),g+=q;else{this._bufs[w].copy(n,g,E,E+_),g+=q;break}_-=q,E&&(E=0)}return n.length>g?n.slice(0,g):n},t.prototype.shallowSlice=function(n,o){if(n=n||0,o=typeof o!="number"?this.length:o,n<0&&(n+=this.length),o<0&&(o+=this.length),n===o)return this._new();const u=this._offset(n),a=this._offset(o),s=this._bufs.slice(u[0],a[0]+1);return a[1]===0?s.pop():s[s.length-1]=s[s.length-1].slice(0,a[1]),u[1]!==0&&(s[0]=s[0].slice(u[1])),this._new(s)},t.prototype.toString=function(n,o,u){return this.slice(o,u).toString(n)},t.prototype.consume=function(n){if(n=Math.trunc(n),Number.isNaN(n)||n<=0)return this;for(;this._bufs.length;)if(n>=this._bufs[0].length)n-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();else{this._bufs[0]=this._bufs[0].slice(n),this.length-=n;break}return this},t.prototype.duplicate=function(){const n=this._new();for(let o=0;o<this._bufs.length;o++)n.append(this._bufs[o]);return n},t.prototype.append=function(n){if(n==null)return this;if(n.buffer)this._appendBuffer(i.from(n.buffer,n.byteOffset,n.byteLength));else if(Array.isArray(n))for(let o=0;o<n.length;o++)this.append(n[o]);else if(this._isBufferList(n))for(let o=0;o<n._bufs.length;o++)this.append(n._bufs[o]);else typeof n=="number"&&(n=n.toString()),this._appendBuffer(i.from(n));return this},t.prototype._appendBuffer=function(n){this._bufs.push(n),this.length+=n.length},t.prototype.indexOf=function(r,n,o){if(o===void 0&&typeof n=="string"&&(o=n,n=void 0),typeof r=="function"||Array.isArray(r))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if(typeof r=="number"?r=i.from([r]):typeof r=="string"?r=i.from(r,o):this._isBufferList(r)?r=r.slice():Array.isArray(r.buffer)?r=i.from(r.buffer,r.byteOffset,r.byteLength):i.isBuffer(r)||(r=i.from(r)),n=Number(n||0),isNaN(n)&&(n=0),n<0&&(n=this.length+n),n<0&&(n=0),r.length===0)return n>this.length?this.length:n;const u=this._offset(n);let a=u[0],s=u[1];for(;a<this._bufs.length;a++){const l=this._bufs[a];for(;s<l.length;)if(l.length-s>=r.length){const _=l.indexOf(r,s);if(_!==-1)return this._reverseOffset([a,_]);s=l.length-r.length+1}else{const _=this._reverseOffset([a,s]);if(this._match(_,r))return _;s++}s=0}return-1},t.prototype._match=function(r,n){if(this.length-r<n.length)return!1;for(let o=0;o<n.length;o++)if(this.get(r+o)!==n[o])return!1;return!0},(function(){const r={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const n in r)(function(o){r[o]===null?t.prototype[o]=function(u,a){return this.slice(u,u+a)[o](0,a)}:t.prototype[o]=function(u=0){return this.slice(u,u+r[o])[o](0)}})(n)})(),t.prototype._isBufferList=function(n){return n instanceof t||t.isBufferList(n)},t.isBufferList=function(n){return n!=null&&n[e]},ha=t,ha}var $d;function f_(){if($d)return Qt.exports;$d=1;const i=Tt().Duplex,e=_t(),t=u_();function r(n){if(!(this instanceof r))return new r(n);if(typeof n=="function"){this._callback=n;const o=function(a){this._callback&&(this._callback(a),this._callback=null)}.bind(this);this.on("pipe",function(a){a.on("error",o)}),this.on("unpipe",function(a){a.removeListener("error",o)}),n=null}t._init.call(this,n),i.call(this)}return e(r,i),Object.assign(r.prototype,t.prototype),r.prototype._new=function(o){return new r(o)},r.prototype._write=function(o,u,a){this._appendBuffer(o),typeof a=="function"&&a()},r.prototype._read=function(o){if(!this.length)return this.push(null);o=Math.min(o,this.length),this.push(this.slice(0,o)),this.consume(o)},r.prototype.end=function(o){i.prototype.end.call(this,o),this._callback&&(this._callback(null,this.slice()),this._callback=null)},r.prototype._destroy=function(o,u){this._bufs.length=0,this.length=0,u(o)},r.prototype._isBufferList=function(o){return o instanceof r||o instanceof t||r.isBufferList(o)},r.isBufferList=t.isBufferList,Qt.exports=r,Qt.exports.BufferListStream=r,Qt.exports.BufferList=t,Qt.exports}var da,Hd;function l_(){if(Hd)return da;Hd=1;class i{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}return da=i,da}var Wd={},hr={};hr.byteLength=d_,hr.toByteArray=m_,hr.fromByteArray=__;for(var ht=[],at=[],c_=typeof Uint8Array!="undefined"?Uint8Array:Array,pa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Bt=0,h_=pa.length;Bt<h_;++Bt)ht[Bt]=pa[Bt],at[pa.charCodeAt(Bt)]=Bt;at[45]=62,at[95]=63;function Yd(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function d_(i){var e=Yd(i),t=e[0],r=e[1];return(t+r)*3/4-r}function p_(i,e,t){return(e+t)*3/4-t}function m_(i){var e,t=Yd(i),r=t[0],n=t[1],o=new c_(p_(i,r,n)),u=0,a=n>0?r-4:r,s;for(s=0;s<a;s+=4)e=at[i.charCodeAt(s)]<<18|at[i.charCodeAt(s+1)]<<12|at[i.charCodeAt(s+2)]<<6|at[i.charCodeAt(s+3)],o[u++]=e>>16&255,o[u++]=e>>8&255,o[u++]=e&255;return n===2&&(e=at[i.charCodeAt(s)]<<2|at[i.charCodeAt(s+1)]>>4,o[u++]=e&255),n===1&&(e=at[i.charCodeAt(s)]<<10|at[i.charCodeAt(s+1)]<<4|at[i.charCodeAt(s+2)]>>2,o[u++]=e>>8&255,o[u++]=e&255),o}function y_(i){return ht[i>>18&63]+ht[i>>12&63]+ht[i>>6&63]+ht[i&63]}function g_(i,e,t){for(var r,n=[],o=e;o<t;o+=3)r=(i[o]<<16&16711680)+(i[o+1]<<8&65280)+(i[o+2]&255),n.push(y_(r));return n.join("")}function __(i){for(var e,t=i.length,r=t%3,n=[],o=16383,u=0,a=t-r;u<a;u+=o)n.push(g_(i,u,u+o>a?a:u+o));return r===1?(e=i[t-1],n.push(ht[e>>2]+ht[e<<4&63]+"==")):r===2&&(e=(i[t-2]<<8)+i[t-1],n.push(ht[e>>10]+ht[e>>4&63]+ht[e<<2&63]+"=")),n.join("")}var ma={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ma.read=function(i,e,t,r,n){var o,u,a=n*8-r-1,s=(1<<a)-1,l=s>>1,d=-7,_=t?n-1:0,g=t?-1:1,E=i[e+_];for(_+=g,o=E&(1<<-d)-1,E>>=-d,d+=a;d>0;o=o*256+i[e+_],_+=g,d-=8);for(u=o&(1<<-d)-1,o>>=-d,d+=r;d>0;u=u*256+i[e+_],_+=g,d-=8);if(o===0)o=1-l;else{if(o===s)return u?NaN:(E?-1:1)*(1/0);u=u+Math.pow(2,r),o=o-l}return(E?-1:1)*u*Math.pow(2,o-r)},ma.write=function(i,e,t,r,n,o){var u,a,s,l=o*8-n-1,d=(1<<l)-1,_=d>>1,g=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=r?0:o-1,w=r?1:-1,q=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,u=d):(u=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-u))<1&&(u--,s*=2),u+_>=1?e+=g/s:e+=g*Math.pow(2,1-_),e*s>=2&&(u++,s/=2),u+_>=d?(a=0,u=d):u+_>=1?(a=(e*s-1)*Math.pow(2,n),u=u+_):(a=e*Math.pow(2,_-1)*Math.pow(2,n),u=0));n>=8;i[t+E]=a&255,E+=w,a/=256,n-=8);for(u=u<<n|a,l+=n;l>0;i[t+E]=u&255,E+=w,u/=256,l-=8);i[t+E-w]|=q*128};/*!
17
+ * The buffer module from node.js, for the browser.
18
+ *
19
+ * @author Feross Aboukhadijeh <https://feross.org>
20
+ * @license MIT
21
+ */(function(i){const e=hr,t=ma,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=d,i.SlowBuffer=h,i.INSPECT_MAX_BYTES=50;const n=2147483647;i.kMaxLength=n;const{Uint8Array:o,ArrayBuffer:u,SharedArrayBuffer:a}=globalThis;d.TYPED_ARRAY_SUPPORT=s(),!d.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&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{const x=new o(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,o.prototype),Object.setPrototypeOf(x,f),x.foo()===42}catch(x){return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function l(x){if(x>n)throw new RangeError('The value "'+x+'" is invalid for option "size"');const f=new o(x);return Object.setPrototypeOf(f,d.prototype),f}function d(x,f,m){if(typeof x=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return w(x)}return _(x,f,m)}d.poolSize=8192;function _(x,f,m){if(typeof x=="string")return q(x,f);if(u.isView(x))return A(x);if(x==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof x);if(Te(x,u)||x&&Te(x.buffer,u)||typeof a!="undefined"&&(Te(x,a)||x&&Te(x.buffer,a)))return R(x,f,m);if(typeof x=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const F=x.valueOf&&x.valueOf();if(F!=null&&F!==x)return d.from(F,f,m);const W=S(x);if(W)return W;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof x[Symbol.toPrimitive]=="function")return d.from(x[Symbol.toPrimitive]("string"),f,m);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof x)}d.from=function(x,f,m){return _(x,f,m)},Object.setPrototypeOf(d.prototype,o.prototype),Object.setPrototypeOf(d,o);function g(x){if(typeof x!="number")throw new TypeError('"size" argument must be of type number');if(x<0)throw new RangeError('The value "'+x+'" is invalid for option "size"')}function E(x,f,m){return g(x),x<=0?l(x):f!==void 0?typeof m=="string"?l(x).fill(f,m):l(x).fill(f):l(x)}d.alloc=function(x,f,m){return E(x,f,m)};function w(x){return g(x),l(x<0?0:b(x)|0)}d.allocUnsafe=function(x){return w(x)},d.allocUnsafeSlow=function(x){return w(x)};function q(x,f){if((typeof f!="string"||f==="")&&(f="utf8"),!d.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const m=p(x,f)|0;let F=l(m);const W=F.write(x,f);return W!==m&&(F=F.slice(0,W)),F}function k(x){const f=x.length<0?0:b(x.length)|0,m=l(f);for(let F=0;F<f;F+=1)m[F]=x[F]&255;return m}function A(x){if(Te(x,o)){const f=new o(x);return R(f.buffer,f.byteOffset,f.byteLength)}return k(x)}function R(x,f,m){if(f<0||x.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(x.byteLength<f+(m||0))throw new RangeError('"length" is outside of buffer bounds');let F;return f===void 0&&m===void 0?F=new o(x):m===void 0?F=new o(x,f):F=new o(x,f,m),Object.setPrototypeOf(F,d.prototype),F}function S(x){if(d.isBuffer(x)){const f=b(x.length)|0,m=l(f);return m.length===0||x.copy(m,0,0,f),m}if(x.length!==void 0)return typeof x.length!="number"||qe(x.length)?l(0):k(x);if(x.type==="Buffer"&&Array.isArray(x.data))return k(x.data)}function b(x){if(x>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return x|0}function h(x){return+x!=x&&(x=0),d.alloc(+x)}d.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==d.prototype},d.compare=function(f,m){if(Te(f,o)&&(f=d.from(f,f.offset,f.byteLength)),Te(m,o)&&(m=d.from(m,m.offset,m.byteLength)),!d.isBuffer(f)||!d.isBuffer(m))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===m)return 0;let F=f.length,W=m.length;for(let te=0,N=Math.min(F,W);te<N;++te)if(f[te]!==m[te]){F=f[te],W=m[te];break}return F<W?-1:W<F?1:0},d.isEncoding=function(f){switch(String(f).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(f,m){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return d.alloc(0);let F;if(m===void 0)for(m=0,F=0;F<f.length;++F)m+=f[F].length;const W=d.allocUnsafe(m);let te=0;for(F=0;F<f.length;++F){let N=f[F];if(Te(N,o))te+N.length>W.length?(d.isBuffer(N)||(N=d.from(N)),N.copy(W,te)):o.prototype.set.call(W,N,te);else if(d.isBuffer(N))N.copy(W,te);else throw new TypeError('"list" argument must be an Array of Buffers');te+=N.length}return W};function p(x,f){if(d.isBuffer(x))return x.length;if(u.isView(x)||Te(x,u))return x.byteLength;if(typeof x!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof x);const m=x.length,F=arguments.length>2&&arguments[2]===!0;if(!F&&m===0)return 0;let W=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return m;case"utf8":case"utf-8":return je(x).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m*2;case"hex":return m>>>1;case"base64":return pe(x).length;default:if(W)return F?-1:je(x).length;f=(""+f).toLowerCase(),W=!0}}d.byteLength=p;function v(x,f,m){let F=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((m===void 0||m>this.length)&&(m=this.length),m<=0)||(m>>>=0,f>>>=0,m<=f))return"";for(x||(x="utf8");;)switch(x){case"hex":return G(this,f,m);case"utf8":case"utf-8":return he(this,f,m);case"ascii":return de(this,f,m);case"latin1":case"binary":return be(this,f,m);case"base64":return se(this,f,m);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return re(this,f,m);default:if(F)throw new TypeError("Unknown encoding: "+x);x=(x+"").toLowerCase(),F=!0}}d.prototype._isBuffer=!0;function I(x,f,m){const F=x[f];x[f]=x[m],x[m]=F}d.prototype.swap16=function(){const f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let m=0;m<f;m+=2)I(this,m,m+1);return this},d.prototype.swap32=function(){const f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let m=0;m<f;m+=4)I(this,m,m+3),I(this,m+1,m+2);return this},d.prototype.swap64=function(){const f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let m=0;m<f;m+=8)I(this,m,m+7),I(this,m+1,m+6),I(this,m+2,m+5),I(this,m+3,m+4);return this},d.prototype.toString=function(){const f=this.length;return f===0?"":arguments.length===0?he(this,0,f):v.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(f){if(!d.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:d.compare(this,f)===0},d.prototype.inspect=function(){let f="";const m=i.INSPECT_MAX_BYTES;return f=this.toString("hex",0,m).replace(/(.{2})/g,"$1 ").trim(),this.length>m&&(f+=" ... "),"<Buffer "+f+">"},r&&(d.prototype[r]=d.prototype.inspect),d.prototype.compare=function(f,m,F,W,te){if(Te(f,o)&&(f=d.from(f,f.offset,f.byteLength)),!d.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(m===void 0&&(m=0),F===void 0&&(F=f?f.length:0),W===void 0&&(W=0),te===void 0&&(te=this.length),m<0||F>f.length||W<0||te>this.length)throw new RangeError("out of range index");if(W>=te&&m>=F)return 0;if(W>=te)return-1;if(m>=F)return 1;if(m>>>=0,F>>>=0,W>>>=0,te>>>=0,this===f)return 0;let N=te-W,Z=F-m;const Ee=Math.min(N,Z),Ae=this.slice(W,te),_e=f.slice(m,F);for(let ve=0;ve<Ee;++ve)if(Ae[ve]!==_e[ve]){N=Ae[ve],Z=_e[ve];break}return N<Z?-1:Z<N?1:0};function B(x,f,m,F,W){if(x.length===0)return-1;if(typeof m=="string"?(F=m,m=0):m>2147483647?m=2147483647:m<-2147483648&&(m=-2147483648),m=+m,qe(m)&&(m=W?0:x.length-1),m<0&&(m=x.length+m),m>=x.length){if(W)return-1;m=x.length-1}else if(m<0)if(W)m=0;else return-1;if(typeof f=="string"&&(f=d.from(f,F)),d.isBuffer(f))return f.length===0?-1:H(x,f,m,F,W);if(typeof f=="number")return f=f&255,typeof o.prototype.indexOf=="function"?W?o.prototype.indexOf.call(x,f,m):o.prototype.lastIndexOf.call(x,f,m):H(x,[f],m,F,W);throw new TypeError("val must be string, number or Buffer")}function H(x,f,m,F,W){let te=1,N=x.length,Z=f.length;if(F!==void 0&&(F=String(F).toLowerCase(),F==="ucs2"||F==="ucs-2"||F==="utf16le"||F==="utf-16le")){if(x.length<2||f.length<2)return-1;te=2,N/=2,Z/=2,m/=2}function Ee(_e,ve){return te===1?_e[ve]:_e.readUInt16BE(ve*te)}let Ae;if(W){let _e=-1;for(Ae=m;Ae<N;Ae++)if(Ee(x,Ae)===Ee(f,_e===-1?0:Ae-_e)){if(_e===-1&&(_e=Ae),Ae-_e+1===Z)return _e*te}else _e!==-1&&(Ae-=Ae-_e),_e=-1}else for(m+Z>N&&(m=N-Z),Ae=m;Ae>=0;Ae--){let _e=!0;for(let ve=0;ve<Z;ve++)if(Ee(x,Ae+ve)!==Ee(f,ve)){_e=!1;break}if(_e)return Ae}return-1}d.prototype.includes=function(f,m,F){return this.indexOf(f,m,F)!==-1},d.prototype.indexOf=function(f,m,F){return B(this,f,m,F,!0)},d.prototype.lastIndexOf=function(f,m,F){return B(this,f,m,F,!1)};function V(x,f,m,F){m=Number(m)||0;const W=x.length-m;F?(F=Number(F),F>W&&(F=W)):F=W;const te=f.length;F>te/2&&(F=te/2);let N;for(N=0;N<F;++N){const Z=parseInt(f.substr(N*2,2),16);if(qe(Z))return N;x[m+N]=Z}return N}function P(x,f,m,F){return X(je(f,x.length-m),x,m,F)}function ce(x,f,m,F){return X(De(f),x,m,F)}function oe(x,f,m,F){return X(pe(f),x,m,F)}function ne(x,f,m,F){return X(K(f,x.length-m),x,m,F)}d.prototype.write=function(f,m,F,W){if(m===void 0)W="utf8",F=this.length,m=0;else if(F===void 0&&typeof m=="string")W=m,F=this.length,m=0;else if(isFinite(m))m=m>>>0,isFinite(F)?(F=F>>>0,W===void 0&&(W="utf8")):(W=F,F=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const te=this.length-m;if((F===void 0||F>te)&&(F=te),f.length>0&&(F<0||m<0)||m>this.length)throw new RangeError("Attempt to write outside buffer bounds");W||(W="utf8");let N=!1;for(;;)switch(W){case"hex":return V(this,f,m,F);case"utf8":case"utf-8":return P(this,f,m,F);case"ascii":case"latin1":case"binary":return ce(this,f,m,F);case"base64":return oe(this,f,m,F);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,f,m,F);default:if(N)throw new TypeError("Unknown encoding: "+W);W=(""+W).toLowerCase(),N=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function se(x,f,m){return f===0&&m===x.length?e.fromByteArray(x):e.fromByteArray(x.slice(f,m))}function he(x,f,m){m=Math.min(x.length,m);const F=[];let W=f;for(;W<m;){const te=x[W];let N=null,Z=te>239?4:te>223?3:te>191?2:1;if(W+Z<=m){let Ee,Ae,_e,ve;switch(Z){case 1:te<128&&(N=te);break;case 2:Ee=x[W+1],(Ee&192)===128&&(ve=(te&31)<<6|Ee&63,ve>127&&(N=ve));break;case 3:Ee=x[W+1],Ae=x[W+2],(Ee&192)===128&&(Ae&192)===128&&(ve=(te&15)<<12|(Ee&63)<<6|Ae&63,ve>2047&&(ve<55296||ve>57343)&&(N=ve));break;case 4:Ee=x[W+1],Ae=x[W+2],_e=x[W+3],(Ee&192)===128&&(Ae&192)===128&&(_e&192)===128&&(ve=(te&15)<<18|(Ee&63)<<12|(Ae&63)<<6|_e&63,ve>65535&&ve<1114112&&(N=ve))}}N===null?(N=65533,Z=1):N>65535&&(N-=65536,F.push(N>>>10&1023|55296),N=56320|N&1023),F.push(N),W+=Z}return me(F)}const J=4096;function me(x){const f=x.length;if(f<=J)return String.fromCharCode.apply(String,x);let m="",F=0;for(;F<f;)m+=String.fromCharCode.apply(String,x.slice(F,F+=J));return m}function de(x,f,m){let F="";m=Math.min(x.length,m);for(let W=f;W<m;++W)F+=String.fromCharCode(x[W]&127);return F}function be(x,f,m){let F="";m=Math.min(x.length,m);for(let W=f;W<m;++W)F+=String.fromCharCode(x[W]);return F}function G(x,f,m){const F=x.length;(!f||f<0)&&(f=0),(!m||m<0||m>F)&&(m=F);let W="";for(let te=f;te<m;++te)W+=$e[x[te]];return W}function re(x,f,m){const F=x.slice(f,m);let W="";for(let te=0;te<F.length-1;te+=2)W+=String.fromCharCode(F[te]+F[te+1]*256);return W}d.prototype.slice=function(f,m){const F=this.length;f=~~f,m=m===void 0?F:~~m,f<0?(f+=F,f<0&&(f=0)):f>F&&(f=F),m<0?(m+=F,m<0&&(m=0)):m>F&&(m=F),m<f&&(m=f);const W=this.subarray(f,m);return Object.setPrototypeOf(W,d.prototype),W};function j(x,f,m){if(x%1!==0||x<0)throw new RangeError("offset is not uint");if(x+f>m)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(f,m,F){f=f>>>0,m=m>>>0,F||j(f,m,this.length);let W=this[f],te=1,N=0;for(;++N<m&&(te*=256);)W+=this[f+N]*te;return W},d.prototype.readUintBE=d.prototype.readUIntBE=function(f,m,F){f=f>>>0,m=m>>>0,F||j(f,m,this.length);let W=this[f+--m],te=1;for(;m>0&&(te*=256);)W+=this[f+--m]*te;return W},d.prototype.readUint8=d.prototype.readUInt8=function(f,m){return f=f>>>0,m||j(f,1,this.length),this[f]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(f,m){return f=f>>>0,m||j(f,2,this.length),this[f]|this[f+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(f,m){return f=f>>>0,m||j(f,2,this.length),this[f]<<8|this[f+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(f,m){return f=f>>>0,m||j(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(f,m){return f=f>>>0,m||j(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},d.prototype.readBigUInt64LE=Be(function(f){f=f>>>0,le(f,"offset");const m=this[f],F=this[f+7];(m===void 0||F===void 0)&&Se(f,this.length-8);const W=m+this[++f]*Oe(2,8)+this[++f]*Oe(2,16)+this[++f]*Oe(2,24),te=this[++f]+this[++f]*Oe(2,8)+this[++f]*Oe(2,16)+F*Oe(2,24);return BigInt(W)+(BigInt(te)<<BigInt(32))}),d.prototype.readBigUInt64BE=Be(function(f){f=f>>>0,le(f,"offset");const m=this[f],F=this[f+7];(m===void 0||F===void 0)&&Se(f,this.length-8);const W=m*Oe(2,24)+this[++f]*Oe(2,16)+this[++f]*Oe(2,8)+this[++f],te=this[++f]*Oe(2,24)+this[++f]*Oe(2,16)+this[++f]*Oe(2,8)+F;return(BigInt(W)<<BigInt(32))+BigInt(te)}),d.prototype.readIntLE=function(f,m,F){f=f>>>0,m=m>>>0,F||j(f,m,this.length);let W=this[f],te=1,N=0;for(;++N<m&&(te*=256);)W+=this[f+N]*te;return te*=128,W>=te&&(W-=Math.pow(2,8*m)),W},d.prototype.readIntBE=function(f,m,F){f=f>>>0,m=m>>>0,F||j(f,m,this.length);let W=m,te=1,N=this[f+--W];for(;W>0&&(te*=256);)N+=this[f+--W]*te;return te*=128,N>=te&&(N-=Math.pow(2,8*m)),N},d.prototype.readInt8=function(f,m){return f=f>>>0,m||j(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},d.prototype.readInt16LE=function(f,m){f=f>>>0,m||j(f,2,this.length);const F=this[f]|this[f+1]<<8;return F&32768?F|4294901760:F},d.prototype.readInt16BE=function(f,m){f=f>>>0,m||j(f,2,this.length);const F=this[f+1]|this[f]<<8;return F&32768?F|4294901760:F},d.prototype.readInt32LE=function(f,m){return f=f>>>0,m||j(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},d.prototype.readInt32BE=function(f,m){return f=f>>>0,m||j(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},d.prototype.readBigInt64LE=Be(function(f){f=f>>>0,le(f,"offset");const m=this[f],F=this[f+7];(m===void 0||F===void 0)&&Se(f,this.length-8);const W=this[f+4]+this[f+5]*Oe(2,8)+this[f+6]*Oe(2,16)+(F<<24);return(BigInt(W)<<BigInt(32))+BigInt(m+this[++f]*Oe(2,8)+this[++f]*Oe(2,16)+this[++f]*Oe(2,24))}),d.prototype.readBigInt64BE=Be(function(f){f=f>>>0,le(f,"offset");const m=this[f],F=this[f+7];(m===void 0||F===void 0)&&Se(f,this.length-8);const W=(m<<24)+this[++f]*Oe(2,16)+this[++f]*Oe(2,8)+this[++f];return(BigInt(W)<<BigInt(32))+BigInt(this[++f]*Oe(2,24)+this[++f]*Oe(2,16)+this[++f]*Oe(2,8)+F)}),d.prototype.readFloatLE=function(f,m){return f=f>>>0,m||j(f,4,this.length),t.read(this,f,!0,23,4)},d.prototype.readFloatBE=function(f,m){return f=f>>>0,m||j(f,4,this.length),t.read(this,f,!1,23,4)},d.prototype.readDoubleLE=function(f,m){return f=f>>>0,m||j(f,8,this.length),t.read(this,f,!0,52,8)},d.prototype.readDoubleBE=function(f,m){return f=f>>>0,m||j(f,8,this.length),t.read(this,f,!1,52,8)};function L(x,f,m,F,W,te){if(!d.isBuffer(x))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>W||f<te)throw new RangeError('"value" argument is out of bounds');if(m+F>x.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(f,m,F,W){if(f=+f,m=m>>>0,F=F>>>0,!W){const Z=Math.pow(2,8*F)-1;L(this,f,m,F,Z,0)}let te=1,N=0;for(this[m]=f&255;++N<F&&(te*=256);)this[m+N]=f/te&255;return m+F},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(f,m,F,W){if(f=+f,m=m>>>0,F=F>>>0,!W){const Z=Math.pow(2,8*F)-1;L(this,f,m,F,Z,0)}let te=F-1,N=1;for(this[m+te]=f&255;--te>=0&&(N*=256);)this[m+te]=f/N&255;return m+F},d.prototype.writeUint8=d.prototype.writeUInt8=function(f,m,F){return f=+f,m=m>>>0,F||L(this,f,m,1,255,0),this[m]=f&255,m+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(f,m,F){return f=+f,m=m>>>0,F||L(this,f,m,2,65535,0),this[m]=f&255,this[m+1]=f>>>8,m+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(f,m,F){return f=+f,m=m>>>0,F||L(this,f,m,2,65535,0),this[m]=f>>>8,this[m+1]=f&255,m+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(f,m,F){return f=+f,m=m>>>0,F||L(this,f,m,4,4294967295,0),this[m+3]=f>>>24,this[m+2]=f>>>16,this[m+1]=f>>>8,this[m]=f&255,m+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(f,m,F){return f=+f,m=m>>>0,F||L(this,f,m,4,4294967295,0),this[m]=f>>>24,this[m+1]=f>>>16,this[m+2]=f>>>8,this[m+3]=f&255,m+4};function M(x,f,m,F,W){ye(f,F,W,x,m,7);let te=Number(f&BigInt(4294967295));x[m++]=te,te=te>>8,x[m++]=te,te=te>>8,x[m++]=te,te=te>>8,x[m++]=te;let N=Number(f>>BigInt(32)&BigInt(4294967295));return x[m++]=N,N=N>>8,x[m++]=N,N=N>>8,x[m++]=N,N=N>>8,x[m++]=N,m}function D(x,f,m,F,W){ye(f,F,W,x,m,7);let te=Number(f&BigInt(4294967295));x[m+7]=te,te=te>>8,x[m+6]=te,te=te>>8,x[m+5]=te,te=te>>8,x[m+4]=te;let N=Number(f>>BigInt(32)&BigInt(4294967295));return x[m+3]=N,N=N>>8,x[m+2]=N,N=N>>8,x[m+1]=N,N=N>>8,x[m]=N,m+8}d.prototype.writeBigUInt64LE=Be(function(f,m=0){return M(this,f,m,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=Be(function(f,m=0){return D(this,f,m,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(f,m,F,W){if(f=+f,m=m>>>0,!W){const Ee=Math.pow(2,8*F-1);L(this,f,m,F,Ee-1,-Ee)}let te=0,N=1,Z=0;for(this[m]=f&255;++te<F&&(N*=256);)f<0&&Z===0&&this[m+te-1]!==0&&(Z=1),this[m+te]=(f/N>>0)-Z&255;return m+F},d.prototype.writeIntBE=function(f,m,F,W){if(f=+f,m=m>>>0,!W){const Ee=Math.pow(2,8*F-1);L(this,f,m,F,Ee-1,-Ee)}let te=F-1,N=1,Z=0;for(this[m+te]=f&255;--te>=0&&(N*=256);)f<0&&Z===0&&this[m+te+1]!==0&&(Z=1),this[m+te]=(f/N>>0)-Z&255;return m+F},d.prototype.writeInt8=function(f,m,F){return f=+f,m=m>>>0,F||L(this,f,m,1,127,-128),f<0&&(f=255+f+1),this[m]=f&255,m+1},d.prototype.writeInt16LE=function(f,m,F){return f=+f,m=m>>>0,F||L(this,f,m,2,32767,-32768),this[m]=f&255,this[m+1]=f>>>8,m+2},d.prototype.writeInt16BE=function(f,m,F){return f=+f,m=m>>>0,F||L(this,f,m,2,32767,-32768),this[m]=f>>>8,this[m+1]=f&255,m+2},d.prototype.writeInt32LE=function(f,m,F){return f=+f,m=m>>>0,F||L(this,f,m,4,2147483647,-2147483648),this[m]=f&255,this[m+1]=f>>>8,this[m+2]=f>>>16,this[m+3]=f>>>24,m+4},d.prototype.writeInt32BE=function(f,m,F){return f=+f,m=m>>>0,F||L(this,f,m,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[m]=f>>>24,this[m+1]=f>>>16,this[m+2]=f>>>8,this[m+3]=f&255,m+4},d.prototype.writeBigInt64LE=Be(function(f,m=0){return M(this,f,m,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=Be(function(f,m=0){return D(this,f,m,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function $(x,f,m,F,W,te){if(m+F>x.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("Index out of range")}function z(x,f,m,F,W){return f=+f,m=m>>>0,W||$(x,f,m,4),t.write(x,f,m,F,23,4),m+4}d.prototype.writeFloatLE=function(f,m,F){return z(this,f,m,!0,F)},d.prototype.writeFloatBE=function(f,m,F){return z(this,f,m,!1,F)};function Y(x,f,m,F,W){return f=+f,m=m>>>0,W||$(x,f,m,8),t.write(x,f,m,F,52,8),m+8}d.prototype.writeDoubleLE=function(f,m,F){return Y(this,f,m,!0,F)},d.prototype.writeDoubleBE=function(f,m,F){return Y(this,f,m,!1,F)},d.prototype.copy=function(f,m,F,W){if(!d.isBuffer(f))throw new TypeError("argument should be a Buffer");if(F||(F=0),!W&&W!==0&&(W=this.length),m>=f.length&&(m=f.length),m||(m=0),W>0&&W<F&&(W=F),W===F||f.length===0||this.length===0)return 0;if(m<0)throw new RangeError("targetStart out of bounds");if(F<0||F>=this.length)throw new RangeError("Index out of range");if(W<0)throw new RangeError("sourceEnd out of bounds");W>this.length&&(W=this.length),f.length-m<W-F&&(W=f.length-m+F);const te=W-F;return this===f&&typeof o.prototype.copyWithin=="function"?this.copyWithin(m,F,W):o.prototype.set.call(f,this.subarray(F,W),m),te},d.prototype.fill=function(f,m,F,W){if(typeof f=="string"){if(typeof m=="string"?(W=m,m=0,F=this.length):typeof F=="string"&&(W=F,F=this.length),W!==void 0&&typeof W!="string")throw new TypeError("encoding must be a string");if(typeof W=="string"&&!d.isEncoding(W))throw new TypeError("Unknown encoding: "+W);if(f.length===1){const N=f.charCodeAt(0);(W==="utf8"&&N<128||W==="latin1")&&(f=N)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(m<0||this.length<m||this.length<F)throw new RangeError("Out of range index");if(F<=m)return this;m=m>>>0,F=F===void 0?this.length:F>>>0,f||(f=0);let te;if(typeof f=="number")for(te=m;te<F;++te)this[te]=f;else{const N=d.isBuffer(f)?f:d.from(f,W),Z=N.length;if(Z===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for(te=0;te<F-m;++te)this[te+m]=N[te%Z]}return this};const T={};function O(x,f,m){T[x]=class extends m{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${x}]`,this.stack,delete this.name}get code(){return x}set code(W){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:W,writable:!0})}toString(){return`${this.name} [${x}]: ${this.message}`}}}O("ERR_BUFFER_OUT_OF_BOUNDS",function(x){return x?`${x} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),O("ERR_INVALID_ARG_TYPE",function(x,f){return`The "${x}" argument must be of type number. Received type ${typeof f}`},TypeError),O("ERR_OUT_OF_RANGE",function(x,f,m){let F=`The value of "${x}" is out of range.`,W=m;return Number.isInteger(m)&&Math.abs(m)>Oe(2,32)?W=ee(String(m)):typeof m=="bigint"&&(W=String(m),(m>Oe(BigInt(2),BigInt(32))||m<-Oe(BigInt(2),BigInt(32)))&&(W=ee(W)),W+="n"),F+=` It must be ${f}. Received ${W}`,F},RangeError);function ee(x){let f="",m=x.length;const F=x[0]==="-"?1:0;for(;m>=F+4;m-=3)f=`_${x.slice(m-3,m)}${f}`;return`${x.slice(0,m)}${f}`}function ae(x,f,m){le(f,"offset"),(x[f]===void 0||x[f+m]===void 0)&&Se(f,x.length-(m+1))}function ye(x,f,m,F,W,te){if(x>m||x<f){const N=typeof f=="bigint"?"n":"";let Z;throw f===0||f===BigInt(0)?Z=`>= 0${N} and < 2${N} ** ${(te+1)*8}${N}`:Z=`>= -(2${N} ** ${(te+1)*8-1}${N}) and < 2 ** ${(te+1)*8-1}${N}`,new T.ERR_OUT_OF_RANGE("value",Z,x)}ae(F,W,te)}function le(x,f){if(typeof x!="number")throw new T.ERR_INVALID_ARG_TYPE(f,"number",x)}function Se(x,f,m){throw Math.floor(x)!==x?(le(x,m),new T.ERR_OUT_OF_RANGE("offset","an integer",x)):f<0?new T.ERR_BUFFER_OUT_OF_BOUNDS:new T.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,x)}const Pe=/[^+/0-9A-Za-z-_]/g;function ue(x){if(x=x.split("=")[0],x=x.trim().replace(Pe,""),x.length<2)return"";for(;x.length%4!==0;)x=x+"=";return x}function je(x,f){f=f||1/0;let m;const F=x.length;let W=null;const te=[];for(let N=0;N<F;++N){if(m=x.charCodeAt(N),m>55295&&m<57344){if(!W){if(m>56319){(f-=3)>-1&&te.push(239,191,189);continue}else if(N+1===F){(f-=3)>-1&&te.push(239,191,189);continue}W=m;continue}if(m<56320){(f-=3)>-1&&te.push(239,191,189),W=m;continue}m=(W-55296<<10|m-56320)+65536}else W&&(f-=3)>-1&&te.push(239,191,189);if(W=null,m<128){if((f-=1)<0)break;te.push(m)}else if(m<2048){if((f-=2)<0)break;te.push(m>>6|192,m&63|128)}else if(m<65536){if((f-=3)<0)break;te.push(m>>12|224,m>>6&63|128,m&63|128)}else if(m<1114112){if((f-=4)<0)break;te.push(m>>18|240,m>>12&63|128,m>>6&63|128,m&63|128)}else throw new Error("Invalid code point")}return te}function De(x){const f=[];for(let m=0;m<x.length;++m)f.push(x.charCodeAt(m)&255);return f}function K(x,f){let m,F,W;const te=[];for(let N=0;N<x.length&&!((f-=2)<0);++N)m=x.charCodeAt(N),F=m>>8,W=m%256,te.push(W),te.push(F);return te}function pe(x){return e.toByteArray(ue(x))}function X(x,f,m,F){let W;for(W=0;W<F&&!(W+m>=f.length||W>=x.length);++W)f[W+m]=x[W];return W}function Te(x,f){return x instanceof f||x!=null&&x.constructor!=null&&x.constructor.name!=null&&x.constructor.name===f.name}function qe(x){return x!==x}const $e=(function(){const x="0123456789abcdef",f=new Array(256);for(let m=0;m<16;++m){const F=m*16;for(let W=0;W<16;++W)f[F+W]=x[m]+x[W]}return f})();function Be(x){return typeof BigInt=="undefined"?Ie:x}function Ie(){throw new Error("BigInt not supported")}})(Wd);const we=Wd.Buffer;var ya={exports:{}},Gd;function zd(){return Gd||(Gd=1,(function(i){const e=i.exports;e.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"},e.codes={};for(const r in e.types){const n=e.types[r];e.codes[n]=r}e.CMD_SHIFT=4,e.CMD_MASK=240,e.DUP_MASK=8,e.QOS_MASK=3,e.QOS_SHIFT=1,e.RETAIN_MASK=1,e.VARBYTEINT_MASK=127,e.VARBYTEINT_FIN_MASK=128,e.VARBYTEINT_MAX=268435455,e.SESSIONPRESENT_MASK=1,e.SESSIONPRESENT_HEADER=we.from([e.SESSIONPRESENT_MASK]),e.CONNACK_HEADER=we.from([e.codes.connack<<e.CMD_SHIFT]),e.USERNAME_MASK=128,e.PASSWORD_MASK=64,e.WILL_RETAIN_MASK=32,e.WILL_QOS_MASK=24,e.WILL_QOS_SHIFT=3,e.WILL_FLAG_MASK=4,e.CLEAN_SESSION_MASK=2,e.CONNECT_HEADER=we.from([e.codes.connect<<e.CMD_SHIFT]),e.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},e.propertiesCodes={};for(const r in e.properties){const n=e.properties[r];e.propertiesCodes[n]=r}e.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"};function t(r){return[0,1,2].map(n=>[0,1].map(o=>[0,1].map(u=>{const a=we.alloc(1);return a.writeUInt8(e.codes[r]<<e.CMD_SHIFT|(o?e.DUP_MASK:0)|n<<e.QOS_SHIFT|u,0,!0),a})))}e.PUBLISH_HEADER=t("publish"),e.SUBSCRIBE_HEADER=t("subscribe"),e.SUBSCRIBE_OPTIONS_QOS_MASK=3,e.SUBSCRIBE_OPTIONS_NL_MASK=1,e.SUBSCRIBE_OPTIONS_NL_SHIFT=2,e.SUBSCRIBE_OPTIONS_RAP_MASK=1,e.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,e.SUBSCRIBE_OPTIONS_RH_MASK=3,e.SUBSCRIBE_OPTIONS_RH_SHIFT=4,e.SUBSCRIBE_OPTIONS_RH=[0,16,32],e.SUBSCRIBE_OPTIONS_NL=4,e.SUBSCRIBE_OPTIONS_RAP=8,e.SUBSCRIBE_OPTIONS_QOS=[0,1,2],e.UNSUBSCRIBE_HEADER=t("unsubscribe"),e.ACKS={unsuback:t("unsuback"),puback:t("puback"),pubcomp:t("pubcomp"),pubrel:t("pubrel"),pubrec:t("pubrec")},e.SUBACK_HEADER=we.from([e.codes.suback<<e.CMD_SHIFT]),e.VERSION3=we.from([3]),e.VERSION4=we.from([4]),e.VERSION5=we.from([5]),e.VERSION131=we.from([131]),e.VERSION132=we.from([132]),e.QOS=[0,1,2].map(r=>we.from([r])),e.EMPTY={pingreq:we.from([e.codes.pingreq<<4,0]),pingresp:we.from([e.codes.pingresp<<4,0]),disconnect:we.from([e.codes.disconnect<<4,0])}})(ya)),ya.exports}var dr={exports:{}},ga,Vd;function v_(){if(Vd)return ga;Vd=1;var i=1e3,e=i*60,t=e*60,r=t*24,n=r*7,o=r*365.25;ga=function(d,_){_=_||{};var g=typeof d;if(g==="string"&&d.length>0)return u(d);if(g==="number"&&isFinite(d))return _.long?s(d):a(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))};function u(d){if(d=String(d),!(d.length>100)){var _=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(_){var g=parseFloat(_[1]),E=(_[2]||"ms").toLowerCase();switch(E){case"years":case"year":case"yrs":case"yr":case"y":return g*o;case"weeks":case"week":case"w":return g*n;case"days":case"day":case"d":return g*r;case"hours":case"hour":case"hrs":case"hr":case"h":return g*t;case"minutes":case"minute":case"mins":case"min":case"m":return g*e;case"seconds":case"second":case"secs":case"sec":case"s":return g*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return g;default:return}}}}function a(d){var _=Math.abs(d);return _>=r?Math.round(d/r)+"d":_>=t?Math.round(d/t)+"h":_>=e?Math.round(d/e)+"m":_>=i?Math.round(d/i)+"s":d+"ms"}function s(d){var _=Math.abs(d);return _>=r?l(d,_,r,"day"):_>=t?l(d,_,t,"hour"):_>=e?l(d,_,e,"minute"):_>=i?l(d,_,i,"second"):d+" ms"}function l(d,_,g,E){var w=_>=g*1.5;return Math.round(d/g)+" "+E+(w?"s":"")}return ga}var _a,Kd;function b_(){if(Kd)return _a;Kd=1;function i(e){r.debug=r,r.default=r,r.coerce=l,r.disable=a,r.enable=o,r.enabled=s,r.humanize=v_(),r.destroy=d,Object.keys(e).forEach(_=>{r[_]=e[_]}),r.names=[],r.skips=[],r.formatters={};function t(_){let g=0;for(let E=0;E<_.length;E++)g=(g<<5)-g+_.charCodeAt(E),g|=0;return r.colors[Math.abs(g)%r.colors.length]}r.selectColor=t;function r(_){let g,E=null,w,q;function k(...A){if(!k.enabled)return;const R=k,S=Number(new Date),b=S-(g||S);R.diff=b,R.prev=g,R.curr=S,g=S,A[0]=r.coerce(A[0]),typeof A[0]!="string"&&A.unshift("%O");let h=0;A[0]=A[0].replace(/%([a-zA-Z%])/g,(v,I)=>{if(v==="%%")return"%";h++;const B=r.formatters[I];if(typeof B=="function"){const H=A[h];v=B.call(R,H),A.splice(h,1),h--}return v}),r.formatArgs.call(R,A),(R.log||r.log).apply(R,A)}return k.namespace=_,k.useColors=r.useColors(),k.color=r.selectColor(_),k.extend=n,k.destroy=r.destroy,Object.defineProperty(k,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(w!==r.namespaces&&(w=r.namespaces,q=r.enabled(_)),q),set:A=>{E=A}}),typeof r.init=="function"&&r.init(k),k}function n(_,g){const E=r(this.namespace+(typeof g=="undefined"?":":g)+_);return E.log=this.log,E}function o(_){r.save(_),r.namespaces=_,r.names=[],r.skips=[];const g=(typeof _=="string"?_:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const E of g)E[0]==="-"?r.skips.push(E.slice(1)):r.names.push(E)}function u(_,g){let E=0,w=0,q=-1,k=0;for(;E<_.length;)if(w<g.length&&(g[w]===_[E]||g[w]==="*"))g[w]==="*"?(q=w,k=E,w++):(E++,w++);else if(q!==-1)w=q+1,k++,E=k;else return!1;for(;w<g.length&&g[w]==="*";)w++;return w===g.length}function a(){const _=[...r.names,...r.skips.map(g=>"-"+g)].join(",");return r.enable(""),_}function s(_){for(const g of r.skips)if(u(_,g))return!1;for(const g of r.names)if(u(_,g))return!0;return!1}function l(_){return _ instanceof Error?_.stack||_.message:_}function d(){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 r.enable(r.load()),r}return _a=i,_a}var Qd;function Rt(){return Qd||(Qd=1,(function(i,e){e.formatArgs=r,e.save=n,e.load=o,e.useColors=t,e.storage=u(),e.destroy=(()=>{let s=!1;return()=>{s||(s=!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`."))}})(),e.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 t(){if(typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let s;return typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&(s=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(s[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(s){if(s[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+s[0]+(this.useColors?"%c ":" ")+"+"+i.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;s.splice(1,0,l,"color: inherit");let d=0,_=0;s[0].replace(/%[a-zA-Z%]/g,g=>{g!=="%%"&&(d++,g==="%c"&&(_=d))}),s.splice(_,0,l)}e.log=console.debug||console.log||(()=>{});function n(s){try{s?e.storage.setItem("debug",s):e.storage.removeItem("debug")}catch(l){}}function o(){let s;try{s=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch(l){}return!s&&typeof Re!="undefined"&&"env"in Re&&(s=Re.env.DEBUG),s}function u(){try{return localStorage}catch(s){}}i.exports=b_()(e);const{formatters:a}=i.exports;a.j=function(s){try{return JSON.stringify(s)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}})(dr,dr.exports)),dr.exports}var va,Jd;function w_(){if(Jd)return va;Jd=1;const i=f_(),e=Gt(),t=l_(),r=zd(),n=Rt()("mqtt-packet:parser");class o extends e{constructor(){super(),this.parser=this.constructor.parser}static parser(a){return this instanceof o?(this.settings=a||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new o().parser(a)}_resetState(){n("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new t,this.error=null,this._list=i(),this._stateCounter=0}parse(a){for(this.error&&this._resetState(),this._list.append(a),n("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++,n("parse: state complete. _stateCounter is now: %d",this._stateCounter),n("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return n("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const a=this._list.readUInt8(0);return this.packet.cmd=r.types[a>>r.CMD_SHIFT],this.packet.retain=(a&r.RETAIN_MASK)!==0,this.packet.qos=a>>r.QOS_SHIFT&r.QOS_MASK,this.packet.dup=(a&r.DUP_MASK)!==0,n("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const a=this._parseVarByteNum(!0);return a&&(this.packet.length=a.value,this._list.consume(a.bytes)),n("_parseLength %d",a.value),!!a}_parsePayload(){n("_parsePayload: payload %O",this._list);let a=!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"))}a=!0}return n("_parsePayload complete result: %s",a),a}_parseConnect(){n("_parseConnect");let a,s,l,d;const _={},g=this.packet,E=this._parseString();if(E===null)return this._emitError(new Error("Cannot parse protocolId"));if(E!=="MQTT"&&E!=="MQIsdp")return this._emitError(new Error("Invalid protocolId"));if(g.protocolId=E,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(_.username=this._list.readUInt8(this._pos)&r.USERNAME_MASK,_.password=this._list.readUInt8(this._pos)&r.PASSWORD_MASK,_.will=this._list.readUInt8(this._pos)&r.WILL_FLAG_MASK,_.will&&(g.will={},g.will.retain=(this._list.readUInt8(this._pos)&r.WILL_RETAIN_MASK)!==0,g.will.qos=(this._list.readUInt8(this._pos)&r.WILL_QOS_MASK)>>r.WILL_QOS_SHIFT),g.clean=(this._list.readUInt8(this._pos)&r.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){const q=this._parseProperties();Object.getOwnPropertyNames(q).length&&(g.properties=q)}const w=this._parseString();if(w===null)return this._emitError(new Error("Packet too short"));if(g.clientId=w,n("_parseConnect: packet.clientId: %s",g.clientId),_.will){if(g.protocolVersion===5){const q=this._parseProperties();Object.getOwnPropertyNames(q).length&&(g.will.properties=q)}if(a=this._parseString(),a===null)return this._emitError(new Error("Cannot parse will topic"));if(g.will.topic=a,n("_parseConnect: packet.will.topic: %s",g.will.topic),s=this._parseBuffer(),s===null)return this._emitError(new Error("Cannot parse will payload"));g.will.payload=s,n("_parseConnect: packet.will.paylaod: %s",g.will.payload)}if(_.username){if(d=this._parseString(),d===null)return this._emitError(new Error("Cannot parse username"));g.username=d,n("_parseConnect: packet.username: %s",g.username)}if(_.password){if(l=this._parseBuffer(),l===null)return this._emitError(new Error("Cannot parse password"));g.password=l}return this.settings=g,n("_parseConnect: complete"),g}_parseConnack(){n("_parseConnack");const a=this.packet;if(this._list.length<1)return null;if(a.sessionPresent=!!(this._list.readUInt8(this._pos++)&r.SESSIONPRESENT_MASK),this.settings.protocolVersion===5)this._list.length>=2?a.reasonCode=this._list.readUInt8(this._pos++):a.reasonCode=0;else{if(this._list.length<2)return null;a.returnCode=this._list.readUInt8(this._pos++)}if(a.returnCode===-1||a.reasonCode===-1)return this._emitError(new Error("Cannot parse return code"));if(this.settings.protocolVersion===5){const s=this._parseProperties();Object.getOwnPropertyNames(s).length&&(a.properties=s)}n("_parseConnack: complete")}_parsePublish(){n("_parsePublish");const a=this.packet;if(a.topic=this._parseString(),a.topic===null)return this._emitError(new Error("Cannot parse topic"));if(!(a.qos>0&&!this._parseMessageId())){if(this.settings.protocolVersion===5){const s=this._parseProperties();Object.getOwnPropertyNames(s).length&&(a.properties=s)}a.payload=this._list.slice(this._pos,a.length),n("_parsePublish: payload from buffer list: %o",a.payload)}}_parseSubscribe(){n("_parseSubscribe");const a=this.packet;let s,l,d,_,g,E,w;if(a.qos!==1)return this._emitError(new Error("Wrong subscribe header"));if(a.subscriptions=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){const q=this._parseProperties();Object.getOwnPropertyNames(q).length&&(a.properties=q)}for(;this._pos<a.length;){if(s=this._parseString(),s===null)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=a.length)return this._emitError(new Error("Malformed Subscribe Payload"));l=this._parseByte(),d=l&r.SUBSCRIBE_OPTIONS_QOS_MASK,E=(l>>r.SUBSCRIBE_OPTIONS_NL_SHIFT&r.SUBSCRIBE_OPTIONS_NL_MASK)!==0,g=(l>>r.SUBSCRIBE_OPTIONS_RAP_SHIFT&r.SUBSCRIBE_OPTIONS_RAP_MASK)!==0,_=l>>r.SUBSCRIBE_OPTIONS_RH_SHIFT&r.SUBSCRIBE_OPTIONS_RH_MASK,w={topic:s,qos:d},this.settings.protocolVersion===5?(w.nl=E,w.rap=g,w.rh=_):this.settings.bridgeMode&&(w.rh=0,w.rap=!0,w.nl=!0),n("_parseSubscribe: push subscription `%s` to subscription",w),a.subscriptions.push(w)}}}_parseSuback(){n("_parseSuback");const a=this.packet;if(this.packet.granted=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){const s=this._parseProperties();Object.getOwnPropertyNames(s).length&&(a.properties=s)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){n("_parseUnsubscribe");const a=this.packet;if(a.unsubscriptions=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){const s=this._parseProperties();Object.getOwnPropertyNames(s).length&&(a.properties=s)}for(;this._pos<a.length;){const s=this._parseString();if(s===null)return this._emitError(new Error("Cannot parse topic"));n("_parseUnsubscribe: push topic `%s` to unsubscriptions",s),a.unsubscriptions.push(s)}}}_parseUnsuback(){n("_parseUnsuback");const a=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(this.settings.protocolVersion===5){const s=this._parseProperties();for(Object.getOwnPropertyNames(s).length&&(a.properties=s),a.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){n("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const a=this.packet;if(this._parseMessageId(),this.settings.protocolVersion===5&&(a.length>2?(a.reasonCode=this._parseByte(),n("_parseConfirmation: packet.reasonCode `%d`",a.reasonCode)):a.reasonCode=0,a.length>3)){const s=this._parseProperties();Object.getOwnPropertyNames(s).length&&(a.properties=s)}return!0}_parseDisconnect(){const a=this.packet;if(n("_parseDisconnect"),this.settings.protocolVersion===5){this._list.length>0?a.reasonCode=this._parseByte():a.reasonCode=0;const s=this._parseProperties();Object.getOwnPropertyNames(s).length&&(a.properties=s)}return n("_parseDisconnect result: true"),!0}_parseAuth(){n("_parseAuth");const a=this.packet;if(this.settings.protocolVersion!==5)return this._emitError(new Error("Not supported auth packet for this version MQTT"));a.reasonCode=this._parseByte();const s=this._parseProperties();return Object.getOwnPropertyNames(s).length&&(a.properties=s),n("_parseAuth: result: true"),!0}_parseMessageId(){const a=this.packet;return a.messageId=this._parseNum(),a.messageId===null?(this._emitError(new Error("Cannot parse messageId")),!1):(n("_parseMessageId: packet.messageId %d",a.messageId),!0)}_parseString(a){const s=this._parseNum(),l=s+this._pos;if(s===-1||l>this._list.length||l>this.packet.length)return null;const d=this._list.toString("utf8",this._pos,l);return this._pos+=s,n("_parseString: result: %s",d),d}_parseStringPair(){return n("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const a=this._parseNum(),s=a+this._pos;if(a===-1||s>this._list.length||s>this.packet.length)return null;const l=this._list.slice(this._pos,s);return this._pos+=a,n("_parseBuffer: result: %o",l),l}_parseNum(){if(this._list.length-this._pos<2)return-1;const a=this._list.readUInt16BE(this._pos);return this._pos+=2,n("_parseNum: result: %s",a),a}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const a=this._list.readUInt32BE(this._pos);return this._pos+=4,n("_parse4ByteNum: result: %s",a),a}_parseVarByteNum(a){n("_parseVarByteNum");const s=4;let l=0,d=1,_=0,g=!1,E;const w=this._pos?this._pos:0;for(;l<s&&w+l<this._list.length;){if(E=this._list.readUInt8(w+l++),_+=d*(E&r.VARBYTEINT_MASK),d*=128,(E&r.VARBYTEINT_FIN_MASK)===0){g=!0;break}if(this._list.length<=l)break}return!g&&l===s&&this._list.length>=l&&this._emitError(new Error("Invalid variable byte integer")),w&&(this._pos+=l),g=g?a?{bytes:l,value:_}:_:!1,n("_parseVarByteNum: result: %o",g),g}_parseByte(){let a;return this._pos<this._list.length&&(a=this._list.readUInt8(this._pos),this._pos++),n("_parseByte: result: %o",a),a}_parseByType(a){switch(n("_parseByType: type: %s",a),a){case"byte":return this._parseByte()!==0;case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){n("_parseProperties");const a=this._parseVarByteNum(),l=this._pos+a,d={};for(;this._pos<l;){const _=this._parseByte();if(!_)return this._emitError(new Error("Cannot parse property code type")),!1;const g=r.propertiesCodes[_];if(!g)return this._emitError(new Error("Unknown property")),!1;if(g==="userProperties"){d[g]||(d[g]=Object.create(null));const E=this._parseByType(r.propertiesTypes[g]);if(d[g][E.name])if(Array.isArray(d[g][E.name]))d[g][E.name].push(E.value);else{const w=d[g][E.name];d[g][E.name]=[w],d[g][E.name].push(E.value)}else d[g][E.name]=E.value;continue}d[g]?Array.isArray(d[g])?d[g].push(this._parseByType(r.propertiesTypes[g])):(d[g]=[d[g]],d[g].push(this._parseByType(r.propertiesTypes[g]))):d[g]=this._parseByType(r.propertiesTypes[g])}return d}_newPacket(){return n("_newPacket"),this.packet&&(this._list.consume(this.packet.length),n("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),n("_newPacket: new packet"),this.packet=new t,this._pos=0,!0}_emitError(a){n("_emitError"),this.error=a,this.emit("error",a)}}return va=o,va}var ba,Xd;function S_(){if(Xd)return ba;Xd=1;const i=65536,e={},t=we.isBuffer(we.from([1,2]).subarray(0,1));function r(a){const s=we.allocUnsafe(2);return s.writeUInt8(a>>8,0),s.writeUInt8(a&255,1),s}function n(){for(let a=0;a<i;a++)e[a]=r(a)}function o(a){let l=0,d=0;const _=we.allocUnsafe(4);do l=a%128|0,a=a/128|0,a>0&&(l=l|128),_.writeUInt8(l,d++);while(a>0&&d<4);return a>0&&(d=0),t?_.subarray(0,d):_.slice(0,d)}function u(a){const s=we.allocUnsafe(4);return s.writeUInt32BE(a,0),s}return ba={cache:e,generateCache:n,generateNumber:r,genBufVariableByteInt:o,generate4ByteBuffer:u},ba}var pr={exports:{}},Zd;function E_(){if(Zd)return pr.exports;Zd=1,typeof Re=="undefined"||!Re.version||Re.version.indexOf("v0.")===0||Re.version.indexOf("v1.")===0&&Re.version.indexOf("v1.8.")!==0?pr.exports={nextTick:i}:pr.exports=Re;function i(e,t,r,n){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var o=arguments.length,u,a;switch(o){case 0:case 1:return Re.nextTick(e);case 2:return Re.nextTick(function(){e.call(null,t)});case 3:return Re.nextTick(function(){e.call(null,t,r)});case 4:return Re.nextTick(function(){e.call(null,t,r,n)});default:for(u=new Array(o-1),a=0;a<u.length;)u[a++]=arguments[a];return Re.nextTick(function(){e.apply(null,u)})}}return pr.exports}var wa,ep;function tp(){if(ep)return wa;ep=1;const i=zd(),e=we.allocUnsafe(0),t=we.from([0]),r=S_(),n=E_().nextTick,o=Rt()("mqtt-packet:writeToStream"),u=r.cache,a=r.generateNumber,s=r.generateCache,l=r.genBufVariableByteInt,d=r.generate4ByteBuffer;let _=oe,g=!0;function E(j,L,M){switch(o("generate called"),L.cork&&(L.cork(),n(w,L)),g&&(g=!1,s()),o("generate: packet.cmd: %s",j.cmd),j.cmd){case"connect":return q(j,L);case"connack":return k(j,L,M);case"publish":return A(j,L,M);case"puback":case"pubrec":case"pubrel":case"pubcomp":return R(j,L,M);case"subscribe":return S(j,L,M);case"suback":return b(j,L,M);case"unsubscribe":return h(j,L,M);case"unsuback":return p(j,L,M);case"pingreq":case"pingresp":return v(j,L);case"disconnect":return I(j,L,M);case"auth":return B(j,L,M);default:return L.emit("error",new Error("Unknown command")),!1}}Object.defineProperty(E,"cacheNumbers",{get(){return _===oe},set(j){j?((!u||Object.keys(u).length===0)&&(g=!0),_=oe):(g=!1,_=ne)}});function w(j){j.uncork()}function q(j,L,M){const D=j||{},$=D.protocolId||"MQTT";let z=D.protocolVersion||4;const Y=D.will;let T=D.clean;const O=D.keepalive||0,ee=D.clientId||"",ae=D.username,ye=D.password,le=D.properties;T===void 0&&(T=!0);let Se=0;if(typeof $!="string"&&!we.isBuffer($))return L.emit("error",new Error("Invalid protocolId")),!1;if(Se+=$.length+2,z!==3&&z!==4&&z!==5)return L.emit("error",new Error("Invalid protocol version")),!1;if(Se+=1,(typeof ee=="string"||we.isBuffer(ee))&&(ee||z>=4)&&(ee||T))Se+=we.byteLength(ee)+2;else{if(z<4)return L.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(T*1===0)return L.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if(typeof O!="number"||O<0||O>65535||O%1!==0)return L.emit("error",new Error("Invalid keepalive")),!1;if(Se+=2,Se+=1,z===5){var Pe=J(L,le);if(!Pe)return!1;Se+=Pe.length}if(Y){if(typeof Y!="object")return L.emit("error",new Error("Invalid will")),!1;if(!Y.topic||typeof Y.topic!="string")return L.emit("error",new Error("Invalid will topic")),!1;if(Se+=we.byteLength(Y.topic)+2,Se+=2,Y.payload)if(Y.payload.length>=0)typeof Y.payload=="string"?Se+=we.byteLength(Y.payload):Se+=Y.payload.length;else return L.emit("error",new Error("Invalid will payload")),!1;var ue={};if(z===5){if(ue=J(L,Y.properties),!ue)return!1;Se+=ue.length}}let je=!1;if(ae!=null)if(re(ae))je=!0,Se+=we.byteLength(ae)+2;else return L.emit("error",new Error("Invalid username")),!1;if(ye!=null){if(!je)return L.emit("error",new Error("Username is required to use password")),!1;if(re(ye))Se+=G(ye)+2;else return L.emit("error",new Error("Invalid password")),!1}L.write(i.CONNECT_HEADER),V(L,Se),he(L,$),D.bridgeMode&&(z+=128),L.write(z===131?i.VERSION131:z===132?i.VERSION132:z===4?i.VERSION4:z===5?i.VERSION5:i.VERSION3);let De=0;return De|=ae!=null?i.USERNAME_MASK:0,De|=ye!=null?i.PASSWORD_MASK:0,De|=Y&&Y.retain?i.WILL_RETAIN_MASK:0,De|=Y&&Y.qos?Y.qos<<i.WILL_QOS_SHIFT:0,De|=Y?i.WILL_FLAG_MASK:0,De|=T?i.CLEAN_SESSION_MASK:0,L.write(we.from([De])),_(L,O),z===5&&Pe.write(),he(L,ee),Y&&(z===5&&ue.write(),P(L,Y.topic),he(L,Y.payload)),ae!=null&&he(L,ae),ye!=null&&he(L,ye),!0}function k(j,L,M){const D=M?M.protocolVersion:4,$=j||{},z=D===5?$.reasonCode:$.returnCode,Y=$.properties;let T=2;if(typeof z!="number")return L.emit("error",new Error("Invalid return code")),!1;let O=null;if(D===5){if(O=J(L,Y),!O)return!1;T+=O.length}return L.write(i.CONNACK_HEADER),V(L,T),L.write($.sessionPresent?i.SESSIONPRESENT_HEADER:t),L.write(we.from([z])),O!=null&&O.write(),!0}function A(j,L,M){o("publish: packet: %o",j);const D=M?M.protocolVersion:4,$=j||{},z=$.qos||0,Y=$.retain?i.RETAIN_MASK:0,T=$.topic,O=$.payload||e,ee=$.messageId,ae=$.properties;let ye=0;if(typeof T=="string")ye+=we.byteLength(T)+2;else if(we.isBuffer(T))ye+=T.length+2;else return L.emit("error",new Error("Invalid topic")),!1;if(we.isBuffer(O)?ye+=O.length:ye+=we.byteLength(O),z&&typeof ee!="number")return L.emit("error",new Error("Invalid messageId")),!1;z&&(ye+=2);let le=null;if(D===5){if(le=J(L,ae),!le)return!1;ye+=le.length}return L.write(i.PUBLISH_HEADER[z][$.dup?1:0][Y?1:0]),V(L,ye),_(L,G(T)),L.write(T),z>0&&_(L,ee),le!=null&&le.write(),o("publish: payload: %o",O),L.write(O)}function R(j,L,M){const D=M?M.protocolVersion:4,$=j||{},z=$.cmd||"puback",Y=$.messageId,T=$.dup&&z==="pubrel"?i.DUP_MASK:0;let O=0;const ee=$.reasonCode,ae=$.properties;let ye=D===5?3:2;if(z==="pubrel"&&(O=1),typeof Y!="number")return L.emit("error",new Error("Invalid messageId")),!1;let le=null;if(D===5&&typeof ae=="object"){if(le=me(L,ae,M,ye),!le)return!1;ye+=le.length}return L.write(i.ACKS[z][O][T][0]),V(L,ye),_(L,Y),D===5&&L.write(we.from([ee])),le!==null&&le.write(),!0}function S(j,L,M){o("subscribe: packet: ");const D=M?M.protocolVersion:4,$=j||{},z=$.dup?i.DUP_MASK:0,Y=$.messageId,T=$.subscriptions,O=$.properties;let ee=0;if(typeof Y!="number")return L.emit("error",new Error("Invalid messageId")),!1;ee+=2;let ae=null;if(D===5){if(ae=J(L,O),!ae)return!1;ee+=ae.length}if(typeof T=="object"&&T.length)for(let le=0;le<T.length;le+=1){const Se=T[le].topic,Pe=T[le].qos;if(typeof Se!="string")return L.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if(typeof Pe!="number")return L.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(D===5){if(typeof(T[le].nl||!1)!="boolean")return L.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if(typeof(T[le].rap||!1)!="boolean")return L.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const De=T[le].rh||0;if(typeof De!="number"||De>2)return L.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}ee+=we.byteLength(Se)+2+1}else return L.emit("error",new Error("Invalid subscriptions")),!1;o("subscribe: writing to stream: %o",i.SUBSCRIBE_HEADER),L.write(i.SUBSCRIBE_HEADER[1][z?1:0][0]),V(L,ee),_(L,Y),ae!==null&&ae.write();let ye=!0;for(const le of T){const Se=le.topic,Pe=le.qos,ue=+le.nl,je=+le.rap,De=le.rh;let K;P(L,Se),K=i.SUBSCRIBE_OPTIONS_QOS[Pe],D===5&&(K|=ue?i.SUBSCRIBE_OPTIONS_NL:0,K|=je?i.SUBSCRIBE_OPTIONS_RAP:0,K|=De?i.SUBSCRIBE_OPTIONS_RH[De]:0),ye=L.write(we.from([K]))}return ye}function b(j,L,M){const D=M?M.protocolVersion:4,$=j||{},z=$.messageId,Y=$.granted,T=$.properties;let O=0;if(typeof z!="number")return L.emit("error",new Error("Invalid messageId")),!1;if(O+=2,typeof Y=="object"&&Y.length)for(let ae=0;ae<Y.length;ae+=1){if(typeof Y[ae]!="number")return L.emit("error",new Error("Invalid qos vector")),!1;O+=1}else return L.emit("error",new Error("Invalid qos vector")),!1;let ee=null;if(D===5){if(ee=me(L,T,M,O),!ee)return!1;O+=ee.length}return L.write(i.SUBACK_HEADER),V(L,O),_(L,z),ee!==null&&ee.write(),L.write(we.from(Y))}function h(j,L,M){const D=M?M.protocolVersion:4,$=j||{},z=$.messageId,Y=$.dup?i.DUP_MASK:0,T=$.unsubscriptions,O=$.properties;let ee=0;if(typeof z!="number")return L.emit("error",new Error("Invalid messageId")),!1;if(ee+=2,typeof T=="object"&&T.length)for(let le=0;le<T.length;le+=1){if(typeof T[le]!="string")return L.emit("error",new Error("Invalid unsubscriptions")),!1;ee+=we.byteLength(T[le])+2}else return L.emit("error",new Error("Invalid unsubscriptions")),!1;let ae=null;if(D===5){if(ae=J(L,O),!ae)return!1;ee+=ae.length}L.write(i.UNSUBSCRIBE_HEADER[1][Y?1:0][0]),V(L,ee),_(L,z),ae!==null&&ae.write();let ye=!0;for(let le=0;le<T.length;le++)ye=P(L,T[le]);return ye}function p(j,L,M){const D=M?M.protocolVersion:4,$=j||{},z=$.messageId,Y=$.dup?i.DUP_MASK:0,T=$.granted,O=$.properties,ee=$.cmd,ae=0;let ye=2;if(typeof z!="number")return L.emit("error",new Error("Invalid messageId")),!1;if(D===5)if(typeof T=="object"&&T.length)for(let Se=0;Se<T.length;Se+=1){if(typeof T[Se]!="number")return L.emit("error",new Error("Invalid qos vector")),!1;ye+=1}else return L.emit("error",new Error("Invalid qos vector")),!1;let le=null;if(D===5){if(le=me(L,O,M,ye),!le)return!1;ye+=le.length}return L.write(i.ACKS[ee][ae][Y][0]),V(L,ye),_(L,z),le!==null&&le.write(),D===5&&L.write(we.from(T)),!0}function v(j,L,M){return L.write(i.EMPTY[j.cmd])}function I(j,L,M){const D=M?M.protocolVersion:4,$=j||{},z=$.reasonCode,Y=$.properties;let T=D===5?1:0,O=null;if(D===5){if(O=me(L,Y,M,T),!O)return!1;T+=O.length}return L.write(we.from([i.codes.disconnect<<4])),V(L,T),D===5&&L.write(we.from([z])),O!==null&&O.write(),!0}function B(j,L,M){const D=M?M.protocolVersion:4,$=j||{},z=$.reasonCode,Y=$.properties;let T=D===5?1:0;D!==5&&L.emit("error",new Error("Invalid mqtt version for auth packet"));const O=me(L,Y,M,T);return O?(T+=O.length,L.write(we.from([i.codes.auth<<4])),V(L,T),L.write(we.from([z])),O!==null&&O.write(),!0):!1}const H={};function V(j,L){if(L>i.VARBYTEINT_MAX)return j.emit("error",new Error(`Invalid variable byte integer: ${L}`)),!1;let M=H[L];return M||(M=l(L),L<16384&&(H[L]=M)),o("writeVarByteInt: writing to stream: %o",M),j.write(M)}function P(j,L){const M=we.byteLength(L);return _(j,M),o("writeString: %s",L),j.write(L,"utf8")}function ce(j,L,M){P(j,L),P(j,M)}function oe(j,L){return o("writeNumberCached: number: %d",L),o("writeNumberCached: %o",u[L]),j.write(u[L])}function ne(j,L){const M=a(L);return o("writeNumberGenerated: %o",M),j.write(M)}function se(j,L){const M=d(L);return o("write4ByteNumber: %o",M),j.write(M)}function he(j,L){typeof L=="string"?P(j,L):L?(_(j,L.length),j.write(L)):_(j,0)}function J(j,L){if(typeof L!="object"||L.length!=null)return{length:1,write(){be(j,{},0)}};let M=0;function D(z,Y){const T=i.propertiesTypes[z];let O=0;switch(T){case"byte":{if(typeof Y!="boolean")return j.emit("error",new Error(`Invalid ${z}: ${Y}`)),!1;O+=2;break}case"int8":{if(typeof Y!="number"||Y<0||Y>255)return j.emit("error",new Error(`Invalid ${z}: ${Y}`)),!1;O+=2;break}case"binary":{if(Y&&Y===null)return j.emit("error",new Error(`Invalid ${z}: ${Y}`)),!1;O+=1+we.byteLength(Y)+2;break}case"int16":{if(typeof Y!="number"||Y<0||Y>65535)return j.emit("error",new Error(`Invalid ${z}: ${Y}`)),!1;O+=3;break}case"int32":{if(typeof Y!="number"||Y<0||Y>4294967295)return j.emit("error",new Error(`Invalid ${z}: ${Y}`)),!1;O+=5;break}case"var":{if(typeof Y!="number"||Y<0||Y>268435455)return j.emit("error",new Error(`Invalid ${z}: ${Y}`)),!1;O+=1+we.byteLength(l(Y));break}case"string":{if(typeof Y!="string")return j.emit("error",new Error(`Invalid ${z}: ${Y}`)),!1;O+=3+we.byteLength(Y.toString());break}case"pair":{if(typeof Y!="object")return j.emit("error",new Error(`Invalid ${z}: ${Y}`)),!1;O+=Object.getOwnPropertyNames(Y).reduce((ee,ae)=>{const ye=Y[ae];return Array.isArray(ye)?ee+=ye.reduce((le,Se)=>(le+=3+we.byteLength(ae.toString())+2+we.byteLength(Se.toString()),le),0):ee+=3+we.byteLength(ae.toString())+2+we.byteLength(Y[ae].toString()),ee},0);break}default:return j.emit("error",new Error(`Invalid property ${z}: ${Y}`)),!1}return O}if(L)for(const z in L){let Y=0,T=0;const O=L[z];if(Array.isArray(O))for(let ee=0;ee<O.length;ee++){if(T=D(z,O[ee]),!T)return!1;Y+=T}else{if(T=D(z,O),!T)return!1;Y=T}if(!Y)return!1;M+=Y}return{length:we.byteLength(l(M))+M,write(){be(j,L,M)}}}function me(j,L,M,D){const $=["reasonString","userProperties"],z=M&&M.properties&&M.properties.maximumPacketSize?M.properties.maximumPacketSize:0;let Y=J(j,L);if(z)for(;D+Y.length>z;){const T=$.shift();if(T&&L[T])delete L[T],Y=J(j,L);else return!1}return Y}function de(j,L,M){switch(i.propertiesTypes[L]){case"byte":{j.write(we.from([i.properties[L]])),j.write(we.from([+M]));break}case"int8":{j.write(we.from([i.properties[L]])),j.write(we.from([M]));break}case"binary":{j.write(we.from([i.properties[L]])),he(j,M);break}case"int16":{j.write(we.from([i.properties[L]])),_(j,M);break}case"int32":{j.write(we.from([i.properties[L]])),se(j,M);break}case"var":{j.write(we.from([i.properties[L]])),V(j,M);break}case"string":{j.write(we.from([i.properties[L]])),P(j,M);break}case"pair":{Object.getOwnPropertyNames(M).forEach($=>{const z=M[$];Array.isArray(z)?z.forEach(Y=>{j.write(we.from([i.properties[L]])),ce(j,$.toString(),Y.toString())}):(j.write(we.from([i.properties[L]])),ce(j,$.toString(),z.toString()))});break}default:return j.emit("error",new Error(`Invalid property ${L} value: ${M}`)),!1}}function be(j,L,M){V(j,M);for(const D in L)if(Object.prototype.hasOwnProperty.call(L,D)&&L[D]!==null){const $=L[D];if(Array.isArray($))for(let z=0;z<$.length;z++)de(j,D,$[z]);else de(j,D,$)}}function G(j){return j?j instanceof we?j.length:we.byteLength(j):0}function re(j){return typeof j=="string"||j instanceof we}return wa=E,wa}var Sa,rp;function I_(){if(rp)return Sa;rp=1;const i=tp(),e=Gt();function t(n,o){const u=new r;return i(n,u,o),u.concat()}class r extends e{constructor(){super(),this._array=new Array(20),this._i=0}write(o){return this._array[this._i++]=o,!0}concat(){let o=0;const u=new Array(this._array.length),a=this._array;let s=0,l;for(l=0;l<a.length&&a[l]!==void 0;l++)typeof a[l]!="string"?u[l]=a[l].length:u[l]=we.byteLength(a[l]),o+=u[l];const d=we.allocUnsafe(o);for(l=0;l<a.length&&a[l]!==void 0;l++)typeof a[l]!="string"?(a[l].copy(d,s),s+=u[l]):(d.write(a[l],s),s+=u[l]);return d}}return Sa=t,Sa}var np;function T_(){return np||(np=1,Kt.parser=w_().parser,Kt.generate=I_(),Kt.writeToStream=tp()),Kt}var Ea,ip;function R_(){if(ip)return Ea;ip=1;function i(t,r,n){var o=this;this._callback=t,this._args=n,this._interval=setInterval(t,r,this._args),this.reschedule=function(u){u||(u=o._interval),o._interval&&clearInterval(o._interval),o._interval=setInterval(o._callback,u,o._args)},this.clear=function(){o._interval&&(clearInterval(o._interval),o._interval=void 0)},this.destroy=function(){o._interval&&clearInterval(o._interval),o._callback=void 0,o._interval=void 0,o._args=void 0}}function e(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("interval needed");var t;if(arguments.length>0){t=new Array(arguments.length-2);for(var r=0;r<t.length;r++)t[r]=arguments[r+2]}return new i(arguments[0],arguments[1],t)}return Ea=e,Ea}var Ia,op;function A_(){if(op)return Ia;op=1;function i(t){for(var r=t.split("/"),n=0;n<r.length;n++)if(r[n]!=="+"){if(r[n]==="#")return n===r.length-1;if(r[n].indexOf("+")!==-1||r[n].indexOf("#")!==-1)return!1}return!0}function e(t){if(t.length===0)return"empty_topic_list";for(var r=0;r<t.length;r++)if(!i(t[r]))return t[r];return null}return Ia={validateTopics:e},Ia}var Ta,sp;function O_(){if(sp)return Ta;sp=1;var i=Gt().EventEmitter,e=Nd(),t=T_(),r=Tt().Writable,n=_t(),o=R_(),u=A_(),a=jo(),s=Rt()("mqttjs:client"),l=Re?Re.nextTick:function(h){setTimeout(h,0)},d=xe.setImmediate||function(h){l(h)},_={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:30*1e3,clean:!0,resubscribe:!0},g=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],E={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 w(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function q(h,p,v){s("sendPacket :: packet: %O",p),s("sendPacket :: emitting `packetsend`"),h.emit("packetsend",p),s("sendPacket :: writing to stream");var I=t.writeToStream(p,h.stream,h.options);s("sendPacket :: writeToStream result %s",I),!I&&v?(s("sendPacket :: handle events on `drain` once through callback."),h.stream.once("drain",v)):v&&(s("sendPacket :: invoking cb"),v())}function k(h){h&&(s("flush: queue exists? %b",!!h),Object.keys(h).forEach(function(p){typeof h[p].cb=="function"&&(h[p].cb(new Error("Connection closed")),delete h[p])}))}function A(h){h&&(s("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(h).forEach(function(p){h[p].volatile&&typeof h[p].cb=="function"&&(h[p].cb(new Error("Connection closed")),delete h[p])}))}function R(h,p,v,I){s("storeAndSend :: store packet with cmd %s to outgoingStore",p.cmd),h.outgoingStore.put(p,function(H){if(H)return v&&v(H);I(),q(h,p,v)})}function S(h){s("nop ::",h)}function b(h,p){var v,I=this;if(!(this instanceof b))return new b(h,p);this.options=p||{};for(v in _)typeof this.options[v]=="undefined"?this.options[v]=_[v]:this.options[v]=p[v];s("MqttClient :: options.protocol",p.protocol),s("MqttClient :: options.protocolVersion",p.protocolVersion),s("MqttClient :: options.username",p.username),s("MqttClient :: options.keepalive",p.keepalive),s("MqttClient :: options.reconnectPeriod",p.reconnectPeriod),s("MqttClient :: options.rejectUnauthorized",p.rejectUnauthorized),this.options.clientId=typeof p.clientId=="string"?p.clientId:w(),s("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=p.protocolVersion===5&&p.customHandleAcks?p.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=h,this.outgoingStore=p.outgoingStore||new e,this.incomingStore=p.incomingStore||new e,this.queueQoSZero=p.queueQoSZero===void 0?!0:p.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.nextId=Math.max(1,Math.floor(Math.random()*65535)),this.outgoing={},this._firstConnection=!0,this.on("connect",function(){var B=this.queue;function H(){var V=B.shift();s("deliver :: entry %o",V);var P=null;V&&(P=V.packet,s("deliver :: call _sendPacket for %o",P),I._sendPacket(P,function(ce){V.cb&&V.cb(ce),H()}))}s("connect :: sending queued packets"),H()}),this.on("close",function(){s("close :: connected set to `false`"),this.connected=!1,s("close :: clearing connackTimer"),clearTimeout(this.connackTimer),s("close :: clearing ping timer"),I.pingTimer!==null&&(I.pingTimer.clear(),I.pingTimer=null),s("close :: calling _setupReconnect"),this._setupReconnect()}),i.call(this),s("MqttClient :: setting up stream"),this._setupStream()}return n(b,i),b.prototype._setupStream=function(){var h,p=this,v=new r,I=t.parser(this.options),B=null,H=[];s("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),s("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),I.on("packet",function(ne){s("parser :: on packet push to packets array."),H.push(ne)});function V(){if(H.length)l(P);else{var ne=B;B=null,ne()}}function P(){s("work :: getting next packet in queue");var ne=H.shift();if(ne)s("work :: packet pulled from queue"),p._handlePacket(ne,V);else{s("work :: no packets in queue");var se=B;B=null,s("work :: done flag is %s",!!se),se&&se()}}v._write=function(ne,se,he){B=he,s("writable stream :: parsing buffer"),I.parse(ne),P()};function ce(ne){s("streamErrorHandler :: error",ne.message),g.includes(ne.code)?(s("streamErrorHandler :: emitting error"),p.emit("error",ne)):S(ne)}if(s("_setupStream :: pipe stream to writable stream"),this.stream.pipe(v),this.stream.on("error",ce),this.stream.on("close",function(){s("(%s)stream :: on close",p.options.clientId),A(p.outgoing),s("stream: emit close to MqttClient"),p.emit("close")}),s("_setupStream: sending packet `connect`"),h=Object.create(this.options),h.cmd="connect",q(this,h),I.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return p.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"){var oe=a({cmd:"auth",reasonCode:0},this.options.authPacket);q(this,oe)}}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){s("!!connectTimeout hit!! Calling _cleanUp with force `true`"),p._cleanUp(!0)},this.options.connectTimeout)},b.prototype._handlePacket=function(h,p){var v=this.options;if(v.protocolVersion===5&&v.properties&&v.properties.maximumPacketSize&&v.properties.maximumPacketSize<h.length)return this.emit("error",new Error("exceeding packets size "+h.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(s("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",h),h.cmd){case"publish":this._handlePublish(h,p);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(h),p();break;case"pubrel":this._handlePubrel(h,p);break;case"connack":this._handleConnack(h),p();break;case"pingresp":this._handlePingresp(h),p();break;case"disconnect":this._handleDisconnect(h),p();break}},b.prototype._checkDisconnecting=function(h){return this.disconnecting&&(h?h(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},b.prototype.publish=function(h,p,v,I){s("publish :: message `%s` to topic `%s`",p,h);var B,H=this.options;typeof v=="function"&&(I=v,v=null);var V={qos:0,retain:!1,dup:!1};if(v=a(V,v),this._checkDisconnecting(I))return this;switch(B={cmd:"publish",topic:h,payload:p,qos:v.qos,retain:v.retain,messageId:this._nextId(),dup:v.dup},H.protocolVersion===5&&(B.properties=v.properties,(!H.properties&&B.properties&&B.properties.topicAlias||v.properties&&H.properties&&(v.properties.topicAlias&&H.properties.topicAliasMaximum&&v.properties.topicAlias>H.properties.topicAliasMaximum||!H.properties.topicAliasMaximum&&v.properties.topicAlias))&&delete B.properties.topicAlias),s("publish :: qos",v.qos),v.qos){case 1:case 2:this.outgoing[B.messageId]={volatile:!1,cb:I||S},this._storeProcessing?(s("_storeProcessing enabled"),this._packetIdsDuringStoreProcessing[B.messageId]=!1,this._storePacket(B,void 0,v.cbStorePut)):(s("MqttClient:publish: packet cmd: %s",B.cmd),this._sendPacket(B,void 0,v.cbStorePut));break;default:this._storeProcessing?(s("_storeProcessing enabled"),this._storePacket(B,I,v.cbStorePut)):(s("MqttClient:publish: packet cmd: %s",B.cmd),this._sendPacket(B,I,v.cbStorePut));break}return this},b.prototype.subscribe=function(){for(var h,p=new Array(arguments.length),v=0;v<arguments.length;v++)p[v]=arguments[v];var I=[],B=p.shift(),H=B.resubscribe,V=p.pop()||S,P=p.pop(),ce,oe=this,ne=this.options.protocolVersion;if(delete B.resubscribe,typeof B=="string"&&(B=[B]),typeof V!="function"&&(P=V,V=S),ce=u.validateTopics(B),ce!==null)return d(V,new Error("Invalid topic "+ce)),this;if(this._checkDisconnecting(V))return s("subscribe: discconecting true"),this;var se={qos:0};if(ne===5&&(se.nl=!1,se.rap=!1,se.rh=0),P=a(se,P),Array.isArray(B)?B.forEach(function(J){if(s("subscribe: array topic %s",J),!oe._resubscribeTopics.hasOwnProperty(J)||oe._resubscribeTopics[J].qos<P.qos||H){var me={topic:J,qos:P.qos};ne===5&&(me.nl=P.nl,me.rap=P.rap,me.rh=P.rh,me.properties=P.properties),s("subscribe: pushing topic `%s` and qos `%s` to subs list",me.topic,me.qos),I.push(me)}}):Object.keys(B).forEach(function(J){if(s("subscribe: object topic %s",J),!oe._resubscribeTopics.hasOwnProperty(J)||oe._resubscribeTopics[J].qos<B[J].qos||H){var me={topic:J,qos:B[J].qos};ne===5&&(me.nl=B[J].nl,me.rap=B[J].rap,me.rh=B[J].rh,me.properties=P.properties),s("subscribe: pushing `%s` to subs list",me),I.push(me)}}),h={cmd:"subscribe",subscriptions:I,qos:1,retain:!1,dup:!1,messageId:this._nextId()},P.properties&&(h.properties=P.properties),!I.length){V(null,[]);return}if(this.options.resubscribe){s("subscribe :: resubscribe true");var he=[];I.forEach(function(J){if(oe.options.reconnectPeriod>0){var me={qos:J.qos};ne===5&&(me.nl=J.nl||!1,me.rap=J.rap||!1,me.rh=J.rh||0,me.properties=J.properties),oe._resubscribeTopics[J.topic]=me,he.push(J.topic)}}),oe.messageIdToTopic[h.messageId]=he}return this.outgoing[h.messageId]={volatile:!0,cb:function(J,me){if(!J)for(var de=me.granted,be=0;be<de.length;be+=1)I[be].qos=de[be];V(J,I)}},s("subscribe :: call _sendPacket"),this._sendPacket(h),this},b.prototype.unsubscribe=function(){for(var h={cmd:"unsubscribe",qos:1,messageId:this._nextId()},p=this,v=new Array(arguments.length),I=0;I<arguments.length;I++)v[I]=arguments[I];var B=v.shift(),H=v.pop()||S,V=v.pop();return typeof B=="string"&&(B=[B]),typeof H!="function"&&(V=H,H=S),this._checkDisconnecting(H)?this:(typeof B=="string"?h.unsubscriptions=[B]:Array.isArray(B)&&(h.unsubscriptions=B),this.options.resubscribe&&h.unsubscriptions.forEach(function(P){delete p._resubscribeTopics[P]}),typeof V=="object"&&V.properties&&(h.properties=V.properties),this.outgoing[h.messageId]={volatile:!0,cb:H},s("unsubscribe: call _sendPacket"),this._sendPacket(h),this)},b.prototype.end=function(h,p,v){var I=this;s("end :: (%s)",this.options.clientId),(h==null||typeof h!="boolean")&&(v=p||S,p=h,h=!1,typeof p!="object"&&(v=p,p=null,typeof v!="function"&&(v=S))),typeof p!="object"&&(v=p,p=null),s("end :: cb? %s",!!v),v=v||S;function B(){s("end :: closeStores: closing incoming and outgoing stores"),I.disconnected=!0,I.incomingStore.close(function(V){I.outgoingStore.close(function(P){if(s("end :: closeStores: emitting end"),I.emit("end"),v){let ce=V||P;s("end :: closeStores: invoking callback with args"),v(ce)}})}),I._deferredReconnect&&I._deferredReconnect()}function H(){s("end :: (%s) :: finish :: calling _cleanUp with force %s",I.options.clientId,h),I._cleanUp(h,()=>{s("end :: finish :: calling process.nextTick on closeStores"),l(B.bind(I))},p)}return this.disconnecting?(v(),this):(this._clearReconnect(),this.disconnecting=!0,!h&&Object.keys(this.outgoing).length>0?(s("end :: (%s) :: calling finish in 10ms once outgoing is empty",I.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,H,10))):(s("end :: (%s) :: immediately calling finish",I.options.clientId),H()),this)},b.prototype.removeOutgoingMessage=function(h){var p=this.outgoing[h]?this.outgoing[h].cb:null;return delete this.outgoing[h],this.outgoingStore.del({messageId:h},function(){p(new Error("Message removed"))}),this},b.prototype.reconnect=function(h){s("client reconnect");var p=this,v=function(){h?(p.options.incomingStore=h.incomingStore,p.options.outgoingStore=h.outgoingStore):(p.options.incomingStore=null,p.options.outgoingStore=null),p.incomingStore=p.options.incomingStore||new e,p.outgoingStore=p.options.outgoingStore||new e,p.disconnecting=!1,p.disconnected=!1,p._deferredReconnect=null,p._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=v:v(),this},b.prototype._reconnect=function(){s("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),s("client already connected. disconnecting first.")):(s("_reconnect: calling _setupStream"),this._setupStream())},b.prototype._setupReconnect=function(){var h=this;!h.disconnecting&&!h.reconnectTimer&&h.options.reconnectPeriod>0?(this.reconnecting||(s("_setupReconnect :: emit `offline` state"),this.emit("offline"),s("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),s("_setupReconnect :: setting reconnectTimer for %d ms",h.options.reconnectPeriod),h.reconnectTimer=setInterval(function(){s("reconnectTimer :: reconnect triggered!"),h._reconnect()},h.options.reconnectPeriod)):s("_setupReconnect :: doing nothing...")},b.prototype._clearReconnect=function(){s("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},b.prototype._cleanUp=function(h,p){var v=arguments[2];if(p&&(s("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",p)),s("_cleanUp :: forced? %s",h),h)this.options.reconnectPeriod===0&&this.options.clean&&k(this.outgoing),s("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{var I=a({cmd:"disconnect"},v);s("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(I,d.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(s("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),this.pingTimer!==null&&(s("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),p&&!this.connected&&(s("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",p),p())},b.prototype._sendPacket=function(h,p,v){if(s("_sendPacket :: (%s) :: start",this.options.clientId),v=v||S,!this.connected){s("_sendPacket :: client not connected. Storing packet offline."),this._storePacket(h,p,v);return}switch(this._shiftPingInterval(),h.cmd){case"publish":break;case"pubrel":R(this,h,p,v);return;default:q(this,h,p);return}switch(h.qos){case 2:case 1:R(this,h,p,v);break;case 0:default:q(this,h,p);break}s("_sendPacket :: (%s) :: end",this.options.clientId)},b.prototype._storePacket=function(h,p,v){s("_storePacket :: packet: %o",h),s("_storePacket :: cb? %s",!!p),v=v||S,(h.qos||0)===0&&this.queueQoSZero||h.cmd!=="publish"?this.queue.push({packet:h,cb:p}):h.qos>0?(p=this.outgoing[h.messageId]?this.outgoing[h.messageId].cb:null,this.outgoingStore.put(h,function(I){if(I)return p&&p(I);v()})):p&&p(new Error("No connection to broker"))},b.prototype._setupPingTimer=function(){s("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);var h=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=o(function(){h._checkPing()},this.options.keepalive*1e3))},b.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(this.options.keepalive*1e3)},b.prototype._checkPing=function(){s("_checkPing :: checking ping..."),this.pingResp?(s("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(s("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},b.prototype._handlePingresp=function(){this.pingResp=!0},b.prototype._handleConnack=function(h){s("_handleConnack");var p=this.options,v=p.protocolVersion,I=v===5?h.reasonCode:h.returnCode;if(clearTimeout(this.connackTimer),h.properties&&(h.properties.topicAliasMaximum&&(p.properties||(p.properties={}),p.properties.topicAliasMaximum=h.properties.topicAliasMaximum),h.properties.serverKeepAlive&&p.keepalive&&(p.keepalive=h.properties.serverKeepAlive,this._shiftPingInterval()),h.properties.maximumPacketSize&&(p.properties||(p.properties={}),p.properties.maximumPacketSize=h.properties.maximumPacketSize)),I===0)this.reconnecting=!1,this._onConnect(h);else if(I>0){var B=new Error("Connection refused: "+E[I]);B.code=I,this.emit("error",B)}},b.prototype._handlePublish=function(h,p){s("_handlePublish: packet %o",h),p=typeof p!="undefined"?p:S;var v=h.topic.toString(),I=h.payload,B=h.qos,H=h.messageId,V=this,P=this.options,ce=[0,16,128,131,135,144,145,151,153];switch(s("_handlePublish: qos %d",B),B){case 2:{P.customHandleAcks(v,I,h,function(oe,ne){if(oe instanceof Error||(ne=oe,oe=null),oe)return V.emit("error",oe);if(ce.indexOf(ne)===-1)return V.emit("error",new Error("Wrong reason code for pubrec"));ne?V._sendPacket({cmd:"pubrec",messageId:H,reasonCode:ne},p):V.incomingStore.put(h,function(){V._sendPacket({cmd:"pubrec",messageId:H},p)})});break}case 1:{P.customHandleAcks(v,I,h,function(oe,ne){if(oe instanceof Error||(ne=oe,oe=null),oe)return V.emit("error",oe);if(ce.indexOf(ne)===-1)return V.emit("error",new Error("Wrong reason code for puback"));ne||V.emit("message",v,I,h),V.handleMessage(h,function(se){if(se)return p&&p(se);V._sendPacket({cmd:"puback",messageId:H,reasonCode:ne},p)})});break}case 0:this.emit("message",v,I,h),this.handleMessage(h,p);break;default:s("_handlePublish: unknown QoS. Doing nothing.");break}},b.prototype.handleMessage=function(h,p){p()},b.prototype._handleAck=function(h){var p=h.messageId,v=h.cmd,I=null,B=this.outgoing[p]?this.outgoing[p].cb:null,H=this,V;if(!B){s("_handleAck :: Server sent an ack in error. Ignoring.");return}switch(s("_handleAck :: packet type",v),v){case"pubcomp":case"puback":var P=h.reasonCode;P&&P>0&&P!==16&&(V=new Error("Publish error: "+E[P]),V.code=P,B(V,h)),delete this.outgoing[p],this.outgoingStore.del(h,B);break;case"pubrec":I={cmd:"pubrel",qos:2,messageId:p};var ce=h.reasonCode;ce&&ce>0&&ce!==16?(V=new Error("Publish error: "+E[ce]),V.code=ce,B(V,h)):this._sendPacket(I);break;case"suback":delete this.outgoing[p];for(var oe=0;oe<h.granted.length;oe++)if((h.granted[oe]&128)!==0){var ne=this.messageIdToTopic[p];ne&&ne.forEach(function(se){delete H._resubscribeTopics[se]})}B(null,h);break;case"unsuback":delete this.outgoing[p],B(null);break;default:H.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&Object.keys(this.outgoing).length===0&&this.emit("outgoingEmpty")},b.prototype._handlePubrel=function(h,p){s("handling pubrel packet"),p=typeof p!="undefined"?p:S;var v=h.messageId,I=this,B={cmd:"pubcomp",messageId:v};I.incomingStore.get(h,function(H,V){H?I._sendPacket(B,p):(I.emit("message",V.topic,V.payload,V),I.handleMessage(V,function(P){if(P)return p(P);I.incomingStore.del(V,S),I._sendPacket(B,p)}))})},b.prototype._handleDisconnect=function(h){this.emit("disconnect",h)},b.prototype._nextId=function(){var h=this.nextId++;return this.nextId===65536&&(this.nextId=1),h},b.prototype.getLastMessageId=function(){return this.nextId===1?65535:this.nextId-1},b.prototype._resubscribe=function(h){s("_resubscribe");var p=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||this.options.protocolVersion===5&&!h.sessionPresent)&&p.length>0)if(this.options.resubscribe)if(this.options.protocolVersion===5){s("_resubscribe: protocolVersion 5");for(var v=0;v<p.length;v++){var I={};I[p[v]]=this._resubscribeTopics[p[v]],I.resubscribe=!0,this.subscribe(I,{properties:I[p[v]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},b.prototype._onConnect=function(h){if(this.disconnected){this.emit("connect",h);return}var p=this;this._setupPingTimer(),this._resubscribe(h),this.connected=!0;function v(){var I=p.outgoingStore.createStream();function B(){p._storeProcessing=!1,p._packetIdsDuringStoreProcessing={}}p.once("close",H),I.on("error",function(P){B(),p.removeListener("close",H),p.emit("error",P)});function H(){I.destroy(),I=null,B()}function V(){if(I){p._storeProcessing=!0;var P=I.read(1),ce;if(!P){I.once("readable",V);return}if(p._packetIdsDuringStoreProcessing[P.messageId]){V();return}!p.disconnecting&&!p.reconnectTimer?(ce=p.outgoing[P.messageId]?p.outgoing[P.messageId].cb:null,p.outgoing[P.messageId]={volatile:!1,cb:function(oe,ne){ce&&ce(oe,ne),V()}},p._packetIdsDuringStoreProcessing[P.messageId]=!0,p._sendPacket(P)):I.destroy&&I.destroy()}}I.on("end",function(){var P=!0;for(var ce in p._packetIdsDuringStoreProcessing)if(!p._packetIdsDuringStoreProcessing[ce]){P=!1;break}P?(B(),p.removeListener("close",H),p.emit("connect",h)):v()}),V()}v()},Ta=b,Ta}var mr={exports:{}},Jt={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var x_=Jt.exports,ap;function C_(){return ap||(ap=1,(function(i,e){(function(t){var r=e&&!e.nodeType&&e,n=i&&!i.nodeType&&i,o=typeof xe=="object"&&xe;(o.global===o||o.window===o||o.self===o)&&(t=o);var u,a=2147483647,s=36,l=1,d=26,_=38,g=700,E=72,w=128,q="-",k=/^xn--/,A=/[^\x20-\x7E]/,R=/[\x2E\u3002\uFF0E\uFF61]/g,S={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},b=s-l,h=Math.floor,p=String.fromCharCode,v;function I(de){throw new RangeError(S[de])}function B(de,be){for(var G=de.length,re=[];G--;)re[G]=be(de[G]);return re}function H(de,be){var G=de.split("@"),re="";G.length>1&&(re=G[0]+"@",de=G[1]),de=de.replace(R,".");var j=de.split("."),L=B(j,be).join(".");return re+L}function V(de){for(var be=[],G=0,re=de.length,j,L;G<re;)j=de.charCodeAt(G++),j>=55296&&j<=56319&&G<re?(L=de.charCodeAt(G++),(L&64512)==56320?be.push(((j&1023)<<10)+(L&1023)+65536):(be.push(j),G--)):be.push(j);return be}function P(de){return B(de,function(be){var G="";return be>65535&&(be-=65536,G+=p(be>>>10&1023|55296),be=56320|be&1023),G+=p(be),G}).join("")}function ce(de){return de-48<10?de-22:de-65<26?de-65:de-97<26?de-97:s}function oe(de,be){return de+22+75*(de<26)-((be!=0)<<5)}function ne(de,be,G){var re=0;for(de=G?h(de/g):de>>1,de+=h(de/be);de>b*d>>1;re+=s)de=h(de/b);return h(re+(b+1)*de/(de+_))}function se(de){var be=[],G=de.length,re,j=0,L=w,M=E,D,$,z,Y,T,O,ee,ae,ye;for(D=de.lastIndexOf(q),D<0&&(D=0),$=0;$<D;++$)de.charCodeAt($)>=128&&I("not-basic"),be.push(de.charCodeAt($));for(z=D>0?D+1:0;z<G;){for(Y=j,T=1,O=s;z>=G&&I("invalid-input"),ee=ce(de.charCodeAt(z++)),(ee>=s||ee>h((a-j)/T))&&I("overflow"),j+=ee*T,ae=O<=M?l:O>=M+d?d:O-M,!(ee<ae);O+=s)ye=s-ae,T>h(a/ye)&&I("overflow"),T*=ye;re=be.length+1,M=ne(j-Y,re,Y==0),h(j/re)>a-L&&I("overflow"),L+=h(j/re),j%=re,be.splice(j++,0,L)}return P(be)}function he(de){var be,G,re,j,L,M,D,$,z,Y,T,O=[],ee,ae,ye,le;for(de=V(de),ee=de.length,be=w,G=0,L=E,M=0;M<ee;++M)T=de[M],T<128&&O.push(p(T));for(re=j=O.length,j&&O.push(q);re<ee;){for(D=a,M=0;M<ee;++M)T=de[M],T>=be&&T<D&&(D=T);for(ae=re+1,D-be>h((a-G)/ae)&&I("overflow"),G+=(D-be)*ae,be=D,M=0;M<ee;++M)if(T=de[M],T<be&&++G>a&&I("overflow"),T==be){for($=G,z=s;Y=z<=L?l:z>=L+d?d:z-L,!($<Y);z+=s)le=$-Y,ye=s-Y,O.push(p(oe(Y+le%ye,0))),$=h(le/ye);O.push(p(oe($,0))),L=ne(G,ae,re==j),G=0,++re}++G,++be}return O.join("")}function J(de){return H(de,function(be){return k.test(be)?se(be.slice(4).toLowerCase()):be})}function me(de){return H(de,function(be){return A.test(be)?"xn--"+he(be):be})}if(u={version:"1.4.1",ucs2:{decode:V,encode:P},decode:se,encode:he,toASCII:me,toUnicode:J},r&&n)if(i.exports==r)n.exports=u;else for(v in u)u.hasOwnProperty(v)&&(r[v]=u[v]);else t.punycode=u})(x_)})(Jt,Jt.exports)),Jt.exports}const k_=ut(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Ra,up;function yr(){if(up)return Ra;up=1;var i=typeof Map=="function"&&Map.prototype,e=Object.getOwnPropertyDescriptor&&i?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,t=i&&e&&typeof e.get=="function"?e.get:null,r=i&&Map.prototype.forEach,n=typeof Set=="function"&&Set.prototype,o=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,u=n&&o&&typeof o.get=="function"?o.get:null,a=n&&Set.prototype.forEach,s=typeof WeakMap=="function"&&WeakMap.prototype,l=s?WeakMap.prototype.has:null,d=typeof WeakSet=="function"&&WeakSet.prototype,_=d?WeakSet.prototype.has:null,g=typeof WeakRef=="function"&&WeakRef.prototype,E=g?WeakRef.prototype.deref:null,w=Boolean.prototype.valueOf,q=Object.prototype.toString,k=Function.prototype.toString,A=String.prototype.match,R=String.prototype.slice,S=String.prototype.replace,b=String.prototype.toUpperCase,h=String.prototype.toLowerCase,p=RegExp.prototype.test,v=Array.prototype.concat,I=Array.prototype.join,B=Array.prototype.slice,H=Math.floor,V=typeof BigInt=="function"?BigInt.prototype.valueOf:null,P=Object.getOwnPropertySymbols,ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,oe=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ne=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===oe||!0)?Symbol.toStringTag:null,se=Object.prototype.propertyIsEnumerable,he=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(N){return N.__proto__}:null);function J(N,Z){if(N===1/0||N===-1/0||N!==N||N&&N>-1e3&&N<1e3||p.call(/e/,Z))return Z;var Ee=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof N=="number"){var Ae=N<0?-H(-N):H(N);if(Ae!==N){var _e=String(Ae),ve=R.call(Z,_e.length+1);return S.call(_e,Ee,"$&_")+"."+S.call(S.call(ve,/([0-9]{3})/g,"$&_"),/_$/,"")}}return S.call(Z,Ee,"$&_")}var me=k_,de=me.custom,be=ae(de)?de:null,G={__proto__:null,double:'"',single:"'"},re={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};Ra=function N(Z,Ee,Ae,_e){var ve=Ee||{};if(Se(ve,"quoteStyle")&&!Se(G,ve.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Se(ve,"maxStringLength")&&(typeof ve.maxStringLength=="number"?ve.maxStringLength<0&&ve.maxStringLength!==1/0:ve.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Ve=Se(ve,"customInspect")?ve.customInspect:!0;if(typeof Ve!="boolean"&&Ve!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Se(ve,"indent")&&ve.indent!==null&&ve.indent!==" "&&!(parseInt(ve.indent,10)===ve.indent&&ve.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Se(ve,"numericSeparator")&&typeof ve.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Ue=ve.numericSeparator;if(typeof Z=="undefined")return"undefined";if(Z===null)return"null";if(typeof Z=="boolean")return Z?"true":"false";if(typeof Z=="string")return $e(Z,ve);if(typeof Z=="number"){if(Z===0)return 1/0/Z>0?"0":"-0";var Ne=String(Z);return Ue?J(Z,Ne):Ne}if(typeof Z=="bigint"){var ot=String(Z)+"n";return Ue?J(Z,ot):ot}var Qe=typeof ve.depth=="undefined"?5:ve.depth;if(typeof Ae=="undefined"&&(Ae=0),Ae>=Qe&&Qe>0&&typeof Z=="object")return D(Z)?"[Array]":"[Object]";var Je=F(ve,Ae);if(typeof _e=="undefined")_e=[];else if(je(_e,Z)>=0)return"[Circular]";function C(Dt,vr,av){if(vr&&(_e=B.call(_e),_e.push(vr)),av){var zp={depth:ve.depth};return Se(ve,"quoteStyle")&&(zp.quoteStyle=ve.quoteStyle),N(Dt,zp,Ae+1,_e)}return N(Dt,ve,Ae+1,_e)}if(typeof Z=="function"&&!z(Z)){var c=ue(Z),y=te(Z,C);return"[Function"+(c?": "+c:" (anonymous)")+"]"+(y.length>0?" { "+I.call(y,", ")+" }":"")}if(ae(Z)){var U=oe?S.call(String(Z),/^(Symbol\(.*\))_[^)]*$/,"$1"):ce.call(Z);return typeof Z=="object"&&!oe?Ie(U):U}if(qe(Z)){for(var Q="<"+h.call(String(Z.nodeName)),ie=Z.attributes||[],fe=0;fe<ie.length;fe++)Q+=" "+ie[fe].name+"="+j(L(ie[fe].value),"double",ve);return Q+=">",Z.childNodes&&Z.childNodes.length&&(Q+="..."),Q+="</"+h.call(String(Z.nodeName))+">",Q}if(D(Z)){if(Z.length===0)return"[]";var Ce=te(Z,C);return Je&&!m(Ce)?"["+W(Ce,Je)+"]":"[ "+I.call(Ce,", ")+" ]"}if(Y(Z)){var Ge=te(Z,C);return!("cause"in Error.prototype)&&"cause"in Z&&!se.call(Z,"cause")?"{ ["+String(Z)+"] "+I.call(v.call("[cause]: "+C(Z.cause),Ge),", ")+" }":Ge.length===0?"["+String(Z)+"]":"{ ["+String(Z)+"] "+I.call(Ge,", ")+" }"}if(typeof Z=="object"&&Ve){if(be&&typeof Z[be]=="function"&&me)return me(Z,{depth:Qe-Ae});if(Ve!=="symbol"&&typeof Z.inspect=="function")return Z.inspect()}if(De(Z)){var We=[];return r&&r.call(Z,function(Dt,vr){We.push(C(vr,Z,!0)+" => "+C(Dt,Z))}),f("Map",t.call(Z),We,Je)}if(X(Z)){var ze=[];return a&&a.call(Z,function(Dt){ze.push(C(Dt,Z))}),f("Set",u.call(Z),ze,Je)}if(K(Z))return x("WeakMap");if(Te(Z))return x("WeakSet");if(pe(Z))return x("WeakRef");if(O(Z))return Ie(C(Number(Z)));if(ye(Z))return Ie(C(V.call(Z)));if(ee(Z))return Ie(w.call(Z));if(T(Z))return Ie(C(String(Z)));if(typeof window!="undefined"&&Z===window)return"{ [object Window] }";if(typeof globalThis!="undefined"&&Z===globalThis||typeof xe!="undefined"&&Z===xe)return"{ [object globalThis] }";if(!$(Z)&&!z(Z)){var Fe=te(Z,C),Yp=he?he(Z)===Object.prototype:Z instanceof Object||Z.constructor===Object,Ja=Z instanceof Object?"":"null prototype",Gp=!Yp&&ne&&Object(Z)===Z&&ne in Z?R.call(Pe(Z),8,-1):Ja?"Object":"",sv=Yp||typeof Z.constructor!="function"?"":Z.constructor.name?Z.constructor.name+" ":"",Xa=sv+(Gp||Ja?"["+I.call(v.call([],Gp||[],Ja||[]),": ")+"] ":"");return Fe.length===0?Xa+"{}":Je?Xa+"{"+W(Fe,Je)+"}":Xa+"{ "+I.call(Fe,", ")+" }"}return String(Z)};function j(N,Z,Ee){var Ae=Ee.quoteStyle||Z,_e=G[Ae];return _e+N+_e}function L(N){return S.call(String(N),/"/g,"&quot;")}function M(N){return!ne||!(typeof N=="object"&&(ne in N||typeof N[ne]!="undefined"))}function D(N){return Pe(N)==="[object Array]"&&M(N)}function $(N){return Pe(N)==="[object Date]"&&M(N)}function z(N){return Pe(N)==="[object RegExp]"&&M(N)}function Y(N){return Pe(N)==="[object Error]"&&M(N)}function T(N){return Pe(N)==="[object String]"&&M(N)}function O(N){return Pe(N)==="[object Number]"&&M(N)}function ee(N){return Pe(N)==="[object Boolean]"&&M(N)}function ae(N){if(oe)return N&&typeof N=="object"&&N instanceof Symbol;if(typeof N=="symbol")return!0;if(!N||typeof N!="object"||!ce)return!1;try{return ce.call(N),!0}catch(Z){}return!1}function ye(N){if(!N||typeof N!="object"||!V)return!1;try{return V.call(N),!0}catch(Z){}return!1}var le=Object.prototype.hasOwnProperty||function(N){return N in this};function Se(N,Z){return le.call(N,Z)}function Pe(N){return q.call(N)}function ue(N){if(N.name)return N.name;var Z=A.call(k.call(N),/^function\s*([\w$]+)/);return Z?Z[1]:null}function je(N,Z){if(N.indexOf)return N.indexOf(Z);for(var Ee=0,Ae=N.length;Ee<Ae;Ee++)if(N[Ee]===Z)return Ee;return-1}function De(N){if(!t||!N||typeof N!="object")return!1;try{t.call(N);try{u.call(N)}catch(Z){return!0}return N instanceof Map}catch(Z){}return!1}function K(N){if(!l||!N||typeof N!="object")return!1;try{l.call(N,l);try{_.call(N,_)}catch(Z){return!0}return N instanceof WeakMap}catch(Z){}return!1}function pe(N){if(!E||!N||typeof N!="object")return!1;try{return E.call(N),!0}catch(Z){}return!1}function X(N){if(!u||!N||typeof N!="object")return!1;try{u.call(N);try{t.call(N)}catch(Z){return!0}return N instanceof Set}catch(Z){}return!1}function Te(N){if(!_||!N||typeof N!="object")return!1;try{_.call(N,_);try{l.call(N,l)}catch(Z){return!0}return N instanceof WeakSet}catch(Z){}return!1}function qe(N){return!N||typeof N!="object"?!1:typeof HTMLElement!="undefined"&&N instanceof HTMLElement?!0:typeof N.nodeName=="string"&&typeof N.getAttribute=="function"}function $e(N,Z){if(N.length>Z.maxStringLength){var Ee=N.length-Z.maxStringLength,Ae="... "+Ee+" more character"+(Ee>1?"s":"");return $e(R.call(N,0,Z.maxStringLength),Z)+Ae}var _e=re[Z.quoteStyle||"single"];_e.lastIndex=0;var ve=S.call(S.call(N,_e,"\\$1"),/[\x00-\x1f]/g,Be);return j(ve,"single",Z)}function Be(N){var Z=N.charCodeAt(0),Ee={8:"b",9:"t",10:"n",12:"f",13:"r"}[Z];return Ee?"\\"+Ee:"\\x"+(Z<16?"0":"")+b.call(Z.toString(16))}function Ie(N){return"Object("+N+")"}function x(N){return N+" { ? }"}function f(N,Z,Ee,Ae){var _e=Ae?W(Ee,Ae):I.call(Ee,", ");return N+" ("+Z+") {"+_e+"}"}function m(N){for(var Z=0;Z<N.length;Z++)if(je(N[Z],`
22
+ `)>=0)return!1;return!0}function F(N,Z){var Ee;if(N.indent===" ")Ee=" ";else if(typeof N.indent=="number"&&N.indent>0)Ee=I.call(Array(N.indent+1)," ");else return null;return{base:Ee,prev:I.call(Array(Z+1),Ee)}}function W(N,Z){if(N.length===0)return"";var Ee=`
23
+ `+Z.prev+Z.base;return Ee+I.call(N,","+Ee)+`
24
+ `+Z.prev}function te(N,Z){var Ee=D(N),Ae=[];if(Ee){Ae.length=N.length;for(var _e=0;_e<N.length;_e++)Ae[_e]=Se(N,_e)?Z(N[_e],N):""}var ve=typeof P=="function"?P(N):[],Ve;if(oe){Ve={};for(var Ue=0;Ue<ve.length;Ue++)Ve["$"+ve[Ue]]=ve[Ue]}for(var Ne in N)Se(N,Ne)&&(Ee&&String(Number(Ne))===Ne&&Ne<N.length||oe&&Ve["$"+Ne]instanceof Symbol||(p.call(/[^\w$]/,Ne)?Ae.push(Z(Ne,N)+": "+Z(N[Ne],N)):Ae.push(Ne+": "+Z(N[Ne],N))));if(typeof P=="function")for(var ot=0;ot<ve.length;ot++)se.call(N,ve[ot])&&Ae.push("["+Z(ve[ot])+"]: "+Z(N[ve[ot]],N));return Ae}return Ra}var Aa,fp;function q_(){if(fp)return Aa;fp=1;var i=yr(),e=gt(),t=function(a,s,l){for(var d=a,_;(_=d.next)!=null;d=_)if(_.key===s)return d.next=_.next,l||(_.next=a.next,a.next=_),_},r=function(a,s){if(a){var l=t(a,s);return l&&l.value}},n=function(a,s,l){var d=t(a,s);d?d.value=l:a.next={key:s,next:a.next,value:l}},o=function(a,s){return a?!!t(a,s):!1},u=function(a,s){if(a)return t(a,s,!0)};return Aa=function(){var s,l={assert:function(d){if(!l.has(d))throw new e("Side channel does not contain "+i(d))},delete:function(d){var _=u(s,d);return _&&s&&!s.next&&(s=void 0),!!_},get:function(d){return r(s,d)},has:function(d){return o(s,d)},set:function(d,_){s||(s={next:void 0}),n(s,d,_)}};return l},Aa}var Oa,lp;function cp(){if(lp)return Oa;lp=1;var i=fr(),e=It(),t=yr(),r=gt(),n=i("%Map%",!0),o=e("Map.prototype.get",!0),u=e("Map.prototype.set",!0),a=e("Map.prototype.has",!0),s=e("Map.prototype.delete",!0),l=e("Map.prototype.size",!0);return Oa=!!n&&function(){var _,g={assert:function(E){if(!g.has(E))throw new r("Side channel does not contain "+t(E))},delete:function(E){if(_){var w=s(_,E);return l(_)===0&&(_=void 0),w}return!1},get:function(E){if(_)return o(_,E)},has:function(E){return _?a(_,E):!1},set:function(E,w){_||(_=new n),u(_,E,w)}};return g},Oa}var xa,hp;function M_(){if(hp)return xa;hp=1;var i=fr(),e=It(),t=yr(),r=cp(),n=gt(),o=i("%WeakMap%",!0),u=e("WeakMap.prototype.get",!0),a=e("WeakMap.prototype.set",!0),s=e("WeakMap.prototype.has",!0),l=e("WeakMap.prototype.delete",!0);return xa=o?function(){var _,g,E={assert:function(w){if(!E.has(w))throw new n("Side channel does not contain "+t(w))},delete:function(w){if(o&&w&&(typeof w=="object"||typeof w=="function")){if(_)return l(_,w)}else if(r&&g)return g.delete(w);return!1},get:function(w){return o&&w&&(typeof w=="object"||typeof w=="function")&&_?u(_,w):g&&g.get(w)},has:function(w){return o&&w&&(typeof w=="object"||typeof w=="function")&&_?s(_,w):!!g&&g.has(w)},set:function(w,q){o&&w&&(typeof w=="object"||typeof w=="function")?(_||(_=new o),a(_,w,q)):r&&(g||(g=r()),g.set(w,q))}};return E}:r,xa}var Ca,dp;function pp(){if(dp)return Ca;dp=1;var i=gt(),e=yr(),t=q_(),r=cp(),n=M_(),o=n||r||t;return Ca=function(){var a,s={assert:function(l){if(!s.has(l)){var d=l&&Object(l)===l?"the given object key":e(l);throw new i("Side channel does not contain "+d)}},delete:function(l){return!!a&&a.delete(l)},get:function(l){return a&&a.get(l)},has:function(l){return!!a&&a.has(l)},set:function(l,d){a||(a=o()),a.set(l,d)}};return s},Ca}var ka,mp;function qa(){if(mp)return ka;mp=1;var i=String.prototype.replace,e=/%20/g,t={RFC1738:"RFC1738",RFC3986:"RFC3986"};return ka={default:t.RFC3986,formatters:{RFC1738:function(r){return i.call(r,e,"+")},RFC3986:function(r){return String(r)}},RFC1738:t.RFC1738,RFC3986:t.RFC3986},ka}var Ma,yp;function gp(){if(yp)return Ma;yp=1;var i=qa(),e=pp(),t=Object.prototype.hasOwnProperty,r=Array.isArray,n=e(),o=function(v,I){return n.set(v,I),v},u=function(v){return n.has(v)},a=function(v){return n.get(v)},s=function(v,I){n.set(v,I)},l=(function(){for(var p=[],v=0;v<256;++v)p[p.length]="%"+((v<16?"0":"")+v.toString(16)).toUpperCase();return p})(),d=function(v){for(;v.length>1;){var I=v.pop(),B=I.obj[I.prop];if(r(B)){for(var H=[],V=0;V<B.length;++V)typeof B[V]!="undefined"&&(H[H.length]=B[V]);I.obj[I.prop]=H}}},_=function(v,I){for(var B=I&&I.plainObjects?{__proto__:null}:{},H=0;H<v.length;++H)typeof v[H]!="undefined"&&(B[H]=v[H]);return B},g=function p(v,I,B){if(!I)return v;if(typeof I!="object"&&typeof I!="function"){if(r(v)){var H=v.length;if(B&&typeof B.arrayLimit=="number"&&H>B.arrayLimit)return o(_(v.concat(I),B),H);v[H]=I}else if(v&&typeof v=="object")if(u(v)){var V=a(v)+1;v[V]=I,s(v,V)}else{if(B&&B.strictMerge)return[v,I];(B&&(B.plainObjects||B.allowPrototypes)||!t.call(Object.prototype,I))&&(v[I]=!0)}else return[v,I];return v}if(!v||typeof v!="object"){if(u(I)){for(var P=Object.keys(I),ce=B&&B.plainObjects?{__proto__:null,0:v}:{0:v},oe=0;oe<P.length;oe++){var ne=parseInt(P[oe],10);ce[ne+1]=I[P[oe]]}return o(ce,a(I)+1)}var se=[v].concat(I);return B&&typeof B.arrayLimit=="number"&&se.length>B.arrayLimit?o(_(se,B),se.length-1):se}var he=v;return r(v)&&!r(I)&&(he=_(v,B)),r(v)&&r(I)?(I.forEach(function(J,me){if(t.call(v,me)){var de=v[me];de&&typeof de=="object"&&J&&typeof J=="object"?v[me]=p(de,J,B):v[v.length]=J}else v[me]=J}),v):Object.keys(I).reduce(function(J,me){var de=I[me];if(t.call(J,me)?J[me]=p(J[me],de,B):J[me]=de,u(I)&&!u(J)&&o(J,a(I)),u(J)){var be=parseInt(me,10);String(be)===me&&be>=0&&be>a(J)&&s(J,be)}return J},he)},E=function(v,I){return Object.keys(I).reduce(function(B,H){return B[H]=I[H],B},v)},w=function(p,v,I){var B=p.replace(/\+/g," ");if(I==="iso-8859-1")return B.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(B)}catch(H){return B}},q=1024,k=function(v,I,B,H,V){if(v.length===0)return v;var P=v;if(typeof v=="symbol"?P=Symbol.prototype.toString.call(v):typeof v!="string"&&(P=String(v)),B==="iso-8859-1")return escape(P).replace(/%u[0-9a-f]{4}/gi,function(me){return"%26%23"+parseInt(me.slice(2),16)+"%3B"});for(var ce="",oe=0;oe<P.length;oe+=q){for(var ne=P.length>=q?P.slice(oe,oe+q):P,se=[],he=0;he<ne.length;++he){var J=ne.charCodeAt(he);if(J===45||J===46||J===95||J===126||J>=48&&J<=57||J>=65&&J<=90||J>=97&&J<=122||V===i.RFC1738&&(J===40||J===41)){se[se.length]=ne.charAt(he);continue}if(J<128){se[se.length]=l[J];continue}if(J<2048){se[se.length]=l[192|J>>6]+l[128|J&63];continue}if(J<55296||J>=57344){se[se.length]=l[224|J>>12]+l[128|J>>6&63]+l[128|J&63];continue}he+=1,J=65536+((J&1023)<<10|ne.charCodeAt(he)&1023),se[se.length]=l[240|J>>18]+l[128|J>>12&63]+l[128|J>>6&63]+l[128|J&63]}ce+=se.join("")}return ce},A=function(v){for(var I=[{obj:{o:v},prop:"o"}],B=[],H=0;H<I.length;++H)for(var V=I[H],P=V.obj[V.prop],ce=Object.keys(P),oe=0;oe<ce.length;++oe){var ne=ce[oe],se=P[ne];typeof se=="object"&&se!==null&&B.indexOf(se)===-1&&(I[I.length]={obj:P,prop:ne},B[B.length]=se)}return d(I),v},R=function(v){return Object.prototype.toString.call(v)==="[object RegExp]"},S=function(v){return!v||typeof v!="object"?!1:!!(v.constructor&&v.constructor.isBuffer&&v.constructor.isBuffer(v))},b=function(v,I,B,H){if(u(v)){var V=a(v)+1;return v[V]=I,s(v,V),v}var P=[].concat(v,I);return P.length>B?o(_(P,{plainObjects:H}),P.length-1):P},h=function(v,I){if(r(v)){for(var B=[],H=0;H<v.length;H+=1)B[B.length]=I(v[H]);return B}return I(v)};return Ma={arrayToObject:_,assign:E,combine:b,compact:A,decode:w,encode:k,isBuffer:S,isOverflow:u,isRegExp:R,markOverflow:o,maybeMap:h,merge:g},Ma}var Pa,_p;function P_(){if(_p)return Pa;_p=1;var i=pp(),e=gp(),t=qa(),r=Object.prototype.hasOwnProperty,n={brackets:function(k){return k+"[]"},comma:"comma",indices:function(k,A){return k+"["+A+"]"},repeat:function(k){return k}},o=Array.isArray,u=Array.prototype.push,a=function(q,k){u.apply(q,o(k)?k:[k])},s=Date.prototype.toISOString,l=t.default,d={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:e.encode,encodeValuesOnly:!1,filter:void 0,format:l,formatter:t.formatters[l],indices:!1,serializeDate:function(k){return s.call(k)},skipNulls:!1,strictNullHandling:!1},_=function(k){return typeof k=="string"||typeof k=="number"||typeof k=="boolean"||typeof k=="symbol"||typeof k=="bigint"},g={},E=function q(k,A,R,S,b,h,p,v,I,B,H,V,P,ce,oe,ne,se,he){for(var J=k,me=he,de=0,be=!1;(me=me.get(g))!==void 0&&!be;){var G=me.get(k);if(de+=1,typeof G!="undefined"){if(G===de)throw new RangeError("Cyclic object value");be=!0}typeof me.get(g)=="undefined"&&(de=0)}if(typeof B=="function"?J=B(A,J):J instanceof Date?J=P(J):R==="comma"&&o(J)&&(J=e.maybeMap(J,function(ye){return ye instanceof Date?P(ye):ye})),J===null){if(h)return oe(I&&!ne?I(A,d.encoder,se,"key",ce):A);J=""}if(_(J)||e.isBuffer(J)){if(I){var re=ne?A:I(A,d.encoder,se,"key",ce);return[oe(re)+"="+oe(I(J,d.encoder,se,"value",ce))]}return[oe(A)+"="+oe(String(J))]}var j=[];if(typeof J=="undefined")return j;var L;if(R==="comma"&&o(J))ne&&I&&(J=e.maybeMap(J,function(ye){return ye==null?ye:I(ye)})),L=[{value:J.length>0?J.join(",")||null:void 0}];else if(o(B))L=B;else{var M=Object.keys(J);L=H?M.sort(H):M}var D=v?String(A).replace(/\./g,"%2E"):String(A),$=S&&o(J)&&J.length===1?D+"[]":D;if(b&&o(J)&&J.length===0)return $+"[]";for(var z=0;z<L.length;++z){var Y=L[z],T=typeof Y=="object"&&Y&&typeof Y.value!="undefined"?Y.value:J[Y];if(!(p&&T===null)){var O=V&&v?String(Y).replace(/\./g,"%2E"):String(Y),ee=o(J)?typeof R=="function"?R($,O):$:$+(V?"."+O:"["+O+"]");he.set(k,de);var ae=i();ae.set(g,he),a(j,q(T,ee,R,S,b,h,p,v,R==="comma"&&ne&&o(J)?null:I,B,H,V,P,ce,oe,ne,se,ae))}}return j},w=function(k){if(!k)return d;if(typeof k.allowEmptyArrays!="undefined"&&typeof k.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof k.encodeDotInKeys!="undefined"&&typeof k.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(k.encoder!==null&&typeof k.encoder!="undefined"&&typeof k.encoder!="function")throw new TypeError("Encoder has to be a function.");var A=k.charset||d.charset;if(typeof k.charset!="undefined"&&k.charset!=="utf-8"&&k.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var R=t.default;if(typeof k.format!="undefined"){if(!r.call(t.formatters,k.format))throw new TypeError("Unknown format option provided.");R=k.format}var S=t.formatters[R],b=d.filter;(typeof k.filter=="function"||o(k.filter))&&(b=k.filter);var h;if(k.arrayFormat in n?h=k.arrayFormat:"indices"in k?h=k.indices?"indices":"repeat":h=d.arrayFormat,"commaRoundTrip"in k&&typeof k.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var p=typeof k.allowDots=="undefined"?k.encodeDotInKeys===!0?!0:d.allowDots:!!k.allowDots;return{addQueryPrefix:typeof k.addQueryPrefix=="boolean"?k.addQueryPrefix:d.addQueryPrefix,allowDots:p,allowEmptyArrays:typeof k.allowEmptyArrays=="boolean"?!!k.allowEmptyArrays:d.allowEmptyArrays,arrayFormat:h,charset:A,charsetSentinel:typeof k.charsetSentinel=="boolean"?k.charsetSentinel:d.charsetSentinel,commaRoundTrip:!!k.commaRoundTrip,delimiter:typeof k.delimiter=="undefined"?d.delimiter:k.delimiter,encode:typeof k.encode=="boolean"?k.encode:d.encode,encodeDotInKeys:typeof k.encodeDotInKeys=="boolean"?k.encodeDotInKeys:d.encodeDotInKeys,encoder:typeof k.encoder=="function"?k.encoder:d.encoder,encodeValuesOnly:typeof k.encodeValuesOnly=="boolean"?k.encodeValuesOnly:d.encodeValuesOnly,filter:b,format:R,formatter:S,serializeDate:typeof k.serializeDate=="function"?k.serializeDate:d.serializeDate,skipNulls:typeof k.skipNulls=="boolean"?k.skipNulls:d.skipNulls,sort:typeof k.sort=="function"?k.sort:null,strictNullHandling:typeof k.strictNullHandling=="boolean"?k.strictNullHandling:d.strictNullHandling}};return Pa=function(q,k){var A=q,R=w(k),S,b;typeof R.filter=="function"?(b=R.filter,A=b("",A)):o(R.filter)&&(b=R.filter,S=b);var h=[];if(typeof A!="object"||A===null)return"";var p=n[R.arrayFormat],v=p==="comma"&&R.commaRoundTrip;S||(S=Object.keys(A)),R.sort&&S.sort(R.sort);for(var I=i(),B=0;B<S.length;++B){var H=S[B];if(!(typeof H=="undefined"||H===null)){var V=A[H];R.skipNulls&&V===null||a(h,E(V,H,p,v,R.allowEmptyArrays,R.strictNullHandling,R.skipNulls,R.encodeDotInKeys,R.encode?R.encoder:null,R.filter,R.sort,R.allowDots,R.serializeDate,R.format,R.formatter,R.encodeValuesOnly,R.charset,I))}}var P=h.join(R.delimiter),ce=R.addQueryPrefix===!0?"?":"";return R.charsetSentinel&&(R.charset==="iso-8859-1"?ce+="utf8=%26%2310003%3B"+R.delimiter:ce+="utf8=%E2%9C%93"+R.delimiter),P.length>0?ce+P:""},Pa}var Ba,vp;function B_(){if(vp)return Ba;vp=1;var i=gp(),e=Object.prototype.hasOwnProperty,t=Array.isArray,r={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:i.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictMerge:!0,strictNullHandling:!1,throwOnLimitExceeded:!1},n=function(E){return E.replace(/&#(\d+);/g,function(w,q){return String.fromCharCode(parseInt(q,10))})},o=function(E,w,q){if(E&&typeof E=="string"&&w.comma&&E.indexOf(",")>-1)return E.split(",");if(w.throwOnLimitExceeded&&q>=w.arrayLimit)throw new RangeError("Array limit exceeded. Only "+w.arrayLimit+" element"+(w.arrayLimit===1?"":"s")+" allowed in an array.");return E},u="utf8=%26%2310003%3B",a="utf8=%E2%9C%93",s=function(w,q){var k={__proto__:null},A=q.ignoreQueryPrefix?w.replace(/^\?/,""):w;A=A.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var R=q.parameterLimit===1/0?void 0:q.parameterLimit,S=A.split(q.delimiter,q.throwOnLimitExceeded&&typeof R!="undefined"?R+1:R);if(q.throwOnLimitExceeded&&typeof R!="undefined"&&S.length>R)throw new RangeError("Parameter limit exceeded. Only "+R+" parameter"+(R===1?"":"s")+" allowed.");var b=-1,h,p=q.charset;if(q.charsetSentinel)for(h=0;h<S.length;++h)S[h].indexOf("utf8=")===0&&(S[h]===a?p="utf-8":S[h]===u&&(p="iso-8859-1"),b=h,h=S.length);for(h=0;h<S.length;++h)if(h!==b){var v=S[h],I=v.indexOf("]="),B=I===-1?v.indexOf("="):I+1,H,V;if(B===-1?(H=q.decoder(v,r.decoder,p,"key"),V=q.strictNullHandling?null:""):(H=q.decoder(v.slice(0,B),r.decoder,p,"key"),H!==null&&(V=i.maybeMap(o(v.slice(B+1),q,t(k[H])?k[H].length:0),function(ce){return q.decoder(ce,r.decoder,p,"value")}))),V&&q.interpretNumericEntities&&p==="iso-8859-1"&&(V=n(String(V))),v.indexOf("[]=")>-1&&(V=t(V)?[V]:V),q.comma&&t(V)&&V.length>q.arrayLimit){if(q.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+q.arrayLimit+" element"+(q.arrayLimit===1?"":"s")+" allowed in an array.");V=i.combine([],V,q.arrayLimit,q.plainObjects)}if(H!==null){var P=e.call(k,H);P&&(q.duplicates==="combine"||v.indexOf("[]=")>-1)?k[H]=i.combine(k[H],V,q.arrayLimit,q.plainObjects):(!P||q.duplicates==="last")&&(k[H]=V)}}return k},l=function(E,w,q,k){var A=0;if(E.length>0&&E[E.length-1]==="[]"){var R=E.slice(0,-1).join("");A=Array.isArray(w)&&w[R]?w[R].length:0}for(var S=k?w:o(w,q,A),b=E.length-1;b>=0;--b){var h,p=E[b];if(p==="[]"&&q.parseArrays)i.isOverflow(S)?h=S:h=q.allowEmptyArrays&&(S===""||q.strictNullHandling&&S===null)?[]:i.combine([],S,q.arrayLimit,q.plainObjects);else{h=q.plainObjects?{__proto__:null}:{};var v=p.charAt(0)==="["&&p.charAt(p.length-1)==="]"?p.slice(1,-1):p,I=q.decodeDotInKeys?v.replace(/%2E/g,"."):v,B=parseInt(I,10),H=!isNaN(B)&&p!==I&&String(B)===I&&B>=0&&q.parseArrays;if(!q.parseArrays&&I==="")h={0:S};else if(H&&B<q.arrayLimit)h=[],h[B]=S;else{if(H&&q.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+q.arrayLimit+" element"+(q.arrayLimit===1?"":"s")+" allowed in an array.");H?(h[B]=S,i.markOverflow(h,B)):I!=="__proto__"&&(h[I]=S)}}S=h}return S},d=function(w,q){var k=q.allowDots?w.replace(/\.([^.[]+)/g,"[$1]"):w;if(q.depth<=0)return!q.plainObjects&&e.call(Object.prototype,k)&&!q.allowPrototypes?void 0:[k];var A=[],R=k.indexOf("["),S=R>=0?k.slice(0,R):k;if(S){if(!q.plainObjects&&e.call(Object.prototype,S)&&!q.allowPrototypes)return;A[A.length]=S}for(var b=k.length,h=R,p=0;h>=0&&p<q.depth;){for(var v=1,I=h+1,B=-1;I<b&&B<0;){var H=k.charCodeAt(I);H===91?v+=1:H===93&&(v-=1,v===0&&(B=I)),I+=1}if(B<0)return A[A.length]="["+k.slice(h)+"]",A;var V=k.slice(h,B+1),P=V.slice(1,-1);if(!q.plainObjects&&e.call(Object.prototype,P)&&!q.allowPrototypes)return;A[A.length]=V,p+=1,h=k.indexOf("[",B+1)}if(h>=0){if(q.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+q.depth+" and strictDepth is true");A[A.length]="["+k.slice(h)+"]"}return A},_=function(w,q,k,A){if(w){var R=d(w,k);if(R)return l(R,q,k,A)}},g=function(w){if(!w)return r;if(typeof w.allowEmptyArrays!="undefined"&&typeof w.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof w.decodeDotInKeys!="undefined"&&typeof w.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(w.decoder!==null&&typeof w.decoder!="undefined"&&typeof w.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof w.charset!="undefined"&&w.charset!=="utf-8"&&w.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(typeof w.throwOnLimitExceeded!="undefined"&&typeof w.throwOnLimitExceeded!="boolean")throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var q=typeof w.charset=="undefined"?r.charset:w.charset,k=typeof w.duplicates=="undefined"?r.duplicates:w.duplicates;if(k!=="combine"&&k!=="first"&&k!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var A=typeof w.allowDots=="undefined"?w.decodeDotInKeys===!0?!0:r.allowDots:!!w.allowDots;return{allowDots:A,allowEmptyArrays:typeof w.allowEmptyArrays=="boolean"?!!w.allowEmptyArrays:r.allowEmptyArrays,allowPrototypes:typeof w.allowPrototypes=="boolean"?w.allowPrototypes:r.allowPrototypes,allowSparse:typeof w.allowSparse=="boolean"?w.allowSparse:r.allowSparse,arrayLimit:typeof w.arrayLimit=="number"?w.arrayLimit:r.arrayLimit,charset:q,charsetSentinel:typeof w.charsetSentinel=="boolean"?w.charsetSentinel:r.charsetSentinel,comma:typeof w.comma=="boolean"?w.comma:r.comma,decodeDotInKeys:typeof w.decodeDotInKeys=="boolean"?w.decodeDotInKeys:r.decodeDotInKeys,decoder:typeof w.decoder=="function"?w.decoder:r.decoder,delimiter:typeof w.delimiter=="string"||i.isRegExp(w.delimiter)?w.delimiter:r.delimiter,depth:typeof w.depth=="number"||w.depth===!1?+w.depth:r.depth,duplicates:k,ignoreQueryPrefix:w.ignoreQueryPrefix===!0,interpretNumericEntities:typeof w.interpretNumericEntities=="boolean"?w.interpretNumericEntities:r.interpretNumericEntities,parameterLimit:typeof w.parameterLimit=="number"?w.parameterLimit:r.parameterLimit,parseArrays:w.parseArrays!==!1,plainObjects:typeof w.plainObjects=="boolean"?w.plainObjects:r.plainObjects,strictDepth:typeof w.strictDepth=="boolean"?!!w.strictDepth:r.strictDepth,strictMerge:typeof w.strictMerge=="boolean"?!!w.strictMerge:r.strictMerge,strictNullHandling:typeof w.strictNullHandling=="boolean"?w.strictNullHandling:r.strictNullHandling,throwOnLimitExceeded:typeof w.throwOnLimitExceeded=="boolean"?w.throwOnLimitExceeded:!1}};return Ba=function(E,w){var q=g(w);if(E===""||E===null||typeof E=="undefined")return q.plainObjects?{__proto__:null}:{};for(var k=typeof E=="string"?s(E,q):E,A=q.plainObjects?{__proto__:null}:{},R=Object.keys(k),S=0;S<R.length;++S){var b=R[S],h=_(b,k[b],q,typeof E=="string");A=i.merge(A,h,q)}return q.allowSparse===!0?A:i.compact(A)},Ba}var Da,bp;function D_(){if(bp)return Da;bp=1;var i=P_(),e=B_(),t=qa();return Da={formats:t,parse:e,stringify:i},Da}var wp;function L_(){return wp||(wp=1,(function(i,e){Object.defineProperty(e,"__esModule",{value:!0});var t=C_(),r=D_();function n(K){return K&&typeof K=="object"&&"default"in K?K:{default:K}}var o=n(t),u=n(r),a=o.default;function s(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var l=/^([a-z0-9.+-]+:)/i,d=/:[0-9]*$/,_=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,g=["<",">",'"',"`"," ","\r",`
25
+ `," "],E=["{","}","|","\\","^","`"].concat(g),w=["'"].concat(E),q=["%","/","?",";","#"].concat(w),k=["/","?","#"],A=255,R=/^[+a-z0-9A-Z_-]{0,63}$/,S=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},h={javascript:!0,"javascript:":!0},p={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=u.default;function I(K,pe,X){if(K&&typeof K=="object"&&K instanceof s)return K;var Te=new s;return Te.parse(K,pe,X),Te}s.prototype.parse=function(K,pe,X){if(typeof K!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof K);var Te=K.indexOf("?"),qe=Te!==-1&&Te<K.indexOf("#")?"?":"#",$e=K.split(qe),Be=/\\/g;$e[0]=$e[0].replace(Be,"/"),K=$e.join(qe);var Ie=K;if(Ie=Ie.trim(),!X&&K.split("#").length===1){var x=_.exec(Ie);if(x)return this.path=Ie,this.href=Ie,this.pathname=x[1],x[2]?(this.search=x[2],pe?this.query=v.parse(this.search.substr(1)):this.query=this.search.substr(1)):pe&&(this.search="",this.query={}),this}var f=l.exec(Ie);if(f){f=f[0];var m=f.toLowerCase();this.protocol=m,Ie=Ie.substr(f.length)}if(X||f||Ie.match(/^\/\/[^@/]+@[^@/]+/)){var F=Ie.substr(0,2)==="//";F&&!(f&&h[f])&&(Ie=Ie.substr(2),this.slashes=!0)}if(!h[f]&&(F||f&&!p[f])){for(var W=-1,te=0;te<k.length;te++){var N=Ie.indexOf(k[te]);N!==-1&&(W===-1||N<W)&&(W=N)}var Z,Ee;W===-1?Ee=Ie.lastIndexOf("@"):Ee=Ie.lastIndexOf("@",W),Ee!==-1&&(Z=Ie.slice(0,Ee),Ie=Ie.slice(Ee+1),this.auth=decodeURIComponent(Z)),W=-1;for(var te=0;te<q.length;te++){var N=Ie.indexOf(q[te]);N!==-1&&(W===-1||N<W)&&(W=N)}W===-1&&(W=Ie.length),this.host=Ie.slice(0,W),Ie=Ie.slice(W),this.parseHost(),this.hostname=this.hostname||"";var Ae=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!Ae)for(var _e=this.hostname.split(/\./),te=0,ve=_e.length;te<ve;te++){var Ve=_e[te];if(Ve&&!Ve.match(R)){for(var Ue="",Ne=0,ot=Ve.length;Ne<ot;Ne++)Ve.charCodeAt(Ne)>127?Ue+="x":Ue+=Ve[Ne];if(!Ue.match(R)){var Qe=_e.slice(0,te),Je=_e.slice(te+1),C=Ve.match(S);C&&(Qe.push(C[1]),Je.unshift(C[2])),Je.length&&(Ie="/"+Je.join(".")+Ie),this.hostname=Qe.join(".");break}}}this.hostname.length>A?this.hostname="":this.hostname=this.hostname.toLowerCase(),Ae||(this.hostname=a.toASCII(this.hostname));var c=this.port?":"+this.port:"",y=this.hostname||"";this.host=y+c,this.href+=this.host,Ae&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),Ie[0]!=="/"&&(Ie="/"+Ie))}if(!b[m])for(var te=0,ve=w.length;te<ve;te++){var U=w[te];if(Ie.indexOf(U)!==-1){var Q=encodeURIComponent(U);Q===U&&(Q=escape(U)),Ie=Ie.split(U).join(Q)}}var ie=Ie.indexOf("#");ie!==-1&&(this.hash=Ie.substr(ie),Ie=Ie.slice(0,ie));var fe=Ie.indexOf("?");if(fe!==-1?(this.search=Ie.substr(fe),this.query=Ie.substr(fe+1),pe&&(this.query=v.parse(this.query)),Ie=Ie.slice(0,fe)):pe&&(this.search="",this.query={}),Ie&&(this.pathname=Ie),p[m]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var c=this.pathname||"",Ce=this.search||"";this.path=c+Ce}return this.href=this.format(),this};function B(K){return typeof K=="string"&&(K=I(K)),K instanceof s?K.format():s.prototype.format.call(K)}s.prototype.format=function(){var K=this.auth||"";K&&(K=encodeURIComponent(K),K=K.replace(/%3A/i,":"),K+="@");var pe=this.protocol||"",X=this.pathname||"",Te=this.hash||"",qe=!1,$e="";this.host?qe=K+this.host:this.hostname&&(qe=K+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(qe+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&($e=v.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var Be=this.search||$e&&"?"+$e||"";return pe&&pe.substr(-1)!==":"&&(pe+=":"),this.slashes||(!pe||p[pe])&&qe!==!1?(qe="//"+(qe||""),X&&X.charAt(0)!=="/"&&(X="/"+X)):qe||(qe=""),Te&&Te.charAt(0)!=="#"&&(Te="#"+Te),Be&&Be.charAt(0)!=="?"&&(Be="?"+Be),X=X.replace(/[?#]/g,function(Ie){return encodeURIComponent(Ie)}),Be=Be.replace("#","%23"),pe+qe+X+Be+Te};function H(K,pe){return I(K,!1,!0).resolve(pe)}s.prototype.resolve=function(K){return this.resolveObject(I(K,!1,!0)).format()};function V(K,pe){return K?I(K,!1,!0).resolveObject(pe):pe}s.prototype.resolveObject=function(K){if(typeof K=="string"){var pe=new s;pe.parse(K,!1,!0),K=pe}for(var X=new s,Te=Object.keys(this),qe=0;qe<Te.length;qe++){var $e=Te[qe];X[$e]=this[$e]}if(X.hash=K.hash,K.href==="")return X.href=X.format(),X;if(K.slashes&&!K.protocol){for(var Be=Object.keys(K),Ie=0;Ie<Be.length;Ie++){var x=Be[Ie];x!=="protocol"&&(X[x]=K[x])}return p[X.protocol]&&X.hostname&&!X.pathname&&(X.pathname="/",X.path=X.pathname),X.href=X.format(),X}if(K.protocol&&K.protocol!==X.protocol){if(!p[K.protocol]){for(var f=Object.keys(K),m=0;m<f.length;m++){var F=f[m];X[F]=K[F]}return X.href=X.format(),X}if(X.protocol=K.protocol,!K.host&&!h[K.protocol]){for(var ve=(K.pathname||"").split("/");ve.length&&!(K.host=ve.shift()););K.host||(K.host=""),K.hostname||(K.hostname=""),ve[0]!==""&&ve.unshift(""),ve.length<2&&ve.unshift(""),X.pathname=ve.join("/")}else X.pathname=K.pathname;if(X.search=K.search,X.query=K.query,X.host=K.host||"",X.auth=K.auth,X.hostname=K.hostname||K.host,X.port=K.port,X.pathname||X.search){var W=X.pathname||"",te=X.search||"";X.path=W+te}return X.slashes=X.slashes||K.slashes,X.href=X.format(),X}var N=X.pathname&&X.pathname.charAt(0)==="/",Z=K.host||K.pathname&&K.pathname.charAt(0)==="/",Ee=Z||N||X.host&&K.pathname,Ae=Ee,_e=X.pathname&&X.pathname.split("/")||[],ve=K.pathname&&K.pathname.split("/")||[],Ve=X.protocol&&!p[X.protocol];if(Ve&&(X.hostname="",X.port=null,X.host&&(_e[0]===""?_e[0]=X.host:_e.unshift(X.host)),X.host="",K.protocol&&(K.hostname=null,K.port=null,K.host&&(ve[0]===""?ve[0]=K.host:ve.unshift(K.host)),K.host=null),Ee=Ee&&(ve[0]===""||_e[0]==="")),Z)X.host=K.host||K.host===""?K.host:X.host,X.hostname=K.hostname||K.hostname===""?K.hostname:X.hostname,X.search=K.search,X.query=K.query,_e=ve;else if(ve.length)_e||(_e=[]),_e.pop(),_e=_e.concat(ve),X.search=K.search,X.query=K.query;else if(K.search!=null){if(Ve){X.host=_e.shift(),X.hostname=X.host;var Ue=X.host&&X.host.indexOf("@")>0?X.host.split("@"):!1;Ue&&(X.auth=Ue.shift(),X.hostname=Ue.shift(),X.host=X.hostname)}return X.search=K.search,X.query=K.query,(X.pathname!==null||X.search!==null)&&(X.path=(X.pathname?X.pathname:"")+(X.search?X.search:"")),X.href=X.format(),X}if(!_e.length)return X.pathname=null,X.search?X.path="/"+X.search:X.path=null,X.href=X.format(),X;for(var Ne=_e.slice(-1)[0],ot=(X.host||K.host||_e.length>1)&&(Ne==="."||Ne==="..")||Ne==="",Qe=0,Je=_e.length;Je>=0;Je--)Ne=_e[Je],Ne==="."?_e.splice(Je,1):Ne===".."?(_e.splice(Je,1),Qe++):Qe&&(_e.splice(Je,1),Qe--);if(!Ee&&!Ae)for(;Qe--;Qe)_e.unshift("..");Ee&&_e[0]!==""&&(!_e[0]||_e[0].charAt(0)!=="/")&&_e.unshift(""),ot&&_e.join("/").substr(-1)!=="/"&&_e.push("");var C=_e[0]===""||_e[0]&&_e[0].charAt(0)==="/";if(Ve){X.hostname=C?"":_e.length?_e.shift():"",X.host=X.hostname;var Ue=X.host&&X.host.indexOf("@")>0?X.host.split("@"):!1;Ue&&(X.auth=Ue.shift(),X.hostname=Ue.shift(),X.host=X.hostname)}return Ee=Ee||X.host&&_e.length,Ee&&!C&&_e.unshift(""),_e.length>0?X.pathname=_e.join("/"):(X.pathname=null,X.path=null),(X.pathname!==null||X.search!==null)&&(X.path=(X.pathname?X.pathname:"")+(X.search?X.search:"")),X.auth=K.auth||X.auth,X.slashes=X.slashes||K.slashes,X.href=X.format(),X},s.prototype.parseHost=function(){var K=this.host,pe=d.exec(K);pe&&(pe=pe[0],pe!==":"&&(this.port=pe.substr(1)),K=K.substr(0,K.length-pe.length)),K&&(this.hostname=K)};var P=I,ce=H,oe=V,ne=B,se=s;function he(K,pe){for(var X=0,Te=K.length-1;Te>=0;Te--){var qe=K[Te];qe==="."?K.splice(Te,1):qe===".."?(K.splice(Te,1),X++):X&&(K.splice(Te,1),X--)}if(pe)for(;X--;X)K.unshift("..");return K}function J(){for(var K="",pe=!1,X=arguments.length-1;X>=-1&&!pe;X--){var Te=X>=0?arguments[X]:"/";if(typeof Te!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!Te)continue;K=Te+"/"+K,pe=Te.charAt(0)==="/"}return K=he(me(K.split("/"),function(qe){return!!qe}),!pe).join("/"),(pe?"/":"")+K||"."}function me(K,pe){if(K.filter)return K.filter(pe);for(var X=[],Te=0;Te<K.length;Te++)pe(K[Te],Te,K)&&X.push(K[Te]);return X}var de=(function(K){function pe(){var Te=this||self;return delete K.prototype.__magic__,Te}if(typeof globalThis=="object")return globalThis;if(this)return pe();K.defineProperty(K.prototype,"__magic__",{configurable:!0,get:pe});var X=__magic__;return X})(Object),be=ne,G=P,re=ce,j=se,L=de.URL,M=de.URLSearchParams,D=/%/g,$=/\\/g,z=/\n/g,Y=/\r/g,T=/\t/g,O=47;function ee(K){var pe=K!=null?K:null;return!!(pe!==null&&(pe!=null&&pe.href)&&(pe!=null&&pe.origin))}function ae(K){if(K.hostname!=="")throw new TypeError('File URL host must be "localhost" or empty on browser');for(var pe=K.pathname,X=0;X<pe.length;X++)if(pe[X]==="%"){var Te=pe.codePointAt(X+2)|32;if(pe[X+1]==="2"&&Te===102)throw new TypeError("File URL path must not include encoded / characters")}return decodeURIComponent(pe)}function ye(K){return K.includes("%")&&(K=K.replace(D,"%25")),K.includes("\\")&&(K=K.replace($,"%5C")),K.includes(`
26
+ `)&&(K=K.replace(z,"%0A")),K.includes("\r")&&(K=K.replace(Y,"%0D")),K.includes(" ")&&(K=K.replace(T,"%09")),K}var le=function(pe){if(typeof pe=="undefined")throw new TypeError('The "domain" argument must be specified');return new L("http://"+pe).hostname},Se=function(pe){if(typeof pe=="undefined")throw new TypeError('The "domain" argument must be specified');return new L("http://"+pe).hostname},Pe=function(pe){var X=new L("file://"),Te=J(pe),qe=pe.charCodeAt(pe.length-1);return qe===O&&Te[Te.length-1]!=="/"&&(Te+="/"),X.pathname=ye(Te),X},ue=function(pe){if(!ee(pe)&&typeof pe!="string")throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type '+typeof pe+" ("+pe+")");var X=new L(pe);if(X.protocol!=="file:")throw new TypeError("The URL must be of scheme file");return ae(X)},je=function(pe,X){var Te,qe,$e,Be;if(X===void 0&&(X={}),!(pe instanceof L))return be(pe);if(typeof X!="object"||X===null)throw new TypeError('The "options" argument must be of type object.');var Ie=(Te=X.auth)!=null?Te:!0,x=(qe=X.fragment)!=null?qe:!0,f=($e=X.search)!=null?$e:!0;(Be=X.unicode)!=null;var m=new L(pe.toString());return Ie||(m.username="",m.password=""),x||(m.hash=""),f||(m.search=""),m.toString()},De={format:je,parse:G,resolve:re,resolveObject:oe,Url:j,URL:L,URLSearchParams:M,domainToASCII:le,domainToUnicode:Se,pathToFileURL:Pe,fileURLToPath:ue};e.URL=L,e.URLSearchParams=M,e.Url=j,e.default=De,e.domainToASCII=le,e.domainToUnicode=Se,e.fileURLToPath=ue,e.format=je,e.parse=G,e.pathToFileURL=Pe,e.resolve=re,e.resolveObject=oe,e=i.exports=De})(mr,mr.exports)),mr.exports}var La,Sp;function Ep(){if(Sp)return La;Sp=1;var i=null;return La=i,La}var Fa,Ip;function Tp(){if(Ip)return Fa;Ip=1;var i=Ep(),e=Rt()("mqttjs:tcp");function t(r,n){var o,u;return n.port=n.port||1883,n.hostname=n.hostname||n.host||"localhost",o=n.port,u=n.hostname,e("port %d and host %s",o,u),i.createConnection(o,u)}return Fa=t,Fa}var Ua,Rp;function Na(){if(Rp)return Ua;Rp=1;var i=Ep(),e=Rt()("mqttjs:tls");function t(r,n){var o;n.port=n.port||8883,n.host=n.hostname||n.host||"localhost",n.servername=n.host,n.rejectUnauthorized=n.rejectUnauthorized!==!1,delete n.path,e("port %d host %s rejectUnauthorized %b",n.port,n.host,n.rejectUnauthorized),o=i.connect(n),o.on("secureConnect",function(){n.rejectUnauthorized&&!o.authorized?o.emit("error",new Error("TLS not authorized")):o.removeListener("error",u)});function u(a){n.rejectUnauthorized&&r.emit("error",a),o.end()}return o.on("error",u),o}return Ua=t,Ua}var gr={exports:{}},ja,Ap;function F_(){if(Ap)return ja;Ap=1,ja=i;function i(e,t){if(e&&t)return i(e)(t);if(typeof e!="function")throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(n){r[n]=e[n]}),r;function r(){for(var n=new Array(arguments.length),o=0;o<n.length;o++)n[o]=arguments[o];var u=e.apply(this,n),a=n[n.length-1];return typeof u=="function"&&u!==a&&Object.keys(a).forEach(function(s){u[s]=a[s]}),u}}return ja}var Op;function U_(){if(Op)return gr.exports;Op=1;var i=F_();gr.exports=i(e),gr.exports.strict=i(t),e.proto=e(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return e(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return t(this)},configurable:!0})});function e(r){var n=function(){return n.called?n.value:(n.called=!0,n.value=r.apply(this,arguments))};return n.called=!1,n}function t(r){var n=function(){if(n.called)throw new Error(n.onceError);return n.called=!0,n.value=r.apply(this,arguments)},o=r.name||"Function wrapped with `once`";return n.onceError=o+" shouldn't be called more than once",n.called=!1,n}return gr.exports}var $a,xp;function N_(){if(xp)return $a;xp=1;var i=U_(),e=function(){},t=xe.Bare?queueMicrotask:Re.nextTick.bind(Re),r=function(u){return u.setHeader&&typeof u.abort=="function"},n=function(u){return u.stdio&&Array.isArray(u.stdio)&&u.stdio.length===3},o=function(u,a,s){if(typeof a=="function")return o(u,null,a);a||(a={}),s=i(s||e);var l=u._writableState,d=u._readableState,_=a.readable||a.readable!==!1&&u.readable,g=a.writable||a.writable!==!1&&u.writable,E=!1,w=function(){u.writable||q()},q=function(){g=!1,_||s.call(u)},k=function(){_=!1,g||s.call(u)},A=function(p){s.call(u,p?new Error("exited with error code: "+p):null)},R=function(p){s.call(u,p)},S=function(){t(b)},b=function(){if(!E){if(_&&!(d&&d.ended&&!d.destroyed))return s.call(u,new Error("premature close"));if(g&&!(l&&l.ended&&!l.destroyed))return s.call(u,new Error("premature close"))}},h=function(){u.req.on("finish",q)};return r(u)?(u.on("complete",q),u.on("abort",S),u.req?h():u.on("request",h)):g&&!l&&(u.on("end",w),u.on("close",w)),n(u)&&u.on("exit",A),u.on("end",k),u.on("finish",q),a.error!==!1&&u.on("error",R),u.on("close",S),function(){E=!0,u.removeListener("complete",q),u.removeListener("abort",S),u.removeListener("request",h),u.req&&u.req.removeListener("finish",q),u.removeListener("end",w),u.removeListener("close",w),u.removeListener("finish",q),u.removeListener("exit",A),u.removeListener("end",k),u.removeListener("error",R),u.removeListener("close",S)}};return $a=o,$a}var Ha,Cp;function j_(){if(Cp)return Ha;Cp=1,Ha=i;function i(t){var r=t._readableState;return r?r.objectMode||typeof t._duplexState=="number"?t.read():t.read(e(r)):null}function e(t){if(t.buffer.length){var r=t.bufferIndex||0;if(t.buffer.head)return t.buffer.head.data.length;if(t.buffer.length-r>0&&t.buffer[r])return t.buffer[r].length}return t.length}return Ha}var Wa,kp;function Ya(){if(kp)return Wa;kp=1;var i=Tt(),e=N_(),t=_t(),r=j_(),n=we.from&&we.from!==Uint8Array.from?we.from([0]):new we([0]),o=function(g,E){g._corked?g.once("uncork",E):E()},u=function(g,E){g._autoDestroy&&g.destroy(E)},a=function(g,E){return function(w){w?u(g,w.message==="premature close"?null:w):E&&!g._ended&&g.end()}},s=function(g,E){if(!g||g._writableState&&g._writableState.finished)return E();if(g._writableState)return g.end(E);g.end(),E()},l=function(){},d=function(g){return new i.Readable({objectMode:!0,highWaterMark:16}).wrap(g)},_=function(g,E,w){if(!(this instanceof _))return new _(g,E,w);i.Duplex.call(this,w),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!w||w.autoDestroy!==!1,this._forwardDestroy=!w||w.destroy!==!1,this._forwardEnd=!w||w.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,g&&this.setWritable(g),E&&this.setReadable(E)};return t(_,i.Duplex),_.obj=function(g,E,w){return w||(w={}),w.objectMode=!0,w.highWaterMark=16,new _(g,E,w)},_.prototype.cork=function(){++this._corked===1&&this.emit("cork")},_.prototype.uncork=function(){this._corked&&--this._corked===0&&this.emit("uncork")},_.prototype.setWritable=function(g){if(this._unwrite&&this._unwrite(),this.destroyed){g&&g.destroy&&g.destroy();return}if(g===null||g===!1){this.end();return}var E=this,w=e(g,{writable:!0,readable:!1},a(this,this._forwardEnd)),q=function(){var A=E._ondrain;E._ondrain=null,A&&A()},k=function(){E._writable.removeListener("drain",q),w()};this._unwrite&&Re.nextTick(q),this._writable=g,this._writable.on("drain",q),this._unwrite=k,this.uncork()},_.prototype.setReadable=function(g){if(this._unread&&this._unread(),this.destroyed){g&&g.destroy&&g.destroy();return}if(g===null||g===!1){this.push(null),this.resume();return}var E=this,w=e(g,{writable:!1,readable:!0},a(this)),q=function(){E._forward()},k=function(){E.push(null)},A=function(){E._readable2.removeListener("readable",q),E._readable2.removeListener("end",k),w()};this._drained=!0,this._readable=g,this._readable2=g._readableState?g:d(g),this._readable2.on("readable",q),this._readable2.on("end",k),this._unread=A,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 g;this._drained&&(g=r(this._readable2))!==null;)this.destroyed||(this._drained=this.push(g));this._forwarding=!1}},_.prototype.destroy=function(g,E){if(E||(E=l),this.destroyed)return E(null);this.destroyed=!0;var w=this;Re.nextTick(function(){w._destroy(g),E(null)})},_.prototype._destroy=function(g){if(g){var E=this._ondrain;this._ondrain=null,E?E(g):this.emit("error",g)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},_.prototype._write=function(g,E,w){if(!this.destroyed){if(this._corked)return o(this,this._write.bind(this,g,E,w));if(g===n)return this._finish(w);if(!this._writable)return w();this._writable.write(g)===!1?this._ondrain=w:this.destroyed||w()}},_.prototype._finish=function(g){var E=this;this.emit("preend"),o(this,function(){s(E._forwardEnd&&E._writable,function(){E._writableState.prefinished===!1&&(E._writableState.prefinished=!0),E.emit("prefinish"),o(E,g)})})},_.prototype.end=function(g,E,w){return typeof g=="function"?this.end(null,null,g):typeof E=="function"?this.end(g,null,E):(this._ended=!0,g&&this.write(g),!this._writableState.ending&&!this._writableState.destroyed&&this.write(n),i.Writable.prototype.end.call(this,w))},Wa=_,Wa}var Ga,qp;function Mp(){if(qp)return Ga;qp=1;var i=Tt().Transform,e=Ya(),t,r,n;function o(){var d=new i;return d._write=function(_,g,E){t.send({data:_.buffer,success:function(){E()},fail:function(w){E(new Error(w))}})},d._flush=function(g){t.close({success:function(){g()}})},d}function u(d){d.hostname||(d.hostname="localhost"),d.path||(d.path="/"),d.wsOptions||(d.wsOptions={})}function a(d,_){var g=d.protocol==="wxs"?"wss":"ws",E=g+"://"+d.hostname+d.path;return d.port&&d.port!==80&&d.port!==443&&(E=g+"://"+d.hostname+":"+d.port+d.path),typeof d.transformWsUrl=="function"&&(E=d.transformWsUrl(E,d,_)),E}function s(){t.onOpen(function(){n.setReadable(r),n.setWritable(r),n.emit("connect")}),t.onMessage(function(d){var _=d.data;_ instanceof ArrayBuffer?_=we.from(_):_=we.from(_,"utf8"),r.push(_)}),t.onClose(function(){n.end(),n.destroy()}),t.onError(function(d){n.destroy(new Error(d.errMsg))})}function l(d,_){if(_.hostname=_.hostname||_.host,!_.hostname)throw new Error("Could not determine host. Specify host manually.");var g=_.protocolId==="MQIsdp"&&_.protocolVersion===3?"mqttv3.1":"mqtt";u(_);var E=a(_,d);t=wx.connectSocket({url:E,protocols:[g]}),r=o(),n=e.obj(),n._destroy=function(q,k){t.close({success:function(){k&&k(q)}})};var w=n.destroy;return n.destroy=function(){n.destroy=w;var q=this;setTimeout(function(){t.close({fail:function(){q._destroy(new Error)}})},0)}.bind(n),s(),n}return Ga=l,Ga}var za,Pp;function Bp(){if(Pp)return za;Pp=1;var i=Tt().Transform,e=Ya(),t,r,n,o=!1;function u(){var _=new i;return _._write=function(g,E,w){t.sendSocketMessage({data:g.buffer,success:function(){w()},fail:function(){w(new Error)}})},_._flush=function(E){t.closeSocket({success:function(){E()}})},_}function a(_){_.hostname||(_.hostname="localhost"),_.path||(_.path="/"),_.wsOptions||(_.wsOptions={})}function s(_,g){var E=_.protocol==="alis"?"wss":"ws",w=E+"://"+_.hostname+_.path;return _.port&&_.port!==80&&_.port!==443&&(w=E+"://"+_.hostname+":"+_.port+_.path),typeof _.transformWsUrl=="function"&&(w=_.transformWsUrl(w,_,g)),w}function l(){o||(o=!0,t.onSocketOpen(function(){n.setReadable(r),n.setWritable(r),n.emit("connect")}),t.onSocketMessage(function(_){if(typeof _.data=="string"){var g=we.from(_.data,"base64");r.push(g)}else{var E=new FileReader;E.addEventListener("load",function(){var w=E.result;w instanceof ArrayBuffer?w=we.from(w):w=we.from(w,"utf8"),r.push(w)}),E.readAsArrayBuffer(_.data)}}),t.onSocketClose(function(){n.end(),n.destroy()}),t.onSocketError(function(_){n.destroy(_)}))}function d(_,g){if(g.hostname=g.hostname||g.host,!g.hostname)throw new Error("Could not determine host. Specify host manually.");var E=g.protocolId==="MQIsdp"&&g.protocolVersion===3?"mqttv3.1":"mqtt";a(g);var w=s(g,_);return t=g.my,t.connectSocket({url:w,protocols:E}),r=u(),n=e.obj(),l(),n}return za=d,za}var _r={exports:{}},Va,Dp;function $_(){return Dp||(Dp=1,Va=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}),Va}var Lp;function Fp(){if(Lp)return _r.exports;Lp=1;const i=$_(),e=Rt()("mqttjs:ws"),t=Ya(),r=Tt().Transform;let n=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];const o=typeof Re!="undefined"&&Re.title==="browser"||typeof __webpack_require__=="function";function u(E,w){let q=E.protocol+"://"+E.hostname+":"+E.port+E.path;return typeof E.transformWsUrl=="function"&&(q=E.transformWsUrl(q,E,w)),q}function a(E){let w=E;return E.hostname||(w.hostname="localhost"),E.port||(E.protocol==="wss"?w.port=443:w.port=80),E.path||(w.path="/"),E.wsOptions||(w.wsOptions={}),!o&&E.protocol==="wss"&&n.forEach(function(q){E.hasOwnProperty(q)&&!E.wsOptions.hasOwnProperty(q)&&(w.wsOptions[q]=E[q])}),w}function s(E){let w=a(E);if(w.hostname||(w.hostname=w.host),!w.hostname){if(typeof document=="undefined")throw new Error("Could not determine host. Specify host manually.");const q=new URL(document.URL);w.hostname=q.hostname,w.port||(w.port=q.port)}return w.objectMode===void 0&&(w.objectMode=!(w.binary===!0||w.binary===void 0)),w}function l(E,w,q){e("createWebSocket"),e("protocol: "+q.protocolId+" "+q.protocolVersion);const k=q.protocolId==="MQIsdp"&&q.protocolVersion===3?"mqttv3.1":"mqtt";return e("creating new Websocket for url: "+w+" and protocol: "+k),new i(w,[k],q.wsOptions)}function d(E,w){const q=w.protocolId==="MQIsdp"&&w.protocolVersion===3?"mqttv3.1":"mqtt";let k=u(w,E),A=new WebSocket(k,[q]);return A.binaryType="arraybuffer",A}function _(E,w){e("streamBuilder");let q=a(w);const k=u(q,E);let A=l(E,k,q),R=i.createWebSocketStream(A,q.wsOptions);return R.url=k,A.on("close",()=>{R.destroy()}),R}function g(E,w){e("browserStreamBuilder");let q;const A=s(w).browserBufferSize||1024*512,R=w.browserBufferTimeout||1e3,S=!w.objectMode;let b=d(E,w),h=v(w,ce,oe);w.objectMode||(h._writev=P),h.on("close",()=>{b.close()});const p=typeof b.addEventListener!="undefined";b.readyState===b.OPEN?q=h:(q=q=t(void 0,void 0,w),w.objectMode||(q._writev=P),p?b.addEventListener("open",I):b.onopen=I),q.socket=b,p?(b.addEventListener("close",B),b.addEventListener("error",H),b.addEventListener("message",V)):(b.onclose=B,b.onerror=H,b.onmessage=V);function v(ne,se,he){let J=new r({objectModeMode:ne.objectMode});return J._write=se,J._flush=he,J}function I(){q.setReadable(h),q.setWritable(h),q.emit("connect")}function B(){q.end(),q.destroy()}function H(ne){q.destroy(ne)}function V(ne){let se=ne.data;se instanceof ArrayBuffer?se=we.from(se):se=we.from(se,"utf8"),h.push(se)}function P(ne,se){const he=new Array(ne.length);for(let J=0;J<ne.length;J++)typeof ne[J].chunk=="string"?he[J]=we.from(ne[J],"utf8"):he[J]=ne[J].chunk;this._write(we.concat(he),"binary",se)}function ce(ne,se,he){b.bufferedAmount>A&&setTimeout(ce,R,ne,se,he),S&&typeof ne=="string"&&(ne=we.from(ne,"utf8"));try{b.send(ne)}catch(J){return he(J)}he()}function oe(ne){b.close(),ne()}return q}return o?_r.exports=g:_r.exports=_,_r.exports}var Up;function H_(){if(Up)return kt.exports;Up=1;var i=O_(),e=Nd(),t=L_(),r=jo(),n=Rt()("mqttjs"),o={};typeof Re!="undefined"&&Re.title!=="browser"||typeof __webpack_require__!="function"?(o.mqtt=Tp(),o.tcp=Tp(),o.ssl=Na(),o.tls=Na(),o.mqtts=Na()):(o.wx=Mp(),o.wxs=Mp(),o.ali=Bp(),o.alis=Bp()),o.ws=Fp(),o.wss=Fp();function u(s){var l;s.auth&&(l=s.auth.match(/^(.+):(.+)$/),l?(s.username=l[1],s.password=l[2]):s.username=s.auth)}function a(s,l){if(n("connecting to an MQTT broker..."),typeof s=="object"&&!l&&(l=s,s=null),l=l||{},s){var d=t.parse(s,!0);if(d.port!=null&&(d.port=Number(d.port)),l=r(d,l),l.protocol===null)throw new Error("Missing protocol");l.protocol=l.protocol.replace(/:$/,"")}if(u(l),l.query&&typeof l.query.clientId=="string"&&(l.clientId=l.query.clientId),l.cert&&l.key)if(l.protocol){if(["mqtts","wss","wxs","alis"].indexOf(l.protocol)===-1)switch(l.protocol){case"mqtt":l.protocol="mqtts";break;case"ws":l.protocol="wss";break;case"wx":l.protocol="wxs";break;case"ali":l.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+l.protocol+'"!')}}else throw new Error("Missing secure protocol key");if(!o[l.protocol]){var _=["mqtts","wss"].indexOf(l.protocol)!==-1;l.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter(function(w,q){return _&&q%2===0?!1:typeof o[w]=="function"})[0]}if(l.clean===!1&&!l.clientId)throw new Error("Missing clientId for unclean clients");l.protocol&&(l.defaultProtocol=l.protocol);function g(w){return l.servers&&((!w._reconnectCount||w._reconnectCount===l.servers.length)&&(w._reconnectCount=0),l.host=l.servers[w._reconnectCount].host,l.port=l.servers[w._reconnectCount].port,l.protocol=l.servers[w._reconnectCount].protocol?l.servers[w._reconnectCount].protocol:l.defaultProtocol,l.hostname=l.host,w._reconnectCount++),n("calling streambuilder for",l.protocol),o[l.protocol](w,l)}var E=new i(g,l);return E.on("error",function(){}),E}return kt.exports=a,kt.exports.connect=a,kt.exports.MqttClient=i,kt.exports.Store=e,kt.exports}var W_=H_();const Y_=rt(W_);var Ka,Np;function G_(){if(Np)return Ka;Np=1;var i="Expected a function",e=NaN,t="[object Symbol]",r=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,u=/^0o[0-7]+$/i,a=parseInt,s=typeof xe=="object"&&xe&&xe.Object===Object&&xe,l=typeof self=="object"&&self&&self.Object===Object&&self,d=s||l||Function("return this")(),_=Object.prototype,g=_.toString,E=Math.max,w=Math.min,q=function(){return d.Date.now()};function k(h,p,v){var I,B,H,V,P,ce,oe=0,ne=!1,se=!1,he=!0;if(typeof h!="function")throw new TypeError(i);p=b(p)||0,A(v)&&(ne=!!v.leading,se="maxWait"in v,H=se?E(b(v.maxWait)||0,p):H,he="trailing"in v?!!v.trailing:he);function J(D){var $=I,z=B;return I=B=void 0,oe=D,V=h.apply(z,$),V}function me(D){return oe=D,P=setTimeout(G,p),ne?J(D):V}function de(D){var $=D-ce,z=D-oe,Y=p-$;return se?w(Y,H-z):Y}function be(D){var $=D-ce,z=D-oe;return ce===void 0||$>=p||$<0||se&&z>=H}function G(){var D=q();if(be(D))return re(D);P=setTimeout(G,de(D))}function re(D){return P=void 0,he&&I?J(D):(I=B=void 0,V)}function j(){P!==void 0&&clearTimeout(P),oe=0,I=ce=B=P=void 0}function L(){return P===void 0?V:re(q())}function M(){var D=q(),$=be(D);if(I=arguments,B=this,ce=D,$){if(P===void 0)return me(ce);if(se)return P=setTimeout(G,p),J(ce)}return P===void 0&&(P=setTimeout(G,p)),V}return M.cancel=j,M.flush=L,M}function A(h){var p=typeof h;return!!h&&(p=="object"||p=="function")}function R(h){return!!h&&typeof h=="object"}function S(h){return typeof h=="symbol"||R(h)&&g.call(h)==t}function b(h){if(typeof h=="number")return h;if(S(h))return e;if(A(h)){var p=typeof h.valueOf=="function"?h.valueOf():h;h=A(p)?p+"":p}if(typeof h!="string")return h===0?h:+h;h=h.replace(r,"");var v=o.test(h);return v||u.test(h)?a(h.slice(2),v?2:8):n.test(h)?e:+h}return Ka=k,Ka}var z_=G_();const V_=rt(z_),jp=(i,e,t,r)=>{try{const n=i();return r!=null&&r(n),n}catch(n){return t!=null&&t(n),e}},K_=i=>i.then(e=>[e,null]).catch(e=>[null,e]);class Q_{constructor(e,t,r,{shouldConnect:n=!0,brokerLbUrl:o,enableLb:u,getClientId:a}){He(this,"_getClientId",()=>this.getClientId==null?`${this.core.AppId}_${this.core.user_id}_${Date.now()}`:this.getClientId());He(this,"__mqtt_connected_handler",()=>{this.emitter.emit("connected")});He(this,"__mqtt_reconnect_handler",()=>{this.emitter.emit("reconnect")});He(this,"__mqtt_closed_handler",(...e)=>{this.emitter.emit("close",e)});He(this,"__mqtt_message_handler",(e,t)=>{const r=t.toString(),n=this.matcher(e);this.logger("message",e,t),n!=null&&n(r)});He(this,"__mqtt_error_handler",e=>{e&&e.message==="client disconnecting"||(this.emitter.emit("error",e.message),this.logger("error",e.message))});He(this,"__mqtt_conneck",e=>{const t=[],r={will:{topic:`u/${this.core.user_id}/s`,payload:0,retain:!0},clientId:this._getClientId()};if(e==null&&(e=this.cacheRealtimeURL),this.mqtt!=null){const o=Object.keys(this.mqtt._resubscribeTopics);t.push(...o),this.mqtt.removeAllListeners(),this.mqtt.end(!0),delete this.mqtt,this.mqtt=null}const n=Y_(e,r);return n.addListener("connect",this.__mqtt_connected_handler),n.addListener("reconnect",this.__mqtt_reconnect_handler),n.addListener("close",this.__mqtt_closed_handler),n.addListener("error",this.__mqtt_error_handler),n.addListener("message",this.__mqtt_message_handler),this.logger(`resubscribe to old topics ${t}`),t.forEach(o=>n.subscribe(o)),n});He(this,"_on_close_handler",V_(()=>ke(this,null,function*(){const e=this.enableLb===!0&&this.core.isLogin===!0&&this.shouldConnect===!0&&!this.willConnectToRealtime;if(this.logEnabled&&(console.group("@mqtt.closed"),console.log(`this.enableLb(${this.enableLb})`),console.log(`this.core.isLogin(${this.core.isLogin})`),console.log(`this.shouldConnect(${this.shouldConnect})`),console.log(`this.willConnectToRealtime(${this.willConnectToRealtime})`),console.log(`shouldReconnect(${e})`),console.groupEnd()),!e)return;this.willConnectToRealtime=!0;const[t,r]=yield K_(this.getMqttNode());r?(this.logger(`cannot get new brokerURL, using old url instead (${this.cacheRealtimeURL})`),this.mqtt=this.__mqtt_conneck(this.cacheRealtimeURL)):(this.cacheRealtimeURL=t,this.logger("trying to reconnect to",t),this.mqtt=this.__mqtt_conneck(t)),this.willConnectToRealtime=!1}),1e3));He(this,"subscribtionBuffer",[]);He(this,"unsubscribtionBuffer",[]);He(this,"publishBuffer",[]);this.emitter=Ot(),this.core=t,this.mqtt=null,this.brokerLbUrl=o,this.getClientId=a,this.enableLb=u,this.shouldConnect=n,this.matcher=hg({[Ze(this.reNewMessage)]:l=>this.newMessageHandler.bind(this,l),[Ze(this.reNotification)]:l=>this.notificationHandler.bind(this,l),[Ze(this.reTyping)]:l=>this.typingHandler.bind(this,l),[Ze(this.reRoomTyping)]:l=>this.roomTypingHandler.bind(this,l),[Ze(this.reDelivery)]:l=>this.deliveryReceiptHandler.bind(this,l),[Ze(this.reRead)]:l=>this.readReceiptHandler.bind(this,l),[Ze(this.reOnlineStatus)]:l=>this.onlinePresenceHandler.bind(this,l),[Ze(this.reChannelMessage)]:l=>this.channelMessageHandler.bind(this,l),[Ze(this.reMessageUpdated)]:l=>this.messageUpdatedHandler.bind(this,l),[Ze()]:l=>this.logger("topic not handled",l)});let s=this.__mqtt_conneck(e);this.mqtt=s,n||s.end(!0),this.willConnectToRealtime=!1,this.emitter.on("close",this._on_close_handler)}get cacheRealtimeURL(){return this.core.mqttURL}set cacheRealtimeURL(e){this.core.mqttURL=e}connect(){this.mqtt=this.__mqtt_conneck()}openConnection(){return ke(this,null,function*(){this.shouldConnect=!0,this.mqtt=this.__mqtt_conneck()})}closeConnection(){return ke(this,null,function*(){this.shouldConnect=!1,this.mqtt.end(!0,e=>{e&&this.logger("error when close connection",e.message)}),this.mqtt=null})}getMqttNode(){return ke(this,null,function*(){const e=yield st.get(this.brokerLbUrl),t=e.body.data.url,r=e.body.data.wss_port;return`wss://${t}:${r}/mqtt`})}get connected(){return this.mqtt==null?!1:this.mqtt.connected}subscribe(...e){for(this.subscribtionBuffer.push(e);this.mqtt!=null&&this.subscribtionBuffer.length>0;){const t=this.subscribtionBuffer.shift();t!=null&&(this.logger("subscribe topic",t),this.mqtt.subscribe(...t))}}unsubscribe(...e){for(this.unsubscribtionBuffer.push(e);this.mqtt!=null&&this.unsubscribtionBuffer.length>0;){const t=this.unsubscribtionBuffer.shift();t!=null&&(this.logger("unsubscribe topic",t),this.mqtt.unsubscribe(...t))}}publish(e,t,r={}){for(this.publishBuffer.push({topic:e,payload:t,options:r});this.mqtt!=null&&this.publishBuffer.length>0;){const n=this.publishBuffer.shift();n!=null&&(this.logger("publish to",n.topic,n.payload,n.options),this.mqtt.publish(n.topic,n.payload.toString(),n.options))}}emit(...e){this.emitter.emit(...e)}on(...e){this.emitter.on(...e)}off(...e){this.emitter.off(...e)}get logEnabled(){return this.core.debugMQTTMode}get logger(){return this.core.debugMQTTMode?console.log.bind(console,"QRealtime ->"):this.noop}get reNewMessage(){return/^(.+)\/c$/i}get reNotification(){return/^(.+)\/n$/i}get reTyping(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/t$/i}get reRoomTyping(){return/^r\/(.+)\/typing$/i}get reDelivery(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/d$/i}get reRead(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/r$/i}get reOnlineStatus(){return/^u\/(.+)\/s$/i}get reChannelMessage(){return/^(.+)\/(.+)\/c$/i}get reMessageUpdated(){return/^(.+)\/update$/i}noop(){}newMessageHandler(e,t){t=JSON.parse(t),this.logger("on:new-message",t),this.emit("new-message",t)}notificationHandler(e,t){this.logger("on:notification",t),t=JSON.parse(t);const r=t.payload.data;"deleted_messages"in r&&r.deleted_messages.forEach(n=>{this.emit("comment-deleted",{roomId:n.room_id,commentUniqueIds:n.message_unique_ids,isForEveryone:!0,isHard:!0})}),"deleted_rooms"in r&&r.deleted_rooms.forEach(n=>{this.emit("room-cleared",n)})}roomTypingHandler(e,t){var o;this.logger("on:room-typing",e);let r=(o=e.match(this.reRoomTyping))==null?void 0:o[1],n=JSON.parse(t);this.emit("room-typing",wr(br({},n),{room_id:r}))}typingHandler(e,t){this.logger("on:typing",e);const r=e.match(this.reTyping);if(r[3]===this.core.user_id)return;const n=r[3],o=r[1];if(this.emit("typing",{message:t,userId:n,roomId:o}),this.core.selected!=null)if(t==="1"&&o===this.core.selected.id){const u=this.core.selected.participants.find(s=>s.email===n);if(u==null)return;const a=u.username;this.core.isTypingStatus=`${a} is typing ...`}else this.core.isTypingStatus=null}deliveryReceiptHandler(e,t){this.logger("on:delivered",e,t);const r=e.match(this.reDelivery),n=t.split(":"),o=Number(n[0]),u=n[1],a=r[3];this.emit("message-delivered",{commentId:o,commentUniqueId:u,userId:a})}readReceiptHandler(e,t){this.logger("on:read",e,t);const r=e.match(this.reRead),n=t.split(":"),o=Number(n[0]),u=n[1],a=r[3];this.emit("message-read",{commentId:o,commentUniqueId:u,userId:a})}onlinePresenceHandler(e,t){this.logger("on:online-presence",e,t);const n=this.reOnlineStatus.exec(e)[1];this.emit("presence",{message:t,userId:n})}channelMessageHandler(e,t){this.logger("on:channel-message",e,t),this.emit("new-message",JSON.parse(t))}messageUpdatedHandler(e,t){t=JSON.parse(t),this.logger("on:message-updated",e,t),this.emit("message:updated",t)}subscribeChannel(e,t){this.subscribe(`${e}/${t}/c`)}subscribeRoom(e){this.core.selected!=null&&(e=e||this.core.selected.id,this.subscribe(`r/${e}/typing`),this.subscribe(`r/${e}/${e}/+/t`),this.subscribe(`r/${e}/${e}/+/d`),this.subscribe(`r/${e}/${e}/+/r`))}unsubscribeRoom(e){this.core.selected!=null&&(e=e||this.core.selected.id,this.unsubscribe(`r/${e}/typing`),this.unsubscribe(`r/${e}/${e}/+/t`),this.unsubscribe(`r/${e}/${e}/+/d`),this.unsubscribe(`r/${e}/${e}/+/r`))}get subscribeTyping(){return this.subscribeRoom.bind(this)}get unsubscribeTyping(){return this.unsubscribeRoom.bind(this)}subscribeUserChannel(){this.subscribe(`${this.core.userData.token}/c`),this.subscribe(`${this.core.userData.token}/n`),this.subscribe(`${this.core.userData.token}/update`)}subscribeUserChannelByToken(e){this.subscribe(`${e}/c`),this.subscribe(`${e}/n`),this.subscribe(`${e}/update`)}unsubscribeUserChannel(){this.unsubscribe(`${this.core.userData.token}/c`),this.unsubscribe(`${this.core.userData.token}/n`),this.unsubscribe(`${this.core.userData.token}/update`)}unsusbcribeUserChannelByToken(e){this.unsubscribe(`${e}/c`),this.unsubscribe(`${e}/n`),this.unsubscribe(`${e}/update`)}publishPresence(e,t=!0){t?this.publish(`u/${e}/s`,1,{retain:!0}):this.publish(`u/${e}/s`,0,{retain:!0})}disconnect(){this.publishPresence(this.core.userData.email,!1),this.unsubscribe(Object.keys(this.mqtt._resubscribeTopics))}subscribeUserPresence(e){this.subscribe(`u/${e}/s`)}unsubscribeUserPresence(e){this.unsubscribe(`u/${e}/s`)}get subscribeRoomPresence(){return this.subscribeUserPresence.bind(this)}get unsubscribeRoomPresence(){return this.unsubscribeUserPresence.bind(this)}publishTyping(e){if(this.core.selected==null)return;const t=this.core.selected.id,r=this.core.user_id;this.publish(`r/${t}/${t}/${r}/t`,e)}}function J_(i,e){const t=Ot(),r={},n=/^r\/[\w]+\/[\w]+\/e$/i;i.mqtt.on("message",(u,a)=>{n.test(u)&&t.emit(u,a)});const o=u=>`r/${u}/${u}/e`;return{publishEvent(u,a){if(Ye.undefined(u))throw new Error("`roomId` required");if(Ye.not.string(u))throw new TypeError("`roomId` must have type of string");if(Ye.undefined(a))throw new Error("`payload` required");if(Ye.not.object(a))throw new TypeError("`payload` must have type of object");const s=JSON.stringify({sender:e,data:a});i.publish(o(u),s)},subscribeEvent(u,a){if(Ye.undefined(u))throw new Error("`roomId` required");if(Ye.not.string(u))throw new TypeError("`roomId` must have type of string");if(Ye.undefined(a))throw new Error("`callback` required");if(Ye.not.function(a))throw new TypeError("`callback` must have type of function");const s=o(u);if(r[s])return;i.subscribe(s);const l=d=>{const _=JSON.parse(d);a(_)};t.on(s,l),r[s]=l},unsubscribeEvent(u){if(Ye.undefined(u))throw new Error("`roomId` required");if(Ye.not.string(u))throw new TypeError("`roomId` must have type of string");const a=o(u);r[a]&&(i.unsubscribe(a),t.off(a,r[a]),r[a]=null,delete r[a])}}}const $p=()=>{},Hp=i=>new Promise(e=>setTimeout(e,i));function X_(i,e,t,r,n){const o=Ot(),u=l=>{const d=nr("api/v2/sdk/sync").param("last_received_comment_id",l).build();return i().get(d).then(_=>{const g=_.body.results,E=g.comments,w=g.meta.last_received_comment_id;return E.sort((q,k)=>q.id-k.id),Promise.resolve({lastMessageId:w,messages:E,interval:e()})}).catch($p)};function a(){return tu(this,null,function*(){let l=0;const d=100,_=()=>i()!=null&&t();for(;;)l+=d,l>=e()&&_()&&(l=0,yield u(r())),yield new Sr(Hp(d))})}return{get synchronize(){return u},get on(){return o.on},get off(){return o.off},run(){return ke(this,null,function*(){try{for(var l=ru(a()),d,_,g;d=!(_=yield l.next()).done;d=!1){let E=_.value;try{if(o.emit("synchronize",Date.now()),(E==null?void 0:E.lastMessageId)!=null&&(E==null?void 0:E.messages)!=null){const w=E.lastMessageId,q=E.messages;w>r()&&(q.forEach(k=>o.emit("message.new",k)),o.emit("last-message-id.new",w))}}catch(w){n("error when sync",w.message),console.log("error when sync",w)}}}catch(_){g=[_]}finally{try{d&&(_=l.return)&&(yield _.call(l))}finally{if(g)throw g[0]}}})}}}function Z_(i,e,t,r,n){const o=Ot(),u=l=>{const d=nr("api/v2/sdk/sync_event").param("start_event_id",l).build();return i().get(d).then(_=>{const g=_.body.events,E=g.map(R=>R.id).sort((R,S)=>R-S).pop(),w=g.filter(R=>R.action_topic==="delivered").map(R=>R.payload.data),q=g.filter(R=>R.action_topic==="read").map(R=>R.payload.data),k=g.filter(R=>R.action_topic==="delete_message").map(R=>R.payload.data),A=g.filter(R=>R.action_topic==="clear_room").map(R=>R.payload.data);return Promise.resolve({lastId:E,messageDelivered:w,messageRead:q,messageDeleted:k,roomCleared:A,interval:e()})}).catch($p)};function a(){return tu(this,null,function*(){let l=0;const d=100,_=()=>i()!=null&&t();for(;;)l+=d,l>=e()&&_()&&(l=0,yield u(r())),yield new Sr(Hp(d))})}return{get synchronize(){return u},get on(){return o.on},get off(){return o.off},run(){return ke(this,null,function*(){try{for(var l=ru(a()),d,_,g;d=!(_=yield l.next()).done;d=!1){let E=_.value;try{const w=E.lastId;w>r()&&(o.emit("last-event-id.new",w),E.messageDelivered.forEach(q=>o.emit("message.delivered",q)),E.messageDeleted.forEach(q=>o.emit("message.deleted",q)),E.messageRead.forEach(q=>o.emit("message.read",q)),E.roomCleared.forEach(q=>o.emit("room.cleared",q)))}catch(w){n("error when sync event",w.message)}}}catch(_){g=[_]}finally{try{d&&(_=l.return)&&(yield _.call(l))}finally{if(g)throw g[0]}}})}}}function ev(i,{isDebug:e=!1,syncInterval:t,getShouldSync:r,syncOnConnect:n,lastCommentId:o,statusLogin:u,enableSync:a,enableSyncEvent:s}){const l=Ot(),d=(...R)=>e?console.log("QSync:",...R):{};let _=0;const g=()=>u()?r()?t():n():0,w=X_(i,g,()=>r()&&a(),o,d);w.on("last-message-id.new",R=>R),w.on("message.new",R=>l.emit("message.new",R)),w.on("synchronize",R=>l.emit("synchronize",R)),w.run().catch(R=>d("got error when sync",R));const k=Z_(i,g,()=>r()&&s(),()=>_,d);return k.on("last-event-id.new",R=>{_=R}),k.on("message.read",R=>{l.emit("message.read",R)}),k.on("message.delivered",R=>l.emit("message.delivered",R)),k.on("message.deleted",R=>l.emit("message.deleted",R)),k.on("room.cleared",R=>l.emit("room.cleared",R)),k.run().catch(R=>d("got error when sync event",R)),{get on(){return l.on},get off(){return l.off},get interval(){return g()},get enabled(){return a()},synchronize(){return ke(this,null,function*(){var p,v;let R=o(),S=yield w.synchronize(R),b=(p=S==null?void 0:S.messages)!=null?p:[],h=(v=S==null?void 0:S.lastMessageId)!=null?v:-1;for(let I of b)l.emit("message.new",I);h>0&&l.emit("last-message-id.new",h)})},synchronizeEvent(){return ke(this,null,function*(){let R=yield k.synchronize(_);try{const S=R.lastId;S>getId()&&(l.emit("last-event-id.new",S),R.messageDelivered.forEach(b=>l.emit("message.delivered",b)),R.messageDeleted.forEach(b=>l.emit("message.deleted",b)),R.messageRead.forEach(b=>l.emit("message.read",b)),R.roomCleared.forEach(b=>l.emit("room.cleared",b)))}catch(S){d("error when sync event",S.message)}})}}}const tv={version:"2.16.2"},dt={MESSAGE_BEFORE_SENT:"message::before-sent",MESSAGE_BEFORE_RECEIVED:"message::before-received"};function rv(){const i={},e=n=>(Array.isArray(i[n])||(i[n]=[]),i[n]);function t(n,o){e(n).push(o);const u=e(n).length;return()=>e(n).splice(u,1)}function r(n,o){return e(n).reduce((u,a)=>Promise.resolve(u).then(a),Promise.resolve(o))}return{trigger:r,intercept:t}}class nv{constructor({httpAdapter:e,refreshToken:t,expiredAt:r,userId:n,onTokenRefreshed:o,getAuthenticationStatus:u}){He(this,"_isExpiredTokenEnabled",!1);He(this,"_refreshToken",null);He(this,"_expiredAt",null);He(this,"_http");He(this,"_onTokenRefreshed");He(this,"_timerId");He(this,"_getAuthenticationStatus");this._http=e,this._refreshToken=t,this._userId=n,this._onTokenRefreshed=o,this._getAuthenticationStatus=u,this._refreshToken!=null&&this._refreshToken===""&&(this._refreshToken=null),r!=null&&r!==""&&(this._expiredAt=new Date(r)),this._isExpiredTokenEnabled=this._refreshToken!=null&&this._expiredAt!=null,this._setTimer(this._expiredAt)}_setTimer(e){var r;this._timerId!=null&&(clearTimeout(this._timerId),this._timerId=null);const t=Math.floor(((r=e==null?void 0:e.getTime())!=null?r:NaN)-Date.now());!isNaN(t)&&t>0&&(this._timerId=setTimeout(()=>{this.refreshAuthToken()},t))}refreshAuthToken(){return ke(this,null,function*(){if(!(this._getAuthenticationStatus()==!1||this._refreshToken==null))return this._http.post("api/v2/sdk/refresh_user_token",{user_id:this._userId,refresh_token:this._refreshToken}).then(e=>{var n;let t=e.body.results,r=t.token;return this._refreshToken=t.refresh_token,(n=this._onTokenRefreshed)==null||n.call(this,r,this._refreshToken,this._expiredAt,this._http.token),this._http.setToken(t.token),t.token_expires_at!=null&&(this._expiredAt=new Date(t.token_expires_at)),this._setTimer(this._expiredAt),t})})}logout(){return ke(this,null,function*(){return this._http.post("api/v2/sdk/logout",{user_id:this._userId,token:this._http.token})})}}let Wp;const iv=Object.freeze({disabled:"UpdateCommentStatusMode.disabled",throttled:"UpdateCommentStatusMode.throttled",enabled:"UpdateCommentStatusMode.enabled"}),vt=class vt{constructor(){He(this,"_pendingComments",[]);He(this,"_pendingCommentsCount",{});He(this,"_readComment",(e,t)=>this._updateStatus(e,t));He(this,"_readCommentT",this._throttle((e,t)=>{this._updateStatus(e,t)},()=>this._throttleDelay));He(this,"_deliverComment",(e,t)=>this._updateStatus(e,void 0,t));He(this,"_deliverCommentT",this._throttle((e,t)=>{this._updateStatus(e,void 0,t)},()=>this._throttleDelay));this.events=Ot(),this.rooms=[],this.selected=null,this.room_name_id_map={},this.pendingCommentId=0,this.uploadedFiles=[],this.chatmateStatus=null,this.version=`WEB_${tv.version}`,this.userData={},this.AppId=null,this.baseURL="https://api.qiscus.com",this.mqttURL="wss://realtime-jogja.qiscus.com:1886/mqtt",this.brokerLbUrl="https://realtime-lb.qiscus.com",this.syncOnConnect=1e4,this.enableEventReport=!1,this.enableRealtime=!0,this.enableRealtimeCheck=!0,this.enableSync=!0,this.enableSyncEvent=!1,this.HTTPAdapter=null,this.expiredTokenAdapter=null,this.realtimeAdapter=null,this.customEventAdapter=null,this.isInit=!1,this.isSynced=!1,this.syncInterval=5e3,this.sync="socket",this.enableLb=!0,this.httpsync=null,this.eventsync=null,this.extras=null,this.last_received_comment_id=0,this.googleMapKey="",this.options={avatar:!0},this.isConfigLoaded=!1,this.updateCommentStatusMode=vt.UpdateCommentStatusMode.enabled,this.updateCommentStatusThrottleDelay=300,this.UI={},this.mode="widget",this.avatar=!0,this.plugins=[],this.isLogin=!1,this.isLoading=!1,this.isInit=!1,this.emoji=!1,this.isTypingStatus="",this.customTemplate=!1,this.templateFunction=null,this.debugMode=!1,this.debugMQTTMode=!1,this._customHeader={},this._forceEnableSync=!0,this.lastReceiveMessages=[],this._hookAdapter=rv(),this._uploadURL=null,this._autoRefreshToken=!1}get uploadURL(){return this._uploadURL||`${this.baseURL}/api/v2/sdk/upload`}set uploadURL(e){this._uploadURL=e}init(e){return ke(this,null,function*(){var a;if(!e.AppId)throw new Error("Please provide valid AppId");this.AppId=e.AppId;const t=e.baseURL!=null&&this.baseURL!==e.baseURL,r=e.mqttURL!=null&&this.mqttURL!==e.mqttURL,n=e.brokerLbURL!=null&&this.brokerLbUrl!==e.brokerLbURL;(t||r)&&!n?(this.logger("force disable load balancing for realtime server, because `baseURL` or `mqttURL` get changed but did not provide `brokerLbURL`"),this.enableLb=!1):e.enableRealtimeLB!=null&&(this.enableLb=e.enableRealtimeLB),e.updateCommentStatusMode!=null&&(this.updateCommentStatusMode=e.updateCommentStatusMode),e.updateCommentStatusThrottleDelay!=null&&(this.updateCommentStatusThrottleDelay=e.updateCommentStatusThrottleDelay),e.baseURL&&(this.baseURL=e.baseURL),e.mqttURL&&(this.mqttURL=e.brokerUrl||e.mqttURL),e.mqttURL&&(this.brokerUrl=e.brokerUrl||e.mqttURL),e.brokerLbURL&&(this.brokerLbUrl=e.brokerLbURL),e.uploadURL&&(this.uploadURL=e.uploadURL),e.sync&&(this.sync=e.sync),e.mode&&(this.mode=e.mode),e.syncInterval&&(this.syncInterval=e.syncInterval||5e3),e.googleMapKey&&(this.googleMapKey=e.googleMapKey),e.allowedFileTypes&&(this.allowedFileTypes=e.allowedFileTypes),e.options&&(this.options=Object.assign({},this.options,e.options)),e.customTemplate&&(this.customTemplate=e.customTemplate),e.templateFunction&&(this.templateFunction=e.templateFunction),e.syncInterval!=null&&(this.syncInterval=e.syncInterval),this.HTTPAdapter=new Do({baseURL:this.baseURL,AppId:this.AppId,userId:this.user_id,version:this.version,getCustomHeader:()=>this._customHeader});const o=(s,l,d)=>l===""&&s!=null&&(typeof s!="string"||s.length>0)?s:l!=null&&(l.length>0||typeof l!="string")?l:d,u=s=>s.includes("wss://")?s:`wss://${s}:1886/mqtt`;this.withConfig=(a=e.withConfig)!=null?a:!0,this.withConfig===!0?yield this.HTTPAdapter.get_request("api/v2/sdk/config").then(s=>(s.status==200?this.isConfigLoaded=!0:this.isConfigLoaded=!1,s.body.results)).then(s=>{const l=this.baseURL,d=this.brokerLbUrl,_=this.mqttURL,g=this.enableRealtime,E=this.enableRealtimeCheck,w=this.syncInterval,q=this.syncOnConnect,k=this.enableEventReport,A={};this.baseURL=o(e.baseURL,s.base_url,l),this.brokerLbUrl=o(e.brokerLbURL,s.broker_lb_url,d),this.mqttURL=u(o(e.mqttURL,s.broker_url,_)),this.enableRealtime=o(e.enableRealtime,s.enable_realtime,g),this.syncInterval=o(e.syncInterval,s.sync_interval,w),this.syncOnConnect=o(e.syncOnConnect,s.sync_on_connect,q),this.enableRealtimeCheck=o(null,s.enable_realtime_check,E),this.enableEventReport=o(null,s.enable_event_report,k),this.extras=o(null,s.extras,A),this.enableSync=o(null,s.enable_sync,this.enableSync),this.enableSyncEvent=o(null,s.enable_sync_event,this.enableSyncEvent),this._autoRefreshToken=o(null,s.auto_refresh_token,!1)}).catch(s=>{this.logger("got error when trying to get app config",s),this.isConfigLoaded=!0}):this.isConfigLoaded=!0,this._getMqttClientId=()=>`${this.AppId}_${this.user_id}_${Date.now()}`,this.realtimeAdapter=new Q_(this.mqttURL,this,this.isLogin,{brokerLbUrl:this.brokerLbUrl,enableLb:this.enableLb,shouldConnect:this.enableRealtime,getClientId:this._getMqttClientId}),this.realtimeAdapter.on("connected",()=>{(this.isLogin||!this.realtimeAdapter.connected)&&(this.last_received_comment_id=this.userData.last_comment_id,this.updateLastReceivedComment(this.last_received_comment_id))}),this.realtimeAdapter.on("close",()=>{}),this.realtimeAdapter.on("reconnect",()=>{var s,l;(l=(s=this.options).onReconnectCallback)==null||l.call(s)}),this.realtimeAdapter.on("message-delivered",({commentId:s,commentUniqueId:l,userId:d})=>this._setDelivered(s,l,d)),this.realtimeAdapter.on("message-read",({commentId:s,commentUniqueId:l,userId:d})=>this._setRead(s,l,d)),this.realtimeAdapter.on("new-message",s=>ke(this,null,function*(){s=yield this._hookAdapter.trigger(dt.MESSAGE_BEFORE_RECEIVED,s),this.events.emit("newmessages",[s])})),this.realtimeAdapter.on("presence",s=>this.events.emit("presence",s)),this.realtimeAdapter.on("comment-deleted",s=>this.events.emit("comment-deleted",s)),this.realtimeAdapter.on("room-cleared",s=>this.events.emit("room-cleared",s)),this.realtimeAdapter.on("typing",s=>this.events.emit("typing",{message:s.message,username:s.userId,room_id:s.roomId})),this.realtimeAdapter.on("message:updated",s=>{this.options.messageUpdatedCallback!=null&&this.options.messageUpdatedCallback(s)}),this.realtimeAdapter.on("room-typing",s=>{this.events.emit("typing",{message:s.text,username:s.sender_name,email:s.sender_id,room_id:s.room_id}),this.options.onRoomTypingCallback!=null&&(this.events.emit("room-typing",s),this.options.onRoomTypingCallback(s))}),this.syncAdapter=ev(()=>this.HTTPAdapter,{syncInterval:()=>this.syncInterval,getShouldSync:()=>this._forceEnableSync&&this.isLogin&&!this.realtimeAdapter.connected,syncOnConnect:()=>this.syncOnConnect,lastCommentId:()=>this.last_received_comment_id,statusLogin:()=>this.isLogin,enableSync:()=>this.enableSync,enableSyncEvent:()=>this.enableSyncEvent}),this.syncAdapter.on("message.new",s=>ke(this,null,function*(){if(s=yield this._hookAdapter.trigger(dt.MESSAGE_BEFORE_RECEIVED,s),this.selected!=null){if(this.selected.comments.findIndex(d=>d.id===s.id||d.unique_id===s.unique_temp_id)===-1){const d=new pt(s);d.room_id===this.selected.id&&(this.selected.comments.push(d),this.sortComments()),this.events.emit("newmessages",[s])}}else this.events.emit("newmessages",[s])})),this.syncAdapter.on("message.delivered",s=>{this._setDelivered(s.comment_id,s.comment_unique_id,s.email)}),this.syncAdapter.on("message.read",s=>{this._setRead(s.comment_id,s.comment_unique_id,s.email)}),this.syncAdapter.on("message.deleted",s=>{s.deleted_messages.forEach(l=>{this.events.emit("comment-deleted",{roomId:l.room_id,commentUniqueIds:l.message_unique_ids,isForEveryone:!0,isHard:!0})})}),this.syncAdapter.on("room.cleared",s=>{s.deleted_rooms.forEach(l=>{this.events.emit("room-cleared",l)})}),this.syncAdapter.on("synchronize",()=>{this._pendingComments.forEach(s=>this._retrySendComment(s))}),this.syncAdapter.on("last-message-id.new",s=>{this.last_received_comment_id=s}),this.customEventAdapter=J_(this.realtimeAdapter,this.user_id),this.setEventListeners()})}_setRead(e,t,r){if(this.selected==null)return;const n=this.selected,o=n.comments.find(a=>a.id===e||a.unique_id===t);if(o==null||o.status==="read")return;const u={participants:n.participants,actor:r,comment_id:e,activeActorId:this.user_id};n.comments.forEach(a=>{a.id<=o.id&&a.markAsRead(u)}),o.isRead&&this.events.emit("comment-read",{comment:o,userId:r})}_setDelivered(e,t,r){if(this.selected==null)return;const n=this.selected,o=n.comments.find(a=>a.id===e||a.unique_id===t);if(o==null||o.status==="read")return;const u={participants:n.participants,actor:r,comment_id:e,activeActorId:this.user_id};n.comments.forEach(a=>{a.id<=o.id&&a.markAsDelivered(u)}),o.isDelivered&&this.events.emit("comment-delivered",{comment:o,userId:r})}setEventListeners(){const e=this;this.authAdapter=new tg(e.HTTPAdapter),this.userData.email!=null&&(this.authAdapter.userId=this.userData.email),e.events.on("start-init",()=>{e.HTTPAdapter=new Do({baseURL:e.baseURL,AppId:e.AppId,userId:e.user_id,version:e.version,getCustomHeader:()=>this._customHeader}),e.HTTPAdapter.setToken(e.userData.token)}),e.events.on("room-changed",t=>{this.logging("room changed",t),e.options.roomChangedCallback&&e.options.roomChangedCallback(t)}),e.events.on("file-uploaded",t=>{e.options.fileUploadedCallback&&e.options.fileUploadedCallback(t)}),e.events.on("profile-updated",t=>{e.username=t.name,e.avatar_url=t.avatar_url,e.options.updateProfileCallback&&e.options.updateProfileCallback(t)}),e.events.on("newmessages",t=>{if(this.logging("newmessages",t),this.lastReceiveMessages.length>0&&this.lastReceiveMessages[0].unique_temp_id===t[0].unique_temp_id){this.logging("lastReceiveMessages double",t);return}this.lastReceiveMessages=t,e._callNewMessagesCallback(t),t.forEach(n=>{e.receiveComment(n.room_id,n.id);const o=e.selected?n.room_id===e.selected.id:!1,u=n.id<=e.last_received_comment_id;if(o){const a=e.selected,s=e.selected.comments[e.selected.comments.length-1];!s.isPending&&!u&&e.user_id!==n.email&&e.readComment(n.room_id,n.id);const l=s.id,d=e.selected.comments.find(g=>g.id===s.comment_before_id);!s.isPending&&!d&&(this.logging("comment before id not found! ",n.comment_before_id),e.synchronize(l));const _=new pt(n);a.receiveComment(_),a.last_comment_id=_.id,a.last_comment_message=_.message}e.updateLastReceivedComment(n.id),this.sortComments()})}),this.events.on("login-success",t=>{this.isLogin=!0,this.userData=t.user,this.last_received_comment_id=this.userData.last_comment_id,this.realtimeAdapter.connected||this.updateLastReceivedComment(this.last_received_comment_id),this.HTTPAdapter=new Do({baseURL:this.baseURL,AppId:this.AppId,userId:this.user_id,version:this.version,getCustomHeader:()=>this._customHeader,expiredTokenAdapterGetter:()=>this.expiredTokenAdapter}),this.HTTPAdapter.setToken(this.userData.token);let r=t.user;this._delayedSync=eg(()=>{this.synchronize(),this.synchronizeEvent()},500),this.expiredTokenAdapter=new nv({httpAdapter:this.HTTPAdapter,refreshToken:r.refresh_token,expiredAt:r.token_expires_at,userId:this.user_id,onTokenRefreshed:(n,o,u,a)=>{this.userData.token=n,this.userData.refresh_token=o,this.userData.token_expires_at=u==null?void 0:u.toJSON(),this.events.emit("token-refreshed",{token:n,refreshToken:o,expiredAt:u,oldToken:a}),this.realtimeAdapter.unsusbcribeUserChannelByToken(a),this.realtimeAdapter.subscribeUserChannelByToken(n),this._delayedSync()},getAuthenticationStatus:()=>this.user_id!=null&&this.isLogin}),this.userAdapter=new og(this.HTTPAdapter),this.roomAdapter=new sg(this.HTTPAdapter),this.realtimeAdapter.subscribeUserChannel(),this.presensePublisherId!=null&&this.presensePublisherId!==-1&&clearInterval(this.presensePublisherId),this.presensePublisherId=setInterval(()=>{this.realtimeAdapter.publishPresence(this.user_id,!0)},3500),this.options.loginSuccessCallback&&this.options.loginSuccessCallback(t),this.authAdapter.userId=this.userData.email,this.authAdapter.refreshToken=this.userData.refresh_token,this.authAdapter.autoRefreshToken=this._autoRefreshToken}),e.events.on("login-error",function(t){e.options.loginErrorCallback&&e.options.loginErrorCallback(t)}),e.events.on("token-refreshed",t=>{var r,n;(n=(r=this.options).authTokenRefreshedCallback)==null||n.call(r,t)}),e.events.on("room-cleared",function(t){if(e.selected){const r=e.selected;e.selected.unique_id===t.unique_id&&(e.selected=null,e.selected=r)}e.options.roomClearedCallback&&e.options.roomClearedCallback(t)}),e.events.on("comment-deleted",function(t){const{roomId:r,commentUniqueIds:n,isForEveryone:o,isHard:u}=t;e.selected&&e.selected.id==r&&n.map(a=>{const s=e.selected.comments.findIndex(d=>d.unique_id===a);s>-1&&(u?e.selected.comments.splice(s,1):e.selected.comments[s].message="this message has been deleted");const l=e.selected.comments[e.selected.comments.length-1];e.selected.last_comment_id=l.id,e.selected.last_comment_message=l.message}),e.options.commentDeletedCallback&&e.options.commentDeletedCallback(t)}),e.events.on("comment-delivered",function(t){if(e.logging("comment-delivered",t),!t)return!1;if(e.options.commentDeliveredCallback)return e.options.commentDeliveredCallback(t)}),e.events.on("chat-room-created",function(t){e.isLoading=!1,e.options.chatRoomCreatedCallback&&e.options.chatRoomCreatedCallback(t)}),e.events.on("group-room-created",function(t){e.isLoading=!1,e.options.groupRoomCreatedCallback&&e.options.groupRoomCreatedCallback(t)}),e.events.on("header-clicked",function(t){e.options.headerClickedCallback&&e.options.headerClickedCallback(t)}),e.events.on("comment-read",function(t){e.logging("comment-read",t),e.options.commentReadCallback&&e.options.commentReadCallback(t)}),e.events.on("presence",({message:t,userId:r})=>{const n=t.split(":");this.chatmateStatus!==n[0]&&(this.chatmateStatus=n[0]===1?"Online":`Last seen ${fm(Number(n[1].substring(0,13)))}`),e.options.presenceCallback&&e.options.presenceCallback(t,r)}),e.events.on("typing",function(t){e.options.typingCallback&&e.options.typingCallback(t)}),e.events.on("message-info",function(t){e.options.messageInfoCallback&&e.options.messageInfoCallback(t)}),e.events.on("participants-added",t=>{t==null||this.selected==null||this.selected.participants.push(...t)}),e.events.on("participants-removed",t=>{if(t==null||this.selected==null)return;const r=this.selected.participants.filter(n=>t.indexOf(n.email)<=-1);this.selected.participants=r}),e.events.on("block-user",function(t){e.options.blockUserCallback&&e.options.blockUserCallback(t)}),e.events.on("unblock-user",function(t){e.options.unblockUserCallback&&e.options.unblockUserCallback(t)})}onReconnectMqtt(){this.options.onReconnectCallback&&this.options.onReconnectedCallback(),this.selected&&this.loadComments(this.selected.id)}_callNewMessagesCallback(e){this.options.newMessagesCallback&&this.options.newMessagesCallback(e)}updateLastReceivedComment(e){this.last_received_comment_id<e&&(this.last_received_comment_id=e)}setUser(e,t,r,n,o){const u=this;u.user_id=e,u.key=t,u.username=r,u.avatar_url=n;let a={email:this.user_id,password:this.key,username:this.username,extras:o?JSON.stringify(o):null};return this.avatar_url&&(a.avatar_url=this.avatar_url),new Promise((s,l)=>{let d=setInterval(()=>{if(!this.isConfigLoaded)this.debugMode&&this.logger("Waiting for init config...");else return clearInterval(d),this.logger("Config Success!"),u.events.emit("start-init"),u.authAdapter.loginOrRegister(a).then(g=>{u.isInit=!0,u.refresh_token=g.user.refresh_token,u.events.emit("login-success",g),this.realtimeAdapter.connect(),s(g)},g=>{u.events.emit("login-error",g),l(g)})},300)})}setUserWithIdentityToken(e){if(!e||!("user"in e))return this.events.emit("login-error",e);this.email=e.user.email,this.user_id=e.user.email,this.key=e.identity_token,this.username=e.user.username,this.avatar_url=e.user.avatar_url,this.isInit=!0;let t=setInterval(()=>{this.isConfigLoaded?(clearInterval(t),this.logger("Config Success!"),this.events.emit("login-success",e)):this.debugMode&&this.logger("Waiting for init config...")},300)}refreshAuthToken(){return this.expiredTokenAdapter.refreshAuthToken()}publishOnlinePresence(e){e===!0?Wp=setInterval(()=>{this.realtimeAdapter.publishPresence(this.user_id,!0)},3500):(clearInterval(this.presensePublisherId),clearInterval(Wp),setTimeout(()=>{this.realtimeAdapter.publishPresence(this.user_id,!1)},3500))}subscribeUserPresence(e){this.realtimeAdapter.subscribeUserPresence(e)}unsubscribeUserPresence(e){this.realtimeAdapter.unsubscribeUserPresence(e)}logout(){return ke(this,null,function*(){yield this.expiredTokenAdapter.logout(),clearInterval(this.presensePublisherId),this.publishOnlinePresence(!1),this.selected=null,this.isInit=!1,this.isLogin=!1,this.realtimeAdapter.disconnect(),this.userData={}})}get synchronize(){return this.syncAdapter.synchronize}get synchronizeEvent(){return this.syncAdapter.synchronizeEvent}disconnect(){this.logout()}setActiveRoom(e){if(this.selected&&(this.realtimeAdapter.unsubscribeTyping(),this.selected.room_type==="single")){const n=this.selected.participants.filter(o=>o.email!==this.user_id);n.length>0&&this.realtimeAdapter.unsubscribeRoomPresence(n[0].email)}e.participants==null&&(e.participants=[]);const t=e.participants.find(n=>n.email!==this.user_id);this.chatmateStatus=null,this.isTypingStatus=null,this.selected=e;const r=setInterval(()=>{this.debugMode&&this.logger("Trying Initial Subscribe"),this.realtimeAdapter!=null?(this.debugMode&&this.logger("MQTT Connected"),clearInterval(r),e.room_type==="single"&&t!=null&&this.realtimeAdapter.subscribeRoomPresence(t.email),this.selected!=null&&!this.selected.isChannel&&(this.realtimeAdapter.subscribeTyping(e.id),this.events.emit("room-changed",this.selected)),this.debugMode&&this.realtimeAdapter==null&&this.logger("Retry")):this.debugMode&&this.logger("MQTT Not Connected, yet")},3e3)}chatTarget(e,t={}){if(this.userData.length!=null)return!1;const r=t?t.message:null,n=t.distinctId;return this.isLoading=!0,this.isTypingStatus="",this.roomAdapter.getOrCreateRoom(e,t,n).then(o=>ke(this,null,function*(){const u=new rr(o);this.updateLastReceivedComment(u.last_comment_id),this.isLoading=!1;const a=d=>ke(this,null,function*(){return yield this._hookAdapter.trigger(dt.MESSAGE_BEFORE_RECEIVED,d)});u.comments=yield Promise.all(u.comments.map(d=>a(d))),this.setActiveRoom(u);const s=u.comments[u.comments.length-1];if(s&&this.readComment(u.id,s.id),this.events.emit("chat-room-created",{room:u}),!r)return u;const l=u.id;return this.sendComment(l,r).then(()=>Promise.resolve(u)).catch(d=>{console.error("Error when submit comment",d)})})).catch(o=>(console.error("Error when creating room",o),this.isLoading=!1,Promise.reject(o)))}chatGroup(e){const t=this;if(t.isInit)return t.getRoomById(e).then(r=>Promise.resolve(r),r=>Promise.reject(r))}getRoomById(e){if(!this.isInit)return;const t=this;return t.isLoading=!0,t.isTypingStatus="",t.roomAdapter.getRoomById(e).then(r=>ke(this,null,function*(){const n=r.results.room,o=[];for(const s of r.results.comments.reverse()){const l=yield this._hookAdapter.trigger(dt.MESSAGE_BEFORE_RECEIVED,s);o.push(l)}const u=new rr(wr(br({},n),{comments:o,name:n.room_name}));t.updateLastReceivedComment(u.last_comment_id),t.setActiveRoom(u),t.isLoading=!1;const a=u.comments[u.comments.length-1];return a&&t.readComment(u.id,a.id),u.isChannel&&this.realtimeAdapter.subscribeChannel(this.AppId,u.unique_id),u})).catch(r=>(console.error("Error getting room by id",r),Promise.reject(r)))}getOrCreateRoomByUniqueId(e,t,r){const n=this;return n.isLoading=!0,n.isTypingStatus="",n.roomAdapter.getOrCreateRoomByUniqueId(e,t,r).then(o=>ke(this,null,function*(){let u=new rr(o);n.updateLastReceivedComment(u.last_comment_id);const a=l=>ke(this,null,function*(){return yield this._hookAdapter.trigger(dt.MESSAGE_BEFORE_RECEIVED,l)});u.comments=yield Promise.all(u.comments.map(l=>a(l))),n.setActiveRoom(u),n.isLoading=!1;const s=u.comments[u.comments.length-1];return s&&n.readComment(u.id,s.id),this.realtimeAdapter.subscribeChannel(this.AppId,u.unique_id),Promise.resolve(u)})).catch(o=>Promise.reject(o))}getOrCreateRoomByChannel(e,t,r){return this.getOrCreateRoomByUniqueId(e,t,r)}sortComments(){this.selected&&this.selected.comments.sort(function(e,t){return e.unix_timestamp-t.unix_timestamp})}loadRoomList(){return ke(this,arguments,function*(e={}){return(yield this.userAdapter.loadRoomList(e)).map(r=>(r.last_comment_id=r.last_comment.id,r.last_comment_message=r.last_comment.message,r.last_comment_message_created_at=r.last_comment.timestamp,r.room_type=r.chat_type,r.comments=[],new rr(r)))})}loadComments(e,t={}){return this.userAdapter.loadComments(e,t).then(r=>ke(this,null,function*(){const n=[];for(const o of r)n.push(yield this._hookAdapter.trigger(dt.MESSAGE_BEFORE_RECEIVED,o));return this.selected!=null&&(this.selected.receiveComments(n.reverse()),this.sortComments()),n}))}loadMore(e,t={}){if(this.selected!=null)return t.last_comment_id=e,t.after=!1,this.loadComments(this.selected.id,t)}registerDeviceToken(e,t=!1){return ke(this,null,function*(){return(yield this.HTTPAdapter.post("api/v2/sdk/set_user_device_token",{device_token:e,device_platform:"rn",is_development:t})).body.results})}removeDeviceToken(e,t=!1){return ke(this,null,function*(){return(yield this.HTTPAdapter.post("api/v2/sdk/remove_user_device_token",{device_token:e,device_platform:"rn",is_development:t})).body.results})}searchMessages(){return ke(this,arguments,function*(e={}){return console.warn("Deprecated: search message will be removed on next release"),(yield this.userAdapter.searchMessages(e)).map(r=>new pt(r))})}updateProfile(e){return this.userAdapter.updateProfile(e).then(t=>(this.events.emit("profile-updated",e),this.userData=t,Promise.resolve(t)),t=>this.logger(t))}getNonce(){return st.post(`${this.baseURL}/api/v2/sdk/auth/nonce`).send().set("qiscus_sdk_app_id",`${this.AppId}`).set("qiscus_sdk_version",`${this.version}`).then(e=>Promise.resolve(e.body.results),e=>Promise.reject(e))}verifyIdentityToken(e){return st.post(`${this.baseURL}/api/v2/sdk/auth/verify_identity_token`).send({identity_token:e}).set("qiscus_sdk_app_id",`${this.AppId}`).set("qiscus_sdk_version",`${this.version}`).then(t=>Promise.resolve(t.body.results),t=>Promise.reject(t))}sendComment(e,t,r,n="text",o,u){return ke(this,null,function*(){var q,k,A,R;const a=this;a.options.prePostCommentCallback&&a.options.prePostCommentCallback(t),a.options.commentFormaterCallback&&(t=a.options.commentFormaterCallback(t)),a.pendingCommentId--;const s={room_id:e,message:t,username_as:this.username,username_real:this.user_id,user_avatar_url:this.userData.avatar_url,user_extras:this.userData.user_extras,id:Math.round(Date.now()*1e6+Date.now()),type:n||"text",timestamp:am(new Date),unique_id:r?String(r):null,payload:jp(()=>JSON.parse(o),o,S=>this.logger("Error when parsing payload",S.message))},l=a.prepareCommentToBeSubmitted(s);if(n==="reply"){var d=JSON.parse(o),_=a.selected.comments.find(S=>S.id===d.replied_comment_id);d.replied_comment_message=_.type==="reply"?_.payload.text:_.message,d.replied_comment_sender_username=_.username_as,l.payload=d}const g=u||a.extras;let E=yield this._hookAdapter.trigger(dt.MESSAGE_BEFORE_SENT,wr(br({},l),{extras:g}));E=a.prepareCommentToBeSubmitted(E),a.selected&&a.selected.comments.push(E);const w=()=>this.userAdapter.postComment(""+e,E.message,E.unique_id,E.type,E.payload,E.extras);try{let S=yield w();if(S=yield this._hookAdapter.trigger(dt.MESSAGE_BEFORE_RECEIVED,S),Object.assign(E,S),!a.selected)return Promise.resolve(E);E.markAsSent(),E.id=S.id,E.before_id=S.comment_before_id,E.unix_timestamp=S.unix_timestamp,(k=(q=this.options).commentSentCallback)==null||k.call(q,{comment:E}),a.events.emit("comment-sent",E),a.sortComments();const b=a._pendingComments.findIndex(h=>h.unique_id===E.unique_id);return b>-1&&a._pendingComments.splice(b,1),E}catch(S){E.markAsFailed();const b=[void 0,408,413,429,500,502,503,504,521,522,524],p=((R=(A=S.message)==null?void 0:A.toLowerCase())!=null?R:"").includes("offline");return(b.includes(S.status)||p)&&(this._pendingComments.push(E),this.logger("Failed sending comment",S)),Promise.reject(S)}})}_retrySendComment(e){return ke(this,null,function*(){var t,r,n;if(this.logger("Retrying send comment",e),this._pendingCommentsCount[e.unique_id]=((t=this._pendingCommentsCount[e.unique_id])!=null?t:0)+1,this._pendingCommentsCount[e.unique_id]>10){this.logger(`Exceeding maximum retry count for comment ${e.unique_id}, not retrying anymore`),(n=(r=this.options).commentRetryExceedCallback)==null||n.call(r,e);const o=this._pendingComments.findIndex(u=>u.unique_id===e.unique_id);return o>-1&&this._pendingComments.splice(o,1),e.markAsFailed(),this.events.emit("comment-retry-exceed",e),Promise.reject(new Error("Exceeding maximum retry count"))}return this.userAdapter.postComment(""+e.room_id,e.message,e.unique_id,e.type,e.payload,e.extras).then(o=>ke(this,null,function*(){var s,l,d,_;if(((s=this.selected)==null?void 0:s.id)!==e.room_id)return o;Object.assign(e,o),e.markAsSent(),e.id=o.id,e.before_id=o.comment_before_id,e.unix_timestamp=o.unix_timestamp;const u=(l=this.selected)==null?void 0:l.comments.findIndex(g=>g.unique_id===e.unique_id);u>-1&&(this.selected.comments[u]=e),this.sortComments(),(_=(d=this.options).commentSentCallback)==null||_.call(d,{comment:e}),this.events.emit("comment-sent",e);const a=this._pendingComments.findIndex(g=>g.unique_id===e.unique_id);return a>-1&&this._pendingComments.splice(a,1),e})).catch(o=>(e.markAsFailed(),Promise.reject(o)))})}getUsers(e="",t=1,r=20){return this.HTTPAdapter.get_request("api/v2/sdk/get_user_list").query({query:e,page:t,limit:r}).then(n=>Promise.resolve(n.body.results))}getParticipants(e,t=1,r=20){return this.HTTPAdapter.get_request("api/v2/sdk/room_participants").query({room_unique_id:e,page:t,limit:r}).then(n=>n.body.results)}getRoomParticipants(e,t=0){return console.warn("`getRoomParticipants` are deprecated, use `getParticipants` instead."),this.HTTPAdapter.get_request("api/v2/sdk/room_participants").query({room_unique_id:e,offset:t}).then(r=>Promise.resolve(r.body.results))}resendComment(e){if(this.selected==null)return;var t=this,r=t.selected,n=r.comments.find(u=>u.id===e.id);const o=t.extras;return this.userAdapter.postComment(""+r.id,n.message,n.unique_id,e.type,e.payload,o).then(u=>(n.markAsSent(),n.id=u.id,n.before_id=u.comment_before_id,new Promise((a,s)=>a(t.selected))),u=>(n.markAsFailed(),new Promise((a,s)=>s(u))))}prepareCommentToBeSubmitted(e){let t=new pt(e),r=`javascript-${Me()}`;return e.unique_id&&(r=e.unique_id),t.attachUniqueId(r),t.markAsPending(),t.isDelivered=!1,t.isSent=!1,t.isRead=!1,t.unix_timestamp=Math.round(new Date().getTime()/1e3),t}updateRoom(e){return this.roomAdapter.updateRoom(e)}removeSelectedRoomParticipants(e=[],t="id"){if(Ye.not.array(e))return Promise.reject(new Error("`values` must have type of array"));const r=this.selected.participants;if(!r)return Promise.reject(new Error("Nothing selected room chat."));let n=r;return t==="id"&&(n=r.filter(o=>e.indexOf(o.id)<=-1)),t==="email"&&(n=r.filter(o=>e.indexOf(o.email)<=-1)),t==="username"&&(n=r.filter(o=>e.indexOf(o.username)<=-1)),this.selected.participants=n,Promise.resolve(r)}createGroupRoom(e,t,r){const n=this;if(!this.isLogin)throw new Error("Please initiate qiscus SDK first");return new Zy(this.roomAdapter).withName(e).withOptions(r).addParticipants(t).create().then(o=>(n.events.emit("group-room-created",o),Promise.resolve(o)))}addParticipantsToGroup(e,t){const r=this;if(!Array.isArray(t))throw new Error("emails' must be type of Array");return r.roomAdapter.addParticipantsToGroup(e,t).then(n=>(r.events.emit("participants-added",n),Promise.resolve(n)),n=>Promise.reject(n))}removeParticipantsFromGroup(e,t){return Ye.not.array(t)?Promise.reject(new Error("`emails` must have type of array")):this.roomAdapter.removeParticipantsFromGroup(e,t).then(r=>(this.events.emit("participants-removed",t),Promise.resolve(r)))}getBlockedUser(e=1,t=20){return this.userAdapter.getBlockedUser(e,t).then(n=>Promise.resolve(n),n=>Promise.reject(n))}blockUser(e){const t=this;return t.userAdapter.blockUser(e).then(r=>(t.events.emit("block-user",r),Promise.resolve(r)),r=>Promise.reject(r))}unblockUser(e){const t=this;return t.userAdapter.unblockUser(e).then(r=>(t.events.emit("unblock-user",r),Promise.resolve(r)),r=>Promise.reject(r))}getUserPresences(e=[]){if(Ye.not.array(e))return Promise.reject(new Error("`email` must have type of array"));const t=this;return t.userAdapter.getUserPresences(e).then(r=>(t.events.emit("user-status",r),Promise.resolve(r)),r=>Promise.reject(r))}upload(e,t){let r=st.post(this.uploadURL);return r=this.HTTPAdapter.setupHeaders(r),r.attach("file",e).on("progress",n=>{n.direction==="upload"&&t(null,n)}).then(n=>{const o=n.body.results.file.url;return t(null,null,n.body.results.file.url),Promise.resolve(o)}).catch(n=>(t(n),Promise.reject(n)))}uploadFile(e,t){const r=this;var n=new FormData;n.append("file",t);var o=new XMLHttpRequest;o.open("POST",`${r.baseURL}/api/v2/sdk/upload`,!0),o.setRequestHeader("qiscus_sdk_app_id",`${r.AppId}`),o.setRequestHeader("qiscus_sdk_user_id",`${r.user_id}`),o.setRequestHeader("qiscus_sdk_token",`${r.userData.token}`),o.onload=function(){if(o.status===200){var u=JSON.parse(o.response).results.file.url;return r.events.emit("fileupload",u),r.sendComment(e,`[file] ${u} [/file]`)}else return Promise.reject(o)},o.send(n)}addUploadedFile(e,t){this.uploadedFiles.push(new ov(e,t))}removeUploadedFile(e,t){const r=this.uploadedFiles.findIndex(n=>n.name===e&&n.roomId===t);this.uploadedFiles.splice(r,1)}publishTyping(e){this.realtimeAdapter.publishTyping(e)}getRoomsInfo(e){return this.userAdapter.getRoomsInfo(e)}deleteComment(e,t,r,n){if(!Array.isArray(t))throw new Error("unique ids' must be type of Array");return this.userAdapter.deleteComment(e,t,r,n).then(o=>(this.events.emit("comment-deleted",{roomId:e,commentUniqueIds:t,isForEveryone:r,isHard:n}),Promise.resolve(o)),o=>Promise.reject(o))}clearRoomsCache(){if(this.selected){this.room_name_id_map={[this.selected.name]:this.selected.id};const e=this.rooms.length;let t=this.rooms.findIndex(r=>r.id===this.selected.id);t+1!==e&&this.rooms.splice(t+1,e-(t+1)),t=this.rooms.findIndex(r=>r.id===this.selected.id),t>0&&this.rooms.length>1&&this.rooms.splice(1,this.rooms.length-1)}}exitChatRoom(){this.realtimeAdapter.unsubscribeTyping(),jp(()=>this.selected.participants.filter(e=>e.email!==this.user_id).map(e=>e.email),null,this.noop,e=>e.forEach(t=>this.realtimeAdapter.unsubscribeRoomPresence(t))),this.selected=null}clearRoomMessages(e){if(!Array.isArray(e))throw new Error("room_ids must be type of array");return this.userAdapter.clearRoomMessages(e)}logging(e,t={}){this.debugMode&&console.log(e,t)}getTotalUnreadCount(){return this.roomAdapter.getTotalUnreadCount().then(e=>Promise.resolve(e),e=>Promise.reject(e))}getRoomUnreadCount(){return this.roomAdapter.getRoomUnreadCount()}publishEvent(...e){this.customEventAdapter.publishEvent(...e)}subscribeEvent(...e){this.customEventAdapter.subscribeEvent(...e)}unsubscribeEvent(...e){this.customEventAdapter.unsubscribeEvent(...e)}setCustomHeader(e){if(Ye.not.json(e))throw new TypeError("`headers` must have type of object");this._customHeader=e}getUserProfile(){return this.userAdapter.getProfile()}get Interceptor(){return dt}intercept(e,t){return this._hookAdapter.intercept(e,t)}getThumbnailURL(e){const t=/^https?:\/\/\S+(\/upload\/)\S+(\.\w+)$/i;return e.replace(t,(r,n,o)=>r.replace(n,"/upload/w_320,h_320,c_limit/").replace(o,".png"))}getBlurryThumbnailURL(e){const t=/^https?:\/\/\S+(\/upload\/)\S+(\.\w+)$/i;return e.replace(t,(r,n,o)=>r.replace(n,"/upload/w_320,h_320,c_limit,e_blur:300/").replace(o,".png"))}get logger(){return this.debugMode?console.log.bind(console,"Qiscus ->"):this.noop}noop(){}get _throttleDelay(){return this.updateCommentStatusMode===vt.UpdateCommentStatusMode.enabled?0:this.updateCommentStatusThrottleDelay||300}get _updateStatusEnabled(){return this.updateCommentStatusMode!==vt.UpdateCommentStatusMode.disabled}_updateStatus(e,t=null,r=null){const n=r!=null,o=t!=null;this.selected!=null&&this.selected.id;const u=this.selected!=null&&this.selected.isChannel||!1,a=!this._updateStatusEnabled,s=(()=>{if(o)return"read";if(n)return"receive"})(),l=!(u||n&&a);if(this.debugMode&&(console.group("update-command-status"),console.log("run:",s,`on: roomId(${e}) commentId(${t||r})`),console.log("is able to run command?",l),console.groupEnd()),!l)return!1;this.userAdapter.updateCommentStatus(e,t,r).catch(d=>{})}readComment(e,t){return this.updateCommentStatusMode===vt.UpdateCommentStatusMode.enabled?this._readComment(e,t):this._readCommentT(e,t)}receiveComment(e,t){return this.updateCommentStatusMode===vt.UpdateCommentStatusMode.enabled?this._deliverComment(e,t):this._deliverCommentT(e,t)}_throttle(e,t){let r=!1;return(...n)=>{let o=t();r||(e(...n),r=!0,setTimeout(()=>r=!1,o))}}searchMessage(){return ke(this,arguments,function*({query:e,roomIds:t=[],userId:r,type:n,roomType:o,page:u,limit:a}={}){const s="api/v2/sdk/search",l=["group","single","channel"].some(_=>_===o);if(o!=null&&!l)return Promise.reject("Invalid room type, valid room type are: `group`, `single`, and `channel`");const d=(_=>{const g=_==null?void 0:_==="single"?"single":"group",E=_==null?void 0:_==="channel";return{type:g,isPublic:E}})(o);return this.HTTPAdapter.post_json(s,{token:this.token,query:e,sender:r,type:n,room_ids:t.map(_=>String(_)),room_type:d.type||void 0,is_public:d.isPublic||void 0,page:u,limit:a}).then(_=>_.body)})}getFileList(){return ke(this,arguments,function*({roomIds:e=[],fileType:t,page:r,limit:n,sender:o,userId:u,includeExtensions:a,excludeExtensions:s}={}){const l="api/v2/sdk/file_list";if(!this.isLogin)return Promise.reject("You need to login to use this method");o===void 0&&(o=this.user_id),u===void 0&&(o=u=this.user_id);let d={room_ids:e.map(_=>String(_)),file_type:t,page:r,limit:n,include_extensions:a,exclude_extensions:s};return o!=null&&(d.sender=o),this.HTTPAdapter.post_json(l,d).then(_=>_.body)})}_generateUniqueId(){return`javascript-${Me()}`}generateMessage({roomId:e,text:t,extras:r}){const n=Date.now();return new pt({id:n,message:t,room_id:e,extras:r,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"text"})}generateFileAttachmentMessage({roomId:e,caption:t,url:r,text:n="File attachment",extras:o,filename:u,size:a}){const s=Date.now();return new pt({id:s,message:n,room_id:e,extras:o,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"file_attachment",payload:{url:r,file_name:u,size:a,caption:t}})}generateCustomMessage({roomId:e,text:t,type:r,payload:n,extras:o}){const u=Date.now();return new pt({id:u,message:t,room_id:e,extras:o,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"custom",payload:{type:r,content:n}})}generateReplyMessage({roomId:e,text:t,repliedMessage:r,extras:n}){const o=Date.now();return new pt({id:o,message:t,room_id:e,extras:n,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"reply",payload:{text:t,replied_comment_id:r.id,replied_comment_message:r.message,replied_comment_type:r.type,replied_comment_payload:r.payload,replied_comment_sender_username:r.username_as,replied_comment_sender_email:r.username_real}})}updateMessage(e){return ke(this,null,function*(){return this.userAdapter.updateMessage(e)})}onMessageUpdated(e){return this.realtimeAdapter.on("message:updated",e),()=>this.realtimeAdapter.off("message:updated",e)}closeRealtimeConnection(){return ke(this,null,function*(){return this.realtimeAdapter.closeConnection()})}openRealtimeConnection(){return ke(this,null,function*(){return this.realtimeAdapter.openConnection()})}startSync(){return ke(this,null,function*(){this._forceEnableSync=!0})}stopSync(){return ke(this,null,function*(){this._forceEnableSync=!1})}};He(vt,"UpdateCommentStatusMode",iv),He(vt,"Interceptor",dt);let Qa=vt;class ov{constructor(e,t){this.name=e,this.roomId=t,this.progress=0}}return Qa}));
27
+ //# sourceMappingURL=qiscus-sdk-core.min.js.map