@amityco/ts-sdk 0.0.1-c868cef.0 → 0.0.1-cb052d5.0
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.
- package/dist/@types/core/model.d.ts +4 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +6 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +1 -0
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/poll.d.ts +27 -0
- package/dist/@types/domains/poll.d.ts.map +1 -0
- package/dist/@types/domains/post.d.ts +1 -1
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/category/api/getCategory.d.ts +18 -2
- package/dist/category/api/getCategory.d.ts.map +1 -1
- package/dist/category/api/queryCategories.d.ts +23 -11
- package/dist/category/api/queryCategories.d.ts.map +1 -1
- package/dist/channel/api/deleteChannel.d.ts.map +1 -1
- package/dist/channel/api/queryChannels.d.ts +2 -0
- package/dist/channel/api/queryChannels.d.ts.map +1 -1
- package/dist/client/api/connectClient.d.ts +5 -4
- package/dist/client/api/connectClient.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/identifyModel.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/core/subscription.d.ts.map +1 -1
- package/dist/external/api/createUserToken.d.ts +23 -0
- package/dist/external/api/createUserToken.d.ts.map +1 -0
- package/dist/external/api/index.d.ts +2 -0
- package/dist/external/api/index.d.ts.map +1 -0
- package/dist/file/api/createFile.d.ts +1 -1
- package/dist/file/api/createFile.d.ts.map +1 -1
- package/dist/file/api/createImage.d.ts +17 -0
- package/dist/file/api/createImage.d.ts.map +1 -0
- package/dist/file/api/index.d.ts +1 -0
- package/dist/file/api/index.d.ts.map +1 -1
- package/dist/index.cjs.js +392 -17
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +384 -18
- package/dist/index.umd.js +5 -5
- package/dist/poll/api/closePoll.d.ts +16 -0
- package/dist/poll/api/closePoll.d.ts.map +1 -0
- package/dist/poll/api/createPoll.d.ts +25 -0
- package/dist/poll/api/createPoll.d.ts.map +1 -0
- package/dist/poll/api/deletePoll.d.ts +16 -0
- package/dist/poll/api/deletePoll.d.ts.map +1 -0
- package/dist/poll/api/getPoll.d.ts +32 -0
- package/dist/poll/api/getPoll.d.ts.map +1 -0
- package/dist/poll/api/index.d.ts +6 -0
- package/dist/poll/api/index.d.ts.map +1 -0
- package/dist/poll/api/votePoll.d.ts +17 -0
- package/dist/poll/api/votePoll.d.ts.map +1 -0
- package/dist/post/api/getPost.d.ts +1 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/model.ts +4 -0
- package/src/@types/core/payload.ts +7 -0
- package/src/@types/domains/comment.ts +1 -0
- package/src/@types/domains/poll.ts +32 -0
- package/src/@types/domains/post.ts +1 -1
- package/src/@types/index.ts +2 -0
- package/src/category/api/getCategory.ts +45 -7
- package/src/category/api/queryCategories.ts +70 -13
- package/src/channel/api/deleteChannel.ts +0 -1
- package/src/channel/api/queryChannels.ts +2 -0
- package/src/client/api/connectClient.ts +5 -5
- package/src/core/model/idResolvers.ts +2 -0
- package/src/core/model/identifyModel.ts +2 -0
- package/src/core/model/index.ts +2 -0
- package/src/core/subscription.ts +1 -3
- package/src/external/api/createUserToken.ts +43 -0
- package/src/external/api/index.ts +1 -0
- package/src/file/api/createFile.ts +5 -5
- package/src/file/api/createImage.ts +58 -0
- package/src/file/api/index.ts +1 -0
- package/src/index.ts +7 -0
- package/src/poll/api/closePoll.ts +39 -0
- package/src/poll/api/createPoll.ts +45 -0
- package/src/poll/api/deletePoll.ts +36 -0
- package/src/poll/api/getPoll.ts +64 -0
- package/src/poll/api/index.ts +7 -0
- package/src/poll/api/votePoll.ts +41 -0
- package/src/post/api/getPost.ts +1 -1
- package/src/utils/env.ts +3 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var Amity=function(e){"use strict";var t;const n=globalThis||global||window,{process:r={}}=n,o="production"===(null===(t=r.env)||void 0===t?void 0:t.NODE_ENV);var i,s;const a=null!==(s=null===(i=r.env)||void 0===i?void 0:i.VERSION)&&void 0!==s?s:"__dev__",c="function"==typeof atob,l="function"==typeof btoa,u="function"==typeof Buffer,h="function"==typeof TextDecoder?new TextDecoder:void 0,p="function"==typeof TextEncoder?new TextEncoder:void 0,f=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],d=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(f),m=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,g=String.fromCharCode.bind(String),y="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),v=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),b=l?e=>btoa(e):u?e=>Buffer.from(e,"binary").toString("base64"):e=>{let t,n,r,o,i="";const s=e.length%3;for(let s=0;s<e.length;){if((n=e.charCodeAt(s++))>255||(r=e.charCodeAt(s++))>255||(o=e.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=n<<16|r<<8|o,i+=f[t>>18&63]+f[t>>12&63]+f[t>>6&63]+f[63&t]}return s?i.slice(0,s-3)+"===".substring(s):i},w=u?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(g.apply(null,e.subarray(n,n+4096)));return b(t.join(""))},_=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?g(192|t>>>6)+g(128|63&t):g(224|t>>>12&15)+g(128|t>>>6&63)+g(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return g(240|t>>>18&7)+g(128|t>>>12&63)+g(128|t>>>6&63)+g(128|63&t)},C=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,S=u?e=>Buffer.from(e,"utf8").toString("base64"):p?e=>w(p.encode(e)):e=>b(e.replace(C,_)),k=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,A=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return g(55296+(t>>>10))+g(56320+(1023&t));case 3:return g((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return g((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},E=c?e=>atob(v(e)):u?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!m.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,r,o="";for(let i=0;i<e.length;)t=d[e.charAt(i++)]<<18|d[e.charAt(i++)]<<12|(n=d[e.charAt(i++)])<<6|(r=d[e.charAt(i++)]),o+=64===n?g(t>>16&255):64===r?g(t>>16&255,t>>8&255):g(t>>16&255,t>>8&255,255&t);return o},I=u?e=>y(Buffer.from(e,"base64")):e=>y(E(e),(e=>e.charCodeAt(0))),x=u?e=>Buffer.from(e,"base64").toString("utf8"):h?e=>h.decode(I(e)):e=>E(e).replace(k,A),R=e=>x(v(e.replace(/[-_]/g,(e=>"-"==e?"+":"/")))),O=e=>["skip","limit"].some((t=>t in e)),F=e=>["after","before","first","last","limit"].some((t=>t in e)),T=e=>"limit"in e,P=e=>(null==e?void 0:e.hasOwnProperty("data"))&&(null==e?void 0:e.hasOwnProperty("nextPage"))&&(null==e?void 0:e.hasOwnProperty("prevPage")),B=(e,t)=>{var n;if(!e||!Object.keys(e).length)return;let r={};return"skiplimit"===t?r={skip:null!==(n=e.after)&&void 0!==n?n:0,limit:e.limit}:"afterbefore"===t&&F(e)?Number.isNaN(null==e?void 0:e.before)?Number.isNaN(null==e?void 0:e.after)?Number.isNaN(null==e?void 0:e.limit)||(r={last:e.limit}):r={after:e.after,first:e.limit}:r={before:e.before,last:e.limit}:"afterbeforeraw"===t&&(r=e),Object.keys(r).length?((e,t=!1)=>t?(e=>e.replace(/[+\/]/g,(e=>"+"==e?"-":"_")).replace(/=+$/m,""))(S(e)):S(e))(JSON.stringify(r)):void 0},j=e=>{if(!e)return;const t=JSON.parse(R(e));if(O(t))return{after:t.skip,limit:t.limit};if(F(t)){if("before"in t)return{before:t.before,limit:t.last};if("after"in t)return{after:t.after,limit:t.first}}},U=e=>{if(!e)return;const t=JSON.parse(R(e));return T(t)?t:void 0},M=e=>"locally"in e,N=e=>"optimistically"in e,L=e=>M(e)||N(e),D=e=>null==e?void 0:e.hasOwnProperty("cachedAt"),q=(e,t=0)=>{var n;return Date.now()-(null!==(n=null==e?void 0:e.cachedAt)&&void 0!==n?n:0)<=t},$=(e,...t)=>({func:e,args:t}),H=(e,t=12e4)=>"cache_only"===e?{lifeSpan:1/0}:"server_only"===e?{lifeSpan:0}:{lifeSpan:t},V=({func:e,args:t},n,r=H("cache_then_server"))=>{let o;if(L(e)&&0!==r.lifeSpan){try{o=N(e)?e.optimistically(...t):e.locally(...t)}catch(e){null==n||n(W(void 0,{origin:"local",loading:!1,error:e}))}const i=D(o)&&q(o,r.lifeSpan);if(null==n||n(W(o,{origin:"local",loading:!(M(e)&&i)})),i)return}else null==n||n(W(void 0,{origin:"local",loading:!0}));e(...t).then((e=>{null==n||n(W(e,{origin:"server",loading:!1}))})).catch((e=>{null==n||n(W(void 0,{origin:"server",loading:!1,error:e}))}))};function W(e,t){return P(e)||D(e)?Object.assign(Object.assign({},t),e):Object.assign(Object.assign({},t),{data:e})}class z extends Error{constructor(e,t,n){super(`Amity SDK (${t}): ${e}`),this.code=t,this.level=n,this.type="ASC",this.timestamp=Date.now(),Error.captureStackTrace&&Error.captureStackTrace(this,z)}}class K extends z{constructor(e,t,n){super(e,t,n)}}class J extends z{constructor(e=8e5,t="fatal"){super("Unexpected error",e,t)}}class Y extends z{constructor(e,t="SDK client is having connection issues"){super(`${t} (${e})`,"disconnected"===e?800211:800210,"error"),this.event=e}}let Q=null;const X=()=>{if(!Q)throw new z("There is no active client",8e5,"fatal");return Q},G=e=>{Q=e};var Z="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ee(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}function te(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ne={exports:{}},re=1e3,oe=6e4,ie=60*oe,se=24*ie,ae=7*se,ce=365.25*se,le=function(e,t){t=t||{};var n=typeof e;if("string"===n&&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 n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*ce;case"weeks":case"week":case"w":return n*ae;case"days":case"day":case"d":return n*se;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ie;case"minutes":case"minute":case"mins":case"min":case"m":return n*oe;case"seconds":case"second":case"secs":case"sec":case"s":return n*re;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=se)return ue(e,t,se,"day");if(t>=ie)return ue(e,t,ie,"hour");if(t>=oe)return ue(e,t,oe,"minute");if(t>=re)return ue(e,t,re,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=se)return Math.round(e/se)+"d";if(t>=ie)return Math.round(e/ie)+"h";if(t>=oe)return Math.round(e/oe)+"m";if(t>=re)return Math.round(e/re)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ue(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}var he=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,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(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(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=le,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((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){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 n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},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&&"undefined"!=typeof process&&"env"in process&&(e=process.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=he(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(ne,ne.exports);var pe=ne.exports;const fe={EU:"eu",SG:"sg",US:"us"},de={http:"https://api.{region}.amity.co",mqtt:"wss://sse.{region}.amity.co:443/mqtt"};function me(e,t){return de[e].replace("{region}",t)}var ge={exports:{}},ye=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},ve=ye,be=Object.prototype.toString;function we(e){return"[object Array]"===be.call(e)}function _e(e){return void 0===e}function Ce(e){return null!==e&&"object"==typeof e}function Se(e){if("[object Object]"!==be.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function ke(e){return"[object Function]"===be.call(e)}function Ae(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),we(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var Ee={isArray:we,isArrayBuffer:function(e){return"[object ArrayBuffer]"===be.call(e)},isBuffer:function(e){return null!==e&&!_e(e)&&null!==e.constructor&&!_e(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:Ce,isPlainObject:Se,isUndefined:_e,isDate:function(e){return"[object Date]"===be.call(e)},isFile:function(e){return"[object File]"===be.call(e)},isBlob:function(e){return"[object Blob]"===be.call(e)},isFunction:ke,isStream:function(e){return Ce(e)&&ke(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:Ae,merge:function e(){var t={};function n(n,r){Se(t[r])&&Se(n)?t[r]=e(t[r],n):Se(n)?t[r]=e({},n):we(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)Ae(arguments[r],n);return t},extend:function(e,t,n){return Ae(t,(function(t,r){e[r]=n&&"function"==typeof t?ve(t,n):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}},Ie=Ee;function xe(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Re=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(Ie.isURLSearchParams(t))r=t.toString();else{var o=[];Ie.forEach(t,(function(e,t){null!=e&&(Ie.isArray(e)?t+="[]":e=[e],Ie.forEach(e,(function(e){Ie.isDate(e)?e=e.toISOString():Ie.isObject(e)&&(e=JSON.stringify(e)),o.push(xe(t)+"="+xe(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},Oe=Ee;function Fe(){this.handlers=[]}Fe.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},Fe.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Fe.prototype.forEach=function(e){Oe.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Te=Fe,Pe=Ee,Be=function(e){return!(!e||!e.__CANCEL__)},je=Ee,Ue=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},Me=function(e,t,n,r,o){var i=new Error(e);return Ue(i,t,n,r,o)},Ne=Me,Le=Ee,De=Le.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),Le.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),Le.isString(r)&&s.push("path="+r),Le.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},qe=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},$e=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},He=Ee,Ve=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],We=Ee,ze=We.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=We.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},Ke=Ee,Je=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(Ne("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)},Ye=De,Qe=Re,Xe=function(e,t){return e&&!qe(t)?$e(e,t):t},Ge=function(e){var t,n,r,o={};return e?(He.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=He.trim(e.substr(0,r)).toLowerCase(),n=He.trim(e.substr(r+1)),t){if(o[t]&&Ve.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o},Ze=ze,et=Me,tt=function(e){return new Promise((function(t,n){var r=e.data,o=e.headers;Ke.isFormData(r)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var s=e.auth.username||"",a=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(s+":"+a)}var c=Xe(e.baseURL,e.url);if(i.open(e.method.toUpperCase(),Qe(c,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in i?Ge(i.getAllResponseHeaders()):null,o={data:e.responseType&&"text"!==e.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:r,config:e,request:i};Je(t,n,o),i=null}},i.onabort=function(){i&&(n(et("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){n(et("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(et(t,e,"ECONNABORTED",i)),i=null},Ke.isStandardBrowserEnv()){var l=(e.withCredentials||Ze(c))&&e.xsrfCookieName?Ye.read(e.xsrfCookieName):void 0;l&&(o[e.xsrfHeaderName]=l)}if("setRequestHeader"in i&&Ke.forEach(o,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)})),Ke.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),e.responseType)try{i.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){i&&(i.abort(),n(e),i=null)})),r||(r=null),i.send(r)}))},nt=Ee,rt=function(e,t){je.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},ot={"Content-Type":"application/x-www-form-urlencoded"};function it(e,t){!nt.isUndefined(e)&&nt.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var st,at={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(st=tt),st),transformRequest:[function(e,t){return rt(t,"Accept"),rt(t,"Content-Type"),nt.isFormData(e)||nt.isArrayBuffer(e)||nt.isBuffer(e)||nt.isStream(e)||nt.isFile(e)||nt.isBlob(e)?e:nt.isArrayBufferView(e)?e.buffer:nt.isURLSearchParams(e)?(it(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):nt.isObject(e)?(it(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};at.headers={common:{Accept:"application/json, text/plain, */*"}},nt.forEach(["delete","get","head"],(function(e){at.headers[e]={}})),nt.forEach(["post","put","patch"],(function(e){at.headers[e]=nt.merge(ot)}));var ct=at,lt=Ee,ut=function(e,t,n){return Pe.forEach(n,(function(n){e=n(e,t)})),e},ht=Be,pt=ct;function ft(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var dt=Ee,mt=function(e,t){t=t||{};var n={},r=["url","method","data"],o=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function a(e,t){return dt.isPlainObject(e)&&dt.isPlainObject(t)?dt.merge(e,t):dt.isPlainObject(t)?dt.merge({},t):dt.isArray(t)?t.slice():t}function c(r){dt.isUndefined(t[r])?dt.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(e[r],t[r])}dt.forEach(r,(function(e){dt.isUndefined(t[e])||(n[e]=a(void 0,t[e]))})),dt.forEach(o,c),dt.forEach(i,(function(r){dt.isUndefined(t[r])?dt.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(void 0,t[r])})),dt.forEach(s,(function(r){r in t?n[r]=a(e[r],t[r]):r in e&&(n[r]=a(void 0,e[r]))}));var l=r.concat(o).concat(i).concat(s),u=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return dt.forEach(u,c),n},gt=Ee,yt=Re,vt=Te,bt=function(e){return ft(e),e.headers=e.headers||{},e.data=ut(e.data,e.headers,e.transformRequest),e.headers=lt.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),lt.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||pt.adapter)(e).then((function(t){return ft(e),t.data=ut(t.data,t.headers,e.transformResponse),t}),(function(t){return ht(t)||(ft(e),t&&t.response&&(t.response.data=ut(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},wt=mt;function _t(e){this.defaults=e,this.interceptors={request:new vt,response:new vt}}_t.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=wt(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[bt,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},_t.prototype.getUri=function(e){return e=wt(this.defaults,e),yt(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},gt.forEach(["delete","get","head","options"],(function(e){_t.prototype[e]=function(t,n){return this.request(wt(n||{},{method:e,url:t,data:(n||{}).data}))}})),gt.forEach(["post","put","patch"],(function(e){_t.prototype[e]=function(t,n,r){return this.request(wt(r||{},{method:e,url:t,data:n}))}}));var Ct=_t;function St(e){this.message=e}St.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},St.prototype.__CANCEL__=!0;var kt=St,At=kt;function Et(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new At(e),t(n.reason))}))}Et.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Et.source=function(){var e;return{token:new Et((function(t){e=t})),cancel:e}};var It=Et,xt=Ee,Rt=ye,Ot=Ct,Ft=mt;function Tt(e){var t=new Ot(e),n=Rt(Ot.prototype.request,t);return xt.extend(n,Ot.prototype,t),xt.extend(n,t),n}var Pt=Tt(ct);Pt.Axios=Ot,Pt.create=function(e){return Tt(Ft(Pt.defaults,e))},Pt.Cancel=kt,Pt.CancelToken=It,Pt.isCancel=Be,Pt.all=function(e){return Promise.all(e)},Pt.spread=function(e){return function(t){return e.apply(null,t)}},Pt.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},ge.exports=Pt,ge.exports.default=Pt;var Bt=ge.exports,jt={exports:{}};jt.exports=Mt;var Ut=jt.exports.HttpsAgent=Mt;function Mt(){}var Nt=jt.exports;const Lt=e=>{if("success"===e.status)return e.data;if("fail"===e.status)throw new J(e.code);if("error"===e.status)throw new K(e.message,e.code,"error")},Dt=(e,t)=>Object.entries(e).filter((([,e])=>void 0!==e)).map((([e,n])=>{const r=t?`${t}[${e}]`:e;return Array.isArray(n)?n.map((e=>`${r}[]=${e}`)).join("&"):"object"!=typeof n?`${r}=${n}`:Dt(n,null!=t?t:e)})).join("&");var qt={exports:{}},$t=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Ht=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Vt=function(e){var t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));for(var o=$t.exec(e||""),i={},s=14;s--;)i[Ht[s]]=o[s]||"";return-1!=n&&-1!=r&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i},Wt={exports:{}},zt={exports:{}},Kt=1e3,Jt=6e4,Yt=60*Jt,Qt=24*Yt,Xt=365.25*Qt,Gt=function(e,t){t=t||{};var n=typeof e;if("string"===n&&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|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*Xt;case"days":case"day":case"d":return n*Qt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Yt;case"minutes":case"minute":case"mins":case"min":case"m":return n*Jt;case"seconds":case"second":case"secs":case"sec":case"s":return n*Kt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return Zt(e,Qt,"day")||Zt(e,Yt,"hour")||Zt(e,Jt,"minute")||Zt(e,Kt,"second")||e+" ms"}(e):function(e){if(e>=Qt)return Math.round(e/Qt)+"d";if(e>=Yt)return Math.round(e/Yt)+"h";if(e>=Jt)return Math.round(e/Jt)+"m";if(e>=Kt)return Math.round(e/Kt)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Zt(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Gt,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(zt,zt.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=zt.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)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="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),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.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(Wt,Wt.exports);var en=Vt,tn=Wt.exports("socket.io-client:url"),nn=function(e,t){var n=e;t=t||"undefined"!=typeof location&&location,null==e&&(e=t.protocol+"//"+t.host);"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?t.protocol+e:t.host+e),/^(https?|wss?):\/\//.test(e)||(tn("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),tn("parse %s",e),n=en(e));n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443"));n.path=n.path||"/";var r=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+r+":"+n.port,n.href=n.protocol+"://"+r+(t&&t.port===n.port?"":":"+n.port),n};var rn={},on={exports:{}},sn={exports:{}},an=1e3,cn=6e4,ln=60*cn,un=24*ln,hn=365.25*un,pn=function(e,t){t=t||{};var n=typeof e;if("string"===n&&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|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*hn;case"days":case"day":case"d":return n*un;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ln;case"minutes":case"minute":case"mins":case"min":case"m":return n*cn;case"seconds":case"second":case"secs":case"sec":case"s":return n*an;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return fn(e,un,"day")||fn(e,ln,"hour")||fn(e,cn,"minute")||fn(e,an,"second")||e+" ms"}(e):function(e){if(e>=un)return Math.round(e/un)+"d";if(e>=ln)return Math.round(e/ln)+"h";if(e>=cn)return Math.round(e/cn)+"m";if(e>=an)return Math.round(e/an)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function fn(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=pn,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(sn,sn.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=sn.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)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="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),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.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(on,on.exports);var dn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t)}return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(dn);var mn={},gn={}.toString,yn=Array.isArray||function(e){return"[object Array]"==gn.call(e)},vn=function(e){return bn&&Buffer.isBuffer(e)||wn&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))},bn="function"==typeof Buffer&&"function"==typeof Buffer.isBuffer,wn="function"==typeof ArrayBuffer;var _n=yn,Cn=vn,Sn=Object.prototype.toString,kn="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Sn.call(Blob),An="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Sn.call(File);function En(e,t){if(!e)return e;if(Cn(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(_n(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=En(e[o],t);return r}if("object"==typeof e&&!(e instanceof Date)){r={};for(var i in e)r[i]=En(e[i],t);return r}return e}function In(e,t){if(!e)return e;if(e&&e._placeholder)return t[e.num];if(_n(e))for(var n=0;n<e.length;n++)e[n]=In(e[n],t);else if("object"==typeof e)for(var r in e)e[r]=In(e[r],t);return e}mn.deconstructPacket=function(e){var t=[],n=e.data,r=e;return r.data=En(n,t),r.attachments=t.length,{packet:r,buffers:t}},mn.reconstructPacket=function(e,t){return e.data=In(e.data,t),e.attachments=void 0,e},mn.removeBlobs=function(e,t){var n=0,r=e;!function e(o,i,s){if(!o)return o;if(kn&&o instanceof Blob||An&&o instanceof File){n++;var a=new FileReader;a.onload=function(){s?s[i]=this.result:r=this.result,--n||t(r)},a.readAsArrayBuffer(o)}else if(_n(o))for(var c=0;c<o.length;c++)e(o[c],c,o);else if("object"==typeof o&&!Cn(o))for(var l in o)e(o[l],l,o)}(r),n||t(r)},function(e){var t=on.exports("socket.io-parser"),n=dn.exports,r=mn,o=yn,i=vn;function s(){}e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=s,e.Decoder=l;var a=e.ERROR+'"encode error"';function c(n){var r=""+n.type;if(e.BINARY_EVENT!==n.type&&e.BINARY_ACK!==n.type||(r+=n.attachments+"-"),n.nsp&&"/"!==n.nsp&&(r+=n.nsp+","),null!=n.id&&(r+=n.id),null!=n.data){var o=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(n.data);if(!1===o)return a;r+=o}return t("encoded %j as %s",n,r),r}function l(){this.reconstructor=null}function u(e){this.reconPack=e,this.buffers=[]}function h(t){return{type:e.ERROR,data:"parser error: "+t}}s.prototype.encode=function(n,o){(t("encoding packet %j",n),e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type)?function(e,t){function n(e){var n=r.deconstructPacket(e),o=c(n.packet),i=n.buffers;i.unshift(o),t(i)}r.removeBlobs(e,n)}(n,o):o([c(n)])},n(l.prototype),l.prototype.add=function(n){var r;if("string"==typeof n)r=function(n){var r=0,i={type:Number(n.charAt(0))};if(null==e.types[i.type])return h("unknown packet type "+i.type);if(e.BINARY_EVENT===i.type||e.BINARY_ACK===i.type){for(var s=r+1;"-"!==n.charAt(++r)&&r!=n.length;);var a=n.substring(s,r);if(a!=Number(a)||"-"!==n.charAt(r))throw new Error("Illegal attachments");i.attachments=Number(a)}if("/"===n.charAt(r+1)){for(s=r+1;++r;){if(","===(l=n.charAt(r)))break;if(r===n.length)break}i.nsp=n.substring(s,r)}else i.nsp="/";var c=n.charAt(r+1);if(""!==c&&Number(c)==c){for(s=r+1;++r;){var l;if(null==(l=n.charAt(r))||Number(l)!=l){--r;break}if(r===n.length)break}i.id=Number(n.substring(s,r+1))}if(n.charAt(++r)){var u=function(e){try{return JSON.parse(e)}catch(e){return!1}}(n.substr(r));if(!(!1!==u&&(i.type===e.ERROR||o(u))))return h("invalid payload");i.data=u}return t("decoded %s as %j",n,i),i}(n),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type?(this.reconstructor=new u(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!i(n)&&!n.base64)throw new Error("Unknown type: "+n);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(r=this.reconstructor.takeBinaryData(n))&&(this.reconstructor=null,this.emit("decoded",r))}},l.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},u.prototype.takeBinaryData=function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=r.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null},u.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}}(rn);var xn={exports:{}},Rn={},On={exports:{}};try{On.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){On.exports=!1}var Fn=On.exports,Tn=function(e){var t=e.xdomain,n=e.xscheme,r=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||Fn))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!n&&r)return new XDomainRequest}catch(e){}if(!t)try{return new(self[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},Pn={exports:{}},Bn={},jn=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var r in e)n.call(e,r)&&t.push(r);return t},Un={}.toString,Mn=Array.isArray||function(e){return"[object Array]"==Un.call(e)},Nn=Object.prototype.toString,Ln="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Nn.call(Blob),Dn="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Nn.call(File),qn=function e(t){if(!t||"object"!=typeof t)return!1;if(Mn(t)){for(var n=0,r=t.length;n<r;n++)if(e(t[n]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(t)||"function"==typeof ArrayBuffer&&t instanceof ArrayBuffer||Ln&&t instanceof Blob||Dn&&t instanceof File)return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&e(t[o]))return!0;return!1};var $n=function(e,t,n){var r=e.byteLength;if(t=t||0,n=n||r,e.slice)return e.slice(t,n);if(t<0&&(t+=r),n<0&&(n+=r),n>r&&(n=r),t>=r||t>=n||0===r)return new ArrayBuffer(0);for(var o=new Uint8Array(e),i=new Uint8Array(n-t),s=t,a=0;s<n;s++,a++)i[a]=o[s];return i.buffer},Hn=function(e,t,n){var r=!1;return n=n||Vn,o.count=e,0===e?t():o;function o(e,i){if(o.count<=0)throw new Error("after called too many times");--o.count,e?(r=!0,t(e),t=n):0!==o.count||r||t(null,i)}};function Vn(){}
|
|
2
|
-
/*! https://mths.be/utf8js v2.1.2 by @mathias */var Wn,zn,Kn,Jn=String.fromCharCode;function Yn(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function Qn(e,t){if(e>=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function Xn(e,t){return Jn(e>>t&63|128)}function Gn(e,t){if(0==(4294967168&e))return Jn(e);var n="";return 0==(4294965248&e)?n=Jn(e>>6&31|192):0==(4294901760&e)?(Qn(e,t)||(e=65533),n=Jn(e>>12&15|224),n+=Xn(e,6)):0==(4292870144&e)&&(n=Jn(e>>18&7|240),n+=Xn(e,12),n+=Xn(e,6)),n+=Jn(63&e|128)}function Zn(){if(Kn>=zn)throw Error("Invalid byte index");var e=255&Wn[Kn];if(Kn++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function er(e){var t,n;if(Kn>zn)throw Error("Invalid byte index");if(Kn==zn)return!1;if(t=255&Wn[Kn],Kn++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|Zn())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|Zn()<<6|Zn())>=2048)return Qn(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|Zn()<<12|Zn()<<6|Zn())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}var tr={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,r=Yn(e),o=r.length,i=-1,s="";++i<o;)s+=Gn(r[i],n);return s},decode:function(e,t){var n=!1!==(t=t||{}).strict;Wn=Yn(e),zn=Wn.length,Kn=0;for(var r,o=[];!1!==(r=er(n));)o.push(r);return function(e){for(var t,n=e.length,r=-1,o="";++r<n;)(t=e[r])>65535&&(o+=Jn((t-=65536)>>>10&1023|55296),t=56320|1023&t),o+=Jn(t);return o}(o)}},nr={};!function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=new Uint8Array(256),n=0;n<e.length;n++)t[e.charCodeAt(n)]=n;nr.encode=function(t){var n,r=new Uint8Array(t),o=r.length,i="";for(n=0;n<o;n+=3)i+=e[r[n]>>2],i+=e[(3&r[n])<<4|r[n+1]>>4],i+=e[(15&r[n+1])<<2|r[n+2]>>6],i+=e[63&r[n+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i},nr.decode=function(e){var n,r,o,i,s,a=.75*e.length,c=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var u=new ArrayBuffer(a),h=new Uint8Array(u);for(n=0;n<c;n+=4)r=t[e.charCodeAt(n)],o=t[e.charCodeAt(n+1)],i=t[e.charCodeAt(n+2)],s=t[e.charCodeAt(n+3)],h[l++]=r<<2|o>>4,h[l++]=(15&o)<<4|i>>2,h[l++]=(3&i)<<6|63&s;return u}}();var rr=void 0!==rr?rr:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,or=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),ir=or&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),sr=rr&&rr.prototype.append&&rr.prototype.getBlob;function ar(e){return e.map((function(e){if(e.buffer instanceof ArrayBuffer){var t=e.buffer;if(e.byteLength!==t.byteLength){var n=new Uint8Array(e.byteLength);n.set(new Uint8Array(t,e.byteOffset,e.byteLength)),t=n.buffer}return t}return e}))}function cr(e,t){t=t||{};var n=new rr;return ar(e).forEach((function(e){n.append(e)})),t.type?n.getBlob(t.type):n.getBlob()}function lr(e,t){return new Blob(ar(e),t||{})}"undefined"!=typeof Blob&&(cr.prototype=Blob.prototype,lr.prototype=Blob.prototype);var ur=or?ir?Blob:lr:sr?cr:void 0;!function(e){var t,n=jn,r=qn,o=$n,i=Hn,s=tr;"undefined"!=typeof ArrayBuffer&&(t=nr);var a="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),c="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),l=a||c;e.protocol=3;var u=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},h=n(u),p={type:"error",data:"parser error"},f=ur;function d(e,t,n){for(var r=new Array(e.length),o=i(e.length,n),s=function(e,n,o){t(n,(function(t,n){r[e]=n,o(t,r)}))},a=0;a<e.length;a++)s(a,e[a],o)}e.encodePacket=function(t,n,r,o){"function"==typeof n&&(o=n,n=!1),"function"==typeof r&&(o=r,r=null);var i=void 0===t.data?void 0:t.data.buffer||t.data;if("undefined"!=typeof ArrayBuffer&&i instanceof ArrayBuffer)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=t.data,i=new Uint8Array(o),s=new Uint8Array(1+o.byteLength);s[0]=u[t.type];for(var a=0;a<i.length;a++)s[a+1]=i[a];return r(s.buffer)}(t,n,o);if(void 0!==f&&i instanceof f)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);if(l)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=new FileReader;return o.onload=function(){e.encodePacket({type:t.type,data:o.result},n,!0,r)},o.readAsArrayBuffer(t.data)}(t,n,r);var o=new Uint8Array(1);o[0]=u[t.type];var i=new f([o.buffer,t.data]);return r(i)}(t,n,o);if(i&&i.base64)return function(t,n){var r="b"+e.packets[t.type]+t.data.data;return n(r)}(t,o);var a=u[t.type];return void 0!==t.data&&(a+=r?s.encode(String(t.data),{strict:!1}):String(t.data)),o(""+a)},e.encodeBase64Packet=function(t,n){var r,o="b"+e.packets[t.type];if(void 0!==f&&t.data instanceof f){var i=new FileReader;return i.onload=function(){var e=i.result.split(",")[1];n(o+e)},i.readAsDataURL(t.data)}try{r=String.fromCharCode.apply(null,new Uint8Array(t.data))}catch(e){for(var s=new Uint8Array(t.data),a=new Array(s.length),c=0;c<s.length;c++)a[c]=s[c];r=String.fromCharCode.apply(null,a)}return o+=btoa(r),n(o)},e.decodePacket=function(t,n,r){if(void 0===t)return p;if("string"==typeof t){if("b"===t.charAt(0))return e.decodeBase64Packet(t.substr(1),n);if(r&&!1===(t=function(e){try{e=s.decode(e,{strict:!1})}catch(e){return!1}return e}(t)))return p;var i=t.charAt(0);return Number(i)==i&&h[i]?t.length>1?{type:h[i],data:t.substring(1)}:{type:h[i]}:p}i=new Uint8Array(t)[0];var a=o(t,1);return f&&"blob"===n&&(a=new f([a])),{type:h[i],data:a}},e.decodeBase64Packet=function(e,n){var r=h[e.charAt(0)];if(!t)return{type:r,data:{base64:!0,data:e.substr(1)}};var o=t.decode(e.substr(1));return"blob"===n&&f&&(o=new f([o])),{type:r,data:o}},e.encodePayload=function(t,n,o){"function"==typeof n&&(o=n,n=null);var i=r(t);if(n&&i)return f&&!l?e.encodePayloadAsBlob(t,o):e.encodePayloadAsArrayBuffer(t,o);if(!t.length)return o("0:");d(t,(function(t,r){e.encodePacket(t,!!i&&n,!1,(function(e){r(null,function(e){return e.length+":"+e}(e))}))}),(function(e,t){return o(t.join(""))}))},e.decodePayload=function(t,n,r){if("string"!=typeof t)return e.decodePayloadAsBinary(t,n,r);var o;if("function"==typeof n&&(r=n,n=null),""===t)return r(p,0,1);for(var i,s,a="",c=0,l=t.length;c<l;c++){var u=t.charAt(c);if(":"===u){if(""===a||a!=(i=Number(a)))return r(p,0,1);if(a!=(s=t.substr(c+1,i)).length)return r(p,0,1);if(s.length){if(o=e.decodePacket(s,n,!1),p.type===o.type&&p.data===o.data)return r(p,0,1);if(!1===r(o,c+i,l))return}c+=i,a=""}else a+=u}return""!==a?r(p,0,1):void 0},e.encodePayloadAsArrayBuffer=function(t,n){if(!t.length)return n(new ArrayBuffer(0));d(t,(function(t,n){e.encodePacket(t,!0,!0,(function(e){return n(null,e)}))}),(function(e,t){var r=t.reduce((function(e,t){var n;return e+(n="string"==typeof t?t.length:t.byteLength).toString().length+n+2}),0),o=new Uint8Array(r),i=0;return t.forEach((function(e){var t="string"==typeof e,n=e;if(t){for(var r=new Uint8Array(e.length),s=0;s<e.length;s++)r[s]=e.charCodeAt(s);n=r.buffer}o[i++]=t?0:1;var a=n.byteLength.toString();for(s=0;s<a.length;s++)o[i++]=parseInt(a[s]);o[i++]=255;for(r=new Uint8Array(n),s=0;s<r.length;s++)o[i++]=r[s]})),n(o.buffer)}))},e.encodePayloadAsBlob=function(t,n){d(t,(function(t,n){e.encodePacket(t,!0,!0,(function(e){var t=new Uint8Array(1);if(t[0]=1,"string"==typeof e){for(var r=new Uint8Array(e.length),o=0;o<e.length;o++)r[o]=e.charCodeAt(o);e=r.buffer,t[0]=0}var i=(e instanceof ArrayBuffer?e.byteLength:e.size).toString(),s=new Uint8Array(i.length+1);for(o=0;o<i.length;o++)s[o]=parseInt(i[o]);if(s[i.length]=255,f){var a=new f([t.buffer,s.buffer,e]);n(null,a)}}))}),(function(e,t){return n(new f(t))}))},e.decodePayloadAsBinary=function(t,n,r){"function"==typeof n&&(r=n,n=null);for(var i=t,s=[];i.byteLength>0;){for(var a=new Uint8Array(i),c=0===a[0],l="",u=1;255!==a[u];u++){if(l.length>310)return r(p,0,1);l+=a[u]}i=o(i,2+l.length),l=parseInt(l);var h=o(i,0,l);if(c)try{h=String.fromCharCode.apply(null,new Uint8Array(h))}catch(e){var f=new Uint8Array(h);h="";for(u=0;u<f.length;u++)h+=String.fromCharCode(f[u])}s.push(h),i=o(i,l)}var d=s.length;s.forEach((function(t,o){r(e.decodePacket(t,n,!0),o,d)}))}}(Bn);var hr={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(hr);var pr=Bn,fr=dr;function dr(e){this.path=e.path,this.hostname=e.hostname,this.port=e.port,this.secure=e.secure,this.query=e.query,this.timestampParam=e.timestampParam,this.timestampRequests=e.timestampRequests,this.readyState="",this.agent=e.agent||!1,this.socket=e.socket,this.enablesXDR=e.enablesXDR,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.forceNode=e.forceNode,this.isReactNative=e.isReactNative,this.extraHeaders=e.extraHeaders,this.localAddress=e.localAddress}(0,hr.exports)(dr.prototype),dr.prototype.onError=function(e,t){var n=new Error(e);return n.type="TransportError",n.description=t,this.emit("error",n),this},dr.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},dr.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},dr.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},dr.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},dr.prototype.onData=function(e){var t=pr.decodePacket(e,this.socket.binaryType);this.onPacket(t)},dr.prototype.onPacket=function(e){this.emit("packet",e)},dr.prototype.onClose=function(){this.readyState="closed",this.emit("close")};var mr,gr={encode:function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},decode:function(e){for(var t={},n=e.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}},yr=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},vr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),br={},wr=0,_r=0;function Cr(e){var t="";do{t=vr[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function Sr(){var e=Cr(+new Date);return e!==mr?(wr=0,mr=e):e+"."+Cr(wr++)}for(;_r<64;_r++)br[vr[_r]]=_r;Sr.encode=Cr,Sr.decode=function(e){var t=0;for(_r=0;_r<e.length;_r++)t=64*t+br[e.charAt(_r)];return t};var kr=Sr,Ar={exports:{}},Er={exports:{}},Ir=1e3,xr=60*Ir,Rr=60*xr,Or=24*Rr,Fr=365.25*Or,Tr=function(e,t){t=t||{};var n=typeof e;if("string"===n&&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|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*Fr;case"days":case"day":case"d":return n*Or;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Rr;case"minutes":case"minute":case"mins":case"min":case"m":return n*xr;case"seconds":case"second":case"secs":case"sec":case"s":return n*Ir;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return Pr(e,Or,"day")||Pr(e,Rr,"hour")||Pr(e,xr,"minute")||Pr(e,Ir,"second")||e+" ms"}(e):function(e){if(e>=Or)return Math.round(e/Or)+"d";if(e>=Rr)return Math.round(e/Rr)+"h";if(e>=xr)return Math.round(e/xr)+"m";if(e>=Ir)return Math.round(e/Ir)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Pr(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Tr,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(Er,Er.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=Er.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)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="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),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.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(Ar,Ar.exports);var Br=fr,jr=gr,Ur=Bn,Mr=yr,Nr=kr,Lr=Ar.exports("engine.io-client:polling"),Dr=$r,qr=null!=new Tn({xdomain:!1}).responseType;function $r(e){var t=e&&e.forceBase64;qr&&!t||(this.supportsBinary=!1),Br.call(this,e)}Mr($r,Br),$r.prototype.name="polling",$r.prototype.doOpen=function(){this.poll()},$r.prototype.pause=function(e){var t=this;function n(){Lr("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(Lr("we are currently polling - waiting to pause"),r++,this.once("pollComplete",(function(){Lr("pre-pause polling complete"),--r||n()}))),this.writable||(Lr("we are currently writing - waiting to pause"),r++,this.once("drain",(function(){Lr("pre-pause writing complete"),--r||n()})))}else n()},$r.prototype.poll=function(){Lr("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},$r.prototype.onData=function(e){var t=this;Lr("polling got data %s",e);Ur.decodePayload(e,this.socket.binaryType,(function(e,n,r){if("opening"===t.readyState&&t.onOpen(),"close"===e.type)return t.onClose(),!1;t.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():Lr('ignoring poll - transport state "%s"',this.readyState))},$r.prototype.doClose=function(){var e=this;function t(){Lr("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(Lr("transport open - closing"),t()):(Lr("transport not open - deferring close"),this.once("open",t))},$r.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};Ur.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,n)}))},$r.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=Nr()),this.supportsBinary||e.sid||(e.b64=1),e=jr.encode(e),this.port&&("https"===t&&443!==Number(this.port)||"http"===t&&80!==Number(this.port))&&(n=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e};var Hr=Tn,Vr=Dr,Wr=hr.exports,zr=yr,Kr=Ar.exports("engine.io-client:polling-xhr");function Jr(){}function Yr(e){if(Vr.call(this,e),this.requestTimeout=e.requestTimeout,this.extraHeaders=e.extraHeaders,"undefined"!=typeof location){var t="https:"===location.protocol,n=location.port;n||(n=t?443:80),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port,this.xs=e.secure!==t}}function Qr(e){this.method=e.method||"GET",this.uri=e.uri,this.xd=!!e.xd,this.xs=!!e.xs,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.agent=e.agent,this.isBinary=e.isBinary,this.supportsBinary=e.supportsBinary,this.enablesXDR=e.enablesXDR,this.requestTimeout=e.requestTimeout,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.extraHeaders=e.extraHeaders,this.create()}if(Pn.exports=Yr,Pn.exports.Request=Qr,zr(Yr,Vr),Yr.prototype.supportsBinary=!0,Yr.prototype.request=function(e){return(e=e||{}).uri=this.uri(),e.xd=this.xd,e.xs=this.xs,e.agent=this.agent||!1,e.supportsBinary=this.supportsBinary,e.enablesXDR=this.enablesXDR,e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized,e.requestTimeout=this.requestTimeout,e.extraHeaders=this.extraHeaders,new Qr(e)},Yr.prototype.doWrite=function(e,t){var n="string"!=typeof e&&void 0!==e,r=this.request({method:"POST",data:e,isBinary:n}),o=this;r.on("success",t),r.on("error",(function(e){o.onError("xhr post error",e)})),this.sendXhr=r},Yr.prototype.doPoll=function(){Kr("xhr poll");var e=this.request(),t=this;e.on("data",(function(e){t.onData(e)})),e.on("error",(function(e){t.onError("xhr poll error",e)})),this.pollXhr=e},Wr(Qr.prototype),Qr.prototype.create=function(){var e={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized;var t=this.xhr=new Hr(e),n=this;try{Kr("xhr open %s: %s",this.method,this.uri),t.open(this.method,this.uri,this.async);try{if(this.extraHeaders)for(var r in t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0),this.extraHeaders)this.extraHeaders.hasOwnProperty(r)&&t.setRequestHeader(r,this.extraHeaders[r])}catch(e){}if("POST"===this.method)try{this.isBinary?t.setRequestHeader("Content-type","application/octet-stream"):t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{t.setRequestHeader("Accept","*/*")}catch(e){}"withCredentials"in t&&(t.withCredentials=!0),this.requestTimeout&&(t.timeout=this.requestTimeout),this.hasXDR()?(t.onload=function(){n.onLoad()},t.onerror=function(){n.onError(t.responseText)}):t.onreadystatechange=function(){if(2===t.readyState)try{var e=t.getResponseHeader("Content-Type");n.supportsBinary&&"application/octet-stream"===e&&(t.responseType="arraybuffer")}catch(e){}4===t.readyState&&(200===t.status||1223===t.status?n.onLoad():setTimeout((function(){n.onError(t.status)}),0))},Kr("xhr data %s",this.data),t.send(this.data)}catch(e){return void setTimeout((function(){n.onError(e)}),0)}"undefined"!=typeof document&&(this.index=Qr.requestsCount++,Qr.requests[this.index]=this)},Qr.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},Qr.prototype.onData=function(e){this.emit("data",e),this.onSuccess()},Qr.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)},Qr.prototype.cleanup=function(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=Jr:this.xhr.onreadystatechange=Jr,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete Qr.requests[this.index],this.xhr=null}},Qr.prototype.onLoad=function(){var e;try{var t;try{t=this.xhr.getResponseHeader("Content-Type")}catch(e){}e="application/octet-stream"===t&&this.xhr.response||this.xhr.responseText}catch(e){this.onError(e)}null!=e&&this.onData(e)},Qr.prototype.hasXDR=function(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR},Qr.prototype.abort=function(){this.cleanup()},Qr.requestsCount=0,Qr.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Gr);else if("function"==typeof addEventListener){var Xr="onpagehide"in self?"pagehide":"unload";addEventListener(Xr,Gr,!1)}function Gr(){for(var e in Qr.requests)Qr.requests.hasOwnProperty(e)&&Qr.requests[e].abort()}var Zr,eo=Dr,to=so,no=/\n/g,ro=/\\n/g;function oo(){}function io(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==Z?Z:{}}function so(e){if(eo.call(this,e),this.query=this.query||{},!Zr){var t=io();Zr=t.___eio=t.___eio||[]}this.index=Zr.length;var n=this;Zr.push((function(e){n.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){n.script&&(n.script.onerror=oo)}),!1)}yr(so,eo),so.prototype.supportsBinary=!1,so.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),eo.prototype.doClose.call(this)},so.prototype.doPoll=function(){var e=this,t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri(),t.onerror=function(t){e.onError("jsonp poll error",t)};var n=document.getElementsByTagName("script")[0];n?n.parentNode.insertBefore(t,n):(document.head||document.body).appendChild(t),this.script=t,"undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout((function(){var e=document.createElement("iframe");document.body.appendChild(e),document.body.removeChild(e)}),100)},so.prototype.doWrite=function(e,t){var n=this;if(!this.form){var r,o=document.createElement("form"),i=document.createElement("textarea"),s=this.iframeId="eio_iframe_"+this.index;o.className="socketio",o.style.position="absolute",o.style.top="-1000px",o.style.left="-1000px",o.target=s,o.method="POST",o.setAttribute("accept-charset","utf-8"),i.name="d",o.appendChild(i),document.body.appendChild(o),this.form=o,this.area=i}function a(){c(),t()}function c(){if(n.iframe)try{n.form.removeChild(n.iframe)}catch(e){n.onError("jsonp polling iframe removal error",e)}try{var e='<iframe src="javascript:0" name="'+n.iframeId+'">';r=document.createElement(e)}catch(e){(r=document.createElement("iframe")).name=n.iframeId,r.src="javascript:0"}r.id=n.iframeId,n.form.appendChild(r),n.iframe=r}this.form.action=this.uri(),c(),e=e.replace(ro,"\\\n"),this.area.value=e.replace(no,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&a()}:this.iframe.onload=a};var ao,co,lo=ee(Object.freeze({__proto__:null,default:{}})),uo=fr,ho=Bn,po=gr,fo=yr,mo=kr,go=Ar.exports("engine.io-client:websocket");if("undefined"!=typeof WebSocket)ao=WebSocket;else if("undefined"!=typeof self)ao=self.WebSocket||self.MozWebSocket;else try{co=lo}catch(e){}var yo=ao||co,vo=bo;function bo(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=ao&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(yo=co),uo.call(this,e)}fo(bo,uo),bo.prototype.name="websocket",bo.prototype.supportsBinary=!0,bo.prototype.doOpen=function(){if(this.check()){var e=this.uri(),t=this.protocols,n={agent:this.agent,perMessageDeflate:this.perMessageDeflate};n.pfx=this.pfx,n.key=this.key,n.passphrase=this.passphrase,n.cert=this.cert,n.ca=this.ca,n.ciphers=this.ciphers,n.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(n.headers=this.extraHeaders),this.localAddress&&(n.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?t?new yo(e,t):new yo(e):new yo(e,t,n)}catch(e){return this.emit("error",e)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},bo.prototype.addEventListeners=function(){var e=this;this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(){e.onClose()},this.ws.onmessage=function(t){e.onData(t.data)},this.ws.onerror=function(t){e.onError("websocket error",t)}},bo.prototype.write=function(e){var t=this;this.writable=!1;for(var n=e.length,r=0,o=n;r<o;r++)!function(e){ho.encodePacket(e,t.supportsBinary,(function(r){if(!t.usingBrowserWebSocket){var o={};if(e.options&&(o.compress=e.options.compress),t.perMessageDeflate)("string"==typeof r?Buffer.byteLength(r):r.length)<t.perMessageDeflate.threshold&&(o.compress=!1)}try{t.usingBrowserWebSocket?t.ws.send(r):t.ws.send(r,o)}catch(e){go("websocket closed before onclose event")}--n||i()}))}(e[r]);function i(){t.emit("flush"),setTimeout((function(){t.writable=!0,t.emit("drain")}),0)}},bo.prototype.onClose=function(){uo.prototype.onClose.call(this)},bo.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},bo.prototype.uri=function(){var e=this.query||{},t=this.secure?"wss":"ws",n="";return this.port&&("wss"===t&&443!==Number(this.port)||"ws"===t&&80!==Number(this.port))&&(n=":"+this.port),this.timestampRequests&&(e[this.timestampParam]=mo()),this.supportsBinary||(e.b64=1),(e=po.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e},bo.prototype.check=function(){return!(!yo||"__initialize"in yo&&this.name===bo.prototype.name)};var wo=Tn,_o=Pn.exports,Co=to,So=vo;Rn.polling=function(e){var t=!1,n=!1,r=!1!==e.jsonp;if("undefined"!=typeof location){var o="https:"===location.protocol,i=location.port;i||(i=o?443:80),t=e.hostname!==location.hostname||i!==e.port,n=e.secure!==o}if(e.xdomain=t,e.xscheme=n,"open"in new wo(e)&&!e.forceJSONP)return new _o(e);if(!r)throw new Error("JSONP disabled");return new Co(e)},Rn.websocket=So;var ko=[].indexOf,Ao=function(e,t){if(ko)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},Eo=Rn,Io=hr.exports,xo=Ar.exports("engine.io-client:socket"),Ro=Ao,Oo=Bn,Fo=Vt,To=gr,Po=Bo;function Bo(e,t){if(!(this instanceof Bo))return new Bo(e,t);t=t||{},e&&"object"==typeof e&&(t=e,e=null),e?(e=Fo(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=Fo(t.host).host),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.agent=t.agent||!1,this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=t.query||{},"string"==typeof this.query&&(this.query=To.decode(this.query)),this.upgrade=!1!==t.upgrade,this.path=(t.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!t.forceJSONP,this.jsonp=!1!==t.jsonp,this.forceBase64=!!t.forceBase64,this.enablesXDR=!!t.enablesXDR,this.timestampParam=t.timestampParam||"t",this.timestampRequests=t.timestampRequests,this.transports=t.transports||["polling","websocket"],this.transportOptions=t.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=t.policyPort||843,this.rememberUpgrade=t.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=t.onlyBinaryUpgrades,this.perMessageDeflate=!1!==t.perMessageDeflate&&(t.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=t.pfx||null,this.key=t.key||null,this.passphrase=t.passphrase||null,this.cert=t.cert||null,this.ca=t.ca||null,this.ciphers=t.ciphers||null,this.rejectUnauthorized=void 0===t.rejectUnauthorized||t.rejectUnauthorized,this.forceNode=!!t.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(t.extraHeaders&&Object.keys(t.extraHeaders).length>0&&(this.extraHeaders=t.extraHeaders),t.localAddress&&(this.localAddress=t.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}Bo.priorWebsocketSuccess=!1,Io(Bo.prototype),Bo.protocol=Oo.protocol,Bo.Socket=Bo,Bo.Transport=fr,Bo.transports=Rn,Bo.parser=Bn,Bo.prototype.createTransport=function(e){xo('creating transport "%s"',e);var t=function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}(this.query);t.EIO=Oo.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new Eo[e]({query:t,socket:this,agent:n.agent||this.agent,hostname:n.hostname||this.hostname,port:n.port||this.port,secure:n.secure||this.secure,path:n.path||this.path,forceJSONP:n.forceJSONP||this.forceJSONP,jsonp:n.jsonp||this.jsonp,forceBase64:n.forceBase64||this.forceBase64,enablesXDR:n.enablesXDR||this.enablesXDR,timestampRequests:n.timestampRequests||this.timestampRequests,timestampParam:n.timestampParam||this.timestampParam,policyPort:n.policyPort||this.policyPort,pfx:n.pfx||this.pfx,key:n.key||this.key,passphrase:n.passphrase||this.passphrase,cert:n.cert||this.cert,ca:n.ca||this.ca,ciphers:n.ciphers||this.ciphers,rejectUnauthorized:n.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:n.perMessageDeflate||this.perMessageDeflate,extraHeaders:n.extraHeaders||this.extraHeaders,forceNode:n.forceNode||this.forceNode,localAddress:n.localAddress||this.localAddress,requestTimeout:n.requestTimeout||this.requestTimeout,protocols:n.protocols||void 0,isReactNative:this.isReactNative})},Bo.prototype.open=function(){var e;if(this.rememberUpgrade&&Bo.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length){var t=this;return void setTimeout((function(){t.emit("error","No transports available")}),0)}e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)},Bo.prototype.setTransport=function(e){xo("setting transport %s",e.name);var t=this;this.transport&&(xo("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",(function(){t.onDrain()})).on("packet",(function(e){t.onPacket(e)})).on("error",(function(e){t.onError(e)})).on("close",(function(){t.onClose("transport close")}))},Bo.prototype.probe=function(e){xo('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),n=!1,r=this;function o(){if(r.onlyBinaryUpgrades){var o=!this.supportsBinary&&r.transport.supportsBinary;n=n||o}n||(xo('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(function(o){if(!n)if("pong"===o.type&&"probe"===o.data){if(xo('probe transport "%s" pong',e),r.upgrading=!0,r.emit("upgrading",t),!t)return;Bo.priorWebsocketSuccess="websocket"===t.name,xo('pausing current transport "%s"',r.transport.name),r.transport.pause((function(){n||"closed"!==r.readyState&&(xo("changing transport and sending upgrade packet"),u(),r.setTransport(t),t.send([{type:"upgrade"}]),r.emit("upgrade",t),t=null,r.upgrading=!1,r.flush())}))}else{xo('probe transport "%s" failed',e);var i=new Error("probe error");i.transport=t.name,r.emit("upgradeError",i)}})))}function i(){n||(n=!0,u(),t.close(),t=null)}function s(n){var o=new Error("probe error: "+n);o.transport=t.name,i(),xo('probe transport "%s" failed because of error: %s',e,n),r.emit("upgradeError",o)}function a(){s("transport closed")}function c(){s("socket closed")}function l(e){t&&e.name!==t.name&&(xo('"%s" works - aborting "%s"',e.name,t.name),i())}function u(){t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",a),r.removeListener("close",c),r.removeListener("upgrading",l)}Bo.priorWebsocketSuccess=!1,t.once("open",o),t.once("error",s),t.once("close",a),this.once("close",c),this.once("upgrading",l),t.open()},Bo.prototype.onOpen=function(){if(xo("socket open"),this.readyState="open",Bo.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){xo("starting upgrade probes");for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},Bo.prototype.onPacket=function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(xo('socket receive: type "%s", data "%s"',e.type,e.data),this.emit("packet",e),this.emit("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emit("data",e.data),this.emit("message",e.data)}else xo('packet received with socket readyState "%s"',this.readyState)},Bo.prototype.onHandshake=function(e){this.emit("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.onOpen(),"closed"!==this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},Bo.prototype.onHeartbeat=function(e){clearTimeout(this.pingTimeoutTimer);var t=this;t.pingTimeoutTimer=setTimeout((function(){"closed"!==t.readyState&&t.onClose("ping timeout")}),e||t.pingInterval+t.pingTimeout)},Bo.prototype.setPing=function(){var e=this;clearTimeout(e.pingIntervalTimer),e.pingIntervalTimer=setTimeout((function(){xo("writing ping packet - expecting pong within %sms",e.pingTimeout),e.ping(),e.onHeartbeat(e.pingTimeout)}),e.pingInterval)},Bo.prototype.ping=function(){var e=this;this.sendPacket("ping",(function(){e.emit("ping")}))},Bo.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},Bo.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(xo("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},Bo.prototype.write=Bo.prototype.send=function(e,t,n){return this.sendPacket("message",e,t,n),this},Bo.prototype.sendPacket=function(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var o={type:e,data:t,options:n};this.emit("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}},Bo.prototype.close=function(){if("opening"===this.readyState||"open"===this.readyState){this.readyState="closing";var e=this;this.writeBuffer.length?this.once("drain",(function(){this.upgrading?r():t()})):this.upgrading?r():t()}function t(){e.onClose("forced close"),xo("socket closing - telling transport to close"),e.transport.close()}function n(){e.removeListener("upgrade",n),e.removeListener("upgradeError",n),t()}function r(){e.once("upgrade",n),e.once("upgradeError",n)}return this},Bo.prototype.onError=function(e){xo("socket error %j",e),Bo.priorWebsocketSuccess=!1,this.emit("error",e),this.onClose("transport error",e)},Bo.prototype.onClose=function(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){xo('socket close with reason: "%s"',e);clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",e,t),this.writeBuffer=[],this.prevBufferLen=0}},Bo.prototype.filterUpgrades=function(e){for(var t=[],n=0,r=e.length;n<r;n++)~Ro(this.transports,e[n])&&t.push(e[n]);return t},xn.exports=Po,xn.exports.parser=Bn;var jo={exports:{}},Uo={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(Uo);var Mo=function(e,t){for(var n=[],r=(t=t||0)||0;r<e.length;r++)n[r-t]=e[r];return n};var No=function(e,t,n){return e.on(t,n),{destroy:function(){e.removeListener(t,n)}}};var Lo=[].slice,Do=function(e,t){if("string"==typeof t&&(t=e[t]),"function"!=typeof t)throw new Error("bind() requires a function");var n=Lo.call(arguments,2);return function(){return t.apply(e,n.concat(Lo.call(arguments)))}};!function(e,t){var n=rn,r=Uo.exports,o=Mo,i=No,s=Do,a=Wt.exports("socket.io-client:socket"),c=gr,l=qn;e.exports=p;var u={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},h=r.prototype.emit;function p(e,t,n){this.io=e,this.nsp=t,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},n&&n.query&&(this.query=n.query),this.io.autoConnect&&this.open()}r(p.prototype),p.prototype.subEvents=function(){if(!this.subs){var e=this.io;this.subs=[i(e,"open",s(this,"onopen")),i(e,"packet",s(this,"onpacket")),i(e,"close",s(this,"onclose"))]}},p.prototype.open=p.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},p.prototype.send=function(){var e=o(arguments);return e.unshift("message"),this.emit.apply(this,e),this},p.prototype.emit=function(e){if(u.hasOwnProperty(e))return h.apply(this,arguments),this;var t=o(arguments),r={type:(void 0!==this.flags.binary?this.flags.binary:l(t))?n.BINARY_EVENT:n.EVENT,data:t,options:{}};return r.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof t[t.length-1]&&(a("emitting packet with ack id %d",this.ids),this.acks[this.ids]=t.pop(),r.id=this.ids++),this.connected?this.packet(r):this.sendBuffer.push(r),this.flags={},this},p.prototype.packet=function(e){e.nsp=this.nsp,this.io.packet(e)},p.prototype.onopen=function(){if(a("transport is open - connecting"),"/"!==this.nsp)if(this.query){var e="object"==typeof this.query?c.encode(this.query):this.query;a("sending connect packet with query %s",e),this.packet({type:n.CONNECT,query:e})}else this.packet({type:n.CONNECT})},p.prototype.onclose=function(e){a("close (%s)",e),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",e)},p.prototype.onpacket=function(e){var t=e.nsp===this.nsp,r=e.type===n.ERROR&&"/"===e.nsp;if(t||r)switch(e.type){case n.CONNECT:this.onconnect();break;case n.EVENT:case n.BINARY_EVENT:this.onevent(e);break;case n.ACK:case n.BINARY_ACK:this.onack(e);break;case n.DISCONNECT:this.ondisconnect();break;case n.ERROR:this.emit("error",e.data)}},p.prototype.onevent=function(e){var t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?h.apply(this,t):this.receiveBuffer.push(t)},p.prototype.ack=function(e){var t=this,r=!1;return function(){if(!r){r=!0;var i=o(arguments);a("sending ack %j",i),t.packet({type:l(i)?n.BINARY_ACK:n.ACK,id:e,data:i})}}},p.prototype.onack=function(e){var t=this.acks[e.id];"function"==typeof t?(a("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):a("bad ack %s",e.id)},p.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},p.prototype.emitBuffered=function(){var e;for(e=0;e<this.receiveBuffer.length;e++)h.apply(this,this.receiveBuffer[e]);for(this.receiveBuffer=[],e=0;e<this.sendBuffer.length;e++)this.packet(this.sendBuffer[e]);this.sendBuffer=[]},p.prototype.ondisconnect=function(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},p.prototype.destroy=function(){if(this.subs){for(var e=0;e<this.subs.length;e++)this.subs[e].destroy();this.subs=null}this.io.destroy(this)},p.prototype.close=p.prototype.disconnect=function(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:n.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},p.prototype.compress=function(e){return this.flags.compress=e,this},p.prototype.binary=function(e){return this.flags.binary=e,this}}(jo);var qo=$o;function $o(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}$o.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},$o.prototype.reset=function(){this.attempts=0},$o.prototype.setMin=function(e){this.ms=e},$o.prototype.setMax=function(e){this.max=e},$o.prototype.setJitter=function(e){this.jitter=e};var Ho=xn.exports,Vo=jo.exports,Wo=Uo.exports,zo=rn,Ko=No,Jo=Do,Yo=Wt.exports("socket.io-client:manager"),Qo=Ao,Xo=qo,Go=Object.prototype.hasOwnProperty,Zo=ei;function ei(e,t){if(!(this instanceof ei))return new ei(e,t);e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.nsps={},this.subs=[],this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new Xo({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this.readyState="closed",this.uri=e,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var n=t.parser||zo;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}ei.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)Go.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},ei.prototype.updateSocketIds=function(){for(var e in this.nsps)Go.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},ei.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},Wo(ei.prototype),ei.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},ei.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},ei.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},ei.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},ei.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},ei.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},ei.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},ei.prototype.open=ei.prototype.connect=function(e,t){if(Yo("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;Yo("opening %s",this.uri),this.engine=Ho(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var o=Ko(n,"open",(function(){r.onopen(),e&&e()})),i=Ko(n,"error",(function(t){if(Yo("connect_error"),r.cleanup(),r.readyState="closed",r.emitAll("connect_error",t),e){var n=new Error("Connection error");n.data=t,e(n)}else r.maybeReconnectOnOpen()}));if(!1!==this._timeout){var s=this._timeout;Yo("connect attempt will timeout after %d",s);var a=setTimeout((function(){Yo("connect attempt timed out after %d",s),o.destroy(),n.close(),n.emit("error","timeout"),r.emitAll("connect_timeout",s)}),s);this.subs.push({destroy:function(){clearTimeout(a)}})}return this.subs.push(o),this.subs.push(i),this},ei.prototype.onopen=function(){Yo("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(Ko(e,"data",Jo(this,"ondata"))),this.subs.push(Ko(e,"ping",Jo(this,"onping"))),this.subs.push(Ko(e,"pong",Jo(this,"onpong"))),this.subs.push(Ko(e,"error",Jo(this,"onerror"))),this.subs.push(Ko(e,"close",Jo(this,"onclose"))),this.subs.push(Ko(this.decoder,"decoded",Jo(this,"ondecoded")))},ei.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},ei.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},ei.prototype.ondata=function(e){this.decoder.add(e)},ei.prototype.ondecoded=function(e){this.emit("packet",e)},ei.prototype.onerror=function(e){Yo("error",e),this.emitAll("error",e)},ei.prototype.socket=function(e,t){var n=this.nsps[e];if(!n){n=new Vo(this,e,t),this.nsps[e]=n;var r=this;n.on("connecting",o),n.on("connect",(function(){n.id=r.generateId(e)})),this.autoConnect&&o()}function o(){~Qo(r.connecting,n)||r.connecting.push(n)}return n},ei.prototype.destroy=function(e){var t=Qo(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},ei.prototype.packet=function(e){Yo("writing packet %j",e);var t=this;e.query&&0===e.type&&(e.nsp+="?"+e.query),t.encoding?t.packetBuffer.push(e):(t.encoding=!0,this.encoder.encode(e,(function(n){for(var r=0;r<n.length;r++)t.engine.write(n[r],e.options);t.encoding=!1,t.processPacketQueue()})))},ei.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},ei.prototype.cleanup=function(){Yo("cleanup");for(var e=this.subs.length,t=0;t<e;t++){this.subs.shift().destroy()}this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},ei.prototype.close=ei.prototype.disconnect=function(){Yo("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},ei.prototype.onclose=function(e){Yo("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()},ei.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var e=this;if(this.backoff.attempts>=this._reconnectionAttempts)Yo("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();Yo("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var n=setTimeout((function(){e.skipReconnect||(Yo("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open((function(t){t?(Yo("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(Yo("reconnect success"),e.onreconnect())})))}),t);this.subs.push({destroy:function(){clearTimeout(n)}})}},ei.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)},function(e,t){var n=nn,r=rn,o=Zo,i=Wt.exports("socket.io-client");e.exports=t=a;var s=t.managers={};function a(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var r,a=n(e),c=a.source,l=a.id,u=a.path,h=s[l]&&u in s[l].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||h?(i("ignoring socket cache for %s",c),r=o(c,t)):(s[l]||(i("new io instance for %s",c),s[l]=o(c,t)),r=s[l]),a.query&&!t.query&&(t.query=a.query),r.socket(a.path,t)}t.protocol=r.protocol,t.connect=a,t.Manager=Zo,t.Socket=jo.exports}(qt,qt.exports);var ti=qt.exports;var ni={exports:{}};ni.exports=function(){function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){if(!a&&te)return te(s);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,(function(e){return o(t[s][1][e]||e)}),l,l.exports,e,t,n,r)}return n[s].exports}for(var i=te,s=0;s<r.length;s++)o(r[s]);return o}return e}()({1:[function(e,t,n){(function(n,r){(function(){var o=e("events").EventEmitter,i=e("./store"),s=e("mqtt-packet"),a=e("readable-stream").Writable,c=e("inherits"),l=e("reinterval"),u=e("./validations"),h=e("xtend"),p=e("debug")("mqttjs:client"),f=n?n.nextTick:function(e){setTimeout(e,0)},d=r.setImmediate||function(e){f(e)},m={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},g=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],y={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(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function b(e,t,n){p("sendPacket :: packet: %O",t),p("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),p("sendPacket :: writing to stream");var r=s.writeToStream(t,e.stream,e.options);p("sendPacket :: writeToStream result %s",r),!r&&n?(p("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",n)):n&&(p("sendPacket :: invoking cb"),n())}function w(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){e&&(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])})))}function C(e,t,n,r){p("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd),e.outgoingStore.put(t,(function(o){if(o)return n&&n(o);r(),b(e,t,n)}))}function S(e){p("nop ::",e)}function k(e,t){var n,r=this;if(!(this instanceof k))return new k(e,t);for(n in this.options=t||{},m)void 0===this.options[n]?this.options[n]=m[n]:this.options[n]=t[n];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:v(),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;function t(){var n=e.shift();p("deliver :: entry %o",n);var o=null;n&&(o=n.packet,p("deliver :: call _sendPacket for %o",o),r._sendPacket(o,(function(e){n.cb&&n.cb(e),t()})))}p("connect :: sending queued packets"),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!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null),p("close :: calling _setupReconnect"),this._setupReconnect()})),o.call(this),p("MqttClient :: setting up stream"),this._setupStream()}c(k,o),k.prototype._setupStream=function(){var e,t=this,n=new a,r=s.parser(this.options),o=null,i=[];function c(){if(i.length)f(l);else{var e=o;o=null,e()}}function l(){p("work :: getting next packet in queue");var e=i.shift();if(e)p("work :: packet pulled from queue"),t._handlePacket(e,c);else{p("work :: no packets in queue");var n=o;o=null,p("work :: done flag is %s",!!n),n&&n()}}function u(e){p("streamErrorHandler :: error",e.message),g.includes(e.code)?(p("streamErrorHandler :: emitting error"),t.emit("error",e)):S(e)}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),r.on("packet",(function(e){p("parser :: on packet push to packets array."),i.push(e)})),n._write=function(e,t,n){o=n,p("writable stream :: parsing buffer"),r.parse(e),l()},p("_setupStream :: pipe stream to writable stream"),this.stream.pipe(n),this.stream.on("error",u),this.stream.on("close",(function(){p("(%s)stream :: on close",t.options.clientId),_(t.outgoing),p("stream: emit close to MqttClient"),t.emit("close")})),p("_setupStream: sending packet `connect`"),(e=Object.create(this.options)).cmd="connect",b(this,e),r.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;this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket&&b(this,h({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 n=this.options;if(5===n.protocolVersion&&n.properties&&n.properties.maximumPacketSize&&n.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,n,r){var o;p("publish :: message `%s` to topic `%s`",t,e);var i=this.options;if("function"==typeof n&&(r=n,n=null),n=h({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;switch(o={cmd:"publish",topic:e,payload:t,qos:n.qos,retain:n.retain,messageId:this._nextId(),dup:n.dup},5===i.protocolVersion&&(o.properties=n.properties,(!i.properties&&o.properties&&o.properties.topicAlias||n.properties&&i.properties&&(n.properties.topicAlias&&i.properties.topicAliasMaximum&&n.properties.topicAlias>i.properties.topicAliasMaximum||!i.properties.topicAliasMaximum&&n.properties.topicAlias))&&delete o.properties.topicAlias),p("publish :: qos",n.qos),n.qos){case 1:case 2:this.outgoing[o.messageId]={volatile:!1,cb:r||S},this._storeProcessing?(p("_storeProcessing enabled"),this._packetIdsDuringStoreProcessing[o.messageId]=!1,this._storePacket(o,void 0,n.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,void 0,n.cbStorePut));break;default:this._storeProcessing?(p("_storeProcessing enabled"),this._storePacket(o,r,n.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,r,n.cbStorePut))}return this},k.prototype.subscribe=function(){for(var e,t=new Array(arguments.length),n=0;n<arguments.length;n++)t[n]=arguments[n];var r,o=[],i=t.shift(),s=i.resubscribe,a=t.pop()||S,c=t.pop(),l=this,f=this.options.protocolVersion;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof a&&(c=a,a=S),null!==(r=u.validateTopics(i)))return d(a,new Error("Invalid topic "+r)),this;if(this._checkDisconnecting(a))return p("subscribe: discconecting true"),this;var m={qos:0};if(5===f&&(m.nl=!1,m.rap=!1,m.rh=0),c=h(m,c),Array.isArray(i)?i.forEach((function(e){if(p("subscribe: array topic %s",e),!l._resubscribeTopics.hasOwnProperty(e)||l._resubscribeTopics[e].qos<c.qos||s){var t={topic:e,qos:c.qos};5===f&&(t.nl=c.nl,t.rap=c.rap,t.rh=c.rh,t.properties=c.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),!l._resubscribeTopics.hasOwnProperty(e)||l._resubscribeTopics[e].qos<i[e].qos||s){var t={topic:e,qos:i[e].qos};5===f&&(t.nl=i[e].nl,t.rap=i[e].rap,t.rh=i[e].rh,t.properties=c.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()},c.properties&&(e.properties=c.properties),o.length){if(this.options.resubscribe){p("subscribe :: resubscribe true");var g=[];o.forEach((function(e){if(l.options.reconnectPeriod>0){var t={qos:e.qos};5===f&&(t.nl=e.nl||!1,t.rap=e.rap||!1,t.rh=e.rh||0,t.properties=e.properties),l._resubscribeTopics[e.topic]=t,g.push(e.topic)}})),l.messageIdToTopic[e.messageId]=g}return this.outgoing[e.messageId]={volatile:!0,cb:function(e,t){if(!e)for(var n=t.granted,r=0;r<n.length;r+=1)o[r].qos=n[r];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,n=new Array(arguments.length),r=0;r<arguments.length;r++)n[r]=arguments[r];var o=n.shift(),i=n.pop()||S,s=n.pop();return"string"==typeof o&&(o=[o]),"function"!=typeof i&&(s=i,i=S),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,n){var r=this;function o(){p("end :: closeStores: closing incoming and outgoing stores"),r.disconnected=!0,r.incomingStore.close((function(e){r.outgoingStore.close((function(t){if(p("end :: closeStores: emitting end"),r.emit("end"),n){let r=e||t;p("end :: closeStores: invoking callback with args"),n(r)}}))})),r._deferredReconnect&&r._deferredReconnect()}function i(){p("end :: (%s) :: finish :: calling _cleanUp with force %s",r.options.clientId,e),r._cleanUp(e,(()=>{p("end :: finish :: calling process.nextTick on closeStores"),f(o.bind(r))}),t)}return p("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(n=t||S,t=e,e=!1,"object"!=typeof t&&(n=t,t=null,"function"!=typeof n&&(n=S))),"object"!=typeof t&&(n=t,t=null),p("end :: cb? %s",!!n),n=n||S,this.disconnecting?(n(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(p("end :: (%s) :: calling finish in 10ms once outgoing is empty",r.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(p("end :: (%s) :: immediately calling finish",r.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,n=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=n:n(),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 n=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&&w(this.outgoing),p("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{var r=h({cmd:"disconnect"},n);p("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(r,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,n){if(p("_sendPacket :: (%s) :: start",this.options.clientId),n=n||S,!this.connected)return p("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,n);switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void C(this,e,t,n);default:return void b(this,e,t)}switch(e.qos){case 2:case 1:C(this,e,t,n);break;default:b(this,e,t)}p("_sendPacket :: (%s) :: end",this.options.clientId)},k.prototype._storePacket=function(e,t,n){p("_storePacket :: packet: %o",e),p("_storePacket :: cb? %s",!!t),n=n||S,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);n()}))):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=l((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,n=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===n)this.reconnecting=!1,this._onConnect(e);else if(n>0){var r=new Error("Connection refused: "+y[n]);r.code=n,this.emit("error",r)}},k.prototype._handlePublish=function(e,t){p("_handlePublish: packet %o",e),t=void 0!==t?t:S;var n=e.topic.toString(),r=e.payload,o=e.qos,i=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];switch(p("_handlePublish: qos %d",o),o){case 2:a.customHandleAcks(n,r,e,(function(n,r){return n instanceof Error||(r=n,n=null),n?s.emit("error",n):-1===c.indexOf(r)?s.emit("error",new Error("Wrong reason code for pubrec")):void(r?s._sendPacket({cmd:"pubrec",messageId:i,reasonCode:r},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:i},t)})))}));break;case 1:a.customHandleAcks(n,r,e,(function(o,a){return o instanceof Error||(a=o,o=null),o?s.emit("error",o):-1===c.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",n,r,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",n,r,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,n=e.messageId,r=e.cmd,o=null,i=this.outgoing[n]?this.outgoing[n].cb:null,s=this;if(i){switch(p("_handleAck :: packet type",r),r){case"pubcomp":case"puback":var a=e.reasonCode;a&&a>0&&16!==a&&((t=new Error("Publish error: "+y[a])).code=a,i(t,e)),delete this.outgoing[n],this.outgoingStore.del(e,i);break;case"pubrec":o={cmd:"pubrel",qos:2,messageId:n};var c=e.reasonCode;c&&c>0&&16!==c?((t=new Error("Publish error: "+y[c])).code=c,i(t,e)):this._sendPacket(o);break;case"suback":delete this.outgoing[n];for(var l=0;l<e.granted.length;l++)if(0!=(128&e.granted[l])){var u=this.messageIdToTopic[n];u&&u.forEach((function(e){delete s._resubscribeTopics[e]}))}i(null,e);break;case"unsuback":delete this.outgoing[n],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:S;var n=e.messageId,r=this,o={cmd:"pubcomp",messageId:n};r.incomingStore.get(e,(function(e,n){e?r._sendPacket(o,t):(r.emit("message",n.topic,n.payload,n),r.handleMessage(n,(function(e){if(e)return t(e);r.incomingStore.del(n,S),r._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 n=0;n<t.length;n++){var r={};r[t[n]]=this._resubscribeTopics[t[n]],r.resubscribe=!0,this.subscribe(r,{properties:r[t[n]].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,n()}function n(){var r=t.outgoingStore.createStream();function o(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function i(){r.destroy(),r=null,o()}function s(){if(r){t._storeProcessing=!0;var e,n=r.read(1);n?t._packetIdsDuringStoreProcessing[n.messageId]?s():t.disconnecting||t.reconnectTimer?r.destroy&&r.destroy():(e=t.outgoing[n.messageId]?t.outgoing[n.messageId].cb:null,t.outgoing[n.messageId]={volatile:!1,cb:function(t,n){e&&e(t,n),s()}},t._packetIdsDuringStoreProcessing[n.messageId]=!0,t._sendPacket(n)):r.once("readable",s)}}t.once("close",i),r.on("error",(function(e){o(),t.removeListener("close",i),t.emit("error",e)})),r.on("end",(function(){var r=!0;for(var s in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[s]){r=!1;break}r?(o(),t.removeListener("close",i),t.emit("connect",e)):n()})),s()}},t.exports=k}).call(this)}).call(this,e("_process"),void 0!==Z?Z:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./store":7,"./validations":8,_process:32,debug:15,events:19,inherits:21,"mqtt-packet":24,"readable-stream":51,reinterval:52,xtend:61}],2:[function(e,t,n){(function(n){(function(){var r,o,i,s=e("readable-stream").Transform,a=e("duplexify"),c=!1;function l(){var e=new s;return e._write=function(e,t,n){r.sendSocketMessage({data:e.buffer,success:function(){n()},fail:function(){n(new Error)}})},e._flush=function(e){r.closeSocket({success:function(){e()}})},e}function u(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function h(e,t){var n="alis"===e.protocol?"wss":"ws",r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function p(){c||(c=!0,r.onSocketOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),r.onSocketMessage((function(e){if("string"==typeof e.data){var t=n.from(e.data,"base64");o.push(t)}else{var r=new FileReader;r.addEventListener("load",(function(){var e=r.result;e=e instanceof ArrayBuffer?n.from(e):n.from(e,"utf8"),o.push(e)})),r.readAsArrayBuffer(e.data)}})),r.onSocketClose((function(){i.end(),i.destroy()})),r.onSocketError((function(e){i.destroy(e)})))}function f(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";u(t);var s=h(t,e);return(r=t.my).connectSocket({url:s,protocols:n}),o=l(),i=a.obj(),p(),i}t.exports=f}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14,duplexify:17,"readable-stream":51}],3:[function(e,t,n){var r=e("net"),o=e("debug")("mqttjs:tcp");function i(e,t){var n,i;return t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost",n=t.port,i=t.hostname,o("port %d and host %s",n,i),r.createConnection(n,i)}t.exports=i},{debug:15,net:13}],4:[function(e,t,n){var r=e("tls"),o=e("debug")("mqttjs:tls");function i(e,t){var n;function i(r){t.rejectUnauthorized&&e.emit("error",r),n.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),(n=r.connect(t)).on("secureConnect",(function(){t.rejectUnauthorized&&!n.authorized?n.emit("error",new Error("TLS not authorized")):n.removeListener("error",i)})),n.on("error",i),n}t.exports=i},{debug:15,tls:13}],5:[function(e,t,n){(function(n,r){(function(){const o=e("ws"),i=e("debug")("mqttjs:ws"),s=e("duplexify"),a=e("readable-stream").Transform;let c=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];const l=void 0!==n&&"browser"===n.title||"function"==typeof __webpack_require__;function u(e,t){let n=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}function h(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={}),l||"wss"!==e.protocol||c.forEach((function(n){e.hasOwnProperty(n)&&!e.wsOptions.hasOwnProperty(n)&&(t.wsOptions[n]=e[n])})),t}function p(e){let t=h(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}function f(e,t,n){i("createWebSocket"),i("protocol: "+n.protocolId+" "+n.protocolVersion);const r="MQIsdp"===n.protocolId&&3===n.protocolVersion?"mqttv3.1":"mqtt";return i("creating new Websocket for url: "+t+" and protocol: "+r),new o(t,[r],n.wsOptions)}function d(e,t){const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";let r=u(t,e),o=new WebSocket(r,[n]);return o.binaryType="arraybuffer",o}function m(e,t){i("streamBuilder");let n=h(t);const r=u(n,e);let s=f(e,r,n),a=o.createWebSocketStream(s,n.wsOptions);return a.url=r,s.on("close",(()=>{a.destroy()})),a}function g(e,t){let n;i("browserStreamBuilder");const o=p(t).browserBufferSize||524288,c=t.browserBufferTimeout||1e3,l=!t.objectMode;let u=d(e,t),h=m(t,_,C);t.objectMode||(h._writev=w),h.on("close",(()=>{u.close()}));const f=void 0!==u.addEventListener;function m(e,t,n){let r=new a({objectModeMode:e.objectMode});return r._write=t,r._flush=n,r}function g(){n.setReadable(h),n.setWritable(h),n.emit("connect")}function y(){n.end(),n.destroy()}function v(e){n.destroy(e)}function b(e){let t=e.data;t=t instanceof ArrayBuffer?r.from(t):r.from(t,"utf8"),h.push(t)}function w(e,t){const n=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?n[t]=r.from(e[t],"utf8"):n[t]=e[t].chunk;this._write(r.concat(n),"binary",t)}function _(e,t,n){u.bufferedAmount>o&&setTimeout(_,c,e,t,n),l&&"string"==typeof e&&(e=r.from(e,"utf8"));try{u.send(e)}catch(e){return n(e)}n()}function C(e){u.close(),e()}return u.readyState===u.OPEN?n=h:(n=n=s(void 0,void 0,t),t.objectMode||(n._writev=w),f?u.addEventListener("open",g):u.onopen=g),n.socket=u,f?(u.addEventListener("close",y),u.addEventListener("error",v),u.addEventListener("message",b)):(u.onclose=y,u.onerror=v,u.onmessage=b),n}t.exports=l?g:m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:32,buffer:14,debug:15,duplexify:17,"readable-stream":51,ws:60}],6:[function(e,t,n){(function(n){(function(){var r,o,i,s=e("readable-stream").Transform,a=e("duplexify");function c(){var e=new s;return e._write=function(e,t,n){r.send({data:e.buffer,success:function(){n()},fail:function(e){n(new Error(e))}})},e._flush=function(e){r.close({success:function(){e()}})},e}function l(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function u(e,t){var n="wxs"===e.protocol?"wss":"ws",r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function h(){r.onOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),r.onMessage((function(e){var t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),o.push(t)})),r.onClose((function(){i.end(),i.destroy()})),r.onError((function(e){i.destroy(new Error(e.errMsg))}))}function p(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";l(t);var s=u(t,e);r=wx.connectSocket({url:s,protocols:[n]}),o=c(),(i=a.obj())._destroy=function(e,t){r.close({success:function(){t&&t(e)}})};var p=i.destroy;return i.destroy=function(){i.destroy=p;var e=this;setTimeout((function(){r.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(i),h(),i}t.exports=p}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14,duplexify:17,"readable-stream":51}],7:[function(e,t,n){var r=e("xtend"),o=e("readable-stream").Readable,i={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=r(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,n=[],r=0;return this._inflights.forEach((function(e,t){n.push(e)})),e._read=function(){!t&&r<n.length?this.push(n[r++]):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()},t.exports=a},{"readable-stream":51,xtend:61}],8:[function(e,t,n){function r(e){for(var t=e.split("/"),n=0;n<t.length;n++)if("+"!==t[n]){if("#"===t[n])return n===t.length-1;if(-1!==t[n].indexOf("+")||-1!==t[n].indexOf("#"))return!1}return!0}function o(e){if(0===e.length)return"empty_topic_list";for(var t=0;t<e.length;t++)if(!r(e[t]))return e[t];return null}t.exports={validateTopics:o}},{}],9:[function(e,t,n){(function(n){(function(){var r=e("../client"),o=e("../store"),i=e("url"),s=e("xtend"),a=e("debug")("mqttjs"),c={};function l(e){var t;e.auth&&((t=e.auth.match(/^(.+):(.+)$/))?(e.username=t[1],e.password=t[2]):e.username=e.auth)}function u(e,t){if(a("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){var n=i.parse(e,!0);if(null!=n.port&&(n.port=Number(n.port)),null===(t=s(n,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(l(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(!c[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 c[e]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");function u(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),c[t.protocol](e,t)}t.protocol&&(t.defaultProtocol=t.protocol);var h=new r(u,t);return h.on("error",(function(){})),h}void 0!==n&&"browser"!==n.title||"function"!=typeof __webpack_require__?(c.mqtt=e("./tcp"),c.tcp=e("./tcp"),c.ssl=e("./tls"),c.tls=e("./tls"),c.mqtts=e("./tls")):(c.wx=e("./wx"),c.wxs=e("./wx"),c.ali=e("./ali"),c.alis=e("./ali")),c.ws=e("./ws"),c.wss=e("./ws"),t.exports=u,t.exports.connect=u,t.exports.MqttClient=r,t.exports.Store=o}).call(this)}).call(this,e("_process"))},{"../client":1,"../store":7,"./ali":2,"./tcp":3,"./tls":4,"./ws":5,"./wx":6,_process:32,debug:15,url:56,xtend:61}],10:[function(e,t,n){n.byteLength=u,n.toByteArray=p,n.fromByteArray=m;for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],o[s.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e){var t=l(e),n=t[0],r=t[1];return 3*(n+r)/4-r}function h(e,t,n){return 3*(t+n)/4-n}function p(e){var t,n,r=l(e),s=r[0],a=r[1],c=new i(h(e,s,a)),u=0,p=a>0?s-4:s;for(n=0;n<p;n+=4)t=o[e.charCodeAt(n)]<<18|o[e.charCodeAt(n+1)]<<12|o[e.charCodeAt(n+2)]<<6|o[e.charCodeAt(n+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;return 2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,c[u++]=255&t),1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t),c}function f(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function d(e,t,n){for(var r,o=[],i=t;i<n;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(f(r));return o.join("")}function m(e){for(var t,n=e.length,o=n%3,i=[],s=16383,a=0,c=n-o;a<c;a+=s)i.push(d(e,a,a+s>c?c:a+s));return 1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],11:[function(e,t,n){const{Buffer:r}=e("buffer"),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 n=0;n<this._bufs.length;n++){const r=t+this._bufs[n].length;if(e<r||n===this._bufs.length-1)return[n,e-t];t=r}},i.prototype._reverseOffset=function(e){const t=e[0];let n=e[1];for(let e=0;e<t;e++)n+=this._bufs[e].length;return n},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,n,o){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof o||o>this.length)&&(o=this.length),n>=this.length)return e||r.alloc(0);if(o<=0)return e||r.alloc(0);const i=!!e,s=this._offset(n),a=o-n;let c=a,l=i&&t||0,u=s[1];if(0===n&&o===this.length){if(!i)return 1===this._bufs.length?this._bufs[0]:r.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,l),l+=this._bufs[t].length;return e}if(c<=this._bufs[s[0]].length-u)return i?this._bufs[s[0]].copy(e,t,u,u+c):this._bufs[s[0]].slice(u,u+c);i||(e=r.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const n=this._bufs[t].length-u;if(!(c>n)){this._bufs[t].copy(e,l,u,u+c),l+=n;break}this._bufs[t].copy(e,l,u),l+=n,c-=n,u&&(u=0)}return e.length>l?e.slice(0,l):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 n=this._offset(e),r=this._offset(t),o=this._bufs.slice(n[0],r[0]+1);return 0===r[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,r[1]),0!==n[1]&&(o[0]=o[0].slice(n[1])),this._new(o)},i.prototype.toString=function(e,t,n){return this.slice(t,n).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(r.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(r.from(e));return this},i.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},i.prototype.indexOf=function(e,t,n){if(void 0===n&&"string"==typeof t&&(n=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=r.from([e]):"string"==typeof e?e=r.from(e,n):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=r.from(e.buffer,e.byteOffset,e.byteLength):r.isBuffer(e)||(e=r.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 n=t.indexOf(e,s);if(-1!==n)return this._reverseOffset([i,n]);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 n=0;n<t.length;n++)if(this.get(e+n)!==t[n])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){null===e[t]?i.prototype[t]=function(e,n){return this.slice(e,e+n)[t](0,n)}:i.prototype[t]=function(n=0){return this.slice(n,n+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]},t.exports=i},{buffer:14}],12:[function(e,t,n){const r=e("readable-stream").Duplex,o=e("inherits"),i=e("./BufferList");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),r.call(this)}o(s,r),Object.assign(s.prototype,i.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,n){this._appendBuffer(e),"function"==typeof n&&n()},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){r.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,t.exports=s,t.exports.BufferListStream=s,t.exports.BufferList=i},{"./BufferList":11,inherits:21,"readable-stream":51}],13:[function(e,t,n){},{}],14:[function(e,t,n){(function(t){(function(){var t=e("base64-js"),r=e("ieee754");n.Buffer=a,n.SlowBuffer=y,n.INSPECT_MAX_BYTES=50;var o=2147483647;function i(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return c(e,t,n)}function c(e,t,n){if("string"==typeof e)return p(e,t);if(ArrayBuffer.isView(e))return f(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Q(e,ArrayBuffer)||e&&Q(e.buffer,ArrayBuffer))return d(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return a.from(r,t,n);var o=m(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function u(e,t,n){return l(e),e<=0?s(e):void 0!==t?"string"==typeof n?s(e).fill(t,n):s(e).fill(t):s(e)}function h(e){return l(e),s(e<0?0:0|g(e))}function p(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|v(e,t),r=s(n),o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}function f(e){for(var t=e.length<0?0:0|g(e.length),n=s(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function d(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return(r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n)).__proto__=a.prototype,r}function m(e){if(a.isBuffer(e)){var t=0|g(e.length),n=s(t);return 0===n.length||e.copy(n,0,0,t),n}return void 0!==e.length?"number"!=typeof e.length||X(e.length)?s(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}function g(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function y(e){return+e!=e&&(e=0),a.alloc(+e)}function v(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Q(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return J(e).length;default:if(o)return r?-1:W(e).length;t=(""+t).toLowerCase(),o=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return j(this,t,n);case"utf8":case"utf-8":return O(this,t,n);case"ascii":return P(this,t,n);case"latin1":case"binary":return B(this,t,n);case"base64":return R(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function _(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),X(n=+n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=a.from(t,r)),a.isBuffer(t))return 0===t.length?-1:C(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):C(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function C(e,t,n,r,o){var i,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var u=-1;for(i=n;i<a;i++)if(l(e,i)===l(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===c)return u*s}else-1!==u&&(i-=i-u),u=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var h=!0,p=0;p<c;p++)if(l(e,i+p)!==l(t,p)){h=!1;break}if(h)return i}return-1}function S(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(X(a))return s;e[n+s]=a}return s}function k(e,t,n,r){return Y(W(t,e.length-n),e,n,r)}function A(e,t,n,r){return Y(z(t),e,n,r)}function E(e,t,n,r){return A(e,t,n,r)}function I(e,t,n,r){return Y(J(t),e,n,r)}function x(e,t,n,r){return Y(K(t,e.length-n),e,n,r)}function R(e,n,r){return 0===n&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function O(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,c,l=e[o],u=null,h=l>239?4:l>223?3:l>191?2:1;if(o+h<=n)switch(h){case 1:l<128&&(u=l);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&l)<<6|63&i)>127&&(u=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&l)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,h=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=h}return T(r)}n.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=i(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,n){return c(e,t,n)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,n){return u(e,t,n)},a.allocUnsafe=function(e){return h(e)},a.allocUnsafeSlow=function(e){return h(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(Q(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),Q(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},a.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}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=a.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(Q(i,Uint8Array)&&(i=a.from(i)),!a.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},a.byteLength=v,a.prototype._isBuffer=!0,a.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)w(this,t,t+1);return this},a.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)w(this,t,t+3),w(this,t+1,t+2);return this},a.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)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?O(this,0,e):b.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a.prototype.compare=function(e,t,n,r,o){if(Q(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),c=Math.min(i,s),l=this.slice(r,o),u=e.slice(t,n),h=0;h<c;++h)if(l[h]!==u[h]){i=l[h],s=u[h];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},a.prototype.indexOf=function(e,t,n){return _(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return _(this,e,t,n,!1)},a.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return S(this,e,t,n);case"utf8":case"utf-8":return k(this,e,t,n);case"ascii":return A(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return I(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var F=4096;function T(e){var t=e.length;if(t<=F)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=F));return n}function P(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function B(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function j(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=V(e[i]);return o}function U(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function M(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function N(e,t,n,r,o,i){if(!a.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(n+r>e.length)throw new RangeError("Index out of range")}function L(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function D(e,t,n,o,i){return t=+t,n>>>=0,i||L(e,t,n,4),r.write(e,t,n,o,23,4),n+4}function q(e,t,n,o,i){return t=+t,n>>>=0,i||L(e,t,n,8),r.write(e,t,n,o,52,8),n+8}a.prototype.slice=function(e,t){var n=this.length;(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);var r=this.subarray(e,t);return r.__proto__=a.prototype,r},a.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},a.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},a.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},a.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||N(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},a.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||N(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);N(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},a.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);N(this,e,t,n,o-1,-o)}var i=n-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+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,n){return D(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return D(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,r){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o=r-n;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,n,r);else if(this===e&&n<t&&t<r)for(var i=o-1;i>=0;--i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,r),t);return o},a.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){var o=e.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(e=o)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=a.isBuffer(e)?e:a.from(e,r),c=s.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=s[i%c]}return this};var $=/[^+/0-9A-Za-z-_]/g;function H(e){if((e=(e=e.split("=")[0]).trim().replace($,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function V(e){return e<16?"0"+e.toString(16):e.toString(16)}function W(e,t){var n;t=t||1/0;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function z(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function K(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}function J(e){return t.toByteArray(H(e))}function Y(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function Q(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function X(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":10,buffer:14,ieee754:20}],15:[function(e,t,n){(function(r){(function(){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),e.splice(o,0,n)}function s(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}}function a(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}n.formatArgs=i,n.save=s,n.load=a,n.useColors=o,n.storage=c(),n.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`."))}})(),n.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"],n.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(n);const{formatters:l}=t.exports;l.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":16,_process:32}],16:[function(e,t,n){function r(t){function n(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){let t,n=null;function i(...e){if(!i.enabled)return;const n=i,o=Number(new Date),s=o-(t||o);n.diff=s,n.prev=t,n.curr=o,t=o,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,o)=>{if("%%"===t)return"%";a++;const i=r.formatters[o];if("function"==typeof i){const r=e[a];t=i.call(n,r),e.splice(a,1),a--}return t})),r.formatArgs.call(n,e),(n.log||r.log).apply(n,e)}return i.namespace=e,i.useColors=r.useColors(),i.color=r.selectColor(e),i.extend=o,i.destroy=r.destroy,Object.defineProperty(i,"enabled",{enumerable:!0,configurable:!1,get:()=>null===n?r.enabled(e):n,set:e=>{n=e}}),"function"==typeof r.init&&r.init(i),i}function o(e,t){const n=r(this.namespace+(void 0===t?":":t)+e);return n.log=this.log,n}function i(e){let t;r.save(e),r.names=[],r.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")))}function s(){const e=[...r.names.map(c),...r.skips.map(c).map((e=>"-"+e))].join(",");return r.enable(""),e}function a(e){if("*"===e[e.length-1])return!0;let t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1}function c(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}function l(e){return e instanceof Error?e.stack||e.message:e}function u(){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.debug=r,r.default=r,r.coerce=l,r.disable=s,r.enable=i,r.enabled=a,r.humanize=e("ms"),r.destroy=u,Object.keys(t).forEach((e=>{r[e]=t[e]})),r.names=[],r.skips=[],r.formatters={},r.selectColor=n,r.enable(r.load()),r}t.exports=r},{ms:29}],17:[function(e,t,n){(function(n,r){(function(){var o=e("readable-stream"),i=e("end-of-stream"),s=e("inherits"),a=e("stream-shift"),c=r.from&&r.from!==Uint8Array.from?r.from([0]):new r([0]),l=function(e,t){e._corked?e.once("uncork",t):t()},u=function(e,t){e._autoDestroy&&e.destroy(t)},h=function(e,t){return function(n){n?u(e,"premature close"===n.message?null:n):t&&!e._ended&&e.end()}},p=function(e,t){return e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),void t()):t()},f=function(){},d=function(e){return new o.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},m=function(e,t,n){if(!(this instanceof m))return new m(e,t,n);o.Duplex.call(this,n),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!n||!1!==n.autoDestroy,this._forwardDestroy=!n||!1!==n.destroy,this._forwardEnd=!n||!1!==n.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(m,o.Duplex),m.obj=function(e,t,n){return n||(n={}),n.objectMode=!0,n.highWaterMark=16,new m(e,t,n)},m.prototype.cork=function(){1==++this._corked&&this.emit("cork")},m.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},m.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},h(this,this._forwardEnd)),o=function(){var e=t._ondrain;t._ondrain=null,e&&e()},s=function(){t._writable.removeListener("drain",o),r()};this._unwrite&&n.nextTick(o),this._writable=e,this._writable.on("drain",o),this._unwrite=s,this.uncork()}else this.end()},m.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=this,n=i(e,{writable:!1,readable:!0},h(this)),r=function(){t._forward()},o=function(){t.push(null)},s=function(){t._readable2.removeListener("readable",r),t._readable2.removeListener("end",o),n()};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:d(e),this._readable2.on("readable",r),this._readable2.on("end",o),this._unread=s,this._forward()}},m.prototype._read=function(){this._drained=!0,this._forward()},m.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}},m.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)}))},m.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")},m.prototype._write=function(e,t,n){if(!this.destroyed)return this._corked?l(this,this._write.bind(this,e,t,n)):e===c?this._finish(n):this._writable?void(!1===this._writable.write(e)?this._ondrain=n:this.destroyed||n()):n()},m.prototype._finish=function(e){var t=this;this.emit("preend"),l(this,(function(){p(t._forwardEnd&&t._writable,(function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),l(t,e)}))}))},m.prototype.end=function(e,t,n){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.write(c),o.Writable.prototype.end.call(this,n))},t.exports=m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:32,buffer:14,"end-of-stream":18,inherits:21,"readable-stream":51,"stream-shift":54}],18:[function(e,t,n){(function(n){(function(){var r=e("once"),o=function(){},i=function(e){return e.setHeader&&"function"==typeof e.abort},s=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},a=function(e,t,c){if("function"==typeof t)return a(e,null,t);t||(t={}),c=r(c||o);var l=e._writableState,u=e._readableState,h=t.readable||!1!==t.readable&&e.readable,p=t.writable||!1!==t.writable&&e.writable,f=!1,d=function(){e.writable||m()},m=function(){p=!1,h||c.call(e)},g=function(){h=!1,p||c.call(e)},y=function(t){c.call(e,t?new Error("exited with error code: "+t):null)},v=function(t){c.call(e,t)},b=function(){n.nextTick(w)},w=function(){if(!f)return(!h||u&&u.ended&&!u.destroyed)&&(!p||l&&l.ended&&!l.destroyed)?void 0:c.call(e,new Error("premature close"))},_=function(){e.req.on("finish",m)};return i(e)?(e.on("complete",m),e.on("abort",b),e.req?_():e.on("request",_)):p&&!l&&(e.on("end",d),e.on("close",d)),s(e)&&e.on("exit",y),e.on("end",g),e.on("finish",m),!1!==t.error&&e.on("error",v),e.on("close",b),function(){f=!0,e.removeListener("complete",m),e.removeListener("abort",b),e.removeListener("request",_),e.req&&e.req.removeListener("finish",m),e.removeListener("end",d),e.removeListener("close",d),e.removeListener("finish",m),e.removeListener("exit",y),e.removeListener("end",g),e.removeListener("error",v),e.removeListener("close",b)}};t.exports=a}).call(this)}).call(this,e("_process"))},{_process:32,once:30}],19:[function(e,t,n){var r=Object.create||k,o=Object.keys||A,i=Function.prototype.bind||E;function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,c=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),a=0===l.x}catch(e){a=!1}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function h(e,t,n){if(t)e.call(n);else for(var r=e.length,o=C(e,r),i=0;i<r;++i)o[i].call(n)}function p(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,i=C(e,o),s=0;s<o;++s)i[s].call(n,r)}function f(e,t,n,r,o){if(t)e.call(n,r,o);else for(var i=e.length,s=C(e,i),a=0;a<i;++a)s[a].call(n,r,o)}function d(e,t,n,r,o,i){if(t)e.call(n,r,o,i);else for(var s=e.length,a=C(e,s),c=0;c<s;++c)a[c].call(n,r,o,i)}function m(e,t,n,r){if(t)e.apply(n,r);else for(var o=e.length,i=C(e,o),s=0;s<o;++s)i[s].apply(n,r)}function g(e,t,n,o){var i,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),a=s[t]):(s=e._events=r(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=o?[n,a]:[a,n]:o?a.unshift(n):a.push(n),!a.warned&&(i=u(e))&&i>0&&a.length>i){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",c.name,c.message)}}else a=s[t]=n,++e._eventsCount;return e}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function v(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=i.call(y,r);return o.listener=n,r.wrapFn=o,o}function b(e,t,n){var r=e._events;if(!r)return[];var o=r[t];return o?"function"==typeof o?n?[o.listener||o]:[o]:n?S(o):C(o,o.length):[]}function w(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function _(e,t){for(var n=t,r=n+1,o=e.length;r<o;n+=1,r+=1)e[n]=e[r];e.pop()}function C(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function S(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function k(e){var t=function(){};return t.prototype=e,new t}function A(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t);return t}function E(e){var t=this;return function(){return t.apply(e,arguments)}}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');c=e}}):s.defaultMaxListeners=c,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){var t,n,r,o,i,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var c=new Error('Unhandled "error" event. ('+t+")");throw c.context=t,c}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:h(n,l,this);break;case 2:p(n,l,this,arguments[1]);break;case 3:f(n,l,this,arguments[1],arguments[2]);break;case 4:d(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i<r;i++)o[i-1]=arguments[i];m(n,l,this,o)}return!0},s.prototype.addListener=function(e,t){return g(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return g(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,v(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,v(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,o,i,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(n=o[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=r(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){a=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():_(n,i),1===n.length&&(o[e]=n[0]),o.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.removeAllListeners=function(e){var t,n,i;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=r(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=r(null):delete n[e]),this;if(0===arguments.length){var s,a=o(n);for(i=0;i<a.length;++i)"removeListener"!==(s=a[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return b(this,e,!0)},s.prototype.rawListeners=function(e){return b(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):w.call(e,t)},s.prototype.listenerCount=w,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],20:[function(e,t,n){
|
|
1
|
+
var Amity=function(e){"use strict";var t;const n="object"==typeof globalThis?globalThis:"object"==typeof global?global:window,{process:r={}}=n,o="production"===(null===(t=r.env)||void 0===t?void 0:t.NODE_ENV);var i,s;const a=null!==(s=null===(i=r.env)||void 0===i?void 0:i.VERSION)&&void 0!==s?s:"__dev__",c="function"==typeof atob,l="function"==typeof btoa,u="function"==typeof Buffer,h="function"==typeof TextDecoder?new TextDecoder:void 0,p="function"==typeof TextEncoder?new TextEncoder:void 0,f=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],d=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(f),m=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,g=String.fromCharCode.bind(String),y="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),v=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),b=l?e=>btoa(e):u?e=>Buffer.from(e,"binary").toString("base64"):e=>{let t,n,r,o,i="";const s=e.length%3;for(let s=0;s<e.length;){if((n=e.charCodeAt(s++))>255||(r=e.charCodeAt(s++))>255||(o=e.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=n<<16|r<<8|o,i+=f[t>>18&63]+f[t>>12&63]+f[t>>6&63]+f[63&t]}return s?i.slice(0,s-3)+"===".substring(s):i},w=u?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(g.apply(null,e.subarray(n,n+4096)));return b(t.join(""))},_=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?g(192|t>>>6)+g(128|63&t):g(224|t>>>12&15)+g(128|t>>>6&63)+g(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return g(240|t>>>18&7)+g(128|t>>>12&63)+g(128|t>>>6&63)+g(128|63&t)},C=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,S=u?e=>Buffer.from(e,"utf8").toString("base64"):p?e=>w(p.encode(e)):e=>b(e.replace(C,_)),k=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,A=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return g(55296+(t>>>10))+g(56320+(1023&t));case 3:return g((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return g((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},E=c?e=>atob(v(e)):u?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!m.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,r,o="";for(let i=0;i<e.length;)t=d[e.charAt(i++)]<<18|d[e.charAt(i++)]<<12|(n=d[e.charAt(i++)])<<6|(r=d[e.charAt(i++)]),o+=64===n?g(t>>16&255):64===r?g(t>>16&255,t>>8&255):g(t>>16&255,t>>8&255,255&t);return o},I=u?e=>y(Buffer.from(e,"base64")):e=>y(E(e),(e=>e.charCodeAt(0))),O=u?e=>Buffer.from(e,"base64").toString("utf8"):h?e=>h.decode(I(e)):e=>E(e).replace(k,A),x=e=>O(v(e.replace(/[-_]/g,(e=>"-"==e?"+":"/")))),R=e=>["skip","limit"].some((t=>t in e)),F=e=>["after","before","first","last","limit"].some((t=>t in e)),T=e=>"limit"in e,P=e=>(null==e?void 0:e.hasOwnProperty("data"))&&(null==e?void 0:e.hasOwnProperty("nextPage"))&&(null==e?void 0:e.hasOwnProperty("prevPage")),B=(e,t)=>{var n;if(!e||!Object.keys(e).length)return;let r={};return"skiplimit"===t?r={skip:null!==(n=e.after)&&void 0!==n?n:0,limit:e.limit}:"afterbefore"===t&&F(e)?Number.isNaN(null==e?void 0:e.before)?Number.isNaN(null==e?void 0:e.after)?Number.isNaN(null==e?void 0:e.limit)||(r={last:e.limit}):r={after:e.after,first:e.limit}:r={before:e.before,last:e.limit}:"afterbeforeraw"===t&&(r=e),Object.keys(r).length?((e,t=!1)=>t?(e=>e.replace(/[+\/]/g,(e=>"+"==e?"-":"_")).replace(/=+$/m,""))(S(e)):S(e))(JSON.stringify(r)):void 0},j=e=>{if(!e)return;const t=JSON.parse(x(e));if(R(t))return{after:t.skip,limit:t.limit};if(F(t)){if("before"in t)return{before:t.before,limit:t.last};if("after"in t)return{after:t.after,limit:t.first}}},U=e=>{if(!e)return;const t=JSON.parse(x(e));return T(t)?t:void 0},M=e=>"locally"in e,N=e=>"optimistically"in e,D=e=>M(e)||N(e),L=e=>null==e?void 0:e.hasOwnProperty("cachedAt"),q=(e,t=0)=>{var n;return Date.now()-(null!==(n=null==e?void 0:e.cachedAt)&&void 0!==n?n:0)<=t},$=(e,...t)=>({func:e,args:t}),H=(e,t=12e4)=>"cache_only"===e?{lifeSpan:1/0}:"server_only"===e?{lifeSpan:0}:{lifeSpan:t},V=({func:e,args:t},n,r=H("cache_then_server"))=>{let o;if(D(e)&&0!==r.lifeSpan){try{o=N(e)?e.optimistically(...t):e.locally(...t)}catch(e){null==n||n(W(void 0,{origin:"local",loading:!1,error:e}))}const i=L(o)&&q(o,r.lifeSpan);if(null==n||n(W(o,{origin:"local",loading:!(M(e)&&i)})),i)return}else null==n||n(W(void 0,{origin:"local",loading:!0}));e(...t).then((e=>{null==n||n(W(e,{origin:"server",loading:!1}))})).catch((e=>{null==n||n(W(void 0,{origin:"server",loading:!1,error:e}))}))};function W(e,t){return P(e)||L(e)?Object.assign(Object.assign({},t),e):Object.assign(Object.assign({},t),{data:e})}class z extends Error{constructor(e,t,n){super(`Amity SDK (${t}): ${e}`),this.code=t,this.level=n,this.type="ASC",this.timestamp=Date.now(),Error.captureStackTrace&&Error.captureStackTrace(this,z)}}class K extends z{constructor(e,t,n){super(e,t,n)}}class J extends z{constructor(e=8e5,t="fatal"){super("Unexpected error",e,t)}}class Y extends z{constructor(e,t="SDK client is having connection issues"){super(`${t} (${e})`,"disconnected"===e?800211:800210,"error"),this.event=e}}let X=null;const Q=()=>{if(!X)throw new z("There is no active client",8e5,"fatal");return X},G=e=>{X=e};var Z="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ee(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}function te(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ne={exports:{}},re=1e3,oe=6e4,ie=60*oe,se=24*ie,ae=7*se,ce=365.25*se,le=function(e,t){t=t||{};var n=typeof e;if("string"===n&&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 n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*ce;case"weeks":case"week":case"w":return n*ae;case"days":case"day":case"d":return n*se;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ie;case"minutes":case"minute":case"mins":case"min":case"m":return n*oe;case"seconds":case"second":case"secs":case"sec":case"s":return n*re;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=se)return ue(e,t,se,"day");if(t>=ie)return ue(e,t,ie,"hour");if(t>=oe)return ue(e,t,oe,"minute");if(t>=re)return ue(e,t,re,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=se)return Math.round(e/se)+"d";if(t>=ie)return Math.round(e/ie)+"h";if(t>=oe)return Math.round(e/oe)+"m";if(t>=re)return Math.round(e/re)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ue(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}var he=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,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(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(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=le,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((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){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 n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},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&&"undefined"!=typeof process&&"env"in process&&(e=process.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=he(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(ne,ne.exports);var pe=ne.exports;const fe={EU:"eu",SG:"sg",US:"us"},de={http:"https://api.{region}.amity.co",mqtt:"wss://sse.{region}.amity.co:443/mqtt"};function me(e,t){return de[e].replace("{region}",t)}var ge={exports:{}},ye=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},ve=ye,be=Object.prototype.toString;function we(e){return"[object Array]"===be.call(e)}function _e(e){return void 0===e}function Ce(e){return null!==e&&"object"==typeof e}function Se(e){if("[object Object]"!==be.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function ke(e){return"[object Function]"===be.call(e)}function Ae(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),we(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var Ee={isArray:we,isArrayBuffer:function(e){return"[object ArrayBuffer]"===be.call(e)},isBuffer:function(e){return null!==e&&!_e(e)&&null!==e.constructor&&!_e(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:Ce,isPlainObject:Se,isUndefined:_e,isDate:function(e){return"[object Date]"===be.call(e)},isFile:function(e){return"[object File]"===be.call(e)},isBlob:function(e){return"[object Blob]"===be.call(e)},isFunction:ke,isStream:function(e){return Ce(e)&&ke(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:Ae,merge:function e(){var t={};function n(n,r){Se(t[r])&&Se(n)?t[r]=e(t[r],n):Se(n)?t[r]=e({},n):we(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)Ae(arguments[r],n);return t},extend:function(e,t,n){return Ae(t,(function(t,r){e[r]=n&&"function"==typeof t?ve(t,n):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}},Ie=Ee;function Oe(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var xe=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(Ie.isURLSearchParams(t))r=t.toString();else{var o=[];Ie.forEach(t,(function(e,t){null!=e&&(Ie.isArray(e)?t+="[]":e=[e],Ie.forEach(e,(function(e){Ie.isDate(e)?e=e.toISOString():Ie.isObject(e)&&(e=JSON.stringify(e)),o.push(Oe(t)+"="+Oe(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},Re=Ee;function Fe(){this.handlers=[]}Fe.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},Fe.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Fe.prototype.forEach=function(e){Re.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Te=Fe,Pe=Ee,Be=function(e){return!(!e||!e.__CANCEL__)},je=Ee,Ue=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},Me=function(e,t,n,r,o){var i=new Error(e);return Ue(i,t,n,r,o)},Ne=Me,De=Ee,Le=De.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),De.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),De.isString(r)&&s.push("path="+r),De.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},qe=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},$e=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},He=Ee,Ve=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],We=Ee,ze=We.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=We.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},Ke=Ee,Je=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(Ne("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)},Ye=Le,Xe=xe,Qe=function(e,t){return e&&!qe(t)?$e(e,t):t},Ge=function(e){var t,n,r,o={};return e?(He.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=He.trim(e.substr(0,r)).toLowerCase(),n=He.trim(e.substr(r+1)),t){if(o[t]&&Ve.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o},Ze=ze,et=Me,tt=function(e){return new Promise((function(t,n){var r=e.data,o=e.headers;Ke.isFormData(r)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var s=e.auth.username||"",a=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(s+":"+a)}var c=Qe(e.baseURL,e.url);if(i.open(e.method.toUpperCase(),Xe(c,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in i?Ge(i.getAllResponseHeaders()):null,o={data:e.responseType&&"text"!==e.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:r,config:e,request:i};Je(t,n,o),i=null}},i.onabort=function(){i&&(n(et("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){n(et("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(et(t,e,"ECONNABORTED",i)),i=null},Ke.isStandardBrowserEnv()){var l=(e.withCredentials||Ze(c))&&e.xsrfCookieName?Ye.read(e.xsrfCookieName):void 0;l&&(o[e.xsrfHeaderName]=l)}if("setRequestHeader"in i&&Ke.forEach(o,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)})),Ke.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),e.responseType)try{i.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){i&&(i.abort(),n(e),i=null)})),r||(r=null),i.send(r)}))},nt=Ee,rt=function(e,t){je.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},ot={"Content-Type":"application/x-www-form-urlencoded"};function it(e,t){!nt.isUndefined(e)&&nt.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var st,at={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(st=tt),st),transformRequest:[function(e,t){return rt(t,"Accept"),rt(t,"Content-Type"),nt.isFormData(e)||nt.isArrayBuffer(e)||nt.isBuffer(e)||nt.isStream(e)||nt.isFile(e)||nt.isBlob(e)?e:nt.isArrayBufferView(e)?e.buffer:nt.isURLSearchParams(e)?(it(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):nt.isObject(e)?(it(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};at.headers={common:{Accept:"application/json, text/plain, */*"}},nt.forEach(["delete","get","head"],(function(e){at.headers[e]={}})),nt.forEach(["post","put","patch"],(function(e){at.headers[e]=nt.merge(ot)}));var ct=at,lt=Ee,ut=function(e,t,n){return Pe.forEach(n,(function(n){e=n(e,t)})),e},ht=Be,pt=ct;function ft(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var dt=Ee,mt=function(e,t){t=t||{};var n={},r=["url","method","data"],o=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function a(e,t){return dt.isPlainObject(e)&&dt.isPlainObject(t)?dt.merge(e,t):dt.isPlainObject(t)?dt.merge({},t):dt.isArray(t)?t.slice():t}function c(r){dt.isUndefined(t[r])?dt.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(e[r],t[r])}dt.forEach(r,(function(e){dt.isUndefined(t[e])||(n[e]=a(void 0,t[e]))})),dt.forEach(o,c),dt.forEach(i,(function(r){dt.isUndefined(t[r])?dt.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(void 0,t[r])})),dt.forEach(s,(function(r){r in t?n[r]=a(e[r],t[r]):r in e&&(n[r]=a(void 0,e[r]))}));var l=r.concat(o).concat(i).concat(s),u=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return dt.forEach(u,c),n},gt=Ee,yt=xe,vt=Te,bt=function(e){return ft(e),e.headers=e.headers||{},e.data=ut(e.data,e.headers,e.transformRequest),e.headers=lt.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),lt.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||pt.adapter)(e).then((function(t){return ft(e),t.data=ut(t.data,t.headers,e.transformResponse),t}),(function(t){return ht(t)||(ft(e),t&&t.response&&(t.response.data=ut(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},wt=mt;function _t(e){this.defaults=e,this.interceptors={request:new vt,response:new vt}}_t.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=wt(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[bt,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},_t.prototype.getUri=function(e){return e=wt(this.defaults,e),yt(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},gt.forEach(["delete","get","head","options"],(function(e){_t.prototype[e]=function(t,n){return this.request(wt(n||{},{method:e,url:t,data:(n||{}).data}))}})),gt.forEach(["post","put","patch"],(function(e){_t.prototype[e]=function(t,n,r){return this.request(wt(r||{},{method:e,url:t,data:n}))}}));var Ct=_t;function St(e){this.message=e}St.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},St.prototype.__CANCEL__=!0;var kt=St,At=kt;function Et(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new At(e),t(n.reason))}))}Et.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Et.source=function(){var e;return{token:new Et((function(t){e=t})),cancel:e}};var It=Et,Ot=Ee,xt=ye,Rt=Ct,Ft=mt;function Tt(e){var t=new Rt(e),n=xt(Rt.prototype.request,t);return Ot.extend(n,Rt.prototype,t),Ot.extend(n,t),n}var Pt=Tt(ct);Pt.Axios=Rt,Pt.create=function(e){return Tt(Ft(Pt.defaults,e))},Pt.Cancel=kt,Pt.CancelToken=It,Pt.isCancel=Be,Pt.all=function(e){return Promise.all(e)},Pt.spread=function(e){return function(t){return e.apply(null,t)}},Pt.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},ge.exports=Pt,ge.exports.default=Pt;var Bt=ge.exports,jt={exports:{}};jt.exports=Mt;var Ut=jt.exports.HttpsAgent=Mt;function Mt(){}var Nt=jt.exports;const Dt=e=>{if("success"===e.status)return e.data;if("fail"===e.status)throw new J(e.code);if("error"===e.status)throw new K(e.message,e.code,"error")},Lt=(e,t)=>Object.entries(e).filter((([,e])=>void 0!==e)).map((([e,n])=>{const r=t?`${t}[${e}]`:e;return Array.isArray(n)?n.map((e=>`${r}[]=${e}`)).join("&"):"object"!=typeof n?`${r}=${n}`:Lt(n,null!=t?t:e)})).join("&"),qt=e=>{const t={maxSockets:100,maxFreeSockets:10,timeout:6e4,freeSocketTimeout:3e4},n=Bt.create({baseURL:e,httpAgent:new Nt(t),httpsAgent:new Ut(t),paramsSerializer:Lt});return n.interceptors.response.use((e=>e),(e=>{var t;const{response:n}=e;console.error(null!==(t=null==n?void 0:n.data)&&void 0!==t?t:e),n&&Dt(n.data)})),n};var $t={exports:{}},Ht=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Vt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Wt=function(e){var t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));for(var o=Ht.exec(e||""),i={},s=14;s--;)i[Vt[s]]=o[s]||"";return-1!=n&&-1!=r&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i},zt={exports:{}},Kt={exports:{}},Jt=1e3,Yt=6e4,Xt=60*Yt,Qt=24*Xt,Gt=365.25*Qt,Zt=function(e,t){t=t||{};var n=typeof e;if("string"===n&&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|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*Gt;case"days":case"day":case"d":return n*Qt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Xt;case"minutes":case"minute":case"mins":case"min":case"m":return n*Yt;case"seconds":case"second":case"secs":case"sec":case"s":return n*Jt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return en(e,Qt,"day")||en(e,Xt,"hour")||en(e,Yt,"minute")||en(e,Jt,"second")||e+" ms"}(e):function(e){if(e>=Qt)return Math.round(e/Qt)+"d";if(e>=Xt)return Math.round(e/Xt)+"h";if(e>=Yt)return Math.round(e/Yt)+"m";if(e>=Jt)return Math.round(e/Jt)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function en(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Zt,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(Kt,Kt.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=Kt.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)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="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),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.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(zt,zt.exports);var tn=Wt,nn=zt.exports("socket.io-client:url"),rn=function(e,t){var n=e;t=t||"undefined"!=typeof location&&location,null==e&&(e=t.protocol+"//"+t.host);"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?t.protocol+e:t.host+e),/^(https?|wss?):\/\//.test(e)||(nn("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),nn("parse %s",e),n=tn(e));n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443"));n.path=n.path||"/";var r=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+r+":"+n.port,n.href=n.protocol+"://"+r+(t&&t.port===n.port?"":":"+n.port),n};var on={},sn={exports:{}},an={exports:{}},cn=1e3,ln=6e4,un=60*ln,hn=24*un,pn=365.25*hn,fn=function(e,t){t=t||{};var n=typeof e;if("string"===n&&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|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*pn;case"days":case"day":case"d":return n*hn;case"hours":case"hour":case"hrs":case"hr":case"h":return n*un;case"minutes":case"minute":case"mins":case"min":case"m":return n*ln;case"seconds":case"second":case"secs":case"sec":case"s":return n*cn;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return dn(e,hn,"day")||dn(e,un,"hour")||dn(e,ln,"minute")||dn(e,cn,"second")||e+" ms"}(e):function(e){if(e>=hn)return Math.round(e/hn)+"d";if(e>=un)return Math.round(e/un)+"h";if(e>=ln)return Math.round(e/ln)+"m";if(e>=cn)return Math.round(e/cn)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function dn(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=fn,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(an,an.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=an.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)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="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),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.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(sn,sn.exports);var mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t)}return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(mn);var gn={},yn={}.toString,vn=Array.isArray||function(e){return"[object Array]"==yn.call(e)},bn=function(e){return wn&&Buffer.isBuffer(e)||_n&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))},wn="function"==typeof Buffer&&"function"==typeof Buffer.isBuffer,_n="function"==typeof ArrayBuffer;var Cn=vn,Sn=bn,kn=Object.prototype.toString,An="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===kn.call(Blob),En="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===kn.call(File);function In(e,t){if(!e)return e;if(Sn(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(Cn(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=In(e[o],t);return r}if("object"==typeof e&&!(e instanceof Date)){r={};for(var i in e)r[i]=In(e[i],t);return r}return e}function On(e,t){if(!e)return e;if(e&&e._placeholder)return t[e.num];if(Cn(e))for(var n=0;n<e.length;n++)e[n]=On(e[n],t);else if("object"==typeof e)for(var r in e)e[r]=On(e[r],t);return e}gn.deconstructPacket=function(e){var t=[],n=e.data,r=e;return r.data=In(n,t),r.attachments=t.length,{packet:r,buffers:t}},gn.reconstructPacket=function(e,t){return e.data=On(e.data,t),e.attachments=void 0,e},gn.removeBlobs=function(e,t){var n=0,r=e;!function e(o,i,s){if(!o)return o;if(An&&o instanceof Blob||En&&o instanceof File){n++;var a=new FileReader;a.onload=function(){s?s[i]=this.result:r=this.result,--n||t(r)},a.readAsArrayBuffer(o)}else if(Cn(o))for(var c=0;c<o.length;c++)e(o[c],c,o);else if("object"==typeof o&&!Sn(o))for(var l in o)e(o[l],l,o)}(r),n||t(r)},function(e){var t=sn.exports("socket.io-parser"),n=mn.exports,r=gn,o=vn,i=bn;function s(){}e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=s,e.Decoder=l;var a=e.ERROR+'"encode error"';function c(n){var r=""+n.type;if(e.BINARY_EVENT!==n.type&&e.BINARY_ACK!==n.type||(r+=n.attachments+"-"),n.nsp&&"/"!==n.nsp&&(r+=n.nsp+","),null!=n.id&&(r+=n.id),null!=n.data){var o=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(n.data);if(!1===o)return a;r+=o}return t("encoded %j as %s",n,r),r}function l(){this.reconstructor=null}function u(e){this.reconPack=e,this.buffers=[]}function h(t){return{type:e.ERROR,data:"parser error: "+t}}s.prototype.encode=function(n,o){(t("encoding packet %j",n),e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type)?function(e,t){function n(e){var n=r.deconstructPacket(e),o=c(n.packet),i=n.buffers;i.unshift(o),t(i)}r.removeBlobs(e,n)}(n,o):o([c(n)])},n(l.prototype),l.prototype.add=function(n){var r;if("string"==typeof n)r=function(n){var r=0,i={type:Number(n.charAt(0))};if(null==e.types[i.type])return h("unknown packet type "+i.type);if(e.BINARY_EVENT===i.type||e.BINARY_ACK===i.type){for(var s=r+1;"-"!==n.charAt(++r)&&r!=n.length;);var a=n.substring(s,r);if(a!=Number(a)||"-"!==n.charAt(r))throw new Error("Illegal attachments");i.attachments=Number(a)}if("/"===n.charAt(r+1)){for(s=r+1;++r;){if(","===(l=n.charAt(r)))break;if(r===n.length)break}i.nsp=n.substring(s,r)}else i.nsp="/";var c=n.charAt(r+1);if(""!==c&&Number(c)==c){for(s=r+1;++r;){var l;if(null==(l=n.charAt(r))||Number(l)!=l){--r;break}if(r===n.length)break}i.id=Number(n.substring(s,r+1))}if(n.charAt(++r)){var u=function(e){try{return JSON.parse(e)}catch(e){return!1}}(n.substr(r));if(!(!1!==u&&(i.type===e.ERROR||o(u))))return h("invalid payload");i.data=u}return t("decoded %s as %j",n,i),i}(n),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type?(this.reconstructor=new u(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!i(n)&&!n.base64)throw new Error("Unknown type: "+n);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(r=this.reconstructor.takeBinaryData(n))&&(this.reconstructor=null,this.emit("decoded",r))}},l.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},u.prototype.takeBinaryData=function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=r.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null},u.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}}(on);var xn={exports:{}},Rn={},Fn={exports:{}};try{Fn.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){Fn.exports=!1}var Tn=Fn.exports,Pn=function(e){var t=e.xdomain,n=e.xscheme,r=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||Tn))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!n&&r)return new XDomainRequest}catch(e){}if(!t)try{return new(self[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},Bn={exports:{}},jn={},Un=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var r in e)n.call(e,r)&&t.push(r);return t},Mn={}.toString,Nn=Array.isArray||function(e){return"[object Array]"==Mn.call(e)},Dn=Object.prototype.toString,Ln="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Dn.call(Blob),qn="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Dn.call(File),$n=function e(t){if(!t||"object"!=typeof t)return!1;if(Nn(t)){for(var n=0,r=t.length;n<r;n++)if(e(t[n]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(t)||"function"==typeof ArrayBuffer&&t instanceof ArrayBuffer||Ln&&t instanceof Blob||qn&&t instanceof File)return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&e(t[o]))return!0;return!1};var Hn=function(e,t,n){var r=e.byteLength;if(t=t||0,n=n||r,e.slice)return e.slice(t,n);if(t<0&&(t+=r),n<0&&(n+=r),n>r&&(n=r),t>=r||t>=n||0===r)return new ArrayBuffer(0);for(var o=new Uint8Array(e),i=new Uint8Array(n-t),s=t,a=0;s<n;s++,a++)i[a]=o[s];return i.buffer},Vn=function(e,t,n){var r=!1;return n=n||Wn,o.count=e,0===e?t():o;function o(e,i){if(o.count<=0)throw new Error("after called too many times");--o.count,e?(r=!0,t(e),t=n):0!==o.count||r||t(null,i)}};function Wn(){}
|
|
2
|
+
/*! https://mths.be/utf8js v2.1.2 by @mathias */var zn,Kn,Jn,Yn=String.fromCharCode;function Xn(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function Qn(e,t){if(e>=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function Gn(e,t){return Yn(e>>t&63|128)}function Zn(e,t){if(0==(4294967168&e))return Yn(e);var n="";return 0==(4294965248&e)?n=Yn(e>>6&31|192):0==(4294901760&e)?(Qn(e,t)||(e=65533),n=Yn(e>>12&15|224),n+=Gn(e,6)):0==(4292870144&e)&&(n=Yn(e>>18&7|240),n+=Gn(e,12),n+=Gn(e,6)),n+=Yn(63&e|128)}function er(){if(Jn>=Kn)throw Error("Invalid byte index");var e=255&zn[Jn];if(Jn++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function tr(e){var t,n;if(Jn>Kn)throw Error("Invalid byte index");if(Jn==Kn)return!1;if(t=255&zn[Jn],Jn++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|er())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|er()<<6|er())>=2048)return Qn(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|er()<<12|er()<<6|er())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}var nr={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,r=Xn(e),o=r.length,i=-1,s="";++i<o;)s+=Zn(r[i],n);return s},decode:function(e,t){var n=!1!==(t=t||{}).strict;zn=Xn(e),Kn=zn.length,Jn=0;for(var r,o=[];!1!==(r=tr(n));)o.push(r);return function(e){for(var t,n=e.length,r=-1,o="";++r<n;)(t=e[r])>65535&&(o+=Yn((t-=65536)>>>10&1023|55296),t=56320|1023&t),o+=Yn(t);return o}(o)}},rr={};!function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=new Uint8Array(256),n=0;n<e.length;n++)t[e.charCodeAt(n)]=n;rr.encode=function(t){var n,r=new Uint8Array(t),o=r.length,i="";for(n=0;n<o;n+=3)i+=e[r[n]>>2],i+=e[(3&r[n])<<4|r[n+1]>>4],i+=e[(15&r[n+1])<<2|r[n+2]>>6],i+=e[63&r[n+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i},rr.decode=function(e){var n,r,o,i,s,a=.75*e.length,c=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var u=new ArrayBuffer(a),h=new Uint8Array(u);for(n=0;n<c;n+=4)r=t[e.charCodeAt(n)],o=t[e.charCodeAt(n+1)],i=t[e.charCodeAt(n+2)],s=t[e.charCodeAt(n+3)],h[l++]=r<<2|o>>4,h[l++]=(15&o)<<4|i>>2,h[l++]=(3&i)<<6|63&s;return u}}();var or=void 0!==or?or:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,ir=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),sr=ir&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),ar=or&&or.prototype.append&&or.prototype.getBlob;function cr(e){return e.map((function(e){if(e.buffer instanceof ArrayBuffer){var t=e.buffer;if(e.byteLength!==t.byteLength){var n=new Uint8Array(e.byteLength);n.set(new Uint8Array(t,e.byteOffset,e.byteLength)),t=n.buffer}return t}return e}))}function lr(e,t){t=t||{};var n=new or;return cr(e).forEach((function(e){n.append(e)})),t.type?n.getBlob(t.type):n.getBlob()}function ur(e,t){return new Blob(cr(e),t||{})}"undefined"!=typeof Blob&&(lr.prototype=Blob.prototype,ur.prototype=Blob.prototype);var hr=ir?sr?Blob:ur:ar?lr:void 0;!function(e){var t,n=Un,r=$n,o=Hn,i=Vn,s=nr;"undefined"!=typeof ArrayBuffer&&(t=rr);var a="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),c="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),l=a||c;e.protocol=3;var u=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},h=n(u),p={type:"error",data:"parser error"},f=hr;function d(e,t,n){for(var r=new Array(e.length),o=i(e.length,n),s=function(e,n,o){t(n,(function(t,n){r[e]=n,o(t,r)}))},a=0;a<e.length;a++)s(a,e[a],o)}e.encodePacket=function(t,n,r,o){"function"==typeof n&&(o=n,n=!1),"function"==typeof r&&(o=r,r=null);var i=void 0===t.data?void 0:t.data.buffer||t.data;if("undefined"!=typeof ArrayBuffer&&i instanceof ArrayBuffer)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=t.data,i=new Uint8Array(o),s=new Uint8Array(1+o.byteLength);s[0]=u[t.type];for(var a=0;a<i.length;a++)s[a+1]=i[a];return r(s.buffer)}(t,n,o);if(void 0!==f&&i instanceof f)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);if(l)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=new FileReader;return o.onload=function(){e.encodePacket({type:t.type,data:o.result},n,!0,r)},o.readAsArrayBuffer(t.data)}(t,n,r);var o=new Uint8Array(1);o[0]=u[t.type];var i=new f([o.buffer,t.data]);return r(i)}(t,n,o);if(i&&i.base64)return function(t,n){var r="b"+e.packets[t.type]+t.data.data;return n(r)}(t,o);var a=u[t.type];return void 0!==t.data&&(a+=r?s.encode(String(t.data),{strict:!1}):String(t.data)),o(""+a)},e.encodeBase64Packet=function(t,n){var r,o="b"+e.packets[t.type];if(void 0!==f&&t.data instanceof f){var i=new FileReader;return i.onload=function(){var e=i.result.split(",")[1];n(o+e)},i.readAsDataURL(t.data)}try{r=String.fromCharCode.apply(null,new Uint8Array(t.data))}catch(e){for(var s=new Uint8Array(t.data),a=new Array(s.length),c=0;c<s.length;c++)a[c]=s[c];r=String.fromCharCode.apply(null,a)}return o+=btoa(r),n(o)},e.decodePacket=function(t,n,r){if(void 0===t)return p;if("string"==typeof t){if("b"===t.charAt(0))return e.decodeBase64Packet(t.substr(1),n);if(r&&!1===(t=function(e){try{e=s.decode(e,{strict:!1})}catch(e){return!1}return e}(t)))return p;var i=t.charAt(0);return Number(i)==i&&h[i]?t.length>1?{type:h[i],data:t.substring(1)}:{type:h[i]}:p}i=new Uint8Array(t)[0];var a=o(t,1);return f&&"blob"===n&&(a=new f([a])),{type:h[i],data:a}},e.decodeBase64Packet=function(e,n){var r=h[e.charAt(0)];if(!t)return{type:r,data:{base64:!0,data:e.substr(1)}};var o=t.decode(e.substr(1));return"blob"===n&&f&&(o=new f([o])),{type:r,data:o}},e.encodePayload=function(t,n,o){"function"==typeof n&&(o=n,n=null);var i=r(t);if(n&&i)return f&&!l?e.encodePayloadAsBlob(t,o):e.encodePayloadAsArrayBuffer(t,o);if(!t.length)return o("0:");d(t,(function(t,r){e.encodePacket(t,!!i&&n,!1,(function(e){r(null,function(e){return e.length+":"+e}(e))}))}),(function(e,t){return o(t.join(""))}))},e.decodePayload=function(t,n,r){if("string"!=typeof t)return e.decodePayloadAsBinary(t,n,r);var o;if("function"==typeof n&&(r=n,n=null),""===t)return r(p,0,1);for(var i,s,a="",c=0,l=t.length;c<l;c++){var u=t.charAt(c);if(":"===u){if(""===a||a!=(i=Number(a)))return r(p,0,1);if(a!=(s=t.substr(c+1,i)).length)return r(p,0,1);if(s.length){if(o=e.decodePacket(s,n,!1),p.type===o.type&&p.data===o.data)return r(p,0,1);if(!1===r(o,c+i,l))return}c+=i,a=""}else a+=u}return""!==a?r(p,0,1):void 0},e.encodePayloadAsArrayBuffer=function(t,n){if(!t.length)return n(new ArrayBuffer(0));d(t,(function(t,n){e.encodePacket(t,!0,!0,(function(e){return n(null,e)}))}),(function(e,t){var r=t.reduce((function(e,t){var n;return e+(n="string"==typeof t?t.length:t.byteLength).toString().length+n+2}),0),o=new Uint8Array(r),i=0;return t.forEach((function(e){var t="string"==typeof e,n=e;if(t){for(var r=new Uint8Array(e.length),s=0;s<e.length;s++)r[s]=e.charCodeAt(s);n=r.buffer}o[i++]=t?0:1;var a=n.byteLength.toString();for(s=0;s<a.length;s++)o[i++]=parseInt(a[s]);o[i++]=255;for(r=new Uint8Array(n),s=0;s<r.length;s++)o[i++]=r[s]})),n(o.buffer)}))},e.encodePayloadAsBlob=function(t,n){d(t,(function(t,n){e.encodePacket(t,!0,!0,(function(e){var t=new Uint8Array(1);if(t[0]=1,"string"==typeof e){for(var r=new Uint8Array(e.length),o=0;o<e.length;o++)r[o]=e.charCodeAt(o);e=r.buffer,t[0]=0}var i=(e instanceof ArrayBuffer?e.byteLength:e.size).toString(),s=new Uint8Array(i.length+1);for(o=0;o<i.length;o++)s[o]=parseInt(i[o]);if(s[i.length]=255,f){var a=new f([t.buffer,s.buffer,e]);n(null,a)}}))}),(function(e,t){return n(new f(t))}))},e.decodePayloadAsBinary=function(t,n,r){"function"==typeof n&&(r=n,n=null);for(var i=t,s=[];i.byteLength>0;){for(var a=new Uint8Array(i),c=0===a[0],l="",u=1;255!==a[u];u++){if(l.length>310)return r(p,0,1);l+=a[u]}i=o(i,2+l.length),l=parseInt(l);var h=o(i,0,l);if(c)try{h=String.fromCharCode.apply(null,new Uint8Array(h))}catch(e){var f=new Uint8Array(h);h="";for(u=0;u<f.length;u++)h+=String.fromCharCode(f[u])}s.push(h),i=o(i,l)}var d=s.length;s.forEach((function(t,o){r(e.decodePacket(t,n,!0),o,d)}))}}(jn);var pr={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(pr);var fr=jn,dr=mr;function mr(e){this.path=e.path,this.hostname=e.hostname,this.port=e.port,this.secure=e.secure,this.query=e.query,this.timestampParam=e.timestampParam,this.timestampRequests=e.timestampRequests,this.readyState="",this.agent=e.agent||!1,this.socket=e.socket,this.enablesXDR=e.enablesXDR,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.forceNode=e.forceNode,this.isReactNative=e.isReactNative,this.extraHeaders=e.extraHeaders,this.localAddress=e.localAddress}(0,pr.exports)(mr.prototype),mr.prototype.onError=function(e,t){var n=new Error(e);return n.type="TransportError",n.description=t,this.emit("error",n),this},mr.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},mr.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},mr.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},mr.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},mr.prototype.onData=function(e){var t=fr.decodePacket(e,this.socket.binaryType);this.onPacket(t)},mr.prototype.onPacket=function(e){this.emit("packet",e)},mr.prototype.onClose=function(){this.readyState="closed",this.emit("close")};var gr,yr={encode:function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},decode:function(e){for(var t={},n=e.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}},vr=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},br="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),wr={},_r=0,Cr=0;function Sr(e){var t="";do{t=br[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function kr(){var e=Sr(+new Date);return e!==gr?(_r=0,gr=e):e+"."+Sr(_r++)}for(;Cr<64;Cr++)wr[br[Cr]]=Cr;kr.encode=Sr,kr.decode=function(e){var t=0;for(Cr=0;Cr<e.length;Cr++)t=64*t+wr[e.charAt(Cr)];return t};var Ar=kr,Er={exports:{}},Ir={exports:{}},Or=1e3,xr=60*Or,Rr=60*xr,Fr=24*Rr,Tr=365.25*Fr,Pr=function(e,t){t=t||{};var n=typeof e;if("string"===n&&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|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*Tr;case"days":case"day":case"d":return n*Fr;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Rr;case"minutes":case"minute":case"mins":case"min":case"m":return n*xr;case"seconds":case"second":case"secs":case"sec":case"s":return n*Or;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return Br(e,Fr,"day")||Br(e,Rr,"hour")||Br(e,xr,"minute")||Br(e,Or,"second")||e+" ms"}(e):function(e){if(e>=Fr)return Math.round(e/Fr)+"d";if(e>=Rr)return Math.round(e/Rr)+"h";if(e>=xr)return Math.round(e/xr)+"m";if(e>=Or)return Math.round(e/Or)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Br(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Pr,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(Ir,Ir.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=Ir.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)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="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),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.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(Er,Er.exports);var jr=dr,Ur=yr,Mr=jn,Nr=vr,Dr=Ar,Lr=Er.exports("engine.io-client:polling"),qr=Hr,$r=null!=new Pn({xdomain:!1}).responseType;function Hr(e){var t=e&&e.forceBase64;$r&&!t||(this.supportsBinary=!1),jr.call(this,e)}Nr(Hr,jr),Hr.prototype.name="polling",Hr.prototype.doOpen=function(){this.poll()},Hr.prototype.pause=function(e){var t=this;function n(){Lr("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(Lr("we are currently polling - waiting to pause"),r++,this.once("pollComplete",(function(){Lr("pre-pause polling complete"),--r||n()}))),this.writable||(Lr("we are currently writing - waiting to pause"),r++,this.once("drain",(function(){Lr("pre-pause writing complete"),--r||n()})))}else n()},Hr.prototype.poll=function(){Lr("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},Hr.prototype.onData=function(e){var t=this;Lr("polling got data %s",e);Mr.decodePayload(e,this.socket.binaryType,(function(e,n,r){if("opening"===t.readyState&&t.onOpen(),"close"===e.type)return t.onClose(),!1;t.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():Lr('ignoring poll - transport state "%s"',this.readyState))},Hr.prototype.doClose=function(){var e=this;function t(){Lr("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(Lr("transport open - closing"),t()):(Lr("transport not open - deferring close"),this.once("open",t))},Hr.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};Mr.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,n)}))},Hr.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=Dr()),this.supportsBinary||e.sid||(e.b64=1),e=Ur.encode(e),this.port&&("https"===t&&443!==Number(this.port)||"http"===t&&80!==Number(this.port))&&(n=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e};var Vr=Pn,Wr=qr,zr=pr.exports,Kr=vr,Jr=Er.exports("engine.io-client:polling-xhr");function Yr(){}function Xr(e){if(Wr.call(this,e),this.requestTimeout=e.requestTimeout,this.extraHeaders=e.extraHeaders,"undefined"!=typeof location){var t="https:"===location.protocol,n=location.port;n||(n=t?443:80),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port,this.xs=e.secure!==t}}function Qr(e){this.method=e.method||"GET",this.uri=e.uri,this.xd=!!e.xd,this.xs=!!e.xs,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.agent=e.agent,this.isBinary=e.isBinary,this.supportsBinary=e.supportsBinary,this.enablesXDR=e.enablesXDR,this.requestTimeout=e.requestTimeout,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.extraHeaders=e.extraHeaders,this.create()}if(Bn.exports=Xr,Bn.exports.Request=Qr,Kr(Xr,Wr),Xr.prototype.supportsBinary=!0,Xr.prototype.request=function(e){return(e=e||{}).uri=this.uri(),e.xd=this.xd,e.xs=this.xs,e.agent=this.agent||!1,e.supportsBinary=this.supportsBinary,e.enablesXDR=this.enablesXDR,e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized,e.requestTimeout=this.requestTimeout,e.extraHeaders=this.extraHeaders,new Qr(e)},Xr.prototype.doWrite=function(e,t){var n="string"!=typeof e&&void 0!==e,r=this.request({method:"POST",data:e,isBinary:n}),o=this;r.on("success",t),r.on("error",(function(e){o.onError("xhr post error",e)})),this.sendXhr=r},Xr.prototype.doPoll=function(){Jr("xhr poll");var e=this.request(),t=this;e.on("data",(function(e){t.onData(e)})),e.on("error",(function(e){t.onError("xhr poll error",e)})),this.pollXhr=e},zr(Qr.prototype),Qr.prototype.create=function(){var e={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized;var t=this.xhr=new Vr(e),n=this;try{Jr("xhr open %s: %s",this.method,this.uri),t.open(this.method,this.uri,this.async);try{if(this.extraHeaders)for(var r in t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0),this.extraHeaders)this.extraHeaders.hasOwnProperty(r)&&t.setRequestHeader(r,this.extraHeaders[r])}catch(e){}if("POST"===this.method)try{this.isBinary?t.setRequestHeader("Content-type","application/octet-stream"):t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{t.setRequestHeader("Accept","*/*")}catch(e){}"withCredentials"in t&&(t.withCredentials=!0),this.requestTimeout&&(t.timeout=this.requestTimeout),this.hasXDR()?(t.onload=function(){n.onLoad()},t.onerror=function(){n.onError(t.responseText)}):t.onreadystatechange=function(){if(2===t.readyState)try{var e=t.getResponseHeader("Content-Type");n.supportsBinary&&"application/octet-stream"===e&&(t.responseType="arraybuffer")}catch(e){}4===t.readyState&&(200===t.status||1223===t.status?n.onLoad():setTimeout((function(){n.onError(t.status)}),0))},Jr("xhr data %s",this.data),t.send(this.data)}catch(e){return void setTimeout((function(){n.onError(e)}),0)}"undefined"!=typeof document&&(this.index=Qr.requestsCount++,Qr.requests[this.index]=this)},Qr.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},Qr.prototype.onData=function(e){this.emit("data",e),this.onSuccess()},Qr.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)},Qr.prototype.cleanup=function(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=Yr:this.xhr.onreadystatechange=Yr,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete Qr.requests[this.index],this.xhr=null}},Qr.prototype.onLoad=function(){var e;try{var t;try{t=this.xhr.getResponseHeader("Content-Type")}catch(e){}e="application/octet-stream"===t&&this.xhr.response||this.xhr.responseText}catch(e){this.onError(e)}null!=e&&this.onData(e)},Qr.prototype.hasXDR=function(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR},Qr.prototype.abort=function(){this.cleanup()},Qr.requestsCount=0,Qr.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Zr);else if("function"==typeof addEventListener){var Gr="onpagehide"in self?"pagehide":"unload";addEventListener(Gr,Zr,!1)}function Zr(){for(var e in Qr.requests)Qr.requests.hasOwnProperty(e)&&Qr.requests[e].abort()}var eo,to=qr,no=ao,ro=/\n/g,oo=/\\n/g;function io(){}function so(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==Z?Z:{}}function ao(e){if(to.call(this,e),this.query=this.query||{},!eo){var t=so();eo=t.___eio=t.___eio||[]}this.index=eo.length;var n=this;eo.push((function(e){n.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){n.script&&(n.script.onerror=io)}),!1)}vr(ao,to),ao.prototype.supportsBinary=!1,ao.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),to.prototype.doClose.call(this)},ao.prototype.doPoll=function(){var e=this,t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri(),t.onerror=function(t){e.onError("jsonp poll error",t)};var n=document.getElementsByTagName("script")[0];n?n.parentNode.insertBefore(t,n):(document.head||document.body).appendChild(t),this.script=t,"undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout((function(){var e=document.createElement("iframe");document.body.appendChild(e),document.body.removeChild(e)}),100)},ao.prototype.doWrite=function(e,t){var n=this;if(!this.form){var r,o=document.createElement("form"),i=document.createElement("textarea"),s=this.iframeId="eio_iframe_"+this.index;o.className="socketio",o.style.position="absolute",o.style.top="-1000px",o.style.left="-1000px",o.target=s,o.method="POST",o.setAttribute("accept-charset","utf-8"),i.name="d",o.appendChild(i),document.body.appendChild(o),this.form=o,this.area=i}function a(){c(),t()}function c(){if(n.iframe)try{n.form.removeChild(n.iframe)}catch(e){n.onError("jsonp polling iframe removal error",e)}try{var e='<iframe src="javascript:0" name="'+n.iframeId+'">';r=document.createElement(e)}catch(e){(r=document.createElement("iframe")).name=n.iframeId,r.src="javascript:0"}r.id=n.iframeId,n.form.appendChild(r),n.iframe=r}this.form.action=this.uri(),c(),e=e.replace(oo,"\\\n"),this.area.value=e.replace(ro,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&a()}:this.iframe.onload=a};var co,lo,uo=ee(Object.freeze({__proto__:null,default:{}})),ho=dr,po=jn,fo=yr,mo=vr,go=Ar,yo=Er.exports("engine.io-client:websocket");if("undefined"!=typeof WebSocket)co=WebSocket;else if("undefined"!=typeof self)co=self.WebSocket||self.MozWebSocket;else try{lo=uo}catch(e){}var vo=co||lo,bo=wo;function wo(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=co&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(vo=lo),ho.call(this,e)}mo(wo,ho),wo.prototype.name="websocket",wo.prototype.supportsBinary=!0,wo.prototype.doOpen=function(){if(this.check()){var e=this.uri(),t=this.protocols,n={agent:this.agent,perMessageDeflate:this.perMessageDeflate};n.pfx=this.pfx,n.key=this.key,n.passphrase=this.passphrase,n.cert=this.cert,n.ca=this.ca,n.ciphers=this.ciphers,n.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(n.headers=this.extraHeaders),this.localAddress&&(n.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?t?new vo(e,t):new vo(e):new vo(e,t,n)}catch(e){return this.emit("error",e)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},wo.prototype.addEventListeners=function(){var e=this;this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(){e.onClose()},this.ws.onmessage=function(t){e.onData(t.data)},this.ws.onerror=function(t){e.onError("websocket error",t)}},wo.prototype.write=function(e){var t=this;this.writable=!1;for(var n=e.length,r=0,o=n;r<o;r++)!function(e){po.encodePacket(e,t.supportsBinary,(function(r){if(!t.usingBrowserWebSocket){var o={};if(e.options&&(o.compress=e.options.compress),t.perMessageDeflate)("string"==typeof r?Buffer.byteLength(r):r.length)<t.perMessageDeflate.threshold&&(o.compress=!1)}try{t.usingBrowserWebSocket?t.ws.send(r):t.ws.send(r,o)}catch(e){yo("websocket closed before onclose event")}--n||i()}))}(e[r]);function i(){t.emit("flush"),setTimeout((function(){t.writable=!0,t.emit("drain")}),0)}},wo.prototype.onClose=function(){ho.prototype.onClose.call(this)},wo.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},wo.prototype.uri=function(){var e=this.query||{},t=this.secure?"wss":"ws",n="";return this.port&&("wss"===t&&443!==Number(this.port)||"ws"===t&&80!==Number(this.port))&&(n=":"+this.port),this.timestampRequests&&(e[this.timestampParam]=go()),this.supportsBinary||(e.b64=1),(e=fo.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e},wo.prototype.check=function(){return!(!vo||"__initialize"in vo&&this.name===wo.prototype.name)};var _o=Pn,Co=Bn.exports,So=no,ko=bo;Rn.polling=function(e){var t=!1,n=!1,r=!1!==e.jsonp;if("undefined"!=typeof location){var o="https:"===location.protocol,i=location.port;i||(i=o?443:80),t=e.hostname!==location.hostname||i!==e.port,n=e.secure!==o}if(e.xdomain=t,e.xscheme=n,"open"in new _o(e)&&!e.forceJSONP)return new Co(e);if(!r)throw new Error("JSONP disabled");return new So(e)},Rn.websocket=ko;var Ao=[].indexOf,Eo=function(e,t){if(Ao)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},Io=Rn,Oo=pr.exports,xo=Er.exports("engine.io-client:socket"),Ro=Eo,Fo=jn,To=Wt,Po=yr,Bo=jo;function jo(e,t){if(!(this instanceof jo))return new jo(e,t);t=t||{},e&&"object"==typeof e&&(t=e,e=null),e?(e=To(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=To(t.host).host),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.agent=t.agent||!1,this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=t.query||{},"string"==typeof this.query&&(this.query=Po.decode(this.query)),this.upgrade=!1!==t.upgrade,this.path=(t.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!t.forceJSONP,this.jsonp=!1!==t.jsonp,this.forceBase64=!!t.forceBase64,this.enablesXDR=!!t.enablesXDR,this.timestampParam=t.timestampParam||"t",this.timestampRequests=t.timestampRequests,this.transports=t.transports||["polling","websocket"],this.transportOptions=t.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=t.policyPort||843,this.rememberUpgrade=t.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=t.onlyBinaryUpgrades,this.perMessageDeflate=!1!==t.perMessageDeflate&&(t.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=t.pfx||null,this.key=t.key||null,this.passphrase=t.passphrase||null,this.cert=t.cert||null,this.ca=t.ca||null,this.ciphers=t.ciphers||null,this.rejectUnauthorized=void 0===t.rejectUnauthorized||t.rejectUnauthorized,this.forceNode=!!t.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(t.extraHeaders&&Object.keys(t.extraHeaders).length>0&&(this.extraHeaders=t.extraHeaders),t.localAddress&&(this.localAddress=t.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}jo.priorWebsocketSuccess=!1,Oo(jo.prototype),jo.protocol=Fo.protocol,jo.Socket=jo,jo.Transport=dr,jo.transports=Rn,jo.parser=jn,jo.prototype.createTransport=function(e){xo('creating transport "%s"',e);var t=function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}(this.query);t.EIO=Fo.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new Io[e]({query:t,socket:this,agent:n.agent||this.agent,hostname:n.hostname||this.hostname,port:n.port||this.port,secure:n.secure||this.secure,path:n.path||this.path,forceJSONP:n.forceJSONP||this.forceJSONP,jsonp:n.jsonp||this.jsonp,forceBase64:n.forceBase64||this.forceBase64,enablesXDR:n.enablesXDR||this.enablesXDR,timestampRequests:n.timestampRequests||this.timestampRequests,timestampParam:n.timestampParam||this.timestampParam,policyPort:n.policyPort||this.policyPort,pfx:n.pfx||this.pfx,key:n.key||this.key,passphrase:n.passphrase||this.passphrase,cert:n.cert||this.cert,ca:n.ca||this.ca,ciphers:n.ciphers||this.ciphers,rejectUnauthorized:n.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:n.perMessageDeflate||this.perMessageDeflate,extraHeaders:n.extraHeaders||this.extraHeaders,forceNode:n.forceNode||this.forceNode,localAddress:n.localAddress||this.localAddress,requestTimeout:n.requestTimeout||this.requestTimeout,protocols:n.protocols||void 0,isReactNative:this.isReactNative})},jo.prototype.open=function(){var e;if(this.rememberUpgrade&&jo.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length){var t=this;return void setTimeout((function(){t.emit("error","No transports available")}),0)}e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)},jo.prototype.setTransport=function(e){xo("setting transport %s",e.name);var t=this;this.transport&&(xo("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",(function(){t.onDrain()})).on("packet",(function(e){t.onPacket(e)})).on("error",(function(e){t.onError(e)})).on("close",(function(){t.onClose("transport close")}))},jo.prototype.probe=function(e){xo('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),n=!1,r=this;function o(){if(r.onlyBinaryUpgrades){var o=!this.supportsBinary&&r.transport.supportsBinary;n=n||o}n||(xo('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(function(o){if(!n)if("pong"===o.type&&"probe"===o.data){if(xo('probe transport "%s" pong',e),r.upgrading=!0,r.emit("upgrading",t),!t)return;jo.priorWebsocketSuccess="websocket"===t.name,xo('pausing current transport "%s"',r.transport.name),r.transport.pause((function(){n||"closed"!==r.readyState&&(xo("changing transport and sending upgrade packet"),u(),r.setTransport(t),t.send([{type:"upgrade"}]),r.emit("upgrade",t),t=null,r.upgrading=!1,r.flush())}))}else{xo('probe transport "%s" failed',e);var i=new Error("probe error");i.transport=t.name,r.emit("upgradeError",i)}})))}function i(){n||(n=!0,u(),t.close(),t=null)}function s(n){var o=new Error("probe error: "+n);o.transport=t.name,i(),xo('probe transport "%s" failed because of error: %s',e,n),r.emit("upgradeError",o)}function a(){s("transport closed")}function c(){s("socket closed")}function l(e){t&&e.name!==t.name&&(xo('"%s" works - aborting "%s"',e.name,t.name),i())}function u(){t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",a),r.removeListener("close",c),r.removeListener("upgrading",l)}jo.priorWebsocketSuccess=!1,t.once("open",o),t.once("error",s),t.once("close",a),this.once("close",c),this.once("upgrading",l),t.open()},jo.prototype.onOpen=function(){if(xo("socket open"),this.readyState="open",jo.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){xo("starting upgrade probes");for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},jo.prototype.onPacket=function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(xo('socket receive: type "%s", data "%s"',e.type,e.data),this.emit("packet",e),this.emit("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emit("data",e.data),this.emit("message",e.data)}else xo('packet received with socket readyState "%s"',this.readyState)},jo.prototype.onHandshake=function(e){this.emit("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.onOpen(),"closed"!==this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},jo.prototype.onHeartbeat=function(e){clearTimeout(this.pingTimeoutTimer);var t=this;t.pingTimeoutTimer=setTimeout((function(){"closed"!==t.readyState&&t.onClose("ping timeout")}),e||t.pingInterval+t.pingTimeout)},jo.prototype.setPing=function(){var e=this;clearTimeout(e.pingIntervalTimer),e.pingIntervalTimer=setTimeout((function(){xo("writing ping packet - expecting pong within %sms",e.pingTimeout),e.ping(),e.onHeartbeat(e.pingTimeout)}),e.pingInterval)},jo.prototype.ping=function(){var e=this;this.sendPacket("ping",(function(){e.emit("ping")}))},jo.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},jo.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(xo("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},jo.prototype.write=jo.prototype.send=function(e,t,n){return this.sendPacket("message",e,t,n),this},jo.prototype.sendPacket=function(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var o={type:e,data:t,options:n};this.emit("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}},jo.prototype.close=function(){if("opening"===this.readyState||"open"===this.readyState){this.readyState="closing";var e=this;this.writeBuffer.length?this.once("drain",(function(){this.upgrading?r():t()})):this.upgrading?r():t()}function t(){e.onClose("forced close"),xo("socket closing - telling transport to close"),e.transport.close()}function n(){e.removeListener("upgrade",n),e.removeListener("upgradeError",n),t()}function r(){e.once("upgrade",n),e.once("upgradeError",n)}return this},jo.prototype.onError=function(e){xo("socket error %j",e),jo.priorWebsocketSuccess=!1,this.emit("error",e),this.onClose("transport error",e)},jo.prototype.onClose=function(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){xo('socket close with reason: "%s"',e);clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",e,t),this.writeBuffer=[],this.prevBufferLen=0}},jo.prototype.filterUpgrades=function(e){for(var t=[],n=0,r=e.length;n<r;n++)~Ro(this.transports,e[n])&&t.push(e[n]);return t},xn.exports=Bo,xn.exports.parser=jn;var Uo={exports:{}},Mo={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(Mo);var No=function(e,t){for(var n=[],r=(t=t||0)||0;r<e.length;r++)n[r-t]=e[r];return n};var Do=function(e,t,n){return e.on(t,n),{destroy:function(){e.removeListener(t,n)}}};var Lo=[].slice,qo=function(e,t){if("string"==typeof t&&(t=e[t]),"function"!=typeof t)throw new Error("bind() requires a function");var n=Lo.call(arguments,2);return function(){return t.apply(e,n.concat(Lo.call(arguments)))}};!function(e,t){var n=on,r=Mo.exports,o=No,i=Do,s=qo,a=zt.exports("socket.io-client:socket"),c=yr,l=$n;e.exports=p;var u={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},h=r.prototype.emit;function p(e,t,n){this.io=e,this.nsp=t,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},n&&n.query&&(this.query=n.query),this.io.autoConnect&&this.open()}r(p.prototype),p.prototype.subEvents=function(){if(!this.subs){var e=this.io;this.subs=[i(e,"open",s(this,"onopen")),i(e,"packet",s(this,"onpacket")),i(e,"close",s(this,"onclose"))]}},p.prototype.open=p.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},p.prototype.send=function(){var e=o(arguments);return e.unshift("message"),this.emit.apply(this,e),this},p.prototype.emit=function(e){if(u.hasOwnProperty(e))return h.apply(this,arguments),this;var t=o(arguments),r={type:(void 0!==this.flags.binary?this.flags.binary:l(t))?n.BINARY_EVENT:n.EVENT,data:t,options:{}};return r.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof t[t.length-1]&&(a("emitting packet with ack id %d",this.ids),this.acks[this.ids]=t.pop(),r.id=this.ids++),this.connected?this.packet(r):this.sendBuffer.push(r),this.flags={},this},p.prototype.packet=function(e){e.nsp=this.nsp,this.io.packet(e)},p.prototype.onopen=function(){if(a("transport is open - connecting"),"/"!==this.nsp)if(this.query){var e="object"==typeof this.query?c.encode(this.query):this.query;a("sending connect packet with query %s",e),this.packet({type:n.CONNECT,query:e})}else this.packet({type:n.CONNECT})},p.prototype.onclose=function(e){a("close (%s)",e),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",e)},p.prototype.onpacket=function(e){var t=e.nsp===this.nsp,r=e.type===n.ERROR&&"/"===e.nsp;if(t||r)switch(e.type){case n.CONNECT:this.onconnect();break;case n.EVENT:case n.BINARY_EVENT:this.onevent(e);break;case n.ACK:case n.BINARY_ACK:this.onack(e);break;case n.DISCONNECT:this.ondisconnect();break;case n.ERROR:this.emit("error",e.data)}},p.prototype.onevent=function(e){var t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?h.apply(this,t):this.receiveBuffer.push(t)},p.prototype.ack=function(e){var t=this,r=!1;return function(){if(!r){r=!0;var i=o(arguments);a("sending ack %j",i),t.packet({type:l(i)?n.BINARY_ACK:n.ACK,id:e,data:i})}}},p.prototype.onack=function(e){var t=this.acks[e.id];"function"==typeof t?(a("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):a("bad ack %s",e.id)},p.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},p.prototype.emitBuffered=function(){var e;for(e=0;e<this.receiveBuffer.length;e++)h.apply(this,this.receiveBuffer[e]);for(this.receiveBuffer=[],e=0;e<this.sendBuffer.length;e++)this.packet(this.sendBuffer[e]);this.sendBuffer=[]},p.prototype.ondisconnect=function(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},p.prototype.destroy=function(){if(this.subs){for(var e=0;e<this.subs.length;e++)this.subs[e].destroy();this.subs=null}this.io.destroy(this)},p.prototype.close=p.prototype.disconnect=function(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:n.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},p.prototype.compress=function(e){return this.flags.compress=e,this},p.prototype.binary=function(e){return this.flags.binary=e,this}}(Uo);var $o=Ho;function Ho(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ho.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},Ho.prototype.reset=function(){this.attempts=0},Ho.prototype.setMin=function(e){this.ms=e},Ho.prototype.setMax=function(e){this.max=e},Ho.prototype.setJitter=function(e){this.jitter=e};var Vo=xn.exports,Wo=Uo.exports,zo=Mo.exports,Ko=on,Jo=Do,Yo=qo,Xo=zt.exports("socket.io-client:manager"),Qo=Eo,Go=$o,Zo=Object.prototype.hasOwnProperty,ei=ti;function ti(e,t){if(!(this instanceof ti))return new ti(e,t);e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.nsps={},this.subs=[],this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new Go({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this.readyState="closed",this.uri=e,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var n=t.parser||Ko;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}ti.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)Zo.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},ti.prototype.updateSocketIds=function(){for(var e in this.nsps)Zo.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},ti.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},zo(ti.prototype),ti.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},ti.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},ti.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},ti.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},ti.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},ti.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},ti.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},ti.prototype.open=ti.prototype.connect=function(e,t){if(Xo("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;Xo("opening %s",this.uri),this.engine=Vo(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var o=Jo(n,"open",(function(){r.onopen(),e&&e()})),i=Jo(n,"error",(function(t){if(Xo("connect_error"),r.cleanup(),r.readyState="closed",r.emitAll("connect_error",t),e){var n=new Error("Connection error");n.data=t,e(n)}else r.maybeReconnectOnOpen()}));if(!1!==this._timeout){var s=this._timeout;Xo("connect attempt will timeout after %d",s);var a=setTimeout((function(){Xo("connect attempt timed out after %d",s),o.destroy(),n.close(),n.emit("error","timeout"),r.emitAll("connect_timeout",s)}),s);this.subs.push({destroy:function(){clearTimeout(a)}})}return this.subs.push(o),this.subs.push(i),this},ti.prototype.onopen=function(){Xo("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(Jo(e,"data",Yo(this,"ondata"))),this.subs.push(Jo(e,"ping",Yo(this,"onping"))),this.subs.push(Jo(e,"pong",Yo(this,"onpong"))),this.subs.push(Jo(e,"error",Yo(this,"onerror"))),this.subs.push(Jo(e,"close",Yo(this,"onclose"))),this.subs.push(Jo(this.decoder,"decoded",Yo(this,"ondecoded")))},ti.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},ti.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},ti.prototype.ondata=function(e){this.decoder.add(e)},ti.prototype.ondecoded=function(e){this.emit("packet",e)},ti.prototype.onerror=function(e){Xo("error",e),this.emitAll("error",e)},ti.prototype.socket=function(e,t){var n=this.nsps[e];if(!n){n=new Wo(this,e,t),this.nsps[e]=n;var r=this;n.on("connecting",o),n.on("connect",(function(){n.id=r.generateId(e)})),this.autoConnect&&o()}function o(){~Qo(r.connecting,n)||r.connecting.push(n)}return n},ti.prototype.destroy=function(e){var t=Qo(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},ti.prototype.packet=function(e){Xo("writing packet %j",e);var t=this;e.query&&0===e.type&&(e.nsp+="?"+e.query),t.encoding?t.packetBuffer.push(e):(t.encoding=!0,this.encoder.encode(e,(function(n){for(var r=0;r<n.length;r++)t.engine.write(n[r],e.options);t.encoding=!1,t.processPacketQueue()})))},ti.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},ti.prototype.cleanup=function(){Xo("cleanup");for(var e=this.subs.length,t=0;t<e;t++){this.subs.shift().destroy()}this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},ti.prototype.close=ti.prototype.disconnect=function(){Xo("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},ti.prototype.onclose=function(e){Xo("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()},ti.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var e=this;if(this.backoff.attempts>=this._reconnectionAttempts)Xo("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();Xo("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var n=setTimeout((function(){e.skipReconnect||(Xo("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open((function(t){t?(Xo("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(Xo("reconnect success"),e.onreconnect())})))}),t);this.subs.push({destroy:function(){clearTimeout(n)}})}},ti.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)},function(e,t){var n=rn,r=on,o=ei,i=zt.exports("socket.io-client");e.exports=t=a;var s=t.managers={};function a(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var r,a=n(e),c=a.source,l=a.id,u=a.path,h=s[l]&&u in s[l].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||h?(i("ignoring socket cache for %s",c),r=o(c,t)):(s[l]||(i("new io instance for %s",c),s[l]=o(c,t)),r=s[l]),a.query&&!t.query&&(t.query=a.query),r.socket(a.path,t)}t.protocol=r.protocol,t.connect=a,t.Manager=ei,t.Socket=Uo.exports}($t,$t.exports);var ni=$t.exports;var ri={exports:{}};ri.exports=function(){function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){if(!a&&te)return te(s);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,(function(e){return o(t[s][1][e]||e)}),l,l.exports,e,t,n,r)}return n[s].exports}for(var i=te,s=0;s<r.length;s++)o(r[s]);return o}return e}()({1:[function(e,t,n){(function(n,r){(function(){var o=e("events").EventEmitter,i=e("./store"),s=e("mqtt-packet"),a=e("readable-stream").Writable,c=e("inherits"),l=e("reinterval"),u=e("./validations"),h=e("xtend"),p=e("debug")("mqttjs:client"),f=n?n.nextTick:function(e){setTimeout(e,0)},d=r.setImmediate||function(e){f(e)},m={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},g=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],y={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(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function b(e,t,n){p("sendPacket :: packet: %O",t),p("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),p("sendPacket :: writing to stream");var r=s.writeToStream(t,e.stream,e.options);p("sendPacket :: writeToStream result %s",r),!r&&n?(p("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",n)):n&&(p("sendPacket :: invoking cb"),n())}function w(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){e&&(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])})))}function C(e,t,n,r){p("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd),e.outgoingStore.put(t,(function(o){if(o)return n&&n(o);r(),b(e,t,n)}))}function S(e){p("nop ::",e)}function k(e,t){var n,r=this;if(!(this instanceof k))return new k(e,t);for(n in this.options=t||{},m)void 0===this.options[n]?this.options[n]=m[n]:this.options[n]=t[n];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:v(),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;function t(){var n=e.shift();p("deliver :: entry %o",n);var o=null;n&&(o=n.packet,p("deliver :: call _sendPacket for %o",o),r._sendPacket(o,(function(e){n.cb&&n.cb(e),t()})))}p("connect :: sending queued packets"),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!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null),p("close :: calling _setupReconnect"),this._setupReconnect()})),o.call(this),p("MqttClient :: setting up stream"),this._setupStream()}c(k,o),k.prototype._setupStream=function(){var e,t=this,n=new a,r=s.parser(this.options),o=null,i=[];function c(){if(i.length)f(l);else{var e=o;o=null,e()}}function l(){p("work :: getting next packet in queue");var e=i.shift();if(e)p("work :: packet pulled from queue"),t._handlePacket(e,c);else{p("work :: no packets in queue");var n=o;o=null,p("work :: done flag is %s",!!n),n&&n()}}function u(e){p("streamErrorHandler :: error",e.message),g.includes(e.code)?(p("streamErrorHandler :: emitting error"),t.emit("error",e)):S(e)}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),r.on("packet",(function(e){p("parser :: on packet push to packets array."),i.push(e)})),n._write=function(e,t,n){o=n,p("writable stream :: parsing buffer"),r.parse(e),l()},p("_setupStream :: pipe stream to writable stream"),this.stream.pipe(n),this.stream.on("error",u),this.stream.on("close",(function(){p("(%s)stream :: on close",t.options.clientId),_(t.outgoing),p("stream: emit close to MqttClient"),t.emit("close")})),p("_setupStream: sending packet `connect`"),(e=Object.create(this.options)).cmd="connect",b(this,e),r.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;this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket&&b(this,h({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 n=this.options;if(5===n.protocolVersion&&n.properties&&n.properties.maximumPacketSize&&n.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,n,r){var o;p("publish :: message `%s` to topic `%s`",t,e);var i=this.options;if("function"==typeof n&&(r=n,n=null),n=h({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;switch(o={cmd:"publish",topic:e,payload:t,qos:n.qos,retain:n.retain,messageId:this._nextId(),dup:n.dup},5===i.protocolVersion&&(o.properties=n.properties,(!i.properties&&o.properties&&o.properties.topicAlias||n.properties&&i.properties&&(n.properties.topicAlias&&i.properties.topicAliasMaximum&&n.properties.topicAlias>i.properties.topicAliasMaximum||!i.properties.topicAliasMaximum&&n.properties.topicAlias))&&delete o.properties.topicAlias),p("publish :: qos",n.qos),n.qos){case 1:case 2:this.outgoing[o.messageId]={volatile:!1,cb:r||S},this._storeProcessing?(p("_storeProcessing enabled"),this._packetIdsDuringStoreProcessing[o.messageId]=!1,this._storePacket(o,void 0,n.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,void 0,n.cbStorePut));break;default:this._storeProcessing?(p("_storeProcessing enabled"),this._storePacket(o,r,n.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,r,n.cbStorePut))}return this},k.prototype.subscribe=function(){for(var e,t=new Array(arguments.length),n=0;n<arguments.length;n++)t[n]=arguments[n];var r,o=[],i=t.shift(),s=i.resubscribe,a=t.pop()||S,c=t.pop(),l=this,f=this.options.protocolVersion;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof a&&(c=a,a=S),null!==(r=u.validateTopics(i)))return d(a,new Error("Invalid topic "+r)),this;if(this._checkDisconnecting(a))return p("subscribe: discconecting true"),this;var m={qos:0};if(5===f&&(m.nl=!1,m.rap=!1,m.rh=0),c=h(m,c),Array.isArray(i)?i.forEach((function(e){if(p("subscribe: array topic %s",e),!l._resubscribeTopics.hasOwnProperty(e)||l._resubscribeTopics[e].qos<c.qos||s){var t={topic:e,qos:c.qos};5===f&&(t.nl=c.nl,t.rap=c.rap,t.rh=c.rh,t.properties=c.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),!l._resubscribeTopics.hasOwnProperty(e)||l._resubscribeTopics[e].qos<i[e].qos||s){var t={topic:e,qos:i[e].qos};5===f&&(t.nl=i[e].nl,t.rap=i[e].rap,t.rh=i[e].rh,t.properties=c.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()},c.properties&&(e.properties=c.properties),o.length){if(this.options.resubscribe){p("subscribe :: resubscribe true");var g=[];o.forEach((function(e){if(l.options.reconnectPeriod>0){var t={qos:e.qos};5===f&&(t.nl=e.nl||!1,t.rap=e.rap||!1,t.rh=e.rh||0,t.properties=e.properties),l._resubscribeTopics[e.topic]=t,g.push(e.topic)}})),l.messageIdToTopic[e.messageId]=g}return this.outgoing[e.messageId]={volatile:!0,cb:function(e,t){if(!e)for(var n=t.granted,r=0;r<n.length;r+=1)o[r].qos=n[r];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,n=new Array(arguments.length),r=0;r<arguments.length;r++)n[r]=arguments[r];var o=n.shift(),i=n.pop()||S,s=n.pop();return"string"==typeof o&&(o=[o]),"function"!=typeof i&&(s=i,i=S),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,n){var r=this;function o(){p("end :: closeStores: closing incoming and outgoing stores"),r.disconnected=!0,r.incomingStore.close((function(e){r.outgoingStore.close((function(t){if(p("end :: closeStores: emitting end"),r.emit("end"),n){let r=e||t;p("end :: closeStores: invoking callback with args"),n(r)}}))})),r._deferredReconnect&&r._deferredReconnect()}function i(){p("end :: (%s) :: finish :: calling _cleanUp with force %s",r.options.clientId,e),r._cleanUp(e,(()=>{p("end :: finish :: calling process.nextTick on closeStores"),f(o.bind(r))}),t)}return p("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(n=t||S,t=e,e=!1,"object"!=typeof t&&(n=t,t=null,"function"!=typeof n&&(n=S))),"object"!=typeof t&&(n=t,t=null),p("end :: cb? %s",!!n),n=n||S,this.disconnecting?(n(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(p("end :: (%s) :: calling finish in 10ms once outgoing is empty",r.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(p("end :: (%s) :: immediately calling finish",r.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,n=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=n:n(),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 n=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&&w(this.outgoing),p("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{var r=h({cmd:"disconnect"},n);p("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(r,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,n){if(p("_sendPacket :: (%s) :: start",this.options.clientId),n=n||S,!this.connected)return p("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,n);switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void C(this,e,t,n);default:return void b(this,e,t)}switch(e.qos){case 2:case 1:C(this,e,t,n);break;default:b(this,e,t)}p("_sendPacket :: (%s) :: end",this.options.clientId)},k.prototype._storePacket=function(e,t,n){p("_storePacket :: packet: %o",e),p("_storePacket :: cb? %s",!!t),n=n||S,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);n()}))):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=l((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,n=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===n)this.reconnecting=!1,this._onConnect(e);else if(n>0){var r=new Error("Connection refused: "+y[n]);r.code=n,this.emit("error",r)}},k.prototype._handlePublish=function(e,t){p("_handlePublish: packet %o",e),t=void 0!==t?t:S;var n=e.topic.toString(),r=e.payload,o=e.qos,i=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];switch(p("_handlePublish: qos %d",o),o){case 2:a.customHandleAcks(n,r,e,(function(n,r){return n instanceof Error||(r=n,n=null),n?s.emit("error",n):-1===c.indexOf(r)?s.emit("error",new Error("Wrong reason code for pubrec")):void(r?s._sendPacket({cmd:"pubrec",messageId:i,reasonCode:r},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:i},t)})))}));break;case 1:a.customHandleAcks(n,r,e,(function(o,a){return o instanceof Error||(a=o,o=null),o?s.emit("error",o):-1===c.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",n,r,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",n,r,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,n=e.messageId,r=e.cmd,o=null,i=this.outgoing[n]?this.outgoing[n].cb:null,s=this;if(i){switch(p("_handleAck :: packet type",r),r){case"pubcomp":case"puback":var a=e.reasonCode;a&&a>0&&16!==a&&((t=new Error("Publish error: "+y[a])).code=a,i(t,e)),delete this.outgoing[n],this.outgoingStore.del(e,i);break;case"pubrec":o={cmd:"pubrel",qos:2,messageId:n};var c=e.reasonCode;c&&c>0&&16!==c?((t=new Error("Publish error: "+y[c])).code=c,i(t,e)):this._sendPacket(o);break;case"suback":delete this.outgoing[n];for(var l=0;l<e.granted.length;l++)if(0!=(128&e.granted[l])){var u=this.messageIdToTopic[n];u&&u.forEach((function(e){delete s._resubscribeTopics[e]}))}i(null,e);break;case"unsuback":delete this.outgoing[n],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:S;var n=e.messageId,r=this,o={cmd:"pubcomp",messageId:n};r.incomingStore.get(e,(function(e,n){e?r._sendPacket(o,t):(r.emit("message",n.topic,n.payload,n),r.handleMessage(n,(function(e){if(e)return t(e);r.incomingStore.del(n,S),r._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 n=0;n<t.length;n++){var r={};r[t[n]]=this._resubscribeTopics[t[n]],r.resubscribe=!0,this.subscribe(r,{properties:r[t[n]].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,n()}function n(){var r=t.outgoingStore.createStream();function o(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function i(){r.destroy(),r=null,o()}function s(){if(r){t._storeProcessing=!0;var e,n=r.read(1);n?t._packetIdsDuringStoreProcessing[n.messageId]?s():t.disconnecting||t.reconnectTimer?r.destroy&&r.destroy():(e=t.outgoing[n.messageId]?t.outgoing[n.messageId].cb:null,t.outgoing[n.messageId]={volatile:!1,cb:function(t,n){e&&e(t,n),s()}},t._packetIdsDuringStoreProcessing[n.messageId]=!0,t._sendPacket(n)):r.once("readable",s)}}t.once("close",i),r.on("error",(function(e){o(),t.removeListener("close",i),t.emit("error",e)})),r.on("end",(function(){var r=!0;for(var s in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[s]){r=!1;break}r?(o(),t.removeListener("close",i),t.emit("connect",e)):n()})),s()}},t.exports=k}).call(this)}).call(this,e("_process"),void 0!==Z?Z:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./store":7,"./validations":8,_process:32,debug:15,events:19,inherits:21,"mqtt-packet":24,"readable-stream":51,reinterval:52,xtend:61}],2:[function(e,t,n){(function(n){(function(){var r,o,i,s=e("readable-stream").Transform,a=e("duplexify"),c=!1;function l(){var e=new s;return e._write=function(e,t,n){r.sendSocketMessage({data:e.buffer,success:function(){n()},fail:function(){n(new Error)}})},e._flush=function(e){r.closeSocket({success:function(){e()}})},e}function u(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function h(e,t){var n="alis"===e.protocol?"wss":"ws",r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function p(){c||(c=!0,r.onSocketOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),r.onSocketMessage((function(e){if("string"==typeof e.data){var t=n.from(e.data,"base64");o.push(t)}else{var r=new FileReader;r.addEventListener("load",(function(){var e=r.result;e=e instanceof ArrayBuffer?n.from(e):n.from(e,"utf8"),o.push(e)})),r.readAsArrayBuffer(e.data)}})),r.onSocketClose((function(){i.end(),i.destroy()})),r.onSocketError((function(e){i.destroy(e)})))}function f(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";u(t);var s=h(t,e);return(r=t.my).connectSocket({url:s,protocols:n}),o=l(),i=a.obj(),p(),i}t.exports=f}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14,duplexify:17,"readable-stream":51}],3:[function(e,t,n){var r=e("net"),o=e("debug")("mqttjs:tcp");function i(e,t){var n,i;return t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost",n=t.port,i=t.hostname,o("port %d and host %s",n,i),r.createConnection(n,i)}t.exports=i},{debug:15,net:13}],4:[function(e,t,n){var r=e("tls"),o=e("debug")("mqttjs:tls");function i(e,t){var n;function i(r){t.rejectUnauthorized&&e.emit("error",r),n.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),(n=r.connect(t)).on("secureConnect",(function(){t.rejectUnauthorized&&!n.authorized?n.emit("error",new Error("TLS not authorized")):n.removeListener("error",i)})),n.on("error",i),n}t.exports=i},{debug:15,tls:13}],5:[function(e,t,n){(function(n,r){(function(){const o=e("ws"),i=e("debug")("mqttjs:ws"),s=e("duplexify"),a=e("readable-stream").Transform;let c=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];const l=void 0!==n&&"browser"===n.title||"function"==typeof __webpack_require__;function u(e,t){let n=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}function h(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={}),l||"wss"!==e.protocol||c.forEach((function(n){e.hasOwnProperty(n)&&!e.wsOptions.hasOwnProperty(n)&&(t.wsOptions[n]=e[n])})),t}function p(e){let t=h(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}function f(e,t,n){i("createWebSocket"),i("protocol: "+n.protocolId+" "+n.protocolVersion);const r="MQIsdp"===n.protocolId&&3===n.protocolVersion?"mqttv3.1":"mqtt";return i("creating new Websocket for url: "+t+" and protocol: "+r),new o(t,[r],n.wsOptions)}function d(e,t){const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";let r=u(t,e),o=new WebSocket(r,[n]);return o.binaryType="arraybuffer",o}function m(e,t){i("streamBuilder");let n=h(t);const r=u(n,e);let s=f(e,r,n),a=o.createWebSocketStream(s,n.wsOptions);return a.url=r,s.on("close",(()=>{a.destroy()})),a}function g(e,t){let n;i("browserStreamBuilder");const o=p(t).browserBufferSize||524288,c=t.browserBufferTimeout||1e3,l=!t.objectMode;let u=d(e,t),h=m(t,_,C);t.objectMode||(h._writev=w),h.on("close",(()=>{u.close()}));const f=void 0!==u.addEventListener;function m(e,t,n){let r=new a({objectModeMode:e.objectMode});return r._write=t,r._flush=n,r}function g(){n.setReadable(h),n.setWritable(h),n.emit("connect")}function y(){n.end(),n.destroy()}function v(e){n.destroy(e)}function b(e){let t=e.data;t=t instanceof ArrayBuffer?r.from(t):r.from(t,"utf8"),h.push(t)}function w(e,t){const n=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?n[t]=r.from(e[t],"utf8"):n[t]=e[t].chunk;this._write(r.concat(n),"binary",t)}function _(e,t,n){u.bufferedAmount>o&&setTimeout(_,c,e,t,n),l&&"string"==typeof e&&(e=r.from(e,"utf8"));try{u.send(e)}catch(e){return n(e)}n()}function C(e){u.close(),e()}return u.readyState===u.OPEN?n=h:(n=n=s(void 0,void 0,t),t.objectMode||(n._writev=w),f?u.addEventListener("open",g):u.onopen=g),n.socket=u,f?(u.addEventListener("close",y),u.addEventListener("error",v),u.addEventListener("message",b)):(u.onclose=y,u.onerror=v,u.onmessage=b),n}t.exports=l?g:m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:32,buffer:14,debug:15,duplexify:17,"readable-stream":51,ws:60}],6:[function(e,t,n){(function(n){(function(){var r,o,i,s=e("readable-stream").Transform,a=e("duplexify");function c(){var e=new s;return e._write=function(e,t,n){r.send({data:e.buffer,success:function(){n()},fail:function(e){n(new Error(e))}})},e._flush=function(e){r.close({success:function(){e()}})},e}function l(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function u(e,t){var n="wxs"===e.protocol?"wss":"ws",r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function h(){r.onOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),r.onMessage((function(e){var t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),o.push(t)})),r.onClose((function(){i.end(),i.destroy()})),r.onError((function(e){i.destroy(new Error(e.errMsg))}))}function p(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";l(t);var s=u(t,e);r=wx.connectSocket({url:s,protocols:[n]}),o=c(),(i=a.obj())._destroy=function(e,t){r.close({success:function(){t&&t(e)}})};var p=i.destroy;return i.destroy=function(){i.destroy=p;var e=this;setTimeout((function(){r.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(i),h(),i}t.exports=p}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14,duplexify:17,"readable-stream":51}],7:[function(e,t,n){var r=e("xtend"),o=e("readable-stream").Readable,i={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=r(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,n=[],r=0;return this._inflights.forEach((function(e,t){n.push(e)})),e._read=function(){!t&&r<n.length?this.push(n[r++]):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()},t.exports=a},{"readable-stream":51,xtend:61}],8:[function(e,t,n){function r(e){for(var t=e.split("/"),n=0;n<t.length;n++)if("+"!==t[n]){if("#"===t[n])return n===t.length-1;if(-1!==t[n].indexOf("+")||-1!==t[n].indexOf("#"))return!1}return!0}function o(e){if(0===e.length)return"empty_topic_list";for(var t=0;t<e.length;t++)if(!r(e[t]))return e[t];return null}t.exports={validateTopics:o}},{}],9:[function(e,t,n){(function(n){(function(){var r=e("../client"),o=e("../store"),i=e("url"),s=e("xtend"),a=e("debug")("mqttjs"),c={};function l(e){var t;e.auth&&((t=e.auth.match(/^(.+):(.+)$/))?(e.username=t[1],e.password=t[2]):e.username=e.auth)}function u(e,t){if(a("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){var n=i.parse(e,!0);if(null!=n.port&&(n.port=Number(n.port)),null===(t=s(n,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(l(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(!c[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 c[e]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");function u(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),c[t.protocol](e,t)}t.protocol&&(t.defaultProtocol=t.protocol);var h=new r(u,t);return h.on("error",(function(){})),h}void 0!==n&&"browser"!==n.title||"function"!=typeof __webpack_require__?(c.mqtt=e("./tcp"),c.tcp=e("./tcp"),c.ssl=e("./tls"),c.tls=e("./tls"),c.mqtts=e("./tls")):(c.wx=e("./wx"),c.wxs=e("./wx"),c.ali=e("./ali"),c.alis=e("./ali")),c.ws=e("./ws"),c.wss=e("./ws"),t.exports=u,t.exports.connect=u,t.exports.MqttClient=r,t.exports.Store=o}).call(this)}).call(this,e("_process"))},{"../client":1,"../store":7,"./ali":2,"./tcp":3,"./tls":4,"./ws":5,"./wx":6,_process:32,debug:15,url:56,xtend:61}],10:[function(e,t,n){n.byteLength=u,n.toByteArray=p,n.fromByteArray=m;for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],o[s.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e){var t=l(e),n=t[0],r=t[1];return 3*(n+r)/4-r}function h(e,t,n){return 3*(t+n)/4-n}function p(e){var t,n,r=l(e),s=r[0],a=r[1],c=new i(h(e,s,a)),u=0,p=a>0?s-4:s;for(n=0;n<p;n+=4)t=o[e.charCodeAt(n)]<<18|o[e.charCodeAt(n+1)]<<12|o[e.charCodeAt(n+2)]<<6|o[e.charCodeAt(n+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;return 2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,c[u++]=255&t),1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t),c}function f(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function d(e,t,n){for(var r,o=[],i=t;i<n;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(f(r));return o.join("")}function m(e){for(var t,n=e.length,o=n%3,i=[],s=16383,a=0,c=n-o;a<c;a+=s)i.push(d(e,a,a+s>c?c:a+s));return 1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],11:[function(e,t,n){const{Buffer:r}=e("buffer"),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 n=0;n<this._bufs.length;n++){const r=t+this._bufs[n].length;if(e<r||n===this._bufs.length-1)return[n,e-t];t=r}},i.prototype._reverseOffset=function(e){const t=e[0];let n=e[1];for(let e=0;e<t;e++)n+=this._bufs[e].length;return n},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,n,o){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof o||o>this.length)&&(o=this.length),n>=this.length)return e||r.alloc(0);if(o<=0)return e||r.alloc(0);const i=!!e,s=this._offset(n),a=o-n;let c=a,l=i&&t||0,u=s[1];if(0===n&&o===this.length){if(!i)return 1===this._bufs.length?this._bufs[0]:r.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,l),l+=this._bufs[t].length;return e}if(c<=this._bufs[s[0]].length-u)return i?this._bufs[s[0]].copy(e,t,u,u+c):this._bufs[s[0]].slice(u,u+c);i||(e=r.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const n=this._bufs[t].length-u;if(!(c>n)){this._bufs[t].copy(e,l,u,u+c),l+=n;break}this._bufs[t].copy(e,l,u),l+=n,c-=n,u&&(u=0)}return e.length>l?e.slice(0,l):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 n=this._offset(e),r=this._offset(t),o=this._bufs.slice(n[0],r[0]+1);return 0===r[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,r[1]),0!==n[1]&&(o[0]=o[0].slice(n[1])),this._new(o)},i.prototype.toString=function(e,t,n){return this.slice(t,n).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(r.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(r.from(e));return this},i.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},i.prototype.indexOf=function(e,t,n){if(void 0===n&&"string"==typeof t&&(n=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=r.from([e]):"string"==typeof e?e=r.from(e,n):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=r.from(e.buffer,e.byteOffset,e.byteLength):r.isBuffer(e)||(e=r.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 n=t.indexOf(e,s);if(-1!==n)return this._reverseOffset([i,n]);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 n=0;n<t.length;n++)if(this.get(e+n)!==t[n])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){null===e[t]?i.prototype[t]=function(e,n){return this.slice(e,e+n)[t](0,n)}:i.prototype[t]=function(n=0){return this.slice(n,n+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]},t.exports=i},{buffer:14}],12:[function(e,t,n){const r=e("readable-stream").Duplex,o=e("inherits"),i=e("./BufferList");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),r.call(this)}o(s,r),Object.assign(s.prototype,i.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,n){this._appendBuffer(e),"function"==typeof n&&n()},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){r.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,t.exports=s,t.exports.BufferListStream=s,t.exports.BufferList=i},{"./BufferList":11,inherits:21,"readable-stream":51}],13:[function(e,t,n){},{}],14:[function(e,t,n){(function(t){(function(){var t=e("base64-js"),r=e("ieee754");n.Buffer=a,n.SlowBuffer=y,n.INSPECT_MAX_BYTES=50;var o=2147483647;function i(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return c(e,t,n)}function c(e,t,n){if("string"==typeof e)return p(e,t);if(ArrayBuffer.isView(e))return f(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return d(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return a.from(r,t,n);var o=m(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function u(e,t,n){return l(e),e<=0?s(e):void 0!==t?"string"==typeof n?s(e).fill(t,n):s(e).fill(t):s(e)}function h(e){return l(e),s(e<0?0:0|g(e))}function p(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|v(e,t),r=s(n),o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}function f(e){for(var t=e.length<0?0:0|g(e.length),n=s(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function d(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return(r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n)).__proto__=a.prototype,r}function m(e){if(a.isBuffer(e)){var t=0|g(e.length),n=s(t);return 0===n.length||e.copy(n,0,0,t),n}return void 0!==e.length?"number"!=typeof e.length||Q(e.length)?s(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}function g(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function y(e){return+e!=e&&(e=0),a.alloc(+e)}function v(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return J(e).length;default:if(o)return r?-1:W(e).length;t=(""+t).toLowerCase(),o=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return j(this,t,n);case"utf8":case"utf-8":return R(this,t,n);case"ascii":return P(this,t,n);case"latin1":case"binary":return B(this,t,n);case"base64":return x(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function _(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Q(n=+n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=a.from(t,r)),a.isBuffer(t))return 0===t.length?-1:C(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):C(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function C(e,t,n,r,o){var i,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var u=-1;for(i=n;i<a;i++)if(l(e,i)===l(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===c)return u*s}else-1!==u&&(i-=i-u),u=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var h=!0,p=0;p<c;p++)if(l(e,i+p)!==l(t,p)){h=!1;break}if(h)return i}return-1}function S(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(Q(a))return s;e[n+s]=a}return s}function k(e,t,n,r){return Y(W(t,e.length-n),e,n,r)}function A(e,t,n,r){return Y(z(t),e,n,r)}function E(e,t,n,r){return A(e,t,n,r)}function I(e,t,n,r){return Y(J(t),e,n,r)}function O(e,t,n,r){return Y(K(t,e.length-n),e,n,r)}function x(e,n,r){return 0===n&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function R(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,c,l=e[o],u=null,h=l>239?4:l>223?3:l>191?2:1;if(o+h<=n)switch(h){case 1:l<128&&(u=l);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&l)<<6|63&i)>127&&(u=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&l)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,h=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=h}return T(r)}n.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=i(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,n){return c(e,t,n)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,n){return u(e,t,n)},a.allocUnsafe=function(e){return h(e)},a.allocUnsafeSlow=function(e){return h(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),X(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},a.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}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=a.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(X(i,Uint8Array)&&(i=a.from(i)),!a.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},a.byteLength=v,a.prototype._isBuffer=!0,a.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)w(this,t,t+1);return this},a.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)w(this,t,t+3),w(this,t+1,t+2);return this},a.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)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?R(this,0,e):b.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a.prototype.compare=function(e,t,n,r,o){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),c=Math.min(i,s),l=this.slice(r,o),u=e.slice(t,n),h=0;h<c;++h)if(l[h]!==u[h]){i=l[h],s=u[h];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},a.prototype.indexOf=function(e,t,n){return _(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return _(this,e,t,n,!1)},a.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return S(this,e,t,n);case"utf8":case"utf-8":return k(this,e,t,n);case"ascii":return A(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return I(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var F=4096;function T(e){var t=e.length;if(t<=F)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=F));return n}function P(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function B(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function j(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=V(e[i]);return o}function U(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function M(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function N(e,t,n,r,o,i){if(!a.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(n+r>e.length)throw new RangeError("Index out of range")}function D(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(e,t,n,o,i){return t=+t,n>>>=0,i||D(e,t,n,4),r.write(e,t,n,o,23,4),n+4}function q(e,t,n,o,i){return t=+t,n>>>=0,i||D(e,t,n,8),r.write(e,t,n,o,52,8),n+8}a.prototype.slice=function(e,t){var n=this.length;(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);var r=this.subarray(e,t);return r.__proto__=a.prototype,r},a.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},a.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},a.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},a.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||N(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},a.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||N(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);N(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},a.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);N(this,e,t,n,o-1,-o)}var i=n-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+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,r){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o=r-n;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,n,r);else if(this===e&&n<t&&t<r)for(var i=o-1;i>=0;--i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,r),t);return o},a.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){var o=e.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(e=o)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=a.isBuffer(e)?e:a.from(e,r),c=s.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=s[i%c]}return this};var $=/[^+/0-9A-Za-z-_]/g;function H(e){if((e=(e=e.split("=")[0]).trim().replace($,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function V(e){return e<16?"0"+e.toString(16):e.toString(16)}function W(e,t){var n;t=t||1/0;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function z(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function K(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}function J(e){return t.toByteArray(H(e))}function Y(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Q(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":10,buffer:14,ieee754:20}],15:[function(e,t,n){(function(r){(function(){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),e.splice(o,0,n)}function s(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}}function a(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}n.formatArgs=i,n.save=s,n.load=a,n.useColors=o,n.storage=c(),n.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`."))}})(),n.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"],n.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(n);const{formatters:l}=t.exports;l.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":16,_process:32}],16:[function(e,t,n){function r(t){function n(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){let t,n=null;function i(...e){if(!i.enabled)return;const n=i,o=Number(new Date),s=o-(t||o);n.diff=s,n.prev=t,n.curr=o,t=o,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,o)=>{if("%%"===t)return"%";a++;const i=r.formatters[o];if("function"==typeof i){const r=e[a];t=i.call(n,r),e.splice(a,1),a--}return t})),r.formatArgs.call(n,e),(n.log||r.log).apply(n,e)}return i.namespace=e,i.useColors=r.useColors(),i.color=r.selectColor(e),i.extend=o,i.destroy=r.destroy,Object.defineProperty(i,"enabled",{enumerable:!0,configurable:!1,get:()=>null===n?r.enabled(e):n,set:e=>{n=e}}),"function"==typeof r.init&&r.init(i),i}function o(e,t){const n=r(this.namespace+(void 0===t?":":t)+e);return n.log=this.log,n}function i(e){let t;r.save(e),r.names=[],r.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")))}function s(){const e=[...r.names.map(c),...r.skips.map(c).map((e=>"-"+e))].join(",");return r.enable(""),e}function a(e){if("*"===e[e.length-1])return!0;let t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1}function c(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}function l(e){return e instanceof Error?e.stack||e.message:e}function u(){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.debug=r,r.default=r,r.coerce=l,r.disable=s,r.enable=i,r.enabled=a,r.humanize=e("ms"),r.destroy=u,Object.keys(t).forEach((e=>{r[e]=t[e]})),r.names=[],r.skips=[],r.formatters={},r.selectColor=n,r.enable(r.load()),r}t.exports=r},{ms:29}],17:[function(e,t,n){(function(n,r){(function(){var o=e("readable-stream"),i=e("end-of-stream"),s=e("inherits"),a=e("stream-shift"),c=r.from&&r.from!==Uint8Array.from?r.from([0]):new r([0]),l=function(e,t){e._corked?e.once("uncork",t):t()},u=function(e,t){e._autoDestroy&&e.destroy(t)},h=function(e,t){return function(n){n?u(e,"premature close"===n.message?null:n):t&&!e._ended&&e.end()}},p=function(e,t){return e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),void t()):t()},f=function(){},d=function(e){return new o.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},m=function(e,t,n){if(!(this instanceof m))return new m(e,t,n);o.Duplex.call(this,n),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!n||!1!==n.autoDestroy,this._forwardDestroy=!n||!1!==n.destroy,this._forwardEnd=!n||!1!==n.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(m,o.Duplex),m.obj=function(e,t,n){return n||(n={}),n.objectMode=!0,n.highWaterMark=16,new m(e,t,n)},m.prototype.cork=function(){1==++this._corked&&this.emit("cork")},m.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},m.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},h(this,this._forwardEnd)),o=function(){var e=t._ondrain;t._ondrain=null,e&&e()},s=function(){t._writable.removeListener("drain",o),r()};this._unwrite&&n.nextTick(o),this._writable=e,this._writable.on("drain",o),this._unwrite=s,this.uncork()}else this.end()},m.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=this,n=i(e,{writable:!1,readable:!0},h(this)),r=function(){t._forward()},o=function(){t.push(null)},s=function(){t._readable2.removeListener("readable",r),t._readable2.removeListener("end",o),n()};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:d(e),this._readable2.on("readable",r),this._readable2.on("end",o),this._unread=s,this._forward()}},m.prototype._read=function(){this._drained=!0,this._forward()},m.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}},m.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)}))},m.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")},m.prototype._write=function(e,t,n){if(!this.destroyed)return this._corked?l(this,this._write.bind(this,e,t,n)):e===c?this._finish(n):this._writable?void(!1===this._writable.write(e)?this._ondrain=n:this.destroyed||n()):n()},m.prototype._finish=function(e){var t=this;this.emit("preend"),l(this,(function(){p(t._forwardEnd&&t._writable,(function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),l(t,e)}))}))},m.prototype.end=function(e,t,n){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.write(c),o.Writable.prototype.end.call(this,n))},t.exports=m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:32,buffer:14,"end-of-stream":18,inherits:21,"readable-stream":51,"stream-shift":54}],18:[function(e,t,n){(function(n){(function(){var r=e("once"),o=function(){},i=function(e){return e.setHeader&&"function"==typeof e.abort},s=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},a=function(e,t,c){if("function"==typeof t)return a(e,null,t);t||(t={}),c=r(c||o);var l=e._writableState,u=e._readableState,h=t.readable||!1!==t.readable&&e.readable,p=t.writable||!1!==t.writable&&e.writable,f=!1,d=function(){e.writable||m()},m=function(){p=!1,h||c.call(e)},g=function(){h=!1,p||c.call(e)},y=function(t){c.call(e,t?new Error("exited with error code: "+t):null)},v=function(t){c.call(e,t)},b=function(){n.nextTick(w)},w=function(){if(!f)return(!h||u&&u.ended&&!u.destroyed)&&(!p||l&&l.ended&&!l.destroyed)?void 0:c.call(e,new Error("premature close"))},_=function(){e.req.on("finish",m)};return i(e)?(e.on("complete",m),e.on("abort",b),e.req?_():e.on("request",_)):p&&!l&&(e.on("end",d),e.on("close",d)),s(e)&&e.on("exit",y),e.on("end",g),e.on("finish",m),!1!==t.error&&e.on("error",v),e.on("close",b),function(){f=!0,e.removeListener("complete",m),e.removeListener("abort",b),e.removeListener("request",_),e.req&&e.req.removeListener("finish",m),e.removeListener("end",d),e.removeListener("close",d),e.removeListener("finish",m),e.removeListener("exit",y),e.removeListener("end",g),e.removeListener("error",v),e.removeListener("close",b)}};t.exports=a}).call(this)}).call(this,e("_process"))},{_process:32,once:30}],19:[function(e,t,n){var r=Object.create||k,o=Object.keys||A,i=Function.prototype.bind||E;function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,c=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),a=0===l.x}catch(e){a=!1}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function h(e,t,n){if(t)e.call(n);else for(var r=e.length,o=C(e,r),i=0;i<r;++i)o[i].call(n)}function p(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,i=C(e,o),s=0;s<o;++s)i[s].call(n,r)}function f(e,t,n,r,o){if(t)e.call(n,r,o);else for(var i=e.length,s=C(e,i),a=0;a<i;++a)s[a].call(n,r,o)}function d(e,t,n,r,o,i){if(t)e.call(n,r,o,i);else for(var s=e.length,a=C(e,s),c=0;c<s;++c)a[c].call(n,r,o,i)}function m(e,t,n,r){if(t)e.apply(n,r);else for(var o=e.length,i=C(e,o),s=0;s<o;++s)i[s].apply(n,r)}function g(e,t,n,o){var i,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),a=s[t]):(s=e._events=r(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=o?[n,a]:[a,n]:o?a.unshift(n):a.push(n),!a.warned&&(i=u(e))&&i>0&&a.length>i){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",c.name,c.message)}}else a=s[t]=n,++e._eventsCount;return e}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function v(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=i.call(y,r);return o.listener=n,r.wrapFn=o,o}function b(e,t,n){var r=e._events;if(!r)return[];var o=r[t];return o?"function"==typeof o?n?[o.listener||o]:[o]:n?S(o):C(o,o.length):[]}function w(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function _(e,t){for(var n=t,r=n+1,o=e.length;r<o;n+=1,r+=1)e[n]=e[r];e.pop()}function C(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function S(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function k(e){var t=function(){};return t.prototype=e,new t}function A(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t);return t}function E(e){var t=this;return function(){return t.apply(e,arguments)}}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');c=e}}):s.defaultMaxListeners=c,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){var t,n,r,o,i,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var c=new Error('Unhandled "error" event. ('+t+")");throw c.context=t,c}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:h(n,l,this);break;case 2:p(n,l,this,arguments[1]);break;case 3:f(n,l,this,arguments[1],arguments[2]);break;case 4:d(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i<r;i++)o[i-1]=arguments[i];m(n,l,this,o)}return!0},s.prototype.addListener=function(e,t){return g(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return g(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,v(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,v(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,o,i,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(n=o[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=r(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){a=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():_(n,i),1===n.length&&(o[e]=n[0]),o.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.removeAllListeners=function(e){var t,n,i;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=r(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=r(null):delete n[e]),this;if(0===arguments.length){var s,a=o(n);for(i=0;i<a.length;++i)"removeListener"!==(s=a[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return b(this,e,!0)},s.prototype.rawListeners=function(e){return b(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):w.call(e,t)},s.prototype.listenerCount=w,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],20:[function(e,t,n){
|
|
3
3
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
4
|
-
n.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,l=c>>1,u=-7,h=n?o-1:0,p=n?-1:1,f=e[t+h];for(h+=p,i=f&(1<<-u)-1,f>>=-u,u+=a;u>0;i=256*i+e[t+h],h+=p,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=256*s+e[t+h],h+=p,u-=8);if(0===i)i=1-l;else{if(i===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),i-=l}return(f?-1:1)*s*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var s,a,c,l=8*i-o-1,u=(1<<l)-1,h=u>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,d=r?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=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?p/c:p*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*c-1)*Math.pow(2,o),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;e[n+f]=255&a,f+=d,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;e[n+f]=255&s,f+=d,s/=256,l-=8);e[n+f-d]|=128*m}},{}],21:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],22:[function(e,t,n){(function(e){(function(){const n=t.exports;n.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"},n.codes={};for(const e in n.types){const t=n.types[e];n.codes[t]=e}n.CMD_SHIFT=4,n.CMD_MASK=240,n.DUP_MASK=8,n.QOS_MASK=3,n.QOS_SHIFT=1,n.RETAIN_MASK=1,n.VARBYTEINT_MASK=127,n.VARBYTEINT_FIN_MASK=128,n.VARBYTEINT_MAX=268435455,n.SESSIONPRESENT_MASK=1,n.SESSIONPRESENT_HEADER=e.from([n.SESSIONPRESENT_MASK]),n.CONNACK_HEADER=e.from([n.codes.connack<<n.CMD_SHIFT]),n.USERNAME_MASK=128,n.PASSWORD_MASK=64,n.WILL_RETAIN_MASK=32,n.WILL_QOS_MASK=24,n.WILL_QOS_SHIFT=3,n.WILL_FLAG_MASK=4,n.CLEAN_SESSION_MASK=2,n.CONNECT_HEADER=e.from([n.codes.connect<<n.CMD_SHIFT]),n.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},n.propertiesCodes={};for(const e in n.properties){const t=n.properties[e];n.propertiesCodes[t]=e}function r(t){return[0,1,2].map((r=>[0,1].map((o=>[0,1].map((i=>{const s=e.alloc(1);return s.writeUInt8(n.codes[t]<<n.CMD_SHIFT|(o?n.DUP_MASK:0)|r<<n.QOS_SHIFT|i,0,!0),s}))))))}n.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"},n.PUBLISH_HEADER=r("publish"),n.SUBSCRIBE_HEADER=r("subscribe"),n.SUBSCRIBE_OPTIONS_QOS_MASK=3,n.SUBSCRIBE_OPTIONS_NL_MASK=1,n.SUBSCRIBE_OPTIONS_NL_SHIFT=2,n.SUBSCRIBE_OPTIONS_RAP_MASK=1,n.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,n.SUBSCRIBE_OPTIONS_RH_MASK=3,n.SUBSCRIBE_OPTIONS_RH_SHIFT=4,n.SUBSCRIBE_OPTIONS_RH=[0,16,32],n.SUBSCRIBE_OPTIONS_NL=4,n.SUBSCRIBE_OPTIONS_RAP=8,n.SUBSCRIBE_OPTIONS_QOS=[0,1,2],n.UNSUBSCRIBE_HEADER=r("unsubscribe"),n.ACKS={unsuback:r("unsuback"),puback:r("puback"),pubcomp:r("pubcomp"),pubrel:r("pubrel"),pubrec:r("pubrec")},n.SUBACK_HEADER=e.from([n.codes.suback<<n.CMD_SHIFT]),n.VERSION3=e.from([3]),n.VERSION4=e.from([4]),n.VERSION5=e.from([5]),n.VERSION131=e.from([131]),n.VERSION132=e.from([132]),n.QOS=[0,1,2].map((t=>e.from([t]))),n.EMPTY={pingreq:e.from([n.codes.pingreq<<4,0]),pingresp:e.from([n.codes.pingresp<<4,0]),disconnect:e.from([n.codes.disconnect<<4,0])}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14}],23:[function(e,t,n){(function(n){(function(){const r=e("./writeToStream"),o=e("events");function i(e,t){const n=new s;return r(e,n,t),n.concat()}class s 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 t=new Array(this._array.length),r=this._array;let o,i=0;for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?t[o]=r[o].length:t[o]=n.byteLength(r[o]),e+=t[o];const s=n.allocUnsafe(e);for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?(r[o].copy(s,i),i+=t[o]):(s.write(r[o],i),i+=t[o]);return s}}t.exports=i}).call(this)}).call(this,e("buffer").Buffer)},{"./writeToStream":28,buffer:14,events:19}],24:[function(e,t,n){n.parser=e("./parser").parser,n.generate=e("./generate"),n.writeToStream=e("./writeToStream")},{"./generate":23,"./parser":27,"./writeToStream":28}],25:[function(e,t,n){(function(e){(function(){const n=65536,r={},o=e.isBuffer(e.from([1,2]).subarray(0,1));function i(t){const n=e.allocUnsafe(2);return n.writeUInt8(t>>8,0),n.writeUInt8(255&t,1),n}function s(){for(let e=0;e<n;e++)r[e]=i(e)}function a(t){const n=4;let r=0,i=0;const s=e.allocUnsafe(n);do{r=t%128|0,(t=t/128|0)>0&&(r|=128),s.writeUInt8(r,i++)}while(t>0&&i<n);return t>0&&(i=0),o?s.subarray(0,i):s.slice(0,i)}function c(t){const n=e.allocUnsafe(4);return n.writeUInt32BE(t,0),n}t.exports={cache:r,generateCache:s,generateNumber:i,genBufVariableByteInt:a,generate4ByteBuffer:c}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14}],26:[function(e,t,n){class r{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}t.exports=r},{}],27:[function(e,t,n){const r=e("bl"),o=e("events"),i=e("./packet"),s=e("./constants"),a=e("debug")("mqtt-packet:parser");class c extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof c?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new c).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new i,this.error=null,this._list=r(),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,n,r;a("_parseConnect");const o={},i=this.packet,c=this._parseString();if(null===c)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==c&&"MQIsdp"!==c)return this._emitError(new Error("Invalid protocolId"));if(i.protocolId=c,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 l=this._parseString();if(null===l)return this._emitError(new Error("Packet too short"));if(i.clientId=l,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(r=this._parseString(),null===r)return this._emitError(new Error("Cannot parse username"));i.username=r,a("_parseConnect: packet.username: %s",i.username)}if(o.password){if(n=this._parseBuffer(),null===n)return this._emitError(new Error("Cannot parse password"));i.password=n}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,n,r,o,i,c,l;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));n=this._parseByte(),r=n&s.SUBSCRIBE_OPTIONS_QOS_MASK,c=0!=(n>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(n>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),o=n>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,l={topic:t,qos:r},5===this.settings.protocolVersion?(l.nl=c,l.rap=i,l.rh=o):this.settings.bridgeMode&&(l.rh=0,l.rap=!0,l.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",l),e.subscriptions.push(l)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!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(),n=t+this._pos;if(-1===t||n>this._list.length||n>this.packet.length)return null;const r=this._list.toString("utf8",this._pos,n);return this._pos+=t,a("_parseString: result: %s",r),r}_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 n=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",n),n}_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");const t=4;let n,r=0,o=1,i=0,c=!1;const l=this._pos?this._pos:0;for(;r<t&&l+r<this._list.length;){if(n=this._list.readUInt8(l+r++),i+=o*(n&s.VARBYTEINT_MASK),o*=128,0==(n&s.VARBYTEINT_FIN_MASK)){c=!0;break}if(this._list.length<=r)break}return!c&&r===t&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=r),c=!!c&&(e?{bytes:r,value:i}:i),a("_parseVarByteNum: result: %o",c),c}_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,n={};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)n[t]?(Array.isArray(n[t])||(n[t]=[n[t]]),n[t].push(this._parseByType(s.propertiesTypes[t]))):n[t]=this._parseByType(s.propertiesTypes[t]);else{n[t]||(n[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(n[t][e.name])if(Array.isArray(n[t][e.name]))n[t][e.name].push(e.value);else{const r=n[t][e.name];n[t][e.name]=[r],n[t][e.name].push(e.value)}else n[t][e.name]=e.value}}return n}_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)}}t.exports=c},{"./constants":22,"./packet":26,bl:12,debug:15,events:19}],28:[function(e,t,n){(function(n){(function(){const r=e("./constants"),o=n.allocUnsafe(0),i=n.from([0]),s=e("./numbers"),a=e("process-nextick-args").nextTick,c=e("debug")("mqtt-packet:writeToStream"),l=s.cache,u=s.generateNumber,h=s.generateCache,p=s.genBufVariableByteInt,f=s.generate4ByteBuffer;let d=P,m=!0;function g(e,t,n){switch(c("generate called"),t.cork&&(t.cork(),a(y,t)),m&&(m=!1,h()),c("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return v(e,t);case"connack":return b(e,t,n);case"publish":return w(e,t,n);case"puback":case"pubrec":case"pubrel":case"pubcomp":return _(e,t,n);case"subscribe":return C(e,t,n);case"suback":return S(e,t,n);case"unsubscribe":return k(e,t,n);case"unsuback":return A(e,t,n);case"pingreq":case"pingresp":return E(e,t);case"disconnect":return I(e,t,n);case"auth":return x(e,t,n);default:return t.emit("error",new Error("Unknown command")),!1}}function y(e){e.uncork()}function v(e,t,o){const i=e||{},s=i.protocolId||"MQTT";let a=i.protocolVersion||4;const c=i.will;let l=i.clean;const u=i.keepalive||0,h=i.clientId||"",p=i.username,f=i.password,m=i.properties;void 0===l&&(l=!0);let g=0;if(!s||"string"!=typeof s&&!n.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),!1;if(g+=s.length+2,3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),!1;if(g+=1,("string"==typeof h||n.isBuffer(h))&&(h||a>=4)&&(h||l))g+=n.byteLength(h)+2;else{if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*l==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof u||u<0||u>65535||u%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;if(g+=2,g+=1,5===a){var y=M(t,m);if(!y)return!1;g+=y.length}if(c){if("object"!=typeof c)return t.emit("error",new Error("Invalid will")),!1;if(!c.topic||"string"!=typeof c.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(g+=n.byteLength(c.topic)+2,g+=2,c.payload){if(!(c.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof c.payload?g+=n.byteLength(c.payload):g+=c.payload.length}var v={};if(5===a){if(!(v=M(t,c.properties)))return!1;g+=v.length}}let b=!1;if(null!=p){if(!$(p))return t.emit("error",new Error("Invalid username")),!1;b=!0,g+=n.byteLength(p)+2}if(null!=f){if(!b)return t.emit("error",new Error("Username is required to use password")),!1;if(!$(f))return t.emit("error",new Error("Invalid password")),!1;g+=q(f)+2}t.write(r.CONNECT_HEADER),O(t,g),U(t,s),i.bridgeMode&&(a+=128),t.write(131===a?r.VERSION131:132===a?r.VERSION132:4===a?r.VERSION4:5===a?r.VERSION5:r.VERSION3);let w=0;return w|=null!=p?r.USERNAME_MASK:0,w|=null!=f?r.PASSWORD_MASK:0,w|=c&&c.retain?r.WILL_RETAIN_MASK:0,w|=c&&c.qos?c.qos<<r.WILL_QOS_SHIFT:0,w|=c?r.WILL_FLAG_MASK:0,w|=l?r.CLEAN_SESSION_MASK:0,t.write(n.from([w])),d(t,u),5===a&&y.write(),U(t,h),c&&(5===a&&v.write(),F(t,c.topic),U(t,c.payload)),null!=p&&U(t,p),null!=f&&U(t,f),!0}function b(e,t,o){const s=o?o.protocolVersion:4,a=e||{},c=5===s?a.reasonCode:a.returnCode,l=a.properties;let u=2;if("number"!=typeof c)return t.emit("error",new Error("Invalid return code")),!1;let h=null;if(5===s){if(h=M(t,l),!h)return!1;u+=h.length}return t.write(r.CONNACK_HEADER),O(t,u),t.write(a.sessionPresent?r.SESSIONPRESENT_HEADER:i),t.write(n.from([c])),null!=h&&h.write(),!0}function w(e,t,i){c("publish: packet: %o",e);const s=i?i.protocolVersion:4,a=e||{},l=a.qos||0,u=a.retain?r.RETAIN_MASK:0,h=a.topic,p=a.payload||o,f=a.messageId,m=a.properties;let g=0;if("string"==typeof h)g+=n.byteLength(h)+2;else{if(!n.isBuffer(h))return t.emit("error",new Error("Invalid topic")),!1;g+=h.length+2}if(n.isBuffer(p)?g+=p.length:g+=n.byteLength(p),l&&"number"!=typeof f)return t.emit("error",new Error("Invalid messageId")),!1;l&&(g+=2);let y=null;if(5===s){if(y=M(t,m),!y)return!1;g+=y.length}return t.write(r.PUBLISH_HEADER[l][a.dup?1:0][u?1:0]),O(t,g),d(t,q(h)),t.write(h),l>0&&d(t,f),null!=y&&y.write(),c("publish: payload: %o",p),t.write(p)}function _(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,l=s.dup&&"pubrel"===a?r.DUP_MASK:0;let u=0;const h=s.reasonCode,p=s.properties;let f=5===i?3:2;if("pubrel"===a&&(u=1),"number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===i&&"object"==typeof p){if(m=N(t,p,o,f),!m)return!1;f+=m.length}return t.write(r.ACKS[a][u][l][0]),O(t,f),d(t,c),5===i&&t.write(n.from([h])),null!==m&&m.write(),!0}function C(e,t,o){c("subscribe: packet: ");const i=o?o.protocolVersion:4,s=e||{},a=s.dup?r.DUP_MASK:0,l=s.messageId,u=s.subscriptions,h=s.properties;let p=0;if("number"!=typeof l)return t.emit("error",new Error("Invalid messageId")),!1;p+=2;let f=null;if(5===i){if(f=M(t,h),!f)return!1;p+=f.length}if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<u.length;e+=1){const r=u[e].topic,o=u[e].qos;if("string"!=typeof r)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===i){if("boolean"!=typeof(u[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(u[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const n=u[e].rh||0;if("number"!=typeof n||n>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}p+=n.byteLength(r)+2+1}c("subscribe: writing to stream: %o",r.SUBSCRIBE_HEADER),t.write(r.SUBSCRIBE_HEADER[1][a?1:0][0]),O(t,p),d(t,l),null!==f&&f.write();let m=!0;for(const e of u){const o=e.topic,s=e.qos,a=+e.nl,c=+e.rap,l=e.rh;let u;F(t,o),u=r.SUBSCRIBE_OPTIONS_QOS[s],5===i&&(u|=a?r.SUBSCRIBE_OPTIONS_NL:0,u|=c?r.SUBSCRIBE_OPTIONS_RAP:0,u|=l?r.SUBSCRIBE_OPTIONS_RH[l]:0),m=t.write(n.from([u]))}return m}function S(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.granted,l=s.properties;let u=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(u+=2,"object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return t.emit("error",new Error("Invalid qos vector")),!1;u+=1}let h=null;if(5===i){if(h=N(t,l,o,u),!h)return!1;u+=h.length}return t.write(r.SUBACK_HEADER),O(t,u),d(t,a),null!==h&&h.write(),t.write(n.from(c))}function k(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,l=s.unsubscriptions,u=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(h+=2,"object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<l.length;e+=1){if("string"!=typeof l[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;h+=n.byteLength(l[e])+2}let p=null;if(5===i){if(p=M(t,u),!p)return!1;h+=p.length}t.write(r.UNSUBSCRIBE_HEADER[1][c?1:0][0]),O(t,h),d(t,a),null!==p&&p.write();let f=!0;for(let e=0;e<l.length;e++)f=F(t,l[e]);return f}function A(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,l=s.granted,u=s.properties,h=s.cmd,p=0;let f=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<l.length;e+=1){if("number"!=typeof l[e])return t.emit("error",new Error("Invalid qos vector")),!1;f+=1}}let m=null;if(5===i){if(m=N(t,u,o,f),!m)return!1;f+=m.length}return t.write(r.ACKS[h][p][c][0]),O(t,f),d(t,a),null!==m&&m.write(),5===i&&t.write(n.from(l)),!0}function E(e,t,n){return t.write(r.EMPTY[e.cmd])}function I(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0,u=null;if(5===i){if(u=N(t,c,o,l),!u)return!1;l+=u.length}return t.write(n.from([r.codes.disconnect<<4])),O(t,l),5===i&&t.write(n.from([a])),null!==u&&u.write(),!0}function x(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0;5!==i&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const u=N(t,c,o,l);return!!u&&(l+=u.length,t.write(n.from([r.codes.auth<<4])),O(t,l),t.write(n.from([a])),null!==u&&u.write(),!0)}Object.defineProperty(g,"cacheNumbers",{get:()=>d===P,set(e){e?(l&&0!==Object.keys(l).length||(m=!0),d=P):(m=!1,d=B)}});const R={};function O(e,t){if(t>r.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let n=R[t];return n||(n=p(t),t<16384&&(R[t]=n)),c("writeVarByteInt: writing to stream: %o",n),e.write(n)}function F(e,t){const r=n.byteLength(t);return d(e,r),c("writeString: %s",t),e.write(t,"utf8")}function T(e,t,n){F(e,t),F(e,n)}function P(e,t){return c("writeNumberCached: number: %d",t),c("writeNumberCached: %o",l[t]),e.write(l[t])}function B(e,t){const n=u(t);return c("writeNumberGenerated: %o",n),e.write(n)}function j(e,t){const n=f(t);return c("write4ByteNumber: %o",n),e.write(n)}function U(e,t){"string"==typeof t?F(e,t):t?(d(e,t.length),e.write(t)):d(e,0)}function M(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){D(e,{},0)}};let o=0;function i(t,o){let i=0;switch(r.propertiesTypes[t]){case"byte":if("boolean"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"int8":if("number"!=typeof o||o<0||o>255)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"binary":if(o&&null===o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(o)+2;break;case"int16":if("number"!=typeof o||o<0||o>65535)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3;break;case"int32":if("number"!=typeof o||o<0||o>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=5;break;case"var":if("number"!=typeof o||o<0||o>268435455)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(p(o));break;case"string":if("string"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3+n.byteLength(o.toString());break;case"pair":if("object"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=Object.getOwnPropertyNames(o).reduce(((e,t)=>{const r=o[t];return Array.isArray(r)?e+=r.reduce(((e,r)=>e+=3+n.byteLength(t.toString())+2+n.byteLength(r.toString())),0):e+=3+n.byteLength(t.toString())+2+n.byteLength(o[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${o}`)),!1}return i}if(t)for(const e in t){let n=0,r=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(r=i(e,s[t]),!r)return!1;n+=r}else{if(r=i(e,s),!r)return!1;n=r}if(!n)return!1;o+=n}return{length:n.byteLength(p(o))+o,write(){D(e,t,o)}}}function N(e,t,n,r){const o=["reasonString","userProperties"],i=n&&n.properties&&n.properties.maximumPacketSize?n.properties.maximumPacketSize:0;let s=M(e,t);if(i)for(;r+s.length>i;){const n=o.shift();if(!n||!t[n])return!1;delete t[n],s=M(e,t)}return s}function L(e,t,o){switch(r.propertiesTypes[t]){case"byte":e.write(n.from([r.properties[t]])),e.write(n.from([+o]));break;case"int8":e.write(n.from([r.properties[t]])),e.write(n.from([o]));break;case"binary":e.write(n.from([r.properties[t]])),U(e,o);break;case"int16":e.write(n.from([r.properties[t]])),d(e,o);break;case"int32":e.write(n.from([r.properties[t]])),j(e,o);break;case"var":e.write(n.from([r.properties[t]])),O(e,o);break;case"string":e.write(n.from([r.properties[t]])),F(e,o);break;case"pair":Object.getOwnPropertyNames(o).forEach((i=>{const s=o[i];Array.isArray(s)?s.forEach((o=>{e.write(n.from([r.properties[t]])),T(e,i.toString(),o.toString())})):(e.write(n.from([r.properties[t]])),T(e,i.toString(),s.toString()))}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${o}`)),!1}}function D(e,t,n){O(e,n);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&null!==t[n]){const r=t[n];if(Array.isArray(r))for(let t=0;t<r.length;t++)L(e,n,r[t]);else L(e,n,r)}}function q(e){return e?e instanceof n?e.length:n.byteLength(e):0}function $(e){return"string"==typeof e||e instanceof n}t.exports=g}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":22,"./numbers":25,buffer:14,debug:15,"process-nextick-args":31}],29:[function(e,t,n){var r=1e3,o=60*r,i=60*o,s=24*i,a=7*s,c=365.25*s;function l(e){if(!((e=String(e)).length>100)){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){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*c;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*i;case"minutes":case"minute":case"mins":case"min":case"m":return n*o;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function u(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=i?Math.round(e/i)+"h":t>=o?Math.round(e/o)+"m":t>=r?Math.round(e/r)+"s":e+"ms"}function h(e){var t=Math.abs(e);return t>=s?p(e,t,s,"day"):t>=i?p(e,t,i,"hour"):t>=o?p(e,t,o,"minute"):t>=r?p(e,t,r,"second"):e+" ms"}function p(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return l(e);if("number"===n&&isFinite(e))return t.long?h(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],30:[function(e,t,n){var r=e("wrappy");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)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}t.exports=r(o),t.exports.strict=r(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})}))},{wrappy:59}],31:[function(e,t,n){(function(e){(function(){function n(t,n,r,o){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var i,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,n)}));case 3:return e.nextTick((function(){t.call(null,n,r)}));case 4:return e.nextTick((function(){t.call(null,n,r,o)}));default:for(i=new Array(a-1),s=0;s<i.length;)i[s++]=arguments[s];return e.nextTick((function(){t.apply(null,i)}))}}void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:n}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:32}],32:[function(e,t,n){var r,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!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 l(e){if(o===clearTimeout)return clearTimeout(e);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(e){o=a}}();var u,h=[],p=!1,f=-1;function d(){p&&u&&(p=!1,u.length?h=u.concat(h):f=-1,h.length&&m())}function m(){if(!p){var e=c(d);p=!0;for(var t=h.length;t;){for(u=h,h=[];++f<t;)u&&u[f].run();f=-1,t=h.length}u=null,p=!1,l(e)}}function g(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new g(e,t)),1!==h.length||p||c(m)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],33:[function(e,t,n){(function(e){(function(){!function(r){var o="object"==typeof n&&n&&!n.nodeType&&n,i="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(r=s);var a,c,l=2147483647,u=36,h=1,p=26,f=38,d=700,m=72,g=128,y="-",v=/^xn--/,b=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},C=u-h,S=Math.floor,k=String.fromCharCode;function A(e){throw new RangeError(_[e])}function E(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function I(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+E((e=e.replace(w,".")).split("."),t).join(".")}function x(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function R(e){return E(e,(function(e){var t="";return e>65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=k(e)})).join("")}function O(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:u}function F(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function T(e,t,n){var r=0;for(e=n?S(e/d):e>>1,e+=S(e/t);e>C*p>>1;r+=u)e=S(e/C);return S(r+(C+1)*e/(e+f))}function P(e){var t,n,r,o,i,s,a,c,f,d,v=[],b=e.length,w=0,_=g,C=m;for((n=e.lastIndexOf(y))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&A("not-basic"),v.push(e.charCodeAt(r));for(o=n>0?n+1:0;o<b;){for(i=w,s=1,a=u;o>=b&&A("invalid-input"),((c=O(e.charCodeAt(o++)))>=u||c>S((l-w)/s))&&A("overflow"),w+=c*s,!(c<(f=a<=C?h:a>=C+p?p:a-C));a+=u)s>S(l/(d=u-f))&&A("overflow"),s*=d;C=T(w-i,t=v.length+1,0==i),S(w/t)>l-_&&A("overflow"),_+=S(w/t),w%=t,v.splice(w++,0,_)}return R(v)}function B(e){var t,n,r,o,i,s,a,c,f,d,v,b,w,_,C,E=[];for(b=(e=x(e)).length,t=g,n=0,i=m,s=0;s<b;++s)(v=e[s])<128&&E.push(k(v));for(r=o=E.length,o&&E.push(y);r<b;){for(a=l,s=0;s<b;++s)(v=e[s])>=t&&v<a&&(a=v);for(a-t>S((l-n)/(w=r+1))&&A("overflow"),n+=(a-t)*w,t=a,s=0;s<b;++s)if((v=e[s])<t&&++n>l&&A("overflow"),v==t){for(c=n,f=u;!(c<(d=f<=i?h:f>=i+p?p:f-i));f+=u)C=c-d,_=u-d,E.push(k(F(d+C%_,0))),c=S(C/_);E.push(k(F(c,0))),i=T(n,w,r==o),n=0,++r}++n,++t}return E.join("")}function j(e){return I(e,(function(e){return v.test(e)?P(e.slice(4).toLowerCase()):e}))}function U(e){return I(e,(function(e){return b.test(e)?"xn--"+B(e):e}))}if(a={version:"1.4.1",ucs2:{decode:x,encode:R},decode:P,encode:B,toASCII:U,toUnicode:j},o&&i)if(t.exports==o)i.exports=a;else for(c in a)a.hasOwnProperty(c)&&(o[c]=a[c]);else r.punycode=a}(this)}).call(this)}).call(this,void 0!==Z?Z:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],34:[function(e,t,n){function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,i){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var l=e.length;c>0&&l>c&&(l=c);for(var u=0;u<l;++u){var h,p,f,d,m=e[u].replace(a,"%20"),g=m.indexOf(n);g>=0?(h=m.substr(0,g),p=m.substr(g+1)):(h=m,p=""),f=decodeURIComponent(h),d=decodeURIComponent(p),r(s,f)?o(s[f])?s[f].push(d):s[f]=[s[f],d]:s[f]=d}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],35:[function(e,t,n){var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?i(s(e),(function(s){var a=encodeURIComponent(r(s))+n;return o(e[s])?i(e[s],(function(e){return a+encodeURIComponent(r(e))})).join(t):a+encodeURIComponent(r(e[s]))})).join(t):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var s=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},{}],36:[function(e,t,n){n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":34,"./encode":35}],37:[function(e,t,n){function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var o={};function i(e,t,n){function i(e,n,r){return"string"==typeof t?t:t(e,n,r)}n||(n=Error);var s=function(e){function t(t,n,r){return e.call(this,i(t,n,r))||this}return r(t,e),t}(n);s.prototype.name=n.name,s.prototype.code=e,o[e]=s}function s(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function a(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function c(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function l(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,o;if("string"==typeof t&&a(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",c(e," argument"))o="The ".concat(e," ").concat(r," ").concat(s(t,"type"));else{var i=l(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(i," ").concat(r," ").concat(s(t,"type"))}return o+=". Received type ".concat(typeof n)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=o},{}],38:[function(e,t,n){(function(n){(function(){var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=l;var o=e("./_stream_readable"),i=e("./_stream_writable");e("inherits")(l,o);for(var s=r(i.prototype),a=0;a<s.length;a++){var c=s[a];l.prototype[c]||(l.prototype[c]=i.prototype[c])}function l(e){if(!(this instanceof l))return new l(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",u)))}function u(){this._writableState.ended||n.nextTick(h,this)}function h(e){e.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.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)}).call(this,e("_process"))},{"./_stream_readable":40,"./_stream_writable":42,_process:32,inherits:21}],39:[function(e,t,n){t.exports=o;var r=e("./_stream_transform");function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}e("inherits")(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":41,inherits:21}],40:[function(e,t,n){(function(n,r){(function(){var o;t.exports=x,x.ReadableState=I,e("events").EventEmitter;var i=function(e,t){return e.listeners(t).length},s=e("./internal/streams/stream"),a=e("buffer").Buffer,c=r.Uint8Array||function(){};function l(e){return a.from(e)}function u(e){return a.isBuffer(e)||e instanceof c}var h,p=e("util");h=p&&p.debuglog?p.debuglog("stream"):function(){};var f,d,m,g=e("./internal/streams/buffer_list"),y=e("./internal/streams/destroy"),v=e("./internal/streams/state").getHighWaterMark,b=e("../errors").codes,w=b.ERR_INVALID_ARG_TYPE,_=b.ERR_STREAM_PUSH_AFTER_EOF,C=b.ERR_METHOD_NOT_IMPLEMENTED,S=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(x,s);var k=y.errorOrDestroy,A=["error","close","destroy","pause","resume"];function E(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}function I(t,n,r){o=o||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof o),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=v(this,t,"readableHighWaterMark",r),this.buffer=new g,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!==t.emitClose,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&&(f||(f=e("string_decoder/").StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function x(t){if(o=o||e("./_stream_duplex"),!(this instanceof x))return new x(t);var n=this instanceof o;this._readableState=new I(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function R(e,t,n,r,o){h("readableAddChunk",t);var i,s=e._readableState;if(null===t)s.reading=!1,j(e,s);else if(o||(i=F(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=l(t)),r)s.endEmitted?k(e,new S):O(e,s,t,!0);else if(s.ended)k(e,new _);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?O(e,s,t,!1):N(e,s)):O(e,s,t,!1)}else r||(s.reading=!1,N(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function O(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&U(e)),N(e,t)}function F(e,t){var n;return u(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new w("chunk",["string","Buffer","Uint8Array"],t)),n}Object.defineProperty(x.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),x.prototype.destroy=y.destroy,x.prototype._undestroy=y.undestroy,x.prototype._destroy=function(e,t){t(e)},x.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=a.from(e,t),t=""),n=!0),R(this,e,t,!1,n)},x.prototype.unshift=function(e){return R(this,e,null,!0,!1)},x.prototype.isPaused=function(){return!1===this._readableState.flowing},x.prototype.setEncoding=function(t){f||(f=e("string_decoder/").StringDecoder);var n=new f(t);this._readableState.decoder=n,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,o="";null!==r;)o+=n.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==o&&this._readableState.buffer.push(o),this._readableState.length=o.length,this};var T=1073741824;function P(e){return e>=T?e=T:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function B(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=P(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function j(e,t){if(h("onEofChunk"),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?U(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,M(e)))}}function U(e){var t=e._readableState;h("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(M,e))}function M(e){var t=e._readableState;h("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,W(e)}function N(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(L,e,t))}function L(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(h("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function D(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&i(e,"data")&&(t.flowing=!0,W(e))}}function q(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 $(e){h("readable nexttick read 0"),e.read(0)}function H(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(V,e,t))}function V(e,t){h("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),W(e),t.flowing&&!t.reading&&e.read(0)}function W(e){var t=e._readableState;for(h("flow",t.flowing);t.flowing&&null!==e.read(););}function z(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function K(e){var t=e._readableState;h("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(J,t,e))}function J(e,t){if(h("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function Y(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}x.prototype.read=function(e){h("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?K(this):U(this),null;if(0===(e=B(e,t))&&t.ended)return 0===t.length&&K(this),null;var r,o=t.needReadable;return h("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&h("length less than watermark",o=!0),t.ended||t.reading?h("reading or ended",o=!1):o&&(h("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=B(n,t))),null===(r=e>0?z(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),n!==e&&t.ended&&K(this)),null!==r&&this.emit("data",r),r},x.prototype._read=function(e){k(this,new C("_read()"))},x.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,h("pipe count=%d opts=%j",o.pipesCount,t);var s=t&&!1===t.end||e===n.stdout||e===n.stderr?y:c;function a(e,t){h("onunpipe"),e===r&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,p())}function c(){h("onend"),e.end()}o.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var l=D(r);e.on("drain",l);var u=!1;function p(){h("cleanup"),e.removeListener("close",m),e.removeListener("finish",g),e.removeListener("drain",l),e.removeListener("error",d),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",y),r.removeListener("data",f),u=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l()}function f(t){h("ondata");var n=e.write(t);h("dest.write",n),!1===n&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==Y(o.pipes,e))&&!u&&(h("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function d(t){h("onerror",t),y(),e.removeListener("error",d),0===i(e,"error")&&k(e,t)}function m(){e.removeListener("finish",g),y()}function g(){h("onfinish"),e.removeListener("close",m),y()}function y(){h("unpipe"),r.unpipe(e)}return r.on("data",f),E(e,"error",d),e.once("close",m),e.once("finish",g),e.emit("pipe",r),o.flowing||(h("pipe resume"),r.resume()),e},x.prototype.unpipe=function(e){var t=this._readableState,n={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,n)),this;if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<o;i++)r[i].emit("unpipe",this,{hasUnpiped:!1});return this}var s=Y(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,n)),this},x.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,h("on readable",o.length,o.reading),o.length?U(this):o.reading||n.nextTick($,this))),r},x.prototype.addListener=x.prototype.on,x.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(q,this),r},x.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(q,this),t},x.prototype.resume=function(){var e=this._readableState;return e.flowing||(h("resume"),e.flowing=!e.readableListening,H(this,e)),e.paused=!1,this},x.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},x.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var o in e.on("end",(function(){if(h("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(o){h("wrapped data"),n.decoder&&(o=n.decoder.write(o)),n.objectMode&&null==o||(n.objectMode||o&&o.length)&&(t.push(o)||(r=!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<A.length;i++)e.on(A[i],this.emit.bind(this,A[i]));return this._read=function(t){h("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(x.prototype[Symbol.asyncIterator]=function(){return void 0===d&&(d=e("./internal/streams/async_iterator")),d(this)}),Object.defineProperty(x.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(x.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(x.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),x._fromList=z,Object.defineProperty(x.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(x.from=function(t,n){return void 0===m&&(m=e("./internal/streams/from")),m(x,t,n)})}).call(this)}).call(this,e("_process"),void 0!==Z?Z:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":37,"./_stream_duplex":38,"./internal/streams/async_iterator":43,"./internal/streams/buffer_list":44,"./internal/streams/destroy":45,"./internal/streams/from":47,"./internal/streams/state":49,"./internal/streams/stream":50,_process:32,buffer:14,events:19,inherits:21,"string_decoder/":55,util:13}],41:[function(e,t,n){t.exports=u;var r=e("../errors").codes,o=r.ERR_METHOD_NOT_IMPLEMENTED,i=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,c=e("./_stream_duplex");function l(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new i);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function u(e){if(!(this instanceof u))return new u(e);c.call(this,e),this._transformState={afterTransform:l.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",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(t,n){p(e,t,n)}))}function p(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}e("inherits")(u,c),u.prototype.push=function(e,t){return this._transformState.needTransform=!1,c.prototype.push.call(this,e,t)},u.prototype._transform=function(e,t,n){n(new o("_transform()"))},u.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},u.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))},u.prototype._destroy=function(e,t){c.prototype._destroy.call(this,e,(function(e){t(e)}))}},{"../errors":37,"./_stream_duplex":38,inherits:21}],42:[function(e,t,n){(function(n,r){(function(){function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){V(t,e)}}var i;t.exports=I,I.WritableState=E;var s={deprecate:e("util-deprecate")},a=e("./internal/streams/stream"),c=e("buffer").Buffer,l=r.Uint8Array||function(){};function u(e){return c.from(e)}function h(e){return c.isBuffer(e)||e instanceof l}var p,f=e("./internal/streams/destroy"),d=e("./internal/streams/state").getHighWaterMark,m=e("../errors").codes,g=m.ERR_INVALID_ARG_TYPE,y=m.ERR_METHOD_NOT_IMPLEMENTED,v=m.ERR_MULTIPLE_CALLBACK,b=m.ERR_STREAM_CANNOT_PIPE,w=m.ERR_STREAM_DESTROYED,_=m.ERR_STREAM_NULL_VALUES,C=m.ERR_STREAM_WRITE_AFTER_END,S=m.ERR_UNKNOWN_ENCODING,k=f.errorOrDestroy;function A(){}function E(t,n,r){i=i||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=d(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){j(n,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!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function I(t){var n=this instanceof(i=i||e("./_stream_duplex"));if(!n&&!p.call(I,this))return new I(t);this._writableState=new E(t,this,n),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),a.call(this)}function x(e,t){var r=new C;k(e,r),n.nextTick(t,r)}function R(e,t,r,o){var i;return null===r?i=new _:"string"==typeof r||t.objectMode||(i=new g("chunk",["string","Buffer"],r)),!i||(k(e,i),n.nextTick(o,i),!1)}function O(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=c.from(t,n)),t}function F(e,t,n,r,o,i){if(!n){var s=O(t,r,o);r!==s&&(n=!0,o="buffer",r=s)}var a=t.objectMode?1:r.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:o,isBuf:n,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else T(e,t,!1,a,r,o,i);return c}function T(e,t,n,r,o,i,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new w("write")):n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function P(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick($,e,t),e._writableState.errorEmitted=!0,k(e,o)):(i(o),e._writableState.errorEmitted=!0,k(e,o),$(e,t))}function B(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function j(e,t){var r=e._writableState,o=r.sync,i=r.writecb;if("function"!=typeof i)throw new v;if(B(r),t)P(e,r,o,t,i);else{var s=L(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||N(e,r),o?n.nextTick(U,e,r,s,i):U(e,r,s,i)}}function U(e,t,n,r){n||M(e,t),t.pendingcb--,r(),$(e,t)}function M(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function N(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),s=t.corkedRequestsFree;s.entry=n;for(var a=0,c=!0;n;)i[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;i.allBuffers=c,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(;n;){var l=n.chunk,u=n.encoding,h=n.callback;if(T(e,t,!1,t.objectMode?1:l.length,l,u,h),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function L(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function D(e,t){e._final((function(n){t.pendingcb--,n&&k(e,n),t.prefinished=!0,e.emit("prefinish"),$(e,t)}))}function q(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(D,e,t)))}function $(e,t){var n=L(t);if(n&&(q(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}function H(e,t,r){t.ending=!0,$(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function V(e,t,n){var r=e.entry;for(e.entry=null;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree.next=e}e("inherits")(I,a),E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(E.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]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(I,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===I&&e&&e._writableState instanceof E}})):p=function(e){return e instanceof this},I.prototype.pipe=function(){k(this,new b)},I.prototype.write=function(e,t,n){var r=this._writableState,o=!1,i=!r.objectMode&&h(e);return i&&!c.isBuffer(e)&&(e=u(e)),"function"==typeof t&&(n=t,t=null),i?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=A),r.ending?x(this,n):(i||R(this,r,e,n))&&(r.pendingcb++,o=F(this,r,i,e,t,n)),o},I.prototype.cork=function(){this._writableState.corked++},I.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||N(this,e))},I.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 S(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),I.prototype._write=function(e,t,n){n(new y("_write()"))},I.prototype._writev=null,I.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||H(this,r,n),this},Object.defineProperty(I.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),I.prototype.destroy=f.destroy,I.prototype._undestroy=f.undestroy,I.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),void 0!==Z?Z:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":37,"./_stream_duplex":38,"./internal/streams/destroy":45,"./internal/streams/state":49,"./internal/streams/stream":50,_process:32,buffer:14,inherits:21,"util-deprecate":58}],43:[function(e,t,n){(function(n){(function(){var r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=e("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),u=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function f(e,t){return{value:e,done:t}}function d(e){var t=e[s];if(null!==t){var n=e[p].read();null!==n&&(e[u]=null,e[s]=null,e[a]=null,t(f(n,!1)))}}function m(e){n.nextTick(d,e)}function g(e,t){return function(n,r){e.then((function(){t[l]?n(f(void 0,!0)):t[h](n,r)}),r)}}var y=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((o(r={get stream(){return this[p]},next:function(){var e=this,t=this[c];if(null!==t)return Promise.reject(t);if(this[l])return Promise.resolve(f(void 0,!0));if(this[p].destroyed)return new Promise((function(t,r){n.nextTick((function(){e[c]?r(e[c]):t(f(void 0,!0))}))}));var r,o=this[u];if(o)r=new Promise(g(o,this));else{var i=this[p].read();if(null!==i)return Promise.resolve(f(i,!1));r=new Promise(this[h])}return this[u]=r,r}},Symbol.asyncIterator,(function(){return this})),o(r,"return",(function(){var e=this;return new Promise((function(t,n){e[p].destroy(null,(function(e){e?n(e):t(f(void 0,!0))}))}))})),r),y),b=function(e){var t,n=Object.create(v,(o(t={},p,{value:e,writable:!0}),o(t,s,{value:null,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,c,{value:null,writable:!0}),o(t,l,{value:e._readableState.endEmitted,writable:!0}),o(t,h,{value:function(e,t){var r=n[p].read();r?(n[u]=null,n[s]=null,n[a]=null,e(f(r,!1))):(n[s]=e,n[a]=t)},writable:!0}),t));return n[u]=null,i(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[u]=null,n[s]=null,n[a]=null,t(e)),void(n[c]=e)}var r=n[s];null!==r&&(n[u]=null,n[s]=null,n[a]=null,r(f(void 0,!0))),n[l]=!0})),e.on("readable",m.bind(null,n)),n};t.exports=b}).call(this)}).call(this,e("_process"))},{"./end-of-stream":46,_process:32}],44:[function(e,t,n){function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}var l=e("buffer").Buffer,u=e("util").inspect,h=u&&u.custom||"inspect";function p(e,t,n){l.prototype.copy.call(e,t,n)}t.exports=function(){function e(){s(this,e),this.head=null,this.tail=null,this.length=0}return c(e,[{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,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return l.alloc(0);for(var t=l.allocUnsafe(e>>>0),n=this.head,r=0;n;)p(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var o=t.data,i=e>o.length?o.length:e;if(i===o.length?r+=o:r+=o.slice(0,e),0==(e-=i)){i===o.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(i));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=l.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var o=n.data,i=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,i),0==(e-=i)){i===o.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(i));break}++r}return this.length-=r,t}},{key:h,value:function(e,t){return u(this,o({},t,{depth:0,customInspect:!1}))}}]),e}()},{buffer:14,util:13}],45:[function(e,t,n){(function(e){(function(){function n(t,n){var i=this,a=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return a||c?(n?n(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(s,this,t)):e.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!n&&t?i._writableState?i._writableState.errorEmitted?e.nextTick(o,i):(i._writableState.errorEmitted=!0,e.nextTick(r,i,t)):e.nextTick(r,i,t):n?(e.nextTick(o,i),n(t)):e.nextTick(o,i)})),this)}function r(e,t){s(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function i(){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 s(e,t){e.emit("error",t)}function a(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}t.exports={destroy:n,undestroy:i,errorOrDestroy:a}}).call(this)}).call(this,e("_process"))},{_process:32}],46:[function(e,t,n){var r=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function o(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];e.apply(this,r)}}}function i(){}function s(e){return e.setHeader&&"function"==typeof e.abort}function a(e,t,n){if("function"==typeof t)return a(e,null,t);t||(t={}),n=o(n||i);var c=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,u=function(){e.writable||p()},h=e._writableState&&e._writableState.finished,p=function(){l=!1,h=!0,c||n.call(e)},f=e._readableState&&e._readableState.endEmitted,d=function(){c=!1,f=!0,l||n.call(e)},m=function(t){n.call(e,t)},g=function(){var t;return c&&!f?(e._readableState&&e._readableState.ended||(t=new r),n.call(e,t)):l&&!h?(e._writableState&&e._writableState.ended||(t=new r),n.call(e,t)):void 0},y=function(){e.req.on("finish",p)};return s(e)?(e.on("complete",p),e.on("abort",g),e.req?y():e.on("request",y)):l&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",d),e.on("finish",p),!1!==t.error&&e.on("error",m),e.on("close",g),function(){e.removeListener("complete",p),e.removeListener("abort",g),e.removeListener("request",y),e.req&&e.req.removeListener("finish",p),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",p),e.removeListener("end",d),e.removeListener("error",m),e.removeListener("close",g)}}t.exports=a},{"../../../errors":37}],47:[function(e,t,n){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],48:[function(e,t,n){var r;function o(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=e("../../../errors").codes,s=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function c(e){if(e)throw e}function l(e){return e.setHeader&&"function"==typeof e.abort}function u(t,n,i,s){s=o(s);var c=!1;t.on("close",(function(){c=!0})),void 0===r&&(r=e("./end-of-stream")),r(t,{readable:n,writable:i},(function(e){if(e)return s(e);c=!0,s()}));var u=!1;return function(e){if(!c&&!u)return u=!0,l(t)?t.abort():"function"==typeof t.destroy?t.destroy():void s(e||new a("pipe"))}}function h(e){e()}function p(e,t){return e.pipe(t)}function f(e){return e.length?"function"!=typeof e[e.length-1]?c:e.pop():c}function d(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,o=f(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new s("streams");var i=t.map((function(e,n){var s=n<t.length-1;return u(e,s,n>0,(function(e){r||(r=e),e&&i.forEach(h),s||(i.forEach(h),o(r))}))}));return t.reduce(p)}t.exports=d},{"../../../errors":37,"./end-of-stream":46}],49:[function(e,t,n){var r=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;function o(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}function i(e,t,n,i){var s=o(t,i,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new r(i?n:"highWaterMark",s);return Math.floor(s)}return e.objectMode?16:16384}t.exports={getHighWaterMark:i}},{"../../../errors":37}],50:[function(e,t,n){t.exports=e("events").EventEmitter},{events:19}],51:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js"),n.finished=e("./lib/internal/streams/end-of-stream.js"),n.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":38,"./lib/_stream_passthrough.js":39,"./lib/_stream_readable.js":40,"./lib/_stream_transform.js":41,"./lib/_stream_writable.js":42,"./lib/internal/streams/end-of-stream.js":46,"./lib/internal/streams/pipeline.js":48}],52:[function(e,t,n){function r(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=r._interval),r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&(clearInterval(r._interval),r._interval=void 0)},this.destroy=function(){r._interval&&clearInterval(r._interval),r._callback=void 0,r._interval=void 0,r._args=void 0}}function o(){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 r(arguments[0],arguments[1],e)}t.exports=o},{}],53:[function(e,t,n){
|
|
4
|
+
n.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,l=c>>1,u=-7,h=n?o-1:0,p=n?-1:1,f=e[t+h];for(h+=p,i=f&(1<<-u)-1,f>>=-u,u+=a;u>0;i=256*i+e[t+h],h+=p,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=256*s+e[t+h],h+=p,u-=8);if(0===i)i=1-l;else{if(i===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),i-=l}return(f?-1:1)*s*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var s,a,c,l=8*i-o-1,u=(1<<l)-1,h=u>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,d=r?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=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?p/c:p*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*c-1)*Math.pow(2,o),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;e[n+f]=255&a,f+=d,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;e[n+f]=255&s,f+=d,s/=256,l-=8);e[n+f-d]|=128*m}},{}],21:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],22:[function(e,t,n){(function(e){(function(){const n=t.exports;n.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"},n.codes={};for(const e in n.types){const t=n.types[e];n.codes[t]=e}n.CMD_SHIFT=4,n.CMD_MASK=240,n.DUP_MASK=8,n.QOS_MASK=3,n.QOS_SHIFT=1,n.RETAIN_MASK=1,n.VARBYTEINT_MASK=127,n.VARBYTEINT_FIN_MASK=128,n.VARBYTEINT_MAX=268435455,n.SESSIONPRESENT_MASK=1,n.SESSIONPRESENT_HEADER=e.from([n.SESSIONPRESENT_MASK]),n.CONNACK_HEADER=e.from([n.codes.connack<<n.CMD_SHIFT]),n.USERNAME_MASK=128,n.PASSWORD_MASK=64,n.WILL_RETAIN_MASK=32,n.WILL_QOS_MASK=24,n.WILL_QOS_SHIFT=3,n.WILL_FLAG_MASK=4,n.CLEAN_SESSION_MASK=2,n.CONNECT_HEADER=e.from([n.codes.connect<<n.CMD_SHIFT]),n.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},n.propertiesCodes={};for(const e in n.properties){const t=n.properties[e];n.propertiesCodes[t]=e}function r(t){return[0,1,2].map((r=>[0,1].map((o=>[0,1].map((i=>{const s=e.alloc(1);return s.writeUInt8(n.codes[t]<<n.CMD_SHIFT|(o?n.DUP_MASK:0)|r<<n.QOS_SHIFT|i,0,!0),s}))))))}n.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"},n.PUBLISH_HEADER=r("publish"),n.SUBSCRIBE_HEADER=r("subscribe"),n.SUBSCRIBE_OPTIONS_QOS_MASK=3,n.SUBSCRIBE_OPTIONS_NL_MASK=1,n.SUBSCRIBE_OPTIONS_NL_SHIFT=2,n.SUBSCRIBE_OPTIONS_RAP_MASK=1,n.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,n.SUBSCRIBE_OPTIONS_RH_MASK=3,n.SUBSCRIBE_OPTIONS_RH_SHIFT=4,n.SUBSCRIBE_OPTIONS_RH=[0,16,32],n.SUBSCRIBE_OPTIONS_NL=4,n.SUBSCRIBE_OPTIONS_RAP=8,n.SUBSCRIBE_OPTIONS_QOS=[0,1,2],n.UNSUBSCRIBE_HEADER=r("unsubscribe"),n.ACKS={unsuback:r("unsuback"),puback:r("puback"),pubcomp:r("pubcomp"),pubrel:r("pubrel"),pubrec:r("pubrec")},n.SUBACK_HEADER=e.from([n.codes.suback<<n.CMD_SHIFT]),n.VERSION3=e.from([3]),n.VERSION4=e.from([4]),n.VERSION5=e.from([5]),n.VERSION131=e.from([131]),n.VERSION132=e.from([132]),n.QOS=[0,1,2].map((t=>e.from([t]))),n.EMPTY={pingreq:e.from([n.codes.pingreq<<4,0]),pingresp:e.from([n.codes.pingresp<<4,0]),disconnect:e.from([n.codes.disconnect<<4,0])}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14}],23:[function(e,t,n){(function(n){(function(){const r=e("./writeToStream"),o=e("events");function i(e,t){const n=new s;return r(e,n,t),n.concat()}class s 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 t=new Array(this._array.length),r=this._array;let o,i=0;for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?t[o]=r[o].length:t[o]=n.byteLength(r[o]),e+=t[o];const s=n.allocUnsafe(e);for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?(r[o].copy(s,i),i+=t[o]):(s.write(r[o],i),i+=t[o]);return s}}t.exports=i}).call(this)}).call(this,e("buffer").Buffer)},{"./writeToStream":28,buffer:14,events:19}],24:[function(e,t,n){n.parser=e("./parser").parser,n.generate=e("./generate"),n.writeToStream=e("./writeToStream")},{"./generate":23,"./parser":27,"./writeToStream":28}],25:[function(e,t,n){(function(e){(function(){const n=65536,r={},o=e.isBuffer(e.from([1,2]).subarray(0,1));function i(t){const n=e.allocUnsafe(2);return n.writeUInt8(t>>8,0),n.writeUInt8(255&t,1),n}function s(){for(let e=0;e<n;e++)r[e]=i(e)}function a(t){const n=4;let r=0,i=0;const s=e.allocUnsafe(n);do{r=t%128|0,(t=t/128|0)>0&&(r|=128),s.writeUInt8(r,i++)}while(t>0&&i<n);return t>0&&(i=0),o?s.subarray(0,i):s.slice(0,i)}function c(t){const n=e.allocUnsafe(4);return n.writeUInt32BE(t,0),n}t.exports={cache:r,generateCache:s,generateNumber:i,genBufVariableByteInt:a,generate4ByteBuffer:c}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14}],26:[function(e,t,n){class r{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}t.exports=r},{}],27:[function(e,t,n){const r=e("bl"),o=e("events"),i=e("./packet"),s=e("./constants"),a=e("debug")("mqtt-packet:parser");class c extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof c?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new c).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new i,this.error=null,this._list=r(),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,n,r;a("_parseConnect");const o={},i=this.packet,c=this._parseString();if(null===c)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==c&&"MQIsdp"!==c)return this._emitError(new Error("Invalid protocolId"));if(i.protocolId=c,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 l=this._parseString();if(null===l)return this._emitError(new Error("Packet too short"));if(i.clientId=l,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(r=this._parseString(),null===r)return this._emitError(new Error("Cannot parse username"));i.username=r,a("_parseConnect: packet.username: %s",i.username)}if(o.password){if(n=this._parseBuffer(),null===n)return this._emitError(new Error("Cannot parse password"));i.password=n}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,n,r,o,i,c,l;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));n=this._parseByte(),r=n&s.SUBSCRIBE_OPTIONS_QOS_MASK,c=0!=(n>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(n>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),o=n>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,l={topic:t,qos:r},5===this.settings.protocolVersion?(l.nl=c,l.rap=i,l.rh=o):this.settings.bridgeMode&&(l.rh=0,l.rap=!0,l.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",l),e.subscriptions.push(l)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!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(),n=t+this._pos;if(-1===t||n>this._list.length||n>this.packet.length)return null;const r=this._list.toString("utf8",this._pos,n);return this._pos+=t,a("_parseString: result: %s",r),r}_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 n=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",n),n}_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");const t=4;let n,r=0,o=1,i=0,c=!1;const l=this._pos?this._pos:0;for(;r<t&&l+r<this._list.length;){if(n=this._list.readUInt8(l+r++),i+=o*(n&s.VARBYTEINT_MASK),o*=128,0==(n&s.VARBYTEINT_FIN_MASK)){c=!0;break}if(this._list.length<=r)break}return!c&&r===t&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=r),c=!!c&&(e?{bytes:r,value:i}:i),a("_parseVarByteNum: result: %o",c),c}_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,n={};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)n[t]?(Array.isArray(n[t])||(n[t]=[n[t]]),n[t].push(this._parseByType(s.propertiesTypes[t]))):n[t]=this._parseByType(s.propertiesTypes[t]);else{n[t]||(n[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(n[t][e.name])if(Array.isArray(n[t][e.name]))n[t][e.name].push(e.value);else{const r=n[t][e.name];n[t][e.name]=[r],n[t][e.name].push(e.value)}else n[t][e.name]=e.value}}return n}_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)}}t.exports=c},{"./constants":22,"./packet":26,bl:12,debug:15,events:19}],28:[function(e,t,n){(function(n){(function(){const r=e("./constants"),o=n.allocUnsafe(0),i=n.from([0]),s=e("./numbers"),a=e("process-nextick-args").nextTick,c=e("debug")("mqtt-packet:writeToStream"),l=s.cache,u=s.generateNumber,h=s.generateCache,p=s.genBufVariableByteInt,f=s.generate4ByteBuffer;let d=P,m=!0;function g(e,t,n){switch(c("generate called"),t.cork&&(t.cork(),a(y,t)),m&&(m=!1,h()),c("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return v(e,t);case"connack":return b(e,t,n);case"publish":return w(e,t,n);case"puback":case"pubrec":case"pubrel":case"pubcomp":return _(e,t,n);case"subscribe":return C(e,t,n);case"suback":return S(e,t,n);case"unsubscribe":return k(e,t,n);case"unsuback":return A(e,t,n);case"pingreq":case"pingresp":return E(e,t);case"disconnect":return I(e,t,n);case"auth":return O(e,t,n);default:return t.emit("error",new Error("Unknown command")),!1}}function y(e){e.uncork()}function v(e,t,o){const i=e||{},s=i.protocolId||"MQTT";let a=i.protocolVersion||4;const c=i.will;let l=i.clean;const u=i.keepalive||0,h=i.clientId||"",p=i.username,f=i.password,m=i.properties;void 0===l&&(l=!0);let g=0;if(!s||"string"!=typeof s&&!n.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),!1;if(g+=s.length+2,3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),!1;if(g+=1,("string"==typeof h||n.isBuffer(h))&&(h||a>=4)&&(h||l))g+=n.byteLength(h)+2;else{if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*l==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof u||u<0||u>65535||u%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;if(g+=2,g+=1,5===a){var y=M(t,m);if(!y)return!1;g+=y.length}if(c){if("object"!=typeof c)return t.emit("error",new Error("Invalid will")),!1;if(!c.topic||"string"!=typeof c.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(g+=n.byteLength(c.topic)+2,g+=2,c.payload){if(!(c.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof c.payload?g+=n.byteLength(c.payload):g+=c.payload.length}var v={};if(5===a){if(!(v=M(t,c.properties)))return!1;g+=v.length}}let b=!1;if(null!=p){if(!$(p))return t.emit("error",new Error("Invalid username")),!1;b=!0,g+=n.byteLength(p)+2}if(null!=f){if(!b)return t.emit("error",new Error("Username is required to use password")),!1;if(!$(f))return t.emit("error",new Error("Invalid password")),!1;g+=q(f)+2}t.write(r.CONNECT_HEADER),R(t,g),U(t,s),i.bridgeMode&&(a+=128),t.write(131===a?r.VERSION131:132===a?r.VERSION132:4===a?r.VERSION4:5===a?r.VERSION5:r.VERSION3);let w=0;return w|=null!=p?r.USERNAME_MASK:0,w|=null!=f?r.PASSWORD_MASK:0,w|=c&&c.retain?r.WILL_RETAIN_MASK:0,w|=c&&c.qos?c.qos<<r.WILL_QOS_SHIFT:0,w|=c?r.WILL_FLAG_MASK:0,w|=l?r.CLEAN_SESSION_MASK:0,t.write(n.from([w])),d(t,u),5===a&&y.write(),U(t,h),c&&(5===a&&v.write(),F(t,c.topic),U(t,c.payload)),null!=p&&U(t,p),null!=f&&U(t,f),!0}function b(e,t,o){const s=o?o.protocolVersion:4,a=e||{},c=5===s?a.reasonCode:a.returnCode,l=a.properties;let u=2;if("number"!=typeof c)return t.emit("error",new Error("Invalid return code")),!1;let h=null;if(5===s){if(h=M(t,l),!h)return!1;u+=h.length}return t.write(r.CONNACK_HEADER),R(t,u),t.write(a.sessionPresent?r.SESSIONPRESENT_HEADER:i),t.write(n.from([c])),null!=h&&h.write(),!0}function w(e,t,i){c("publish: packet: %o",e);const s=i?i.protocolVersion:4,a=e||{},l=a.qos||0,u=a.retain?r.RETAIN_MASK:0,h=a.topic,p=a.payload||o,f=a.messageId,m=a.properties;let g=0;if("string"==typeof h)g+=n.byteLength(h)+2;else{if(!n.isBuffer(h))return t.emit("error",new Error("Invalid topic")),!1;g+=h.length+2}if(n.isBuffer(p)?g+=p.length:g+=n.byteLength(p),l&&"number"!=typeof f)return t.emit("error",new Error("Invalid messageId")),!1;l&&(g+=2);let y=null;if(5===s){if(y=M(t,m),!y)return!1;g+=y.length}return t.write(r.PUBLISH_HEADER[l][a.dup?1:0][u?1:0]),R(t,g),d(t,q(h)),t.write(h),l>0&&d(t,f),null!=y&&y.write(),c("publish: payload: %o",p),t.write(p)}function _(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,l=s.dup&&"pubrel"===a?r.DUP_MASK:0;let u=0;const h=s.reasonCode,p=s.properties;let f=5===i?3:2;if("pubrel"===a&&(u=1),"number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===i&&"object"==typeof p){if(m=N(t,p,o,f),!m)return!1;f+=m.length}return t.write(r.ACKS[a][u][l][0]),R(t,f),d(t,c),5===i&&t.write(n.from([h])),null!==m&&m.write(),!0}function C(e,t,o){c("subscribe: packet: ");const i=o?o.protocolVersion:4,s=e||{},a=s.dup?r.DUP_MASK:0,l=s.messageId,u=s.subscriptions,h=s.properties;let p=0;if("number"!=typeof l)return t.emit("error",new Error("Invalid messageId")),!1;p+=2;let f=null;if(5===i){if(f=M(t,h),!f)return!1;p+=f.length}if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<u.length;e+=1){const r=u[e].topic,o=u[e].qos;if("string"!=typeof r)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===i){if("boolean"!=typeof(u[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(u[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const n=u[e].rh||0;if("number"!=typeof n||n>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}p+=n.byteLength(r)+2+1}c("subscribe: writing to stream: %o",r.SUBSCRIBE_HEADER),t.write(r.SUBSCRIBE_HEADER[1][a?1:0][0]),R(t,p),d(t,l),null!==f&&f.write();let m=!0;for(const e of u){const o=e.topic,s=e.qos,a=+e.nl,c=+e.rap,l=e.rh;let u;F(t,o),u=r.SUBSCRIBE_OPTIONS_QOS[s],5===i&&(u|=a?r.SUBSCRIBE_OPTIONS_NL:0,u|=c?r.SUBSCRIBE_OPTIONS_RAP:0,u|=l?r.SUBSCRIBE_OPTIONS_RH[l]:0),m=t.write(n.from([u]))}return m}function S(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.granted,l=s.properties;let u=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(u+=2,"object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return t.emit("error",new Error("Invalid qos vector")),!1;u+=1}let h=null;if(5===i){if(h=N(t,l,o,u),!h)return!1;u+=h.length}return t.write(r.SUBACK_HEADER),R(t,u),d(t,a),null!==h&&h.write(),t.write(n.from(c))}function k(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,l=s.unsubscriptions,u=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(h+=2,"object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<l.length;e+=1){if("string"!=typeof l[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;h+=n.byteLength(l[e])+2}let p=null;if(5===i){if(p=M(t,u),!p)return!1;h+=p.length}t.write(r.UNSUBSCRIBE_HEADER[1][c?1:0][0]),R(t,h),d(t,a),null!==p&&p.write();let f=!0;for(let e=0;e<l.length;e++)f=F(t,l[e]);return f}function A(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,l=s.granted,u=s.properties,h=s.cmd,p=0;let f=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<l.length;e+=1){if("number"!=typeof l[e])return t.emit("error",new Error("Invalid qos vector")),!1;f+=1}}let m=null;if(5===i){if(m=N(t,u,o,f),!m)return!1;f+=m.length}return t.write(r.ACKS[h][p][c][0]),R(t,f),d(t,a),null!==m&&m.write(),5===i&&t.write(n.from(l)),!0}function E(e,t,n){return t.write(r.EMPTY[e.cmd])}function I(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0,u=null;if(5===i){if(u=N(t,c,o,l),!u)return!1;l+=u.length}return t.write(n.from([r.codes.disconnect<<4])),R(t,l),5===i&&t.write(n.from([a])),null!==u&&u.write(),!0}function O(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0;5!==i&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const u=N(t,c,o,l);return!!u&&(l+=u.length,t.write(n.from([r.codes.auth<<4])),R(t,l),t.write(n.from([a])),null!==u&&u.write(),!0)}Object.defineProperty(g,"cacheNumbers",{get:()=>d===P,set(e){e?(l&&0!==Object.keys(l).length||(m=!0),d=P):(m=!1,d=B)}});const x={};function R(e,t){if(t>r.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let n=x[t];return n||(n=p(t),t<16384&&(x[t]=n)),c("writeVarByteInt: writing to stream: %o",n),e.write(n)}function F(e,t){const r=n.byteLength(t);return d(e,r),c("writeString: %s",t),e.write(t,"utf8")}function T(e,t,n){F(e,t),F(e,n)}function P(e,t){return c("writeNumberCached: number: %d",t),c("writeNumberCached: %o",l[t]),e.write(l[t])}function B(e,t){const n=u(t);return c("writeNumberGenerated: %o",n),e.write(n)}function j(e,t){const n=f(t);return c("write4ByteNumber: %o",n),e.write(n)}function U(e,t){"string"==typeof t?F(e,t):t?(d(e,t.length),e.write(t)):d(e,0)}function M(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){L(e,{},0)}};let o=0;function i(t,o){let i=0;switch(r.propertiesTypes[t]){case"byte":if("boolean"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"int8":if("number"!=typeof o||o<0||o>255)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"binary":if(o&&null===o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(o)+2;break;case"int16":if("number"!=typeof o||o<0||o>65535)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3;break;case"int32":if("number"!=typeof o||o<0||o>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=5;break;case"var":if("number"!=typeof o||o<0||o>268435455)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(p(o));break;case"string":if("string"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3+n.byteLength(o.toString());break;case"pair":if("object"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=Object.getOwnPropertyNames(o).reduce(((e,t)=>{const r=o[t];return Array.isArray(r)?e+=r.reduce(((e,r)=>e+=3+n.byteLength(t.toString())+2+n.byteLength(r.toString())),0):e+=3+n.byteLength(t.toString())+2+n.byteLength(o[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${o}`)),!1}return i}if(t)for(const e in t){let n=0,r=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(r=i(e,s[t]),!r)return!1;n+=r}else{if(r=i(e,s),!r)return!1;n=r}if(!n)return!1;o+=n}return{length:n.byteLength(p(o))+o,write(){L(e,t,o)}}}function N(e,t,n,r){const o=["reasonString","userProperties"],i=n&&n.properties&&n.properties.maximumPacketSize?n.properties.maximumPacketSize:0;let s=M(e,t);if(i)for(;r+s.length>i;){const n=o.shift();if(!n||!t[n])return!1;delete t[n],s=M(e,t)}return s}function D(e,t,o){switch(r.propertiesTypes[t]){case"byte":e.write(n.from([r.properties[t]])),e.write(n.from([+o]));break;case"int8":e.write(n.from([r.properties[t]])),e.write(n.from([o]));break;case"binary":e.write(n.from([r.properties[t]])),U(e,o);break;case"int16":e.write(n.from([r.properties[t]])),d(e,o);break;case"int32":e.write(n.from([r.properties[t]])),j(e,o);break;case"var":e.write(n.from([r.properties[t]])),R(e,o);break;case"string":e.write(n.from([r.properties[t]])),F(e,o);break;case"pair":Object.getOwnPropertyNames(o).forEach((i=>{const s=o[i];Array.isArray(s)?s.forEach((o=>{e.write(n.from([r.properties[t]])),T(e,i.toString(),o.toString())})):(e.write(n.from([r.properties[t]])),T(e,i.toString(),s.toString()))}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${o}`)),!1}}function L(e,t,n){R(e,n);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&null!==t[n]){const r=t[n];if(Array.isArray(r))for(let t=0;t<r.length;t++)D(e,n,r[t]);else D(e,n,r)}}function q(e){return e?e instanceof n?e.length:n.byteLength(e):0}function $(e){return"string"==typeof e||e instanceof n}t.exports=g}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":22,"./numbers":25,buffer:14,debug:15,"process-nextick-args":31}],29:[function(e,t,n){var r=1e3,o=60*r,i=60*o,s=24*i,a=7*s,c=365.25*s;function l(e){if(!((e=String(e)).length>100)){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){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*c;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*i;case"minutes":case"minute":case"mins":case"min":case"m":return n*o;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function u(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=i?Math.round(e/i)+"h":t>=o?Math.round(e/o)+"m":t>=r?Math.round(e/r)+"s":e+"ms"}function h(e){var t=Math.abs(e);return t>=s?p(e,t,s,"day"):t>=i?p(e,t,i,"hour"):t>=o?p(e,t,o,"minute"):t>=r?p(e,t,r,"second"):e+" ms"}function p(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return l(e);if("number"===n&&isFinite(e))return t.long?h(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],30:[function(e,t,n){var r=e("wrappy");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)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}t.exports=r(o),t.exports.strict=r(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})}))},{wrappy:59}],31:[function(e,t,n){(function(e){(function(){function n(t,n,r,o){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var i,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,n)}));case 3:return e.nextTick((function(){t.call(null,n,r)}));case 4:return e.nextTick((function(){t.call(null,n,r,o)}));default:for(i=new Array(a-1),s=0;s<i.length;)i[s++]=arguments[s];return e.nextTick((function(){t.apply(null,i)}))}}void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:n}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:32}],32:[function(e,t,n){var r,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!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 l(e){if(o===clearTimeout)return clearTimeout(e);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(e){o=a}}();var u,h=[],p=!1,f=-1;function d(){p&&u&&(p=!1,u.length?h=u.concat(h):f=-1,h.length&&m())}function m(){if(!p){var e=c(d);p=!0;for(var t=h.length;t;){for(u=h,h=[];++f<t;)u&&u[f].run();f=-1,t=h.length}u=null,p=!1,l(e)}}function g(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new g(e,t)),1!==h.length||p||c(m)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],33:[function(e,t,n){(function(e){(function(){!function(r){var o="object"==typeof n&&n&&!n.nodeType&&n,i="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(r=s);var a,c,l=2147483647,u=36,h=1,p=26,f=38,d=700,m=72,g=128,y="-",v=/^xn--/,b=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},C=u-h,S=Math.floor,k=String.fromCharCode;function A(e){throw new RangeError(_[e])}function E(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function I(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+E((e=e.replace(w,".")).split("."),t).join(".")}function O(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function x(e){return E(e,(function(e){var t="";return e>65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=k(e)})).join("")}function R(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:u}function F(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function T(e,t,n){var r=0;for(e=n?S(e/d):e>>1,e+=S(e/t);e>C*p>>1;r+=u)e=S(e/C);return S(r+(C+1)*e/(e+f))}function P(e){var t,n,r,o,i,s,a,c,f,d,v=[],b=e.length,w=0,_=g,C=m;for((n=e.lastIndexOf(y))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&A("not-basic"),v.push(e.charCodeAt(r));for(o=n>0?n+1:0;o<b;){for(i=w,s=1,a=u;o>=b&&A("invalid-input"),((c=R(e.charCodeAt(o++)))>=u||c>S((l-w)/s))&&A("overflow"),w+=c*s,!(c<(f=a<=C?h:a>=C+p?p:a-C));a+=u)s>S(l/(d=u-f))&&A("overflow"),s*=d;C=T(w-i,t=v.length+1,0==i),S(w/t)>l-_&&A("overflow"),_+=S(w/t),w%=t,v.splice(w++,0,_)}return x(v)}function B(e){var t,n,r,o,i,s,a,c,f,d,v,b,w,_,C,E=[];for(b=(e=O(e)).length,t=g,n=0,i=m,s=0;s<b;++s)(v=e[s])<128&&E.push(k(v));for(r=o=E.length,o&&E.push(y);r<b;){for(a=l,s=0;s<b;++s)(v=e[s])>=t&&v<a&&(a=v);for(a-t>S((l-n)/(w=r+1))&&A("overflow"),n+=(a-t)*w,t=a,s=0;s<b;++s)if((v=e[s])<t&&++n>l&&A("overflow"),v==t){for(c=n,f=u;!(c<(d=f<=i?h:f>=i+p?p:f-i));f+=u)C=c-d,_=u-d,E.push(k(F(d+C%_,0))),c=S(C/_);E.push(k(F(c,0))),i=T(n,w,r==o),n=0,++r}++n,++t}return E.join("")}function j(e){return I(e,(function(e){return v.test(e)?P(e.slice(4).toLowerCase()):e}))}function U(e){return I(e,(function(e){return b.test(e)?"xn--"+B(e):e}))}if(a={version:"1.4.1",ucs2:{decode:O,encode:x},decode:P,encode:B,toASCII:U,toUnicode:j},o&&i)if(t.exports==o)i.exports=a;else for(c in a)a.hasOwnProperty(c)&&(o[c]=a[c]);else r.punycode=a}(this)}).call(this)}).call(this,void 0!==Z?Z:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],34:[function(e,t,n){function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,i){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var l=e.length;c>0&&l>c&&(l=c);for(var u=0;u<l;++u){var h,p,f,d,m=e[u].replace(a,"%20"),g=m.indexOf(n);g>=0?(h=m.substr(0,g),p=m.substr(g+1)):(h=m,p=""),f=decodeURIComponent(h),d=decodeURIComponent(p),r(s,f)?o(s[f])?s[f].push(d):s[f]=[s[f],d]:s[f]=d}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],35:[function(e,t,n){var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?i(s(e),(function(s){var a=encodeURIComponent(r(s))+n;return o(e[s])?i(e[s],(function(e){return a+encodeURIComponent(r(e))})).join(t):a+encodeURIComponent(r(e[s]))})).join(t):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var s=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},{}],36:[function(e,t,n){n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":34,"./encode":35}],37:[function(e,t,n){function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var o={};function i(e,t,n){function i(e,n,r){return"string"==typeof t?t:t(e,n,r)}n||(n=Error);var s=function(e){function t(t,n,r){return e.call(this,i(t,n,r))||this}return r(t,e),t}(n);s.prototype.name=n.name,s.prototype.code=e,o[e]=s}function s(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function a(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function c(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function l(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,o;if("string"==typeof t&&a(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",c(e," argument"))o="The ".concat(e," ").concat(r," ").concat(s(t,"type"));else{var i=l(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(i," ").concat(r," ").concat(s(t,"type"))}return o+=". Received type ".concat(typeof n)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=o},{}],38:[function(e,t,n){(function(n){(function(){var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=l;var o=e("./_stream_readable"),i=e("./_stream_writable");e("inherits")(l,o);for(var s=r(i.prototype),a=0;a<s.length;a++){var c=s[a];l.prototype[c]||(l.prototype[c]=i.prototype[c])}function l(e){if(!(this instanceof l))return new l(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",u)))}function u(){this._writableState.ended||n.nextTick(h,this)}function h(e){e.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.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)}).call(this,e("_process"))},{"./_stream_readable":40,"./_stream_writable":42,_process:32,inherits:21}],39:[function(e,t,n){t.exports=o;var r=e("./_stream_transform");function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}e("inherits")(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":41,inherits:21}],40:[function(e,t,n){(function(n,r){(function(){var o;t.exports=O,O.ReadableState=I,e("events").EventEmitter;var i=function(e,t){return e.listeners(t).length},s=e("./internal/streams/stream"),a=e("buffer").Buffer,c=r.Uint8Array||function(){};function l(e){return a.from(e)}function u(e){return a.isBuffer(e)||e instanceof c}var h,p=e("util");h=p&&p.debuglog?p.debuglog("stream"):function(){};var f,d,m,g=e("./internal/streams/buffer_list"),y=e("./internal/streams/destroy"),v=e("./internal/streams/state").getHighWaterMark,b=e("../errors").codes,w=b.ERR_INVALID_ARG_TYPE,_=b.ERR_STREAM_PUSH_AFTER_EOF,C=b.ERR_METHOD_NOT_IMPLEMENTED,S=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(O,s);var k=y.errorOrDestroy,A=["error","close","destroy","pause","resume"];function E(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}function I(t,n,r){o=o||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof o),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=v(this,t,"readableHighWaterMark",r),this.buffer=new g,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!==t.emitClose,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&&(f||(f=e("string_decoder/").StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function O(t){if(o=o||e("./_stream_duplex"),!(this instanceof O))return new O(t);var n=this instanceof o;this._readableState=new I(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function x(e,t,n,r,o){h("readableAddChunk",t);var i,s=e._readableState;if(null===t)s.reading=!1,j(e,s);else if(o||(i=F(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=l(t)),r)s.endEmitted?k(e,new S):R(e,s,t,!0);else if(s.ended)k(e,new _);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?R(e,s,t,!1):N(e,s)):R(e,s,t,!1)}else r||(s.reading=!1,N(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function R(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&U(e)),N(e,t)}function F(e,t){var n;return u(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new w("chunk",["string","Buffer","Uint8Array"],t)),n}Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),O.prototype.destroy=y.destroy,O.prototype._undestroy=y.undestroy,O.prototype._destroy=function(e,t){t(e)},O.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=a.from(e,t),t=""),n=!0),x(this,e,t,!1,n)},O.prototype.unshift=function(e){return x(this,e,null,!0,!1)},O.prototype.isPaused=function(){return!1===this._readableState.flowing},O.prototype.setEncoding=function(t){f||(f=e("string_decoder/").StringDecoder);var n=new f(t);this._readableState.decoder=n,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,o="";null!==r;)o+=n.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==o&&this._readableState.buffer.push(o),this._readableState.length=o.length,this};var T=1073741824;function P(e){return e>=T?e=T:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function B(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=P(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function j(e,t){if(h("onEofChunk"),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?U(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,M(e)))}}function U(e){var t=e._readableState;h("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(M,e))}function M(e){var t=e._readableState;h("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,W(e)}function N(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(D,e,t))}function D(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(h("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function L(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&i(e,"data")&&(t.flowing=!0,W(e))}}function q(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 $(e){h("readable nexttick read 0"),e.read(0)}function H(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(V,e,t))}function V(e,t){h("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),W(e),t.flowing&&!t.reading&&e.read(0)}function W(e){var t=e._readableState;for(h("flow",t.flowing);t.flowing&&null!==e.read(););}function z(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function K(e){var t=e._readableState;h("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(J,t,e))}function J(e,t){if(h("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function Y(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}O.prototype.read=function(e){h("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?K(this):U(this),null;if(0===(e=B(e,t))&&t.ended)return 0===t.length&&K(this),null;var r,o=t.needReadable;return h("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&h("length less than watermark",o=!0),t.ended||t.reading?h("reading or ended",o=!1):o&&(h("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=B(n,t))),null===(r=e>0?z(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),n!==e&&t.ended&&K(this)),null!==r&&this.emit("data",r),r},O.prototype._read=function(e){k(this,new C("_read()"))},O.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,h("pipe count=%d opts=%j",o.pipesCount,t);var s=t&&!1===t.end||e===n.stdout||e===n.stderr?y:c;function a(e,t){h("onunpipe"),e===r&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,p())}function c(){h("onend"),e.end()}o.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var l=L(r);e.on("drain",l);var u=!1;function p(){h("cleanup"),e.removeListener("close",m),e.removeListener("finish",g),e.removeListener("drain",l),e.removeListener("error",d),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",y),r.removeListener("data",f),u=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l()}function f(t){h("ondata");var n=e.write(t);h("dest.write",n),!1===n&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==Y(o.pipes,e))&&!u&&(h("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function d(t){h("onerror",t),y(),e.removeListener("error",d),0===i(e,"error")&&k(e,t)}function m(){e.removeListener("finish",g),y()}function g(){h("onfinish"),e.removeListener("close",m),y()}function y(){h("unpipe"),r.unpipe(e)}return r.on("data",f),E(e,"error",d),e.once("close",m),e.once("finish",g),e.emit("pipe",r),o.flowing||(h("pipe resume"),r.resume()),e},O.prototype.unpipe=function(e){var t=this._readableState,n={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,n)),this;if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<o;i++)r[i].emit("unpipe",this,{hasUnpiped:!1});return this}var s=Y(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,n)),this},O.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,h("on readable",o.length,o.reading),o.length?U(this):o.reading||n.nextTick($,this))),r},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(q,this),r},O.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(q,this),t},O.prototype.resume=function(){var e=this._readableState;return e.flowing||(h("resume"),e.flowing=!e.readableListening,H(this,e)),e.paused=!1,this},O.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},O.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var o in e.on("end",(function(){if(h("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(o){h("wrapped data"),n.decoder&&(o=n.decoder.write(o)),n.objectMode&&null==o||(n.objectMode||o&&o.length)&&(t.push(o)||(r=!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<A.length;i++)e.on(A[i],this.emit.bind(this,A[i]));return this._read=function(t){h("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(O.prototype[Symbol.asyncIterator]=function(){return void 0===d&&(d=e("./internal/streams/async_iterator")),d(this)}),Object.defineProperty(O.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(O.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(O.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),O._fromList=z,Object.defineProperty(O.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(O.from=function(t,n){return void 0===m&&(m=e("./internal/streams/from")),m(O,t,n)})}).call(this)}).call(this,e("_process"),void 0!==Z?Z:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":37,"./_stream_duplex":38,"./internal/streams/async_iterator":43,"./internal/streams/buffer_list":44,"./internal/streams/destroy":45,"./internal/streams/from":47,"./internal/streams/state":49,"./internal/streams/stream":50,_process:32,buffer:14,events:19,inherits:21,"string_decoder/":55,util:13}],41:[function(e,t,n){t.exports=u;var r=e("../errors").codes,o=r.ERR_METHOD_NOT_IMPLEMENTED,i=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,c=e("./_stream_duplex");function l(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new i);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function u(e){if(!(this instanceof u))return new u(e);c.call(this,e),this._transformState={afterTransform:l.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",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(t,n){p(e,t,n)}))}function p(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}e("inherits")(u,c),u.prototype.push=function(e,t){return this._transformState.needTransform=!1,c.prototype.push.call(this,e,t)},u.prototype._transform=function(e,t,n){n(new o("_transform()"))},u.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},u.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))},u.prototype._destroy=function(e,t){c.prototype._destroy.call(this,e,(function(e){t(e)}))}},{"../errors":37,"./_stream_duplex":38,inherits:21}],42:[function(e,t,n){(function(n,r){(function(){function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){V(t,e)}}var i;t.exports=I,I.WritableState=E;var s={deprecate:e("util-deprecate")},a=e("./internal/streams/stream"),c=e("buffer").Buffer,l=r.Uint8Array||function(){};function u(e){return c.from(e)}function h(e){return c.isBuffer(e)||e instanceof l}var p,f=e("./internal/streams/destroy"),d=e("./internal/streams/state").getHighWaterMark,m=e("../errors").codes,g=m.ERR_INVALID_ARG_TYPE,y=m.ERR_METHOD_NOT_IMPLEMENTED,v=m.ERR_MULTIPLE_CALLBACK,b=m.ERR_STREAM_CANNOT_PIPE,w=m.ERR_STREAM_DESTROYED,_=m.ERR_STREAM_NULL_VALUES,C=m.ERR_STREAM_WRITE_AFTER_END,S=m.ERR_UNKNOWN_ENCODING,k=f.errorOrDestroy;function A(){}function E(t,n,r){i=i||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=d(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){j(n,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!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function I(t){var n=this instanceof(i=i||e("./_stream_duplex"));if(!n&&!p.call(I,this))return new I(t);this._writableState=new E(t,this,n),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),a.call(this)}function O(e,t){var r=new C;k(e,r),n.nextTick(t,r)}function x(e,t,r,o){var i;return null===r?i=new _:"string"==typeof r||t.objectMode||(i=new g("chunk",["string","Buffer"],r)),!i||(k(e,i),n.nextTick(o,i),!1)}function R(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=c.from(t,n)),t}function F(e,t,n,r,o,i){if(!n){var s=R(t,r,o);r!==s&&(n=!0,o="buffer",r=s)}var a=t.objectMode?1:r.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:o,isBuf:n,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else T(e,t,!1,a,r,o,i);return c}function T(e,t,n,r,o,i,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new w("write")):n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function P(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick($,e,t),e._writableState.errorEmitted=!0,k(e,o)):(i(o),e._writableState.errorEmitted=!0,k(e,o),$(e,t))}function B(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function j(e,t){var r=e._writableState,o=r.sync,i=r.writecb;if("function"!=typeof i)throw new v;if(B(r),t)P(e,r,o,t,i);else{var s=D(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||N(e,r),o?n.nextTick(U,e,r,s,i):U(e,r,s,i)}}function U(e,t,n,r){n||M(e,t),t.pendingcb--,r(),$(e,t)}function M(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function N(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),s=t.corkedRequestsFree;s.entry=n;for(var a=0,c=!0;n;)i[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;i.allBuffers=c,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(;n;){var l=n.chunk,u=n.encoding,h=n.callback;if(T(e,t,!1,t.objectMode?1:l.length,l,u,h),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function D(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function L(e,t){e._final((function(n){t.pendingcb--,n&&k(e,n),t.prefinished=!0,e.emit("prefinish"),$(e,t)}))}function q(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(L,e,t)))}function $(e,t){var n=D(t);if(n&&(q(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}function H(e,t,r){t.ending=!0,$(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function V(e,t,n){var r=e.entry;for(e.entry=null;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree.next=e}e("inherits")(I,a),E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(E.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]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(I,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===I&&e&&e._writableState instanceof E}})):p=function(e){return e instanceof this},I.prototype.pipe=function(){k(this,new b)},I.prototype.write=function(e,t,n){var r=this._writableState,o=!1,i=!r.objectMode&&h(e);return i&&!c.isBuffer(e)&&(e=u(e)),"function"==typeof t&&(n=t,t=null),i?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=A),r.ending?O(this,n):(i||x(this,r,e,n))&&(r.pendingcb++,o=F(this,r,i,e,t,n)),o},I.prototype.cork=function(){this._writableState.corked++},I.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||N(this,e))},I.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 S(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),I.prototype._write=function(e,t,n){n(new y("_write()"))},I.prototype._writev=null,I.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||H(this,r,n),this},Object.defineProperty(I.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),I.prototype.destroy=f.destroy,I.prototype._undestroy=f.undestroy,I.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),void 0!==Z?Z:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":37,"./_stream_duplex":38,"./internal/streams/destroy":45,"./internal/streams/state":49,"./internal/streams/stream":50,_process:32,buffer:14,inherits:21,"util-deprecate":58}],43:[function(e,t,n){(function(n){(function(){var r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=e("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),u=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function f(e,t){return{value:e,done:t}}function d(e){var t=e[s];if(null!==t){var n=e[p].read();null!==n&&(e[u]=null,e[s]=null,e[a]=null,t(f(n,!1)))}}function m(e){n.nextTick(d,e)}function g(e,t){return function(n,r){e.then((function(){t[l]?n(f(void 0,!0)):t[h](n,r)}),r)}}var y=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((o(r={get stream(){return this[p]},next:function(){var e=this,t=this[c];if(null!==t)return Promise.reject(t);if(this[l])return Promise.resolve(f(void 0,!0));if(this[p].destroyed)return new Promise((function(t,r){n.nextTick((function(){e[c]?r(e[c]):t(f(void 0,!0))}))}));var r,o=this[u];if(o)r=new Promise(g(o,this));else{var i=this[p].read();if(null!==i)return Promise.resolve(f(i,!1));r=new Promise(this[h])}return this[u]=r,r}},Symbol.asyncIterator,(function(){return this})),o(r,"return",(function(){var e=this;return new Promise((function(t,n){e[p].destroy(null,(function(e){e?n(e):t(f(void 0,!0))}))}))})),r),y),b=function(e){var t,n=Object.create(v,(o(t={},p,{value:e,writable:!0}),o(t,s,{value:null,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,c,{value:null,writable:!0}),o(t,l,{value:e._readableState.endEmitted,writable:!0}),o(t,h,{value:function(e,t){var r=n[p].read();r?(n[u]=null,n[s]=null,n[a]=null,e(f(r,!1))):(n[s]=e,n[a]=t)},writable:!0}),t));return n[u]=null,i(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[u]=null,n[s]=null,n[a]=null,t(e)),void(n[c]=e)}var r=n[s];null!==r&&(n[u]=null,n[s]=null,n[a]=null,r(f(void 0,!0))),n[l]=!0})),e.on("readable",m.bind(null,n)),n};t.exports=b}).call(this)}).call(this,e("_process"))},{"./end-of-stream":46,_process:32}],44:[function(e,t,n){function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}var l=e("buffer").Buffer,u=e("util").inspect,h=u&&u.custom||"inspect";function p(e,t,n){l.prototype.copy.call(e,t,n)}t.exports=function(){function e(){s(this,e),this.head=null,this.tail=null,this.length=0}return c(e,[{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,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return l.alloc(0);for(var t=l.allocUnsafe(e>>>0),n=this.head,r=0;n;)p(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var o=t.data,i=e>o.length?o.length:e;if(i===o.length?r+=o:r+=o.slice(0,e),0==(e-=i)){i===o.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(i));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=l.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var o=n.data,i=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,i),0==(e-=i)){i===o.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(i));break}++r}return this.length-=r,t}},{key:h,value:function(e,t){return u(this,o({},t,{depth:0,customInspect:!1}))}}]),e}()},{buffer:14,util:13}],45:[function(e,t,n){(function(e){(function(){function n(t,n){var i=this,a=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return a||c?(n?n(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(s,this,t)):e.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!n&&t?i._writableState?i._writableState.errorEmitted?e.nextTick(o,i):(i._writableState.errorEmitted=!0,e.nextTick(r,i,t)):e.nextTick(r,i,t):n?(e.nextTick(o,i),n(t)):e.nextTick(o,i)})),this)}function r(e,t){s(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function i(){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 s(e,t){e.emit("error",t)}function a(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}t.exports={destroy:n,undestroy:i,errorOrDestroy:a}}).call(this)}).call(this,e("_process"))},{_process:32}],46:[function(e,t,n){var r=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function o(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];e.apply(this,r)}}}function i(){}function s(e){return e.setHeader&&"function"==typeof e.abort}function a(e,t,n){if("function"==typeof t)return a(e,null,t);t||(t={}),n=o(n||i);var c=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,u=function(){e.writable||p()},h=e._writableState&&e._writableState.finished,p=function(){l=!1,h=!0,c||n.call(e)},f=e._readableState&&e._readableState.endEmitted,d=function(){c=!1,f=!0,l||n.call(e)},m=function(t){n.call(e,t)},g=function(){var t;return c&&!f?(e._readableState&&e._readableState.ended||(t=new r),n.call(e,t)):l&&!h?(e._writableState&&e._writableState.ended||(t=new r),n.call(e,t)):void 0},y=function(){e.req.on("finish",p)};return s(e)?(e.on("complete",p),e.on("abort",g),e.req?y():e.on("request",y)):l&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",d),e.on("finish",p),!1!==t.error&&e.on("error",m),e.on("close",g),function(){e.removeListener("complete",p),e.removeListener("abort",g),e.removeListener("request",y),e.req&&e.req.removeListener("finish",p),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",p),e.removeListener("end",d),e.removeListener("error",m),e.removeListener("close",g)}}t.exports=a},{"../../../errors":37}],47:[function(e,t,n){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],48:[function(e,t,n){var r;function o(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=e("../../../errors").codes,s=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function c(e){if(e)throw e}function l(e){return e.setHeader&&"function"==typeof e.abort}function u(t,n,i,s){s=o(s);var c=!1;t.on("close",(function(){c=!0})),void 0===r&&(r=e("./end-of-stream")),r(t,{readable:n,writable:i},(function(e){if(e)return s(e);c=!0,s()}));var u=!1;return function(e){if(!c&&!u)return u=!0,l(t)?t.abort():"function"==typeof t.destroy?t.destroy():void s(e||new a("pipe"))}}function h(e){e()}function p(e,t){return e.pipe(t)}function f(e){return e.length?"function"!=typeof e[e.length-1]?c:e.pop():c}function d(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,o=f(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new s("streams");var i=t.map((function(e,n){var s=n<t.length-1;return u(e,s,n>0,(function(e){r||(r=e),e&&i.forEach(h),s||(i.forEach(h),o(r))}))}));return t.reduce(p)}t.exports=d},{"../../../errors":37,"./end-of-stream":46}],49:[function(e,t,n){var r=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;function o(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}function i(e,t,n,i){var s=o(t,i,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new r(i?n:"highWaterMark",s);return Math.floor(s)}return e.objectMode?16:16384}t.exports={getHighWaterMark:i}},{"../../../errors":37}],50:[function(e,t,n){t.exports=e("events").EventEmitter},{events:19}],51:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js"),n.finished=e("./lib/internal/streams/end-of-stream.js"),n.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":38,"./lib/_stream_passthrough.js":39,"./lib/_stream_readable.js":40,"./lib/_stream_transform.js":41,"./lib/_stream_writable.js":42,"./lib/internal/streams/end-of-stream.js":46,"./lib/internal/streams/pipeline.js":48}],52:[function(e,t,n){function r(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=r._interval),r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&(clearInterval(r._interval),r._interval=void 0)},this.destroy=function(){r._interval&&clearInterval(r._interval),r._callback=void 0,r._interval=void 0,r._args=void 0}}function o(){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 r(arguments[0],arguments[1],e)}t.exports=o},{}],53:[function(e,t,n){
|
|
5
5
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
6
|
-
var r=e("buffer"),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=r:(i(r,n),n.Buffer=s),s.prototype=Object.create(o.prototype),i(o,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},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 r.SlowBuffer(e)}},{buffer:14}],54:[function(e,t,n){function r(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(o(t)):null}function o(e){return e.buffer.length?e.buffer.head?e.buffer.head.data.length:e.buffer[0].length:e.length}t.exports=r},{}],55:[function(e,t,n){var r=e("safe-buffer").Buffer,o=r.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){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}}function s(e){var t=i(e);if("string"!=typeof t&&(r.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}function a(e){var t;switch(this.encoding=s(e),this.encoding){case"utf16le":this.text=d,this.end=m,t=4;break;case"utf8":this.fillLast=h,t=4;break;case"base64":this.text=g,this.end=y,t=3;break;default:return this.write=v,void(this.end=b)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function c(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function l(e,t,n){var r=t.length-1;if(r<n)return 0;var o=c(t[r]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(e.lastNeed=o-2),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(2===o?o=0:e.lastNeed=o-3),o):0}function u(e,t,n){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,"�"}}function h(e){var t=this.lastTotal-this.lastNeed,n=u(this,e);return void 0!==n?n: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 p(e,t){var n=l(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function d(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function m(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function g(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?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-n))}function y(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function v(e){return e.toString(this.encoding)}function b(e){return e&&e.length?this.write(e):""}n.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},a.prototype.end=f,a.prototype.text=p,a.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}},{"safe-buffer":53}],56:[function(e,t,n){var r=e("punycode"),o=e("./util");function i(){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}n.parse=w,n.resolve=C,n.resolveObject=S,n.format=_,n.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(l),h=["%","/","?",";","#"].concat(u),p=["/","?","#"],f=255,d=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=e("querystring");function w(e,t,n){if(e&&o.isObject(e)&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}function _(e){return o.isString(e)&&(e=w(e)),e instanceof i?e.format():i.prototype.format.call(e)}function C(e,t){return w(e,!1,!0).resolve(t)}function S(e,t){return e?w(e,!1,!0).resolveObject(t):t}i.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),a=-1!==i&&i<e.indexOf("#")?"?":"#",l=e.split(a),w=/\\/g;l[0]=l[0].replace(w,"/");var _=e=l.join(a);if(_=_.trim(),!n&&1===e.split("#").length){var C=c.exec(_);if(C)return this.path=_,this.href=_,this.pathname=C[1],C[2]?(this.search=C[2],this.query=t?b.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var S=s.exec(_);if(S){var k=(S=S[0]).toLowerCase();this.protocol=k,_=_.substr(S.length)}if(n||S||_.match(/^\/\/[^@\/]+@[^@\/]+/)){var A="//"===_.substr(0,2);!A||S&&y[S]||(_=_.substr(2),this.slashes=!0)}if(!y[S]&&(A||S&&!v[S])){for(var E,I,x=-1,R=0;R<p.length;R++)-1!==(O=_.indexOf(p[R]))&&(-1===x||O<x)&&(x=O);for(-1!==(I=-1===x?_.lastIndexOf("@"):_.lastIndexOf("@",x))&&(E=_.slice(0,I),_=_.slice(I+1),this.auth=decodeURIComponent(E)),x=-1,R=0;R<h.length;R++){var O;-1!==(O=_.indexOf(h[R]))&&(-1===x||O<x)&&(x=O)}-1===x&&(x=_.length),this.host=_.slice(0,x),_=_.slice(x),this.parseHost(),this.hostname=this.hostname||"";var F="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!F)for(var T=this.hostname.split(/\./),P=(R=0,T.length);R<P;R++){var B=T[R];if(B&&!B.match(d)){for(var j="",U=0,M=B.length;U<M;U++)B.charCodeAt(U)>127?j+="x":j+=B[U];if(!j.match(d)){var N=T.slice(0,R),L=T.slice(R+1),D=B.match(m);D&&(N.push(D[1]),L.unshift(D[2])),L.length&&(_="/"+L.join(".")+_),this.hostname=N.join(".");break}}}this.hostname.length>f?this.hostname="":this.hostname=this.hostname.toLowerCase(),F||(this.hostname=r.toASCII(this.hostname));var q=this.port?":"+this.port:"",$=this.hostname||"";this.host=$+q,this.href+=this.host,F&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!g[k])for(R=0,P=u.length;R<P;R++){var H=u[R];if(-1!==_.indexOf(H)){var V=encodeURIComponent(H);V===H&&(V=escape(H)),_=_.split(H).join(V)}}var W=_.indexOf("#");-1!==W&&(this.hash=_.substr(W),_=_.slice(0,W));var z=_.indexOf("?");if(-1!==z?(this.search=_.substr(z),this.query=_.substr(z+1),t&&(this.query=b.parse(this.query)),_=_.slice(0,z)):t&&(this.search="",this.query={}),_&&(this.pathname=_),v[k]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){q=this.pathname||"";var K=this.search||"";this.path=q+K}return this.href=this.format(),this},i.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,s="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(s=b.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||v[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),t+i+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+r},i.prototype.resolve=function(e){return this.resolveObject(w(e,!1,!0)).format()},i.prototype.resolveObject=function(e){if(o.isString(e)){var t=new i;t.parse(e,!1,!0),e=t}for(var n=new i,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),l=0;l<c.length;l++){var u=c[l];"protocol"!==u&&(n[u]=e[u])}return v[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!v[e.protocol]){for(var h=Object.keys(e),p=0;p<h.length;p++){var f=h[p];n[f]=e[f]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||y[e.protocol])n.pathname=e.pathname;else{for(var d=(e.pathname||"").split("/");d.length&&!(e.host=d.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),n.pathname=d.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var m=n.pathname||"",g=n.search||"";n.path=m+g}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var b=n.pathname&&"/"===n.pathname.charAt(0),w=e.host||e.pathname&&"/"===e.pathname.charAt(0),_=w||b||n.host&&e.pathname,C=_,S=n.pathname&&n.pathname.split("/")||[],k=(d=e.pathname&&e.pathname.split("/")||[],n.protocol&&!v[n.protocol]);if(k&&(n.hostname="",n.port=null,n.host&&(""===S[0]?S[0]=n.host:S.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===d[0]?d[0]=e.host:d.unshift(e.host)),e.host=null),_=_&&(""===d[0]||""===S[0])),w)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,S=d;else if(d.length)S||(S=[]),S.pop(),S=S.concat(d),n.search=e.search,n.query=e.query;else if(!o.isNullOrUndefined(e.search))return k&&(n.hostname=n.host=S.shift(),(R=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=R.shift(),n.host=n.hostname=R.shift())),n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!S.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var A=S.slice(-1)[0],E=(n.host||e.host||S.length>1)&&("."===A||".."===A)||""===A,I=0,x=S.length;x>=0;x--)"."===(A=S[x])?S.splice(x,1):".."===A?(S.splice(x,1),I++):I&&(S.splice(x,1),I--);if(!_&&!C)for(;I--;I)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),E&&"/"!==S.join("/").substr(-1)&&S.push("");var R,O=""===S[0]||S[0]&&"/"===S[0].charAt(0);return k&&(n.hostname=n.host=O?"":S.length?S.shift():"",(R=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=R.shift(),n.host=n.hostname=R.shift())),(_=_||n.host&&S.length)&&!O&&S.unshift(""),S.length?n.pathname=S.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":57,punycode:33,querystring:36}],57:[function(e,t,n){t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],58:[function(e,t,n){(function(e){(function(){function n(e,t){if(r("noDeprecation"))return e;var n=!1;function o(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}return o}function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=n}).call(this)}).call(this,void 0!==Z?Z:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],59:[function(e,t,n){function r(e,t){if(e&&t)return r(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach((function(t){n[t]=e[t]})),n;function n(){for(var t=new Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),o=t[t.length-1];return"function"==typeof r&&r!==o&&Object.keys(o).forEach((function(e){r[e]=o[e]})),r}}t.exports=r},{}],60:[function(e,t,n){t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],61:[function(e,t,n){t.exports=o;var r=Object.prototype.hasOwnProperty;function o(){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}},{}]},{},[9])(9);var ri=ni.exports;var oi;!function(e){e[e.IDENTIFIER_REJECTED=2]="IDENTIFIER_REJECTED",e[e.BAD_USERNAME_OR_PASSWORD=4]="BAD_USERNAME_OR_PASSWORD",e[e.NOT_AUTHORIZED=5]="NOT_AUTHORIZED"}(oi||(oi={}));const ii=e=>{let t,n=0,r=!0;return{connect:async function(o){return t&&(t.removeAllListeners(),t.end(!0)),t=ri.connect(e,function(e){return Object.assign({clean:!1,clientId:`mqttjs_ + ${Math.random().toString(16).substr(2,8)}`,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:0,will:{topic:"WillMsg",payload:"Connection Closed abnormally..!",qos:0,retain:!1}},e)}({username:o.userId,password:o.accessToken})),t.on("connect",(()=>{n=0,r=!0})),t.on("error",(e=>{switch(e.code){case 2:case 4:case 5:r=!1}})),t.on("close",(()=>{r&&setTimeout((()=>{n+=1,t.reconnect()}),1e3*2**(n>10?10:n))})),new Promise((e=>t.once("connect",(()=>e()))))},async disconnect(){if(r=!1,this.connected)return new Promise((e=>null==t?void 0:t.end(!0,void 0,(()=>e()))))},get connected(){return!!(null==t?void 0:t.connected)},on(e,n){null==t||t.on(e,n)},once(e,n){null==t||t.once(e,n)},off(e,n){void 0!==n?null==t||t.off(e,n):null==t||t.removeAllListeners(e)},removeAllListeners(){null==t||t.removeAllListeners()},subscribe(e,n){const r=(t,r)=>{if(t||128===r[0].qos){const r=t?new z(t.message,8e5,"error"):new J(8e5,"error");console.error(`Failed to subscribe to topic ${e}`,r),null==n||n(r)}else console.log(`Subscribed to topic ${r[0].topic}`),null==n||n()};return t?t.subscribe(e,{qos:0},r):r(new Error("No connection to broker"),[]),()=>null==t?void 0:t.unsubscribe(e)},unsubscribe(e){null==t||t.unsubscribe(e)}}};let si,ai=[];const ci=["disconnected","error","connect_error","reconnect_error","reconnect_failed","v3.channel.didUpdate","v3.channel.didUpdate","v3.channel.didJoin","v3.channel.didLeave","v3.channel.didAddUsers","v3.channel.didRemoveUsers","v3.channel.didBan","v3.channel.didUnban","v3.message.didCreate","v3.message.didUpdate","v3.message.didDelete"],li=["connect","message","disconnect","error","close","end","reconnect"],ui=()=>{return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map((function(e){e(n)})),(r=e.get("*"))&&r.slice().map((function(e){e(t,n)}))}};var e},hi=(e,t,n,r)=>{const{log:o,emitter:i}=e,s=Date.now();o(`${t}(tmpid: ${s}) > listen`);const a=(...e)=>{o(`${t}(tmpid: ${s}) > trigger`,e),r(...e)};return i.on(n,a),()=>{o(`${t}(tmpid: ${s}) > dispose`),i.off(n,a)}},pi=(e,t)=>{const{emitter:n}=X();var r;r=()=>{n.emit(e,t)},clearTimeout(si),ai.push(r),si=setTimeout((()=>{ai.forEach((e=>e())),ai=[]}),0)},fi=async()=>{const e=X();return e.log("client/api/disconnectClient"),await new Promise((t=>{e.ws.once("disconnect",t),e.ws.disconnect(),e.mqtt.disconnect()})),e.emitter.all.clear(),e.ws.removeAllListeners(),e.mqtt.removeAllListeners(),e.userId=void 0,e.accessToken=void 0,!e.ws.connected},di=()=>{const e=(()=>{var e,t;return(null===(e=r.versions)||void 0===e?void 0:e.node)?r.versions.node:navigator?`${navigator.product.toLowerCase()}#${null!==(t=navigator.userAgent)&&void 0!==t?t:"unknown_agent"}`:"unknown_model"})();return{version:"11.0.0",kind:"web",model:e}};let mi=null;const gi=()=>{if(!mi)throw new z("Connect client first",8e5,"fatal");return mi},yi=["disconnected","error","connect_error","reconnect_error","reconnect_failed"],vi=e=>{const t=X(),n=yi.map((n=>hi(t,`client/onConnectionError(${n})`,n,(t=>{const r=(null==t?void 0:t.code)?new z(t.message,t.code,"fatal"):new Y(n);e(r)}))));return()=>{n.forEach((e=>e()))}},bi=e=>vi((({code:t})=>{400312===t&&e()}));var wi;e.SubscriptionLevels=void 0,(wi=e.SubscriptionLevels||(e.SubscriptionLevels={})).COMMUNITY="community",wi.POST="post",wi.COMMENT="comment",wi.POST_AND_COMMENT="post_and_comment",wi.USER="user";const _i=(e,t)=>{switch(t){case"post":return`${e}/post/+`;case"comment":return`${e}/post/+/comment/+`;case"post_and_comment":return`${e}/post/#`;default:return e}};let Ci,Si;const ki=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},{hasOwnProperty:Ai}=Object.prototype,{propertyIsEnumerable:Ei}=Object,Ii=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}),xi=Z,Ri={concatArrays:!1,ignoreUndefined:!1},Oi=e=>{const t=[];for(const n in e)Ai.call(e,n)&&t.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(e);for(const r of n)Ei.call(e,r)&&t.push(r)}return t};function Fi(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return Oi(e).forEach((n=>{Ii(t,n,Fi(e[n]))})),t}(e):ki(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return Oi(e).forEach((n=>{Ii(t,n,Fi(e[n]))})),t}(e):e}const Ti=(e,t,n,r)=>(n.forEach((n=>{void 0===t[n]&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?Ii(e,n,Pi(e[n],t[n],r)):Ii(e,n,Fi(t[n])))})),e);function Pi(e,t,n){return n.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,n)=>{let r=e.slice(0,0),o=0;return[e,t].forEach((t=>{const i=[];for(let n=0;n<t.length;n++)Ai.call(t,n)&&(i.push(String(n)),Ii(r,o++,t===e?t[n]:Fi(t[n])));r=Ti(r,t,Oi(t).filter((e=>!i.includes(e))),n)})),r})(e,t,n):ki(t)&&ki(e)?Ti(e,t,Oi(t),n):Fi(t)}const Bi=function(...e){const t=Pi(Fi(Ri),this!==xi&&this||{},Ri);let n={_:{}};for(const r of e)if(void 0!==r){if(!ki(r))throw new TypeError("`"+r+"` is not an Option Object");n=Pi(n,{_:r},t)}return n._}.bind({concatArrays:!0,ignoreUndefined:!0}),ji=(e,t)=>new Promise(((n,r)=>{try{const r=e();t&&t(null,r),n(r)}catch(e){t&&t(e),r(e)}})),Ui=(e,t,n)=>Promise.all(e).then((e=>{const r=n?n(e):null;return t&&t(null,r),Promise.resolve(r)}),(e=>(t&&t(e),Promise.reject(e))));class Mi{static getItem(e,t){return ji((()=>window.localStorage.getItem(e)),t)}static setItem(e,t,n){return ji((()=>{window.localStorage.setItem(e,t)}),n)}static removeItem(e,t){return ji((()=>window.localStorage.removeItem(e)),t)}static mergeItem(e,t,n){return ji((()=>{((e,t)=>{const n=window.localStorage.getItem(e),r=JSON.parse(n),o=JSON.parse(t),i=JSON.stringify(Bi(r,o));window.localStorage.setItem(e,i)})(e,t)}),n)}static clear(e){return ji((()=>{window.localStorage.clear()}),e)}static getAllKeys(e){return ji((()=>{const e=window.localStorage.length,t=[];for(let n=0;n<e;n+=1){const e=window.localStorage.key(n);t.push(e)}return t}),e)}static flushGetRequests(){}static multiGet(e,t){const n=e.map((e=>Mi.getItem(e)));return Ui(n,t,(t=>t.map(((t,n)=>[e[n],t]))))}static multiSet(e,t){const n=e.map((e=>Mi.setItem(e[0],e[1])));return Ui(n,t)}static multiRemove(e,t){const n=e.map((e=>Mi.removeItem(e)));return Ui(n,t)}static multiMerge(e,t){const n=e.map((e=>Mi.mergeItem(e[0],e[1])));return Ui(n,t)}}const Ni=e=>JSON.stringify(e,((e,t)=>{return"object"==typeof t?(n=t,Object.keys(n).sort().reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:n[t]})),{})):t;var n})),Li=e=>JSON.parse(e),Di=(e,t)=>e===t||!(!e||!t)&&("object"==typeof e&&Object.keys(e).every((n=>Di(e[n],t[n])))),qi=e=>{const{log:t,cache:n}=X();if(n)return t("cache/api/queryCache",{key:e}),Object.keys(n.data).filter((t=>{const n=Li(t);return Di(e,n)})).map((e=>n.data[e]))},$i=e=>{const{log:t,cache:n}=X();if(!n)return;t("cache/api/pullFromCache",e);const r=Ni(e);return n.data[r]?n.data[r]:void 0},Hi=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=X();if(!o)return!1;r("cache/api/pushToCache",{key:e,data:t,options:n}),!(null==n?void 0:n.hasOwnProperty("offline"))&&o.persistIf&&(n.offline=o.persistIf(e,t));const i=Ni(e);return o.data[i]=Object.assign({key:e,data:t},n),!0},Vi=(e,t,n)=>{const{log:r,cache:o}=X();if(!o)return!1;r("cache/api/mergeInCache",{key:e,mutation:t});const i=$i(e);if(!i)return!1;const s="function"==typeof t?t(i.data):Object.assign(Object.assign({},i.data),t);return Hi(e,s,n),!0},Wi=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=X();if(!o)return!1;r("cache/api/upsertInCache",{key:e,data:t,options:n});return $i(e)?Vi(e,t,n):Hi(e,t,n)},zi=(e,t=!1)=>{const{log:n,cache:r}=X();if(!r)return!1;if(n("cache/api/dropFromCache",{key:e,exact:t}),!t)return Object.keys(r.data).map((e=>Li(e))).filter((t=>Di(e,t))).map((e=>zi(e,!0))).every((e=>e));const o=Ni(e);return o in r.data&&(delete r.data[o],!0)},Ki={user:({userId:e})=>e,file:({fileId:e})=>e,role:({roleId:e})=>e,channel:({channelId:e})=>e,channelUsers:({channelId:e,userId:t})=>`${e}#${t}`,message:({messageId:e})=>e,community:({communityId:e})=>e,communityUsers:({communityId:e,userId:t})=>`${e}#${t}`,post:({postId:e})=>e,comment:({commentId:e})=>e,stream:({streamId:e})=>e,follow:({from:e,to:t})=>`${e}#${t}`,followCount:({userId:e})=>e},Ji=e=>Ki[e],Yi={users:"user",files:"file",roles:"role",channels:"channel",channelUsers:"channelUsers",messages:"message",communities:"community",communityUsers:"communityUsers",posts:"post",postChildren:"post",comments:"comment",videoStreamings:"stream",follows:"follow",followCounts:"followCount"},Qi=(e={},t)=>{Object.entries(e).forEach((([e,n])=>{const r=Yi[e];if(!r)return;const o=Ji(r);n.forEach((e=>{Wi([r,"get",o(e)],e,t)}))}))},Xi=async e=>{const t=X();t.log("user/getUser",e);const{data:n}=await t.http.get(`/api/v3/users/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r});const{users:o}=n;return{data:o.find((t=>t.userId===e)),cachedAt:r}};Xi.locally=e=>{const t=X();return t.log("user/getUser.locally",e),t.cache&&$i(["user","get",e])};const Gi=async e=>{const t=X();t.log("user/getUsers",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/users/list",{params:{userIds:n}}),o=t.cache&&Date.now();return t.cache&&Qi(r,{cachedAt:o}),{data:r.users,cachedAt:o}};
|
|
6
|
+
var r=e("buffer"),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=r:(i(r,n),n.Buffer=s),s.prototype=Object.create(o.prototype),i(o,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},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 r.SlowBuffer(e)}},{buffer:14}],54:[function(e,t,n){function r(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(o(t)):null}function o(e){return e.buffer.length?e.buffer.head?e.buffer.head.data.length:e.buffer[0].length:e.length}t.exports=r},{}],55:[function(e,t,n){var r=e("safe-buffer").Buffer,o=r.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){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}}function s(e){var t=i(e);if("string"!=typeof t&&(r.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}function a(e){var t;switch(this.encoding=s(e),this.encoding){case"utf16le":this.text=d,this.end=m,t=4;break;case"utf8":this.fillLast=h,t=4;break;case"base64":this.text=g,this.end=y,t=3;break;default:return this.write=v,void(this.end=b)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function c(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function l(e,t,n){var r=t.length-1;if(r<n)return 0;var o=c(t[r]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(e.lastNeed=o-2),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(2===o?o=0:e.lastNeed=o-3),o):0}function u(e,t,n){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,"�"}}function h(e){var t=this.lastTotal-this.lastNeed,n=u(this,e);return void 0!==n?n: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 p(e,t){var n=l(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function d(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function m(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function g(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?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-n))}function y(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function v(e){return e.toString(this.encoding)}function b(e){return e&&e.length?this.write(e):""}n.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},a.prototype.end=f,a.prototype.text=p,a.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}},{"safe-buffer":53}],56:[function(e,t,n){var r=e("punycode"),o=e("./util");function i(){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}n.parse=w,n.resolve=C,n.resolveObject=S,n.format=_,n.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(l),h=["%","/","?",";","#"].concat(u),p=["/","?","#"],f=255,d=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=e("querystring");function w(e,t,n){if(e&&o.isObject(e)&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}function _(e){return o.isString(e)&&(e=w(e)),e instanceof i?e.format():i.prototype.format.call(e)}function C(e,t){return w(e,!1,!0).resolve(t)}function S(e,t){return e?w(e,!1,!0).resolveObject(t):t}i.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),a=-1!==i&&i<e.indexOf("#")?"?":"#",l=e.split(a),w=/\\/g;l[0]=l[0].replace(w,"/");var _=e=l.join(a);if(_=_.trim(),!n&&1===e.split("#").length){var C=c.exec(_);if(C)return this.path=_,this.href=_,this.pathname=C[1],C[2]?(this.search=C[2],this.query=t?b.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var S=s.exec(_);if(S){var k=(S=S[0]).toLowerCase();this.protocol=k,_=_.substr(S.length)}if(n||S||_.match(/^\/\/[^@\/]+@[^@\/]+/)){var A="//"===_.substr(0,2);!A||S&&y[S]||(_=_.substr(2),this.slashes=!0)}if(!y[S]&&(A||S&&!v[S])){for(var E,I,O=-1,x=0;x<p.length;x++)-1!==(R=_.indexOf(p[x]))&&(-1===O||R<O)&&(O=R);for(-1!==(I=-1===O?_.lastIndexOf("@"):_.lastIndexOf("@",O))&&(E=_.slice(0,I),_=_.slice(I+1),this.auth=decodeURIComponent(E)),O=-1,x=0;x<h.length;x++){var R;-1!==(R=_.indexOf(h[x]))&&(-1===O||R<O)&&(O=R)}-1===O&&(O=_.length),this.host=_.slice(0,O),_=_.slice(O),this.parseHost(),this.hostname=this.hostname||"";var F="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!F)for(var T=this.hostname.split(/\./),P=(x=0,T.length);x<P;x++){var B=T[x];if(B&&!B.match(d)){for(var j="",U=0,M=B.length;U<M;U++)B.charCodeAt(U)>127?j+="x":j+=B[U];if(!j.match(d)){var N=T.slice(0,x),D=T.slice(x+1),L=B.match(m);L&&(N.push(L[1]),D.unshift(L[2])),D.length&&(_="/"+D.join(".")+_),this.hostname=N.join(".");break}}}this.hostname.length>f?this.hostname="":this.hostname=this.hostname.toLowerCase(),F||(this.hostname=r.toASCII(this.hostname));var q=this.port?":"+this.port:"",$=this.hostname||"";this.host=$+q,this.href+=this.host,F&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!g[k])for(x=0,P=u.length;x<P;x++){var H=u[x];if(-1!==_.indexOf(H)){var V=encodeURIComponent(H);V===H&&(V=escape(H)),_=_.split(H).join(V)}}var W=_.indexOf("#");-1!==W&&(this.hash=_.substr(W),_=_.slice(0,W));var z=_.indexOf("?");if(-1!==z?(this.search=_.substr(z),this.query=_.substr(z+1),t&&(this.query=b.parse(this.query)),_=_.slice(0,z)):t&&(this.search="",this.query={}),_&&(this.pathname=_),v[k]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){q=this.pathname||"";var K=this.search||"";this.path=q+K}return this.href=this.format(),this},i.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,s="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(s=b.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||v[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),t+i+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+r},i.prototype.resolve=function(e){return this.resolveObject(w(e,!1,!0)).format()},i.prototype.resolveObject=function(e){if(o.isString(e)){var t=new i;t.parse(e,!1,!0),e=t}for(var n=new i,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),l=0;l<c.length;l++){var u=c[l];"protocol"!==u&&(n[u]=e[u])}return v[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!v[e.protocol]){for(var h=Object.keys(e),p=0;p<h.length;p++){var f=h[p];n[f]=e[f]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||y[e.protocol])n.pathname=e.pathname;else{for(var d=(e.pathname||"").split("/");d.length&&!(e.host=d.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),n.pathname=d.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var m=n.pathname||"",g=n.search||"";n.path=m+g}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var b=n.pathname&&"/"===n.pathname.charAt(0),w=e.host||e.pathname&&"/"===e.pathname.charAt(0),_=w||b||n.host&&e.pathname,C=_,S=n.pathname&&n.pathname.split("/")||[],k=(d=e.pathname&&e.pathname.split("/")||[],n.protocol&&!v[n.protocol]);if(k&&(n.hostname="",n.port=null,n.host&&(""===S[0]?S[0]=n.host:S.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===d[0]?d[0]=e.host:d.unshift(e.host)),e.host=null),_=_&&(""===d[0]||""===S[0])),w)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,S=d;else if(d.length)S||(S=[]),S.pop(),S=S.concat(d),n.search=e.search,n.query=e.query;else if(!o.isNullOrUndefined(e.search))return k&&(n.hostname=n.host=S.shift(),(x=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=x.shift(),n.host=n.hostname=x.shift())),n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!S.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var A=S.slice(-1)[0],E=(n.host||e.host||S.length>1)&&("."===A||".."===A)||""===A,I=0,O=S.length;O>=0;O--)"."===(A=S[O])?S.splice(O,1):".."===A?(S.splice(O,1),I++):I&&(S.splice(O,1),I--);if(!_&&!C)for(;I--;I)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),E&&"/"!==S.join("/").substr(-1)&&S.push("");var x,R=""===S[0]||S[0]&&"/"===S[0].charAt(0);return k&&(n.hostname=n.host=R?"":S.length?S.shift():"",(x=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=x.shift(),n.host=n.hostname=x.shift())),(_=_||n.host&&S.length)&&!R&&S.unshift(""),S.length?n.pathname=S.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":57,punycode:33,querystring:36}],57:[function(e,t,n){t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],58:[function(e,t,n){(function(e){(function(){function n(e,t){if(r("noDeprecation"))return e;var n=!1;function o(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}return o}function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=n}).call(this)}).call(this,void 0!==Z?Z:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],59:[function(e,t,n){function r(e,t){if(e&&t)return r(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach((function(t){n[t]=e[t]})),n;function n(){for(var t=new Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),o=t[t.length-1];return"function"==typeof r&&r!==o&&Object.keys(o).forEach((function(e){r[e]=o[e]})),r}}t.exports=r},{}],60:[function(e,t,n){t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],61:[function(e,t,n){t.exports=o;var r=Object.prototype.hasOwnProperty;function o(){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}},{}]},{},[9])(9);var oi=ri.exports;var ii;!function(e){e[e.IDENTIFIER_REJECTED=2]="IDENTIFIER_REJECTED",e[e.BAD_USERNAME_OR_PASSWORD=4]="BAD_USERNAME_OR_PASSWORD",e[e.NOT_AUTHORIZED=5]="NOT_AUTHORIZED"}(ii||(ii={}));const si=e=>{let t,n=0,r=!0;return{connect:async function(o){return t&&(t.removeAllListeners(),t.end(!0)),t=oi.connect(e,function(e){return Object.assign({clean:!1,clientId:`mqttjs_ + ${Math.random().toString(16).substr(2,8)}`,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:0,will:{topic:"WillMsg",payload:"Connection Closed abnormally..!",qos:0,retain:!1}},e)}({username:o.userId,password:o.accessToken})),t.on("connect",(()=>{n=0,r=!0})),t.on("error",(e=>{switch(e.code){case 2:case 4:case 5:r=!1}})),t.on("close",(()=>{r&&setTimeout((()=>{n+=1,t.reconnect()}),1e3*2**(n>10?10:n))})),new Promise((e=>t.once("connect",(()=>e()))))},async disconnect(){if(r=!1,this.connected)return new Promise((e=>null==t?void 0:t.end(!0,void 0,(()=>e()))))},get connected(){return!!(null==t?void 0:t.connected)},on(e,n){null==t||t.on(e,n)},once(e,n){null==t||t.once(e,n)},off(e,n){void 0!==n?null==t||t.off(e,n):null==t||t.removeAllListeners(e)},removeAllListeners(){null==t||t.removeAllListeners()},subscribe(e,n){const r=(t,r)=>{if(t||128===r[0].qos){const r=t?new z(t.message,8e5,"error"):new J(8e5,"error");console.error(`Failed to subscribe to topic ${e}`,r),null==n||n(r)}else console.log(`Subscribed to topic ${r[0].topic}`),null==n||n()};return t?t.subscribe(e,{qos:0},r):r(new Error("No connection to broker"),[]),()=>null==t?void 0:t.unsubscribe(e)},unsubscribe(e){null==t||t.unsubscribe(e)}}};let ai,ci=[];const li=["disconnected","error","connect_error","reconnect_error","reconnect_failed","v3.channel.didUpdate","v3.channel.didUpdate","v3.channel.didJoin","v3.channel.didLeave","v3.channel.didAddUsers","v3.channel.didRemoveUsers","v3.channel.didBan","v3.channel.didUnban","v3.message.didCreate","v3.message.didUpdate","v3.message.didDelete"],ui=["connect","message","disconnect","error","close","end","reconnect"],hi=()=>{return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map((function(e){e(n)})),(r=e.get("*"))&&r.slice().map((function(e){e(t,n)}))}};var e},pi=(e,t,n,r)=>{const{log:o,emitter:i}=e,s=Date.now();o(`${t}(tmpid: ${s}) > listen`);const a=(...e)=>{o(`${t}(tmpid: ${s}) > trigger`,e),r(...e)};return i.on(n,a),()=>{o(`${t}(tmpid: ${s}) > dispose`),i.off(n,a)}},fi=(e,t)=>{const{emitter:n}=Q();var r;r=()=>{n.emit(e,t)},clearTimeout(ai),ci.push(r),ai=setTimeout((()=>{ci.forEach((e=>e())),ci=[]}),0)},di=async()=>{const e=Q();return e.log("client/api/disconnectClient"),await new Promise((t=>{e.ws.once("disconnect",t),e.ws.disconnect(),e.mqtt.disconnect()})),e.emitter.all.clear(),e.ws.removeAllListeners(),e.mqtt.removeAllListeners(),e.userId=void 0,e.accessToken=void 0,!e.ws.connected},mi=()=>`ascWebSdk#${Math.random().toString(16)}`,gi=()=>{const e=(()=>{var e,t;return(null===(e=r.versions)||void 0===e?void 0:e.node)?r.versions.node:navigator?`${navigator.product.toLowerCase()}#${null!==(t=navigator.userAgent)&&void 0!==t?t:"unknown_agent"}`:"unknown_model"})();return{version:"11.0.0",kind:"web",model:e}};let yi=null;const vi=()=>{if(!yi)throw new z("Connect client first",8e5,"fatal");return yi},bi=["disconnected","error","connect_error","reconnect_error","reconnect_failed"],wi=e=>{const t=Q(),n=bi.map((n=>pi(t,`client/onConnectionError(${n})`,n,(t=>{const r=(null==t?void 0:t.code)?new z(t.message,t.code,"fatal"):new Y(n);e(r)}))));return()=>{n.forEach((e=>e()))}},_i=e=>wi((({code:t})=>{400312===t&&e()}));var Ci;e.SubscriptionLevels=void 0,(Ci=e.SubscriptionLevels||(e.SubscriptionLevels={})).COMMUNITY="community",Ci.POST="post",Ci.COMMENT="comment",Ci.POST_AND_COMMENT="post_and_comment",Ci.USER="user";const Si=(e,t)=>{switch(t){case"post":return`${e}/post/+`;case"comment":return`${e}/post/+/comment/+`;case"post_and_comment":return`${e}/post/#`;default:return e}};let ki,Ai;const Ei=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},{hasOwnProperty:Ii}=Object.prototype,{propertyIsEnumerable:Oi}=Object,xi=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}),Ri=Z,Fi={concatArrays:!1,ignoreUndefined:!1},Ti=e=>{const t=[];for(const n in e)Ii.call(e,n)&&t.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(e);for(const r of n)Oi.call(e,r)&&t.push(r)}return t};function Pi(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return Ti(e).forEach((n=>{xi(t,n,Pi(e[n]))})),t}(e):Ei(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return Ti(e).forEach((n=>{xi(t,n,Pi(e[n]))})),t}(e):e}const Bi=(e,t,n,r)=>(n.forEach((n=>{void 0===t[n]&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?xi(e,n,ji(e[n],t[n],r)):xi(e,n,Pi(t[n])))})),e);function ji(e,t,n){return n.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,n)=>{let r=e.slice(0,0),o=0;return[e,t].forEach((t=>{const i=[];for(let n=0;n<t.length;n++)Ii.call(t,n)&&(i.push(String(n)),xi(r,o++,t===e?t[n]:Pi(t[n])));r=Bi(r,t,Ti(t).filter((e=>!i.includes(e))),n)})),r})(e,t,n):Ei(t)&&Ei(e)?Bi(e,t,Ti(t),n):Pi(t)}const Ui=function(...e){const t=ji(Pi(Fi),this!==Ri&&this||{},Fi);let n={_:{}};for(const r of e)if(void 0!==r){if(!Ei(r))throw new TypeError("`"+r+"` is not an Option Object");n=ji(n,{_:r},t)}return n._}.bind({concatArrays:!0,ignoreUndefined:!0}),Mi=(e,t)=>new Promise(((n,r)=>{try{const r=e();t&&t(null,r),n(r)}catch(e){t&&t(e),r(e)}})),Ni=(e,t,n)=>Promise.all(e).then((e=>{const r=n?n(e):null;return t&&t(null,r),Promise.resolve(r)}),(e=>(t&&t(e),Promise.reject(e))));class Di{static getItem(e,t){return Mi((()=>window.localStorage.getItem(e)),t)}static setItem(e,t,n){return Mi((()=>{window.localStorage.setItem(e,t)}),n)}static removeItem(e,t){return Mi((()=>window.localStorage.removeItem(e)),t)}static mergeItem(e,t,n){return Mi((()=>{((e,t)=>{const n=window.localStorage.getItem(e),r=JSON.parse(n),o=JSON.parse(t),i=JSON.stringify(Ui(r,o));window.localStorage.setItem(e,i)})(e,t)}),n)}static clear(e){return Mi((()=>{window.localStorage.clear()}),e)}static getAllKeys(e){return Mi((()=>{const e=window.localStorage.length,t=[];for(let n=0;n<e;n+=1){const e=window.localStorage.key(n);t.push(e)}return t}),e)}static flushGetRequests(){}static multiGet(e,t){const n=e.map((e=>Di.getItem(e)));return Ni(n,t,(t=>t.map(((t,n)=>[e[n],t]))))}static multiSet(e,t){const n=e.map((e=>Di.setItem(e[0],e[1])));return Ni(n,t)}static multiRemove(e,t){const n=e.map((e=>Di.removeItem(e)));return Ni(n,t)}static multiMerge(e,t){const n=e.map((e=>Di.mergeItem(e[0],e[1])));return Ni(n,t)}}const Li=e=>JSON.stringify(e,((e,t)=>{return"object"==typeof t?(n=t,Object.keys(n).sort().reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:n[t]})),{})):t;var n})),qi=e=>JSON.parse(e),$i=(e,t)=>e===t||!(!e||!t)&&("object"==typeof e&&Object.keys(e).every((n=>$i(e[n],t[n])))),Hi=e=>{const{log:t,cache:n}=Q();if(n)return t("cache/api/queryCache",{key:e}),Object.keys(n.data).filter((t=>{const n=qi(t);return $i(e,n)})).map((e=>n.data[e]))},Vi=e=>{const{log:t,cache:n}=Q();if(!n)return;t("cache/api/pullFromCache",e);const r=Li(e);return n.data[r]?n.data[r]:void 0},Wi=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=Q();if(!o)return!1;r("cache/api/pushToCache",{key:e,data:t,options:n}),!(null==n?void 0:n.hasOwnProperty("offline"))&&o.persistIf&&(n.offline=o.persistIf(e,t));const i=Li(e);return o.data[i]=Object.assign({key:e,data:t},n),!0},zi=(e,t,n)=>{const{log:r,cache:o}=Q();if(!o)return!1;r("cache/api/mergeInCache",{key:e,mutation:t});const i=Vi(e);if(!i)return!1;const s="function"==typeof t?t(i.data):Object.assign(Object.assign({},i.data),t);return Wi(e,s,n),!0},Ki=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=Q();if(!o)return!1;r("cache/api/upsertInCache",{key:e,data:t,options:n});return Vi(e)?zi(e,t,n):Wi(e,t,n)},Ji=(e,t=!1)=>{const{log:n,cache:r}=Q();if(!r)return!1;if(n("cache/api/dropFromCache",{key:e,exact:t}),!t)return Object.keys(r.data).map((e=>qi(e))).filter((t=>$i(e,t))).map((e=>Ji(e,!0))).every((e=>e));const o=Li(e);return o in r.data&&(delete r.data[o],!0)},Yi={user:({userId:e})=>e,file:({fileId:e})=>e,role:({roleId:e})=>e,channel:({channelId:e})=>e,channelUsers:({channelId:e,userId:t})=>`${e}#${t}`,message:({messageId:e})=>e,community:({communityId:e})=>e,category:({categoryId:e})=>e,communityUsers:({communityId:e,userId:t})=>`${e}#${t}`,post:({postId:e})=>e,comment:({commentId:e})=>e,poll:({pollId:e})=>e,stream:({streamId:e})=>e,follow:({from:e,to:t})=>`${e}#${t}`,followCount:({userId:e})=>e},Xi=e=>Yi[e],Qi={users:"user",files:"file",roles:"role",channels:"channel",channelUsers:"channelUsers",messages:"message",communities:"community",categories:"category",communityUsers:"communityUsers",posts:"post",postChildren:"post",comments:"comment",polls:"poll",videoStreamings:"stream",follows:"follow",followCounts:"followCount"},Gi=(e={},t)=>{Object.entries(e).forEach((([e,n])=>{const r=Qi[e];if(!r)return;const o=Xi(r);n.forEach((e=>{Ki([r,"get",o(e)],e,t)}))}))},Zi=async e=>{const t=Q();t.log("user/getUser",e);const{data:n}=await t.http.get(`/api/v3/users/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{users:o}=n;return{data:o.find((t=>t.userId===e)),cachedAt:r}};Zi.locally=e=>{const t=Q();return t.log("user/getUser.locally",e),t.cache&&Vi(["user","get",e])};const es=async e=>{const t=Q();t.log("user/getUsers",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/users/list",{params:{userIds:n}}),o=t.cache&&Date.now();return t.cache&&Gi(r,{cachedAt:o}),{data:r.users,cachedAt:o}};
|
|
7
7
|
/*! *****************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
9
9
|
|
|
@@ -18,4 +18,4 @@ var r=e("buffer"),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function s
|
|
|
18
18
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
19
|
PERFORMANCE OF THIS SOFTWARE.
|
|
20
20
|
***************************************************************************** */
|
|
21
|
-
function Zi(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}Gi.locally=e=>{var t;const n=X();if(n.log("user/getUsers.locally",e),!n.cache)return;const r=e.map((e=>$i(["user","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const es=async(e={})=>{const t=X();t.log("user/queryUsers",e);const{page:n,displayName:r,filter:o="all",sortBy:i="displayName"}=e,s=Zi(e,["page","displayName","filter","sortBy"]),{data:a}=await t.http.get("/api/v3/users",{params:Object.assign(Object.assign({},s),{keyword:r,filter:o,sortBy:i,options:{token:B(n,"skiplimit")}})}),{paging:c}=a,l=Zi(a,["paging"]),{users:u}=l,h=t.cache&&Date.now();if(t.cache){Qi(l,{cachedAt:h});Hi(["user","query",e],{users:u.map(Ji("user")),paging:c})}return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:j(c.next)}};es.locally=(e={})=>{var t,n,r;const o=X();if(o.log("user/queryUsers.locally",e),!o.cache)return;const i=["user","query",e],{data:s,cachedAt:a}=null!==(t=$i(i))&&void 0!==t?t:{},c=null!==(n=null==s?void 0:s.users.map((e=>$i(["user","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==n?n:[],l=j(null==s?void 0:s.paging.previous),u=j(null==s?void 0:s.paging.next);return c.length>0&&c.length===(null===(r=null==s?void 0:s.users)||void 0===r?void 0:r.length)?{data:c,cachedAt:a,prevPage:l,nextPage:u}:void 0};const ts=(e,t)=>{const n=X();return hi(n,e,e,(e=>{n.cache&&Qi(e),t(e.users[0])}))},ns=e=>ts("user.updated",e),rs=e=>ts("user.flagged",e),os=e=>ts("user.unflagged",e),is=e=>ts("user.flagCleared",e),ss=async e=>{const t=X();t.log("file/getFile",e);const{data:n}=await t.http.get(`/api/v3/files/${e}`),r=t.cache&&Date.now();return t.cache&&Qi({files:[n]},{cachedAt:r}),{data:n,cachedAt:r}};ss.locally=e=>{const t=X();if(t.log("file/getFile.locally",e),!t.cache)return;const n=$i(["file","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const as=async e=>{const t=X();t.log("role/queryRoles",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,sortBy:i}=n,s=Zi(n,["page","displayName","sortBy"]),{data:a}=await t.http.get("/api/v3/roles",{params:Object.assign(Object.assign({},s),{keyword:o,sortBy:i,options:{token:B(r,"skiplimit")}})}),{paging:c}=a,l=Zi(a,["paging"]),{roles:u}=l,h=t.cache&&Date.now();t.cache&&Qi(l,{cachedAt:h});const p=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:p}};as.locally=e=>{X().log("role/queryRoles.locally",e)};const cs=async e=>{const t=X();t.log("role/getRole",e);const{data:n}=await t.http.get(`/api/v3/roles/${e}`),r=t.cache&&Date.now();return t.cache&&Qi({roles:n},{cachedAt:r}),{data:n.find((t=>t.roleId===e)),cachedAt:r}};cs.locally=e=>{const t=X();if(t.log("role/getRole.locally",e),!t.cache)return;const n=$i(["role","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const ls=(e,t)=>{"message"===e?pi("v3.message.didUpdate",{messages:[t]}):"post"===e?pi("post.updated",{posts:[t]}):"comment"===e&&pi("comment.updated",{comments:[t]})},us=async e=>{const t=X();t.log("message/getMessage",e);const{data:n}=await t.http.get(`/api/v3/messages/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r});const{messages:o}=n;return{data:o.find((t=>t.messageId===e)),cachedAt:r}};us.locally=e=>{const t=X();if(t.log("message/getMessage.locally",e),!t.cache)return;const n=$i(["message","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const hs=async e=>{const t=X();t.log("message/getMessages",e);const{data:n}=await t.http.get("/api/v3/messages/list",{params:{messageIds:e}}),r=t.cache&&Date.now();return t.cache&&Qi(n,{cachedAt:r}),{data:n.messages,cachedAt:r}};hs.locally=e=>{var t;const n=X();if(n.log("message/getMessages.locally",e),!n.cache)return;const r=e.map((e=>$i(["message","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const ps=async e=>{const t=X();t.log("message/queryMessages",e);const{page:n={limit:10}}=e,r=Zi(e,["page"]),{data:o}=await t.http.get("/api/v3/messages",{params:Object.assign(Object.assign({},r),{options:{token:B(n,"afterbefore")}})}),{paging:i}=o,s=Zi(o,["paging"]),{messages:a}=s,c=t.cache&&Date.now();if(t.cache){Qi(s,{cachedAt:c});const e=["message","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];Hi(e,{messages:a.map(Ji("message")),paging:i})}const l=j(i.next);return{data:a,cachedAt:c,prevPage:j(i.previous),nextPage:l}};ps.locally=e=>{var t,n;const r=X();if(r.log("message/queryMessages.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Zi(e,["page"]),s=["message","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=$i(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.messages.length))return;const l=a.messages.map((e=>$i(["message","get",e]))).filter(Boolean).map((({data:e})=>e)),u=j(null==a?void 0:a.paging.previous),h=j(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const fs=async e=>{const t=X();t.log("user/createMessage",e);const{data:n}=await t.http.post("/api/v3/messages",e),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r});const{messages:o}=n;return{data:o[0],cachedAt:r}};fs.optimistically=e=>{var t,n;const r=X();if(r.log("user/createMessage.locally",e),!r.cache)return;const o=$i(["channel","get",e.channelId]);Wi(["channel","get",e.channelId],Object.assign(Object.assign({},null==o?void 0:o.data),{messageCount:(null!==(t=null==o?void 0:o.data.messageCount)&&void 0!==t?t:0)+1}));const i=Object.assign({messageId:Math.random().toString(16),userId:r.userId,channelSegment:(null!==(n=null==o?void 0:o.data.messageCount)&&void 0!==n?n:0)+1,createdAt:(new Date).toISOString()},e);return Hi(["message","get",i.messageId],i,{cachedAt:-1}),pi("v3.message.didCreate",{messages:[i]}),{data:i,cachedAt:-1}};const ds=async(e,t)=>{const n=X();n.log("user/updateMessage",t);const{data:r}=await n.http.put(`/api/v3/messages/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Qi(r,{cachedAt:o});const{messages:i}=r;return{data:i.find((t=>t.messageId===e)),cachedAt:o}};ds.optimistically=(e,t)=>{const n=X();if(n.log("user/updateMessage",t),!n.cache)return;const r=$i(["message","get",e]);if(!r)return;const o=Object.assign(Object.assign(Object.assign({},r.data),t),{updatedAt:(new Date).toISOString()});return Wi(["message","get",e],o,{cachedAt:-1}),pi("v3.message.didUpdate",{messages:[o]}),{data:o,cachedAt:-1}};const ms=async e=>{const t=X();t.log("message/deleteMessage",e),await t.http.delete(`/api/v3/messages/${encodeURIComponent(e)}`);return(await us(e)).data};ms.optimistically=e=>{X().log("message/deleteMessage",e);const t=$i(["message","get",e]);if(!t)return;const n=Object.assign(Object.assign({},t.data),{isDeleted:!0,updatedAt:(new Date).toISOString()});return Wi(["message","get",e],n,{cachedAt:-1}),pi("v3.message.didDelete",{messages:[n]}),{data:n,cachedAt:-1}};const gs=async e=>{const t=X();t.log("post/queryPosts",e);const{page:n={limit:10}}=e,r=Zi(e,["page"]),{data:o}=await t.http.get("/api/v4/posts",{params:Object.assign(Object.assign({},r),{options:{token:B(n,"afterbeforeraw")}})}),{paging:i}=o,s=Zi(o,["paging"]),{posts:a}=s,c=t.cache&&Date.now();if(t.cache){Qi(s,{cachedAt:c});const e=["post","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];Hi(e,{posts:a.map(Ji("post")),paging:i})}const l=U(i.next);return{data:a,cachedAt:c,prevPage:U(i.previous),nextPage:l}};gs.locally=e=>{var t,n;const r=X();if(r.log("post/queryPosts.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Zi(e,["page"]),s=["post","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=$i(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.posts.length))return;const l=a.posts.map((e=>$i(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),u=U(null==a?void 0:a.paging.previous),h=U(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.posts)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const ys=async e=>{const t=X();t.log("post/getPosts",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/posts/list",{params:{postIds:n}}),o=t.cache&&Date.now();return t.cache&&Qi(r,{cachedAt:o}),{data:r.posts,cachedAt:o}};ys.locally=e=>{var t;const n=X();if(n.log("post/getPosts.locally",e),!n.cache)return;const r=e.map((e=>$i(["post","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const vs=async e=>{var t;const n=X();let r;n.log("post/getPost",e);try{r=(await n.http.get(`/api/v3/posts/${encodeURIComponent(e)}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&zi(["post","get",e],!0),n}const o=n.cache&&Date.now();n.cache&&Qi(r,{cachedAt:o});const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}};vs.locally=e=>{const t=X();if(t.log("post/getPost.locally",e),!t.cache)return;const n=$i(["post","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const bs=async e=>{const t=X();t.log("channel/queryCommunities",e);const n=null!=e?e:{},{page:r,displayName:o,membership:i}=n,s=Zi(n,["page","displayName","membership"]),{data:a}=await t.http.get("/api/v3/communities",{params:Object.assign(Object.assign({},s),{keyword:o,filter:i,options:{token:B(r,"skiplimit")}})}),{paging:c}=a,l=Zi(a,["paging"]),{communities:u}=l,h=t.cache&&Date.now();if(t.cache){Qi(l,{cachedAt:h});const e=["community","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];Hi(e,{communities:u.map(Ji("community")),paging:c})}const p=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:p}};bs.locally=e=>{X().log("community/queryCommunities.locally",e)};const ws=async e=>{const t=X();t.log("community/getCommunities",e);const{data:n}=await t.http.get("/api/v3/communities/list",{params:{communityIds:e}}),r=t.cache&&Date.now();return t.cache&&Qi(n,{cachedAt:r}),{data:n.communities,cachedAt:r}};ws.locally=e=>{var t;const n=X();if(n.log("community/getCommunities.locally",e),!n.cache)return;const r=e.map((e=>$i(["community","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const _s=async e=>{const t=X();t.log("community/getCommunity",e);const{data:n}=await t.http.get(`/api/v3/communities/${e}`),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r});const{communities:o}=n;return{data:o.find((t=>t.communityId===e)),cachedAt:r}};_s.locally=e=>{const t=X();if(t.log("community/getCommunity.locally",e),!t.cache)return;const n=$i(["community","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Cs=async e=>{const t=X();t.log("community/queryCommunityMembers",e);const n=null!=e?e:{},{page:r,communityId:o}=n,i=Zi(n,["page","communityId"]),{data:s}=await t.http.get(`/api/v3/communities/${o}/users`,{params:Object.assign(Object.assign({},i),{options:{token:B(r,"skiplimit")}})}),{paging:a}=s,c=Zi(s,["paging"]),{communityUsers:l}=c,u=t.cache&&Date.now();t.cache&&Qi(c,{cachedAt:u});return{data:l,cachedAt:u,nextPage:j(a.next),prevPage:j(a.previous)}};Cs.locally=e=>{X().log("community/queryCommunityMembers",e)};const Ss=async e=>{const t=X();t.log("channel/getTopTrendingCommunities",e);const{limit:n=5}=null!=e?e:{},{data:r}=await t.http.get("/api/v3/communities/top-trending",{params:{options:{limit:n}}}),{communities:o}=r,i=t.cache&&Date.now();if(t.cache){Qi(r,{cachedAt:i});Hi(["community","top-trending",{params:{options:{limit:n}}}],{communities:o.map(Ji("community"))})}return{data:o,cachedAt:i}};Ss.locally=e=>{var t,n;const r=X();if(r.log("community/getTopTrendingCommunities.locally",e),!r.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","top-trending",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=$i(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>$i(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(n=null==s?void 0:s.communities)||void 0===n?void 0:n.length)?{data:c,cachedAt:a}:void 0};const ks=async e=>{const t=X();t.log("channel/getRecommendedCommunities",e);const{limit:n=5}=null!=e?e:{},{data:r}=await t.http.get("/api/v3/communities/recommended",{params:{options:{limit:n}}}),{communities:o}=r,i=t.cache&&Date.now();if(t.cache){Qi(r,{cachedAt:i});Hi(["community","recommended",{params:{options:{limit:n}}}],{communities:o.map(Ji("community"))})}return{data:o,cachedAt:i}};ks.locally=e=>{var t,n;const r=X();if(r.log("community/getRecommendedCommunities.locally",e),!r.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","recommended",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=$i(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>$i(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(n=null==s?void 0:s.communities)||void 0===n?void 0:n.length)?{data:c,cachedAt:a}:void 0};const As=async e=>{const t=X();t.log("comment/queryComments",e);const{page:n={limit:10}}=e,r=Zi(e,["page"]),{data:o}=await t.http.get("/api/v3/comments",{params:Object.assign(Object.assign({},r),{options:{token:B(n,"afterbefore")}})}),{paging:i}=o,s=Zi(o,["paging"]),{comments:a}=s,c=t.cache&&Date.now();if(t.cache){Qi(s,{cachedAt:c});const e=["comment","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];Hi(e,{comments:a.map(Ji("comment")),paging:i})}const l=j(i.next);return{data:a,cachedAt:c,prevPage:j(i.previous),nextPage:l}};As.locally=e=>{var t,n;const r=X();if(r.log("comment/queryComments.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Zi(e,["page"]),s=["comment","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=$i(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.comments.length))return;const l=a.comments.map((e=>$i(["comment","get",e]))).filter(Boolean).map((({data:e})=>e)),u=j(null==a?void 0:a.paging.previous),h=j(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.comments)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const Es=async e=>{const t=X();t.log("comment/getComments",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/comments/list",{params:{commentIds:n}}),o=t.cache&&Date.now();return t.cache&&Qi(r,{cachedAt:o}),{data:r.comments,cachedAt:o}};Es.locally=e=>{var t;const n=X();if(n.log("comment/getComments.locally",e),!n.cache)return;const r=e.map((e=>$i(["comment","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Is=async e=>{var t;const n=X();let r;n.log("comment/getComment",e);try{r=(await n.http.get(`/api/v3/comments/${encodeURIComponent(e)}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&zi(["comment","get",e],!0),n}const o=n.cache&&Date.now();n.cache&&Qi(r,{cachedAt:o});const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}};Is.locally=e=>{const t=X();if(t.log("comment/getComment.locally",e),!t.cache)return;const n=$i(["comment","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const xs=async(e,t)=>{if("message"===e)return us(t);if("post"===e)return vs(t);if("comment"===e)return Is(t);throw new Error(`Incorrect referenceType: ${e}`)},Rs=(e,t)=>{var n,r;if(X().userId!==t.reactor.userId)return;let o,i;if("post.addReaction"===e||"post.removeReaction"===e){const e=t.posts[0];i=null===(n=$i(["post","get",e.postId]))||void 0===n?void 0:n.data,o=e}else{const e=t.comments[0];i=null===(r=$i(["comment","get",e.commentId]))||void 0===r?void 0:r.data,o=e}if(i&&i.myReactions)if("post.addReaction"===e||"comment.addReaction"===e){if(i.myReactions.includes(t.reactor.reactionName))return;Object.assign(o,{myReactions:[...i.myReactions,t.reactor.reactionName]})}else{if(!i.myReactions.includes(t.reactor.reactionName))return;Object.assign(o,{myReactions:i.myReactions.filter((e=>e!==t.reactor.reactionName))})}},Os=async(e,t,n)=>{var r,o;const i=X();i.log("reaction/createReaction",{referenceId:t,referenceType:e,reactionName:n}),await i.http.post("/api/v2/reactions",{referenceId:t,referenceType:e,reactionName:n});const s=await xs(e,t);return ls(e,s.data),null!==(o=null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n))&&void 0!==o&&o};Os.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=X();if(c.log("reaction/createReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const l=$i([e,"get",t]);if(!(null==l?void 0:l.data)||(null===(r=l.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:l.data.reactionsCount+1,myReactions:[...null!==(o=l.data.myReactions)&&void 0!==o?o:[],n],reactions:Object.assign(Object.assign({},l.data.reactions),{[n]:(null!==(i=l.data.reactions[n])&&void 0!==i?i:0)+1})});return Wi([e,"get",t],u,{cachedAt:-1}),ls(e,u),null!==(a=null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(n))&&void 0!==a&&a};const Fs=async(e,t,n)=>{var r,o;const i=X();i.log("reaction/removeReaction",{referenceId:t,referenceType:e,reactionName:n}),await i.http.delete("/api/v2/reactions",{data:{referenceId:t,referenceType:e,reactionName:n}});const s=await xs(e,t);return ls(e,s.data),null!==(o=!(null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n)))&&void 0!==o&&o};Fs.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=X();if(c.log("reaction/removeReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const l=$i([e,"get",t]);if(!(null==l?void 0:l.data)||!(null===(r=l.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:Math.max(0,l.data.reactionsCount-1),myReactions:(null!==(o=l.data.myReactions)&&void 0!==o?o:[]).filter((e=>e!==n)),reactions:Object.assign(Object.assign({},l.data.reactions),{[n]:Math.max(0,(null!==(i=l.data.reactions[n])&&void 0!==i?i:0)-1)})});return Wi([e,"get",t],u,{cachedAt:-1}),ls(e,u),null!==(a=!(null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(n)))&&void 0!==a&&a};const Ts=(e,t)=>{const n=X();return hi(n,e,e,(r=>{var o;if(n.cache){const{communities:n}=r,i=Zi(r,["communities"]);Qi(i),(null==n?void 0:n[0])&&!["post.updated"].includes(e)&&pi("community.updated",{communities:n});const s=$i(["post","get",r.posts[0].postId]);if(["post.created","post.approved","post.declined"].includes(e)){let t=null===(o=qi(["post","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.targetId)===s.data.targetId}));"post.declined"===e&&(t=null==t?void 0:t.filter((({key:e})=>{var t;return"reviewing"===(null===(t=e[2])||void 0===t?void 0:t.feedType)}))),null==t||t.map((({key:e,data:t})=>Wi(e,t,{cachedAt:-1})))}t(s.data)}else t(r.posts[0])}))},Ps=e=>Ts("post.created",e),Bs=e=>Ts("post.updated",e),js=e=>Ts("post.deleted",e),Us=e=>Ts("post.approved",e),Ms=e=>Ts("post.declined",e),Ns=e=>Ts("post.flagged",e),Ls=e=>Ts("post.unflagged",e),Ds=e=>{const t=X();return hi(t,"post.addReaction","post.addReaction",(n=>{if(t.cache){Rs("post.addReaction",n);const t=Zi(n,["reactor"]);Qi(t);const r=$i(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},qs=e=>{const t=X();return hi(t,"post.removeReaction","post.removeReaction",(n=>{if(t.cache){Rs("post.removeReaction",n);const t=Zi(n,["reactor"]);Qi(t);const r=$i(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},$s=(e,t)=>{const n=X();return hi(n,e,e,(r=>{var o;if(n.cache){Qi(r);const n=$i(["comment","get",r.comments[0].commentId]);if(["comment.created"].includes(e)){const e=null===(o=qi(["comment","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.referenceId)===n.data.referenceId}));null==e||e.map((({key:e,data:t})=>Wi(e,t,{cachedAt:-1})))}t(n.data)}else t(r.comments[0])}))},Hs=e=>$s("comment.created",e),Vs=e=>$s("comment.updated",e),Ws=e=>$s("comment.deleted",e),zs=e=>$s("comment.flagged",e),Ks=e=>$s("comment.unflagged",e),Js=e=>{const t=X();return hi(t,"comment.addReaction","comment.addReaction",(n=>{if(t.cache){Rs("comment.addReaction",n);const t=Zi(n,["reactor"]);Qi(t);const r=$i(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))},Ys=e=>{const t=X();return hi(t,"comment.removeReaction","comment.removeReaction",(n=>{if(t.cache){Rs("comment.removeReaction",n);const t=Zi(n,["reactor"]);Qi(t);const r=$i(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))};var Qs={post:{domainName:"posts",eventName:"v3/post.isflagbyme",primaryKey:"postId"},comment:{domainName:"comments",eventName:"v3/comment.isflagbyme",primaryKey:"commentId"},message:{domainName:"messages",eventName:"v3/message.isFlaggedByMe",primaryKey:"messageId"},user:{domainName:"users",eventName:"user.isFlagByMe",primaryKey:"userId"}};const Xs=async e=>{const t=X();t.log("channel/queryChannels",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,membership:i}=n,s=Zi(n,["page","displayName","membership"]),{data:a}=await t.http.get("/api/v3/channels",{params:Object.assign(Object.assign({},s),{keyword:o,filter:i,options:{token:B(r,"skiplimit")}})}),{paging:c}=a,l=Zi(a,["paging"]),{channels:u}=l,h=t.cache&&Date.now();if(t.cache){Qi(l,{cachedAt:h});const e=["channel","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];Hi(e,{channels:u.map(Ji("channel")),paging:c})}const p=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:p}};Xs.locally=e=>{X().log("channel/queryChannels.locally",e)};const Gs=async e=>{const t=X();t.log("channel/getChannels",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/channels/list",{params:{channelIds:n}}),o=t.cache&&Date.now();return t.cache&&Qi(r,{cachedAt:o}),{data:r.channels,cachedAt:o}};Gs.locally=e=>{var t;const n=X();if(n.log("channel/getChannels.locally",e),!n.cache)return;const r=e.map((e=>$i(["channel","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Zs=async e=>{const t=X();t.log("channel/getChannel",e);const{data:n}=await t.http.get(`/api/v3/channels/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r});const{channels:o}=n;return{data:o.find((t=>t.channelId===e)),cachedAt:r}};Zs.locally=e=>{const t=X();if(t.log("channel/getChannel.locally",e),!t.cache)return;const n=$i(["channel","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const ea=async e=>{const t=X();t.log("channel/queryChannelMembers",e);const n=null!=e?e:{},{page:r,channelId:o,membership:i}=n,s=Zi(n,["page","channelId","membership"]),{data:a}=await t.http.get(`/api/v3/channels/${encodeURIComponent(o)}/users`,{params:Object.assign(Object.assign({},s),{filter:i,options:{token:B(r,"skiplimit")}})}),{paging:c}=a,l=Zi(a,["paging"]),{channelUsers:u}=l,h=t.cache&&Date.now();t.cache&&Qi(l);return{data:u,cachedAt:h,nextPage:j(c.next),prevPage:j(c.previous)}};ea.locally=e=>{X().log("channel/queryChannelMembers",e)};const ta=e=>{const t=X();return hi(t,"onChannelUpdated","v3.channel.didUpdate",(t=>{Qi(t),e(t.channels[0])}))},na=e=>{const t=X();return hi(t,"onChannelDeleted","v3.channel.didDelete",(t=>{Qi(t),e(t.channels[0])}))},ra=e=>{const t=X();return hi(t,"onChannelJoined","v3.channel.didJoin",(t=>{Qi(t),e(t.channels[0])}))},oa=e=>{const t=X();return hi(t,"onChannelLeft","v3.channel.didLeave",(t=>{Qi(t),e(t.channels[0])}))},ia=e=>{const t=X();return hi(t,"onMemberAdded","v3.channel.didAddUsers",(t=>{Qi(t),e(t.channels[0])}))},sa=e=>{const t=X();return hi(t,"onMemberRemoved","v3.channel.didRemoveUsers",(t=>{Qi(t),e(t.channels[0])}))},aa=e=>{const t=X();return hi(t,"message/onMessageCreated","v3.message.didCreate",(t=>{Qi(t),e(t.messages[0])}))},ca=e=>{const t=X();return hi(t,"message/onMessageUpdated","v3.message.didUpdate",(t=>{Qi(t),e(t.messages[0])}))},la=e=>{const t=X();return hi(t,"message/onMessageDeleted","v3.message.didDelete",(t=>{Qi(t),e(t.messages[0])}))},ua=(e,t)=>{const n=X();return hi(n,e,e,(e=>{if(n.cache){Qi(e);const n=$i(["community","get",e.communities[0].communityId]);t(n.data)}else t(e.communities[0])}))};function ha(e,t,n){return!!e.permissions.some((e=>e===n))||t.users.find((t=>t.userId===e.userId)).permissions.some((e=>e===n))}function pa(e,t){return"community.joined"===e||"community.left"===e?t.communityUsers[0]:"community.userRemoved"===e?t.communityUsers.filter((e=>"none"===e.communityMembership))[0]:"community.userBanned"===e?t.communityUsers.filter((e=>"banned"===e.communityMembership))[0]:"community.userUnbanned"===e?t.communityUsers.filter((e=>!ha(e,t,"BAN_COMMUNITY_USER")))[0]:t.communityUsers.filter((e=>!ha(e,t,"ADD_COMMUNITY_USER")))[0]}const fa=(e,t)=>{const n=X();return hi(n,e,e,(r=>{if(n.cache){Qi(r);const n=$i(["community","get",r.communities[0].communityId]),o=$i(["communityUsers","get",Ji("communityUsers")(pa(e,r))]);t(n.data,o.data)}else t(r.communities[0],pa(e,r))}))},da=e=>ua("community.updated",e),ma=e=>ua("community.deleted",e),ga=e=>fa("community.joined",e),ya=e=>fa("community.left",e),va=e=>fa("community.userAdded",e),ba=e=>fa("community.userRemoved",e),wa=e=>fa("community.userBanned",e),_a=e=>fa("community.userUnbanned",e),Ca=async e=>{const t=X();t.log("feed/queryGlobalFeed",e);const n=null!=e?e:{},{useCustomRanking:r,page:o}=n,i=Zi(n,["useCustomRanking","page"]),{data:s}=await t.http.get(r?"/api/v5/me/global-feeds":"/api/v4/me/global-feeds",{params:Object.assign(Object.assign({},i),{options:{token:B(o,"skiplimit")}})}),{paging:a}=s,c=Zi(s,["paging"]),{posts:l}=c,u=t.cache&&Date.now();if(t.cache){Qi(c);const e=["globalFeed","query",Object.assign(Object.assign({},i),{useCustomRanking:r,options:Object.assign({},o)})];Hi(e,{posts:l.map(Ji("post")),paging:a})}const h=j(a.next);return{data:l,cachedAt:u,prevPage:j(a.previous),nextPage:h}};Ca.locally=e=>{var t,n;const r=X();if(r.log("post/queryGlobalFeed.locally",e),!r.cache)return;const o=null!=e?e:{},{useCustomRanking:i,page:s}=o,a=Zi(o,["useCustomRanking","page"]),c=["globalFeed","query",Object.assign(Object.assign({},a),{useCustomRanking:i,options:Object.assign({},s)})],{data:l,cachedAt:u}=null!==(t=$i(c))&&void 0!==t?t:{};if(!(null==l?void 0:l.posts.length))return;const h=l.posts.map((e=>$i(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),p=j(null==l?void 0:l.paging.previous),f=j(null==l?void 0:l.paging.next);return h.length===(null===(n=null==l?void 0:l.posts)||void 0===n?void 0:n.length)?{data:h,cachedAt:u,prevPage:p,nextPage:f}:void 0};const Sa=async(e,t)=>{const n=X();n.log(`follow/queryF${e.substring(1)}`,t);const{userId:r,page:o}=t,i=Zi(t,["userId","page"]),{data:s}=await n.http.get(n.userId===r?`/api/v4/me/${e}`:`/api/v4/users/${r}/${e}`,{params:Object.assign(Object.assign({},i),{token:B(o,"skiplimit")})}),{paging:a}=s,c=Zi(s,["paging"]),{follows:l}=c,u=n.cache&&Date.now();if(n.cache){Qi(c,{cachedAt:u});const t=[e,"query",Object.assign(Object.assign({},i),{userId:r,options:Object.assign({},o)})];Hi(t,{follows:l.map(Ji("follow")),paging:a})}const h=j(a.next);return{data:l,cachedAt:u,prevPage:j(a.previous),nextPage:h}};Sa.locally=(e,t)=>{var n,r;const o=X();if(o.log(`follow/queryF${e.substring(1)}.locally`,t),!o.cache)return;const{page:i}=t,s=Zi(t,["page"]),a=[e,"query",Object.assign(Object.assign({},s),{options:Object.assign({},i)})],{data:c,cachedAt:l}=null!==(n=$i(a))&&void 0!==n?n:{};if(!(null==c?void 0:c.follows.length))return;const u=c.follows.map((e=>$i(["follow","get",e]))).filter(Boolean).map((({data:e})=>e)),h=j(null==c?void 0:c.paging.previous),p=j(null==c?void 0:c.paging.next);return u.length===(null===(r=null==c?void 0:c.follows)||void 0===r?void 0:r.length)?{data:u,cachedAt:l,prevPage:h,nextPage:p}:void 0};const ka=async e=>Sa("followers",e);ka.locally=e=>Sa.locally("followers",e);const Aa=async e=>Sa("following",e);Aa.locally=e=>Sa.locally("following",e);const Ea=e=>["followInfo","get",`${X().userId}#${e}`],Ia=async e=>{var t,n;const r=X();r.log("follow/getFollowInfo",e);const{data:o}=await r.http.get(r.userId===e?"/api/v4/me/followInfo":`/api/v4/users/${e}/followInfo`),i=r.cache&&Date.now(),s=Object.assign(Object.assign({},o.followCounts[0]),{status:null===(n=null===(t=o.follows)||void 0===t?void 0:t[0])||void 0===n?void 0:n.status});return r.cache&&Hi(Ea(e),s,{cachedAt:i}),{data:s,cachedAt:i}};Ia.locally=e=>{const t=X();if(t.log("follow/getFollowInfo.locally",e),!t.cache)return;const n=$i(Ea(e));return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const xa=(e,t)=>{const n=X();return hi(n,e,e,(e=>{var r,o;if(n.cache){Qi({follows:[e]});[...null!==(r=qi(["followers","query"]))&&void 0!==r?r:[],...null!==(o=qi(["followings","query"]))&&void 0!==o?o:[]].filter((({key:t})=>t[2].userId===e.from||t[2].userId===e.to)).forEach((({key:e,data:t})=>Wi(e,t,{cachedAt:-1}))),t(e)}else t(e)}))},Ra=e=>xa("follow.created",e),Oa=e=>xa("follow.unfollowed",e),Fa=e=>xa("follow.followerDeleted",e),Ta=e=>xa("follow.requested",e),Pa=e=>xa("follow.requestCanceled",e),Ba=e=>xa("follow.accepted",e),ja=e=>xa("follow.requestDeclined",e),Ua=e=>{const t=async t=>{const[{data:n},{data:r}]=await Promise.all([Ia(t.from),Ia(t.to)]);e(n),e(r)},n=[xa("follow.created",t),xa("follow.requested",t),xa("follow.accepted",t),xa("follow.unfollowed",t),xa("follow.requestCanceled",t),xa("follow.requestDeclined",t),xa("follow.followerDeleted",t)];return()=>{n.forEach((e=>e()))}},Ma=async e=>{const t=X();t.log("stream/getStream",e);const{data:n}=await t.http.get(`/api/v3/video-streaming/${e}`),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}};Ma.locally=e=>{const t=X();if(t.log("stream/getStream",e),!t.cache)return;const n=$i(["stream","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Na=async e=>{const t=X();t.log("stream/queryStreams",e);const n=null!=e?e:{},{page:r}=n,o=Zi(n,["page"]),{data:i}=await t.http.get("/api/v3/video-streaming",{params:Object.assign(Object.assign({},o),{options:{token:B(r,"skiplimit")}})}),{paging:s,results:a}=i,{videoStreamings:c}=a,l=t.cache&&Date.now();t.cache&&Qi(a,{cachedAt:l});const u=j(s.next);return{data:c,cachedAt:l,prevPage:j(s.previous),nextPage:u}};Na.locally=e=>{X().log("stream/queryStreams.locally",e)};return e.API_REGIONS=fe,e.VERSION=a,e.acceptFollower=async e=>{const t=X();t.log("follow/acceptFollower",e);const{data:n}=await t.http.post(`/api/v4/me/followers/${e}`);return t.cache&&Qi(n),pi("follow.accepted",n.follows[0]),!0},e.addChannelMembers=async(e,t)=>{const n=X();n.log("channel/addChannelMembers",e,t);const{data:r}=await n.http.post(`/api/v3/channels/${encodeURIComponent(e)}/users`,{channelId:e,userIds:t});n.cache&&Qi(r),pi("v3.channel.didAddUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"===t.membership))},e.addChannelMembersRole=async(e,t,n)=>{const r=X();r.log("channel/addChannelMembersRole",e,t,n);const{data:o}=await r.http.post(`/api/v3/channels/${encodeURIComponent(e)}/users/roles`,{channelId:e,role:t,userIds:n});r.cache&&Qi(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&n.roles.includes(t)))},e.addCommunityMembers=async(e,t)=>{const n=X();n.log("community/addCommunityMembers",e,t);const{data:r}=await n.http.post(`/api/v3/communities/${e}/users`,{communityId:e,userIds:t});n.cache&&Qi(r),pi("community.userAdded",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.addCommunityMembersRoles=async(e,t,n)=>{const r=X();r.log("community/addCommunityMembersRoles",e,t,n);const{data:o}=await r.http.post(`/api/v4/communities/${e}/users/roles`,{communityId:e,roles:t,userIds:n});r.cache&&Qi(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&t.some((e=>n.roles.includes(e)))))},e.addReaction=Os,e.backupCache=async(e="amitySdk",t=(e=>e.offline))=>{const{log:n,cache:r,userId:o}=X();if(!r)return!1;n("cache/api/backupCache",{storageKey:e});const i=Object.fromEntries(Object.entries(r.data).filter((([e,n])=>t(n))));return!!Object.keys(i).length&&(await Mi.setItem(`${e}#${o}`,JSON.stringify(i)),!0)},e.connectClient=async e=>{var t,n;const r=X();r.log("client/api/connectClient",Object.assign({apiKey:r.apiKey},e)),null!==(t=e.displayName)&&void 0!==t||(e.displayName=e.userId),null!==(n=e.deviceId)&&void 0!==n||(e.deviceId=`ascWebSdk#${Math.random().toString(16)}`);const{accessToken:o,users:i}=await(async e=>{const t=X();t.log("client/api/getToken",e);const n=await di(),{data:r}=await t.http.post("/v1/device",Object.assign(Object.assign({},e),{deviceInfo:n}),{headers:{"X-API-Key":t.apiKey}});return r})(e);var s,a;r.http.defaults.headers.common.Authorization=`Bearer ${o}`,r.ws.io.opts.query={token:o},s=r.ws,a=r.emitter,ci.forEach((e=>{s.on(e,(t=>a.emit(e,t)))})),await new Promise((e=>{r.ws.once("connect",e),r.ws.open()}));const c=bi((()=>{fi(),c()}));var l;return r.userId=e.userId,r.accessToken=o,l=i[0],mi={_id:l._id,userId:l.userId,path:l.path},r.ws.connected},e.createChannel=async e=>{const t=X();let n;t.log("user/createChannel",e),n="conversation"===(null==e?void 0:e.type)?await t.http.post("/api/v3/channels/conversation",Object.assign(Object.assign({},e),{isDistinct:!0})):await t.http.post("/api/v3/channels",e);const r=t.cache&&Date.now();t.cache&&Qi(n.data,{cachedAt:r});const{channels:o}=n.data;return{data:o[0],cachedAt:r}},e.createClient=(e,t=fe.SG,n="amity")=>{const r=(e=>{const t=`${null==e?void 0:e.trim()}`.length>0&&!o,n=pe(e),r=(e,...r)=>{t&&n(e,r)};return r.__instance__=n,r})(n);r("client/api/createClient",{apiKey:e.replace(/.{5}$/g,"xxxxx"),apiRegion:t});const i=(e=>{const t={maxSockets:100,maxFreeSockets:10,timeout:6e4,freeSocketTimeout:3e4},n=Bt.create({baseURL:e,httpAgent:new Nt(t),httpsAgent:new Ut(t),paramsSerializer:Dt});return n.interceptors.response.use((e=>e),(e=>{var t;const{response:n}=e;console.error(null!==(t=null==n?void 0:n.data)&&void 0!==t?t:e),n&&Lt(n.data)})),n})(me("http",t)),s=(e=>{const t=ti(e,{autoConnect:!1,reconnectionDelay:2e3,transports:["websocket"]});return t.on("disconnect",(e=>{"io server disconnect"===e&&t.connect()})),t})(me("http",t)),c=ii(me("mqtt",t)),l=ui(),u={version:`${a}`,apiKey:e,log:r,http:i,ws:s,mqtt:c,emitter:l,use:()=>G(u)};try{X()}catch(e){G(u)}return u},e.createComment=async e=>{const t=X();t.log("comment/createComment",e);const{data:n}=await t.http.post("/api/v3/comments",e),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r});const o=await vs(e.referenceId);pi("post.updated",{posts:[o.data]}),pi("comment.created",n);const{comments:i}=n;return{data:i[0],cachedAt:r}},e.createCommunity=async e=>{const t=X();t.log("user/createCommunity",e);const{data:n}=await t.http.post("/api/v3/communities/",e),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r}),pi("community.created",n);const{communities:o}=n;return{data:o[0],cachedAt:r}},e.createFile=async(e,t)=>{const n=X();if(n.log("file/createFile",e),!e.getAll("file").length)throw new Error("The formData object must have a `file` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v3/files",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&Qi({files:o},{cachedAt:i}),{data:o[0],cachedAt:i}},e.createMessage=fs,e.createPost=async e=>{const t=X();t.log("post/createPost",e),e.dataType&&!["text","image","file","video"].includes(e.dataType)||delete e.dataType;const{data:n}=await t.http.post("/api/v4/posts",e),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r}),pi("post.created",n);const{posts:o}=n;return{data:o[0],cachedAt:r}},e.createQuery=$,e.createReport=async(e,t)=>{const n=X();n.log("report/createReport",{referenceType:e,referenceId:t});const{domainName:r}=Qs[e],{data:o}=await n.http.post(`/api/v3/${r}/${encodeURIComponent(t)}/flag`);n.cache&&Qi(o);return pi("message"===e?"v3.message.didUpdate":`${e}.flagged`,o),!!o},e.createStream=async e=>{const t=X();t.log("stream/createStream",e);const{data:n}=await t.http.post("/api/v3/video-streaming",e),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o[0],cachedAt:r}},e.createVideo=async(e,t)=>{const n=X();if(n.log("file/createVideo",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/videos",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&Qi({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.declineFollower=async e=>{const t=X();t.log("follow/declineFollower",e);const{data:n}=await t.http.delete(`/api/v4/me/followers/${e}`);return t.cache&&Qi(n),pi("follow.requestDeclined",n.follows[0]),!0},e.deleteChannel=async e=>{const t=X();t.log("channel/deleteChannel",e),await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}`);return(await Zs(e)).data},e.deleteComment=async(e,t=!1)=>{const n=X();n.log("comment/deleteComment",e);const r=await Is(e);await n.http.delete(`/api/v4/comments/${encodeURIComponent(e)}`,{params:{commentId:e,permanent:t}});const o=Object.assign(Object.assign({},r.data),{isDeleted:!0}),i=await vs(r.data.referenceId);return pi("post.updated",{posts:[i.data]}),pi("comment.deleted",{comments:[o]}),t?setTimeout((()=>{zi(["comment","get",e],!0)}),0):Wi(["comment","get",e],{isDeleted:!0}),o},e.deleteCommunity=async e=>{const t=X();t.log("community/deleteCommunity",e),await t.http.delete(`/api/v3/communities/${e}`);const n=await _s(e);return pi("community.deleted",{communities:[n.data]}),n.data},e.deleteFile=async e=>{const t=X();return t.log("file/deleteFile",e),await t.http.delete(`/api/v3/files/${e}`),zi(["file","get",e],!0),{success:!0}},e.deleteMessage=ms,e.deletePost=async(e,t=!1)=>{const n=X();n.log("post/deletePost",e);const r=await vs(e);if(await n.http.delete(`/api/v4/posts/${encodeURIComponent(e)}`,{params:{postId:e,permanent:t}}),"community"===r.data.targetType){const e=await _s(r.data.targetId);pi("community.updated",{communities:[e.data]})}const o=Object.assign(Object.assign({},r.data),{isDeleted:!0});return pi("post.deleted",{posts:[o]}),t?setTimeout((()=>{zi(["post","get",e],!0)}),0):Wi(["post","get",e],{isDeleted:!0}),o},e.deleteReport=async(e,t)=>{const n=X();n.log("report/deleteReport",{referenceType:e,referenceId:t});const{domainName:r}=Qs[e],{data:o}=await n.http.delete(`/api/v3/${r}/${encodeURIComponent(t)}/unflag`);n.cache&&Qi(o);return pi("message"===e?"v3.message.didUpdate":`${e}.unflagged`,o),!!o},e.deleteStream=async e=>{const t=X();t.log("stream/deleteStream",e);const n=await Ma(e),{data:r}=await t.http.delete(`/api/v3/video-streaming/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return Wi(["stream","get",e],i),o},e.disableCache=()=>{const e=X();e.cache&&(e.log("cache/api/disableCache"),delete e.cache)},e.disconnectClient=fi,e.disposeStream=async e=>{const t=X();t.log("stream/disposeStream",e);const{data:n}=await t.http.delete(`/api/v3/video-streaming/${e}/streaming-url`),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}},e.dropFromCache=zi,e.enableCache=(e={},t)=>{const n=X();n.cache||(n.log("cache/api/enableCache"),n.cache={data:e,persistIf:t})},e.fileUrlWithSize=(e,t)=>`${e}?size=${t}`,e.filterByPropEquality=(e,t,n)=>void 0!==n?e.filter((e=>e[t]===n)):e,e.follow=async e=>{const t=X();t.log("follow/follow",e);const{data:n}=await t.http.post(`/api/v4/me/following/${e}`),r=t.cache&&Date.now();return t.cache&&Qi(n,{cachedAt:r}),pi("accepted"===n.follows[0].status?"follow.created":"follow.requested",n.follows[0]),{data:n.follows[0],cachedAt:r}},e.getActiveClient=X,e.getChannel=Zs,e.getChannels=Gs,e.getComment=Is,e.getCommentTopic=({path:e})=>e,e.getComments=Es,e.getCommunities=ws,e.getCommunity=_s,e.getCommunityTopic=({path:t},n=e.SubscriptionLevels.COMMUNITY)=>_i(t,n),e.getFile=ss,e.getFollowInfo=Ia,e.getMessage=us,e.getMessages=hs,e.getMyFollowersTopic=()=>{const e=gi(),[t]=e.path.split("/user/");return`${t}/membership/${e._id}/+/+`},e.getMyFollowingsTopic=()=>{const e=gi(),[t]=e.path.split("/user/");return`${t}/membership/+/${e._id}/+`},e.getPost=vs,e.getPostTopic=({path:t},n=e.SubscriptionLevels.POST)=>"comment"===n?`${t}/comment/+`:t,e.getPosts=ys,e.getRecommendedCommunities=ks,e.getRole=cs,e.getStream=Ma,e.getTopTrendingCommunities=Ss,e.getUser=Xi,e.getUserTopic=({path:t},n=e.SubscriptionLevels.USER)=>_i(n===e.SubscriptionLevels.USER?t:t.replace(/^(?<networkId>\w*)/,"$<networkId>/social"),n),e.getUsers=Gi,e.isAfterBefore=F,e.isAfterBeforeRaw=T,e.isCachable=D,e.isConnected=()=>{var e,t;const n=X();return n.log("client/api/isConnected",n),!!(n.userId&&(null===(t=null===(e=n.http.defaults.headers.common)||void 0===e?void 0:e.Authorization)||void 0===t?void 0:t.length)&&n.ws.connected)},e.isFetcher=M,e.isFresh=q,e.isLocal=e=>D(e)&&-1===(null==e?void 0:e.cachedAt),e.isMutator=N,e.isOffline=L,e.isPaged=P,e.isReportedByMe=async(e,t)=>{var n,r;const o=X();o.log("report/isReportedByMe",{referenceType:e,referenceId:t});const{eventName:i,primaryKey:s}=Qs[e],{result:a,isFlagByMe:c}=null!==(n=await(async(e,t,n)=>{const{ws:r}=e;return await new Promise(((e,o)=>{r.emit(t,n,(t=>{try{e(Lt(t))}catch(e){o(e)}}))}))})(o,i,{[s]:t}))&&void 0!==n?n:{};return null!==(r=null!=a?a:c)&&void 0!==r&&r},e.isSkipLimit=O,e.joinChannel=async e=>{const t=X();t.log("channel/joinChannel",e);const{data:n}=await t.http.post(`/api/v3/channels/${encodeURIComponent(e)}/join`);t.cache&&Qi(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"===t.membership))},e.joinCommunity=async e=>{const t=X();t.log("community/joinCommunity",e);const{data:n}=await t.http.post(`/api/v3/communities/${e}/join`),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r}),pi("community.joined",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.leaveChannel=async e=>{const t=X();t.log("channel/leaveChannel",e);const{data:n}=await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/leave`);t.cache&&Qi(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"!==t.membership))},e.leaveCommunity=async e=>{const t=X();t.log("community/leaveCommunity",e);const{data:n}=await t.http.delete(`/api/v3/communities/${e}/leave`),r=t.cache&&Date.now();t.cache&&Qi(n,{cachedAt:r}),pi("community.left",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.mergeInCache=Vi,e.observeChannel=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeChannel(tmpid: ${r}) > listen`);const o=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.channelId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}},i=[];return i.push(ta((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),na((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),ra((e=>o({data:e,loading:!1,origin:"event"},"onJoin"))),oa((e=>o({data:e,loading:!1,origin:"event"},"onLeft"))),ia((e=>o({data:e,loading:!1,origin:"event"},"onMemberAdded"))),sa((e=>o({data:e,loading:!1,origin:"event"},"onMemberRemoved")))),V($(Zs,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeChannel(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.observeComment=(e,t,n="cache_then_server")=>{const{log:r}=X(),o=Date.now();r(`observeComment(tmpid: ${o}) > listen`);const i=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},s=(t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.commentId)===e&&i(t,n)},a=[];return a.push(Vs((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),Ws((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),zs((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),Ks((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),Js((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),Ys((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),V($(Is,e),(e=>(e.data||e.error)&&i(e,"onFetch")),H(n)),()=>{r(`observeComment(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observeComments=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeComments(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.referenceId===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Hs((e=>i(e,"onCreate"))),Vs((e=>i(e,"onUpdate"))),Ws((e=>i(e,"onDelete"))),zs((e=>i(e,"onFlagged"))),Ks((e=>i(e,"onUnflagged"))),Js((e=>i(e,"onReactionAdded"))),Ys((e=>i(e,"onReactionRemoved")))),()=>{n(`observeComments(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeCommunity=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeCommunity(tmpid: ${r}) > listen`);const o=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},i=(t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.communityId)===e&&o(t,n)},s=[];return s.push(da((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),ma((e=>i({data:e,loading:!1,origin:"event"},"onDelete"))),ga((e=>i({data:e,loading:!1,origin:"event"},"onJoin"))),ya((e=>i({data:e,loading:!1,origin:"event"},"onLeft"))),va((e=>i({data:e,loading:!1,origin:"event"},"onUserAdded"))),ba((e=>i({data:e,loading:!1,origin:"event"},"onUserRemoved"))),wa((e=>i({data:e,loading:!1,origin:"event"},"onUserBanned"))),_a((e=>i({data:e,loading:!1,origin:"event"},"onUserUnbanned")))),V($(_s,e),(e=>(e.data||e.error)&&o(e,"onFetch"))),()=>{n(`observeCommunity(tmpid: ${r}) > dispose`),s.forEach((e=>e()))}},e.observeFile=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeFile(tmpid: ${r}) > listen`);return V($(ss,e),(n=>n.data&&((n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.fileId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}})(n,"onFetch"))),()=>{n(`observeFile(tmpid: ${r}) > dispose`)}},e.observeFollowInfo=(e,t,n="cache_then_server")=>{const{log:r}=X(),o=Date.now();r(`observeFollowInfo(tmpid: ${o}) > listen`);const i=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},s=[];return s.push(Ua((t=>((t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.userId)===e&&i(t,n)})({data:t,loading:!1,origin:"event"},"onUpdate")))),V($(Ia,e),(e=>(e.data||e.error)&&i(e,"onFetch")),H(n)),()=>{r(`observeFollowInfo(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeFollowers=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeFollowers(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.from===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Ta((e=>i(e,"onRequested"))),Ba((e=>i(e,"onAccepted"))),ja((e=>i(e,"onDeclined"))),Pa((e=>i(e,"onCanceled"))),Ra((e=>i(e,"onFollowed"))),Oa((e=>i(e,"onUnfollowed"))),Fa((e=>i(e,"onDeleted")))),()=>{n(`observeFollowers(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeFollowings=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeFollowings(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.to===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Ta((e=>i(e,"onRequested"))),Ba((e=>i(e,"onAccepted"))),ja((e=>i(e,"onDeclined"))),Pa((e=>i(e,"onCanceled"))),Ra((e=>i(e,"onFollowed"))),Oa((e=>i(e,"onUnfollowed"))),Fa((e=>i(e,"onDeleted")))),()=>{n(`observeFollowings(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeMessage=(e,t,n="cache_then_server")=>{const{log:r}=X(),o=Date.now();r(`observeMessage(tmpid: ${o}) > listen`);const i=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.messageId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}},s=[];return s.push(ca((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),la((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),"no_fetch"!==n&&V($(us,e),(e=>e.data&&i(e,"onFetch")),H(n)),()=>{r(`observeMessages(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeMessages=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeMessages(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.channelId)===e){if(t instanceof Function)return t(n);null===(i=t.onEvent)||void 0===i||i.call(t,r,n),null===(s=t[r])||void 0===s||s.call(t,n)}};return o.push(aa((e=>i({data:e,loading:!1,origin:"event"},"onCreate"))),ca((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),la((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),()=>{n(`observeMessages(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observePost=(e,t,n="cache_then_server")=>{const{log:r}=X(),o=Date.now();r(`observePost(tmpid: ${o}) > listen`);const i=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},s=(t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.postId)===e&&i(t,n)},a=[];return a.push(Bs((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),js((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),Us((e=>s({data:e,loading:!1,origin:"event"},"onApproved"))),Ms((e=>s({data:e,loading:!1,origin:"event"},"onDeclined"))),Ns((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),Ls((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),Ds((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),qs((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),V($(vs,e),(e=>(e.data||e.error)&&i(e,"onFetch")),H(n)),()=>{r(`observePosts(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observePosts=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observePosts(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(e.targetId===n.targetId&&e.targetType===n.targetType){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Ps((e=>i(e,"onCreate"))),Bs((e=>i(e,"onUpdate"))),js((e=>i(e,"onDelete"))),Us((e=>i(e,"onApproved"))),Ms((e=>i(e,"onDeclined"))),Ns((e=>i(e,"onFlagged"))),Ls((e=>i(e,"onUnflagged"))),Ds((e=>i(e,"onReactionAdded"))),qs((e=>i(e,"onReactionRemoved")))),()=>{n(`observePosts(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeUser=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeUser(tmpid: ${r}) > listen`);const o=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.userId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}},i=[];return i.push(ns((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),rs((e=>o({data:e,loading:!1,origin:"event"},"onFlagged"))),os((e=>o({data:e,loading:!1,origin:"event"},"onUnflagged"))),is((e=>o({data:e,loading:!1,origin:"event"},"onFlagCleared")))),V($(Xi,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeUser(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.onChannelDeleted=na,e.onChannelJoined=ra,e.onChannelLeft=oa,e.onChannelUpdated=ta,e.onClientBanned=bi,e.onClientDisconnected=e=>vi((({code:t})=>{800211===t&&e()})),e.onCommentCreated=Hs,e.onCommentDeleted=Ws,e.onCommentFlagged=zs,e.onCommentReactionAdded=Js,e.onCommentReactionRemoved=Ys,e.onCommentUnflagged=Ks,e.onCommentUpdated=Vs,e.onCommunityCreated=e=>ua("community.created",e),e.onCommunityDeleted=ma,e.onCommunityJoined=ga,e.onCommunityLeft=ya,e.onCommunityUpdated=da,e.onCommunityUserAdded=va,e.onCommunityUserBanned=wa,e.onCommunityUserRemoved=ba,e.onCommunityUserUnbanned=_a,e.onConnectionError=vi,e.onFollowInfoUpdated=Ua,e.onFollowRequestAccepted=Ba,e.onFollowRequestCanceled=Pa,e.onFollowRequestDeclined=ja,e.onFollowerDeleted=Fa,e.onFollowerRequested=Ta,e.onMemberAdded=ia,e.onMemberRemoved=sa,e.onMessageCreated=aa,e.onMessageDeleted=la,e.onMessageUpdated=ca,e.onPostApproved=Us,e.onPostCreated=Ps,e.onPostDeclined=Ms,e.onPostDeleted=js,e.onPostFlagged=Ns,e.onPostReactionAdded=Ds,e.onPostReactionRemoved=qs,e.onPostUnflagged=Ls,e.onPostUpdated=Bs,e.onReactionRemoved=(e,t,n)=>{const r=r=>{Ji(e)(r)===t&&n(r)};if("message"===e){const e=X(),t=e=>{var t;const n=$i(["message","get",e.messages[0].messageId]),o=(null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.reactionsCount)!==e.messages[0].reactionsCount;Qi(e),o&&r(e.messages[0])};return hi(e,"reaction/onReactionRemoved","v3.message.didUpdate",t)}return"post"===e?qs(r):Ys(r)},e.onStreamRecorded=e=>{const t=X();return hi(t,"stream/onStreamRecorded","video-streaming.didRecord",(t=>{Qi(t),e(t.videoStreamings[0])}))},e.onStreamStarted=e=>{const t=X();return hi(t,"stream/onStreamStarted","video-streaming.didStart",(t=>{Qi(t),e(t.videoStreamings[0])}))},e.onStreamStopped=e=>{const t=X();return hi(t,"stream/onStreamStarted","video-streaming.didStop",(t=>{Qi(t),e(t.videoStreamings[0])}))},e.onUserFlagCleared=is,e.onUserFlagged=rs,e.onUserFollowed=Ra,e.onUserUnflagged=os,e.onUserUnfollowed=Oa,e.onUserUpdated=ns,e.pullFromCache=$i,e.pushToCache=Hi,e.queryCache=qi,e.queryChannelMembers=ea,e.queryChannels=Xs,e.queryComments=As,e.queryCommunities=bs,e.queryCommunityMembers=Cs,e.queryFollowers=ka,e.queryFollowings=Aa,e.queryGlobalFeed=Ca,e.queryMessages=ps,e.queryOptions=H,e.queryPosts=gs,e.queryRoles=as,e.queryStreams=Na,e.queryUsers=es,e.removeChannelMembers=async(e,t)=>{const n=X();n.log("channel/removeChannelMembers",e,t);const{data:r}=await n.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/users`,{data:{channelId:e,userIds:t}});n.cache&&Qi(r),pi("v3.channel.didRemoveUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"!==t.membership))},e.removeChannelMembersRole=async(e,t,n)=>{const r=X();r.log("channel/removeChannelMembersRole",e,t,n);const{data:o}=await r.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/users/roles`,{data:{channelId:e,role:t,userIds:n}});r.cache&&Qi(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&!n.roles.includes(t)))},e.removeCommunityMembers=async(e,t)=>{const n=X();n.log("community/removeCommunityMembers",e,t);const{data:r}=await n.http.delete(`/api/v3/communities/${e}/users`,{data:{communityId:e,userIds:t}});n.cache&&Qi(r),pi("community.userRemoved",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.removeCommunityMembersRoles=async(e,t,n)=>{const r=X();r.log("community/removeCommunityMembersRoles",e,t,n);const{data:o}=await r.http.delete(`/api/v4/communities/${e}/users/roles`,{data:{communityId:e,roles:t,userIds:n}});r.cache&&Qi(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&!t.some((e=>n.roles.includes(e)))))},e.removeReaction=Fs,e.restoreCache=async(e="amitySdk")=>{var t;const n=X();if(!n.cache)return!1;n.log("cache/api/restoreCache",{storageKey:e});const r=null!==(t=await Mi.getItem(`${e}#${n.userId}`))&&void 0!==t?t:"{}";let o={};try{o=JSON.parse(r)}catch(e){}return n.cache.data=Object.assign(Object.assign({},o),n.cache.data),!0},e.runQuery=V,e.sortByChannelSegment=({channelSegment:e},{channelSegment:t})=>e-t,e.sortByDisplayName=({displayName:e},{displayName:t})=>e===t?0:e<t?-1:1,e.sortByFirstCreated=({createdAt:e},{createdAt:t})=>new Date(e).valueOf()-new Date(t).valueOf(),e.sortByLastActivity=({lastActivity:e},{lastActivity:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortByLastCreated=({createdAt:e},{createdAt:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortBySegmentNumber=({segmentNumber:e},{segmentNumber:t})=>e-t,e.subscribeTopic=function(e,t){const{mqtt:n,emitter:r,accessToken:o}=X(),i=gi();return Ci===o&&Si===i._id||(Ci=o,Si=i._id,n.connect({accessToken:Ci,userId:Si}),((e,t)=>{li.forEach((n=>{e.on(n,((...e)=>t.emit(n,1===e.length?e[0]:e)))})),e.on("message",((e,n)=>{const r=JSON.parse(n.toString());t.emit(r.eventType,r.data)}))})(n,r)),n.subscribe(e,t)},e.toPage=j,e.toPageRaw=U,e.toToken=B,e.unfollow=async e=>{const t=X();t.log("follow/unfollow",e);const{data:n}=await t.http.delete(`/api/v4/me/following/${e}`);return t.cache&&Qi(n),pi("follow.unfollowed",n.follows[0]),!0},e.updateChannel=async(e,t)=>{const n=X();n.log("channel/updateChannel",e,t);const{data:r}=await n.http.put(`/api/v3/channels/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Qi(r,{cachedAt:o});const{channels:i}=r;return{data:i.find((t=>t.channelId===e)),cachedAt:o}},e.updateComment=async(e,t)=>{const n=X();n.log("user/updateComment",t);const{data:r}=await n.http.put(`/api/v3/comments/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Qi(r,{cachedAt:o}),pi("comment.updated",r);const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}},e.updateCommunity=async(e,t)=>{const n=X();n.log("community/updateCommunity",e,t);const{data:r}=await n.http.put(`/api/v3/communities/${e}`,t),o=n.cache&&Date.now();n.cache&&Qi(r,{cachedAt:o}),pi("community.updated",r);const{communities:i}=r;return{data:i.find((t=>t.communityId===e)),cachedAt:o}},e.updateMessage=ds,e.updatePost=async(e,t)=>{const n=X();n.log("user/updatePost",t);const{data:r}=await n.http.put(`/api/v4/posts/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Qi(r,{cachedAt:o}),pi("post.updated",r);const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}},e.updateStream=async(e,t)=>{const n=X();n.log("stream/updateStream",e,t);const{data:r}=await n.http.put(`/api/v3/video-streaming/${e}`,t),o=n.cache&&Date.now();n.cache&&Qi(r,{cachedAt:o});const{videoStreamings:i}=r;return{data:i.find((t=>t.streamId===e)),cachedAt:o}},e.updateUser=async(e,t)=>{const n=X();n.log("user/updateUser",e,t);const{data:r}=await n.http.put("/api/v3/users/",Object.assign(Object.assign({userId:e},t),{createNewUserWhenNotFound:!1})),o=n.cache&&Date.now();n.cache&&Qi(r,{cachedAt:o});const{users:i}=r;return{data:i.find((t=>t.userId===e)),cachedAt:o}},e.upsertInCache=Wi,e.wipeCache=async(e="amitySdk")=>{const{log:t,cache:n,userId:r}=X();return!!n&&(t("cache/api/wipeCache",{storageKey:e}),n.data={},await Mi.setItem(`${e}#${r}`,"{}"),!0)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
21
|
+
function ts(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}es.locally=e=>{var t;const n=Q();if(n.log("user/getUsers.locally",e),!n.cache)return;const r=e.map((e=>Vi(["user","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const ns=async(e={})=>{const t=Q();t.log("user/queryUsers",e);const{page:n,displayName:r,filter:o="all",sortBy:i="displayName"}=e,s=ts(e,["page","displayName","filter","sortBy"]),{data:a}=await t.http.get("/api/v3/users",{params:Object.assign(Object.assign({},s),{keyword:r,filter:o,sortBy:i,options:{token:B(n,"skiplimit")}})}),{paging:c}=a,l=ts(a,["paging"]),{users:u}=l,h=t.cache&&Date.now();if(t.cache){Gi(l,{cachedAt:h});Wi(["user","query",e],{users:u.map(Xi("user")),paging:c})}return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:j(c.next)}};ns.locally=(e={})=>{var t,n,r;const o=Q();if(o.log("user/queryUsers.locally",e),!o.cache)return;const i=["user","query",e],{data:s,cachedAt:a}=null!==(t=Vi(i))&&void 0!==t?t:{},c=null!==(n=null==s?void 0:s.users.map((e=>Vi(["user","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==n?n:[],l=j(null==s?void 0:s.paging.previous),u=j(null==s?void 0:s.paging.next);return c.length>0&&c.length===(null===(r=null==s?void 0:s.users)||void 0===r?void 0:r.length)?{data:c,cachedAt:a,prevPage:l,nextPage:u}:void 0};const rs=(e,t)=>{const n=Q();return pi(n,e,e,(e=>{n.cache&&Gi(e),t(e.users[0])}))},os=e=>rs("user.updated",e),is=e=>rs("user.flagged",e),ss=e=>rs("user.unflagged",e),as=e=>rs("user.flagCleared",e),cs=async e=>{const t=Q();t.log("file/getFile",e);const{data:n}=await t.http.get(`/api/v3/files/${e}`),r=t.cache&&Date.now();return t.cache&&Gi({files:[n]},{cachedAt:r}),{data:n,cachedAt:r}};cs.locally=e=>{const t=Q();if(t.log("file/getFile.locally",e),!t.cache)return;const n=Vi(["file","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const ls=async e=>{const t=Q();t.log("role/queryRoles",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,sortBy:i}=n,s=ts(n,["page","displayName","sortBy"]),{data:a}=await t.http.get("/api/v3/roles",{params:Object.assign(Object.assign({},s),{keyword:o,sortBy:i,options:{token:B(r,"skiplimit")}})}),{paging:c}=a,l=ts(a,["paging"]),{roles:u}=l,h=t.cache&&Date.now();t.cache&&Gi(l,{cachedAt:h});const p=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:p}};ls.locally=e=>{Q().log("role/queryRoles.locally",e)};const us=async e=>{const t=Q();t.log("role/getRole",e);const{data:n}=await t.http.get(`/api/v3/roles/${e}`),r=t.cache&&Date.now();return t.cache&&Gi({roles:n},{cachedAt:r}),{data:n.find((t=>t.roleId===e)),cachedAt:r}};us.locally=e=>{const t=Q();if(t.log("role/getRole.locally",e),!t.cache)return;const n=Vi(["role","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const hs=(e,t)=>{"message"===e?fi("v3.message.didUpdate",{messages:[t]}):"post"===e?fi("post.updated",{posts:[t]}):"comment"===e&&fi("comment.updated",{comments:[t]})},ps=async e=>{const t=Q();t.log("message/getMessage",e);const{data:n}=await t.http.get(`/api/v3/messages/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{messages:o}=n;return{data:o.find((t=>t.messageId===e)),cachedAt:r}};ps.locally=e=>{const t=Q();if(t.log("message/getMessage.locally",e),!t.cache)return;const n=Vi(["message","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const fs=async e=>{const t=Q();t.log("message/getMessages",e);const{data:n}=await t.http.get("/api/v3/messages/list",{params:{messageIds:e}}),r=t.cache&&Date.now();return t.cache&&Gi(n,{cachedAt:r}),{data:n.messages,cachedAt:r}};fs.locally=e=>{var t;const n=Q();if(n.log("message/getMessages.locally",e),!n.cache)return;const r=e.map((e=>Vi(["message","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const ds=async e=>{const t=Q();t.log("message/queryMessages",e);const{page:n={limit:10}}=e,r=ts(e,["page"]),{data:o}=await t.http.get("/api/v3/messages",{params:Object.assign(Object.assign({},r),{options:{token:B(n,"afterbefore")}})}),{paging:i}=o,s=ts(o,["paging"]),{messages:a}=s,c=t.cache&&Date.now();if(t.cache){Gi(s,{cachedAt:c});const e=["message","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];Wi(e,{messages:a.map(Xi("message")),paging:i})}const l=j(i.next);return{data:a,cachedAt:c,prevPage:j(i.previous),nextPage:l}};ds.locally=e=>{var t,n;const r=Q();if(r.log("message/queryMessages.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=ts(e,["page"]),s=["message","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=Vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.messages.length))return;const l=a.messages.map((e=>Vi(["message","get",e]))).filter(Boolean).map((({data:e})=>e)),u=j(null==a?void 0:a.paging.previous),h=j(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const ms=async e=>{const t=Q();t.log("user/createMessage",e);const{data:n}=await t.http.post("/api/v3/messages",e),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{messages:o}=n;return{data:o[0],cachedAt:r}};ms.optimistically=e=>{var t,n;const r=Q();if(r.log("user/createMessage.locally",e),!r.cache)return;const o=Vi(["channel","get",e.channelId]);Ki(["channel","get",e.channelId],Object.assign(Object.assign({},null==o?void 0:o.data),{messageCount:(null!==(t=null==o?void 0:o.data.messageCount)&&void 0!==t?t:0)+1}));const i=Object.assign({messageId:Math.random().toString(16),userId:r.userId,channelSegment:(null!==(n=null==o?void 0:o.data.messageCount)&&void 0!==n?n:0)+1,createdAt:(new Date).toISOString()},e);return Wi(["message","get",i.messageId],i,{cachedAt:-1}),fi("v3.message.didCreate",{messages:[i]}),{data:i,cachedAt:-1}};const gs=async(e,t)=>{const n=Q();n.log("user/updateMessage",t);const{data:r}=await n.http.put(`/api/v3/messages/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Gi(r,{cachedAt:o});const{messages:i}=r;return{data:i.find((t=>t.messageId===e)),cachedAt:o}};gs.optimistically=(e,t)=>{const n=Q();if(n.log("user/updateMessage",t),!n.cache)return;const r=Vi(["message","get",e]);if(!r)return;const o=Object.assign(Object.assign(Object.assign({},r.data),t),{updatedAt:(new Date).toISOString()});return Ki(["message","get",e],o,{cachedAt:-1}),fi("v3.message.didUpdate",{messages:[o]}),{data:o,cachedAt:-1}};const ys=async e=>{const t=Q();t.log("message/deleteMessage",e),await t.http.delete(`/api/v3/messages/${encodeURIComponent(e)}`);return(await ps(e)).data};ys.optimistically=e=>{Q().log("message/deleteMessage",e);const t=Vi(["message","get",e]);if(!t)return;const n=Object.assign(Object.assign({},t.data),{isDeleted:!0,updatedAt:(new Date).toISOString()});return Ki(["message","get",e],n,{cachedAt:-1}),fi("v3.message.didDelete",{messages:[n]}),{data:n,cachedAt:-1}};const vs=async e=>{const t=Q();t.log("post/queryPosts",e);const{page:n={limit:10}}=e,r=ts(e,["page"]),{data:o}=await t.http.get("/api/v4/posts",{params:Object.assign(Object.assign({},r),{options:{token:B(n,"afterbeforeraw")}})}),{paging:i}=o,s=ts(o,["paging"]),{posts:a}=s,c=t.cache&&Date.now();if(t.cache){Gi(s,{cachedAt:c});const e=["post","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];Wi(e,{posts:a.map(Xi("post")),paging:i})}const l=U(i.next);return{data:a,cachedAt:c,prevPage:U(i.previous),nextPage:l}};vs.locally=e=>{var t,n;const r=Q();if(r.log("post/queryPosts.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=ts(e,["page"]),s=["post","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=Vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.posts.length))return;const l=a.posts.map((e=>Vi(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),u=U(null==a?void 0:a.paging.previous),h=U(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.posts)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const bs=async e=>{const t=Q();t.log("post/getPosts",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/posts/list",{params:{postIds:n}}),o=t.cache&&Date.now();return t.cache&&Gi(r,{cachedAt:o}),{data:r.posts,cachedAt:o}};bs.locally=e=>{var t;const n=Q();if(n.log("post/getPosts.locally",e),!n.cache)return;const r=e.map((e=>Vi(["post","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const ws=async e=>{var t;const n=Q();let r;n.log("post/getPost",e);try{r=(await n.http.get(`/api/v3/posts/${encodeURIComponent(e)}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&Ji(["post","get",e],!0),n}const o=n.cache&&Date.now();n.cache&&Gi(r,{cachedAt:o});const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}};ws.locally=e=>{const t=Q();if(t.log("post/getPost.locally",e),!t.cache)return;const n=Vi(["post","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const _s=async e=>{const t=Q();t.log("channel/queryCommunities",e);const n=null!=e?e:{},{page:r,displayName:o,membership:i}=n,s=ts(n,["page","displayName","membership"]),{data:a}=await t.http.get("/api/v3/communities",{params:Object.assign(Object.assign({},s),{keyword:o,filter:i,options:{token:B(r,"skiplimit")}})}),{paging:c}=a,l=ts(a,["paging"]),{communities:u}=l,h=t.cache&&Date.now();if(t.cache){Gi(l,{cachedAt:h});const e=["community","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];Wi(e,{communities:u.map(Xi("community")),paging:c})}const p=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:p}};_s.locally=e=>{Q().log("community/queryCommunities.locally",e)};const Cs=async e=>{const t=Q();t.log("community/getCommunities",e);const{data:n}=await t.http.get("/api/v3/communities/list",{params:{communityIds:e}}),r=t.cache&&Date.now();return t.cache&&Gi(n,{cachedAt:r}),{data:n.communities,cachedAt:r}};Cs.locally=e=>{var t;const n=Q();if(n.log("community/getCommunities.locally",e),!n.cache)return;const r=e.map((e=>Vi(["community","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Ss=async e=>{const t=Q();t.log("community/getCommunity",e);const{data:n}=await t.http.get(`/api/v3/communities/${e}`),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{communities:o}=n;return{data:o.find((t=>t.communityId===e)),cachedAt:r}};Ss.locally=e=>{const t=Q();if(t.log("community/getCommunity.locally",e),!t.cache)return;const n=Vi(["community","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const ks=async e=>{const t=Q();t.log("community/queryCommunityMembers",e);const n=null!=e?e:{},{page:r,communityId:o}=n,i=ts(n,["page","communityId"]),{data:s}=await t.http.get(`/api/v3/communities/${o}/users`,{params:Object.assign(Object.assign({},i),{options:{token:B(r,"skiplimit")}})}),{paging:a}=s,c=ts(s,["paging"]),{communityUsers:l}=c,u=t.cache&&Date.now();t.cache&&Gi(c,{cachedAt:u});return{data:l,cachedAt:u,nextPage:j(a.next),prevPage:j(a.previous)}};ks.locally=e=>{Q().log("community/queryCommunityMembers",e)};const As=async e=>{const t=Q();t.log("channel/getTopTrendingCommunities",e);const{limit:n=5}=null!=e?e:{},{data:r}=await t.http.get("/api/v3/communities/top-trending",{params:{options:{limit:n}}}),{communities:o}=r,i=t.cache&&Date.now();if(t.cache){Gi(r,{cachedAt:i});Wi(["community","top-trending",{params:{options:{limit:n}}}],{communities:o.map(Xi("community"))})}return{data:o,cachedAt:i}};As.locally=e=>{var t,n;const r=Q();if(r.log("community/getTopTrendingCommunities.locally",e),!r.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","top-trending",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=Vi(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>Vi(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(n=null==s?void 0:s.communities)||void 0===n?void 0:n.length)?{data:c,cachedAt:a}:void 0};const Es=async e=>{const t=Q();t.log("channel/getRecommendedCommunities",e);const{limit:n=5}=null!=e?e:{},{data:r}=await t.http.get("/api/v3/communities/recommended",{params:{options:{limit:n}}}),{communities:o}=r,i=t.cache&&Date.now();if(t.cache){Gi(r,{cachedAt:i});Wi(["community","recommended",{params:{options:{limit:n}}}],{communities:o.map(Xi("community"))})}return{data:o,cachedAt:i}};Es.locally=e=>{var t,n;const r=Q();if(r.log("community/getRecommendedCommunities.locally",e),!r.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","recommended",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=Vi(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>Vi(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(n=null==s?void 0:s.communities)||void 0===n?void 0:n.length)?{data:c,cachedAt:a}:void 0};const Is=async e=>{const t=Q();t.log("comment/queryComments",e);const{page:n={limit:10}}=e,r=ts(e,["page"]),{data:o}=await t.http.get("/api/v3/comments",{params:Object.assign(Object.assign({},r),{options:{token:B(n,"afterbefore")}})}),{paging:i}=o,s=ts(o,["paging"]),{comments:a}=s,c=t.cache&&Date.now();if(t.cache){Gi(s,{cachedAt:c});const e=["comment","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];Wi(e,{comments:a.map(Xi("comment")),paging:i})}const l=j(i.next);return{data:a,cachedAt:c,prevPage:j(i.previous),nextPage:l}};Is.locally=e=>{var t,n;const r=Q();if(r.log("comment/queryComments.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=ts(e,["page"]),s=["comment","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=Vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.comments.length))return;const l=a.comments.map((e=>Vi(["comment","get",e]))).filter(Boolean).map((({data:e})=>e)),u=j(null==a?void 0:a.paging.previous),h=j(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.comments)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const Os=async e=>{const t=Q();t.log("comment/getComments",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/comments/list",{params:{commentIds:n}}),o=t.cache&&Date.now();return t.cache&&Gi(r,{cachedAt:o}),{data:r.comments,cachedAt:o}};Os.locally=e=>{var t;const n=Q();if(n.log("comment/getComments.locally",e),!n.cache)return;const r=e.map((e=>Vi(["comment","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const xs=async e=>{var t;const n=Q();let r;n.log("comment/getComment",e);try{r=(await n.http.get(`/api/v3/comments/${encodeURIComponent(e)}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&Ji(["comment","get",e],!0),n}const o=n.cache&&Date.now();n.cache&&Gi(r,{cachedAt:o});const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}};xs.locally=e=>{const t=Q();if(t.log("comment/getComment.locally",e),!t.cache)return;const n=Vi(["comment","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Rs=async(e,t)=>{if("message"===e)return ps(t);if("post"===e)return ws(t);if("comment"===e)return xs(t);throw new Error(`Incorrect referenceType: ${e}`)},Fs=(e,t)=>{var n,r;if(Q().userId!==t.reactor.userId)return;let o,i;if("post.addReaction"===e||"post.removeReaction"===e){const e=t.posts[0];i=null===(n=Vi(["post","get",e.postId]))||void 0===n?void 0:n.data,o=e}else{const e=t.comments[0];i=null===(r=Vi(["comment","get",e.commentId]))||void 0===r?void 0:r.data,o=e}if(i&&i.myReactions)if("post.addReaction"===e||"comment.addReaction"===e){if(i.myReactions.includes(t.reactor.reactionName))return;Object.assign(o,{myReactions:[...i.myReactions,t.reactor.reactionName]})}else{if(!i.myReactions.includes(t.reactor.reactionName))return;Object.assign(o,{myReactions:i.myReactions.filter((e=>e!==t.reactor.reactionName))})}},Ts=async(e,t,n)=>{var r,o;const i=Q();i.log("reaction/createReaction",{referenceId:t,referenceType:e,reactionName:n}),await i.http.post("/api/v2/reactions",{referenceId:t,referenceType:e,reactionName:n});const s=await Rs(e,t);return hs(e,s.data),null!==(o=null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n))&&void 0!==o&&o};Ts.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=Q();if(c.log("reaction/createReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const l=Vi([e,"get",t]);if(!(null==l?void 0:l.data)||(null===(r=l.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:l.data.reactionsCount+1,myReactions:[...null!==(o=l.data.myReactions)&&void 0!==o?o:[],n],reactions:Object.assign(Object.assign({},l.data.reactions),{[n]:(null!==(i=l.data.reactions[n])&&void 0!==i?i:0)+1})});return Ki([e,"get",t],u,{cachedAt:-1}),hs(e,u),null!==(a=null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(n))&&void 0!==a&&a};const Ps=async(e,t,n)=>{var r,o;const i=Q();i.log("reaction/removeReaction",{referenceId:t,referenceType:e,reactionName:n}),await i.http.delete("/api/v2/reactions",{data:{referenceId:t,referenceType:e,reactionName:n}});const s=await Rs(e,t);return hs(e,s.data),null!==(o=!(null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n)))&&void 0!==o&&o};Ps.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=Q();if(c.log("reaction/removeReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const l=Vi([e,"get",t]);if(!(null==l?void 0:l.data)||!(null===(r=l.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:Math.max(0,l.data.reactionsCount-1),myReactions:(null!==(o=l.data.myReactions)&&void 0!==o?o:[]).filter((e=>e!==n)),reactions:Object.assign(Object.assign({},l.data.reactions),{[n]:Math.max(0,(null!==(i=l.data.reactions[n])&&void 0!==i?i:0)-1)})});return Ki([e,"get",t],u,{cachedAt:-1}),hs(e,u),null!==(a=!(null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(n)))&&void 0!==a&&a};const Bs=(e,t)=>{const n=Q();return pi(n,e,e,(r=>{var o;if(n.cache){const{communities:n}=r,i=ts(r,["communities"]);Gi(i),(null==n?void 0:n[0])&&!["post.updated"].includes(e)&&fi("community.updated",{communities:n});const s=Vi(["post","get",r.posts[0].postId]);if(["post.created","post.approved","post.declined"].includes(e)){let t=null===(o=Hi(["post","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.targetId)===s.data.targetId}));"post.declined"===e&&(t=null==t?void 0:t.filter((({key:e})=>{var t;return"reviewing"===(null===(t=e[2])||void 0===t?void 0:t.feedType)}))),null==t||t.map((({key:e,data:t})=>Ki(e,t,{cachedAt:-1})))}t(s.data)}else t(r.posts[0])}))},js=e=>Bs("post.created",e),Us=e=>Bs("post.updated",e),Ms=e=>Bs("post.deleted",e),Ns=e=>Bs("post.approved",e),Ds=e=>Bs("post.declined",e),Ls=e=>Bs("post.flagged",e),qs=e=>Bs("post.unflagged",e),$s=e=>{const t=Q();return pi(t,"post.addReaction","post.addReaction",(n=>{if(t.cache){Fs("post.addReaction",n);const t=ts(n,["reactor"]);Gi(t);const r=Vi(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},Hs=e=>{const t=Q();return pi(t,"post.removeReaction","post.removeReaction",(n=>{if(t.cache){Fs("post.removeReaction",n);const t=ts(n,["reactor"]);Gi(t);const r=Vi(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},Vs=(e,t)=>{const n=Q();return pi(n,e,e,(r=>{var o;if(n.cache){Gi(r);const n=Vi(["comment","get",r.comments[0].commentId]);if(["comment.created"].includes(e)){const e=null===(o=Hi(["comment","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.referenceId)===n.data.referenceId}));null==e||e.map((({key:e,data:t})=>Ki(e,t,{cachedAt:-1})))}t(n.data)}else t(r.comments[0])}))},Ws=e=>Vs("comment.created",e),zs=e=>Vs("comment.updated",e),Ks=e=>Vs("comment.deleted",e),Js=e=>Vs("comment.flagged",e),Ys=e=>Vs("comment.unflagged",e),Xs=e=>{const t=Q();return pi(t,"comment.addReaction","comment.addReaction",(n=>{if(t.cache){Fs("comment.addReaction",n);const t=ts(n,["reactor"]);Gi(t);const r=Vi(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))},Qs=e=>{const t=Q();return pi(t,"comment.removeReaction","comment.removeReaction",(n=>{if(t.cache){Fs("comment.removeReaction",n);const t=ts(n,["reactor"]);Gi(t);const r=Vi(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))};var Gs={post:{domainName:"posts",eventName:"v3/post.isflagbyme",primaryKey:"postId"},comment:{domainName:"comments",eventName:"v3/comment.isflagbyme",primaryKey:"commentId"},message:{domainName:"messages",eventName:"v3/message.isFlaggedByMe",primaryKey:"messageId"},user:{domainName:"users",eventName:"user.isFlagByMe",primaryKey:"userId"}};const Zs=async e=>{const t=Q();t.log("channel/queryChannels",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,membership:i}=n,s=ts(n,["page","displayName","membership"]),{data:a}=await t.http.get("/api/v3/channels",{params:Object.assign(Object.assign({},s),{keyword:o,filter:i,options:{token:B(r,"skiplimit")}})}),{paging:c}=a,l=ts(a,["paging"]),{channels:u}=l,h=t.cache&&Date.now();if(t.cache){Gi(l,{cachedAt:h});const e=["channel","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];Wi(e,{channels:u.map(Xi("channel")),paging:c})}const p=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:p}};Zs.locally=e=>{Q().log("channel/queryChannels.locally",e)};const ea=async e=>{const t=Q();t.log("channel/getChannels",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/channels/list",{params:{channelIds:n}}),o=t.cache&&Date.now();return t.cache&&Gi(r,{cachedAt:o}),{data:r.channels,cachedAt:o}};ea.locally=e=>{var t;const n=Q();if(n.log("channel/getChannels.locally",e),!n.cache)return;const r=e.map((e=>Vi(["channel","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const ta=async e=>{const t=Q();t.log("channel/getChannel",e);const{data:n}=await t.http.get(`/api/v3/channels/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{channels:o}=n;return{data:o.find((t=>t.channelId===e)),cachedAt:r}};ta.locally=e=>{const t=Q();if(t.log("channel/getChannel.locally",e),!t.cache)return;const n=Vi(["channel","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const na=async e=>{const t=Q();t.log("channel/queryChannelMembers",e);const n=null!=e?e:{},{page:r,channelId:o,membership:i}=n,s=ts(n,["page","channelId","membership"]),{data:a}=await t.http.get(`/api/v3/channels/${encodeURIComponent(o)}/users`,{params:Object.assign(Object.assign({},s),{filter:i,options:{token:B(r,"skiplimit")}})}),{paging:c}=a,l=ts(a,["paging"]),{channelUsers:u}=l,h=t.cache&&Date.now();t.cache&&Gi(l);return{data:u,cachedAt:h,nextPage:j(c.next),prevPage:j(c.previous)}};na.locally=e=>{Q().log("channel/queryChannelMembers",e)};const ra=e=>{const t=Q();return pi(t,"onChannelUpdated","v3.channel.didUpdate",(t=>{Gi(t),e(t.channels[0])}))},oa=e=>{const t=Q();return pi(t,"onChannelDeleted","v3.channel.didDelete",(t=>{Gi(t),e(t.channels[0])}))},ia=e=>{const t=Q();return pi(t,"onChannelJoined","v3.channel.didJoin",(t=>{Gi(t),e(t.channels[0])}))},sa=e=>{const t=Q();return pi(t,"onChannelLeft","v3.channel.didLeave",(t=>{Gi(t),e(t.channels[0])}))},aa=e=>{const t=Q();return pi(t,"onMemberAdded","v3.channel.didAddUsers",(t=>{Gi(t),e(t.channels[0])}))},ca=e=>{const t=Q();return pi(t,"onMemberRemoved","v3.channel.didRemoveUsers",(t=>{Gi(t),e(t.channels[0])}))},la=e=>{const t=Q();return pi(t,"message/onMessageCreated","v3.message.didCreate",(t=>{Gi(t),e(t.messages[0])}))},ua=e=>{const t=Q();return pi(t,"message/onMessageUpdated","v3.message.didUpdate",(t=>{Gi(t),e(t.messages[0])}))},ha=e=>{const t=Q();return pi(t,"message/onMessageDeleted","v3.message.didDelete",(t=>{Gi(t),e(t.messages[0])}))},pa=(e,t)=>{const n=Q();return pi(n,e,e,(e=>{if(n.cache){Gi(e);const n=Vi(["community","get",e.communities[0].communityId]);t(n.data)}else t(e.communities[0])}))};function fa(e,t,n){return!!e.permissions.some((e=>e===n))||t.users.find((t=>t.userId===e.userId)).permissions.some((e=>e===n))}function da(e,t){return"community.joined"===e||"community.left"===e?t.communityUsers[0]:"community.userRemoved"===e?t.communityUsers.filter((e=>"none"===e.communityMembership))[0]:"community.userBanned"===e?t.communityUsers.filter((e=>"banned"===e.communityMembership))[0]:"community.userUnbanned"===e?t.communityUsers.filter((e=>!fa(e,t,"BAN_COMMUNITY_USER")))[0]:t.communityUsers.filter((e=>!fa(e,t,"ADD_COMMUNITY_USER")))[0]}const ma=(e,t)=>{const n=Q();return pi(n,e,e,(r=>{if(n.cache){Gi(r);const n=Vi(["community","get",r.communities[0].communityId]),o=Vi(["communityUsers","get",Xi("communityUsers")(da(e,r))]);t(n.data,o.data)}else t(r.communities[0],da(e,r))}))},ga=e=>pa("community.updated",e),ya=e=>pa("community.deleted",e),va=e=>ma("community.joined",e),ba=e=>ma("community.left",e),wa=e=>ma("community.userAdded",e),_a=e=>ma("community.userRemoved",e),Ca=e=>ma("community.userBanned",e),Sa=e=>ma("community.userUnbanned",e),ka=async e=>{const t=Q();t.log("category/queryCategories",e);const n=null!=e?e:{},{page:r={limit:10}}=n,o=ts(n,["page"]),{data:i}=await t.http.get("/api/v3/community-categories",{params:Object.assign(Object.assign({},o),{options:{token:B(r,"skiplimit")}})}),{paging:s}=i,a=ts(i,["paging"]),{categories:c}=a,l=t.cache&&Date.now();if(t.cache){Gi(a,{cachedAt:l});const e=["category","query",Object.assign(Object.assign({},o),{options:Object.assign({},r)})];Wi(e,{categories:c.map(Xi("category")),paging:s})}const u=j(s.next);return{data:c,cachedAt:l,prevPage:j(s.previous),nextPage:u}};ka.locally=e=>{var t,n;const r=Q();if(r.log("category/queryCategories.locally",e),!r.cache)return;const o=null!=e?e:{},{page:i={limit:10}}=o,s=ts(o,["page"]),a=["category","query",Object.assign(Object.assign({},s),{options:Object.assign({},i)})],{data:c,cachedAt:l}=null!==(t=Vi(a))&&void 0!==t?t:{};if(!(null==c?void 0:c.categories.length))return;const u=c.categories.map((e=>Vi(["category","get",e]))).filter(Boolean).map((({data:e})=>e)),h=j(null==c?void 0:c.paging.previous),p=j(null==c?void 0:c.paging.next);return u.length===(null===(n=null==c?void 0:c.categories)||void 0===n?void 0:n.length)?{data:u,cachedAt:l,prevPage:h,nextPage:p}:void 0};const Aa=async e=>{const t=Q();t.log("category/getCategory",e);const{data:n}=await t.http.get(`/api/v3/community-categories/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{categories:o}=n;return{data:o.find((t=>t.categoryId===e)),cachedAt:r}};Aa.locally=e=>{const t=Q();if(t.log("category/getCategory.locally",e),!t.cache)return;const n=Vi(["category","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ea=async e=>{const t=Q();t.log("feed/queryGlobalFeed",e);const n=null!=e?e:{},{useCustomRanking:r,page:o}=n,i=ts(n,["useCustomRanking","page"]),{data:s}=await t.http.get(r?"/api/v5/me/global-feeds":"/api/v4/me/global-feeds",{params:Object.assign(Object.assign({},i),{options:{token:B(o,"skiplimit")}})}),{paging:a}=s,c=ts(s,["paging"]),{posts:l}=c,u=t.cache&&Date.now();if(t.cache){Gi(c);const e=["globalFeed","query",Object.assign(Object.assign({},i),{useCustomRanking:r,options:Object.assign({},o)})];Wi(e,{posts:l.map(Xi("post")),paging:a})}const h=j(a.next);return{data:l,cachedAt:u,prevPage:j(a.previous),nextPage:h}};Ea.locally=e=>{var t,n;const r=Q();if(r.log("post/queryGlobalFeed.locally",e),!r.cache)return;const o=null!=e?e:{},{useCustomRanking:i,page:s}=o,a=ts(o,["useCustomRanking","page"]),c=["globalFeed","query",Object.assign(Object.assign({},a),{useCustomRanking:i,options:Object.assign({},s)})],{data:l,cachedAt:u}=null!==(t=Vi(c))&&void 0!==t?t:{};if(!(null==l?void 0:l.posts.length))return;const h=l.posts.map((e=>Vi(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),p=j(null==l?void 0:l.paging.previous),f=j(null==l?void 0:l.paging.next);return h.length===(null===(n=null==l?void 0:l.posts)||void 0===n?void 0:n.length)?{data:h,cachedAt:u,prevPage:p,nextPage:f}:void 0};const Ia=async(e,t)=>{const n=Q();n.log(`follow/queryF${e.substring(1)}`,t);const{userId:r,page:o}=t,i=ts(t,["userId","page"]),{data:s}=await n.http.get(n.userId===r?`/api/v4/me/${e}`:`/api/v4/users/${r}/${e}`,{params:Object.assign(Object.assign({},i),{token:B(o,"skiplimit")})}),{paging:a}=s,c=ts(s,["paging"]),{follows:l}=c,u=n.cache&&Date.now();if(n.cache){Gi(c,{cachedAt:u});const t=[e,"query",Object.assign(Object.assign({},i),{userId:r,options:Object.assign({},o)})];Wi(t,{follows:l.map(Xi("follow")),paging:a})}const h=j(a.next);return{data:l,cachedAt:u,prevPage:j(a.previous),nextPage:h}};Ia.locally=(e,t)=>{var n,r;const o=Q();if(o.log(`follow/queryF${e.substring(1)}.locally`,t),!o.cache)return;const{page:i}=t,s=ts(t,["page"]),a=[e,"query",Object.assign(Object.assign({},s),{options:Object.assign({},i)})],{data:c,cachedAt:l}=null!==(n=Vi(a))&&void 0!==n?n:{};if(!(null==c?void 0:c.follows.length))return;const u=c.follows.map((e=>Vi(["follow","get",e]))).filter(Boolean).map((({data:e})=>e)),h=j(null==c?void 0:c.paging.previous),p=j(null==c?void 0:c.paging.next);return u.length===(null===(r=null==c?void 0:c.follows)||void 0===r?void 0:r.length)?{data:u,cachedAt:l,prevPage:h,nextPage:p}:void 0};const Oa=async e=>Ia("followers",e);Oa.locally=e=>Ia.locally("followers",e);const xa=async e=>Ia("following",e);xa.locally=e=>Ia.locally("following",e);const Ra=e=>["followInfo","get",`${Q().userId}#${e}`],Fa=async e=>{var t,n;const r=Q();r.log("follow/getFollowInfo",e);const{data:o}=await r.http.get(r.userId===e?"/api/v4/me/followInfo":`/api/v4/users/${e}/followInfo`),i=r.cache&&Date.now(),s=Object.assign(Object.assign({},o.followCounts[0]),{status:null===(n=null===(t=o.follows)||void 0===t?void 0:t[0])||void 0===n?void 0:n.status});return r.cache&&Wi(Ra(e),s,{cachedAt:i}),{data:s,cachedAt:i}};Fa.locally=e=>{const t=Q();if(t.log("follow/getFollowInfo.locally",e),!t.cache)return;const n=Vi(Ra(e));return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ta=(e,t)=>{const n=Q();return pi(n,e,e,(e=>{var r,o;if(n.cache){Gi({follows:[e]});[...null!==(r=Hi(["followers","query"]))&&void 0!==r?r:[],...null!==(o=Hi(["followings","query"]))&&void 0!==o?o:[]].filter((({key:t})=>t[2].userId===e.from||t[2].userId===e.to)).forEach((({key:e,data:t})=>Ki(e,t,{cachedAt:-1}))),t(e)}else t(e)}))},Pa=e=>Ta("follow.created",e),Ba=e=>Ta("follow.unfollowed",e),ja=e=>Ta("follow.followerDeleted",e),Ua=e=>Ta("follow.requested",e),Ma=e=>Ta("follow.requestCanceled",e),Na=e=>Ta("follow.accepted",e),Da=e=>Ta("follow.requestDeclined",e),La=e=>{const t=async t=>{const[{data:n},{data:r}]=await Promise.all([Fa(t.from),Fa(t.to)]);e(n),e(r)},n=[Ta("follow.created",t),Ta("follow.requested",t),Ta("follow.accepted",t),Ta("follow.unfollowed",t),Ta("follow.requestCanceled",t),Ta("follow.requestDeclined",t),Ta("follow.followerDeleted",t)];return()=>{n.forEach((e=>e()))}},qa=async e=>{const t=Q();t.log("poll/getPoll",e);const{data:n}=await t.http.get(`/api/v3/polls/${e}`),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{polls:o}=n;return{data:o.find((t=>t.pollId===e)),cachedAt:r}};qa.locally=e=>{const t=Q();if(t.log("poll/getPoll",e),!t.cache)return;const n=Vi(["poll","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const $a=async e=>{const t=Q();t.log("stream/getStream",e);const{data:n}=await t.http.get(`/api/v3/video-streaming/${e}`),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}};$a.locally=e=>{const t=Q();if(t.log("stream/getStream",e),!t.cache)return;const n=Vi(["stream","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ha=async e=>{const t=Q();t.log("stream/queryStreams",e);const n=null!=e?e:{},{page:r}=n,o=ts(n,["page"]),{data:i}=await t.http.get("/api/v3/video-streaming",{params:Object.assign(Object.assign({},o),{options:{token:B(r,"skiplimit")}})}),{paging:s,results:a}=i,{videoStreamings:c}=a,l=t.cache&&Date.now();t.cache&&Gi(a,{cachedAt:l});const u=j(s.next);return{data:c,cachedAt:l,prevPage:j(s.previous),nextPage:u}};Ha.locally=e=>{Q().log("stream/queryStreams.locally",e)};return e.API_REGIONS=fe,e.VERSION=a,e.acceptFollower=async e=>{const t=Q();t.log("follow/acceptFollower",e);const{data:n}=await t.http.post(`/api/v4/me/followers/${e}`);return t.cache&&Gi(n),fi("follow.accepted",n.follows[0]),!0},e.addChannelMembers=async(e,t)=>{const n=Q();n.log("channel/addChannelMembers",e,t);const{data:r}=await n.http.post(`/api/v3/channels/${encodeURIComponent(e)}/users`,{channelId:e,userIds:t});n.cache&&Gi(r),fi("v3.channel.didAddUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"===t.membership))},e.addChannelMembersRole=async(e,t,n)=>{const r=Q();r.log("channel/addChannelMembersRole",e,t,n);const{data:o}=await r.http.post(`/api/v3/channels/${encodeURIComponent(e)}/users/roles`,{channelId:e,role:t,userIds:n});r.cache&&Gi(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&n.roles.includes(t)))},e.addCommunityMembers=async(e,t)=>{const n=Q();n.log("community/addCommunityMembers",e,t);const{data:r}=await n.http.post(`/api/v3/communities/${e}/users`,{communityId:e,userIds:t});n.cache&&Gi(r),fi("community.userAdded",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.addCommunityMembersRoles=async(e,t,n)=>{const r=Q();r.log("community/addCommunityMembersRoles",e,t,n);const{data:o}=await r.http.post(`/api/v4/communities/${e}/users/roles`,{communityId:e,roles:t,userIds:n});r.cache&&Gi(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&t.some((e=>n.roles.includes(e)))))},e.addReaction=Ts,e.backupCache=async(e="amitySdk",t=(e=>e.offline))=>{const{log:n,cache:r,userId:o}=Q();if(!r)return!1;n("cache/api/backupCache",{storageKey:e});const i=Object.fromEntries(Object.entries(r.data).filter((([e,n])=>t(n))));return!!Object.keys(i).length&&(await Di.setItem(`${e}#${o}`,JSON.stringify(i)),!0)},e.closePoll=async e=>{const t=Q();t.log("user/closePoll",e);const{data:n}=await t.http.put(`/api/v3/polls/${encodeURIComponent(e)}`,{status:"closed"}),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{polls:o}=n;return{data:o.find((t=>t.pollId===e)),cachedAt:r}},e.connectClient=async e=>{var t;const n=Q();n.log("client/api/connectClient",Object.assign({apiKey:n.apiKey},e)),null!==(t=e.deviceId)&&void 0!==t||(e.deviceId=mi());const{accessToken:r,users:o}=await(async e=>{const t=Q();t.log("client/api/getToken",e);const n=await gi(),{data:r}=await t.http.post("/v1/device",Object.assign(Object.assign({},e),{deviceInfo:n}),{headers:{"X-API-Key":t.apiKey}});return r})(e);var i,s;n.http.defaults.headers.common.Authorization=`Bearer ${r}`,n.ws.io.opts.query={token:r},i=n.ws,s=n.emitter,li.forEach((e=>{i.on(e,(t=>s.emit(e,t)))})),await new Promise((e=>{n.ws.once("connect",e),n.ws.open()}));const a=_i((()=>{di(),a()}));var c;return n.userId=e.userId,n.accessToken=r,c=o[0],yi={_id:c._id,userId:c.userId,path:c.path},n.ws.connected},e.createChannel=async e=>{const t=Q();let n;t.log("user/createChannel",e),n="conversation"===(null==e?void 0:e.type)?await t.http.post("/api/v3/channels/conversation",Object.assign(Object.assign({},e),{isDistinct:!0})):await t.http.post("/api/v3/channels",e);const r=t.cache&&Date.now();t.cache&&Gi(n.data,{cachedAt:r});const{channels:o}=n.data;return{data:o[0],cachedAt:r}},e.createClient=(e,t=fe.SG,n="amity")=>{const r=(e=>{const t=`${null==e?void 0:e.trim()}`.length>0&&!o,n=pe(e),r=(e,...r)=>{t&&n(e,r)};return r.__instance__=n,r})(n);r("client/api/createClient",{apiKey:e.replace(/.{5}$/g,"xxxxx"),apiRegion:t});const i=qt(me("http",t)),s=(e=>{const t=ni(e,{autoConnect:!1,reconnectionDelay:2e3,transports:["websocket"]});return t.on("disconnect",(e=>{"io server disconnect"===e&&t.connect()})),t})(me("http",t)),c=si(me("mqtt",t)),l=hi(),u={version:`${a}`,apiKey:e,log:r,http:i,ws:s,mqtt:c,emitter:l,use:()=>G(u)};try{Q()}catch(e){G(u)}return u},e.createComment=async e=>{const t=Q();t.log("comment/createComment",e);const{data:n}=await t.http.post("/api/v3/comments",e),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const o=await ws(e.referenceId);fi("post.updated",{posts:[o.data]}),fi("comment.created",n);const{comments:i}=n;return{data:i[0],cachedAt:r}},e.createCommunity=async e=>{const t=Q();t.log("user/createCommunity",e);const{data:n}=await t.http.post("/api/v3/communities/",e),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r}),fi("community.created",n);const{communities:o}=n;return{data:o[0],cachedAt:r}},e.createFile=async(e,t)=>{const n=Q();if(n.log("file/createFile",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/files",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&Gi({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.createImage=async(e,t)=>{const n=Q();if(n.log("file/createImage",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/images",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&Gi({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.createMessage=ms,e.createPoll=async e=>{const t=Q();t.log("post/createPoll",e);const{data:n}=await t.http.post("/api/v3/polls",e),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{polls:o}=n;return{data:o[0],cachedAt:r}},e.createPost=async e=>{const t=Q();t.log("post/createPost",e),e.dataType&&!["text","image","file","video"].includes(e.dataType)||delete e.dataType;const{data:n}=await t.http.post("/api/v4/posts",e),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r}),fi("post.created",n);const{posts:o}=n;return{data:o[0],cachedAt:r}},e.createQuery=$,e.createReport=async(e,t)=>{const n=Q();n.log("report/createReport",{referenceType:e,referenceId:t});const{domainName:r}=Gs[e],{data:o}=await n.http.post(`/api/v3/${r}/${encodeURIComponent(t)}/flag`);n.cache&&Gi(o);return fi("message"===e?"v3.message.didUpdate":`${e}.flagged`,o),!!o},e.createStream=async e=>{const t=Q();t.log("stream/createStream",e);const{data:n}=await t.http.post("/api/v3/video-streaming",e),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o[0],cachedAt:r}},e.createUserToken=async(e,t,n)=>{const r=mi(),o=await gi(),i=qt(me("http",t)),{data:s}=await i.post("/api/v3/sessions",Object.assign(Object.assign({},n),{deviceId:r,deviceInfo:Object.assign(Object.assign({},o),{model:"token management API on TS-SDK"})}),{headers:{"X-API-Key":e}});return{accessToken:s.accessToken}},e.createVideo=async(e,t)=>{const n=Q();if(n.log("file/createVideo",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/videos",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&Gi({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.declineFollower=async e=>{const t=Q();t.log("follow/declineFollower",e);const{data:n}=await t.http.delete(`/api/v4/me/followers/${e}`);return t.cache&&Gi(n),fi("follow.requestDeclined",n.follows[0]),!0},e.deleteChannel=async e=>{const t=Q();t.log("channel/deleteChannel",e),await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}`);return(await ta(e)).data},e.deleteComment=async(e,t=!1)=>{const n=Q();n.log("comment/deleteComment",e);const r=await xs(e);await n.http.delete(`/api/v4/comments/${encodeURIComponent(e)}`,{params:{commentId:e,permanent:t}});const o=Object.assign(Object.assign({},r.data),{isDeleted:!0}),i=await ws(r.data.referenceId);return fi("post.updated",{posts:[i.data]}),fi("comment.deleted",{comments:[o]}),t?setTimeout((()=>{Ji(["comment","get",e],!0)}),0):Ki(["comment","get",e],{isDeleted:!0}),o},e.deleteCommunity=async e=>{const t=Q();t.log("community/deleteCommunity",e),await t.http.delete(`/api/v3/communities/${e}`);const n=await Ss(e);return fi("community.deleted",{communities:[n.data]}),n.data},e.deleteFile=async e=>{const t=Q();return t.log("file/deleteFile",e),await t.http.delete(`/api/v3/files/${e}`),Ji(["file","get",e],!0),{success:!0}},e.deleteMessage=ys,e.deletePoll=async e=>{const t=Q();t.log("poll/deletePoll",e);const n=await qa(e),{data:r}=await t.http.delete(`/api/v3/polls/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return Ki(["poll","get",e],i),o},e.deletePost=async(e,t=!1)=>{const n=Q();n.log("post/deletePost",e);const r=await ws(e);if(await n.http.delete(`/api/v4/posts/${encodeURIComponent(e)}`,{params:{postId:e,permanent:t}}),"community"===r.data.targetType){const e=await Ss(r.data.targetId);fi("community.updated",{communities:[e.data]})}const o=Object.assign(Object.assign({},r.data),{isDeleted:!0});return fi("post.deleted",{posts:[o]}),t?setTimeout((()=>{Ji(["post","get",e],!0)}),0):Ki(["post","get",e],{isDeleted:!0}),o},e.deleteReport=async(e,t)=>{const n=Q();n.log("report/deleteReport",{referenceType:e,referenceId:t});const{domainName:r}=Gs[e],{data:o}=await n.http.delete(`/api/v3/${r}/${encodeURIComponent(t)}/unflag`);n.cache&&Gi(o);return fi("message"===e?"v3.message.didUpdate":`${e}.unflagged`,o),!!o},e.deleteStream=async e=>{const t=Q();t.log("stream/deleteStream",e);const n=await $a(e),{data:r}=await t.http.delete(`/api/v3/video-streaming/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return Ki(["stream","get",e],i),o},e.disableCache=()=>{const e=Q();e.cache&&(e.log("cache/api/disableCache"),delete e.cache)},e.disconnectClient=di,e.disposeStream=async e=>{const t=Q();t.log("stream/disposeStream",e);const{data:n}=await t.http.delete(`/api/v3/video-streaming/${e}/streaming-url`),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}},e.dropFromCache=Ji,e.enableCache=(e={},t)=>{const n=Q();n.cache||(n.log("cache/api/enableCache"),n.cache={data:e,persistIf:t})},e.fileUrlWithSize=(e,t)=>`${e}?size=${t}`,e.filterByPropEquality=(e,t,n)=>void 0!==n?e.filter((e=>e[t]===n)):e,e.follow=async e=>{const t=Q();t.log("follow/follow",e);const{data:n}=await t.http.post(`/api/v4/me/following/${e}`),r=t.cache&&Date.now();return t.cache&&Gi(n,{cachedAt:r}),fi("accepted"===n.follows[0].status?"follow.created":"follow.requested",n.follows[0]),{data:n.follows[0],cachedAt:r}},e.getActiveClient=Q,e.getCategory=Aa,e.getChannel=ta,e.getChannels=ea,e.getComment=xs,e.getCommentTopic=({path:e})=>e,e.getComments=Os,e.getCommunities=Cs,e.getCommunity=Ss,e.getCommunityTopic=({path:t},n=e.SubscriptionLevels.COMMUNITY)=>Si(t,n),e.getFile=cs,e.getFollowInfo=Fa,e.getMessage=ps,e.getMessages=fs,e.getMyFollowersTopic=()=>{const e=vi(),[t]=e.path.split("/user/");return`${t}/membership/${e._id}/+/+`},e.getMyFollowingsTopic=()=>{const e=vi(),[t]=e.path.split("/user/");return`${t}/membership/+/${e._id}/+`},e.getPoll=qa,e.getPost=ws,e.getPostTopic=({path:t},n=e.SubscriptionLevels.POST)=>"comment"===n?`${t}/comment/+`:t,e.getPosts=bs,e.getRecommendedCommunities=Es,e.getRole=us,e.getStream=$a,e.getTopTrendingCommunities=As,e.getUser=Zi,e.getUserTopic=({path:t},n=e.SubscriptionLevels.USER)=>Si(n===e.SubscriptionLevels.USER?t:t.replace(/^(\w*)/,"$1/social"),n),e.getUsers=es,e.isAfterBefore=F,e.isAfterBeforeRaw=T,e.isCachable=L,e.isConnected=()=>{var e,t;const n=Q();return n.log("client/api/isConnected",n),!!(n.userId&&(null===(t=null===(e=n.http.defaults.headers.common)||void 0===e?void 0:e.Authorization)||void 0===t?void 0:t.length)&&n.ws.connected)},e.isFetcher=M,e.isFresh=q,e.isLocal=e=>L(e)&&-1===(null==e?void 0:e.cachedAt),e.isMutator=N,e.isOffline=D,e.isPaged=P,e.isReportedByMe=async(e,t)=>{var n,r;const o=Q();o.log("report/isReportedByMe",{referenceType:e,referenceId:t});const{eventName:i,primaryKey:s}=Gs[e],{result:a,isFlagByMe:c}=null!==(n=await(async(e,t,n)=>{const{ws:r}=e;return await new Promise(((e,o)=>{r.emit(t,n,(t=>{try{e(Dt(t))}catch(e){o(e)}}))}))})(o,i,{[s]:t}))&&void 0!==n?n:{};return null!==(r=null!=a?a:c)&&void 0!==r&&r},e.isSkipLimit=R,e.joinChannel=async e=>{const t=Q();t.log("channel/joinChannel",e);const{data:n}=await t.http.post(`/api/v3/channels/${encodeURIComponent(e)}/join`);t.cache&&Gi(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"===t.membership))},e.joinCommunity=async e=>{const t=Q();t.log("community/joinCommunity",e);const{data:n}=await t.http.post(`/api/v3/communities/${e}/join`),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r}),fi("community.joined",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.leaveChannel=async e=>{const t=Q();t.log("channel/leaveChannel",e);const{data:n}=await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/leave`);t.cache&&Gi(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"!==t.membership))},e.leaveCommunity=async e=>{const t=Q();t.log("community/leaveCommunity",e);const{data:n}=await t.http.delete(`/api/v3/communities/${e}/leave`),r=t.cache&&Date.now();t.cache&&Gi(n,{cachedAt:r}),fi("community.left",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.mergeInCache=zi,e.observeChannel=(e,t)=>{const{log:n}=Q(),r=Date.now();n(`observeChannel(tmpid: ${r}) > listen`);const o=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.channelId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}},i=[];return i.push(ra((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),oa((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),ia((e=>o({data:e,loading:!1,origin:"event"},"onJoin"))),sa((e=>o({data:e,loading:!1,origin:"event"},"onLeft"))),aa((e=>o({data:e,loading:!1,origin:"event"},"onMemberAdded"))),ca((e=>o({data:e,loading:!1,origin:"event"},"onMemberRemoved")))),V($(ta,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeChannel(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.observeComment=(e,t,n="cache_then_server")=>{const{log:r}=Q(),o=Date.now();r(`observeComment(tmpid: ${o}) > listen`);const i=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},s=(t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.commentId)===e&&i(t,n)},a=[];return a.push(zs((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),Ks((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),Js((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),Ys((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),Xs((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),Qs((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),V($(xs,e),(e=>(e.data||e.error)&&i(e,"onFetch")),H(n)),()=>{r(`observeComment(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observeComments=(e,t)=>{const{log:n}=Q(),r=Date.now();n(`observeComments(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.referenceId===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Ws((e=>i(e,"onCreate"))),zs((e=>i(e,"onUpdate"))),Ks((e=>i(e,"onDelete"))),Js((e=>i(e,"onFlagged"))),Ys((e=>i(e,"onUnflagged"))),Xs((e=>i(e,"onReactionAdded"))),Qs((e=>i(e,"onReactionRemoved")))),()=>{n(`observeComments(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeCommunity=(e,t)=>{const{log:n}=Q(),r=Date.now();n(`observeCommunity(tmpid: ${r}) > listen`);const o=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},i=(t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.communityId)===e&&o(t,n)},s=[];return s.push(ga((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),ya((e=>i({data:e,loading:!1,origin:"event"},"onDelete"))),va((e=>i({data:e,loading:!1,origin:"event"},"onJoin"))),ba((e=>i({data:e,loading:!1,origin:"event"},"onLeft"))),wa((e=>i({data:e,loading:!1,origin:"event"},"onUserAdded"))),_a((e=>i({data:e,loading:!1,origin:"event"},"onUserRemoved"))),Ca((e=>i({data:e,loading:!1,origin:"event"},"onUserBanned"))),Sa((e=>i({data:e,loading:!1,origin:"event"},"onUserUnbanned")))),V($(Ss,e),(e=>(e.data||e.error)&&o(e,"onFetch"))),()=>{n(`observeCommunity(tmpid: ${r}) > dispose`),s.forEach((e=>e()))}},e.observeFile=(e,t)=>{const{log:n}=Q(),r=Date.now();n(`observeFile(tmpid: ${r}) > listen`);return V($(cs,e),(n=>n.data&&((n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.fileId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}})(n,"onFetch"))),()=>{n(`observeFile(tmpid: ${r}) > dispose`)}},e.observeFollowInfo=(e,t,n="cache_then_server")=>{const{log:r}=Q(),o=Date.now();r(`observeFollowInfo(tmpid: ${o}) > listen`);const i=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},s=[];return s.push(La((t=>((t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.userId)===e&&i(t,n)})({data:t,loading:!1,origin:"event"},"onUpdate")))),V($(Fa,e),(e=>(e.data||e.error)&&i(e,"onFetch")),H(n)),()=>{r(`observeFollowInfo(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeFollowers=(e,t)=>{const{log:n}=Q(),r=Date.now();n(`observeFollowers(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.from===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Ua((e=>i(e,"onRequested"))),Na((e=>i(e,"onAccepted"))),Da((e=>i(e,"onDeclined"))),Ma((e=>i(e,"onCanceled"))),Pa((e=>i(e,"onFollowed"))),Ba((e=>i(e,"onUnfollowed"))),ja((e=>i(e,"onDeleted")))),()=>{n(`observeFollowers(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeFollowings=(e,t)=>{const{log:n}=Q(),r=Date.now();n(`observeFollowings(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.to===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Ua((e=>i(e,"onRequested"))),Na((e=>i(e,"onAccepted"))),Da((e=>i(e,"onDeclined"))),Ma((e=>i(e,"onCanceled"))),Pa((e=>i(e,"onFollowed"))),Ba((e=>i(e,"onUnfollowed"))),ja((e=>i(e,"onDeleted")))),()=>{n(`observeFollowings(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeMessage=(e,t,n="cache_then_server")=>{const{log:r}=Q(),o=Date.now();r(`observeMessage(tmpid: ${o}) > listen`);const i=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.messageId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}},s=[];return s.push(ua((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),ha((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),"no_fetch"!==n&&V($(ps,e),(e=>e.data&&i(e,"onFetch")),H(n)),()=>{r(`observeMessages(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeMessages=(e,t)=>{const{log:n}=Q(),r=Date.now();n(`observeMessages(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.channelId)===e){if(t instanceof Function)return t(n);null===(i=t.onEvent)||void 0===i||i.call(t,r,n),null===(s=t[r])||void 0===s||s.call(t,n)}};return o.push(la((e=>i({data:e,loading:!1,origin:"event"},"onCreate"))),ua((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),ha((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),()=>{n(`observeMessages(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observePost=(e,t,n="cache_then_server")=>{const{log:r}=Q(),o=Date.now();r(`observePost(tmpid: ${o}) > listen`);const i=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},s=(t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.postId)===e&&i(t,n)},a=[];return a.push(Us((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),Ms((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),Ns((e=>s({data:e,loading:!1,origin:"event"},"onApproved"))),Ds((e=>s({data:e,loading:!1,origin:"event"},"onDeclined"))),Ls((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),qs((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),$s((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),Hs((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),V($(ws,e),(e=>(e.data||e.error)&&i(e,"onFetch")),H(n)),()=>{r(`observePosts(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observePosts=(e,t)=>{const{log:n}=Q(),r=Date.now();n(`observePosts(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(e.targetId===n.targetId&&e.targetType===n.targetType){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(js((e=>i(e,"onCreate"))),Us((e=>i(e,"onUpdate"))),Ms((e=>i(e,"onDelete"))),Ns((e=>i(e,"onApproved"))),Ds((e=>i(e,"onDeclined"))),Ls((e=>i(e,"onFlagged"))),qs((e=>i(e,"onUnflagged"))),$s((e=>i(e,"onReactionAdded"))),Hs((e=>i(e,"onReactionRemoved")))),()=>{n(`observePosts(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeUser=(e,t)=>{const{log:n}=Q(),r=Date.now();n(`observeUser(tmpid: ${r}) > listen`);const o=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.userId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}},i=[];return i.push(os((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),is((e=>o({data:e,loading:!1,origin:"event"},"onFlagged"))),ss((e=>o({data:e,loading:!1,origin:"event"},"onUnflagged"))),as((e=>o({data:e,loading:!1,origin:"event"},"onFlagCleared")))),V($(Zi,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeUser(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.onChannelDeleted=oa,e.onChannelJoined=ia,e.onChannelLeft=sa,e.onChannelUpdated=ra,e.onClientBanned=_i,e.onClientDisconnected=e=>wi((({code:t})=>{800211===t&&e()})),e.onCommentCreated=Ws,e.onCommentDeleted=Ks,e.onCommentFlagged=Js,e.onCommentReactionAdded=Xs,e.onCommentReactionRemoved=Qs,e.onCommentUnflagged=Ys,e.onCommentUpdated=zs,e.onCommunityCreated=e=>pa("community.created",e),e.onCommunityDeleted=ya,e.onCommunityJoined=va,e.onCommunityLeft=ba,e.onCommunityUpdated=ga,e.onCommunityUserAdded=wa,e.onCommunityUserBanned=Ca,e.onCommunityUserRemoved=_a,e.onCommunityUserUnbanned=Sa,e.onConnectionError=wi,e.onFollowInfoUpdated=La,e.onFollowRequestAccepted=Na,e.onFollowRequestCanceled=Ma,e.onFollowRequestDeclined=Da,e.onFollowerDeleted=ja,e.onFollowerRequested=Ua,e.onMemberAdded=aa,e.onMemberRemoved=ca,e.onMessageCreated=la,e.onMessageDeleted=ha,e.onMessageUpdated=ua,e.onPostApproved=Ns,e.onPostCreated=js,e.onPostDeclined=Ds,e.onPostDeleted=Ms,e.onPostFlagged=Ls,e.onPostReactionAdded=$s,e.onPostReactionRemoved=Hs,e.onPostUnflagged=qs,e.onPostUpdated=Us,e.onReactionRemoved=(e,t,n)=>{const r=r=>{Xi(e)(r)===t&&n(r)};if("message"===e){const e=Q(),t=e=>{var t;const n=Vi(["message","get",e.messages[0].messageId]),o=(null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.reactionsCount)!==e.messages[0].reactionsCount;Gi(e),o&&r(e.messages[0])};return pi(e,"reaction/onReactionRemoved","v3.message.didUpdate",t)}return"post"===e?Hs(r):Qs(r)},e.onStreamRecorded=e=>{const t=Q();return pi(t,"stream/onStreamRecorded","video-streaming.didRecord",(t=>{Gi(t),e(t.videoStreamings[0])}))},e.onStreamStarted=e=>{const t=Q();return pi(t,"stream/onStreamStarted","video-streaming.didStart",(t=>{Gi(t),e(t.videoStreamings[0])}))},e.onStreamStopped=e=>{const t=Q();return pi(t,"stream/onStreamStarted","video-streaming.didStop",(t=>{Gi(t),e(t.videoStreamings[0])}))},e.onUserFlagCleared=as,e.onUserFlagged=is,e.onUserFollowed=Pa,e.onUserUnflagged=ss,e.onUserUnfollowed=Ba,e.onUserUpdated=os,e.pullFromCache=Vi,e.pushToCache=Wi,e.queryCache=Hi,e.queryCategories=ka,e.queryChannelMembers=na,e.queryChannels=Zs,e.queryComments=Is,e.queryCommunities=_s,e.queryCommunityMembers=ks,e.queryFollowers=Oa,e.queryFollowings=xa,e.queryGlobalFeed=Ea,e.queryMessages=ds,e.queryOptions=H,e.queryPosts=vs,e.queryRoles=ls,e.queryStreams=Ha,e.queryUsers=ns,e.removeChannelMembers=async(e,t)=>{const n=Q();n.log("channel/removeChannelMembers",e,t);const{data:r}=await n.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/users`,{data:{channelId:e,userIds:t}});n.cache&&Gi(r),fi("v3.channel.didRemoveUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"!==t.membership))},e.removeChannelMembersRole=async(e,t,n)=>{const r=Q();r.log("channel/removeChannelMembersRole",e,t,n);const{data:o}=await r.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/users/roles`,{data:{channelId:e,role:t,userIds:n}});r.cache&&Gi(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&!n.roles.includes(t)))},e.removeCommunityMembers=async(e,t)=>{const n=Q();n.log("community/removeCommunityMembers",e,t);const{data:r}=await n.http.delete(`/api/v3/communities/${e}/users`,{data:{communityId:e,userIds:t}});n.cache&&Gi(r),fi("community.userRemoved",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.removeCommunityMembersRoles=async(e,t,n)=>{const r=Q();r.log("community/removeCommunityMembersRoles",e,t,n);const{data:o}=await r.http.delete(`/api/v4/communities/${e}/users/roles`,{data:{communityId:e,roles:t,userIds:n}});r.cache&&Gi(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&!t.some((e=>n.roles.includes(e)))))},e.removeReaction=Ps,e.restoreCache=async(e="amitySdk")=>{var t;const n=Q();if(!n.cache)return!1;n.log("cache/api/restoreCache",{storageKey:e});const r=null!==(t=await Di.getItem(`${e}#${n.userId}`))&&void 0!==t?t:"{}";let o={};try{o=JSON.parse(r)}catch(e){}return n.cache.data=Object.assign(Object.assign({},o),n.cache.data),!0},e.runQuery=V,e.sortByChannelSegment=({channelSegment:e},{channelSegment:t})=>e-t,e.sortByDisplayName=({displayName:e},{displayName:t})=>e===t?0:e<t?-1:1,e.sortByFirstCreated=({createdAt:e},{createdAt:t})=>new Date(e).valueOf()-new Date(t).valueOf(),e.sortByLastActivity=({lastActivity:e},{lastActivity:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortByLastCreated=({createdAt:e},{createdAt:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortBySegmentNumber=({segmentNumber:e},{segmentNumber:t})=>e-t,e.subscribeTopic=function(e,t){const{mqtt:n,emitter:r,accessToken:o}=Q(),i=vi();return ki===o&&Ai===i._id||(ki=o,Ai=i._id,n.connect({accessToken:ki,userId:Ai}),((e,t)=>{ui.forEach((n=>{e.on(n,((...e)=>t.emit(n,1===e.length?e[0]:e)))})),e.on("message",((e,n)=>{const r=JSON.parse(n.toString());t.emit(r.eventType,r.data)}))})(n,r)),n.subscribe(e,t)},e.toPage=j,e.toPageRaw=U,e.toToken=B,e.unfollow=async e=>{const t=Q();t.log("follow/unfollow",e);const{data:n}=await t.http.delete(`/api/v4/me/following/${e}`);return t.cache&&Gi(n),fi("follow.unfollowed",n.follows[0]),!0},e.updateChannel=async(e,t)=>{const n=Q();n.log("channel/updateChannel",e,t);const{data:r}=await n.http.put(`/api/v3/channels/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Gi(r,{cachedAt:o});const{channels:i}=r;return{data:i.find((t=>t.channelId===e)),cachedAt:o}},e.updateComment=async(e,t)=>{const n=Q();n.log("user/updateComment",t);const{data:r}=await n.http.put(`/api/v3/comments/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Gi(r,{cachedAt:o}),fi("comment.updated",r);const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}},e.updateCommunity=async(e,t)=>{const n=Q();n.log("community/updateCommunity",e,t);const{data:r}=await n.http.put(`/api/v3/communities/${e}`,t),o=n.cache&&Date.now();n.cache&&Gi(r,{cachedAt:o}),fi("community.updated",r);const{communities:i}=r;return{data:i.find((t=>t.communityId===e)),cachedAt:o}},e.updateMessage=gs,e.updatePost=async(e,t)=>{const n=Q();n.log("user/updatePost",t);const{data:r}=await n.http.put(`/api/v4/posts/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Gi(r,{cachedAt:o}),fi("post.updated",r);const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}},e.updateStream=async(e,t)=>{const n=Q();n.log("stream/updateStream",e,t);const{data:r}=await n.http.put(`/api/v3/video-streaming/${e}`,t),o=n.cache&&Date.now();n.cache&&Gi(r,{cachedAt:o});const{videoStreamings:i}=r;return{data:i.find((t=>t.streamId===e)),cachedAt:o}},e.updateUser=async(e,t)=>{const n=Q();n.log("user/updateUser",e,t);const{data:r}=await n.http.put("/api/v3/users/",Object.assign(Object.assign({userId:e},t),{createNewUserWhenNotFound:!1})),o=n.cache&&Date.now();n.cache&&Gi(r,{cachedAt:o});const{users:i}=r;return{data:i.find((t=>t.userId===e)),cachedAt:o}},e.upsertInCache=Ki,e.votePoll=async(e,t)=>{const n=Q();n.log("user/votePoll",e);const{data:r}=await n.http.post(`/api/v3/polls/${encodeURIComponent(e)}/votes`,{pollId:e,answerIds:t}),o=n.cache&&Date.now();n.cache&&Gi(r,{cachedAt:o});const{polls:i}=r;return{data:i.find((t=>t.pollId===e)),cachedAt:o}},e.wipeCache=async(e="amitySdk")=>{const{log:t,cache:n,userId:r}=Q();return!!n&&(t("cache/api/wipeCache",{storageKey:e}),n.data={},await Di.setItem(`${e}#${r}`,"{}"),!0)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|