@voicenter-team/events-sdk 0.0.70 → 0.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,20 @@
1
- var VoicenterEventsSDK=function(U,Y){"use strict";var ln=Object.defineProperty;var un=(U,Y,nt)=>Y in U?ln(U,Y,{enumerable:!0,configurable:!0,writable:!0,value:nt}):U[Y]=nt;var L=(U,Y,nt)=>(un(U,typeof Y!="symbol"?Y+"":Y,nt),nt);function nt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var he={exports:{}},pe={exports:{}};(function(){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={rotl:function(s,r){return s<<r|s>>>32-r},rotr:function(s,r){return s<<32-r|s>>>r},endian:function(s){if(s.constructor==Number)return e.rotl(s,8)&16711935|e.rotl(s,24)&4278255360;for(var r=0;r<s.length;r++)s[r]=e.endian(s[r]);return s},randomBytes:function(s){for(var r=[];s>0;s--)r.push(Math.floor(Math.random()*256));return r},bytesToWords:function(s){for(var r=[],n=0,o=0;n<s.length;n++,o+=8)r[o>>>5]|=s[n]<<24-o%32;return r},wordsToBytes:function(s){for(var r=[],n=0;n<s.length*32;n+=8)r.push(s[n>>>5]>>>24-n%32&255);return r},bytesToHex:function(s){for(var r=[],n=0;n<s.length;n++)r.push((s[n]>>>4).toString(16)),r.push((s[n]&15).toString(16));return r.join("")},hexToBytes:function(s){for(var r=[],n=0;n<s.length;n+=2)r.push(parseInt(s.substr(n,2),16));return r},bytesToBase64:function(s){for(var r=[],n=0;n<s.length;n+=3)for(var o=s[n]<<16|s[n+1]<<8|s[n+2],u=0;u<4;u++)n*8+u*6<=s.length*8?r.push(t.charAt(o>>>6*(3-u)&63)):r.push("=");return r.join("")},base64ToBytes:function(s){s=s.replace(/[^A-Z0-9+\/]/ig,"");for(var r=[],n=0,o=0;n<s.length;o=++n%4)o!=0&&r.push((t.indexOf(s.charAt(n-1))&Math.pow(2,-2*o+8)-1)<<o*2|t.indexOf(s.charAt(n))>>>6-o*2);return r}};pe.exports=e})();var as=pe.exports,_t={utf8:{stringToBytes:function(t){return _t.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(_t.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var e=[],s=0;s<t.length;s++)e.push(t.charCodeAt(s)&255);return e},bytesToString:function(t){for(var e=[],s=0;s<t.length;s++)e.push(String.fromCharCode(t[s]));return e.join("")}}},le=_t;/*!
1
+ var VoicenterEventsSDK=function($,lt){"use strict";var $o=Object.defineProperty;var Go=($,lt,bt)=>lt in $?$o($,lt,{enumerable:!0,configurable:!0,writable:!0,value:bt}):$[lt]=bt;var H=($,lt,bt)=>(Go($,typeof lt!="symbol"?lt+"":lt,bt),bt);function bt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Pe={exports:{}},Fe={exports:{}};(function(){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={rotl:function(r,n){return r<<n|r>>>32-n},rotr:function(r,n){return r<<32-n|r>>>n},endian:function(r){if(r.constructor==Number)return e.rotl(r,8)&16711935|e.rotl(r,24)&4278255360;for(var n=0;n<r.length;n++)r[n]=e.endian(r[n]);return r},randomBytes:function(r){for(var n=[];r>0;r--)n.push(Math.floor(Math.random()*256));return n},bytesToWords:function(r){for(var n=[],o=0,i=0;o<r.length;o++,i+=8)n[i>>>5]|=r[o]<<24-i%32;return n},wordsToBytes:function(r){for(var n=[],o=0;o<r.length*32;o+=8)n.push(r[o>>>5]>>>24-o%32&255);return n},bytesToHex:function(r){for(var n=[],o=0;o<r.length;o++)n.push((r[o]>>>4).toString(16)),n.push((r[o]&15).toString(16));return n.join("")},hexToBytes:function(r){for(var n=[],o=0;o<r.length;o+=2)n.push(parseInt(r.substr(o,2),16));return n},bytesToBase64:function(r){for(var n=[],o=0;o<r.length;o+=3)for(var i=r[o]<<16|r[o+1]<<8|r[o+2],u=0;u<4;u++)o*8+u*6<=r.length*8?n.push(t.charAt(i>>>6*(3-u)&63)):n.push("=");return n.join("")},base64ToBytes:function(r){r=r.replace(/[^A-Z0-9+\/]/ig,"");for(var n=[],o=0,i=0;o<r.length;i=++o%4)i!=0&&n.push((t.indexOf(r.charAt(o-1))&Math.pow(2,-2*i+8)-1)<<i*2|t.indexOf(r.charAt(o))>>>6-i*2);return n}};Fe.exports=e})();var jr=Fe.exports,Yt={utf8:{stringToBytes:function(t){return Yt.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(Yt.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var e=[],r=0;r<t.length;r++)e.push(t.charCodeAt(r)&255);return e},bytesToString:function(t){for(var e=[],r=0;r<t.length;r++)e.push(String.fromCharCode(t[r]));return e.join("")}}},je=Yt;/*!
2
2
  * Determine if an object is a Buffer
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
5
5
  * @license MIT
6
- */var cs=function(t){return t!=null&&(ue(t)||hs(t)||!!t._isBuffer)};function ue(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function hs(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&ue(t.slice(0,0))}(function(){var t=as,e=le.utf8,s=cs,r=le.bin,n=function(o,u){o.constructor==String?u&&u.encoding==="binary"?o=r.stringToBytes(o):o=e.stringToBytes(o):s(o)?o=Array.prototype.slice.call(o,0):!Array.isArray(o)&&o.constructor!==Uint8Array&&(o=o.toString());for(var a=t.bytesToWords(o),f=o.length*8,i=1732584193,c=-271733879,l=-1732584194,p=271733878,h=0;h<a.length;h++)a[h]=(a[h]<<8|a[h]>>>24)&16711935|(a[h]<<24|a[h]>>>8)&4278255360;a[f>>>5]|=128<<f%32,a[(f+64>>>9<<4)+14]=f;for(var w=n._ff,S=n._gg,g=n._hh,y=n._ii,h=0;h<a.length;h+=16){var R=i,P=c,d=l,v=p;i=w(i,c,l,p,a[h+0],7,-680876936),p=w(p,i,c,l,a[h+1],12,-389564586),l=w(l,p,i,c,a[h+2],17,606105819),c=w(c,l,p,i,a[h+3],22,-1044525330),i=w(i,c,l,p,a[h+4],7,-176418897),p=w(p,i,c,l,a[h+5],12,1200080426),l=w(l,p,i,c,a[h+6],17,-1473231341),c=w(c,l,p,i,a[h+7],22,-45705983),i=w(i,c,l,p,a[h+8],7,1770035416),p=w(p,i,c,l,a[h+9],12,-1958414417),l=w(l,p,i,c,a[h+10],17,-42063),c=w(c,l,p,i,a[h+11],22,-1990404162),i=w(i,c,l,p,a[h+12],7,1804603682),p=w(p,i,c,l,a[h+13],12,-40341101),l=w(l,p,i,c,a[h+14],17,-1502002290),c=w(c,l,p,i,a[h+15],22,1236535329),i=S(i,c,l,p,a[h+1],5,-165796510),p=S(p,i,c,l,a[h+6],9,-1069501632),l=S(l,p,i,c,a[h+11],14,643717713),c=S(c,l,p,i,a[h+0],20,-373897302),i=S(i,c,l,p,a[h+5],5,-701558691),p=S(p,i,c,l,a[h+10],9,38016083),l=S(l,p,i,c,a[h+15],14,-660478335),c=S(c,l,p,i,a[h+4],20,-405537848),i=S(i,c,l,p,a[h+9],5,568446438),p=S(p,i,c,l,a[h+14],9,-1019803690),l=S(l,p,i,c,a[h+3],14,-187363961),c=S(c,l,p,i,a[h+8],20,1163531501),i=S(i,c,l,p,a[h+13],5,-1444681467),p=S(p,i,c,l,a[h+2],9,-51403784),l=S(l,p,i,c,a[h+7],14,1735328473),c=S(c,l,p,i,a[h+12],20,-1926607734),i=g(i,c,l,p,a[h+5],4,-378558),p=g(p,i,c,l,a[h+8],11,-2022574463),l=g(l,p,i,c,a[h+11],16,1839030562),c=g(c,l,p,i,a[h+14],23,-35309556),i=g(i,c,l,p,a[h+1],4,-1530992060),p=g(p,i,c,l,a[h+4],11,1272893353),l=g(l,p,i,c,a[h+7],16,-155497632),c=g(c,l,p,i,a[h+10],23,-1094730640),i=g(i,c,l,p,a[h+13],4,681279174),p=g(p,i,c,l,a[h+0],11,-358537222),l=g(l,p,i,c,a[h+3],16,-722521979),c=g(c,l,p,i,a[h+6],23,76029189),i=g(i,c,l,p,a[h+9],4,-640364487),p=g(p,i,c,l,a[h+12],11,-421815835),l=g(l,p,i,c,a[h+15],16,530742520),c=g(c,l,p,i,a[h+2],23,-995338651),i=y(i,c,l,p,a[h+0],6,-198630844),p=y(p,i,c,l,a[h+7],10,1126891415),l=y(l,p,i,c,a[h+14],15,-1416354905),c=y(c,l,p,i,a[h+5],21,-57434055),i=y(i,c,l,p,a[h+12],6,1700485571),p=y(p,i,c,l,a[h+3],10,-1894986606),l=y(l,p,i,c,a[h+10],15,-1051523),c=y(c,l,p,i,a[h+1],21,-2054922799),i=y(i,c,l,p,a[h+8],6,1873313359),p=y(p,i,c,l,a[h+15],10,-30611744),l=y(l,p,i,c,a[h+6],15,-1560198380),c=y(c,l,p,i,a[h+13],21,1309151649),i=y(i,c,l,p,a[h+4],6,-145523070),p=y(p,i,c,l,a[h+11],10,-1120210379),l=y(l,p,i,c,a[h+2],15,718787259),c=y(c,l,p,i,a[h+9],21,-343485551),i=i+R>>>0,c=c+P>>>0,l=l+d>>>0,p=p+v>>>0}return t.endian([i,c,l,p])};n._ff=function(o,u,a,f,i,c,l){var p=o+(u&a|~u&f)+(i>>>0)+l;return(p<<c|p>>>32-c)+u},n._gg=function(o,u,a,f,i,c,l){var p=o+(u&f|a&~f)+(i>>>0)+l;return(p<<c|p>>>32-c)+u},n._hh=function(o,u,a,f,i,c,l){var p=o+(u^a^f)+(i>>>0)+l;return(p<<c|p>>>32-c)+u},n._ii=function(o,u,a,f,i,c,l){var p=o+(a^(u|~f))+(i>>>0)+l;return(p<<c|p>>>32-c)+u},n._blocksize=16,n._digestsize=16,he.exports=function(o,u){if(o==null)throw new Error("Illegal argument "+o);var a=t.wordsToBytes(n(o,u));return u&&u.asBytes?a:u&&u.asString?r.bytesToString(a):t.bytesToHex(a)}})();var ps=he.exports;const ls=nt(ps);var ot=(t=>(t.MAIN="main",t.NEXT="next",t))(ot||{}),H=(t=>(t.USER="User",t.TOKEN="Token",t))(H||{});class dt{static async getSessionStorageDataByKey(e,s=!0){if(typeof chrome<"u"&&typeof chrome.storage<"u"){const r=await chrome.storage.session.get(e);if(r[e])return s?JSON.parse(r[e]):r[e]}if(typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.getItem=="function"){const r=window.sessionStorage.getItem(e);if(r)return s?JSON.parse(r):r}}static async updateSessionStorageKey(e,s){typeof chrome<"u"&&typeof chrome.storage<"u"&&await chrome.storage.session.set({[e]:JSON.stringify(s)}),typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.setItem=="function"&&window.sessionStorage.setItem(e,JSON.stringify(s))}static clearSessionStorage(){typeof chrome<"u"&&typeof chrome.storage<"u"&&chrome.storage.session.clear(),typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.clear=="function"&&window.sessionStorage.clear()}}var us=Object.defineProperty,fs=(t,e,s)=>e in t?us(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,_=(t,e,s)=>(fs(t,typeof e!="symbol"?e+"":e,s),s);function ds(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function gs(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var s=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};s.prototype=e.prototype}else s={};return Object.defineProperty(s,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}),s}var Ut={exports:{}},ys=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,vs=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],fe=function(t){var e=t,s=t.indexOf("["),r=t.indexOf("]");s!=-1&&r!=-1&&(t=t.substring(0,s)+t.substring(s,r).replace(/:/g,";")+t.substring(r,t.length));for(var n=ys.exec(t||""),o={},u=14;u--;)o[vs[u]]=n[u]||"";return s!=-1&&r!=-1&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=ms(o,o.path),o.queryKey=Cs(o,o.query),o};function ms(t,e){var s=/\/{2,9}/g,r=e.replace(s,"/").split("/");return(e.substr(0,1)=="/"||e.length===0)&&r.splice(0,1),e.substr(e.length-1,1)=="/"&&r.splice(r.length-1,1),r}function Cs(t,e){var s={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,o){n&&(s[n]=o)}),s}var xt={exports:{}},Bt={exports:{}},gt=1e3,yt=gt*60,vt=yt*60,mt=vt*24,Ss=mt*365.25,ks=function(t,e){e=e||{};var s=typeof t;if(s==="string"&&t.length>0)return ws(t);if(s==="number"&&isNaN(t)===!1)return e.long?bs(t):Es(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function ws(t){if(t=String(t),!(t.length>100)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var s=parseFloat(e[1]),r=(e[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return s*Ss;case"days":case"day":case"d":return s*mt;case"hours":case"hour":case"hrs":case"hr":case"h":return s*vt;case"minutes":case"minute":case"mins":case"min":case"m":return s*yt;case"seconds":case"second":case"secs":case"sec":case"s":return s*gt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}}}function Es(t){return t>=mt?Math.round(t/mt)+"d":t>=vt?Math.round(t/vt)+"h":t>=yt?Math.round(t/yt)+"m":t>=gt?Math.round(t/gt)+"s":t+"ms"}function bs(t){return Ct(t,mt,"day")||Ct(t,vt,"hour")||Ct(t,yt,"minute")||Ct(t,gt,"second")||t+" ms"}function Ct(t,e,s){if(!(t<e))return t<e*1.5?Math.floor(t/e)+" "+s:Math.ceil(t/e)+" "+s+"s"}(function(t,e){e=t.exports=r.debug=r.default=r,e.coerce=f,e.disable=u,e.enable=o,e.enabled=a,e.humanize=ks,e.instances=[],e.names=[],e.skips=[],e.formatters={};function s(i){var c=0,l;for(l in i)c=(c<<5)-c+i.charCodeAt(l),c|=0;return e.colors[Math.abs(c)%e.colors.length]}function r(i){var c;function l(){if(l.enabled){var p=l,h=+new Date,w=h-(c||h);p.diff=w,p.prev=c,p.curr=h,c=h;for(var S=new Array(arguments.length),g=0;g<S.length;g++)S[g]=arguments[g];S[0]=e.coerce(S[0]),typeof S[0]!="string"&&S.unshift("%O");var y=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,function(P,d){if(P==="%%")return P;y++;var v=e.formatters[d];if(typeof v=="function"){var m=S[y];P=v.call(p,m),S.splice(y,1),y--}return P}),e.formatArgs.call(p,S);var R=l.log||e.log||console.log.bind(console);R.apply(p,S)}}return l.namespace=i,l.enabled=e.enabled(i),l.useColors=e.useColors(),l.color=s(i),l.destroy=n,typeof e.init=="function"&&e.init(l),e.instances.push(l),l}function n(){var i=e.instances.indexOf(this);return i!==-1?(e.instances.splice(i,1),!0):!1}function o(i){e.save(i),e.names=[],e.skips=[];var c,l=(typeof i=="string"?i:"").split(/[\s,]+/),p=l.length;for(c=0;c<p;c++)l[c]&&(i=l[c].replace(/\*/g,".*?"),i[0]==="-"?e.skips.push(new RegExp("^"+i.substr(1)+"$")):e.names.push(new RegExp("^"+i+"$")));for(c=0;c<e.instances.length;c++){var h=e.instances[c];h.enabled=e.enabled(h.namespace)}}function u(){e.enable("")}function a(i){if(i[i.length-1]==="*")return!0;var c,l;for(c=0,l=e.skips.length;c<l;c++)if(e.skips[c].test(i))return!1;for(c=0,l=e.names.length;c<l;c++)if(e.names[c].test(i))return!0;return!1}function f(i){return i instanceof Error?i.stack||i.message:i}})(Bt,Bt.exports);var Ns=Bt.exports;(function(t,e){e=t.exports=Ns,e.log=n,e.formatArgs=r,e.save=o,e.load=u,e.useColors=s,e.storage=typeof chrome<"u"&&typeof chrome.storage<"u"?chrome.storage.local:a(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function s(){return typeof window<"u"&&window.process&&window.process.type==="renderer"?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}e.formatters.j=function(f){try{return JSON.stringify(f)}catch(i){return"[UnexpectedJSONParseError]: "+i.message}};function r(f){var i=this.useColors;if(f[0]=(i?"%c":"")+this.namespace+(i?" %c":" ")+f[0]+(i?"%c ":" ")+"+"+e.humanize(this.diff),!!i){var c="color: "+this.color;f.splice(1,0,c,"color: inherit");var l=0,p=0;f[0].replace(/%[a-zA-Z%]/g,function(h){h!=="%%"&&(l++,h==="%c"&&(p=l))}),f.splice(p,0,c)}}function n(){return typeof console=="object"&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function o(f){try{f==null?e.storage.removeItem("debug"):e.storage.debug=f}catch{}}function u(){var f;try{f=e.storage.debug}catch{}return!f&&typeof process<"u"&&"env"in process&&(f=process.env.DEBUG),f}e.enable(u());function a(){try{return window.localStorage}catch{}}})(xt,xt.exports);var Q=xt.exports,Ts=fe,de=Q("socket.io-client:url"),As=Os;function Os(t,e){var s=t;e=e||typeof location<"u"&&location,t==null&&(t=e.protocol+"//"+e.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=e.protocol+t:t=e.host+t),/^(https?|wss?):\/\//.test(t)||(de("protocol-less url %s",t),typeof e<"u"?t=e.protocol+"//"+t:t="https://"+t),de("parse %s",t),s=Ts(t)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";var r=s.host.indexOf(":")!==-1,n=r?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+n+":"+s.port,s.href=s.protocol+"://"+n+(e&&e.port===s.port?"":":"+s.port),s}var St={},ge={exports:{}};(function(t){t.exports=e;function e(r){if(r)return s(r)}function s(r){for(var n in e.prototype)r[n]=e.prototype[n];return r}e.prototype.on=e.prototype.addEventListener=function(r,n){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(n),this},e.prototype.once=function(r,n){function o(){this.off(r,o),n.apply(this,arguments)}return o.fn=n,this.on(r,o),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(r,n){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var o=this._callbacks["$"+r];if(!o)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var u,a=0;a<o.length;a++)if(u=o[a],u===n||u.fn===n){o.splice(a,1);break}return o.length===0&&delete this._callbacks["$"+r],this},e.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var n=new Array(arguments.length-1),o=this._callbacks["$"+r],u=1;u<arguments.length;u++)n[u-1]=arguments[u];if(o){o=o.slice(0);for(var u=0,a=o.length;u<a;++u)o[u].apply(this,n)}return this},e.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]},e.prototype.hasListeners=function(r){return!!this.listeners(r).length}})(ge);var at=ge.exports,kt={},Is={}.toString,Dt=Array.isArray||function(t){return Is.call(t)=="[object Array]"},ye=Us,Ls=typeof Buffer=="function"&&typeof Buffer.isBuffer=="function",Rs=typeof ArrayBuffer=="function",_s=function(t){return typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer};function Us(t){return Ls&&Buffer.isBuffer(t)||Rs&&(t instanceof ArrayBuffer||_s(t))}var Ft=Dt,ve=ye,me=Object.prototype.toString,xs=typeof Blob=="function"||typeof Blob<"u"&&me.call(Blob)==="[object BlobConstructor]",Bs=typeof File=="function"||typeof File<"u"&&me.call(File)==="[object FileConstructor]";kt.deconstructPacket=function(t){var e=[],s=t.data,r=t;return r.data=Pt(s,e),r.attachments=e.length,{packet:r,buffers:e}};function Pt(t,e){if(!t)return t;if(ve(t)){var s={_placeholder:!0,num:e.length};return e.push(t),s}else if(Ft(t)){for(var r=new Array(t.length),n=0;n<t.length;n++)r[n]=Pt(t[n],e);return r}else if(typeof t=="object"&&!(t instanceof Date)){var r={};for(var o in t)r[o]=Pt(t[o],e);return r}return t}kt.reconstructPacket=function(t,e){return t.data=Mt(t.data,e),t.attachments=void 0,t};function Mt(t,e){if(!t)return t;if(t&&t._placeholder===!0){var s=typeof t.num=="number"&&t.num>=0&&t.num<e.length;if(s)return e[t.num];throw new Error("illegal attachments")}else if(Ft(t))for(var r=0;r<t.length;r++)t[r]=Mt(t[r],e);else if(typeof t=="object")for(var n in t)t[n]=Mt(t[n],e);return t}kt.removeBlobs=function(t,e){function s(o,u,a){if(!o)return o;if(xs&&o instanceof Blob||Bs&&o instanceof File){r++;var f=new FileReader;f.onload=function(){a?a[u]=this.result:n=this.result,--r||e(n)},f.readAsArrayBuffer(o)}else if(Ft(o))for(var i=0;i<o.length;i++)s(o[i],i,o);else if(typeof o=="object"&&!ve(o))for(var c in o)s(o[c],c,o)}var r=0,n=t;s(n),r||e(n)},function(t){var e=Q("socket.io-parser"),s=at,r=kt,n=Dt,o=ye;t.protocol=4,t.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],t.CONNECT=0,t.DISCONNECT=1,t.EVENT=2,t.ACK=3,t.ERROR=4,t.BINARY_EVENT=5,t.BINARY_ACK=6,t.Encoder=u,t.Decoder=l;function u(){}var a=t.ERROR+'"encode error"';u.prototype.encode=function(g,y){if(e("encoding packet %j",g),t.BINARY_EVENT===g.type||t.BINARY_ACK===g.type)c(g,y);else{var R=f(g);y([R])}};function f(g){var y=""+g.type;if((t.BINARY_EVENT===g.type||t.BINARY_ACK===g.type)&&(y+=g.attachments+"-"),g.nsp&&g.nsp!=="/"&&(y+=g.nsp+","),g.id!=null&&(y+=g.id),g.data!=null){var R=i(g.data);if(R!==!1)y+=R;else return a}return e("encoded %j as %s",g,y),y}function i(g){try{return JSON.stringify(g)}catch{return!1}}function c(g,y){function R(P){var d=r.deconstructPacket(P),v=f(d.packet),m=d.buffers;m.unshift(v),y(m)}r.removeBlobs(g,R)}function l(){this.reconstructor=null}s(l.prototype),l.prototype.add=function(g){var y;if(typeof g=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");y=p(g),t.BINARY_EVENT===y.type||t.BINARY_ACK===y.type?(this.reconstructor=new w(y),this.reconstructor.reconPack.attachments===0&&this.emit("decoded",y)):this.emit("decoded",y)}else if(o(g)||g.base64)if(this.reconstructor)y=this.reconstructor.takeBinaryData(g),y&&(this.reconstructor=null,this.emit("decoded",y));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+g)};function p(g){var y=0,R={type:Number(g.charAt(0))};if(t.types[R.type]==null)return S("unknown packet type "+R.type);if(t.BINARY_EVENT===R.type||t.BINARY_ACK===R.type){for(var P=y+1;g.charAt(++y)!=="-"&&y!=g.length;);var d=g.substring(P,y);if(d!=Number(d)||g.charAt(y)!=="-")throw new Error("Illegal attachments");R.attachments=Number(d)}if(g.charAt(y+1)==="/"){for(var P=y+1;++y;){var v=g.charAt(y);if(v===","||y===g.length)break}R.nsp=g.substring(P,y)}else R.nsp="/";var m=g.charAt(y+1);if(m!==""&&Number(m)==m){for(var P=y+1;++y;){var v=g.charAt(y);if(v==null||Number(v)!=v){--y;break}if(y===g.length)break}R.id=Number(g.substring(P,y+1))}if(g.charAt(++y)){var C=h(g.substr(y)),k=C!==!1&&(R.type===t.ERROR||n(C));if(k)R.data=C;else return S("invalid payload")}return e("decoded %s as %j",g,R),R}function h(g){try{return JSON.parse(g)}catch{return!1}}l.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()};function w(g){this.reconPack=g,this.buffers=[]}w.prototype.takeBinaryData=function(g){if(this.buffers.push(g),this.buffers.length===this.reconPack.attachments){var y=r.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),y}return null},w.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]};function S(g){return{type:t.ERROR,data:"parser error: "+g}}}(St);var jt={exports:{}},wt={},qt={exports:{}};try{qt.exports=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{qt.exports=!1}var Ds=qt.exports,Wt=function(){return typeof self<"u"?self:typeof window<"u"?window:Function("return this")()}(),Fs=Ds,Ps=Wt,Kt=function(t){var e=t.xdomain,s=t.xscheme,r=t.enablesXDR;try{if(typeof XMLHttpRequest<"u"&&(!e||Fs))return new XMLHttpRequest}catch{}try{if(typeof XDomainRequest<"u"&&!s&&r)return new XDomainRequest}catch{}if(!e)try{return new Ps[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}},Gt={exports:{}},it={},Ms=Object.keys||function(t){var e=[],s=Object.prototype.hasOwnProperty;for(var r in t)s.call(t,r)&&e.push(r);return e},Ht,Ce;function Se(){if(Ce)return Ht;Ce=1;var t=Dt,e=Object.prototype.toString,s=typeof Blob=="function"||typeof Blob<"u"&&e.call(Blob)==="[object BlobConstructor]",r=typeof File=="function"||typeof File<"u"&&e.call(File)==="[object FileConstructor]";Ht=n;function n(o){if(!o||typeof o!="object")return!1;if(t(o)){for(var u=0,a=o.length;u<a;u++)if(n(o[u]))return!0;return!1}if(typeof Buffer=="function"&&Buffer.isBuffer&&Buffer.isBuffer(o)||typeof ArrayBuffer=="function"&&o instanceof ArrayBuffer||s&&o instanceof Blob||r&&o instanceof File)return!0;if(o.toJSON&&typeof o.toJSON=="function"&&arguments.length===1)return n(o.toJSON(),!0);for(var f in o)if(Object.prototype.hasOwnProperty.call(o,f)&&n(o[f]))return!0;return!1}return Ht}var js=function(t,e,s){var r=t.byteLength;if(e=e||0,s=s||r,t.slice)return t.slice(e,s);if(e<0&&(e+=r),s<0&&(s+=r),s>r&&(s=r),e>=r||e>=s||r===0)return new ArrayBuffer(0);for(var n=new Uint8Array(t),o=new Uint8Array(s-e),u=e,a=0;u<s;u++,a++)o[a]=n[u];return o.buffer},qs=Ws;function Ws(t,e,s){var r=!1;return s=s||Ks,n.count=t,t===0?e():n;function n(o,u){if(n.count<=0)throw new Error("after called too many times");--n.count,o?(r=!0,e(o),e=s):n.count===0&&!r&&e(null,u)}}function Ks(){}/*! https://mths.be/utf8js v2.1.2 by @mathias */var Z=String.fromCharCode;function ke(t){for(var e=[],s=0,r=t.length,n,o;s<r;)n=t.charCodeAt(s++),n>=55296&&n<=56319&&s<r?(o=t.charCodeAt(s++),(o&64512)==56320?e.push(((n&1023)<<10)+(o&1023)+65536):(e.push(n),s--)):e.push(n);return e}function Gs(t){for(var e=t.length,s=-1,r,n="";++s<e;)r=t[s],r>65535&&(r-=65536,n+=Z(r>>>10&1023|55296),r=56320|r&1023),n+=Z(r);return n}function we(t,e){if(t>=55296&&t<=57343){if(e)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function Vt(t,e){return Z(t>>e&63|128)}function Hs(t,e){if(!(t&4294967168))return Z(t);var s="";return t&4294965248?t&4294901760?t&4292870144||(s=Z(t>>18&7|240),s+=Vt(t,12),s+=Vt(t,6)):(we(t,e)||(t=65533),s=Z(t>>12&15|224),s+=Vt(t,6)):s=Z(t>>6&31|192),s+=Z(t&63|128),s}function Vs(t,e){e=e||{};for(var s=e.strict!==!1,r=ke(t),n=r.length,o=-1,u,a="";++o<n;)u=r[o],a+=Hs(u,s);return a}function ct(){if(tt>=bt)throw Error("Invalid byte index");var t=Et[tt]&255;if(tt++,(t&192)==128)return t&63;throw Error("Invalid continuation byte")}function zs(t){var e,s,r,n,o;if(tt>bt)throw Error("Invalid byte index");if(tt==bt)return!1;if(e=Et[tt]&255,tt++,!(e&128))return e;if((e&224)==192){if(s=ct(),o=(e&31)<<6|s,o>=128)return o;throw Error("Invalid continuation byte")}if((e&240)==224){if(s=ct(),r=ct(),o=(e&15)<<12|s<<6|r,o>=2048)return we(o,t)?o:65533;throw Error("Invalid continuation byte")}if((e&248)==240&&(s=ct(),r=ct(),n=ct(),o=(e&7)<<18|s<<12|r<<6|n,o>=65536&&o<=1114111))return o;throw Error("Invalid UTF-8 detected")}var Et,bt,tt;function $s(t,e){e=e||{};var s=e.strict!==!1;Et=ke(t),bt=Et.length,tt=0;for(var r=[],n;(n=zs(s))!==!1;)r.push(n);return Gs(r)}var Xs={version:"2.1.2",encode:Vs,decode:$s},zt={},Ee;function Js(){return Ee||(Ee=1,function(t){zt.encode=function(e){var s=new Uint8Array(e),r,n=s.length,o="";for(r=0;r<n;r+=3)o+=t[s[r]>>2],o+=t[(s[r]&3)<<4|s[r+1]>>4],o+=t[(s[r+1]&15)<<2|s[r+2]>>6],o+=t[s[r+2]&63];return n%3===2?o=o.substring(0,o.length-1)+"=":n%3===1&&(o=o.substring(0,o.length-2)+"=="),o},zt.decode=function(e){var s=e.length*.75,r=e.length,n,o=0,u,a,f,i;e[e.length-1]==="="&&(s--,e[e.length-2]==="="&&s--);var c=new ArrayBuffer(s),l=new Uint8Array(c);for(n=0;n<r;n+=4)u=t.indexOf(e[n]),a=t.indexOf(e[n+1]),f=t.indexOf(e[n+2]),i=t.indexOf(e[n+3]),l[o++]=u<<2|a>>4,l[o++]=(a&15)<<4|f>>2,l[o++]=(f&3)<<6|i&63;return c}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")),zt}var $t,be;function Ys(){if(be)return $t;be=1;var t=typeof t<"u"?t:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:!1,e=function(){try{var a=new Blob(["hi"]);return a.size===2}catch{return!1}}(),s=e&&function(){try{var a=new Blob([new Uint8Array([1,2])]);return a.size===2}catch{return!1}}(),r=t&&t.prototype.append&&t.prototype.getBlob;function n(a){return a.map(function(f){if(f.buffer instanceof ArrayBuffer){var i=f.buffer;if(f.byteLength!==i.byteLength){var c=new Uint8Array(f.byteLength);c.set(new Uint8Array(i,f.byteOffset,f.byteLength)),i=c.buffer}return i}return f})}function o(a,f){f=f||{};var i=new t;return n(a).forEach(function(c){i.append(c)}),f.type?i.getBlob(f.type):i.getBlob()}function u(a,f){return new Blob(n(a),f||{})}return typeof Blob<"u"&&(o.prototype=Blob.prototype,u.prototype=Blob.prototype),$t=function(){return e?s?Blob:u:r?o:void 0}(),$t}(function(t){var e=Ms,s=Se(),r=js,n=qs,o=Xs,u;typeof ArrayBuffer<"u"&&(u=Js());var a=typeof navigator<"u"&&/Android/i.test(navigator.userAgent),f=typeof navigator<"u"&&/PhantomJS/i.test(navigator.userAgent),i=a||f;t.protocol=3;var c=t.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},l=e(c),p={type:"error",data:"parser error"},h=Ys();t.encodePacket=function(d,v,m,C){typeof v=="function"&&(C=v,v=!1),typeof m=="function"&&(C=m,m=null);var k=d.data===void 0?void 0:d.data.buffer||d.data;if(typeof ArrayBuffer<"u"&&k instanceof ArrayBuffer)return S(d,v,C);if(typeof h<"u"&&k instanceof h)return y(d,v,C);if(k&&k.base64)return w(d,C);var E=c[d.type];return d.data!==void 0&&(E+=m?o.encode(String(d.data),{strict:!1}):String(d.data)),C(""+E)};function w(d,v){var m="b"+t.packets[d.type]+d.data.data;return v(m)}function S(d,v,m){if(!v)return t.encodeBase64Packet(d,m);var C=d.data,k=new Uint8Array(C),E=new Uint8Array(1+C.byteLength);E[0]=c[d.type];for(var N=0;N<k.length;N++)E[N+1]=k[N];return m(E.buffer)}function g(d,v,m){if(!v)return t.encodeBase64Packet(d,m);var C=new FileReader;return C.onload=function(){t.encodePacket({type:d.type,data:C.result},v,!0,m)},C.readAsArrayBuffer(d.data)}function y(d,v,m){if(!v)return t.encodeBase64Packet(d,m);if(i)return g(d,v,m);var C=new Uint8Array(1);C[0]=c[d.type];var k=new h([C.buffer,d.data]);return m(k)}t.encodeBase64Packet=function(d,v){var m="b"+t.packets[d.type];if(typeof h<"u"&&d.data instanceof h){var C=new FileReader;return C.onload=function(){var O=C.result.split(",")[1];v(m+O)},C.readAsDataURL(d.data)}var k;try{k=String.fromCharCode.apply(null,new Uint8Array(d.data))}catch{for(var E=new Uint8Array(d.data),N=new Array(E.length),A=0;A<E.length;A++)N[A]=E[A];k=String.fromCharCode.apply(null,N)}return m+=btoa(k),v(m)},t.decodePacket=function(d,v,m){if(d===void 0)return p;if(typeof d=="string"){if(d.charAt(0)==="b")return t.decodeBase64Packet(d.substr(1),v);if(m&&(d=R(d),d===!1))return p;var k=d.charAt(0);return Number(k)!=k||!l[k]?p:d.length>1?{type:l[k],data:d.substring(1)}:{type:l[k]}}var C=new Uint8Array(d),k=C[0],E=r(d,1);return h&&v==="blob"&&(E=new h([E])),{type:l[k],data:E}};function R(d){try{d=o.decode(d,{strict:!1})}catch{return!1}return d}t.decodeBase64Packet=function(d,v){var m=l[d.charAt(0)];if(!u)return{type:m,data:{base64:!0,data:d.substr(1)}};var C=u.decode(d.substr(1));return v==="blob"&&h&&(C=new h([C])),{type:m,data:C}},t.encodePayload=function(d,v,m){typeof v=="function"&&(m=v,v=null);var C=s(d);if(v&&C)return h&&!i?t.encodePayloadAsBlob(d,m):t.encodePayloadAsArrayBuffer(d,m);if(!d.length)return m("0:");function k(N){return N.length+":"+N}function E(N,A){t.encodePacket(N,C?v:!1,!1,function(O){A(null,k(O))})}P(d,E,function(N,A){return m(A.join(""))})};function P(d,v,m){for(var C=new Array(d.length),k=n(d.length,m),E=function(A,O,B){v(O,function(D,G){C[A]=G,B(D,C)})},N=0;N<d.length;N++)E(N,d[N],k)}t.decodePayload=function(d,v,m){if(typeof d!="string")return t.decodePayloadAsBinary(d,v,m);typeof v=="function"&&(m=v,v=null);var C;if(d==="")return m(p,0,1);for(var k="",E,N,A=0,O=d.length;A<O;A++){var B=d.charAt(A);if(B!==":"){k+=B;continue}if(k===""||k!=(E=Number(k))||(N=d.substr(A+1,E),k!=N.length))return m(p,0,1);if(N.length){if(C=t.decodePacket(N,v,!1),p.type===C.type&&p.data===C.data)return m(p,0,1);var D=m(C,A+E,O);if(D===!1)return}A+=E,k=""}if(k!=="")return m(p,0,1)},t.encodePayloadAsArrayBuffer=function(d,v){if(!d.length)return v(new ArrayBuffer(0));function m(C,k){t.encodePacket(C,!0,!0,function(E){return k(null,E)})}P(d,m,function(C,k){var E=k.reduce(function(O,B){var D;return typeof B=="string"?D=B.length:D=B.byteLength,O+D.toString().length+D+2},0),N=new Uint8Array(E),A=0;return k.forEach(function(O){var B=typeof O=="string",D=O;if(B){for(var G=new Uint8Array(O.length),q=0;q<O.length;q++)G[q]=O.charCodeAt(q);D=G.buffer}B?N[A++]=0:N[A++]=1;for(var Rt=D.byteLength.toString(),q=0;q<Rt.length;q++)N[A++]=parseInt(Rt[q]);N[A++]=255;for(var G=new Uint8Array(D),q=0;q<G.length;q++)N[A++]=G[q]}),v(N.buffer)})},t.encodePayloadAsBlob=function(d,v){function m(C,k){t.encodePacket(C,!0,!0,function(E){var N=new Uint8Array(1);if(N[0]=1,typeof E=="string"){for(var A=new Uint8Array(E.length),O=0;O<E.length;O++)A[O]=E.charCodeAt(O);E=A.buffer,N[0]=0}for(var B=E instanceof ArrayBuffer?E.byteLength:E.size,D=B.toString(),G=new Uint8Array(D.length+1),O=0;O<D.length;O++)G[O]=parseInt(D[O]);if(G[D.length]=255,h){var q=new h([N.buffer,G.buffer,E]);k(null,q)}})}P(d,m,function(C,k){return v(new h(k))})},t.decodePayloadAsBinary=function(d,v,m){typeof v=="function"&&(m=v,v=null);for(var C=d,k=[];C.byteLength>0;){for(var E=new Uint8Array(C),N=E[0]===0,A="",O=1;E[O]!==255;O++){if(A.length>310)return m(p,0,1);A+=E[O]}C=r(C,2+A.length),A=parseInt(A);var B=r(C,0,A);if(N)try{B=String.fromCharCode.apply(null,new Uint8Array(B))}catch{var D=new Uint8Array(B);B="";for(var O=0;O<D.length;O++)B+=String.fromCharCode(D[O])}k.push(B),C=r(C,A)}var G=k.length;k.forEach(function(q,Rt){m(t.decodePacket(q,v,!0),Rt,G)})}})(it);var Xt,Ne;function Jt(){if(Ne)return Xt;Ne=1;var t=it,e=at;Xt=s;function s(r){this.path=r.path,this.hostname=r.hostname,this.port=r.port,this.secure=r.secure,this.query=r.query,this.timestampParam=r.timestampParam,this.timestampRequests=r.timestampRequests,this.readyState="",this.agent=r.agent||!1,this.socket=r.socket,this.enablesXDR=r.enablesXDR,this.withCredentials=r.withCredentials,this.pfx=r.pfx,this.key=r.key,this.passphrase=r.passphrase,this.cert=r.cert,this.ca=r.ca,this.ciphers=r.ciphers,this.rejectUnauthorized=r.rejectUnauthorized,this.forceNode=r.forceNode,this.isReactNative=r.isReactNative,this.extraHeaders=r.extraHeaders,this.localAddress=r.localAddress}return e(s.prototype),s.prototype.onError=function(r,n){var o=new Error(r);return o.type="TransportError",o.description=n,this.emit("error",o),this},s.prototype.open=function(){return(this.readyState==="closed"||this.readyState==="")&&(this.readyState="opening",this.doOpen()),this},s.prototype.close=function(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this},s.prototype.send=function(r){if(this.readyState==="open")this.write(r);else throw new Error("Transport not open")},s.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},s.prototype.onData=function(r){var n=t.decodePacket(r,this.socket.binaryType);this.onPacket(n)},s.prototype.onPacket=function(r){this.emit("packet",r)},s.prototype.onClose=function(){this.readyState="closed",this.emit("close")},Xt}var Yt={},Te;function Nt(){return Te||(Te=1,Yt.encode=function(t){var e="";for(var s in t)t.hasOwnProperty(s)&&(e.length&&(e+="&"),e+=encodeURIComponent(s)+"="+encodeURIComponent(t[s]));return e},Yt.decode=function(t){for(var e={},s=t.split("&"),r=0,n=s.length;r<n;r++){var o=s[r].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}),Yt}var Tt=function(t,e){var s=function(){};s.prototype=e.prototype,t.prototype=new s,t.prototype.constructor=t},Ae="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),At=64,Oe={},Ie=0,et=0,Le;function Qt(t){var e="";do e=Ae[t%At]+e,t=Math.floor(t/At);while(t>0);return e}function Qs(t){var e=0;for(et=0;et<t.length;et++)e=e*At+Oe[t.charAt(et)];return e}function Zt(){var t=Qt(+new Date);return t!==Le?(Ie=0,Le=t):t+"."+Qt(Ie++)}for(;et<At;et++)Oe[Ae[et]]=et;Zt.encode=Qt,Zt.decode=Qs;var Re=Zt,_e=Jt(),Zs=Nt(),Ue=it,tr=Tt,er=Re,z=Q("engine.io-client:polling"),xe=J,sr=function(){var t=Kt,e=new t({xdomain:!1});return e.responseType!=null}();function J(t){var e=t&&t.forceBase64;(!sr||e)&&(this.supportsBinary=!1),_e.call(this,t)}tr(J,_e),J.prototype.name="polling",J.prototype.doOpen=function(){this.poll()},J.prototype.pause=function(t){var e=this;this.readyState="pausing";function s(){z("paused"),e.readyState="paused",t()}if(this.polling||!this.writable){var r=0;this.polling&&(z("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){z("pre-pause polling complete"),--r||s()})),this.writable||(z("we are currently writing - waiting to pause"),r++,this.once("drain",function(){z("pre-pause writing complete"),--r||s()}))}else s()},J.prototype.poll=function(){z("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},J.prototype.onData=function(t){var e=this;z("polling got data %s",t);var s=function(r,n,o){if(e.readyState==="opening"&&r.type==="open"&&e.onOpen(),r.type==="close")return e.onClose(),!1;e.onPacket(r)};Ue.decodePayload(t,this.socket.binaryType,s),this.readyState!=="closed"&&(this.polling=!1,this.emit("pollComplete"),this.readyState==="open"?this.poll():z('ignoring poll - transport state "%s"',this.readyState))},J.prototype.doClose=function(){var t=this;function e(){z("writing close packet"),t.write([{type:"close"}])}this.readyState==="open"?(z("transport open - closing"),e()):(z("transport not open - deferring close"),this.once("open",e))},J.prototype.write=function(t){var e=this;this.writable=!1;var s=function(){e.writable=!0,e.emit("drain")};Ue.encodePayload(t,this.supportsBinary,function(r){e.doWrite(r,s)})},J.prototype.uri=function(){var t=this.query||{},e=this.secure?"https":"http",s="";this.timestampRequests!==!1&&(t[this.timestampParam]=er()),!this.supportsBinary&&!t.sid&&(t.b64=1),t=Zs.encode(t),this.port&&(e==="https"&&Number(this.port)!==443||e==="http"&&Number(this.port)!==80)&&(s=":"+this.port),t.length&&(t="?"+t);var r=this.hostname.indexOf(":")!==-1;return e+"://"+(r?"["+this.hostname+"]":this.hostname)+s+this.path+t};var rr=Kt,Be=xe,nr=at,or=Tt,te=Q("engine.io-client:polling-xhr"),ir=Wt;Gt.exports=ht,Gt.exports.Request=F;function De(){}function ht(t){if(Be.call(this,t),this.requestTimeout=t.requestTimeout,this.extraHeaders=t.extraHeaders,typeof location<"u"){var e=location.protocol==="https:",s=location.port;s||(s=e?443:80),this.xd=typeof location<"u"&&t.hostname!==location.hostname||s!==t.port,this.xs=t.secure!==e}}or(ht,Be),ht.prototype.supportsBinary=!0,ht.prototype.request=function(t){return t=t||{},t.uri=this.uri(),t.xd=this.xd,t.xs=this.xs,t.agent=this.agent||!1,t.supportsBinary=this.supportsBinary,t.enablesXDR=this.enablesXDR,t.withCredentials=this.withCredentials,t.pfx=this.pfx,t.key=this.key,t.passphrase=this.passphrase,t.cert=this.cert,t.ca=this.ca,t.ciphers=this.ciphers,t.rejectUnauthorized=this.rejectUnauthorized,t.requestTimeout=this.requestTimeout,t.extraHeaders=this.extraHeaders,new F(t)},ht.prototype.doWrite=function(t,e){var s=typeof t!="string"&&t!==void 0,r=this.request({method:"POST",data:t,isBinary:s}),n=this;r.on("success",e),r.on("error",function(o){n.onError("xhr post error",o)}),this.sendXhr=r},ht.prototype.doPoll=function(){te("xhr poll");var t=this.request(),e=this;t.on("data",function(s){e.onData(s)}),t.on("error",function(s){e.onError("xhr poll error",s)}),this.pollXhr=t};function F(t){this.method=t.method||"GET",this.uri=t.uri,this.xd=!!t.xd,this.xs=!!t.xs,this.async=t.async!==!1,this.data=t.data!==void 0?t.data:null,this.agent=t.agent,this.isBinary=t.isBinary,this.supportsBinary=t.supportsBinary,this.enablesXDR=t.enablesXDR,this.withCredentials=t.withCredentials,this.requestTimeout=t.requestTimeout,this.pfx=t.pfx,this.key=t.key,this.passphrase=t.passphrase,this.cert=t.cert,this.ca=t.ca,this.ciphers=t.ciphers,this.rejectUnauthorized=t.rejectUnauthorized,this.extraHeaders=t.extraHeaders,this.create()}if(nr(F.prototype),F.prototype.create=function(){var t={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};t.pfx=this.pfx,t.key=this.key,t.passphrase=this.passphrase,t.cert=this.cert,t.ca=this.ca,t.ciphers=this.ciphers,t.rejectUnauthorized=this.rejectUnauthorized;var e=this.xhr=new rr(t),s=this;try{te("xhr open %s: %s",this.method,this.uri),e.open(this.method,this.uri,this.async);try{if(this.extraHeaders){e.setDisableHeaderCheck&&e.setDisableHeaderCheck(!0);for(var r in this.extraHeaders)this.extraHeaders.hasOwnProperty(r)&&e.setRequestHeader(r,this.extraHeaders[r])}}catch{}if(this.method==="POST")try{this.isBinary?e.setRequestHeader("Content-type","application/octet-stream"):e.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{e.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in e&&(e.withCredentials=this.withCredentials),this.requestTimeout&&(e.timeout=this.requestTimeout),this.hasXDR()?(e.onload=function(){s.onLoad()},e.onerror=function(){s.onError(e.responseText)}):e.onreadystatechange=function(){if(e.readyState===2)try{var n=e.getResponseHeader("Content-Type");(s.supportsBinary&&n==="application/octet-stream"||n==="application/octet-stream; charset=UTF-8")&&(e.responseType="arraybuffer")}catch{}e.readyState===4&&(e.status===200||e.status===1223?s.onLoad():setTimeout(function(){s.onError(typeof e.status=="number"?e.status:0)},0))},te("xhr data %s",this.data),e.send(this.data)}catch(n){setTimeout(function(){s.onError(n)},0);return}typeof document<"u"&&(this.index=F.requestsCount++,F.requests[this.index]=this)},F.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},F.prototype.onData=function(t){this.emit("data",t),this.onSuccess()},F.prototype.onError=function(t){this.emit("error",t),this.cleanup(!0)},F.prototype.cleanup=function(t){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=De:this.xhr.onreadystatechange=De,t)try{this.xhr.abort()}catch{}typeof document<"u"&&delete F.requests[this.index],this.xhr=null}},F.prototype.onLoad=function(){var t;try{var e;try{e=this.xhr.getResponseHeader("Content-Type")}catch{}e==="application/octet-stream"||e==="application/octet-stream; charset=UTF-8"?t=this.xhr.response||this.xhr.responseText:t=this.xhr.responseText}catch(s){this.onError(s)}t!=null&&this.onData(t)},F.prototype.hasXDR=function(){return typeof XDomainRequest<"u"&&!this.xs&&this.enablesXDR},F.prototype.abort=function(){this.cleanup()},F.requestsCount=0,F.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Fe);else if(typeof addEventListener=="function"){var ar="onpagehide"in ir?"pagehide":"unload";addEventListener(ar,Fe,!1)}}function Fe(){for(var t in F.requests)F.requests.hasOwnProperty(t)&&F.requests[t].abort()}var cr=Gt.exports,ee=xe,hr=Tt,Pe=Wt,pr=pt,lr=/\n/g,ur=/\\n/g,Ot;function fr(){}function pt(t){ee.call(this,t),this.query=this.query||{},Ot||(Ot=Pe.___eio=Pe.___eio||[]),this.index=Ot.length;var e=this;Ot.push(function(s){e.onData(s)}),this.query.j=this.index,typeof addEventListener=="function"&&addEventListener("beforeunload",function(){e.script&&(e.script.onerror=fr)},!1)}hr(pt,ee),pt.prototype.supportsBinary=!1,pt.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),ee.prototype.doClose.call(this)},pt.prototype.doPoll=function(){var t=this,e=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=function(n){t.onError("jsonp poll error",n)};var s=document.getElementsByTagName("script")[0];s?s.parentNode.insertBefore(e,s):(document.head||document.body).appendChild(e),this.script=e;var r=typeof navigator<"u"&&/gecko/i.test(navigator.userAgent);r&&setTimeout(function(){var n=document.createElement("iframe");document.body.appendChild(n),document.body.removeChild(n)},100)},pt.prototype.doWrite=function(t,e){var s=this;if(!this.form){var r=document.createElement("form"),n=document.createElement("textarea"),o=this.iframeId="eio_iframe_"+this.index,u;r.className="socketio",r.style.position="absolute",r.style.top="-1000px",r.style.left="-1000px",r.target=o,r.method="POST",r.setAttribute("accept-charset","utf-8"),n.name="d",r.appendChild(n),document.body.appendChild(r),this.form=r,this.area=n}this.form.action=this.uri();function a(){f(),e()}function f(){if(s.iframe)try{s.form.removeChild(s.iframe)}catch(c){s.onError("jsonp polling iframe removal error",c)}try{var i='<iframe src="javascript:0" name="'+s.iframeId+'">';u=document.createElement(i)}catch{u=document.createElement("iframe"),u.name=s.iframeId,u.src="javascript:0"}u.id=s.iframeId,s.form.appendChild(u),s.iframe=u}f(),t=t.replace(ur,`\\
7
- `),this.area.value=t.replace(lr,"\\n");try{this.form.submit()}catch{}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){s.iframe.readyState==="complete"&&a()}:this.iframe.onload=a};const dr={},gr=Object.freeze(Object.defineProperty({__proto__:null,default:dr},Symbol.toStringTag,{value:"Module"})),yr=gs(gr);var se=Jt(),vr=it,mr=Nt(),Cr=Tt,Sr=Re,kr=Q("engine.io-client:websocket"),It,re;if(typeof WebSocket<"u"?It=WebSocket:typeof self<"u"&&(It=self.WebSocket||self.MozWebSocket),typeof window>"u")try{re=yr}catch{}var lt=It||re,wr=V;function V(t){var e=t&&t.forceBase64;e&&(this.supportsBinary=!1),this.perMessageDeflate=t.perMessageDeflate,this.usingBrowserWebSocket=It&&!t.forceNode,this.protocols=t.protocols,this.usingBrowserWebSocket||(lt=re),se.call(this,t)}Cr(V,se),V.prototype.name="websocket",V.prototype.supportsBinary=!0,V.prototype.doOpen=function(){if(this.check()){var t=this.uri(),e=this.protocols,s={};this.isReactNative||(s.agent=this.agent,s.perMessageDeflate=this.perMessageDeflate,s.pfx=this.pfx,s.key=this.key,s.passphrase=this.passphrase,s.cert=this.cert,s.ca=this.ca,s.ciphers=this.ciphers,s.rejectUnauthorized=this.rejectUnauthorized),this.extraHeaders&&(s.headers=this.extraHeaders),this.localAddress&&(s.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?e?new lt(t,e):new lt(t):new lt(t,e,s)}catch(r){return this.emit("error",r)}this.ws.binaryType===void 0&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},V.prototype.addEventListeners=function(){var t=this;this.ws.onopen=function(){t.onOpen()},this.ws.onclose=function(){t.onClose()},this.ws.onmessage=function(e){t.onData(e.data)},this.ws.onerror=function(e){t.onError("websocket error",e)}},V.prototype.write=function(t){var e=this;this.writable=!1;for(var s=t.length,r=0,n=s;r<n;r++)(function(u){vr.encodePacket(u,e.supportsBinary,function(a){if(!e.usingBrowserWebSocket){var f={};if(u.options&&(f.compress=u.options.compress),e.perMessageDeflate){var i=typeof a=="string"?Buffer.byteLength(a):a.length;i<e.perMessageDeflate.threshold&&(f.compress=!1)}}try{e.usingBrowserWebSocket?e.ws.send(a):e.ws.send(a,f)}catch{kr("websocket closed before onclose event")}--s||o()})})(t[r]);function o(){e.emit("flush"),setTimeout(function(){e.writable=!0,e.emit("drain")},0)}},V.prototype.onClose=function(){se.prototype.onClose.call(this)},V.prototype.doClose=function(){typeof this.ws<"u"&&this.ws.close()},V.prototype.uri=function(){var t=this.query||{},e=this.secure?"wss":"ws",s="";this.port&&(e==="wss"&&Number(this.port)!==443||e==="ws"&&Number(this.port)!==80)&&(s=":"+this.port),this.timestampRequests&&(t[this.timestampParam]=Sr()),this.supportsBinary||(t.b64=1),t=mr.encode(t),t.length&&(t="?"+t);var r=this.hostname.indexOf(":")!==-1;return e+"://"+(r?"["+this.hostname+"]":this.hostname)+s+this.path+t},V.prototype.check=function(){return!!lt&&!("__initialize"in lt&&this.name===V.prototype.name)};var Er=Kt,br=cr,Nr=pr,Tr=wr;wt.polling=Ar,wt.websocket=Tr;function Ar(t){var e,s=!1,r=!1,n=t.jsonp!==!1;if(typeof location<"u"){var o=location.protocol==="https:",u=location.port;u||(u=o?443:80),s=t.hostname!==location.hostname||u!==t.port,r=t.secure!==o}if(t.xdomain=s,t.xscheme=r,e=new Er(t),"open"in e&&!t.forceJSONP)return new br(t);if(!n)throw new Error("JSONP disabled");return new Nr(t)}var Or=[].indexOf,Me=function(t,e){if(Or)return t.indexOf(e);for(var s=0;s<t.length;++s)if(t[s]===e)return s;return-1},Ir=wt,Lr=at,x=Q("engine.io-client:socket"),Rr=Me,je=it,qe=fe,_r=Nt(),Ur=T;function T(t,e){if(!(this instanceof T))return new T(t,e);e=e||{},t&&typeof t=="object"&&(e=t,t=null),t?(t=qe(t),e.hostname=t.host,e.secure=t.protocol==="https"||t.protocol==="wss",e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=qe(e.host).host),this.secure=e.secure!=null?e.secure:typeof location<"u"&&location.protocol==="https:",e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.agent=e.agent||!1,this.hostname=e.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=e.port||(typeof location<"u"&&location.port?location.port:this.secure?443:80),this.query=e.query||{},typeof this.query=="string"&&(this.query=_r.decode(this.query)),this.upgrade=e.upgrade!==!1,this.path=(e.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!e.forceJSONP,this.jsonp=e.jsonp!==!1,this.forceBase64=!!e.forceBase64,this.enablesXDR=!!e.enablesXDR,this.withCredentials=e.withCredentials!==!1,this.timestampParam=e.timestampParam||"t",this.timestampRequests=e.timestampRequests,this.transports=e.transports||["polling","websocket"],this.transportOptions=e.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=e.policyPort||843,this.rememberUpgrade=e.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=e.onlyBinaryUpgrades,this.perMessageDeflate=e.perMessageDeflate!==!1?e.perMessageDeflate||{}:!1,this.perMessageDeflate===!0&&(this.perMessageDeflate={}),this.perMessageDeflate&&this.perMessageDeflate.threshold==null&&(this.perMessageDeflate.threshold=1024),this.pfx=e.pfx||void 0,this.key=e.key||void 0,this.passphrase=e.passphrase||void 0,this.cert=e.cert||void 0,this.ca=e.ca||void 0,this.ciphers=e.ciphers||void 0,this.rejectUnauthorized=e.rejectUnauthorized===void 0?!0:e.rejectUnauthorized,this.forceNode=!!e.forceNode,this.isReactNative=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",(typeof self>"u"||this.isReactNative)&&(e.extraHeaders&&Object.keys(e.extraHeaders).length>0&&(this.extraHeaders=e.extraHeaders),e.localAddress&&(this.localAddress=e.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}T.priorWebsocketSuccess=!1,Lr(T.prototype),T.protocol=je.protocol,T.Socket=T,T.Transport=Jt(),T.transports=wt,T.parser=it,T.prototype.createTransport=function(t){x('creating transport "%s"',t);var e=xr(this.query);e.EIO=je.protocol,e.transport=t;var s=this.transportOptions[t]||{};this.id&&(e.sid=this.id);var r=new Ir[t]({query:e,socket:this,agent:s.agent||this.agent,hostname:s.hostname||this.hostname,port:s.port||this.port,secure:s.secure||this.secure,path:s.path||this.path,forceJSONP:s.forceJSONP||this.forceJSONP,jsonp:s.jsonp||this.jsonp,forceBase64:s.forceBase64||this.forceBase64,enablesXDR:s.enablesXDR||this.enablesXDR,withCredentials:s.withCredentials||this.withCredentials,timestampRequests:s.timestampRequests||this.timestampRequests,timestampParam:s.timestampParam||this.timestampParam,policyPort:s.policyPort||this.policyPort,pfx:s.pfx||this.pfx,key:s.key||this.key,passphrase:s.passphrase||this.passphrase,cert:s.cert||this.cert,ca:s.ca||this.ca,ciphers:s.ciphers||this.ciphers,rejectUnauthorized:s.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:s.perMessageDeflate||this.perMessageDeflate,extraHeaders:s.extraHeaders||this.extraHeaders,forceNode:s.forceNode||this.forceNode,localAddress:s.localAddress||this.localAddress,requestTimeout:s.requestTimeout||this.requestTimeout,protocols:s.protocols||void 0,isReactNative:this.isReactNative});return r};function xr(t){var e={};for(var s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e}T.prototype.open=function(){var t;if(this.rememberUpgrade&&T.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)t="websocket";else if(this.transports.length===0){var e=this;setTimeout(function(){e.emit("error","No transports available")},0);return}else t=this.transports[0];this.readyState="opening";try{t=this.createTransport(t)}catch{this.transports.shift(),this.open();return}t.open(),this.setTransport(t)},T.prototype.setTransport=function(t){x("setting transport %s",t.name);var e=this;this.transport&&(x("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on("drain",function(){e.onDrain()}).on("packet",function(s){e.onPacket(s)}).on("error",function(s){e.onError(s)}).on("close",function(){e.onClose("transport close")})},T.prototype.probe=function(t){x('probing transport "%s"',t);var e=this.createTransport(t,{probe:1}),s=!1,r=this;T.priorWebsocketSuccess=!1;function n(){if(r.onlyBinaryUpgrades){var l=!this.supportsBinary&&r.transport.supportsBinary;s=s||l}s||(x('probe transport "%s" opened',t),e.send([{type:"ping",data:"probe"}]),e.once("packet",function(p){if(!s)if(p.type==="pong"&&p.data==="probe"){if(x('probe transport "%s" pong',t),r.upgrading=!0,r.emit("upgrading",e),!e)return;T.priorWebsocketSuccess=e.name==="websocket",x('pausing current transport "%s"',r.transport.name),r.transport.pause(function(){s||r.readyState!=="closed"&&(x("changing transport and sending upgrade packet"),c(),r.setTransport(e),e.send([{type:"upgrade"}]),r.emit("upgrade",e),e=null,r.upgrading=!1,r.flush())})}else{x('probe transport "%s" failed',t);var h=new Error("probe error");h.transport=e.name,r.emit("upgradeError",h)}}))}function o(){s||(s=!0,c(),e.close(),e=null)}function u(l){var p=new Error("probe error: "+l);p.transport=e.name,o(),x('probe transport "%s" failed because of error: %s',t,l),r.emit("upgradeError",p)}function a(){u("transport closed")}function f(){u("socket closed")}function i(l){e&&l.name!==e.name&&(x('"%s" works - aborting "%s"',l.name,e.name),o())}function c(){e.removeListener("open",n),e.removeListener("error",u),e.removeListener("close",a),r.removeListener("close",f),r.removeListener("upgrading",i)}e.once("open",n),e.once("error",u),e.once("close",a),this.once("close",f),this.once("upgrading",i),e.open()},T.prototype.onOpen=function(){if(x("socket open"),this.readyState="open",T.priorWebsocketSuccess=this.transport.name==="websocket",this.emit("open"),this.flush(),this.readyState==="open"&&this.upgrade&&this.transport.pause){x("starting upgrade probes");for(var t=0,e=this.upgrades.length;t<e;t++)this.probe(this.upgrades[t])}},T.prototype.onPacket=function(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(x('socket receive: type "%s", data "%s"',t.type,t.data),this.emit("packet",t),this.emit("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emit("data",t.data),this.emit("message",t.data);break}else x('packet received with socket readyState "%s"',this.readyState)},T.prototype.onHandshake=function(t){this.emit("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),this.readyState!=="closed"&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},T.prototype.onHeartbeat=function(t){clearTimeout(this.pingTimeoutTimer);var e=this;e.pingTimeoutTimer=setTimeout(function(){e.readyState!=="closed"&&e.onClose("ping timeout")},t||e.pingInterval+e.pingTimeout)},T.prototype.setPing=function(){var t=this;clearTimeout(t.pingIntervalTimer),t.pingIntervalTimer=setTimeout(function(){x("writing ping packet - expecting pong within %sms",t.pingTimeout),t.ping(),t.onHeartbeat(t.pingTimeout)},t.pingInterval)},T.prototype.ping=function(){var t=this;this.sendPacket("ping",function(){t.emit("ping")})},T.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emit("drain"):this.flush()},T.prototype.flush=function(){this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(x("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},T.prototype.write=T.prototype.send=function(t,e,s){return this.sendPacket("message",t,e,s),this},T.prototype.sendPacket=function(t,e,s,r){if(typeof e=="function"&&(r=e,e=void 0),typeof s=="function"&&(r=s,s=null),!(this.readyState==="closing"||this.readyState==="closed")){s=s||{},s.compress=s.compress!==!1;var n={type:t,data:e,options:s};this.emit("packetCreate",n),this.writeBuffer.push(n),r&&this.once("flush",r),this.flush()}},T.prototype.close=function(){if(this.readyState==="opening"||this.readyState==="open"){this.readyState="closing";var t=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?r():e()}):this.upgrading?r():e()}function e(){t.onClose("forced close"),x("socket closing - telling transport to close"),t.transport.close()}function s(){t.removeListener("upgrade",s),t.removeListener("upgradeError",s),e()}function r(){t.once("upgrade",s),t.once("upgradeError",s)}return this},T.prototype.onError=function(t){x("socket error %j",t),T.priorWebsocketSuccess=!1,this.emit("error",t),this.onClose("transport error",t)},T.prototype.onClose=function(t,e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){x('socket close with reason: "%s"',t);var s=this;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",t,e),s.writeBuffer=[],s.prevBufferLen=0}},T.prototype.filterUpgrades=function(t){for(var e=[],s=0,r=t.length;s<r;s++)~Rr(this.transports,t[s])&&e.push(t[s]);return e},jt.exports=Ur,jt.exports.parser=it;var Br=jt.exports,We={exports:{}},ne,Ke;function Dr(){if(Ke)return ne;Ke=1,ne=t;function t(e,s){var r=[];s=s||0;for(var n=s||0;n<e.length;n++)r[n-s]=e[n];return r}return ne}var Ge=Fr;function Fr(t,e,s){return t.on(e,s),{destroy:function(){t.removeListener(e,s)}}}var He=[].slice,Ve=function(t,e){if(typeof e=="string"&&(e=t[e]),typeof e!="function")throw new Error("bind() requires a function");var s=He.call(arguments,2);return function(){return e.apply(t,s.concat(He.call(arguments)))}},ze;function $e(){return ze||(ze=1,function(t,e){var s=St,r=at,n=Dr(),o=Ge,u=Ve,a=Q("socket.io-client:socket"),f=Nt(),i=Se();t.exports=p;var c={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},l=r.prototype.emit;function p(h,w,S){this.io=h,this.nsp=w,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},S&&S.query&&(this.query=S.query),this.io.autoConnect&&this.open()}r(p.prototype),p.prototype.subEvents=function(){if(!this.subs){var h=this.io;this.subs=[o(h,"open",u(this,"onopen")),o(h,"packet",u(this,"onpacket")),o(h,"close",u(this,"onclose"))]}},p.prototype.open=p.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.reconnecting||this.io.open(),this.io.readyState==="open"&&this.onopen(),this.emit("connecting"),this)},p.prototype.send=function(){var h=n(arguments);return h.unshift("message"),this.emit.apply(this,h),this},p.prototype.emit=function(h){if(c.hasOwnProperty(h))return l.apply(this,arguments),this;var w=n(arguments),S={type:(this.flags.binary!==void 0?this.flags.binary:i(w))?s.BINARY_EVENT:s.EVENT,data:w};return S.options={},S.options.compress=!this.flags||this.flags.compress!==!1,typeof w[w.length-1]=="function"&&(a("emitting packet with ack id %d",this.ids),this.acks[this.ids]=w.pop(),S.id=this.ids++),this.connected?this.packet(S):this.sendBuffer.push(S),this.flags={},this},p.prototype.packet=function(h){h.nsp=this.nsp,this.io.packet(h)},p.prototype.onopen=function(){if(a("transport is open - connecting"),this.nsp!=="/")if(this.query){var h=typeof this.query=="object"?f.encode(this.query):this.query;a("sending connect packet with query %s",h),this.packet({type:s.CONNECT,query:h})}else this.packet({type:s.CONNECT})},p.prototype.onclose=function(h){a("close (%s)",h),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",h)},p.prototype.onpacket=function(h){var w=h.nsp===this.nsp,S=h.type===s.ERROR&&h.nsp==="/";if(!(!w&&!S))switch(h.type){case s.CONNECT:this.onconnect();break;case s.EVENT:this.onevent(h);break;case s.BINARY_EVENT:this.onevent(h);break;case s.ACK:this.onack(h);break;case s.BINARY_ACK:this.onack(h);break;case s.DISCONNECT:this.ondisconnect();break;case s.ERROR:this.emit("error",h.data);break}},p.prototype.onevent=function(h){var w=h.data||[];a("emitting event %j",w),h.id!=null&&(a("attaching ack callback to event"),w.push(this.ack(h.id))),this.connected?l.apply(this,w):this.receiveBuffer.push(w)},p.prototype.ack=function(h){var w=this,S=!1;return function(){if(!S){S=!0;var g=n(arguments);a("sending ack %j",g),w.packet({type:i(g)?s.BINARY_ACK:s.ACK,id:h,data:g})}}},p.prototype.onack=function(h){var w=this.acks[h.id];typeof w=="function"?(a("calling ack %s with %j",h.id,h.data),w.apply(this,h.data),delete this.acks[h.id]):a("bad ack %s",h.id)},p.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emit("connect")},p.prototype.emitBuffered=function(){var h;for(h=0;h<this.receiveBuffer.length;h++)l.apply(this,this.receiveBuffer[h]);for(this.receiveBuffer=[],h=0;h<this.sendBuffer.length;h++)this.packet(this.sendBuffer[h]);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 h=0;h<this.subs.length;h++)this.subs[h].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:s.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},p.prototype.compress=function(h){return this.flags.compress=h,this},p.prototype.binary=function(h){return this.flags.binary=h,this}}(We)),We.exports}var Pr=ut;function ut(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}ut.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),s=Math.floor(e*this.jitter*t);t=Math.floor(e*10)&1?t+s:t-s}return Math.min(t,this.max)|0},ut.prototype.reset=function(){this.attempts=0},ut.prototype.setMin=function(t){this.ms=t},ut.prototype.setMax=function(t){this.max=t},ut.prototype.setJitter=function(t){this.jitter=t};var Mr=Br,jr=$e(),qr=at,Wr=St,st=Ge,ft=Ve,j=Q("socket.io-client:manager"),Xe=Me,Kr=Pr,Je=Object.prototype.hasOwnProperty,Ye=I;function I(t,e){if(!(this instanceof I))return new I(t,e);t&&typeof t=="object"&&(e=t,t=void 0),e=e||{},e.path=e.path||"/socket.io",this.nsps={},this.subs=[],this.opts=e,this.reconnection(e.reconnection!==!1),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(e.randomizationFactor||.5),this.backoff=new Kr({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(e.timeout==null?2e4:e.timeout),this.readyState="closed",this.uri=t,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var s=e.parser||Wr;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this.autoConnect=e.autoConnect!==!1,this.autoConnect&&this.open()}I.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var t in this.nsps)Je.call(this.nsps,t)&&this.nsps[t].emit.apply(this.nsps[t],arguments)},I.prototype.updateSocketIds=function(){for(var t in this.nsps)Je.call(this.nsps,t)&&(this.nsps[t].id=this.generateId(t))},I.prototype.generateId=function(t){return(t==="/"?"":t+"#")+this.engine.id},qr(I.prototype),I.prototype.reconnection=function(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection},I.prototype.reconnectionAttempts=function(t){return arguments.length?(this._reconnectionAttempts=t,this):this._reconnectionAttempts},I.prototype.reconnectionDelay=function(t){return arguments.length?(this._reconnectionDelay=t,this.backoff&&this.backoff.setMin(t),this):this._reconnectionDelay},I.prototype.randomizationFactor=function(t){return arguments.length?(this._randomizationFactor=t,this.backoff&&this.backoff.setJitter(t),this):this._randomizationFactor},I.prototype.reconnectionDelayMax=function(t){return arguments.length?(this._reconnectionDelayMax=t,this.backoff&&this.backoff.setMax(t),this):this._reconnectionDelayMax},I.prototype.timeout=function(t){return arguments.length?(this._timeout=t,this):this._timeout},I.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()},I.prototype.open=I.prototype.connect=function(t,e){if(j("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;j("opening %s",this.uri),this.engine=Mr(this.uri,this.opts);var s=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var n=st(s,"open",function(){r.onopen(),t&&t()}),o=st(s,"error",function(f){if(j("connect_error"),r.cleanup(),r.readyState="closed",r.emitAll("connect_error",f),t){var i=new Error("Connection error");i.data=f,t(i)}else r.maybeReconnectOnOpen()});if(this._timeout!==!1){var u=this._timeout;j("connect attempt will timeout after %d",u),u===0&&n.destroy();var a=setTimeout(function(){j("connect attempt timed out after %d",u),n.destroy(),s.close(),s.emit("error","timeout"),r.emitAll("connect_timeout",u)},u);this.subs.push({destroy:function(){clearTimeout(a)}})}return this.subs.push(n),this.subs.push(o),this},I.prototype.onopen=function(){j("open"),this.cleanup(),this.readyState="open",this.emit("open");var t=this.engine;this.subs.push(st(t,"data",ft(this,"ondata"))),this.subs.push(st(t,"ping",ft(this,"onping"))),this.subs.push(st(t,"pong",ft(this,"onpong"))),this.subs.push(st(t,"error",ft(this,"onerror"))),this.subs.push(st(t,"close",ft(this,"onclose"))),this.subs.push(st(this.decoder,"decoded",ft(this,"ondecoded")))},I.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},I.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},I.prototype.ondata=function(t){this.decoder.add(t)},I.prototype.ondecoded=function(t){this.emit("packet",t)},I.prototype.onerror=function(t){j("error",t),this.emitAll("error",t)},I.prototype.socket=function(t,e){var s=this.nsps[t];if(!s){s=new jr(this,t,e),this.nsps[t]=s;var r=this;s.on("connecting",n),s.on("connect",function(){s.id=r.generateId(t)}),this.autoConnect&&n()}function n(){~Xe(r.connecting,s)||r.connecting.push(s)}return s},I.prototype.destroy=function(t){var e=Xe(this.connecting,t);~e&&this.connecting.splice(e,1),!this.connecting.length&&this.close()},I.prototype.packet=function(t){j("writing packet %j",t);var e=this;t.query&&t.type===0&&(t.nsp+="?"+t.query),e.encoding?e.packetBuffer.push(t):(e.encoding=!0,this.encoder.encode(t,function(s){for(var r=0;r<s.length;r++)e.engine.write(s[r],t.options);e.encoding=!1,e.processPacketQueue()}))},I.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var t=this.packetBuffer.shift();this.packet(t)}},I.prototype.cleanup=function(){j("cleanup");for(var t=this.subs.length,e=0;e<t;e++){var s=this.subs.shift();s.destroy()}this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},I.prototype.close=I.prototype.disconnect=function(){j("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,this.readyState==="opening"&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},I.prototype.onclose=function(t){j("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",t),this._reconnection&&!this.skipReconnect&&this.reconnect()},I.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var t=this;if(this.backoff.attempts>=this._reconnectionAttempts)j("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var e=this.backoff.duration();j("will wait %dms before reconnect attempt",e),this.reconnecting=!0;var s=setTimeout(function(){t.skipReconnect||(j("attempting reconnect"),t.emitAll("reconnect_attempt",t.backoff.attempts),t.emitAll("reconnecting",t.backoff.attempts),!t.skipReconnect&&t.open(function(r){r?(j("reconnect attempt error"),t.reconnecting=!1,t.reconnect(),t.emitAll("reconnect_error",r.data)):(j("reconnect success"),t.onreconnect())}))},e);this.subs.push({destroy:function(){clearTimeout(s)}})}},I.prototype.onreconnect=function(){var t=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",t)},function(t,e){var s=As,r=St,n=Ye,o=Q("socket.io-client");t.exports=e=a;var u=e.managers={};function a(f,i){typeof f=="object"&&(i=f,f=void 0),i=i||{};var c=s(f),l=c.source,p=c.id,h=c.path,w=u[p]&&h in u[p].nsps,S=i.forceNew||i["force new connection"]||i.multiplex===!1||w,g;return S?(o("ignoring socket cache for %s",l),g=n(l,i)):(u[p]||(o("new io instance for %s",l),u[p]=n(l,i)),g=u[p]),c.query&&!i.query&&(i.query=c.query),g.socket(c.path,i)}e.protocol=r.protocol,e.connect=a,e.Manager=Ye,e.Socket=$e()}(Ut,Ut.exports);var Gr=Ut.exports;const Hr=ds(Gr);let Lt;const Vr=new Uint8Array(16);function zr(){if(!Lt&&(Lt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Lt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Lt(Vr)}const M=[];for(let t=0;t<256;++t)M.push((t+256).toString(16).slice(1));function $r(t,e=0){return M[t[e+0]]+M[t[e+1]]+M[t[e+2]]+M[t[e+3]]+"-"+M[t[e+4]]+M[t[e+5]]+"-"+M[t[e+6]]+M[t[e+7]]+"-"+M[t[e+8]]+M[t[e+9]]+"-"+M[t[e+10]]+M[t[e+11]]+M[t[e+12]]+M[t[e+13]]+M[t[e+14]]+M[t[e+15]]}const Xr=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Qe={randomUUID:Xr};function Jr(t,e,s){if(Qe.randomUUID&&!e&&!t)return Qe.randomUUID();t=t||{};const r=t.random||(t.rng||zr)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){s=s||0;for(let n=0;n<16;++n)e[s+n]=r[n];return e}return $r(r)}function Yr(t,e){const s=e.map(n=>JSON.stringify(n)).join(" "),r=new Date().toISOString();return JSON.stringify({level:t,time:r,message:s})}function Qr(t,e){const s=JSON.parse(t);return e.forEach(r=>delete s[r]),s}function Zr(t){if(typeof t=="object"&&t!==null)return t;try{return JSON.parse(t)}catch{return{extraData:t}}}function tn(t){const e=/\(([^)]+)\)/,s=t.match(e);if(s&&s[1]){const r=s[1].split(";");for(let n of r)if(n=n.trim(),n.startsWith("Windows")||n.startsWith("Macintosh")||n.startsWith("Linux"))return n}return"Unknown"}function Ze(t){return(...e)=>new Promise((s,r)=>{try{const n=t(...e);s(n)}catch(n){r(n)}})}const en={reconnection:!0,reconnectionDelay:5e3,reconnectionAttempts:10,upgrade:!1,transports:["websocket"],debug:!1},oe={logToConsole:!0,overloadGlobalConsole:!1,socketEmitInterval:6e4},$={CREATE:"Create",READ:"Read",UPDATE:"Update",DELETE:"Delete",CONVERT:"Convert",DOWNLOAD:"Download",UPLOAD:"Upload",ENCRYPT:"Encrypt",DECRYPT:"Decrypt",FILTER:"Filter",INPUT:"Input",OUTPUT:"Output",PLUGIN:"Plugin",LOGIN:"Login",LOGOUT:"Logout",REFRESH:"Refresh",CHECK:"Check",WEBHOOK:"Webhook",WSCONNECT:"WSConnect"},sn={Create:1,Read:2,Update:3,Delete:4,Convert:5,Download:6,Upload:7,Encrypt:8,Decrypt:9,Filter:10,Input:11,Output:12,Plugin:13,Login:14,Logout:15,Refresh:16,Check:17,Webhook:18,WSConnect:19},X={INFO:"info",WARNING:"warning",MODIFY:"modify",ERROR:"error",VIEW:"view"},W={INFO:"info",WARNING:"warning",ERROR:"error",DEBUG:"debug"};let K=console;class rn{constructor(e){_(this,"logToConsole"),_(this,"overloadGlobalConsole"),_(this,"system"),_(this,"socketEmitInterval"),_(this,"storageId"),_(this,"emitInProgress"),_(this,"queue"),_(this,"processing"),_(this,"storageInitialized"),_(this,"interval"),_(this,"logIndex"),_(this,"socket"),_(this,"staticObject",{}),_(this,"localObject",{}),_(this,"isGetItemAsync"),_(this,"isSetItemAsync"),_(this,"getItem"),_(this,"setItem"),_(this,"parseLog"),_(this,"_logMethod"),_(this,"_warnMethod"),_(this,"_errorMethod"),_(this,"_debugMethod");const{loggerOptions:s}=e;if(!s.system)throw new Error("Config property 'system' should be provided!");this.isGetItemAsync=s.isGetItemAsync||!1,this.isSetItemAsync=s.isSetItemAsync||!1,this.setupStorageFunctions(s.getItem,s.setItem,s.parseLog),this.system=s.system,this.socketEmitInterval=s.socketEmitInterval||oe.socketEmitInterval,this.logToConsole=s.logToConsole!==void 0?s.logToConsole:oe.logToConsole,this.overloadGlobalConsole=s.overloadGlobalConsole!==void 0?s.overloadGlobalConsole:oe.overloadGlobalConsole,this.storageId=this.getStorageName(),this.queue=[],this.processing=!1,this.storageInitialized=!1,this.emitInProgress=!1,this.logIndex=0,this.init(e)}setupStorageFunctions(e,s,r){this.getItem=e&&typeof e=="function"?this.isGetItemAsync?e:Ze(e):this.defaultGetItemFunction,this.setItem=s&&typeof s=="function"?this.isSetItemAsync?s:Ze(s):this.defaultSetItemFunction,this.parseLog=r&&typeof r=="function"?r:Yr}init(e){const{socket:s,url:r,socketOptions:n={}}=e;this._logMethod=K.log.bind(K),this._warnMethod=K.warn.bind(K),this._errorMethod=K.error.bind(K),this._debugMethod=K.debug.bind(K),this.initStorage().then(()=>{if(s)this.socket=s;else if(r)this.socket=this.createConnection(r,n);else throw new Error("Must provide either a 'socket' or a 'url' for socket connection");this.interval=setInterval(async()=>{await this.emitLogs()},this.socketEmitInterval),this.overloadGlobalConsole&&this._overloadConsole()})}createConnection(e,s={}){const r={...en,...s};return Hr(e,r)}async emitLogs(){if(!this.emitInProgress)try{const e=await this.getItem(this.storageId),s=JSON.parse(e||"{}"),r={...this.localObject,...s};if(!Object.keys(r).length)return;const n=[];this.emitInProgress=!0;const o=Object.keys(r);if(!o.length)return;if(!this.socket||!this.socket.connected)throw new Error("Socket is disconnected");for(const f of o){const i=Zr(r[f]),c={...this.staticObject,...i},l=this.populateSendingLog(c);await this.socket.emit("Log",JSON.stringify(l)),n.push(f)}const u=await this.getItem(this.storageId);if(!u)return;const a=Qr(u,n);this.localObject={},await this.setItem(this.storageId,JSON.stringify(a))}catch(e){this._errorMethod(e)}finally{this.emitInProgress=!1}}populateSendingLog(e){const s={...e},r=s.ActionName;return r&&(s.ActionID=sn[r]),s}setupStaticFields(e){this.staticObject={...e}}populateMetaData(){const e=new Date;let s;typeof window<"u"&&typeof window.document<"u"?s=window==null?void 0:window.navigator.userAgent:typeof self<"u"&&self.navigator&&(s=self.navigator.userAgent);let r;return s&&(r=tn(s)),{System:this.system,DateTime:e,UserAgent:s,OSVersion:r}}async stop(){!this.socket||!this.socket.connected||(clearInterval(this.interval),await this.emitLogs(),this.socket.disconnect())}async start(){this.socket&&this.socket.connected||(this.socket.connect(),this.interval=setInterval(async()=>{await this.emitLogs()},this.socketEmitInterval))}_overloadConsole(){K=Object.assign(K,{log:e=>{this.log(e)},warn:e=>{this.warn(e)},error:e=>{this.error(e)},debug:e=>{this.debug(e)}})}async initStorage(){const e=await this.getItem(this.storageId);(!e||typeof e!="string")&&(await this.setItem(this.storageId,JSON.stringify({})),this.storageInitialized=!0)}async resetStorage(){await this.setItem(this.storageId,JSON.stringify({}))}getStorageName(){const e=Jr();return this.system.toString().toUpperCase()+e+Date.now()}async processLog(...e){try{if(e.length<2)return;const s=e[0],r=e[1],n=this.formItemKey(s);if(!this.storageInitialized){this.localObject={...this.localObject,[n]:r};return}const o=await this.getItem(this.storageId);if(!o)return;const u=JSON.parse(o);u[n]=JSON.stringify(r),await this.setItem(this.storageId,JSON.stringify(u))}catch(s){this._errorMethod(s)}}async processQueue(){if(this.processing||this.queue.length===0)return;const e=this.queue.shift();e&&(this.processing=!0,await this.processLog(...e).finally(()=>{this.processing=!1,this.processQueue()}))}log(e){const s={...this.populateMetaData(),...e},r=["INFO",s];this.queue.push(r),this.logToConsole&&this._logMethod.apply(K,[s]),this.processQueue()}warn(e){const s=["WARN",e];this.queue.push(s),this.logToConsole&&this._warnMethod.apply(K,[e]),this.processQueue()}error(e){const s=["ERROR",e];this.queue.push(s),this.logToConsole&&this._errorMethod.apply(K,[e]),this.processQueue()}debug(e){const s=["DEBUG",e];this.queue.push(s),this.logToConsole&&this._debugMethod.apply(K,[e]),this.processQueue()}async defaultGetItemFunction(e){return localStorage.getItem(e)}async defaultSetItemFunction(e,s){try{localStorage.setItem(e,s)}catch(r){this._errorMethod(r)}}formItemKey(e){const s=new Date().toISOString();return this.logIndex++,`${e}-${this.system}-${s}-${this.logIndex}`}}class nn{constructor(e){L(this,"delay",1e3);L(this,"lastLoginTimestamp");L(this,"token");L(this,"refreshToken");L(this,"tokenExpiry");L(this,"storageKey");this.eventsSdkClass=e,this.eventsSdkClass=e,this.storageKey=""}async login(){const e={token:this.eventsSdkClass.options.token&&this.eventsSdkClass.options.token,email:this.eventsSdkClass.options.email&&this.eventsSdkClass.options.email,password:this.eventsSdkClass.options.password&&this.eventsSdkClass.options.password};if(this.storageKey=ls(JSON.stringify({...this.eventsSdkClass.options,loggerSocketConnection:null},this.eventsSdkClass.getCircularReplacer())),this.lastLoginTimestamp&&this.lastLoginTimestamp+this.delay>new Date().getTime())return;this.updateLastLoginTimestamp();const s=await this.checkLoginStatus(this.storageKey);return s||(dt.clearSessionStorage(),await this.userLoginFunction(e,this.storageKey,this.eventsSdkClass.options.loginType))}updateLastLoginTimestamp(){this.lastLoginTimestamp=new Date().getTime()}async checkLoginStatus(e){const s=await dt.getSessionStorageDataByKey(e);if(s)return s}async userLoginFunction(e,s,r){let n,o,u;return this.eventsSdkClass.options.isNewStack?(n=await this.externalLogin(this.eventsSdkClass.options.loginUrl,e,r),o=await this.getSettings(n.Data.AccessToken),u={...n.Data,...o}):(n=await this.externalLogin(this.eventsSdkClass.options.loginUrl,e,r),u={...n.Data.Socket}),await dt.updateSessionStorageKey(s,u),u}onLoginResponse(e){if(!this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((s,r)=>s.Priority>r.Priority?s:r)),this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((s,r)=>s.Priority>r.Priority?s:r)),e.MonitorList&&e.MonitorList.length&&(this.eventsSdkClass.servers=[...e.MonitorList],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((s,r)=>s.Priority>r.Priority?s:r)),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length&&e.URLList&&(this.eventsSdkClass.URLList=e.URLList),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.URLList.length&&!this.eventsSdkClass.servers.length)throw new Error("Socket servers not defined");if(this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length)throw new Error("Socket servers not defined");this.eventsSdkClass.server&&this.eventsSdkClass.socketIoClass.getSocketIoFunction(`v=${this.eventsSdkClass.server.Version}`),!this.eventsSdkClass.server&&this.eventsSdkClass.URLList.length&&this.eventsSdkClass.socketIoClass.getSocketIoFunction(`v=${e.Version}`),e.IdentityCode&&(this.token=e.IdentityCode,this.eventsSdkClass.connect(ot.MAIN)),e.Token&&(this.token=e.Token,this.eventsSdkClass.connect(ot.MAIN)),e.RefreshToken&&e.IdentityCodeExpiry&&this.eventsSdkClass.options.loginType===H.USER&&(this.refreshToken=e.RefreshToken,this.tokenExpiry=e.IdentityCodeExpiry,this.handleTokenExpiry()),e.RefreshToken&&e.TokenExpiry&&this.normalizeLoginType(this.eventsSdkClass.options.loginType)===H.USER&&(this.refreshToken=e.RefreshToken,this.tokenExpiry=e.TokenExpiry,this.handleTokenExpiry())}handleTokenExpiry(){if(!this.eventsSdkClass.options.refreshTokenUrl)throw new Error("refreshTokenUrl not provided");let e;if(this.tokenExpiry)e=new Date(this.tokenExpiry);else return;const s=e.getTime()-new Date().getTime()-5e3,r=Math.min(s,2147483647);setTimeout(async()=>{if(this.refreshToken){this.eventsSdkClass.socketIoClass.closeAllConnections();let n,o;if(this.eventsSdkClass.options.isNewStack){const u=await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken);n=await this.getSettings(u.Data.AccessToken),o={...u.Data,...n}}else o={...(await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken)).Data.Socket};this.onLoginResponse(o),await dt.updateSessionStorageKey(this.storageKey,o)}},r)}async externalLogin(e,{password:s,token:r,email:n},o){if(!e)throw new Error("loginUrl not provided");let u;this.eventsSdkClass.options.isNewStack?o===H.TOKEN?u=JSON.stringify({identityType:H.TOKEN,token:r}):u=JSON.stringify({identityType:H.USER,username:n,password:s}):this.eventsSdkClass.options.loginType===H.TOKEN?(u=JSON.stringify({token:r}),e=`${e}/${H.TOKEN}`):(u=JSON.stringify({email:n,pin:s}),e=`${e}/${H.USER}`);try{const a=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:u});if(!a.ok&&a.status===400)throw new Error("Bad body request. Login type or isNewStack values not correct or not provided");if(!a.ok&&a.status===401)throw new Error("Unauthorized. Invalid token provided");if(!a.ok&&a.status===403)throw new Error("Forbidden. Identity token not provided or not valid");const f=await a.json();if(f.error)throw new Error(f.error);return f}catch(a){throw this.eventsSdkClass.loggerClass.log({Message:`External login request error with the login type ${H} ${o===H.TOKEN?{token:r}:{email:n,pin:s}}`,ActionName:$.WSCONNECT,isShowClient:!1,Status:"External login error",StatusCode:400,Level:W.ERROR,LogType:X.ERROR}),a}}async getSettings(e){try{if(!this.eventsSdkClass.options.getSettingsUrl)throw new Error("getSettingsUrl not provided");const s=await fetch(this.eventsSdkClass.options.getSettingsUrl,{headers:{Authorization:`Bearer ${e}`}});if(!s.ok&&s.status===401)throw new Error("Unauthorized. Access token not provided or not valid");return s.json()}catch(s){throw this.eventsSdkClass.loggerClass.log({Message:`Get settings error with token ${e}, error: ${s}`,ActionName:$.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:W.ERROR,LogType:X.ERROR}),s}}async externalRefreshToken(e,s){try{return(await fetch(e,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})).json()}catch(r){throw this.eventsSdkClass.loggerClass.log({Message:`Refresh token error with old refresh token ${s}, url: ${e}, error: ${r}`,ActionName:$.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:W.ERROR,LogType:X.ERROR}),r}}normalizeLoginType(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}}const on={isNewStack:!1,loginUrl:"https://loginapi.voicenter.co.il/monitorAPI/Login",refreshTokenUrl:"https://loginapi.voicenter.co.il/monitorAPI/RefreshIdentityToken",forceNew:!0,reconnectionDelay:1e4,timeout:1e4,keepAliveTimeout:6e4,protocol:"https",useLogger:!0,loggerServer:"https://socketlog.voicenter.co",loggerConfig:{logToConsole:!0,overloadGlobalConsole:!1,system:"events-sdk",socketEmitInterval:1e4},loggerConnectOptions:{reconnection:!0,reconnectionDelay:5e3,reconnectionAttempts:10,perMessageDeflate:void 0,upgrade:!1,transports:["websocket"],debug:!1}};var ts=(t=>(t.RINGING="Ringing",t.TALKING="Talking",t.DIALING="Dialing",t.HOLD="Hold",t))(ts||{}),es=(t=>(t.INCOMING="Incoming",t.OUTGOING="Outgoing",t))(es||{}),rt=(t=>(t.CONNECTED="connected",t.DISCONNECTED="disconnected",t.TRYING_TO_CONNECT="tryingToConnect",t))(rt||{}),ss=(t=>(t.AUTOMATIC="Automatic",t.IVR="IVR",t))(ss||{}),rs=(t=>(t.INCOMINC="Incoming",t.OUTGOING="Outgoing",t.SPY="Spy",t.CLICK2CALL="Click2Call",t))(rs||{}),ns=(t=>(t.RESPONSE_FROM_API_VALID="RESPONSE_FROM_API_VALID",t.RESPONSE_FROM_API_INVALID="RESPONSE_FROM_API_INVALID",t))(ns||{}),b=(t=>(t.ALL_DIALER_STATUS="AllDialersStatus",t.ALL_EXTENSION_STATUS="AllExtensionsStatus",t.ALL_USERS_STATUS="AllUsersStatus",t.CONNECT="connect",t.DISCONNECT="disconnect",t.CONNECT_ERROR_EVENT="connect_error",t.EXTENSION_EVENT="ExtensionEvent",t.KEEP_ALIVE="keepalive",t.KEEP_ALIVE_RESPONSE="keepaliveResponse",t.LOGIN_STATUS="loginStatus",t.LOGIN_SUCCESS="loginSuccess",t.QUEUE_EVENT="QueueEvent",t.ONLINE_STATUS_EVENT="onlineStatusEvent",t.DIALER_EVENT="DialerEvent",t.EXTENSIONS_UPDATED="ExtensionsUpdated",t))(b||{}),ie=(t=>(t.NEWCALL="NEWCALL",t.ANSWER="ANSWER",t.HOLD="HOLD",t.UNHOLD="UNHOLD",t.HANGUP="HANGUP",t.USER_STATUS_UPDATE="userStatusUpdate",t))(ie||{}),os=(t=>(t.NORMAL_HANGUP="Normal hangup",t.USER_BUSY="User busy",t.CALL_REJECTED="Call Rejected",t.UNALLOCATED_NUMBER="Unallocated (unassigned) number",t.UNKNOWN="Unknown",t.NO_USER_RESPONDING="No user responding",t.USER_ALERTING="User alerting, no answer",t.ANSWERED_ELSEWHERE="Answered elsewhere",t))(os||{}),is=(t=>(t.ANSWER="ANSWER",t.ABANDONED="ABANDONED",t.EXIT="EXIT",t.JOIN="JOIN",t))(is||{});class ae{static mapExtensionEvent(e){var u,a;const s=e.reason;let r,n;e.data.currentCall&&(n=this.mapExtensionCall(e,e.data.currentCall));const o=this.mapExtensionData(e,e.data);return s===ie.HANGUP?r={...e,reason:s,data:{...o,currentCall:n?{...n,duration:n.callAnswered_UTC_CLIENT?Date.now()-n.callAnswered_UTC_CLIENT:0}:void 0,calls:(u=e.data.calls)==null?void 0:u.map(f=>{const i=this.mapExtensionCall(e,f);return{...i,duration:i.callAnswered_UTC_CLIENT?Date.now()-i.callAnswered_UTC_CLIENT:0}})}}:r={...e,data:{...o,currentCall:n,calls:(a=e.data.calls)==null?void 0:a.map(f=>this.mapExtensionCall(e,f))},reason:s},r}static mapAllExtensionStatus(e){return{...e,extensions:e.extensions.map(s=>{var r;return{...this.mapExtensionData(e,s),currentCall:s.currentCall?this.mapExtensionCall(e,s.currentCall):void 0,calls:(r=s.calls)==null?void 0:r.map(n=>this.mapExtensionCall(e,n))}})}}static mapExtensionData(e,s){return this.configureUTCForObject(s,[{key:"lastAnsweredCallEventEpoch",format:"sec"},{key:"lastCallEventEpoch",format:"sec"},{key:"lastHangupCallEpoch",format:"sec"},{key:"representativeUpdated",format:"ms"}],e.servertime,e.servertimeoffset)}static mapExtensionCall(e,s){return this.configureUTCForObject(s,[{key:"callAnswered",format:"sec"},{key:"callStarted",format:"sec"}],e.servertime,e.servertimeoffset)}static mapQueueEvent(e){var s;return{...e,data:{...e.data,Calls:(s=e.data.Calls)==null?void 0:s.map(r=>this.configureUTCForObject(r,[{key:"JoinTimeStamp",format:"sec"}],e.servertime,e.servertimeoffset))}}}static assignProperty(e,s,r){e[s]=r}static configureUTCForObject(e,s,r,n){const o=(r-n*60)*1e3,u=Date.now()-o,a={};return s.forEach(f=>{const i=e[f.key],c=f.key;if(i!==0&&typeof i=="number"&&!isNaN(i)){let l=i;f.format==="ms"&&(l=Math.floor(l/1e3));const p=(l-n*60)*1e3;this.assignProperty(a,`${c}_UTC`,p),this.assignProperty(a,`${c}_UTC_CLIENT`,p+u)}else this.assignProperty(a,`${c}_UTC`,0),this.assignProperty(a,`${c}_UTC_CLIENT`,0)}),{...e,...a}}}var ce=(t=>(t.UPDATE_MONITORED_EXTENSIONS="updateMonitoredExtensions",t.KEEP_ALIVE="keepAlive",t))(ce||{});class an{constructor(e){L(this,"io");L(this,"ioFunction");L(this,"lastEventTimestamp",new Date().getTime());L(this,"doReconnect",!0);L(this,"keepAliveInterval");L(this,"keepReconnectInterval");L(this,"connected",!1);this.eventsSdkClass=e,this.eventsSdkClass=e}getSocketIoFunction(e){const s=e.split("v=");"v".concat(s[s.length-1]).replaceAll(".","_"),this.ioFunction=Y}initSocketConnection(){const e=this.eventsSdkClass.authClass.token,s=this.eventsSdkClass.options.protocol,r=this.eventsSdkClass.server;try{const n=r?r.Domain:this.eventsSdkClass.URL,o=r?`${s}://${n}`:this.eventsSdkClass.URL;this.eventsSdkClass.eventEmitterClass.emit(b.ONLINE_STATUS_EVENT,{attemptToConnect:o,connectionStatus:rt.TRYING_TO_CONNECT});const u={reconnection:!1,upgrade:!1,transports:["websocket"],forceNew:!0,query:{token:e},timeout:this.eventsSdkClass.options.timeout};if(e&&(u.query={token:e}),this.ioFunction&&o)this.io=this.ioFunction(o,u),this.eventsSdkClass.loggerClass.log({Message:`${this.eventsSdkClass.options.loggerConfig.system} is trying to connect to WS server ${n}`,ActionName:$.WSCONNECT,isShowClient:!1,Status:"Switching Protocols",StatusCode:101,Level:W.INFO,LogType:X.INFO});else throw new Error("Socket server url no defined")}catch(n){this.eventsSdkClass.loggerClass.log({Message:`${n}`,ActionName:$.WSCONNECT,isShowClient:!1,Status:"Connection error",StatusCode:500,Level:W.ERROR,LogType:X.ERROR})}}clearKeepAliveInterval(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval)}initKeepAlive(){this.clearKeepAliveInterval(),this.keepAliveInterval=setInterval(async()=>{if(new Date().getTime()>this.lastEventTimestamp+this.eventsSdkClass.options.keepAliveTimeout&&this.io&&this.eventsSdkClass.authClass.token){this.eventsSdkClass.emit(ce.KEEP_ALIVE,this.eventsSdkClass.authClass.token),this.eventsSdkClass.loggerClass.log({Message:`Keep alive event emitted with this token: ${this.eventsSdkClass.authClass.token}`,ActionName:$.WSCONNECT,isShowClient:!1,Level:W.INFO,LogType:X.INFO});return}},this.eventsSdkClass.options.keepAliveTimeout)}closeAllConnections(){var e;this.io&&(this.io.close(),(e=this.io)==null||e.disconnect(),this.io=void 0),dt.clearSessionStorage()}initSocketEvents(){this.io&&this.io.on(b.LOGIN_SUCCESS,e=>this.onLoginSuccessEvent(e)).on(b.QUEUE_EVENT,e=>this.onQueueEvent(e)).on(b.EXTENSION_EVENT,e=>this.onExtensionEvent(e)).on(b.DIALER_EVENT,e=>this.onDialerEvent(e)).on(b.LOGIN_STATUS,e=>this.onLoginStatusEvent(e)).on(b.ALL_EXTENSION_STATUS,e=>this.onAllExtensionStatus(e)).on(b.ALL_DIALER_STATUS,e=>this.onAllDialerStatus(e)).on(b.KEEP_ALIVE_RESPONSE,e=>this.onKeepAliveResponse(e)).on(b.EXTENSIONS_UPDATED,e=>this.onExtensionsUpdatedEvent(e)).on(b.CONNECT,()=>this.onConnect()).on(b.DISCONNECT,e=>this.onDisconnect(e)).on(b.CONNECT_ERROR_EVENT,e=>this.onConnectError(e))}onLoginSuccessEvent(e){this.eventsSdkClass.eventEmitterClass.emit(b.LOGIN_SUCCESS,e)}onQueueEvent(e){this.eventsSdkClass.eventEmitterClass.emit(b.QUEUE_EVENT,ae.mapQueueEvent(e))}onExtensionEvent(e){const s=ae.mapExtensionEvent(e);s&&this.eventsSdkClass.eventEmitterClass.emit(b.EXTENSION_EVENT,s)}onDialerEvent(e){this.eventsSdkClass.eventEmitterClass.emit(b.DIALER_EVENT,e)}onLoginStatusEvent(e){this.eventsSdkClass.eventEmitterClass.emit(b.LOGIN_STATUS,e)}onAllExtensionStatus(e){const s=ae.mapAllExtensionStatus(e);this.eventsSdkClass.eventEmitterClass.emit(b.ALL_EXTENSION_STATUS,s)}onAllDialerStatus(e){this.eventsSdkClass.eventEmitterClass.emit(b.ALL_DIALER_STATUS,e)}onKeepAliveResponse(e){if(e.errorCode){this.initSocketConnection();return}this.eventsSdkClass.loggerClass.log({Message:`Keep alive response: ${e}`,ActionName:$.WSCONNECT,isShowClient:!1,Status:"Successful",StatusCode:200,Level:W.INFO,LogType:X.INFO}),this.connected?this.lastEventTimestamp=new Date().getTime():this.initSocketConnection()}onExtensionsUpdatedEvent(e){this.eventsSdkClass.eventEmitterClass.emit(b.EXTENSIONS_UPDATED,e)}onConnect(){this.keepReconnectInterval&&clearInterval(this.keepReconnectInterval),this.connected=!0,this.eventsSdkClass.eventEmitterClass.emit(b.ONLINE_STATUS_EVENT,{connectionStatus:rt.CONNECTED}),this.eventsSdkClass.loggerClass.log({Message:`Sdk connected to the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL}`,ActionName:$.WSCONNECT,isShowClient:!1,Status:"Connection established",StatusCode:200,Level:W.INFO,LogType:X.INFO})}onDisconnect(e){this.connected=!1,this.closeAllConnections(),this.eventsSdkClass.eventEmitterClass.emit(b.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?rt.TRYING_TO_CONNECT:rt.DISCONNECTED}),this.eventsSdkClass.loggerClass.log({Message:`Sdk disconnected from the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL} (${e})`,ActionName:$.WSCONNECT,isShowClient:!1,Status:"Connection closed",StatusCode:200,Level:W.INFO,LogType:X.INFO}),this.doReconnect&&this.eventsSdkClass.connect(ot.NEXT)}onConnectError(e){this.eventsSdkClass.eventEmitterClass.emit(b.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?rt.TRYING_TO_CONNECT:rt.DISCONNECTED}),this.eventsSdkClass.loggerClass.log({Message:`Sdk attempt to connect to the socket server ${this.eventsSdkClass.URL} failed (${e})`,ActionName:$.WSCONNECT,isShowClient:!1,Status:"Connection attempt error",StatusCode:500,Level:W.ERROR,LogType:X.ERROR}),setTimeout(()=>{this.eventsSdkClass.connect(ot.NEXT)},this.eventsSdkClass.options.reconnectionDelay)}}class cn{constructor(e){L(this,"storageLogger");this.eventsSdkClass=e,this.eventsSdkClass=e}init(){if(!this.eventsSdkClass.options.useLogger)return;if(this.eventsSdkClass.options.storageLoggerInstance){this.storageLogger=this.eventsSdkClass.options.storageLoggerInstance;return}let e;this.eventsSdkClass.options.loggerSocketConnection&&(e=this.eventsSdkClass.options.loggerSocketConnection),this.eventsSdkClass.socketIoClass.ioFunction&&!e&&(e=this.eventsSdkClass.socketIoClass.ioFunction(this.eventsSdkClass.options.loggerServer,this.eventsSdkClass.options.loggerConnectOptions)),e&&(this.storageLogger=new rn({socket:e,loggerOptions:this.eventsSdkClass.options.loggerConfig}))}stop(){this.storageLogger&&this.storageLogger.stop()}log(e){this.eventsSdkClass.options.useLogger&&(this.storageLogger?e.Level===W.INFO?this.storageLogger.log(e):e.Level===W.ERROR&&this.storageLogger.error(e):e.Level===W.INFO?console.log(e):e.Level===W.ERROR&&console.error(e))}sdkInitializedLog(){const e={...this.eventsSdkClass.options,token:"CENSORED",password:"CENSORED"};this.log({Message:"Sdk initialized with provided options",Body:JSON.stringify(e,this.eventsSdkClass.getCircularReplacer()),ActionName:$.WSCONNECT,isShowClient:!1,Status:"Sdk initialized",StatusCode:200,Level:W.INFO,LogType:X.INFO})}}class hn{constructor(e){L(this,"listeners",{[b.ALL_EXTENSION_STATUS]:[],[b.ALL_DIALER_STATUS]:[],[b.ALL_USERS_STATUS]:[],[b.QUEUE_EVENT]:[],[b.EXTENSION_EVENT]:[],[b.DIALER_EVENT]:[],[b.LOGIN_SUCCESS]:[],[b.LOGIN_STATUS]:[],[b.KEEP_ALIVE_RESPONSE]:[],[b.ONLINE_STATUS_EVENT]:[],[b.EXTENSIONS_UPDATED]:[]});L(this,"allListeners",[]);this.eventsSdkClass=e,this.eventsSdkClass=e}on(e,s){e==="*"?this.allListeners.push(s):this.listeners[e].push(s)}off(e,s){if(e==="*")this.allListeners=this.allListeners.filter(r=>r!==s);else{const n=this.listeners[e].filter(o=>o!==s);this.listeners={...this.listeners,[e]:n}}}emit(e,s){this.eventsSdkClass.socketIoClass.lastEventTimestamp=new Date().getTime(),this.listeners[e].forEach(n=>n({name:e,data:s}));const r={name:e,data:s};this.allListeners.forEach(n=>n(r))}}class pn{constructor(e){L(this,"options");L(this,"servers",[]);L(this,"URLList",[]);L(this,"server");L(this,"URL");L(this,"socket");L(this,"mainServer");L(this,"alreadyAttemptedOtherServers",[]);L(this,"authClass",new nn(this));L(this,"socketIoClass",new an(this));L(this,"loggerClass",new cn(this));L(this,"eventEmitterClass",new hn(this));L(this,"getCircularReplacer",()=>{const e=new WeakSet;return(s,r)=>{if(!(s==="socket"||s==="io"||s==="nsps")){if(typeof r=="object"&&r!==null){if(e.has(r))return;e.add(r)}return r}}});this.options={...on,...e}}on(e,s){this.eventEmitterClass.on(e,s)}emit(e,...s){this.socketIoClass.io&&this.socketIoClass.io.emit(e,...s)}connect(e){e===ot.MAIN&&this.findMainServer(),e===ot.NEXT&&this.findNextServer(),this.socketIoClass.doReconnect=!0;try{this.loggerClass.init()}catch(s){console.error(s)}this.socketIoClass.initSocketConnection(),this.socketIoClass.initSocketEvents(),this.socketIoClass.initKeepAlive()}disconnect(){this.socketIoClass.doReconnect=!1,this.socketIoClass.closeAllConnections(),this.loggerClass.stop()}clearKeepAliveInterval(){this.socketIoClass.clearKeepAliveInterval()}findMainServer(){this.servers.length?(this.mainServer=this.servers.reduce((e,s)=>s.Priority>e.Priority?s:e),this.server=this.mainServer):this.URLList.length&&(this.URL=this.URLList[0])}findNextServer(){if(this.servers.length&&this.server)if(this.server.Priority===this.mainServer.Priority){let e=this.servers.filter(s=>s.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(s.Priority)+1===0);e.length||(this.alreadyAttemptedOtherServers=[],e=this.servers.filter(s=>s.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(s.Priority)+1===0)),e.length&&(this.server=e.reduce((s,r)=>r.Priority>s.Priority?r:s),this.alreadyAttemptedOtherServers.push(this.server.Priority))}else this.server=this.mainServer;else if(this.URLList.length)if(this.URL===this.URLList[0]){let e=this.URLList.filter(s=>s!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(s)+1===0);e.length||(this.alreadyAttemptedOtherServers=[],e=this.URLList.filter(s=>s!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(s)+1===0)),e.length&&(this.URL=e[0],this.alreadyAttemptedOtherServers.push(this.URL))}else this.URL=this.URLList[0]}async init(){const e=await this.authClass.login();return e&&this.authClass.onLoginResponse(e),this.loggerClass.sdkInitializedLog(),!0}getCurrentMonitorServer(){return this.server}}return U.CallStatusEnum=ts,U.CallTypeEnum=es,U.ConnectionStatusEnum=rt,U.DialerTypeEnum=ss,U.DirectionEnum=rs,U.DoNotCallMeStatusCodeEnum=ns,U.EventsEnum=b,U.ExtensionEventReasonEnum=ie,U.ExtensionHangupCauseEnum=os,U.LoginType=H,U.QueueEventReasonEnum=is,U.ServerListenerEventsEnum=ce,U.default=pn,Object.defineProperties(U,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),U}({},io);
6
+ */var Mr=function(t){return t!=null&&(Me(t)||qr(t)||!!t._isBuffer)};function Me(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function qr(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&Me(t.slice(0,0))}(function(){var t=jr,e=je.utf8,r=Mr,n=je.bin,o=function(i,u){i.constructor==String?u&&u.encoding==="binary"?i=n.stringToBytes(i):i=e.stringToBytes(i):r(i)?i=Array.prototype.slice.call(i,0):!Array.isArray(i)&&i.constructor!==Uint8Array&&(i=i.toString());for(var h=t.bytesToWords(i),f=i.length*8,c=1732584193,l=-271733879,p=-1732584194,a=271733878,s=0;s<h.length;s++)h[s]=(h[s]<<8|h[s]>>>24)&16711935|(h[s]<<24|h[s]>>>8)&4278255360;h[f>>>5]|=128<<f%32,h[(f+64>>>9<<4)+14]=f;for(var d=o._ff,y=o._gg,g=o._hh,w=o._ii,s=0;s<h.length;s+=16){var _=c,B=l,b=p,S=a;c=d(c,l,p,a,h[s+0],7,-680876936),a=d(a,c,l,p,h[s+1],12,-389564586),p=d(p,a,c,l,h[s+2],17,606105819),l=d(l,p,a,c,h[s+3],22,-1044525330),c=d(c,l,p,a,h[s+4],7,-176418897),a=d(a,c,l,p,h[s+5],12,1200080426),p=d(p,a,c,l,h[s+6],17,-1473231341),l=d(l,p,a,c,h[s+7],22,-45705983),c=d(c,l,p,a,h[s+8],7,1770035416),a=d(a,c,l,p,h[s+9],12,-1958414417),p=d(p,a,c,l,h[s+10],17,-42063),l=d(l,p,a,c,h[s+11],22,-1990404162),c=d(c,l,p,a,h[s+12],7,1804603682),a=d(a,c,l,p,h[s+13],12,-40341101),p=d(p,a,c,l,h[s+14],17,-1502002290),l=d(l,p,a,c,h[s+15],22,1236535329),c=y(c,l,p,a,h[s+1],5,-165796510),a=y(a,c,l,p,h[s+6],9,-1069501632),p=y(p,a,c,l,h[s+11],14,643717713),l=y(l,p,a,c,h[s+0],20,-373897302),c=y(c,l,p,a,h[s+5],5,-701558691),a=y(a,c,l,p,h[s+10],9,38016083),p=y(p,a,c,l,h[s+15],14,-660478335),l=y(l,p,a,c,h[s+4],20,-405537848),c=y(c,l,p,a,h[s+9],5,568446438),a=y(a,c,l,p,h[s+14],9,-1019803690),p=y(p,a,c,l,h[s+3],14,-187363961),l=y(l,p,a,c,h[s+8],20,1163531501),c=y(c,l,p,a,h[s+13],5,-1444681467),a=y(a,c,l,p,h[s+2],9,-51403784),p=y(p,a,c,l,h[s+7],14,1735328473),l=y(l,p,a,c,h[s+12],20,-1926607734),c=g(c,l,p,a,h[s+5],4,-378558),a=g(a,c,l,p,h[s+8],11,-2022574463),p=g(p,a,c,l,h[s+11],16,1839030562),l=g(l,p,a,c,h[s+14],23,-35309556),c=g(c,l,p,a,h[s+1],4,-1530992060),a=g(a,c,l,p,h[s+4],11,1272893353),p=g(p,a,c,l,h[s+7],16,-155497632),l=g(l,p,a,c,h[s+10],23,-1094730640),c=g(c,l,p,a,h[s+13],4,681279174),a=g(a,c,l,p,h[s+0],11,-358537222),p=g(p,a,c,l,h[s+3],16,-722521979),l=g(l,p,a,c,h[s+6],23,76029189),c=g(c,l,p,a,h[s+9],4,-640364487),a=g(a,c,l,p,h[s+12],11,-421815835),p=g(p,a,c,l,h[s+15],16,530742520),l=g(l,p,a,c,h[s+2],23,-995338651),c=w(c,l,p,a,h[s+0],6,-198630844),a=w(a,c,l,p,h[s+7],10,1126891415),p=w(p,a,c,l,h[s+14],15,-1416354905),l=w(l,p,a,c,h[s+5],21,-57434055),c=w(c,l,p,a,h[s+12],6,1700485571),a=w(a,c,l,p,h[s+3],10,-1894986606),p=w(p,a,c,l,h[s+10],15,-1051523),l=w(l,p,a,c,h[s+1],21,-2054922799),c=w(c,l,p,a,h[s+8],6,1873313359),a=w(a,c,l,p,h[s+15],10,-30611744),p=w(p,a,c,l,h[s+6],15,-1560198380),l=w(l,p,a,c,h[s+13],21,1309151649),c=w(c,l,p,a,h[s+4],6,-145523070),a=w(a,c,l,p,h[s+11],10,-1120210379),p=w(p,a,c,l,h[s+2],15,718787259),l=w(l,p,a,c,h[s+9],21,-343485551),c=c+_>>>0,l=l+B>>>0,p=p+b>>>0,a=a+S>>>0}return t.endian([c,l,p,a])};o._ff=function(i,u,h,f,c,l,p){var a=i+(u&h|~u&f)+(c>>>0)+p;return(a<<l|a>>>32-l)+u},o._gg=function(i,u,h,f,c,l,p){var a=i+(u&f|h&~f)+(c>>>0)+p;return(a<<l|a>>>32-l)+u},o._hh=function(i,u,h,f,c,l,p){var a=i+(u^h^f)+(c>>>0)+p;return(a<<l|a>>>32-l)+u},o._ii=function(i,u,h,f,c,l,p){var a=i+(h^(u|~f))+(c>>>0)+p;return(a<<l|a>>>32-l)+u},o._blocksize=16,o._digestsize=16,Pe.exports=function(i,u){if(i==null)throw new Error("Illegal argument "+i);var h=t.wordsToBytes(o(i,u));return u&&u.asBytes?h:u&&u.asString?n.bytesToString(h):t.bytesToHex(h)}})();var zr=Pe.exports;const Xr=bt(zr);var Ct=(t=>(t.MAIN="main",t.NEXT="next",t))(Ct||{}),st=(t=>(t.USER="User",t.TOKEN="Token",t))(st||{});class Rt{static async getSessionStorageDataByKey(e,r=!0){if(typeof chrome<"u"&&typeof chrome.storage<"u"){const n=await chrome.storage.session.get(e);if(n[e])return r?JSON.parse(n[e]):n[e]}if(typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.getItem=="function"){const n=window.sessionStorage.getItem(e);if(n)return r?JSON.parse(n):n}}static async updateSessionStorageKey(e,r){typeof chrome<"u"&&typeof chrome.storage<"u"&&await chrome.storage.session.set({[e]:JSON.stringify(r)}),typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.setItem=="function"&&window.sessionStorage.setItem(e,JSON.stringify(r))}static clearSessionStorage(){typeof chrome<"u"&&typeof chrome.storage<"u"&&chrome.storage.session.clear(),typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.clear=="function"&&window.sessionStorage.clear()}}var Wr=Object.defineProperty,Kr=(t,e,r)=>e in t?Wr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,V=(t,e,r)=>(Kr(t,typeof e!="symbol"?e+"":e,r),r);function Hr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Jr(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}),r}var Qt={exports:{}},Vr=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,$r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],qe=function(t){var e=t,r=t.indexOf("["),n=t.indexOf("]");r!=-1&&n!=-1&&(t=t.substring(0,r)+t.substring(r,n).replace(/:/g,";")+t.substring(n,t.length));for(var o=Vr.exec(t||""),i={},u=14;u--;)i[$r[u]]=o[u]||"";return r!=-1&&n!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Gr(i,i.path),i.queryKey=Yr(i,i.query),i};function Gr(t,e){var r=/\/{2,9}/g,n=e.replace(r,"/").split("/");return(e.substr(0,1)=="/"||e.length===0)&&n.splice(0,1),e.substr(e.length-1,1)=="/"&&n.splice(n.length-1,1),n}function Yr(t,e){var r={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,o,i){o&&(r[o]=i)}),r}var Zt={exports:{}},te={exports:{}},It=1e3,_t=It*60,Bt=_t*60,Lt=Bt*24,Qr=Lt*365.25,Zr=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return tn(t);if(r==="number"&&isNaN(t)===!1)return e.long?rn(t):en(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function tn(t){if(t=String(t),!(t.length>100)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Qr;case"days":case"day":case"d":return r*Lt;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Bt;case"minutes":case"minute":case"mins":case"min":case"m":return r*_t;case"seconds":case"second":case"secs":case"sec":case"s":return r*It;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function en(t){return t>=Lt?Math.round(t/Lt)+"d":t>=Bt?Math.round(t/Bt)+"h":t>=_t?Math.round(t/_t)+"m":t>=It?Math.round(t/It)+"s":t+"ms"}function rn(t){return Ft(t,Lt,"day")||Ft(t,Bt,"hour")||Ft(t,_t,"minute")||Ft(t,It,"second")||t+" ms"}function Ft(t,e,r){if(!(t<e))return t<e*1.5?Math.floor(t/e)+" "+r:Math.ceil(t/e)+" "+r+"s"}(function(t,e){e=t.exports=n.debug=n.default=n,e.coerce=f,e.disable=u,e.enable=i,e.enabled=h,e.humanize=Zr,e.instances=[],e.names=[],e.skips=[],e.formatters={};function r(c){var l=0,p;for(p in c)l=(l<<5)-l+c.charCodeAt(p),l|=0;return e.colors[Math.abs(l)%e.colors.length]}function n(c){var l;function p(){if(p.enabled){var a=p,s=+new Date,d=s-(l||s);a.diff=d,a.prev=l,a.curr=s,l=s;for(var y=new Array(arguments.length),g=0;g<y.length;g++)y[g]=arguments[g];y[0]=e.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");var w=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,function(B,b){if(B==="%%")return B;w++;var S=e.formatters[b];if(typeof S=="function"){var m=y[w];B=S.call(a,m),y.splice(w,1),w--}return B}),e.formatArgs.call(a,y);var _=p.log||e.log||console.log.bind(console);_.apply(a,y)}}return p.namespace=c,p.enabled=e.enabled(c),p.useColors=e.useColors(),p.color=r(c),p.destroy=o,typeof e.init=="function"&&e.init(p),e.instances.push(p),p}function o(){var c=e.instances.indexOf(this);return c!==-1?(e.instances.splice(c,1),!0):!1}function i(c){e.save(c),e.names=[],e.skips=[];var l,p=(typeof c=="string"?c:"").split(/[\s,]+/),a=p.length;for(l=0;l<a;l++)p[l]&&(c=p[l].replace(/\*/g,".*?"),c[0]==="-"?e.skips.push(new RegExp("^"+c.substr(1)+"$")):e.names.push(new RegExp("^"+c+"$")));for(l=0;l<e.instances.length;l++){var s=e.instances[l];s.enabled=e.enabled(s.namespace)}}function u(){e.enable("")}function h(c){if(c[c.length-1]==="*")return!0;var l,p;for(l=0,p=e.skips.length;l<p;l++)if(e.skips[l].test(c))return!1;for(l=0,p=e.names.length;l<p;l++)if(e.names[l].test(c))return!0;return!1}function f(c){return c instanceof Error?c.stack||c.message:c}})(te,te.exports);var nn=te.exports;(function(t,e){e=t.exports=nn,e.log=o,e.formatArgs=n,e.save=i,e.load=u,e.useColors=r,e.storage=typeof chrome<"u"&&typeof chrome.storage<"u"?chrome.storage.local:h(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&window.process.type==="renderer"?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}e.formatters.j=function(f){try{return JSON.stringify(f)}catch(c){return"[UnexpectedJSONParseError]: "+c.message}};function n(f){var c=this.useColors;if(f[0]=(c?"%c":"")+this.namespace+(c?" %c":" ")+f[0]+(c?"%c ":" ")+"+"+e.humanize(this.diff),!!c){var l="color: "+this.color;f.splice(1,0,l,"color: inherit");var p=0,a=0;f[0].replace(/%[a-zA-Z%]/g,function(s){s!=="%%"&&(p++,s==="%c"&&(a=p))}),f.splice(a,0,l)}}function o(){return typeof console=="object"&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function i(f){try{f==null?e.storage.removeItem("debug"):e.storage.debug=f}catch{}}function u(){var f;try{f=e.storage.debug}catch{}return!f&&typeof process<"u"&&"env"in process&&(f=process.env.DEBUG),f}e.enable(u());function h(){try{return window.localStorage}catch{}}})(Zt,Zt.exports);var ft=Zt.exports,on=qe,ze=ft("socket.io-client:url"),sn=an;function an(t,e){var r=t;e=e||typeof location<"u"&&location,t==null&&(t=e.protocol+"//"+e.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=e.protocol+t:t=e.host+t),/^(https?|wss?):\/\//.test(t)||(ze("protocol-less url %s",t),typeof e<"u"?t=e.protocol+"//"+t:t="https://"+t),ze("parse %s",t),r=on(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var n=r.host.indexOf(":")!==-1,o=n?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port,r.href=r.protocol+"://"+o+(e&&e.port===r.port?"":":"+r.port),r}var jt={},Xe={exports:{}};(function(t){t.exports=e;function e(n){if(n)return r(n)}function r(n){for(var o in e.prototype)n[o]=e.prototype[o];return n}e.prototype.on=e.prototype.addEventListener=function(n,o){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(o),this},e.prototype.once=function(n,o){function i(){this.off(n,i),o.apply(this,arguments)}return i.fn=o,this.on(n,i),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(n,o){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+n];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var u,h=0;h<i.length;h++)if(u=i[h],u===o||u.fn===o){i.splice(h,1);break}return i.length===0&&delete this._callbacks["$"+n],this},e.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var o=new Array(arguments.length-1),i=this._callbacks["$"+n],u=1;u<arguments.length;u++)o[u-1]=arguments[u];if(i){i=i.slice(0);for(var u=0,h=i.length;u<h;++u)i[u].apply(this,o)}return this},e.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]},e.prototype.hasListeners=function(n){return!!this.listeners(n).length}})(Xe);var St=Xe.exports,Mt={},cn={}.toString,ee=Array.isArray||function(t){return cn.call(t)=="[object Array]"},We=ln,hn=typeof Buffer=="function"&&typeof Buffer.isBuffer=="function",pn=typeof ArrayBuffer=="function",un=function(t){return typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer};function ln(t){return hn&&Buffer.isBuffer(t)||pn&&(t instanceof ArrayBuffer||un(t))}var re=ee,Ke=We,He=Object.prototype.toString,fn=typeof Blob=="function"||typeof Blob<"u"&&He.call(Blob)==="[object BlobConstructor]",dn=typeof File=="function"||typeof File<"u"&&He.call(File)==="[object FileConstructor]";Mt.deconstructPacket=function(t){var e=[],r=t.data,n=t;return n.data=ne(r,e),n.attachments=e.length,{packet:n,buffers:e}};function ne(t,e){if(!t)return t;if(Ke(t)){var r={_placeholder:!0,num:e.length};return e.push(t),r}else if(re(t)){for(var n=new Array(t.length),o=0;o<t.length;o++)n[o]=ne(t[o],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){var n={};for(var i in t)n[i]=ne(t[i],e);return n}return t}Mt.reconstructPacket=function(t,e){return t.data=oe(t.data,e),t.attachments=void 0,t};function oe(t,e){if(!t)return t;if(t&&t._placeholder===!0){var r=typeof t.num=="number"&&t.num>=0&&t.num<e.length;if(r)return e[t.num];throw new Error("illegal attachments")}else if(re(t))for(var n=0;n<t.length;n++)t[n]=oe(t[n],e);else if(typeof t=="object")for(var o in t)t[o]=oe(t[o],e);return t}Mt.removeBlobs=function(t,e){function r(i,u,h){if(!i)return i;if(fn&&i instanceof Blob||dn&&i instanceof File){n++;var f=new FileReader;f.onload=function(){h?h[u]=this.result:o=this.result,--n||e(o)},f.readAsArrayBuffer(i)}else if(re(i))for(var c=0;c<i.length;c++)r(i[c],c,i);else if(typeof i=="object"&&!Ke(i))for(var l in i)r(i[l],l,i)}var n=0,o=t;r(o),n||e(o)},function(t){var e=ft("socket.io-parser"),r=St,n=Mt,o=ee,i=We;t.protocol=4,t.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],t.CONNECT=0,t.DISCONNECT=1,t.EVENT=2,t.ACK=3,t.ERROR=4,t.BINARY_EVENT=5,t.BINARY_ACK=6,t.Encoder=u,t.Decoder=p;function u(){}var h=t.ERROR+'"encode error"';u.prototype.encode=function(g,w){if(e("encoding packet %j",g),t.BINARY_EVENT===g.type||t.BINARY_ACK===g.type)l(g,w);else{var _=f(g);w([_])}};function f(g){var w=""+g.type;if((t.BINARY_EVENT===g.type||t.BINARY_ACK===g.type)&&(w+=g.attachments+"-"),g.nsp&&g.nsp!=="/"&&(w+=g.nsp+","),g.id!=null&&(w+=g.id),g.data!=null){var _=c(g.data);if(_!==!1)w+=_;else return h}return e("encoded %j as %s",g,w),w}function c(g){try{return JSON.stringify(g)}catch{return!1}}function l(g,w){function _(B){var b=n.deconstructPacket(B),S=f(b.packet),m=b.buffers;m.unshift(S),w(m)}n.removeBlobs(g,_)}function p(){this.reconstructor=null}r(p.prototype),p.prototype.add=function(g){var w;if(typeof g=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");w=a(g),t.BINARY_EVENT===w.type||t.BINARY_ACK===w.type?(this.reconstructor=new d(w),this.reconstructor.reconPack.attachments===0&&this.emit("decoded",w)):this.emit("decoded",w)}else if(i(g)||g.base64)if(this.reconstructor)w=this.reconstructor.takeBinaryData(g),w&&(this.reconstructor=null,this.emit("decoded",w));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+g)};function a(g){var w=0,_={type:Number(g.charAt(0))};if(t.types[_.type]==null)return y("unknown packet type "+_.type);if(t.BINARY_EVENT===_.type||t.BINARY_ACK===_.type){for(var B=w+1;g.charAt(++w)!=="-"&&w!=g.length;);var b=g.substring(B,w);if(b!=Number(b)||g.charAt(w)!=="-")throw new Error("Illegal attachments");_.attachments=Number(b)}if(g.charAt(w+1)==="/"){for(var B=w+1;++w;){var S=g.charAt(w);if(S===","||w===g.length)break}_.nsp=g.substring(B,w)}else _.nsp="/";var m=g.charAt(w+1);if(m!==""&&Number(m)==m){for(var B=w+1;++w;){var S=g.charAt(w);if(S==null||Number(S)!=S){--w;break}if(w===g.length)break}_.id=Number(g.substring(B,w+1))}if(g.charAt(++w)){var C=s(g.substr(w)),E=C!==!1&&(_.type===t.ERROR||o(C));if(E)_.data=C;else return y("invalid payload")}return e("decoded %s as %j",g,_),_}function s(g){try{return JSON.parse(g)}catch{return!1}}p.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()};function d(g){this.reconPack=g,this.buffers=[]}d.prototype.takeBinaryData=function(g){if(this.buffers.push(g),this.buffers.length===this.reconPack.attachments){var w=n.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),w}return null},d.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]};function y(g){return{type:t.ERROR,data:"parser error: "+g}}}(jt);var se={exports:{}},qt={},ie={exports:{}};try{ie.exports=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{ie.exports=!1}var yn=ie.exports,ae=function(){return typeof self<"u"?self:typeof window<"u"?window:Function("return this")()}(),gn=yn,mn=ae,ce=function(t){var e=t.xdomain,r=t.xscheme,n=t.enablesXDR;try{if(typeof XMLHttpRequest<"u"&&(!e||gn))return new XMLHttpRequest}catch{}try{if(typeof XDomainRequest<"u"&&!r&&n)return new XDomainRequest}catch{}if(!e)try{return new mn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}},he={exports:{}},wt={},vn=Object.keys||function(t){var e=[],r=Object.prototype.hasOwnProperty;for(var n in t)r.call(t,n)&&e.push(n);return e},pe,Je;function Ve(){if(Je)return pe;Je=1;var t=ee,e=Object.prototype.toString,r=typeof Blob=="function"||typeof Blob<"u"&&e.call(Blob)==="[object BlobConstructor]",n=typeof File=="function"||typeof File<"u"&&e.call(File)==="[object FileConstructor]";pe=o;function o(i){if(!i||typeof i!="object")return!1;if(t(i)){for(var u=0,h=i.length;u<h;u++)if(o(i[u]))return!0;return!1}if(typeof Buffer=="function"&&Buffer.isBuffer&&Buffer.isBuffer(i)||typeof ArrayBuffer=="function"&&i instanceof ArrayBuffer||r&&i instanceof Blob||n&&i instanceof File)return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return o(i.toJSON(),!0);for(var f in i)if(Object.prototype.hasOwnProperty.call(i,f)&&o(i[f]))return!0;return!1}return pe}var kn=function(t,e,r){var n=t.byteLength;if(e=e||0,r=r||n,t.slice)return t.slice(e,r);if(e<0&&(e+=n),r<0&&(r+=n),r>n&&(r=n),e>=n||e>=r||n===0)return new ArrayBuffer(0);for(var o=new Uint8Array(t),i=new Uint8Array(r-e),u=e,h=0;u<r;u++,h++)i[h]=o[u];return i.buffer},bn=Cn;function Cn(t,e,r){var n=!1;return r=r||wn,o.count=t,t===0?e():o;function o(i,u){if(o.count<=0)throw new Error("after called too many times");--o.count,i?(n=!0,e(i),e=r):o.count===0&&!n&&e(null,u)}}function wn(){}/*! https://mths.be/utf8js v2.1.2 by @mathias */var yt=String.fromCharCode;function $e(t){for(var e=[],r=0,n=t.length,o,i;r<n;)o=t.charCodeAt(r++),o>=55296&&o<=56319&&r<n?(i=t.charCodeAt(r++),(i&64512)==56320?e.push(((o&1023)<<10)+(i&1023)+65536):(e.push(o),r--)):e.push(o);return e}function Sn(t){for(var e=t.length,r=-1,n,o="";++r<e;)n=t[r],n>65535&&(n-=65536,o+=yt(n>>>10&1023|55296),n=56320|n&1023),o+=yt(n);return o}function Ge(t,e){if(t>=55296&&t<=57343){if(e)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function ue(t,e){return yt(t>>e&63|128)}function En(t,e){if(!(t&4294967168))return yt(t);var r="";return t&4294965248?t&4294901760?t&4292870144||(r=yt(t>>18&7|240),r+=ue(t,12),r+=ue(t,6)):(Ge(t,e)||(t=65533),r=yt(t>>12&15|224),r+=ue(t,6)):r=yt(t>>6&31|192),r+=yt(t&63|128),r}function An(t,e){e=e||{};for(var r=e.strict!==!1,n=$e(t),o=n.length,i=-1,u,h="";++i<o;)u=n[i],h+=En(u,r);return h}function Et(){if(gt>=Xt)throw Error("Invalid byte index");var t=zt[gt]&255;if(gt++,(t&192)==128)return t&63;throw Error("Invalid continuation byte")}function Tn(t){var e,r,n,o,i;if(gt>Xt)throw Error("Invalid byte index");if(gt==Xt)return!1;if(e=zt[gt]&255,gt++,!(e&128))return e;if((e&224)==192){if(r=Et(),i=(e&31)<<6|r,i>=128)return i;throw Error("Invalid continuation byte")}if((e&240)==224){if(r=Et(),n=Et(),i=(e&15)<<12|r<<6|n,i>=2048)return Ge(i,t)?i:65533;throw Error("Invalid continuation byte")}if((e&248)==240&&(r=Et(),n=Et(),o=Et(),i=(e&7)<<18|r<<12|n<<6|o,i>=65536&&i<=1114111))return i;throw Error("Invalid UTF-8 detected")}var zt,Xt,gt;function Nn(t,e){e=e||{};var r=e.strict!==!1;zt=$e(t),Xt=zt.length,gt=0;for(var n=[],o;(o=Tn(r))!==!1;)n.push(o);return Sn(n)}var On={version:"2.1.2",encode:An,decode:Nn},le={},Ye;function xn(){return Ye||(Ye=1,function(t){le.encode=function(e){var r=new Uint8Array(e),n,o=r.length,i="";for(n=0;n<o;n+=3)i+=t[r[n]>>2],i+=t[(r[n]&3)<<4|r[n+1]>>4],i+=t[(r[n+1]&15)<<2|r[n+2]>>6],i+=t[r[n+2]&63];return o%3===2?i=i.substring(0,i.length-1)+"=":o%3===1&&(i=i.substring(0,i.length-2)+"=="),i},le.decode=function(e){var r=e.length*.75,n=e.length,o,i=0,u,h,f,c;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var l=new ArrayBuffer(r),p=new Uint8Array(l);for(o=0;o<n;o+=4)u=t.indexOf(e[o]),h=t.indexOf(e[o+1]),f=t.indexOf(e[o+2]),c=t.indexOf(e[o+3]),p[i++]=u<<2|h>>4,p[i++]=(h&15)<<4|f>>2,p[i++]=(f&3)<<6|c&63;return l}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")),le}var fe,Qe;function Rn(){if(Qe)return fe;Qe=1;var t=typeof t<"u"?t:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:!1,e=function(){try{var h=new Blob(["hi"]);return h.size===2}catch{return!1}}(),r=e&&function(){try{var h=new Blob([new Uint8Array([1,2])]);return h.size===2}catch{return!1}}(),n=t&&t.prototype.append&&t.prototype.getBlob;function o(h){return h.map(function(f){if(f.buffer instanceof ArrayBuffer){var c=f.buffer;if(f.byteLength!==c.byteLength){var l=new Uint8Array(f.byteLength);l.set(new Uint8Array(c,f.byteOffset,f.byteLength)),c=l.buffer}return c}return f})}function i(h,f){f=f||{};var c=new t;return o(h).forEach(function(l){c.append(l)}),f.type?c.getBlob(f.type):c.getBlob()}function u(h,f){return new Blob(o(h),f||{})}return typeof Blob<"u"&&(i.prototype=Blob.prototype,u.prototype=Blob.prototype),fe=function(){return e?r?Blob:u:n?i:void 0}(),fe}(function(t){var e=vn,r=Ve(),n=kn,o=bn,i=On,u;typeof ArrayBuffer<"u"&&(u=xn());var h=typeof navigator<"u"&&/Android/i.test(navigator.userAgent),f=typeof navigator<"u"&&/PhantomJS/i.test(navigator.userAgent),c=h||f;t.protocol=3;var l=t.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},p=e(l),a={type:"error",data:"parser error"},s=Rn();t.encodePacket=function(b,S,m,C){typeof S=="function"&&(C=S,S=!1),typeof m=="function"&&(C=m,m=null);var E=b.data===void 0?void 0:b.data.buffer||b.data;if(typeof ArrayBuffer<"u"&&E instanceof ArrayBuffer)return y(b,S,C);if(typeof s<"u"&&E instanceof s)return w(b,S,C);if(E&&E.base64)return d(b,C);var v=l[b.type];return b.data!==void 0&&(v+=m?i.encode(String(b.data),{strict:!1}):String(b.data)),C(""+v)};function d(b,S){var m="b"+t.packets[b.type]+b.data.data;return S(m)}function y(b,S,m){if(!S)return t.encodeBase64Packet(b,m);var C=b.data,E=new Uint8Array(C),v=new Uint8Array(1+C.byteLength);v[0]=l[b.type];for(var k=0;k<E.length;k++)v[k+1]=E[k];return m(v.buffer)}function g(b,S,m){if(!S)return t.encodeBase64Packet(b,m);var C=new FileReader;return C.onload=function(){t.encodePacket({type:b.type,data:C.result},S,!0,m)},C.readAsArrayBuffer(b.data)}function w(b,S,m){if(!S)return t.encodeBase64Packet(b,m);if(c)return g(b,S,m);var C=new Uint8Array(1);C[0]=l[b.type];var E=new s([C.buffer,b.data]);return m(E)}t.encodeBase64Packet=function(b,S){var m="b"+t.packets[b.type];if(typeof s<"u"&&b.data instanceof s){var C=new FileReader;return C.onload=function(){var O=C.result.split(",")[1];S(m+O)},C.readAsDataURL(b.data)}var E;try{E=String.fromCharCode.apply(null,new Uint8Array(b.data))}catch{for(var v=new Uint8Array(b.data),k=new Array(v.length),T=0;T<v.length;T++)k[T]=v[T];E=String.fromCharCode.apply(null,k)}return m+=btoa(E),S(m)},t.decodePacket=function(b,S,m){if(b===void 0)return a;if(typeof b=="string"){if(b.charAt(0)==="b")return t.decodeBase64Packet(b.substr(1),S);if(m&&(b=_(b),b===!1))return a;var E=b.charAt(0);return Number(E)!=E||!p[E]?a:b.length>1?{type:p[E],data:b.substring(1)}:{type:p[E]}}var C=new Uint8Array(b),E=C[0],v=n(b,1);return s&&S==="blob"&&(v=new s([v])),{type:p[E],data:v}};function _(b){try{b=i.decode(b,{strict:!1})}catch{return!1}return b}t.decodeBase64Packet=function(b,S){var m=p[b.charAt(0)];if(!u)return{type:m,data:{base64:!0,data:b.substr(1)}};var C=u.decode(b.substr(1));return S==="blob"&&s&&(C=new s([C])),{type:m,data:C}},t.encodePayload=function(b,S,m){typeof S=="function"&&(m=S,S=null);var C=r(b);if(S&&C)return s&&!c?t.encodePayloadAsBlob(b,m):t.encodePayloadAsArrayBuffer(b,m);if(!b.length)return m("0:");function E(k){return k.length+":"+k}function v(k,T){t.encodePacket(k,C?S:!1,!1,function(O){T(null,E(O))})}B(b,v,function(k,T){return m(T.join(""))})};function B(b,S,m){for(var C=new Array(b.length),E=o(b.length,m),v=function(T,O,x){S(O,function(A,q){C[T]=q,x(A,C)})},k=0;k<b.length;k++)v(k,b[k],E)}t.decodePayload=function(b,S,m){if(typeof b!="string")return t.decodePayloadAsBinary(b,S,m);typeof S=="function"&&(m=S,S=null);var C;if(b==="")return m(a,0,1);for(var E="",v,k,T=0,O=b.length;T<O;T++){var x=b.charAt(T);if(x!==":"){E+=x;continue}if(E===""||E!=(v=Number(E))||(k=b.substr(T+1,v),E!=k.length))return m(a,0,1);if(k.length){if(C=t.decodePacket(k,S,!1),a.type===C.type&&a.data===C.data)return m(a,0,1);var A=m(C,T+v,O);if(A===!1)return}T+=v,E=""}if(E!=="")return m(a,0,1)},t.encodePayloadAsArrayBuffer=function(b,S){if(!b.length)return S(new ArrayBuffer(0));function m(C,E){t.encodePacket(C,!0,!0,function(v){return E(null,v)})}B(b,m,function(C,E){var v=E.reduce(function(O,x){var A;return typeof x=="string"?A=x.length:A=x.byteLength,O+A.toString().length+A+2},0),k=new Uint8Array(v),T=0;return E.forEach(function(O){var x=typeof O=="string",A=O;if(x){for(var q=new Uint8Array(O.length),j=0;j<O.length;j++)q[j]=O.charCodeAt(j);A=q.buffer}x?k[T++]=0:k[T++]=1;for(var G=A.byteLength.toString(),j=0;j<G.length;j++)k[T++]=parseInt(G[j]);k[T++]=255;for(var q=new Uint8Array(A),j=0;j<q.length;j++)k[T++]=q[j]}),S(k.buffer)})},t.encodePayloadAsBlob=function(b,S){function m(C,E){t.encodePacket(C,!0,!0,function(v){var k=new Uint8Array(1);if(k[0]=1,typeof v=="string"){for(var T=new Uint8Array(v.length),O=0;O<v.length;O++)T[O]=v.charCodeAt(O);v=T.buffer,k[0]=0}for(var x=v instanceof ArrayBuffer?v.byteLength:v.size,A=x.toString(),q=new Uint8Array(A.length+1),O=0;O<A.length;O++)q[O]=parseInt(A[O]);if(q[A.length]=255,s){var j=new s([k.buffer,q.buffer,v]);E(null,j)}})}B(b,m,function(C,E){return S(new s(E))})},t.decodePayloadAsBinary=function(b,S,m){typeof S=="function"&&(m=S,S=null);for(var C=b,E=[];C.byteLength>0;){for(var v=new Uint8Array(C),k=v[0]===0,T="",O=1;v[O]!==255;O++){if(T.length>310)return m(a,0,1);T+=v[O]}C=n(C,2+T.length),T=parseInt(T);var x=n(C,0,T);if(k)try{x=String.fromCharCode.apply(null,new Uint8Array(x))}catch{var A=new Uint8Array(x);x="";for(var O=0;O<A.length;O++)x+=String.fromCharCode(A[O])}E.push(x),C=n(C,T)}var q=E.length;E.forEach(function(j,G){m(t.decodePacket(j,S,!0),G,q)})}})(wt);var de,Ze;function ye(){if(Ze)return de;Ze=1;var t=wt,e=St;de=r;function r(n){this.path=n.path,this.hostname=n.hostname,this.port=n.port,this.secure=n.secure,this.query=n.query,this.timestampParam=n.timestampParam,this.timestampRequests=n.timestampRequests,this.readyState="",this.agent=n.agent||!1,this.socket=n.socket,this.enablesXDR=n.enablesXDR,this.withCredentials=n.withCredentials,this.pfx=n.pfx,this.key=n.key,this.passphrase=n.passphrase,this.cert=n.cert,this.ca=n.ca,this.ciphers=n.ciphers,this.rejectUnauthorized=n.rejectUnauthorized,this.forceNode=n.forceNode,this.isReactNative=n.isReactNative,this.extraHeaders=n.extraHeaders,this.localAddress=n.localAddress}return e(r.prototype),r.prototype.onError=function(n,o){var i=new Error(n);return i.type="TransportError",i.description=o,this.emit("error",i),this},r.prototype.open=function(){return(this.readyState==="closed"||this.readyState==="")&&(this.readyState="opening",this.doOpen()),this},r.prototype.close=function(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this},r.prototype.send=function(n){if(this.readyState==="open")this.write(n);else throw new Error("Transport not open")},r.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},r.prototype.onData=function(n){var o=t.decodePacket(n,this.socket.binaryType);this.onPacket(o)},r.prototype.onPacket=function(n){this.emit("packet",n)},r.prototype.onClose=function(){this.readyState="closed",this.emit("close")},de}var ge={},tr;function Wt(){return tr||(tr=1,ge.encode=function(t){var e="";for(var r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e},ge.decode=function(t){for(var e={},r=t.split("&"),n=0,o=r.length;n<o;n++){var i=r[n].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}),ge}var Kt=function(t,e){var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t},er="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Ht=64,rr={},nr=0,mt=0,or;function me(t){var e="";do e=er[t%Ht]+e,t=Math.floor(t/Ht);while(t>0);return e}function In(t){var e=0;for(mt=0;mt<t.length;mt++)e=e*Ht+rr[t.charAt(mt)];return e}function ve(){var t=me(+new Date);return t!==or?(nr=0,or=t):t+"."+me(nr++)}for(;mt<Ht;mt++)rr[er[mt]]=mt;ve.encode=me,ve.decode=In;var sr=ve,ir=ye(),_n=Wt(),ar=wt,Bn=Kt,Ln=sr,ct=ft("engine.io-client:polling"),cr=ut,Un=function(){var t=ce,e=new t({xdomain:!1});return e.responseType!=null}();function ut(t){var e=t&&t.forceBase64;(!Un||e)&&(this.supportsBinary=!1),ir.call(this,t)}Bn(ut,ir),ut.prototype.name="polling",ut.prototype.doOpen=function(){this.poll()},ut.prototype.pause=function(t){var e=this;this.readyState="pausing";function r(){ct("paused"),e.readyState="paused",t()}if(this.polling||!this.writable){var n=0;this.polling&&(ct("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){ct("pre-pause polling complete"),--n||r()})),this.writable||(ct("we are currently writing - waiting to pause"),n++,this.once("drain",function(){ct("pre-pause writing complete"),--n||r()}))}else r()},ut.prototype.poll=function(){ct("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},ut.prototype.onData=function(t){var e=this;ct("polling got data %s",t);var r=function(n,o,i){if(e.readyState==="opening"&&n.type==="open"&&e.onOpen(),n.type==="close")return e.onClose(),!1;e.onPacket(n)};ar.decodePayload(t,this.socket.binaryType,r),this.readyState!=="closed"&&(this.polling=!1,this.emit("pollComplete"),this.readyState==="open"?this.poll():ct('ignoring poll - transport state "%s"',this.readyState))},ut.prototype.doClose=function(){var t=this;function e(){ct("writing close packet"),t.write([{type:"close"}])}this.readyState==="open"?(ct("transport open - closing"),e()):(ct("transport not open - deferring close"),this.once("open",e))},ut.prototype.write=function(t){var e=this;this.writable=!1;var r=function(){e.writable=!0,e.emit("drain")};ar.encodePayload(t,this.supportsBinary,function(n){e.doWrite(n,r)})},ut.prototype.uri=function(){var t=this.query||{},e=this.secure?"https":"http",r="";this.timestampRequests!==!1&&(t[this.timestampParam]=Ln()),!this.supportsBinary&&!t.sid&&(t.b64=1),t=_n.encode(t),this.port&&(e==="https"&&Number(this.port)!==443||e==="http"&&Number(this.port)!==80)&&(r=":"+this.port),t.length&&(t="?"+t);var n=this.hostname.indexOf(":")!==-1;return e+"://"+(n?"["+this.hostname+"]":this.hostname)+r+this.path+t};var Dn=ce,hr=cr,Pn=St,Fn=Kt,ke=ft("engine.io-client:polling-xhr"),jn=ae;he.exports=At,he.exports.Request=Q;function pr(){}function At(t){if(hr.call(this,t),this.requestTimeout=t.requestTimeout,this.extraHeaders=t.extraHeaders,typeof location<"u"){var e=location.protocol==="https:",r=location.port;r||(r=e?443:80),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port,this.xs=t.secure!==e}}Fn(At,hr),At.prototype.supportsBinary=!0,At.prototype.request=function(t){return t=t||{},t.uri=this.uri(),t.xd=this.xd,t.xs=this.xs,t.agent=this.agent||!1,t.supportsBinary=this.supportsBinary,t.enablesXDR=this.enablesXDR,t.withCredentials=this.withCredentials,t.pfx=this.pfx,t.key=this.key,t.passphrase=this.passphrase,t.cert=this.cert,t.ca=this.ca,t.ciphers=this.ciphers,t.rejectUnauthorized=this.rejectUnauthorized,t.requestTimeout=this.requestTimeout,t.extraHeaders=this.extraHeaders,new Q(t)},At.prototype.doWrite=function(t,e){var r=typeof t!="string"&&t!==void 0,n=this.request({method:"POST",data:t,isBinary:r}),o=this;n.on("success",e),n.on("error",function(i){o.onError("xhr post error",i)}),this.sendXhr=n},At.prototype.doPoll=function(){ke("xhr poll");var t=this.request(),e=this;t.on("data",function(r){e.onData(r)}),t.on("error",function(r){e.onError("xhr poll error",r)}),this.pollXhr=t};function Q(t){this.method=t.method||"GET",this.uri=t.uri,this.xd=!!t.xd,this.xs=!!t.xs,this.async=t.async!==!1,this.data=t.data!==void 0?t.data:null,this.agent=t.agent,this.isBinary=t.isBinary,this.supportsBinary=t.supportsBinary,this.enablesXDR=t.enablesXDR,this.withCredentials=t.withCredentials,this.requestTimeout=t.requestTimeout,this.pfx=t.pfx,this.key=t.key,this.passphrase=t.passphrase,this.cert=t.cert,this.ca=t.ca,this.ciphers=t.ciphers,this.rejectUnauthorized=t.rejectUnauthorized,this.extraHeaders=t.extraHeaders,this.create()}if(Pn(Q.prototype),Q.prototype.create=function(){var t={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};t.pfx=this.pfx,t.key=this.key,t.passphrase=this.passphrase,t.cert=this.cert,t.ca=this.ca,t.ciphers=this.ciphers,t.rejectUnauthorized=this.rejectUnauthorized;var e=this.xhr=new Dn(t),r=this;try{ke("xhr open %s: %s",this.method,this.uri),e.open(this.method,this.uri,this.async);try{if(this.extraHeaders){e.setDisableHeaderCheck&&e.setDisableHeaderCheck(!0);for(var n in this.extraHeaders)this.extraHeaders.hasOwnProperty(n)&&e.setRequestHeader(n,this.extraHeaders[n])}}catch{}if(this.method==="POST")try{this.isBinary?e.setRequestHeader("Content-type","application/octet-stream"):e.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{e.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in e&&(e.withCredentials=this.withCredentials),this.requestTimeout&&(e.timeout=this.requestTimeout),this.hasXDR()?(e.onload=function(){r.onLoad()},e.onerror=function(){r.onError(e.responseText)}):e.onreadystatechange=function(){if(e.readyState===2)try{var o=e.getResponseHeader("Content-Type");(r.supportsBinary&&o==="application/octet-stream"||o==="application/octet-stream; charset=UTF-8")&&(e.responseType="arraybuffer")}catch{}e.readyState===4&&(e.status===200||e.status===1223?r.onLoad():setTimeout(function(){r.onError(typeof e.status=="number"?e.status:0)},0))},ke("xhr data %s",this.data),e.send(this.data)}catch(o){setTimeout(function(){r.onError(o)},0);return}typeof document<"u"&&(this.index=Q.requestsCount++,Q.requests[this.index]=this)},Q.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},Q.prototype.onData=function(t){this.emit("data",t),this.onSuccess()},Q.prototype.onError=function(t){this.emit("error",t),this.cleanup(!0)},Q.prototype.cleanup=function(t){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=pr:this.xhr.onreadystatechange=pr,t)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Q.requests[this.index],this.xhr=null}},Q.prototype.onLoad=function(){var t;try{var e;try{e=this.xhr.getResponseHeader("Content-Type")}catch{}e==="application/octet-stream"||e==="application/octet-stream; charset=UTF-8"?t=this.xhr.response||this.xhr.responseText:t=this.xhr.responseText}catch(r){this.onError(r)}t!=null&&this.onData(t)},Q.prototype.hasXDR=function(){return typeof XDomainRequest<"u"&&!this.xs&&this.enablesXDR},Q.prototype.abort=function(){this.cleanup()},Q.requestsCount=0,Q.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",ur);else if(typeof addEventListener=="function"){var Mn="onpagehide"in jn?"pagehide":"unload";addEventListener(Mn,ur,!1)}}function ur(){for(var t in Q.requests)Q.requests.hasOwnProperty(t)&&Q.requests[t].abort()}var qn=he.exports,be=cr,zn=Kt,lr=ae,Xn=Tt,Wn=/\n/g,Kn=/\\n/g,Jt;function Hn(){}function Tt(t){be.call(this,t),this.query=this.query||{},Jt||(Jt=lr.___eio=lr.___eio||[]),this.index=Jt.length;var e=this;Jt.push(function(r){e.onData(r)}),this.query.j=this.index,typeof addEventListener=="function"&&addEventListener("beforeunload",function(){e.script&&(e.script.onerror=Hn)},!1)}zn(Tt,be),Tt.prototype.supportsBinary=!1,Tt.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),be.prototype.doClose.call(this)},Tt.prototype.doPoll=function(){var t=this,e=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=function(o){t.onError("jsonp poll error",o)};var r=document.getElementsByTagName("script")[0];r?r.parentNode.insertBefore(e,r):(document.head||document.body).appendChild(e),this.script=e;var n=typeof navigator<"u"&&/gecko/i.test(navigator.userAgent);n&&setTimeout(function(){var o=document.createElement("iframe");document.body.appendChild(o),document.body.removeChild(o)},100)},Tt.prototype.doWrite=function(t,e){var r=this;if(!this.form){var n=document.createElement("form"),o=document.createElement("textarea"),i=this.iframeId="eio_iframe_"+this.index,u;n.className="socketio",n.style.position="absolute",n.style.top="-1000px",n.style.left="-1000px",n.target=i,n.method="POST",n.setAttribute("accept-charset","utf-8"),o.name="d",n.appendChild(o),document.body.appendChild(n),this.form=n,this.area=o}this.form.action=this.uri();function h(){f(),e()}function f(){if(r.iframe)try{r.form.removeChild(r.iframe)}catch(l){r.onError("jsonp polling iframe removal error",l)}try{var c='<iframe src="javascript:0" name="'+r.iframeId+'">';u=document.createElement(c)}catch{u=document.createElement("iframe"),u.name=r.iframeId,u.src="javascript:0"}u.id=r.iframeId,r.form.appendChild(u),r.iframe=u}f(),t=t.replace(Kn,`\\
7
+ `),this.area.value=t.replace(Wn,"\\n");try{this.form.submit()}catch{}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){r.iframe.readyState==="complete"&&h()}:this.iframe.onload=h};const Jn={},Vn=Object.freeze(Object.defineProperty({__proto__:null,default:Jn},Symbol.toStringTag,{value:"Module"})),$n=Jr(Vn);var Ce=ye(),Gn=wt,Yn=Wt(),Qn=Kt,Zn=sr,to=ft("engine.io-client:websocket"),Vt,we;if(typeof WebSocket<"u"?Vt=WebSocket:typeof self<"u"&&(Vt=self.WebSocket||self.MozWebSocket),typeof window>"u")try{we=$n}catch{}var Nt=Vt||we,eo=it;function it(t){var e=t&&t.forceBase64;e&&(this.supportsBinary=!1),this.perMessageDeflate=t.perMessageDeflate,this.usingBrowserWebSocket=Vt&&!t.forceNode,this.protocols=t.protocols,this.usingBrowserWebSocket||(Nt=we),Ce.call(this,t)}Qn(it,Ce),it.prototype.name="websocket",it.prototype.supportsBinary=!0,it.prototype.doOpen=function(){if(this.check()){var t=this.uri(),e=this.protocols,r={};this.isReactNative||(r.agent=this.agent,r.perMessageDeflate=this.perMessageDeflate,r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized),this.extraHeaders&&(r.headers=this.extraHeaders),this.localAddress&&(r.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?e?new Nt(t,e):new Nt(t):new Nt(t,e,r)}catch(n){return this.emit("error",n)}this.ws.binaryType===void 0&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},it.prototype.addEventListeners=function(){var t=this;this.ws.onopen=function(){t.onOpen()},this.ws.onclose=function(){t.onClose()},this.ws.onmessage=function(e){t.onData(e.data)},this.ws.onerror=function(e){t.onError("websocket error",e)}},it.prototype.write=function(t){var e=this;this.writable=!1;for(var r=t.length,n=0,o=r;n<o;n++)(function(u){Gn.encodePacket(u,e.supportsBinary,function(h){if(!e.usingBrowserWebSocket){var f={};if(u.options&&(f.compress=u.options.compress),e.perMessageDeflate){var c=typeof h=="string"?Buffer.byteLength(h):h.length;c<e.perMessageDeflate.threshold&&(f.compress=!1)}}try{e.usingBrowserWebSocket?e.ws.send(h):e.ws.send(h,f)}catch{to("websocket closed before onclose event")}--r||i()})})(t[n]);function i(){e.emit("flush"),setTimeout(function(){e.writable=!0,e.emit("drain")},0)}},it.prototype.onClose=function(){Ce.prototype.onClose.call(this)},it.prototype.doClose=function(){typeof this.ws<"u"&&this.ws.close()},it.prototype.uri=function(){var t=this.query||{},e=this.secure?"wss":"ws",r="";this.port&&(e==="wss"&&Number(this.port)!==443||e==="ws"&&Number(this.port)!==80)&&(r=":"+this.port),this.timestampRequests&&(t[this.timestampParam]=Zn()),this.supportsBinary||(t.b64=1),t=Yn.encode(t),t.length&&(t="?"+t);var n=this.hostname.indexOf(":")!==-1;return e+"://"+(n?"["+this.hostname+"]":this.hostname)+r+this.path+t},it.prototype.check=function(){return!!Nt&&!("__initialize"in Nt&&this.name===it.prototype.name)};var ro=ce,no=qn,oo=Xn,so=eo;qt.polling=io,qt.websocket=so;function io(t){var e,r=!1,n=!1,o=t.jsonp!==!1;if(typeof location<"u"){var i=location.protocol==="https:",u=location.port;u||(u=i?443:80),r=t.hostname!==location.hostname||u!==t.port,n=t.secure!==i}if(t.xdomain=r,t.xscheme=n,e=new ro(t),"open"in e&&!t.forceJSONP)return new no(t);if(!o)throw new Error("JSONP disabled");return new oo(t)}var ao=[].indexOf,fr=function(t,e){if(ao)return t.indexOf(e);for(var r=0;r<t.length;++r)if(t[r]===e)return r;return-1},co=qt,ho=St,Y=ft("engine.io-client:socket"),po=fr,dr=wt,yr=qe,uo=Wt(),lo=X;function X(t,e){if(!(this instanceof X))return new X(t,e);e=e||{},t&&typeof t=="object"&&(e=t,t=null),t?(t=yr(t),e.hostname=t.host,e.secure=t.protocol==="https"||t.protocol==="wss",e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=yr(e.host).host),this.secure=e.secure!=null?e.secure:typeof location<"u"&&location.protocol==="https:",e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.agent=e.agent||!1,this.hostname=e.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=e.port||(typeof location<"u"&&location.port?location.port:this.secure?443:80),this.query=e.query||{},typeof this.query=="string"&&(this.query=uo.decode(this.query)),this.upgrade=e.upgrade!==!1,this.path=(e.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!e.forceJSONP,this.jsonp=e.jsonp!==!1,this.forceBase64=!!e.forceBase64,this.enablesXDR=!!e.enablesXDR,this.withCredentials=e.withCredentials!==!1,this.timestampParam=e.timestampParam||"t",this.timestampRequests=e.timestampRequests,this.transports=e.transports||["polling","websocket"],this.transportOptions=e.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=e.policyPort||843,this.rememberUpgrade=e.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=e.onlyBinaryUpgrades,this.perMessageDeflate=e.perMessageDeflate!==!1?e.perMessageDeflate||{}:!1,this.perMessageDeflate===!0&&(this.perMessageDeflate={}),this.perMessageDeflate&&this.perMessageDeflate.threshold==null&&(this.perMessageDeflate.threshold=1024),this.pfx=e.pfx||void 0,this.key=e.key||void 0,this.passphrase=e.passphrase||void 0,this.cert=e.cert||void 0,this.ca=e.ca||void 0,this.ciphers=e.ciphers||void 0,this.rejectUnauthorized=e.rejectUnauthorized===void 0?!0:e.rejectUnauthorized,this.forceNode=!!e.forceNode,this.isReactNative=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",(typeof self>"u"||this.isReactNative)&&(e.extraHeaders&&Object.keys(e.extraHeaders).length>0&&(this.extraHeaders=e.extraHeaders),e.localAddress&&(this.localAddress=e.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}X.priorWebsocketSuccess=!1,ho(X.prototype),X.protocol=dr.protocol,X.Socket=X,X.Transport=ye(),X.transports=qt,X.parser=wt,X.prototype.createTransport=function(t){Y('creating transport "%s"',t);var e=fo(this.query);e.EIO=dr.protocol,e.transport=t;var r=this.transportOptions[t]||{};this.id&&(e.sid=this.id);var n=new co[t]({query:e,socket:this,agent:r.agent||this.agent,hostname:r.hostname||this.hostname,port:r.port||this.port,secure:r.secure||this.secure,path:r.path||this.path,forceJSONP:r.forceJSONP||this.forceJSONP,jsonp:r.jsonp||this.jsonp,forceBase64:r.forceBase64||this.forceBase64,enablesXDR:r.enablesXDR||this.enablesXDR,withCredentials:r.withCredentials||this.withCredentials,timestampRequests:r.timestampRequests||this.timestampRequests,timestampParam:r.timestampParam||this.timestampParam,policyPort:r.policyPort||this.policyPort,pfx:r.pfx||this.pfx,key:r.key||this.key,passphrase:r.passphrase||this.passphrase,cert:r.cert||this.cert,ca:r.ca||this.ca,ciphers:r.ciphers||this.ciphers,rejectUnauthorized:r.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:r.perMessageDeflate||this.perMessageDeflate,extraHeaders:r.extraHeaders||this.extraHeaders,forceNode:r.forceNode||this.forceNode,localAddress:r.localAddress||this.localAddress,requestTimeout:r.requestTimeout||this.requestTimeout,protocols:r.protocols||void 0,isReactNative:this.isReactNative});return n};function fo(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}X.prototype.open=function(){var t;if(this.rememberUpgrade&&X.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)t="websocket";else if(this.transports.length===0){var e=this;setTimeout(function(){e.emit("error","No transports available")},0);return}else t=this.transports[0];this.readyState="opening";try{t=this.createTransport(t)}catch{this.transports.shift(),this.open();return}t.open(),this.setTransport(t)},X.prototype.setTransport=function(t){Y("setting transport %s",t.name);var e=this;this.transport&&(Y("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on("drain",function(){e.onDrain()}).on("packet",function(r){e.onPacket(r)}).on("error",function(r){e.onError(r)}).on("close",function(){e.onClose("transport close")})},X.prototype.probe=function(t){Y('probing transport "%s"',t);var e=this.createTransport(t,{probe:1}),r=!1,n=this;X.priorWebsocketSuccess=!1;function o(){if(n.onlyBinaryUpgrades){var p=!this.supportsBinary&&n.transport.supportsBinary;r=r||p}r||(Y('probe transport "%s" opened',t),e.send([{type:"ping",data:"probe"}]),e.once("packet",function(a){if(!r)if(a.type==="pong"&&a.data==="probe"){if(Y('probe transport "%s" pong',t),n.upgrading=!0,n.emit("upgrading",e),!e)return;X.priorWebsocketSuccess=e.name==="websocket",Y('pausing current transport "%s"',n.transport.name),n.transport.pause(function(){r||n.readyState!=="closed"&&(Y("changing transport and sending upgrade packet"),l(),n.setTransport(e),e.send([{type:"upgrade"}]),n.emit("upgrade",e),e=null,n.upgrading=!1,n.flush())})}else{Y('probe transport "%s" failed',t);var s=new Error("probe error");s.transport=e.name,n.emit("upgradeError",s)}}))}function i(){r||(r=!0,l(),e.close(),e=null)}function u(p){var a=new Error("probe error: "+p);a.transport=e.name,i(),Y('probe transport "%s" failed because of error: %s',t,p),n.emit("upgradeError",a)}function h(){u("transport closed")}function f(){u("socket closed")}function c(p){e&&p.name!==e.name&&(Y('"%s" works - aborting "%s"',p.name,e.name),i())}function l(){e.removeListener("open",o),e.removeListener("error",u),e.removeListener("close",h),n.removeListener("close",f),n.removeListener("upgrading",c)}e.once("open",o),e.once("error",u),e.once("close",h),this.once("close",f),this.once("upgrading",c),e.open()},X.prototype.onOpen=function(){if(Y("socket open"),this.readyState="open",X.priorWebsocketSuccess=this.transport.name==="websocket",this.emit("open"),this.flush(),this.readyState==="open"&&this.upgrade&&this.transport.pause){Y("starting upgrade probes");for(var t=0,e=this.upgrades.length;t<e;t++)this.probe(this.upgrades[t])}},X.prototype.onPacket=function(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(Y('socket receive: type "%s", data "%s"',t.type,t.data),this.emit("packet",t),this.emit("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emit("data",t.data),this.emit("message",t.data);break}else Y('packet received with socket readyState "%s"',this.readyState)},X.prototype.onHandshake=function(t){this.emit("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),this.readyState!=="closed"&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},X.prototype.onHeartbeat=function(t){clearTimeout(this.pingTimeoutTimer);var e=this;e.pingTimeoutTimer=setTimeout(function(){e.readyState!=="closed"&&e.onClose("ping timeout")},t||e.pingInterval+e.pingTimeout)},X.prototype.setPing=function(){var t=this;clearTimeout(t.pingIntervalTimer),t.pingIntervalTimer=setTimeout(function(){Y("writing ping packet - expecting pong within %sms",t.pingTimeout),t.ping(),t.onHeartbeat(t.pingTimeout)},t.pingInterval)},X.prototype.ping=function(){var t=this;this.sendPacket("ping",function(){t.emit("ping")})},X.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emit("drain"):this.flush()},X.prototype.flush=function(){this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(Y("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},X.prototype.write=X.prototype.send=function(t,e,r){return this.sendPacket("message",t,e,r),this},X.prototype.sendPacket=function(t,e,r,n){if(typeof e=="function"&&(n=e,e=void 0),typeof r=="function"&&(n=r,r=null),!(this.readyState==="closing"||this.readyState==="closed")){r=r||{},r.compress=r.compress!==!1;var o={type:t,data:e,options:r};this.emit("packetCreate",o),this.writeBuffer.push(o),n&&this.once("flush",n),this.flush()}},X.prototype.close=function(){if(this.readyState==="opening"||this.readyState==="open"){this.readyState="closing";var t=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?n():e()}):this.upgrading?n():e()}function e(){t.onClose("forced close"),Y("socket closing - telling transport to close"),t.transport.close()}function r(){t.removeListener("upgrade",r),t.removeListener("upgradeError",r),e()}function n(){t.once("upgrade",r),t.once("upgradeError",r)}return this},X.prototype.onError=function(t){Y("socket error %j",t),X.priorWebsocketSuccess=!1,this.emit("error",t),this.onClose("transport error",t)},X.prototype.onClose=function(t,e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){Y('socket close with reason: "%s"',t);var r=this;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",t,e),r.writeBuffer=[],r.prevBufferLen=0}},X.prototype.filterUpgrades=function(t){for(var e=[],r=0,n=t.length;r<n;r++)~po(this.transports,t[r])&&e.push(t[r]);return e},se.exports=lo,se.exports.parser=wt;var yo=se.exports,gr={exports:{}},Se,mr;function go(){if(mr)return Se;mr=1,Se=t;function t(e,r){var n=[];r=r||0;for(var o=r||0;o<e.length;o++)n[o-r]=e[o];return n}return Se}var vr=mo;function mo(t,e,r){return t.on(e,r),{destroy:function(){t.removeListener(e,r)}}}var kr=[].slice,br=function(t,e){if(typeof e=="string"&&(e=t[e]),typeof e!="function")throw new Error("bind() requires a function");var r=kr.call(arguments,2);return function(){return e.apply(t,r.concat(kr.call(arguments)))}},Cr;function wr(){return Cr||(Cr=1,function(t,e){var r=jt,n=St,o=go(),i=vr,u=br,h=ft("socket.io-client:socket"),f=Wt(),c=Ve();t.exports=a;var l={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},p=n.prototype.emit;function a(s,d,y){this.io=s,this.nsp=d,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},y&&y.query&&(this.query=y.query),this.io.autoConnect&&this.open()}n(a.prototype),a.prototype.subEvents=function(){if(!this.subs){var s=this.io;this.subs=[i(s,"open",u(this,"onopen")),i(s,"packet",u(this,"onpacket")),i(s,"close",u(this,"onclose"))]}},a.prototype.open=a.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.reconnecting||this.io.open(),this.io.readyState==="open"&&this.onopen(),this.emit("connecting"),this)},a.prototype.send=function(){var s=o(arguments);return s.unshift("message"),this.emit.apply(this,s),this},a.prototype.emit=function(s){if(l.hasOwnProperty(s))return p.apply(this,arguments),this;var d=o(arguments),y={type:(this.flags.binary!==void 0?this.flags.binary:c(d))?r.BINARY_EVENT:r.EVENT,data:d};return y.options={},y.options.compress=!this.flags||this.flags.compress!==!1,typeof d[d.length-1]=="function"&&(h("emitting packet with ack id %d",this.ids),this.acks[this.ids]=d.pop(),y.id=this.ids++),this.connected?this.packet(y):this.sendBuffer.push(y),this.flags={},this},a.prototype.packet=function(s){s.nsp=this.nsp,this.io.packet(s)},a.prototype.onopen=function(){if(h("transport is open - connecting"),this.nsp!=="/")if(this.query){var s=typeof this.query=="object"?f.encode(this.query):this.query;h("sending connect packet with query %s",s),this.packet({type:r.CONNECT,query:s})}else this.packet({type:r.CONNECT})},a.prototype.onclose=function(s){h("close (%s)",s),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",s)},a.prototype.onpacket=function(s){var d=s.nsp===this.nsp,y=s.type===r.ERROR&&s.nsp==="/";if(!(!d&&!y))switch(s.type){case r.CONNECT:this.onconnect();break;case r.EVENT:this.onevent(s);break;case r.BINARY_EVENT:this.onevent(s);break;case r.ACK:this.onack(s);break;case r.BINARY_ACK:this.onack(s);break;case r.DISCONNECT:this.ondisconnect();break;case r.ERROR:this.emit("error",s.data);break}},a.prototype.onevent=function(s){var d=s.data||[];h("emitting event %j",d),s.id!=null&&(h("attaching ack callback to event"),d.push(this.ack(s.id))),this.connected?p.apply(this,d):this.receiveBuffer.push(d)},a.prototype.ack=function(s){var d=this,y=!1;return function(){if(!y){y=!0;var g=o(arguments);h("sending ack %j",g),d.packet({type:c(g)?r.BINARY_ACK:r.ACK,id:s,data:g})}}},a.prototype.onack=function(s){var d=this.acks[s.id];typeof d=="function"?(h("calling ack %s with %j",s.id,s.data),d.apply(this,s.data),delete this.acks[s.id]):h("bad ack %s",s.id)},a.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emit("connect")},a.prototype.emitBuffered=function(){var s;for(s=0;s<this.receiveBuffer.length;s++)p.apply(this,this.receiveBuffer[s]);for(this.receiveBuffer=[],s=0;s<this.sendBuffer.length;s++)this.packet(this.sendBuffer[s]);this.sendBuffer=[]},a.prototype.ondisconnect=function(){h("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},a.prototype.destroy=function(){if(this.subs){for(var s=0;s<this.subs.length;s++)this.subs[s].destroy();this.subs=null}this.io.destroy(this)},a.prototype.close=a.prototype.disconnect=function(){return this.connected&&(h("performing disconnect (%s)",this.nsp),this.packet({type:r.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},a.prototype.compress=function(s){return this.flags.compress=s,this},a.prototype.binary=function(s){return this.flags.binary=s,this}}(gr)),gr.exports}var vo=Ot;function Ot(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Ot.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=Math.floor(e*10)&1?t+r:t-r}return Math.min(t,this.max)|0},Ot.prototype.reset=function(){this.attempts=0},Ot.prototype.setMin=function(t){this.ms=t},Ot.prototype.setMax=function(t){this.max=t},Ot.prototype.setJitter=function(t){this.jitter=t};var ko=yo,bo=wr(),Co=St,wo=jt,vt=vr,xt=br,tt=ft("socket.io-client:manager"),Sr=fr,So=vo,Er=Object.prototype.hasOwnProperty,Ar=K;function K(t,e){if(!(this instanceof K))return new K(t,e);t&&typeof t=="object"&&(e=t,t=void 0),e=e||{},e.path=e.path||"/socket.io",this.nsps={},this.subs=[],this.opts=e,this.reconnection(e.reconnection!==!1),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(e.randomizationFactor||.5),this.backoff=new So({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(e.timeout==null?2e4:e.timeout),this.readyState="closed",this.uri=t,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var r=e.parser||wo;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this.autoConnect=e.autoConnect!==!1,this.autoConnect&&this.open()}K.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var t in this.nsps)Er.call(this.nsps,t)&&this.nsps[t].emit.apply(this.nsps[t],arguments)},K.prototype.updateSocketIds=function(){for(var t in this.nsps)Er.call(this.nsps,t)&&(this.nsps[t].id=this.generateId(t))},K.prototype.generateId=function(t){return(t==="/"?"":t+"#")+this.engine.id},Co(K.prototype),K.prototype.reconnection=function(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection},K.prototype.reconnectionAttempts=function(t){return arguments.length?(this._reconnectionAttempts=t,this):this._reconnectionAttempts},K.prototype.reconnectionDelay=function(t){return arguments.length?(this._reconnectionDelay=t,this.backoff&&this.backoff.setMin(t),this):this._reconnectionDelay},K.prototype.randomizationFactor=function(t){return arguments.length?(this._randomizationFactor=t,this.backoff&&this.backoff.setJitter(t),this):this._randomizationFactor},K.prototype.reconnectionDelayMax=function(t){return arguments.length?(this._reconnectionDelayMax=t,this.backoff&&this.backoff.setMax(t),this):this._reconnectionDelayMax},K.prototype.timeout=function(t){return arguments.length?(this._timeout=t,this):this._timeout},K.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()},K.prototype.open=K.prototype.connect=function(t,e){if(tt("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;tt("opening %s",this.uri),this.engine=ko(this.uri,this.opts);var r=this.engine,n=this;this.readyState="opening",this.skipReconnect=!1;var o=vt(r,"open",function(){n.onopen(),t&&t()}),i=vt(r,"error",function(f){if(tt("connect_error"),n.cleanup(),n.readyState="closed",n.emitAll("connect_error",f),t){var c=new Error("Connection error");c.data=f,t(c)}else n.maybeReconnectOnOpen()});if(this._timeout!==!1){var u=this._timeout;tt("connect attempt will timeout after %d",u),u===0&&o.destroy();var h=setTimeout(function(){tt("connect attempt timed out after %d",u),o.destroy(),r.close(),r.emit("error","timeout"),n.emitAll("connect_timeout",u)},u);this.subs.push({destroy:function(){clearTimeout(h)}})}return this.subs.push(o),this.subs.push(i),this},K.prototype.onopen=function(){tt("open"),this.cleanup(),this.readyState="open",this.emit("open");var t=this.engine;this.subs.push(vt(t,"data",xt(this,"ondata"))),this.subs.push(vt(t,"ping",xt(this,"onping"))),this.subs.push(vt(t,"pong",xt(this,"onpong"))),this.subs.push(vt(t,"error",xt(this,"onerror"))),this.subs.push(vt(t,"close",xt(this,"onclose"))),this.subs.push(vt(this.decoder,"decoded",xt(this,"ondecoded")))},K.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},K.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},K.prototype.ondata=function(t){this.decoder.add(t)},K.prototype.ondecoded=function(t){this.emit("packet",t)},K.prototype.onerror=function(t){tt("error",t),this.emitAll("error",t)},K.prototype.socket=function(t,e){var r=this.nsps[t];if(!r){r=new bo(this,t,e),this.nsps[t]=r;var n=this;r.on("connecting",o),r.on("connect",function(){r.id=n.generateId(t)}),this.autoConnect&&o()}function o(){~Sr(n.connecting,r)||n.connecting.push(r)}return r},K.prototype.destroy=function(t){var e=Sr(this.connecting,t);~e&&this.connecting.splice(e,1),!this.connecting.length&&this.close()},K.prototype.packet=function(t){tt("writing packet %j",t);var e=this;t.query&&t.type===0&&(t.nsp+="?"+t.query),e.encoding?e.packetBuffer.push(t):(e.encoding=!0,this.encoder.encode(t,function(r){for(var n=0;n<r.length;n++)e.engine.write(r[n],t.options);e.encoding=!1,e.processPacketQueue()}))},K.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var t=this.packetBuffer.shift();this.packet(t)}},K.prototype.cleanup=function(){tt("cleanup");for(var t=this.subs.length,e=0;e<t;e++){var r=this.subs.shift();r.destroy()}this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},K.prototype.close=K.prototype.disconnect=function(){tt("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,this.readyState==="opening"&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},K.prototype.onclose=function(t){tt("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",t),this._reconnection&&!this.skipReconnect&&this.reconnect()},K.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var t=this;if(this.backoff.attempts>=this._reconnectionAttempts)tt("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var e=this.backoff.duration();tt("will wait %dms before reconnect attempt",e),this.reconnecting=!0;var r=setTimeout(function(){t.skipReconnect||(tt("attempting reconnect"),t.emitAll("reconnect_attempt",t.backoff.attempts),t.emitAll("reconnecting",t.backoff.attempts),!t.skipReconnect&&t.open(function(n){n?(tt("reconnect attempt error"),t.reconnecting=!1,t.reconnect(),t.emitAll("reconnect_error",n.data)):(tt("reconnect success"),t.onreconnect())}))},e);this.subs.push({destroy:function(){clearTimeout(r)}})}},K.prototype.onreconnect=function(){var t=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",t)},function(t,e){var r=sn,n=jt,o=Ar,i=ft("socket.io-client");t.exports=e=h;var u=e.managers={};function h(f,c){typeof f=="object"&&(c=f,f=void 0),c=c||{};var l=r(f),p=l.source,a=l.id,s=l.path,d=u[a]&&s in u[a].nsps,y=c.forceNew||c["force new connection"]||c.multiplex===!1||d,g;return y?(i("ignoring socket cache for %s",p),g=o(p,c)):(u[a]||(i("new io instance for %s",p),u[a]=o(p,c)),g=u[a]),l.query&&!c.query&&(c.query=l.query),g.socket(l.path,c)}e.protocol=n.protocol,e.connect=h,e.Manager=Ar,e.Socket=wr()}(Qt,Qt.exports);var Eo=Qt.exports;const Ao=Hr(Eo);let $t;const To=new Uint8Array(16);function No(){if(!$t&&($t=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!$t))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return $t(To)}const Z=[];for(let t=0;t<256;++t)Z.push((t+256).toString(16).slice(1));function Oo(t,e=0){return Z[t[e+0]]+Z[t[e+1]]+Z[t[e+2]]+Z[t[e+3]]+"-"+Z[t[e+4]]+Z[t[e+5]]+"-"+Z[t[e+6]]+Z[t[e+7]]+"-"+Z[t[e+8]]+Z[t[e+9]]+"-"+Z[t[e+10]]+Z[t[e+11]]+Z[t[e+12]]+Z[t[e+13]]+Z[t[e+14]]+Z[t[e+15]]}const xo=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Tr={randomUUID:xo};function Ro(t,e,r){if(Tr.randomUUID&&!e&&!t)return Tr.randomUUID();t=t||{};const n=t.random||(t.rng||No)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return Oo(n)}function Io(t,e){const r=e.map(o=>JSON.stringify(o)).join(" "),n=new Date().toISOString();return JSON.stringify({level:t,time:n,message:r})}function _o(t,e){const r=JSON.parse(t);return e.forEach(n=>delete r[n]),r}function Bo(t){if(typeof t=="object"&&t!==null)return t;try{return JSON.parse(t)}catch{return{extraData:t}}}function Lo(t){const e=/\(([^)]+)\)/,r=t.match(e);if(r&&r[1]){const n=r[1].split(";");for(let o of n)if(o=o.trim(),o.startsWith("Windows")||o.startsWith("Macintosh")||o.startsWith("Linux"))return o}return"Unknown"}function Nr(t){return(...e)=>new Promise((r,n)=>{try{const o=t(...e);r(o)}catch(o){n(o)}})}const Uo={reconnection:!0,reconnectionDelay:5e3,reconnectionAttempts:10,upgrade:!1,transports:["websocket"],debug:!1},Ee={logToConsole:!0,overloadGlobalConsole:!1,socketEmitInterval:6e4},ht={CREATE:"Create",READ:"Read",UPDATE:"Update",DELETE:"Delete",CONVERT:"Convert",DOWNLOAD:"Download",UPLOAD:"Upload",ENCRYPT:"Encrypt",DECRYPT:"Decrypt",FILTER:"Filter",INPUT:"Input",OUTPUT:"Output",PLUGIN:"Plugin",LOGIN:"Login",LOGOUT:"Logout",REFRESH:"Refresh",CHECK:"Check",WEBHOOK:"Webhook",WSCONNECT:"WSConnect"},Do={Create:1,Read:2,Update:3,Delete:4,Convert:5,Download:6,Upload:7,Encrypt:8,Decrypt:9,Filter:10,Input:11,Output:12,Plugin:13,Login:14,Logout:15,Refresh:16,Check:17,Webhook:18,WSConnect:19},pt={INFO:"info",WARNING:"warning",MODIFY:"modify",ERROR:"error",VIEW:"view"},et={INFO:"info",WARNING:"warning",ERROR:"error",DEBUG:"debug"};let rt=console;class Po{constructor(e){V(this,"logToConsole"),V(this,"overloadGlobalConsole"),V(this,"system"),V(this,"socketEmitInterval"),V(this,"storageId"),V(this,"emitInProgress"),V(this,"queue"),V(this,"processing"),V(this,"storageInitialized"),V(this,"interval"),V(this,"logIndex"),V(this,"socket"),V(this,"staticObject",{}),V(this,"localObject",{}),V(this,"isGetItemAsync"),V(this,"isSetItemAsync"),V(this,"getItem"),V(this,"setItem"),V(this,"parseLog"),V(this,"_logMethod"),V(this,"_warnMethod"),V(this,"_errorMethod"),V(this,"_debugMethod");const{loggerOptions:r}=e;if(!r.system)throw new Error("Config property 'system' should be provided!");this.isGetItemAsync=r.isGetItemAsync||!1,this.isSetItemAsync=r.isSetItemAsync||!1,this.setupStorageFunctions(r.getItem,r.setItem,r.parseLog),this.system=r.system,this.socketEmitInterval=r.socketEmitInterval||Ee.socketEmitInterval,this.logToConsole=r.logToConsole!==void 0?r.logToConsole:Ee.logToConsole,this.overloadGlobalConsole=r.overloadGlobalConsole!==void 0?r.overloadGlobalConsole:Ee.overloadGlobalConsole,this.storageId=this.getStorageName(),this.queue=[],this.processing=!1,this.storageInitialized=!1,this.emitInProgress=!1,this.logIndex=0,this.init(e)}setupStorageFunctions(e,r,n){this.getItem=e&&typeof e=="function"?this.isGetItemAsync?e:Nr(e):this.defaultGetItemFunction,this.setItem=r&&typeof r=="function"?this.isSetItemAsync?r:Nr(r):this.defaultSetItemFunction,this.parseLog=n&&typeof n=="function"?n:Io}init(e){const{socket:r,url:n,socketOptions:o={}}=e;this._logMethod=rt.log.bind(rt),this._warnMethod=rt.warn.bind(rt),this._errorMethod=rt.error.bind(rt),this._debugMethod=rt.debug.bind(rt),this.initStorage().then(()=>{if(r)this.socket=r;else if(n)this.socket=this.createConnection(n,o);else throw new Error("Must provide either a 'socket' or a 'url' for socket connection");this.interval=setInterval(async()=>{await this.emitLogs()},this.socketEmitInterval),this.overloadGlobalConsole&&this._overloadConsole()})}createConnection(e,r={}){const n={...Uo,...r};return Ao(e,n)}async emitLogs(){if(!this.emitInProgress)try{const e=await this.getItem(this.storageId),r=JSON.parse(e||"{}"),n={...this.localObject,...r};if(!Object.keys(n).length)return;const o=[];this.emitInProgress=!0;const i=Object.keys(n);if(!i.length)return;if(!this.socket||!this.socket.connected)throw new Error("Socket is disconnected");for(const f of i){const c=Bo(n[f]),l={...this.staticObject,...c},p=this.populateSendingLog(l);await this.socket.emit("Log",JSON.stringify(p)),o.push(f)}const u=await this.getItem(this.storageId);if(!u)return;const h=_o(u,o);this.localObject={},await this.setItem(this.storageId,JSON.stringify(h))}catch(e){this._errorMethod(e)}finally{this.emitInProgress=!1}}populateSendingLog(e){const r={...e},n=r.ActionName;return n&&(r.ActionID=Do[n]),r}setupStaticFields(e){this.staticObject={...e}}populateMetaData(){const e=new Date;let r;typeof window<"u"&&typeof window.document<"u"?r=window==null?void 0:window.navigator.userAgent:typeof self<"u"&&self.navigator&&(r=self.navigator.userAgent);let n;return r&&(n=Lo(r)),{System:this.system,DateTime:e,UserAgent:r,OSVersion:n}}async stop(){!this.socket||!this.socket.connected||(clearInterval(this.interval),await this.emitLogs(),this.socket.disconnect())}async start(){this.socket&&this.socket.connected||(this.socket.connect(),this.interval=setInterval(async()=>{await this.emitLogs()},this.socketEmitInterval))}_overloadConsole(){rt=Object.assign(rt,{log:e=>{this.log(e)},warn:e=>{this.warn(e)},error:e=>{this.error(e)},debug:e=>{this.debug(e)}})}async initStorage(){const e=await this.getItem(this.storageId);(!e||typeof e!="string")&&(await this.setItem(this.storageId,JSON.stringify({})),this.storageInitialized=!0)}async resetStorage(){await this.setItem(this.storageId,JSON.stringify({}))}getStorageName(){const e=Ro();return this.system.toString().toUpperCase()+e+Date.now()}async processLog(...e){try{if(e.length<2)return;const r=e[0],n=e[1],o=this.formItemKey(r);if(!this.storageInitialized){this.localObject={...this.localObject,[o]:n};return}const i=await this.getItem(this.storageId);if(!i)return;const u=JSON.parse(i);u[o]=JSON.stringify(n),await this.setItem(this.storageId,JSON.stringify(u))}catch(r){this._errorMethod(r)}}async processQueue(){if(this.processing||this.queue.length===0)return;const e=this.queue.shift();e&&(this.processing=!0,await this.processLog(...e).finally(()=>{this.processing=!1,this.processQueue()}))}log(e){const r={...this.populateMetaData(),...e},n=["INFO",r];this.queue.push(n),this.logToConsole&&this._logMethod.apply(rt,[r]),this.processQueue()}warn(e){const r=["WARN",e];this.queue.push(r),this.logToConsole&&this._warnMethod.apply(rt,[e]),this.processQueue()}error(e){const r=["ERROR",e];this.queue.push(r),this.logToConsole&&this._errorMethod.apply(rt,[e]),this.processQueue()}debug(e){const r=["DEBUG",e];this.queue.push(r),this.logToConsole&&this._debugMethod.apply(rt,[e]),this.processQueue()}async defaultGetItemFunction(e){return localStorage.getItem(e)}async defaultSetItemFunction(e,r){try{localStorage.setItem(e,r)}catch(n){this._errorMethod(n)}}formItemKey(e){const r=new Date().toISOString();return this.logIndex++,`${e}-${this.system}-${r}-${this.logIndex}`}}class Fo{constructor(e){H(this,"delay",1e3);H(this,"lastLoginTimestamp");H(this,"token");H(this,"refreshToken");H(this,"tokenExpiry");H(this,"storageKey");this.eventsSdkClass=e,this.eventsSdkClass=e,this.storageKey=""}async login(){const e={token:this.eventsSdkClass.options.token&&this.eventsSdkClass.options.token,email:this.eventsSdkClass.options.email&&this.eventsSdkClass.options.email,password:this.eventsSdkClass.options.password&&this.eventsSdkClass.options.password};if(this.storageKey=Xr(JSON.stringify({...this.eventsSdkClass.options,loggerSocketConnection:null},this.eventsSdkClass.getCircularReplacer())),this.lastLoginTimestamp&&this.lastLoginTimestamp+this.delay>new Date().getTime())return;this.updateLastLoginTimestamp();const r=await this.checkLoginStatus(this.storageKey);return r||(Rt.clearSessionStorage(),await this.userLoginFunction(e,this.storageKey,this.eventsSdkClass.options.loginType))}updateLastLoginTimestamp(){this.lastLoginTimestamp=new Date().getTime()}async checkLoginStatus(e){const r=await Rt.getSessionStorageDataByKey(e);if(r)return r}async userLoginFunction(e,r,n){let o,i,u;return this.eventsSdkClass.options.isNewStack?(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,e,n),i=await this.getSettings(o.Data.AccessToken),u={...o.Data,...i}):(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,e,n),u={...o.Data.Socket}),await Rt.updateSessionStorageKey(r,u),u}onLoginResponse(e){if(!this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((r,n)=>r.Priority>n.Priority?r:n)),this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((r,n)=>r.Priority>n.Priority?r:n)),e.MonitorList&&e.MonitorList.length&&(this.eventsSdkClass.servers=[...e.MonitorList],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((r,n)=>r.Priority>n.Priority?r:n)),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length&&e.URLList&&(this.eventsSdkClass.URLList=e.URLList),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.URLList.length&&!this.eventsSdkClass.servers.length)throw new Error("Socket servers not defined");if(this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length)throw new Error("Socket servers not defined");this.eventsSdkClass.server&&this.eventsSdkClass.socketIoClass.getSocketIoFunction(`v=${this.eventsSdkClass.server.Version}`),!this.eventsSdkClass.server&&this.eventsSdkClass.URLList.length&&this.eventsSdkClass.socketIoClass.getSocketIoFunction(`v=${e.Version}`),e.IdentityCode&&(this.token=e.IdentityCode,this.eventsSdkClass.connect(Ct.MAIN)),e.Token&&(this.token=e.Token,this.eventsSdkClass.connect(Ct.MAIN)),e.RefreshToken&&e.IdentityCodeExpiry&&this.eventsSdkClass.options.loginType===st.USER&&(this.refreshToken=e.RefreshToken,this.tokenExpiry=e.IdentityCodeExpiry,this.handleTokenExpiry()),e.RefreshToken&&e.TokenExpiry&&this.normalizeLoginType(this.eventsSdkClass.options.loginType)===st.USER&&(this.refreshToken=e.RefreshToken,this.tokenExpiry=e.TokenExpiry,this.handleTokenExpiry())}handleTokenExpiry(){if(!this.eventsSdkClass.options.refreshTokenUrl)throw new Error("refreshTokenUrl not provided");let e;if(this.tokenExpiry)e=new Date(this.tokenExpiry);else return;const r=e.getTime()-new Date().getTime()-5e3,n=Math.min(r,2147483647);setTimeout(async()=>{if(this.refreshToken){this.eventsSdkClass.socketIoClass.closeAllConnections();let o,i;if(this.eventsSdkClass.options.isNewStack){const u=await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken);o=await this.getSettings(u.Data.AccessToken),i={...u.Data,...o}}else i={...(await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken)).Data.Socket};this.onLoginResponse(i),await Rt.updateSessionStorageKey(this.storageKey,i)}},n)}async externalLogin(e,{password:r,token:n,email:o},i){if(!e)throw new Error("loginUrl not provided");let u;this.eventsSdkClass.options.isNewStack?i===st.TOKEN?u=JSON.stringify({identityType:st.TOKEN,token:n}):u=JSON.stringify({identityType:st.USER,username:o,password:r}):this.eventsSdkClass.options.loginType===st.TOKEN?(u=JSON.stringify({token:n}),e=`${e}/${st.TOKEN}`):(u=JSON.stringify({email:o,pin:r}),e=`${e}/${st.USER}`);try{const h=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:u});if(!h.ok&&h.status===400)throw new Error("Bad body request. Login type or isNewStack values not correct or not provided");if(!h.ok&&h.status===401)throw new Error("Unauthorized. Invalid token provided");if(!h.ok&&h.status===403)throw new Error("Forbidden. Identity token not provided or not valid");const f=await h.json();if(f.error)throw new Error(f.error);return f}catch(h){throw this.eventsSdkClass.loggerClass.log({Message:`External login request error with the login type ${st} ${i===st.TOKEN?{token:n}:{email:o,pin:r}}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"External login error",StatusCode:400,Level:et.ERROR,LogType:pt.ERROR}),h}}async getSettings(e){try{if(!this.eventsSdkClass.options.getSettingsUrl)throw new Error("getSettingsUrl not provided");const r=await fetch(this.eventsSdkClass.options.getSettingsUrl,{headers:{Authorization:`Bearer ${e}`}});if(!r.ok&&r.status===401)throw new Error("Unauthorized. Access token not provided or not valid");return r.json()}catch(r){throw this.eventsSdkClass.loggerClass.log({Message:`Get settings error with token ${e}, error: ${r}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:et.ERROR,LogType:pt.ERROR}),r}}async externalRefreshToken(e,r){try{return(await fetch(e,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`}})).json()}catch(n){throw this.eventsSdkClass.loggerClass.log({Message:`Refresh token error with old refresh token ${r}, url: ${e}, error: ${n}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:et.ERROR,LogType:pt.ERROR}),n}}normalizeLoginType(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}}const jo={isNewStack:!1,loginUrl:"https://loginapi.voicenter.co.il/monitorAPI/Login",refreshTokenUrl:"https://loginapi.voicenter.co.il/monitorAPI/RefreshIdentityToken",forceNew:!0,reconnectionDelay:1e4,timeout:1e4,keepAliveTimeout:6e4,protocol:"https",useLogger:!0,loggerServer:"https://socketlog.voicenter.co",loggerConfig:{logToConsole:!0,overloadGlobalConsole:!1,system:"events-sdk",socketEmitInterval:1e4},loggerConnectOptions:{reconnection:!0,reconnectionDelay:5e3,reconnectionAttempts:10,perMessageDeflate:void 0,upgrade:!1,transports:["websocket"],debug:!1}};function Mo(){return typeof window<"u"&&(typeof window.navigator>"u"||typeof window.navigator.userAgent>"u")&&(window.navigator.userAgent="react-native"),typeof self>"u"&&typeof global=="object"&&(global.self=global,global.WebSocket=lt,typeof self.navigator>"u"&&(self.navigator={userAgent:"node"})),function t(e,r,n){function o(h,f){if(!r[h]){if(!e[h]){var c=typeof require=="function"&&require;if(!f&&c)return c(h,!0);if(i)return i(h,!0);throw new Error("Cannot find module '"+h+"'")}var l=r[h]={exports:{}};e[h][0].call(l.exports,function(p){var a=e[h][1][p];return o(a||p)},l,l.exports,t,e,r,n)}return r[h].exports}for(var i=typeof require=="function"&&require,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(t,e){e.exports=t("./lib/")},{"./lib/":2}],2:[function(t,e,r){function n(c,l){typeof c=="object"&&(l=c,c=void 0),l=l||{};var p,a=o(c),s=a.source,d=a.id;return l.forceNew||l["force new connection"]||l.multiplex===!1?(h("ignoring socket cache for %s",s),p=u(s,l)):(f[d]||(h("new io instance for %s",s),f[d]=u(s,l)),p=f[d]),p.socket(a.path)}var o=t("./url"),i=t("socket.io-parser"),u=t("./manager"),h=t("debug")("socket.io-client");e.exports=r=n;var f=r.managers={};r.protocol=i.protocol,r.connect=n,r.Manager=t("./manager"),r.Socket=t("./socket")},{"./manager":3,"./socket":5,"./url":6,debug:10,"socket.io-parser":44}],3:[function(t,e){function r(a,s){return this instanceof r?(a&&typeof a=="object"&&(s=a,a=void 0),s=s||{},s.path=s.path||"/socket.io",this.nsps={},this.subs=[],this.opts=s,this.reconnection(s.reconnection!==!1),this.reconnectionAttempts(s.reconnectionAttempts||1/0),this.reconnectionDelay(s.reconnectionDelay||1e3),this.reconnectionDelayMax(s.reconnectionDelayMax||5e3),this.randomizationFactor(s.randomizationFactor||.5),this.backoff=new p({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(s.timeout==null?2e4:s.timeout),this.readyState="closed",this.uri=a,this.connected=[],this.encoding=!1,this.packetBuffer=[],this.encoder=new u.Encoder,this.decoder=new u.Decoder,this.autoConnect=s.autoConnect!==!1,void(this.autoConnect&&this.open())):new r(a,s)}var n=(t("./url"),t("engine.io-client")),o=t("./socket"),i=t("component-emitter"),u=t("socket.io-parser"),h=t("./on"),f=t("component-bind"),c=(t("object-component"),t("debug")("socket.io-client:manager")),l=t("indexof"),p=t("backo2");e.exports=r,r.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var a in this.nsps)this.nsps[a].emit.apply(this.nsps[a],arguments)},r.prototype.updateSocketIds=function(){for(var a in this.nsps)this.nsps[a].id=this.engine.id},i(r.prototype),r.prototype.reconnection=function(a){return arguments.length?(this._reconnection=!!a,this):this._reconnection},r.prototype.reconnectionAttempts=function(a){return arguments.length?(this._reconnectionAttempts=a,this):this._reconnectionAttempts},r.prototype.reconnectionDelay=function(a){return arguments.length?(this._reconnectionDelay=a,this.backoff&&this.backoff.setMin(a),this):this._reconnectionDelay},r.prototype.randomizationFactor=function(a){return arguments.length?(this._randomizationFactor=a,this.backoff&&this.backoff.setJitter(a),this):this._randomizationFactor},r.prototype.reconnectionDelayMax=function(a){return arguments.length?(this._reconnectionDelayMax=a,this.backoff&&this.backoff.setMax(a),this):this._reconnectionDelayMax},r.prototype.timeout=function(a){return arguments.length?(this._timeout=a,this):this._timeout},r.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()},r.prototype.open=r.prototype.connect=function(a){if(c("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;c("opening %s",this.uri),this.engine=n(this.uri,this.opts);var s=this.engine,d=this;this.readyState="opening",this.skipReconnect=!1;var y=h(s,"open",function(){d.onopen(),a&&a()}),g=h(s,"error",function(B){if(c("connect_error"),d.cleanup(),d.readyState="closed",d.emitAll("connect_error",B),a){var b=new Error("Connection error");b.data=B,a(b)}else d.maybeReconnectOnOpen()});if(this._timeout!==!1){var w=this._timeout;c("connect attempt will timeout after %d",w);var _=setTimeout(function(){c("connect attempt timed out after %d",w),y.destroy(),s.close(),s.emit("error","timeout"),d.emitAll("connect_timeout",w)},w);this.subs.push({destroy:function(){clearTimeout(_)}})}return this.subs.push(y),this.subs.push(g),this},r.prototype.onopen=function(){c("open"),this.cleanup(),this.readyState="open",this.emit("open");var a=this.engine;this.subs.push(h(a,"data",f(this,"ondata"))),this.subs.push(h(this.decoder,"decoded",f(this,"ondecoded"))),this.subs.push(h(a,"error",f(this,"onerror"))),this.subs.push(h(a,"close",f(this,"onclose")))},r.prototype.ondata=function(a){this.decoder.add(a)},r.prototype.ondecoded=function(a){this.emit("packet",a)},r.prototype.onerror=function(a){c("error",a),this.emitAll("error",a)},r.prototype.socket=function(a){var s=this.nsps[a];if(!s){s=new o(this,a),this.nsps[a]=s;var d=this;s.on("connect",function(){s.id=d.engine.id,~l(d.connected,s)||d.connected.push(s)})}return s},r.prototype.destroy=function(a){var s=l(this.connected,a);~s&&this.connected.splice(s,1),this.connected.length||this.close()},r.prototype.packet=function(a){c("writing packet %j",a);var s=this;s.encoding?s.packetBuffer.push(a):(s.encoding=!0,this.encoder.encode(a,function(d){for(var y=0;y<d.length;y++)s.engine.write(d[y]);s.encoding=!1,s.processPacketQueue()}))},r.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var a=this.packetBuffer.shift();this.packet(a)}},r.prototype.cleanup=function(){for(var a;a=this.subs.shift();)a.destroy();this.packetBuffer=[],this.encoding=!1,this.decoder.destroy()},r.prototype.close=r.prototype.disconnect=function(){this.skipReconnect=!0,this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},r.prototype.onclose=function(a){c("close"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",a),this._reconnection&&!this.skipReconnect&&this.reconnect()},r.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var a=this;if(this.backoff.attempts>=this._reconnectionAttempts)c("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var s=this.backoff.duration();c("will wait %dms before reconnect attempt",s),this.reconnecting=!0;var d=setTimeout(function(){a.skipReconnect||(c("attempting reconnect"),a.emitAll("reconnect_attempt",a.backoff.attempts),a.emitAll("reconnecting",a.backoff.attempts),a.skipReconnect||a.open(function(y){y?(c("reconnect attempt error"),a.reconnecting=!1,a.reconnect(),a.emitAll("reconnect_error",y.data)):(c("reconnect success"),a.onreconnect())}))},s);this.subs.push({destroy:function(){clearTimeout(d)}})}},r.prototype.onreconnect=function(){var a=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",a)}},{"./on":4,"./socket":5,"./url":6,backo2:7,"component-bind":8,"component-emitter":9,debug:10,"engine.io-client":11,indexof:40,"object-component":41,"socket.io-parser":44}],4:[function(t,e){function r(n,o,i){return n.on(o,i),{destroy:function(){n.removeListener(o,i)}}}e.exports=r},{}],5:[function(t,e,r){function n(s,d){this.io=s,this.nsp=d,this.json=this,this.ids=0,this.acks={},this.io.autoConnect&&this.open(),this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0}var o=t("socket.io-parser"),i=t("component-emitter"),u=t("to-array"),h=t("./on"),f=t("component-bind"),c=t("debug")("socket.io-client:socket"),l=t("has-binary");e.exports=n;var p={connect:1,connect_error:1,connect_timeout:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1},a=i.prototype.emit;i(n.prototype),n.prototype.subEvents=function(){if(!this.subs){var s=this.io;this.subs=[h(s,"open",f(this,"onopen")),h(s,"packet",f(this,"onpacket")),h(s,"close",f(this,"onclose"))]}},n.prototype.open=n.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),this.io.readyState=="open"&&this.onopen(),this)},n.prototype.send=function(){var s=u(arguments);return s.unshift("message"),this.emit.apply(this,s),this},n.prototype.emit=function(s){if(p.hasOwnProperty(s))return a.apply(this,arguments),this;var d=u(arguments),y=o.EVENT;l(d)&&(y=o.BINARY_EVENT);var g={type:y,data:d};return typeof d[d.length-1]=="function"&&(c("emitting packet with ack id %d",this.ids),this.acks[this.ids]=d.pop(),g.id=this.ids++),this.connected?this.packet(g):this.sendBuffer.push(g),this},n.prototype.packet=function(s){s.nsp=this.nsp,this.io.packet(s)},n.prototype.onopen=function(){c("transport is open - connecting"),this.nsp!="/"&&this.packet({type:o.CONNECT})},n.prototype.onclose=function(s){c("close (%s)",s),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",s)},n.prototype.onpacket=function(s){if(s.nsp==this.nsp)switch(s.type){case o.CONNECT:this.onconnect();break;case o.EVENT:this.onevent(s);break;case o.BINARY_EVENT:this.onevent(s);break;case o.ACK:this.onack(s);break;case o.BINARY_ACK:this.onack(s);break;case o.DISCONNECT:this.ondisconnect();break;case o.ERROR:this.emit("error",s.data)}},n.prototype.onevent=function(s){var d=s.data||[];c("emitting event %j",d),s.id!=null&&(c("attaching ack callback to event"),d.push(this.ack(s.id))),this.connected?a.apply(this,d):this.receiveBuffer.push(d)},n.prototype.ack=function(s){var d=this,y=!1;return function(){if(!y){y=!0;var g=u(arguments);c("sending ack %j",g);var w=l(g)?o.BINARY_ACK:o.ACK;d.packet({type:w,id:s,data:g})}}},n.prototype.onack=function(s){c("calling ack %s with %j",s.id,s.data);var d=this.acks[s.id];d.apply(this,s.data),delete this.acks[s.id]},n.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},n.prototype.emitBuffered=function(){var s;for(s=0;s<this.receiveBuffer.length;s++)a.apply(this,this.receiveBuffer[s]);for(this.receiveBuffer=[],s=0;s<this.sendBuffer.length;s++)this.packet(this.sendBuffer[s]);this.sendBuffer=[]},n.prototype.ondisconnect=function(){c("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},n.prototype.destroy=function(){if(this.subs){for(var s=0;s<this.subs.length;s++)this.subs[s].destroy();this.subs=null}this.io.destroy(this)},n.prototype.close=n.prototype.disconnect=function(){return this.connected&&(c("performing disconnect (%s)",this.nsp),this.packet({type:o.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}},{"./on":4,"component-bind":8,"component-emitter":9,debug:10,"has-binary":36,"socket.io-parser":44,"to-array":48}],6:[function(t,e){(function(r){function n(u,c){var f=u,c=c||r.location;return u==null&&(u=c.protocol+"//"+c.host),typeof u=="string"&&(u.charAt(0)=="/"&&(u=u.charAt(1)=="/"?c.protocol+u:c.hostname+u),/^(https?|wss?):\/\//.test(u)||(i("protocol-less url %s",u),u=typeof c<"u"?c.protocol+"//"+u:"https://"+u),i("parse %s",u),f=o(u)),f.port||(/^(http|ws)$/.test(f.protocol)?f.port="80":/^(http|ws)s$/.test(f.protocol)&&(f.port="443")),f.path=f.path||"/",f.id=f.protocol+"://"+f.host+":"+f.port,f.href=f.protocol+"://"+f.host+(c&&c.port==f.port?"":":"+f.port),f}var o=t("parseuri"),i=t("debug")("socket.io-client:url");e.exports=n}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{debug:10,parseuri:42}],7:[function(t,e){function r(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}e.exports=r,r.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var o=Math.random(),i=Math.floor(o*this.jitter*n);n=1&Math.floor(10*o)?n+i:n-i}return 0|Math.min(n,this.max)},r.prototype.reset=function(){this.attempts=0},r.prototype.setMin=function(n){this.ms=n},r.prototype.setMax=function(n){this.max=n},r.prototype.setJitter=function(n){this.jitter=n}},{}],8:[function(t,e){var r=[].slice;e.exports=function(n,o){if(typeof o=="string"&&(o=n[o]),typeof o!="function")throw new Error("bind() requires a function");var i=r.call(arguments,2);return function(){return o.apply(n,i.concat(r.call(arguments)))}}},{}],9:[function(t,e){function r(o){return o?n(o):void 0}function n(o){for(var i in r.prototype)o[i]=r.prototype[i];return o}e.exports=r,r.prototype.on=r.prototype.addEventListener=function(o,i){return this._callbacks=this._callbacks||{},(this._callbacks[o]=this._callbacks[o]||[]).push(i),this},r.prototype.once=function(o,i){function u(){h.off(o,u),i.apply(this,arguments)}var h=this;return this._callbacks=this._callbacks||{},u.fn=i,this.on(o,u),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(o,i){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var u=this._callbacks[o];if(!u)return this;if(arguments.length==1)return delete this._callbacks[o],this;for(var h,f=0;f<u.length;f++)if(h=u[f],h===i||h.fn===i){u.splice(f,1);break}return this},r.prototype.emit=function(o){this._callbacks=this._callbacks||{};var i=[].slice.call(arguments,1),u=this._callbacks[o];if(u){u=u.slice(0);for(var h=0,f=u.length;f>h;++h)u[h].apply(this,i)}return this},r.prototype.listeners=function(o){return this._callbacks=this._callbacks||{},this._callbacks[o]||[]},r.prototype.hasListeners=function(o){return!!this.listeners(o).length}},{}],10:[function(t,e){function r(o){return r.enabled(o)?function(i){i=n(i);var u=new Date,h=u-(r[o]||u);r[o]=u,i=o+" "+i+" +"+r.humanize(h),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}function n(o){return o instanceof Error?o.stack||o.message:o}e.exports=r,r.names=[],r.skips=[],r.enable=function(o){try{localStorage.debug=o}catch{}for(var i=(o||"").split(/[\s,]+/),u=i.length,h=0;u>h;h++)o=i[h].replace("*",".*?"),o[0]==="-"?r.skips.push(new RegExp("^"+o.substr(1)+"$")):r.names.push(new RegExp("^"+o+"$"))},r.disable=function(){r.enable("")},r.humanize=function(o){var i=1e3,u=6e4,h=60*u;return o>=h?(o/h).toFixed(1)+"h":o>=u?(o/u).toFixed(1)+"m":o>=i?(o/i|0)+"s":o+"ms"},r.enabled=function(o){for(var i=0,u=r.skips.length;u>i;i++)if(r.skips[i].test(o))return!1;for(var i=0,u=r.names.length;u>i;i++)if(r.names[i].test(o))return!0;return!1};try{window.localStorage&&r.enable(localStorage.debug)}catch{}},{}],11:[function(t,e){e.exports=t("./lib/")},{"./lib/":12}],12:[function(t,e){e.exports=t("./socket"),e.exports.parser=t("engine.io-parser")},{"./socket":13,"engine.io-parser":25}],13:[function(t,e){(function(r){function n(s,d){if(!(this instanceof n))return new n(s,d);if(d=d||{},s&&typeof s=="object"&&(d=s,s=null),s&&(s=l(s),d.host=s.host,d.secure=s.protocol=="https"||s.protocol=="wss",d.port=s.port,s.query&&(d.query=s.query)),this.secure=d.secure!=null?d.secure:r.location&&location.protocol=="https:",d.host){var y=d.host.split(":");d.hostname=y.shift(),y.length?d.port=y.pop():d.port||(d.port=this.secure?"443":"80")}this.agent=d.agent||!1,this.hostname=d.hostname||(r.location?location.hostname:"localhost"),this.port=d.port||(r.location&&location.port?location.port:this.secure?443:80),this.query=d.query||{},typeof this.query=="string"&&(this.query=a.decode(this.query)),this.upgrade=d.upgrade!==!1,this.path=(d.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!d.forceJSONP,this.jsonp=d.jsonp!==!1,this.forceBase64=!!d.forceBase64,this.enablesXDR=!!d.enablesXDR,this.timestampParam=d.timestampParam||"t",this.timestampRequests=d.timestampRequests,this.transports=d.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.callbackBuffer=[],this.policyPort=d.policyPort||843,this.rememberUpgrade=d.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=d.onlyBinaryUpgrades,this.pfx=d.pfx||null,this.key=d.key||null,this.passphrase=d.passphrase||null,this.cert=d.cert||null,this.ca=d.ca||null,this.ciphers=d.ciphers||null,this.rejectUnauthorized=d.rejectUnauthorized||null,this.open()}function o(s){var d={};for(var y in s)s.hasOwnProperty(y)&&(d[y]=s[y]);return d}var i=t("./transports"),u=t("component-emitter"),h=t("debug")("engine.io-client:socket"),f=t("indexof"),c=t("engine.io-parser"),l=t("parseuri"),p=t("parsejson"),a=t("parseqs");e.exports=n,n.priorWebsocketSuccess=!1,u(n.prototype),n.protocol=c.protocol,n.Socket=n,n.Transport=t("./transport"),n.transports=t("./transports"),n.parser=t("engine.io-parser"),n.prototype.createTransport=function(s){h('creating transport "%s"',s);var d=o(this.query);d.EIO=c.protocol,d.transport=s,this.id&&(d.sid=this.id);var y=new i[s]({agent:this.agent,hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:d,forceJSONP:this.forceJSONP,jsonp:this.jsonp,forceBase64:this.forceBase64,enablesXDR:this.enablesXDR,timestampRequests:this.timestampRequests,timestampParam:this.timestampParam,policyPort:this.policyPort,socket:this,pfx:this.pfx,key:this.key,passphrase:this.passphrase,cert:this.cert,ca:this.ca,ciphers:this.ciphers,rejectUnauthorized:this.rejectUnauthorized});return y},n.prototype.open=function(){var d;if(this.rememberUpgrade&&n.priorWebsocketSuccess&&this.transports.indexOf("websocket")!=-1)d="websocket";else{if(this.transports.length==0){var s=this;return void setTimeout(function(){s.emit("error","No transports available")},0)}d=this.transports[0]}this.readyState="opening";var d;try{d=this.createTransport(d)}catch{return this.transports.shift(),void this.open()}d.open(),this.setTransport(d)},n.prototype.setTransport=function(s){h("setting transport %s",s.name);var d=this;this.transport&&(h("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=s,s.on("drain",function(){d.onDrain()}).on("packet",function(y){d.onPacket(y)}).on("error",function(y){d.onError(y)}).on("close",function(){d.onClose("transport close")})},n.prototype.probe=function(s){function d(){if(C.onlyBinaryUpgrades){var E=!this.supportsBinary&&C.transport.supportsBinary;m=m||E}m||(h('probe transport "%s" opened',s),S.send([{type:"ping",data:"probe"}]),S.once("packet",function(v){if(!m)if(v.type=="pong"&&v.data=="probe"){if(h('probe transport "%s" pong',s),C.upgrading=!0,C.emit("upgrading",S),!S)return;n.priorWebsocketSuccess=S.name=="websocket",h('pausing current transport "%s"',C.transport.name),C.transport.pause(function(){m||C.readyState!="closed"&&(h("changing transport and sending upgrade packet"),b(),C.setTransport(S),S.send([{type:"upgrade"}]),C.emit("upgrade",S),S=null,C.upgrading=!1,C.flush())})}else{h('probe transport "%s" failed',s);var k=new Error("probe error");k.transport=S.name,C.emit("upgradeError",k)}}))}function y(){m||(m=!0,b(),S.close(),S=null)}function g(E){var v=new Error("probe error: "+E);v.transport=S.name,y(),h('probe transport "%s" failed because of error: %s',s,E),C.emit("upgradeError",v)}function w(){g("transport closed")}function _(){g("socket closed")}function B(E){S&&E.name!=S.name&&(h('"%s" works - aborting "%s"',E.name,S.name),y())}function b(){S.removeListener("open",d),S.removeListener("error",g),S.removeListener("close",w),C.removeListener("close",_),C.removeListener("upgrading",B)}h('probing transport "%s"',s);var S=this.createTransport(s,{probe:1}),m=!1,C=this;n.priorWebsocketSuccess=!1,S.once("open",d),S.once("error",g),S.once("close",w),this.once("close",_),this.once("upgrading",B),S.open()},n.prototype.onOpen=function(){if(h("socket open"),this.readyState="open",n.priorWebsocketSuccess=this.transport.name=="websocket",this.emit("open"),this.flush(),this.readyState=="open"&&this.upgrade&&this.transport.pause){h("starting upgrade probes");for(var s=0,d=this.upgrades.length;d>s;s++)this.probe(this.upgrades[s])}},n.prototype.onPacket=function(s){if(this.readyState=="opening"||this.readyState=="open")switch(h('socket receive: type "%s", data "%s"',s.type,s.data),this.emit("packet",s),this.emit("heartbeat"),s.type){case"open":this.onHandshake(p(s.data));break;case"pong":this.setPing();break;case"error":var d=new Error("server error");d.code=s.data,this.emit("error",d);break;case"message":this.emit("data",s.data),this.emit("message",s.data)}else h('packet received with socket readyState "%s"',this.readyState)},n.prototype.onHandshake=function(s){this.emit("handshake",s),this.id=s.sid,this.transport.query.sid=s.sid,this.upgrades=this.filterUpgrades(s.upgrades),this.pingInterval=s.pingInterval,this.pingTimeout=s.pingTimeout,this.onOpen(),this.readyState!="closed"&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},n.prototype.onHeartbeat=function(s){clearTimeout(this.pingTimeoutTimer);var d=this;d.pingTimeoutTimer=setTimeout(function(){d.readyState!="closed"&&d.onClose("ping timeout")},s||d.pingInterval+d.pingTimeout)},n.prototype.setPing=function(){var s=this;clearTimeout(s.pingIntervalTimer),s.pingIntervalTimer=setTimeout(function(){h("writing ping packet - expecting pong within %sms",s.pingTimeout),s.ping(),s.onHeartbeat(s.pingTimeout)},s.pingInterval)},n.prototype.ping=function(){this.sendPacket("ping")},n.prototype.onDrain=function(){for(var s=0;s<this.prevBufferLen;s++)this.callbackBuffer[s]&&this.callbackBuffer[s]();this.writeBuffer.splice(0,this.prevBufferLen),this.callbackBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length==0?this.emit("drain"):this.flush()},n.prototype.flush=function(){this.readyState!="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(h("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},n.prototype.write=n.prototype.send=function(s,d){return this.sendPacket("message",s,d),this},n.prototype.sendPacket=function(s,d,y){if(this.readyState!="closing"&&this.readyState!="closed"){var g={type:s,data:d};this.emit("packetCreate",g),this.writeBuffer.push(g),this.callbackBuffer.push(y),this.flush()}},n.prototype.close=function(){function s(){g.onClose("forced close"),h("socket closing - telling transport to close"),g.transport.close()}function d(){g.removeListener("upgrade",d),g.removeListener("upgradeError",d),s()}function y(){g.once("upgrade",d),g.once("upgradeError",d)}if(this.readyState=="opening"||this.readyState=="open"){this.readyState="closing";var g=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?y():s()}):this.upgrading?y():s()}return this},n.prototype.onError=function(s){h("socket error %j",s),n.priorWebsocketSuccess=!1,this.emit("error",s),this.onClose("transport error",s)},n.prototype.onClose=function(s,d){if(this.readyState=="opening"||this.readyState=="open"||this.readyState=="closing"){h('socket close with reason: "%s"',s);var y=this;clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),setTimeout(function(){y.writeBuffer=[],y.callbackBuffer=[],y.prevBufferLen=0},0),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",s,d)}},n.prototype.filterUpgrades=function(s){for(var d=[],y=0,g=s.length;g>y;y++)~f(this.transports,s[y])&&d.push(s[y]);return d}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./transport":14,"./transports":15,"component-emitter":9,debug:22,"engine.io-parser":25,indexof:40,parsejson:32,parseqs:33,parseuri:34}],14:[function(t,e){function r(i){this.path=i.path,this.hostname=i.hostname,this.port=i.port,this.secure=i.secure,this.query=i.query,this.timestampParam=i.timestampParam,this.timestampRequests=i.timestampRequests,this.readyState="",this.agent=i.agent||!1,this.socket=i.socket,this.enablesXDR=i.enablesXDR,this.pfx=i.pfx,this.key=i.key,this.passphrase=i.passphrase,this.cert=i.cert,this.ca=i.ca,this.ciphers=i.ciphers,this.rejectUnauthorized=i.rejectUnauthorized}var n=t("engine.io-parser"),o=t("component-emitter");e.exports=r,o(r.prototype),r.timestamps=0,r.prototype.onError=function(i,u){var h=new Error(i);return h.type="TransportError",h.description=u,this.emit("error",h),this},r.prototype.open=function(){return(this.readyState=="closed"||this.readyState=="")&&(this.readyState="opening",this.doOpen()),this},r.prototype.close=function(){return(this.readyState=="opening"||this.readyState=="open")&&(this.doClose(),this.onClose()),this},r.prototype.send=function(i){if(this.readyState!="open")throw new Error("Transport not open");this.write(i)},r.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},r.prototype.onData=function(i){var u=n.decodePacket(i,this.socket.binaryType);this.onPacket(u)},r.prototype.onPacket=function(i){this.emit("packet",i)},r.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},{"component-emitter":9,"engine.io-parser":25}],15:[function(t,e,r){(function(n){function o(c){var l,p=!1,a=!1,s=c.jsonp!==!1;if(n.location){var d=location.protocol=="https:",y=location.port;y||(y=d?443:80),p=c.hostname!=location.hostname||y!=c.port,a=c.secure!=d}if(c.xdomain=p,c.xscheme=a,l=new i(c),"open"in l&&!c.forceJSONP)return new u(c);if(!s)throw new Error("JSONP disabled");return new h(c)}var i=t("xmlhttprequest"),u=t("./polling-xhr"),h=t("./polling-jsonp"),f=t("./websocket");r.polling=o,r.websocket=f}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling-jsonp":16,"./polling-xhr":17,"./websocket":19,xmlhttprequest:20}],16:[function(t,e){(function(r){function n(){}function o(l){i.call(this,l),this.query=this.query||{},h||(r.___eio||(r.___eio=[]),h=r.___eio),this.index=h.length;var p=this;h.push(function(a){p.onData(a)}),this.query.j=this.index,r.document&&r.addEventListener&&r.addEventListener("beforeunload",function(){p.script&&(p.script.onerror=n)},!1)}var i=t("./polling"),u=t("component-inherit");e.exports=o;var h,f=/\n/g,c=/\\n/g;u(o,i),o.prototype.supportsBinary=!1,o.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),i.prototype.doClose.call(this)},o.prototype.doPoll=function(){var l=this,p=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),p.async=!0,p.src=this.uri(),p.onerror=function(d){l.onError("jsonp poll error",d)};var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(p,a),this.script=p;var s=typeof navigator<"u"&&/gecko/i.test(navigator.userAgent);s&&setTimeout(function(){var d=document.createElement("iframe");document.body.appendChild(d),document.body.removeChild(d)},100)},o.prototype.doWrite=function(l,p){function a(){s(),p()}function s(){if(d.iframe)try{d.form.removeChild(d.iframe)}catch(b){d.onError("jsonp polling iframe removal error",b)}try{var B='<iframe src="javascript:0" name="'+d.iframeId+'">';y=document.createElement(B)}catch{y=document.createElement("iframe"),y.name=d.iframeId,y.src="javascript:0"}y.id=d.iframeId,d.form.appendChild(y),d.iframe=y}var d=this;if(!this.form){var y,g=document.createElement("form"),w=document.createElement("textarea"),_=this.iframeId="eio_iframe_"+this.index;g.className="socketio",g.style.position="absolute",g.style.top="-1000px",g.style.left="-1000px",g.target=_,g.method="POST",g.setAttribute("accept-charset","utf-8"),w.name="d",g.appendChild(w),document.body.appendChild(g),this.form=g,this.area=w}this.form.action=this.uri(),s(),l=l.replace(c,`\\
8
+ `),this.area.value=l.replace(f,"\\n");try{this.form.submit()}catch{}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){d.iframe.readyState=="complete"&&a()}:this.iframe.onload=a}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-inherit":21}],17:[function(t,e){(function(r){function n(){}function o(a){if(f.call(this,a),r.location){var s=location.protocol=="https:",d=location.port;d||(d=s?443:80),this.xd=a.hostname!=r.location.hostname||d!=a.port,this.xs=a.secure!=s}}function i(a){this.method=a.method||"GET",this.uri=a.uri,this.xd=!!a.xd,this.xs=!!a.xs,this.async=a.async!==!1,this.data=a.data!=null?a.data:null,this.agent=a.agent,this.isBinary=a.isBinary,this.supportsBinary=a.supportsBinary,this.enablesXDR=a.enablesXDR,this.pfx=a.pfx,this.key=a.key,this.passphrase=a.passphrase,this.cert=a.cert,this.ca=a.ca,this.ciphers=a.ciphers,this.rejectUnauthorized=a.rejectUnauthorized,this.create()}function u(){for(var a in i.requests)i.requests.hasOwnProperty(a)&&i.requests[a].abort()}var h=t("xmlhttprequest"),f=t("./polling"),c=t("component-emitter"),l=t("component-inherit"),p=t("debug")("engine.io-client:polling-xhr");e.exports=o,e.exports.Request=i,l(o,f),o.prototype.supportsBinary=!0,o.prototype.request=function(a){return a=a||{},a.uri=this.uri(),a.xd=this.xd,a.xs=this.xs,a.agent=this.agent||!1,a.supportsBinary=this.supportsBinary,a.enablesXDR=this.enablesXDR,a.pfx=this.pfx,a.key=this.key,a.passphrase=this.passphrase,a.cert=this.cert,a.ca=this.ca,a.ciphers=this.ciphers,a.rejectUnauthorized=this.rejectUnauthorized,new i(a)},o.prototype.doWrite=function(a,s){var d=typeof a!="string"&&a!==void 0,y=this.request({method:"POST",data:a,isBinary:d}),g=this;y.on("success",s),y.on("error",function(w){g.onError("xhr post error",w)}),this.sendXhr=y},o.prototype.doPoll=function(){p("xhr poll");var a=this.request(),s=this;a.on("data",function(d){s.onData(d)}),a.on("error",function(d){s.onError("xhr poll error",d)}),this.pollXhr=a},c(i.prototype),i.prototype.create=function(){var a={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};a.pfx=this.pfx,a.key=this.key,a.passphrase=this.passphrase,a.cert=this.cert,a.ca=this.ca,a.ciphers=this.ciphers,a.rejectUnauthorized=this.rejectUnauthorized;var s=this.xhr=new h(a),d=this;try{if(p("xhr open %s: %s",this.method,this.uri),s.open(this.method,this.uri,this.async),this.supportsBinary&&(s.responseType="arraybuffer"),this.method=="POST")try{this.isBinary?s.setRequestHeader("Content-type","application/octet-stream"):s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}"withCredentials"in s&&(s.withCredentials=!0),this.hasXDR()?(s.onload=function(){d.onLoad()},s.onerror=function(){d.onError(s.responseText)}):s.onreadystatechange=function(){s.readyState==4&&(s.status==200||s.status==1223?d.onLoad():setTimeout(function(){d.onError(s.status)},0))},p("xhr data %s",this.data),s.send(this.data)}catch(y){return void setTimeout(function(){d.onError(y)},0)}r.document&&(this.index=i.requestsCount++,i.requests[this.index]=this)},i.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},i.prototype.onData=function(a){this.emit("data",a),this.onSuccess()},i.prototype.onError=function(a){this.emit("error",a),this.cleanup(!0)},i.prototype.cleanup=function(a){if(typeof this.xhr<"u"&&this.xhr!==null){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=n:this.xhr.onreadystatechange=n,a)try{this.xhr.abort()}catch{}r.document&&delete i.requests[this.index],this.xhr=null}},i.prototype.onLoad=function(){var a;try{var s;try{s=this.xhr.getResponseHeader("Content-Type").split(";")[0]}catch{}a=s==="application/octet-stream"?this.xhr.response:this.supportsBinary?"ok":this.xhr.responseText}catch(d){this.onError(d)}a!=null&&this.onData(a)},i.prototype.hasXDR=function(){return typeof r.XDomainRequest<"u"&&!this.xs&&this.enablesXDR},i.prototype.abort=function(){this.cleanup()},r.document&&(i.requestsCount=0,i.requests={},r.attachEvent?r.attachEvent("onunload",u):r.addEventListener&&r.addEventListener("beforeunload",u,!1))}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-emitter":9,"component-inherit":21,debug:22,xmlhttprequest:20}],18:[function(t,e){function r(c){var l=c&&c.forceBase64;(!f||l)&&(this.supportsBinary=!1),n.call(this,c)}var n=t("../transport"),o=t("parseqs"),i=t("engine.io-parser"),u=t("component-inherit"),h=t("debug")("engine.io-client:polling");e.exports=r;var f=function(){var c=t("xmlhttprequest"),l=new c({xdomain:!1});return l.responseType!=null}();u(r,n),r.prototype.name="polling",r.prototype.doOpen=function(){this.poll()},r.prototype.pause=function(c){function l(){h("paused"),p.readyState="paused",c()}var p=this;if(this.readyState="pausing",this.polling||!this.writable){var a=0;this.polling&&(h("we are currently polling - waiting to pause"),a++,this.once("pollComplete",function(){h("pre-pause polling complete"),--a||l()})),this.writable||(h("we are currently writing - waiting to pause"),a++,this.once("drain",function(){h("pre-pause writing complete"),--a||l()}))}else l()},r.prototype.poll=function(){h("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},r.prototype.onData=function(c){var l=this;h("polling got data %s",c);var p=function(a){return l.readyState=="opening"&&l.onOpen(),a.type=="close"?(l.onClose(),!1):void l.onPacket(a)};i.decodePayload(c,this.socket.binaryType,p),this.readyState!="closed"&&(this.polling=!1,this.emit("pollComplete"),this.readyState=="open"?this.poll():h('ignoring poll - transport state "%s"',this.readyState))},r.prototype.doClose=function(){function c(){h("writing close packet"),l.write([{type:"close"}])}var l=this;this.readyState=="open"?(h("transport open - closing"),c()):(h("transport not open - deferring close"),this.once("open",c))},r.prototype.write=function(c){var p=this;this.writable=!1;var l=function(){p.writable=!0,p.emit("drain")},p=this;i.encodePayload(c,this.supportsBinary,function(a){p.doWrite(a,l)})},r.prototype.uri=function(){var c=this.query||{},l=this.secure?"https":"http",p="";return this.timestampRequests!==!1&&(c[this.timestampParam]=+new Date+"-"+n.timestamps++),this.supportsBinary||c.sid||(c.b64=1),c=o.encode(c),this.port&&(l=="https"&&this.port!=443||l=="http"&&this.port!=80)&&(p=":"+this.port),c.length&&(c="?"+c),l+"://"+this.hostname+p+this.path+c}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,xmlhttprequest:20}],19:[function(t,e){function r(c){var l=c&&c.forceBase64;l&&(this.supportsBinary=!1),n.call(this,c)}var n=t("../transport"),o=t("engine.io-parser"),i=t("parseqs"),u=t("component-inherit"),h=t("debug")("engine.io-client:websocket"),f=t("ws");e.exports=r,u(r,n),r.prototype.name="websocket",r.prototype.supportsBinary=!0,r.prototype.doOpen=function(){if(this.check()){var c=this.uri(),l=void 0,p={agent:this.agent};p.pfx=this.pfx,p.key=this.key,p.passphrase=this.passphrase,p.cert=this.cert,p.ca=this.ca,p.ciphers=this.ciphers,p.rejectUnauthorized=this.rejectUnauthorized,this.ws=new f(c,l,p),this.ws.binaryType===void 0&&(this.supportsBinary=!1),this.ws.binaryType="arraybuffer",this.addEventListeners()}},r.prototype.addEventListeners=function(){var c=this;this.ws.onopen=function(){c.onOpen()},this.ws.onclose=function(){c.onClose()},this.ws.onmessage=function(l){c.onData(l.data)},this.ws.onerror=function(l){c.onError("websocket error",l)}},typeof navigator<"u"&&/iPad|iPhone|iPod/i.test(navigator.userAgent)&&(r.prototype.onData=function(c){var l=this;setTimeout(function(){n.prototype.onData.call(l,c)},0)}),r.prototype.write=function(c){function l(){p.writable=!0,p.emit("drain")}var p=this;this.writable=!1;for(var a=0,s=c.length;s>a;a++)o.encodePacket(c[a],this.supportsBinary,function(d){try{p.ws.send(d)}catch{h("websocket closed before onclose event")}});setTimeout(l,0)},r.prototype.onClose=function(){n.prototype.onClose.call(this)},r.prototype.doClose=function(){typeof this.ws<"u"&&this.ws.close()},r.prototype.uri=function(){var c=this.query||{},l=this.secure?"wss":"ws",p="";return this.port&&(l=="wss"&&this.port!=443||l=="ws"&&this.port!=80)&&(p=":"+this.port),this.timestampRequests&&(c[this.timestampParam]=+new Date),this.supportsBinary||(c.b64=1),c=i.encode(c),c.length&&(c="?"+c),l+"://"+this.hostname+p+this.path+c},r.prototype.check=function(){return!(!f||"__initialize"in f&&this.name===r.prototype.name)}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,ws:35}],20:[function(t,e){var r=t("has-cors");e.exports=function(n){var o=n.xdomain,i=n.xscheme,u=n.enablesXDR;try{if(typeof XMLHttpRequest<"u"&&(!o||r))return new XMLHttpRequest}catch{}try{if(typeof XDomainRequest<"u"&&!i&&u)return new XDomainRequest}catch{}if(!o)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch{}}},{"has-cors":38}],21:[function(t,e){e.exports=function(r,n){var o=function(){};o.prototype=n.prototype,r.prototype=new o,r.prototype.constructor=r}},{}],22:[function(t,e,r){function n(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function o(){var f=arguments,c=this.useColors;if(f[0]=(c?"%c":"")+this.namespace+(c?" %c":" ")+f[0]+(c?"%c ":" ")+"+"+r.humanize(this.diff),!c)return f;var l="color: "+this.color;f=[f[0],l,"color: inherit"].concat(Array.prototype.slice.call(f,1));var p=0,a=0;return f[0].replace(/%[a-z%]/g,function(s){s!=="%%"&&(p++,s==="%c"&&(a=p))}),f.splice(a,0,l),f}function i(){return typeof console=="object"&&typeof console.log=="function"&&Function.prototype.apply.call(console.log,console,arguments)}function u(f){try{f==null?localStorage.removeItem("debug"):localStorage.debug=f}catch{}}function h(){var f;try{f=localStorage.debug}catch{}return f}r=e.exports=t("./debug"),r.log=i,r.formatArgs=o,r.save=u,r.load=h,r.useColors=n,r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(f){return JSON.stringify(f)},r.enable(h())},{"./debug":23}],23:[function(t,e,r){function n(){return r.colors[l++%r.colors.length]}function o(p){function a(){}function s(){var y=s,g=+new Date,w=g-(c||g);y.diff=w,y.prev=c,y.curr=g,c=g,y.useColors==null&&(y.useColors=r.useColors()),y.color==null&&y.useColors&&(y.color=n());var _=Array.prototype.slice.call(arguments);_[0]=r.coerce(_[0]),typeof _[0]!="string"&&(_=["%o"].concat(_));var B=0;_[0]=_[0].replace(/%([a-z%])/g,function(S,m){if(S==="%%")return S;B++;var C=r.formatters[m];if(typeof C=="function"){var E=_[B];S=C.call(y,E),_.splice(B,1),B--}return S}),typeof r.formatArgs=="function"&&(_=r.formatArgs.apply(y,_));var b=s.log||r.log||console.log.bind(console);b.apply(y,_)}a.enabled=!1,s.enabled=!0;var d=r.enabled(p)?s:a;return d.namespace=p,d}function i(p){r.save(p);for(var a=(p||"").split(/[\s,]+/),s=a.length,d=0;s>d;d++)a[d]&&(p=a[d].replace(/\*/g,".*?"),p[0]==="-"?r.skips.push(new RegExp("^"+p.substr(1)+"$")):r.names.push(new RegExp("^"+p+"$")))}function u(){r.enable("")}function h(p){var a,s;for(a=0,s=r.skips.length;s>a;a++)if(r.skips[a].test(p))return!1;for(a=0,s=r.names.length;s>a;a++)if(r.names[a].test(p))return!0;return!1}function f(p){return p instanceof Error?p.stack||p.message:p}r=e.exports=o,r.coerce=f,r.disable=u,r.enable=i,r.enabled=h,r.humanize=t("ms"),r.names=[],r.skips=[],r.formatters={};var c,l=0},{ms:24}],24:[function(t,e){function r(p){var a=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(p);if(a){var s=parseFloat(a[1]),d=(a[2]||"ms").toLowerCase();switch(d){case"years":case"year":case"y":return s*l;case"days":case"day":case"d":return s*c;case"hours":case"hour":case"h":return s*f;case"minutes":case"minute":case"m":return s*h;case"seconds":case"second":case"s":return s*u;case"ms":return s}}}function n(p){return p>=c?Math.round(p/c)+"d":p>=f?Math.round(p/f)+"h":p>=h?Math.round(p/h)+"m":p>=u?Math.round(p/u)+"s":p+"ms"}function o(p){return i(p,c,"day")||i(p,f,"hour")||i(p,h,"minute")||i(p,u,"second")||p+" ms"}function i(p,a,s){return a>p?void 0:1.5*a>p?Math.floor(p/a)+" "+s:Math.ceil(p/a)+" "+s+"s"}var u=1e3,h=60*u,f=60*h,c=24*f,l=365.25*c;e.exports=function(p,a){return a=a||{},typeof p=="string"?r(p):a.long?o(p):n(p)}},{}],25:[function(t,e,r){(function(n){function o(m,C){var E="b"+r.packets[m.type]+m.data.data;return C(E)}function i(m,C,E){if(!C)return r.encodeBase64Packet(m,E);var v=m.data,k=new Uint8Array(v),T=new Uint8Array(1+v.byteLength);T[0]=_[m.type];for(var O=0;O<k.length;O++)T[O+1]=k[O];return E(T.buffer)}function u(m,C,E){if(!C)return r.encodeBase64Packet(m,E);var v=new FileReader;return v.onload=function(){m.data=v.result,r.encodePacket(m,C,!0,E)},v.readAsArrayBuffer(m.data)}function h(m,C,E){if(!C)return r.encodeBase64Packet(m,E);if(w)return u(m,C,E);var v=new Uint8Array(1);v[0]=_[m.type];var k=new S([v.buffer,m.data]);return E(k)}function f(m,C,E){for(var v=new Array(m.length),k=s(m.length,E),T=function(x,A,q){C(A,function(j,G){v[x]=G,q(j,v)})},O=0;O<m.length;O++)T(O,m[O],k)}var c=t("./keys"),l=t("has-binary"),p=t("arraybuffer.slice"),a=t("base64-arraybuffer"),s=t("after"),d=t("utf8"),y=navigator.userAgent.match(/Android/i),g=/PhantomJS/i.test(navigator.userAgent),w=y||g;r.protocol=3;var _=r.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},B=c(_),b={type:"error",data:"parser error"},S=t("blob");r.encodePacket=function(m,C,E,v){typeof C=="function"&&(v=C,C=!1),typeof E=="function"&&(v=E,E=null);var k=m.data===void 0?void 0:m.data.buffer||m.data;if(n.ArrayBuffer&&k instanceof ArrayBuffer)return i(m,C,v);if(S&&k instanceof n.Blob)return h(m,C,v);if(k&&k.base64)return o(m,v);var T=_[m.type];return m.data!==void 0&&(T+=E?d.encode(String(m.data)):String(m.data)),v(""+T)},r.encodeBase64Packet=function(m,C){var E="b"+r.packets[m.type];if(S&&m.data instanceof S){var v=new FileReader;return v.onload=function(){var A=v.result.split(",")[1];C(E+A)},v.readAsDataURL(m.data)}var k;try{k=String.fromCharCode.apply(null,new Uint8Array(m.data))}catch{for(var T=new Uint8Array(m.data),O=new Array(T.length),x=0;x<T.length;x++)O[x]=T[x];k=String.fromCharCode.apply(null,O)}return E+=n.btoa(k),C(E)},r.decodePacket=function(m,C,E){if(typeof m=="string"||m===void 0){if(m.charAt(0)=="b")return r.decodeBase64Packet(m.substr(1),C);if(E)try{m=d.decode(m)}catch{return b}var k=m.charAt(0);return Number(k)==k&&B[k]?m.length>1?{type:B[k],data:m.substring(1)}:{type:B[k]}:b}var v=new Uint8Array(m),k=v[0],T=p(m,1);return S&&C==="blob"&&(T=new S([T])),{type:B[k],data:T}},r.decodeBase64Packet=function(m,C){var E=B[m.charAt(0)];if(!n.ArrayBuffer)return{type:E,data:{base64:!0,data:m.substr(1)}};var v=a.decode(m.substr(1));return C==="blob"&&S&&(v=new S([v])),{type:E,data:v}},r.encodePayload=function(m,C,E){function v(O){return O.length+":"+O}function k(O,x){r.encodePacket(O,T?C:!1,!0,function(A){x(null,v(A))})}typeof C=="function"&&(E=C,C=null);var T=l(m);return C&&T?S&&!w?r.encodePayloadAsBlob(m,E):r.encodePayloadAsArrayBuffer(m,E):m.length?void f(m,k,function(O,x){return E(x.join(""))}):E("0:")},r.decodePayload=function(m,C,E){if(typeof m!="string")return r.decodePayloadAsBinary(m,C,E);typeof C=="function"&&(E=C,C=null);var v;if(m=="")return E(b,0,1);for(var k,T,O="",x=0,A=m.length;A>x;x++){var q=m.charAt(x);if(q!=":")O+=q;else{if(O==""||O!=(k=Number(O))||(T=m.substr(x+1,k),O!=T.length))return E(b,0,1);if(T.length){if(v=r.decodePacket(T,C,!0),b.type==v.type&&b.data==v.data)return E(b,0,1);var j=E(v,x+k,A);if(j===!1)return}x+=k,O=""}}return O!=""?E(b,0,1):void 0},r.encodePayloadAsArrayBuffer=function(m,C){function E(v,k){r.encodePacket(v,!0,!0,function(T){return k(null,T)})}return m.length?void f(m,E,function(v,k){var T=k.reduce(function(A,q){var j;return j=typeof q=="string"?q.length:q.byteLength,A+j.toString().length+j+2},0),O=new Uint8Array(T),x=0;return k.forEach(function(A){var q=typeof A=="string",j=A;if(q){for(var G=new Uint8Array(A.length),W=0;W<A.length;W++)G[W]=A.charCodeAt(W);j=G.buffer}O[x++]=q?0:1;for(var nt=j.byteLength.toString(),W=0;W<nt.length;W++)O[x++]=parseInt(nt[W]);O[x++]=255;for(var G=new Uint8Array(j),W=0;W<G.length;W++)O[x++]=G[W]}),C(O.buffer)}):C(new ArrayBuffer(0))},r.encodePayloadAsBlob=function(m,C){function E(v,k){r.encodePacket(v,!0,!0,function(T){var O=new Uint8Array(1);if(O[0]=1,typeof T=="string"){for(var x=new Uint8Array(T.length),A=0;A<T.length;A++)x[A]=T.charCodeAt(A);T=x.buffer,O[0]=0}for(var q=T instanceof ArrayBuffer?T.byteLength:T.size,j=q.toString(),G=new Uint8Array(j.length+1),A=0;A<j.length;A++)G[A]=parseInt(j[A]);if(G[j.length]=255,S){var W=new S([O.buffer,G.buffer,T]);k(null,W)}})}f(m,E,function(v,k){return C(new S(k))})},r.decodePayloadAsBinary=function(m,C,E){typeof C=="function"&&(E=C,C=null);for(var v=m,k=[],T=!1;v.byteLength>0;){for(var O=new Uint8Array(v),x=O[0]===0,A="",q=1;O[q]!=255;q++){if(A.length>310){T=!0;break}A+=O[q]}if(T)return E(b,0,1);v=p(v,2+A.length),A=parseInt(A);var j=p(v,0,A);if(x)try{j=String.fromCharCode.apply(null,new Uint8Array(j))}catch{var G=new Uint8Array(j);j="";for(var q=0;q<G.length;q++)j+=String.fromCharCode(G[q])}k.push(j),v=p(v,A)}var W=k.length;k.forEach(function(nt,Ut){E(r.decodePacket(nt,C,!0),Ut,W)})}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./keys":26,after:27,"arraybuffer.slice":28,"base64-arraybuffer":29,blob:30,"has-binary":36,utf8:31}],26:[function(t,e){e.exports=Object.keys||function(r){var n=[],o=Object.prototype.hasOwnProperty;for(var i in r)o.call(r,i)&&n.push(i);return n}},{}],27:[function(t,e){function r(o,i,u){function h(c,l){if(h.count<=0)throw new Error("after called too many times");--h.count,c?(f=!0,i(c),i=u):h.count!==0||f||i(null,l)}var f=!1;return u=u||n,h.count=o,o===0?i():h}function n(){}e.exports=r},{}],28:[function(t,e){e.exports=function(r,n,o){var i=r.byteLength;if(n=n||0,o=o||i,r.slice)return r.slice(n,o);if(0>n&&(n+=i),0>o&&(o+=i),o>i&&(o=i),n>=i||n>=o||i===0)return new ArrayBuffer(0);for(var u=new Uint8Array(r),h=new Uint8Array(o-n),f=n,c=0;o>f;f++,c++)h[c]=u[f];return h.buffer}},{}],29:[function(t,e,r){(function(n){r.encode=function(o){var i,u=new Uint8Array(o),h=u.length,f="";for(i=0;h>i;i+=3)f+=n[u[i]>>2],f+=n[(3&u[i])<<4|u[i+1]>>4],f+=n[(15&u[i+1])<<2|u[i+2]>>6],f+=n[63&u[i+2]];return h%3===2?f=f.substring(0,f.length-1)+"=":h%3===1&&(f=f.substring(0,f.length-2)+"=="),f},r.decode=function(o){var i,u,h,f,c,l=.75*o.length,p=o.length,a=0;o[o.length-1]==="="&&(l--,o[o.length-2]==="="&&l--);var s=new ArrayBuffer(l),d=new Uint8Array(s);for(i=0;p>i;i+=4)u=n.indexOf(o[i]),h=n.indexOf(o[i+1]),f=n.indexOf(o[i+2]),c=n.indexOf(o[i+3]),d[a++]=u<<2|h>>4,d[a++]=(15&h)<<4|f>>2,d[a++]=(3&f)<<6|63&c;return s}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],30:[function(t,e){(function(r){function n(l){for(var p=0;p<l.length;p++){var a=l[p];if(a.buffer instanceof ArrayBuffer){var s=a.buffer;if(a.byteLength!==s.byteLength){var d=new Uint8Array(a.byteLength);d.set(new Uint8Array(s,a.byteOffset,a.byteLength)),s=d.buffer}l[p]=s}}}function o(l,p){p=p||{};var a=new u;n(l);for(var s=0;s<l.length;s++)a.append(l[s]);return p.type?a.getBlob(p.type):a.getBlob()}function i(l,p){return n(l),new Blob(l,p||{})}var u=r.BlobBuilder||r.WebKitBlobBuilder||r.MSBlobBuilder||r.MozBlobBuilder,h=function(){try{var l=new Blob(["hi"]);return l.size===2}catch{return!1}}(),f=h&&function(){try{var l=new Blob([new Uint8Array([1,2])]);return l.size===2}catch{return!1}}(),c=u&&u.prototype.append&&u.prototype.getBlob;e.exports=function(){return h?f?r.Blob:i:c?o:void 0}()}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],31:[function(t,e,r){(function(n){(function(o){function i(v){for(var k,T,O=[],x=0,A=v.length;A>x;)k=v.charCodeAt(x++),k>=55296&&56319>=k&&A>x?(T=v.charCodeAt(x++),(64512&T)==56320?O.push(((1023&k)<<10)+(1023&T)+65536):(O.push(k),x--)):O.push(k);return O}function u(v){for(var k,T=v.length,O=-1,x="";++O<T;)k=v[O],k>65535&&(k-=65536,x+=b(k>>>10&1023|55296),k=56320|1023&k),x+=b(k);return x}function h(v){if(v>=55296&&57343>=v)throw Error("Lone surrogate U+"+v.toString(16).toUpperCase()+" is not a scalar value")}function f(v,k){return b(v>>k&63|128)}function c(v){if(!(4294967168&v))return b(v);var k="";return 4294965248&v?4294901760&v?!(4292870144&v)&&(k=b(v>>18&7|240),k+=f(v,12),k+=f(v,6)):(h(v),k=b(v>>12&15|224),k+=f(v,6)):k=b(v>>6&31|192),k+=b(63&v|128)}function l(v){for(var k,T=i(v),O=T.length,x=-1,A="";++x<O;)k=T[x],A+=c(k);return A}function p(){if(B>=_)throw Error("Invalid byte index");var v=255&w[B];if(B++,(192&v)==128)return 63&v;throw Error("Invalid continuation byte")}function a(){var v,k,T,O,x;if(B>_)throw Error("Invalid byte index");if(B==_)return!1;if(v=255&w[B],B++,(128&v)==0)return v;if((224&v)==192){var k=p();if(x=(31&v)<<6|k,x>=128)return x;throw Error("Invalid continuation byte")}if((240&v)==224){if(k=p(),T=p(),x=(15&v)<<12|k<<6|T,x>=2048)return h(x),x;throw Error("Invalid continuation byte")}if((248&v)==240&&(k=p(),T=p(),O=p(),x=(15&v)<<18|k<<12|T<<6|O,x>=65536&&1114111>=x))return x;throw Error("Invalid UTF-8 detected")}function s(v){w=i(v),_=w.length,B=0;for(var k,T=[];(k=a())!==!1;)T.push(k);return u(T)}var d=typeof r=="object"&&r,y=typeof e=="object"&&e&&e.exports==d&&e,g=typeof n=="object"&&n;(g.global===g||g.window===g)&&(o=g);var w,_,B,b=String.fromCharCode,S={version:"2.0.0",encode:l,decode:s};if(d&&!d.nodeType)if(y)y.exports=S;else{var m={},C=m.hasOwnProperty;for(var E in S)C.call(S,E)&&(d[E]=S[E])}else o.utf8=S})(this)}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],32:[function(t,e){(function(r){var n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,i=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,u=/(?:^|:|,)(?:\s*\[)+/g,h=/^\s+/,f=/\s+$/;e.exports=function(c){return typeof c=="string"&&c?(c=c.replace(h,"").replace(f,""),r.JSON&&JSON.parse?JSON.parse(c):n.test(c.replace(o,"@").replace(i,"]").replace(u,""))?new Function("return "+c)():void 0):null}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],33:[function(t,e,r){r.encode=function(n){var o="";for(var i in n)n.hasOwnProperty(i)&&(o.length&&(o+="&"),o+=encodeURIComponent(i)+"="+encodeURIComponent(n[i]));return o},r.decode=function(n){for(var o={},i=n.split("&"),u=0,h=i.length;h>u;u++){var f=i[u].split("=");o[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return o}},{}],34:[function(t,e){var r=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];e.exports=function(o){var i=o,u=o.indexOf("["),h=o.indexOf("]");u!=-1&&h!=-1&&(o=o.substring(0,u)+o.substring(u,h).replace(/:/g,";")+o.substring(h,o.length));for(var f=r.exec(o||""),c={},l=14;l--;)c[n[l]]=f[l]||"";return u!=-1&&h!=-1&&(c.source=i,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c}},{}],35:[function(t,e){function r(i,u){return u?new o(i,u):new o(i)}var n=function(){return self}(),o=n.WebSocket||n.MozWebSocket;e.exports=o?r:null,o&&(r.prototype=o.prototype)},{}],36:[function(t,e){(function(r){function n(i){function u(h){if(!h)return!1;if(r.Buffer&&r.Buffer.isBuffer(h)||r.ArrayBuffer&&h instanceof ArrayBuffer||r.Blob&&h instanceof Blob||r.File&&h instanceof File)return!0;if(o(h)){for(var f=0;f<h.length;f++)if(u(h[f]))return!0}else if(h&&typeof h=="object"){h.toJSON&&(h=h.toJSON());for(var c in h)if(Object.prototype.hasOwnProperty.call(h,c)&&u(h[c]))return!0}return!1}return u(i)}var o=t("isarray");e.exports=n}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{isarray:37}],37:[function(t,e){e.exports=Array.isArray||function(r){return Object.prototype.toString.call(r)=="[object Array]"}},{}],38:[function(t,e){var r=t("global");try{e.exports="XMLHttpRequest"in r&&"withCredentials"in new r.XMLHttpRequest}catch{e.exports=!1}},{global:39}],39:[function(t,e){e.exports=function(){return this}()},{}],40:[function(t,e){var r=[].indexOf;e.exports=function(n,o){if(r)return n.indexOf(o);for(var i=0;i<n.length;++i)if(n[i]===o)return i;return-1}},{}],41:[function(t,e,r){var n=Object.prototype.hasOwnProperty;r.keys=Object.keys||function(o){var i=[];for(var u in o)n.call(o,u)&&i.push(u);return i},r.values=function(o){var i=[];for(var u in o)n.call(o,u)&&i.push(o[u]);return i},r.merge=function(o,i){for(var u in i)n.call(i,u)&&(o[u]=i[u]);return o},r.length=function(o){return r.keys(o).length},r.isEmpty=function(o){return r.length(o)==0}},{}],42:[function(t,e){var r=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];e.exports=function(o){for(var i=r.exec(o||""),u={},h=14;h--;)u[n[h]]=i[h]||"";return u}},{}],43:[function(t,e,r){(function(n){var o=t("isarray"),i=t("./is-buffer");r.deconstructPacket=function(u){function h(p){if(!p)return p;if(i(p)){var a={_placeholder:!0,num:f.length};return f.push(p),a}if(o(p)){for(var s=new Array(p.length),d=0;d<p.length;d++)s[d]=h(p[d]);return s}if(typeof p=="object"&&!(p instanceof Date)){var s={};for(var y in p)s[y]=h(p[y]);return s}return p}var f=[],c=u.data,l=u;return l.data=h(c),l.attachments=f.length,{packet:l,buffers:f}},r.reconstructPacket=function(u,h){function f(c){if(c&&c._placeholder){var l=h[c.num];return l}if(o(c)){for(var p=0;p<c.length;p++)c[p]=f(c[p]);return c}if(c&&typeof c=="object"){for(var a in c)c[a]=f(c[a]);return c}return c}return u.data=f(u.data),u.attachments=void 0,u},r.removeBlobs=function(u,h){function f(p,a,s){if(!p)return p;if(n.Blob&&p instanceof Blob||n.File&&p instanceof File){c++;var d=new FileReader;d.onload=function(){s?s[a]=this.result:l=this.result,--c||h(l)},d.readAsArrayBuffer(p)}else if(o(p))for(var y=0;y<p.length;y++)f(p[y],y,p);else if(p&&typeof p=="object"&&!i(p))for(var g in p)f(p[g],g,p)}var c=0,l=u;f(l),c||h(l)}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./is-buffer":45,isarray:46}],44:[function(t,e,r){function n(){}function o(y){var g="",w=!1;return g+=y.type,(r.BINARY_EVENT==y.type||r.BINARY_ACK==y.type)&&(g+=y.attachments,g+="-"),y.nsp&&y.nsp!="/"&&(w=!0,g+=y.nsp),y.id!=null&&(w&&(g+=",",w=!1),g+=y.id),y.data!=null&&(w&&(g+=","),g+=p.stringify(y.data)),l("encoded %j as %s",y,g),g}function i(y,g){function w(_){var B=s.deconstructPacket(_),b=o(B.packet),S=B.buffers;S.unshift(b),g(S)}s.removeBlobs(y,w)}function u(){this.reconstructor=null}function h(y){var g={},w=0;if(g.type=Number(y.charAt(0)),r.types[g.type]==null)return c();if(r.BINARY_EVENT==g.type||r.BINARY_ACK==g.type){for(var _="";y.charAt(++w)!="-"&&(_+=y.charAt(w),w!=y.length););if(_!=Number(_)||y.charAt(w)!="-")throw new Error("Illegal attachments");g.attachments=Number(_)}if(y.charAt(w+1)=="/")for(g.nsp="";++w;){var B=y.charAt(w);if(B==","||(g.nsp+=B,w==y.length))break}else g.nsp="/";var b=y.charAt(w+1);if(b!==""&&Number(b)==b){for(g.id="";++w;){var B=y.charAt(w);if(B==null||Number(B)!=B){--w;break}if(g.id+=y.charAt(w),w==y.length)break}g.id=Number(g.id)}if(y.charAt(++w))try{g.data=p.parse(y.substr(w))}catch{return c()}return l("decoded %s as %j",y,g),g}function f(y){this.reconPack=y,this.buffers=[]}function c(){return{type:r.ERROR,data:"parser error"}}var l=t("debug")("socket.io-parser"),p=t("json3"),a=(t("isarray"),t("component-emitter")),s=t("./binary"),d=t("./is-buffer");r.protocol=4,r.types=["CONNECT","DISCONNECT","EVENT","BINARY_EVENT","ACK","BINARY_ACK","ERROR"],r.CONNECT=0,r.DISCONNECT=1,r.EVENT=2,r.ACK=3,r.ERROR=4,r.BINARY_EVENT=5,r.BINARY_ACK=6,r.Encoder=n,r.Decoder=u,n.prototype.encode=function(y,g){if(l("encoding packet %j",y),r.BINARY_EVENT==y.type||r.BINARY_ACK==y.type)i(y,g);else{var w=o(y);g([w])}},a(u.prototype),u.prototype.add=function(y){var g;if(typeof y=="string")g=h(y),r.BINARY_EVENT==g.type||r.BINARY_ACK==g.type?(this.reconstructor=new f(g),this.reconstructor.reconPack.attachments===0&&this.emit("decoded",g)):this.emit("decoded",g);else{if(!d(y)&&!y.base64)throw new Error("Unknown type: "+y);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");g=this.reconstructor.takeBinaryData(y),g&&(this.reconstructor=null,this.emit("decoded",g))}},u.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},f.prototype.takeBinaryData=function(y){if(this.buffers.push(y),this.buffers.length==this.reconPack.attachments){var g=s.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),g}return null},f.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},{"./binary":43,"./is-buffer":45,"component-emitter":9,debug:10,isarray:46,json3:47}],45:[function(t,e){(function(r){function n(o){return r.Buffer&&r.Buffer.isBuffer(o)||r.ArrayBuffer&&o instanceof ArrayBuffer}e.exports=n}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],46:[function(t,e){e.exports=t(37)},{}],47:[function(t,e,r){(function(n){function o(R){if(o[R]!==h)return o[R];var U;if(R=="bug-string-char-index")U=!1;else if(R=="json")U=o("json-stringify")&&o("json-parse");else{var I,F='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if(R=="json-stringify"){var N=l.stringify,D=typeof N=="function"&&p;if(D){(I=function(){return 1}).toJSON=I;try{D=N(0)==="0"&&N(new Number)==="0"&&N(new String)=='""'&&N(f)===h&&N(h)===h&&N()===h&&N(I)==="1"&&N([I])=="[1]"&&N([h])=="[null]"&&N(null)=="null"&&N([h,f,null])=="[null,null,null]"&&N({a:[I,!0,!1,null,`\0\b
9
+ \f\r `]})==F&&N(null,I)==="1"&&N([1,2],null,1)==`[
10
+ 1,
11
+ 2
12
+ ]`&&N(new Date(-864e13))=='"-271821-04-20T00:00:00.000Z"'&&N(new Date(864e13))=='"+275760-09-13T00:00:00.000Z"'&&N(new Date(-621987552e5))=='"-000001-01-01T00:00:00.000Z"'&&N(new Date(-1))=='"1969-12-31T23:59:59.999Z"'}catch{D=!1}}U=D}if(R=="json-parse"){var P=l.parse;if(typeof P=="function")try{if(P("0")===0&&!P(!1)){I=P(F);var L=I.a.length==5&&I.a[0]===1;if(L){try{L=!P('" "')}catch{}if(L)try{L=P("01")!==1}catch{}if(L)try{L=P("1.")!==1}catch{}}}}catch{L=!1}U=L}}return o[R]=!!U}var i,u,h,f={}.toString,c=typeof JSON=="object"&&JSON,l=typeof r=="object"&&r&&!r.nodeType&&r;l&&c?(l.stringify=c.stringify,l.parse=c.parse):l=n.JSON=c||{};var p=new Date(-0xc782b5b800cec);try{p=p.getUTCFullYear()==-109252&&p.getUTCMonth()===0&&p.getUTCDate()===1&&p.getUTCHours()==10&&p.getUTCMinutes()==37&&p.getUTCSeconds()==6&&p.getUTCMilliseconds()==708}catch{}if(!o("json")){var a="[object Function]",s="[object Date]",d="[object Number]",y="[object String]",g="[object Array]",w="[object Boolean]",_=o("bug-string-char-index");if(!p)var B=Math.floor,b=[0,31,59,90,120,151,181,212,243,273,304,334],S=function(R,U){return b[U]+365*(R-1970)+B((R-1969+(U=+(U>1)))/4)-B((R-1901+U)/100)+B((R-1601+U)/400)};(i={}.hasOwnProperty)||(i=function(R){var U,I={};return(I.__proto__=null,I.__proto__={toString:1},I).toString!=f?i=function(F){var N=this.__proto__,D=F in(this.__proto__=null,this);return this.__proto__=N,D}:(U=I.constructor,i=function(F){var N=(this.constructor||U).prototype;return F in this&&!(F in N&&this[F]===N[F])}),I=null,i.call(this,R)});var m={boolean:1,number:1,string:1,undefined:1},C=function(R,U){var I=typeof R[U];return I=="object"?!!R[U]:!m[I]};if(u=function(R,U){var I,F,N,D=0;(I=function(){this.valueOf=0}).prototype.valueOf=0,F=new I;for(N in F)i.call(F,N)&&D++;return I=F=null,D?u=D==2?function(P,L){var M,J={},ot=f.call(P)==a;for(M in P)ot&&M=="prototype"||i.call(J,M)||!(J[M]=1)||!i.call(P,M)||L(M)}:function(P,L){var M,J,ot=f.call(P)==a;for(M in P)ot&&M=="prototype"||!i.call(P,M)||(J=M==="constructor")||L(M);(J||i.call(P,M="constructor"))&&L(M)}:(F=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],u=function(P,L){var M,J,ot=f.call(P)==a,at=!ot&&typeof P.constructor!="function"&&C(P,"hasOwnProperty")?P.hasOwnProperty:i;for(M in P)ot&&M=="prototype"||!at.call(P,M)||L(M);for(J=F.length;M=F[--J];at.call(P,M)&&L(M));}),u(R,U)},!o("json-stringify")){var E={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},v="000000",k=function(R,U){return(v+(U||0)).slice(-R)},T="\\u00",O=function(R){var U,I='"',F=0,N=R.length,D=N>10&&_;for(D&&(U=R.split(""));N>F;F++){var P=R.charCodeAt(F);switch(P){case 8:case 9:case 10:case 12:case 13:case 34:case 92:I+=E[P];break;default:if(32>P){I+=T+k(2,P.toString(16));break}I+=D?U[F]:_?R.charAt(F):R[F]}}return I+'"'},x=function(R,U,I,F,N,D,P){var L,M,J,ot,at,Dt,xe,Re,Ie,_e,dt,Be,Gt,Pt,Le,Ue;try{L=U[R]}catch{}if(typeof L=="object"&&L)if(M=f.call(L),M!=s||i.call(L,"toJSON"))typeof L.toJSON=="function"&&(M!=d&&M!=y&&M!=g||i.call(L,"toJSON"))&&(L=L.toJSON(R));else if(L>-1/0&&1/0>L){if(S){for(at=B(L/864e5),J=B(at/365.2425)+1970-1;S(J+1,0)<=at;J++);for(ot=B((at-S(J,0))/30.42);S(J,ot+1)<=at;ot++);at=1+at-S(J,ot),Dt=(L%864e5+864e5)%864e5,xe=B(Dt/36e5)%24,Re=B(Dt/6e4)%60,Ie=B(Dt/1e3)%60,_e=Dt%1e3}else J=L.getUTCFullYear(),ot=L.getUTCMonth(),at=L.getUTCDate(),xe=L.getUTCHours(),Re=L.getUTCMinutes(),Ie=L.getUTCSeconds(),_e=L.getUTCMilliseconds();L=(0>=J||J>=1e4?(0>J?"-":"+")+k(6,0>J?-J:J):k(4,J))+"-"+k(2,ot+1)+"-"+k(2,at)+"T"+k(2,xe)+":"+k(2,Re)+":"+k(2,Ie)+"."+k(3,_e)+"Z"}else L=null;if(I&&(L=I.call(U,R,L)),L===null)return"null";if(M=f.call(L),M==w)return""+L;if(M==d)return L>-1/0&&1/0>L?""+L:"null";if(M==y)return O(""+L);if(typeof L=="object"){for(Pt=P.length;Pt--;)if(P[Pt]===L)throw TypeError();if(P.push(L),dt=[],Le=D,D+=N,M==g){for(Gt=0,Pt=L.length;Pt>Gt;Gt++)Be=x(Gt,L,I,F,N,D,P),dt.push(Be===h?"null":Be);Ue=dt.length?N?`[
13
+ `+D+dt.join(`,
14
+ `+D)+`
15
+ `+Le+"]":"["+dt.join(",")+"]":"[]"}else u(F||L,function(De){var Fr=x(De,L,I,F,N,D,P);Fr!==h&&dt.push(O(De)+":"+(N?" ":"")+Fr)}),Ue=dt.length?N?`{
16
+ `+D+dt.join(`,
17
+ `+D)+`
18
+ `+Le+"}":"{"+dt.join(",")+"}":"{}";return P.pop(),Ue}};l.stringify=function(R,U,I){var F,N,D,P;if(typeof U=="function"||typeof U=="object"&&U){if((P=f.call(U))==a)N=U;else if(P==g){D={};for(var L,M=0,J=U.length;J>M;L=U[M++],P=f.call(L),(P==y||P==d)&&(D[L]=1));}}if(I)if((P=f.call(I))==d){if((I-=I%1)>0)for(F="",I>10&&(I=10);F.length<I;F+=" ");}else P==y&&(F=I.length<=10?I:I.slice(0,10));return x("",(L={},L[""]=R,L),N,D,F,"",[])}}if(!o("json-parse")){var A,q,j=String.fromCharCode,G={92:"\\",34:'"',47:"/",98:"\b",116:" ",110:`
19
+ `,102:"\f",114:"\r"},W=function(){throw A=q=null,SyntaxError()},nt=function(){for(var R,U,I,F,N,D=q,P=D.length;P>A;)switch(N=D.charCodeAt(A)){case 9:case 10:case 13:case 32:A++;break;case 123:case 125:case 91:case 93:case 58:case 44:return R=_?D.charAt(A):D[A],A++,R;case 34:for(R="@",A++;P>A;)if(N=D.charCodeAt(A),32>N)W();else if(N==92)switch(N=D.charCodeAt(++A)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:R+=G[N],A++;break;case 117:for(U=++A,I=A+4;I>A;A++)N=D.charCodeAt(A),N>=48&&57>=N||N>=97&&102>=N||N>=65&&70>=N||W();R+=j("0x"+D.slice(U,A));break;default:W()}else{if(N==34)break;for(N=D.charCodeAt(A),U=A;N>=32&&N!=92&&N!=34;)N=D.charCodeAt(++A);R+=D.slice(U,A)}if(D.charCodeAt(A)==34)return A++,R;W();default:if(U=A,N==45&&(F=!0,N=D.charCodeAt(++A)),N>=48&&57>=N){for(N==48&&(N=D.charCodeAt(A+1),N>=48&&57>=N)&&W(),F=!1;P>A&&(N=D.charCodeAt(A),N>=48&&57>=N);A++);if(D.charCodeAt(A)==46){for(I=++A;P>I&&(N=D.charCodeAt(I),N>=48&&57>=N);I++);I==A&&W(),A=I}if(N=D.charCodeAt(A),N==101||N==69){for(N=D.charCodeAt(++A),(N==43||N==45)&&A++,I=A;P>I&&(N=D.charCodeAt(I),N>=48&&57>=N);I++);I==A&&W(),A=I}return+D.slice(U,A)}if(F&&W(),D.slice(A,A+4)=="true")return A+=4,!0;if(D.slice(A,A+5)=="false")return A+=5,!1;if(D.slice(A,A+4)=="null")return A+=4,null;W()}return"$"},Ut=function(R){var U,I;if(R=="$"&&W(),typeof R=="string"){if((_?R.charAt(0):R[0])=="@")return R.slice(1);if(R=="["){for(U=[];R=nt(),R!="]";I||(I=!0))I&&(R==","?(R=nt(),R=="]"&&W()):W()),R==","&&W(),U.push(Ut(R));return U}if(R=="{"){for(U={};R=nt(),R!="}";I||(I=!0))I&&(R==","?(R=nt(),R=="}"&&W()):W()),(R==","||typeof R!="string"||(_?R.charAt(0):R[0])!="@"||nt()!=":")&&W(),U[R.slice(1)]=Ut(nt());return U}W()}return R},Dr=function(R,U,I){var F=Pr(R,U,I);F===h?delete R[U]:R[U]=F},Pr=function(R,U,I){var F,N=R[U];if(typeof N=="object"&&N)if(f.call(N)==g)for(F=N.length;F--;)Dr(N,F,I);else u(N,function(D){Dr(N,D,I)});return I.call(R,U,N)};l.parse=function(R,U){var I,F;return A=0,q=""+R,I=Ut(nt()),nt()!="$"&&W(),A=q=null,U&&f.call(U)==a?Pr((F={},F[""]=I,F),"",U):I}}}})(this)},{}],48:[function(t,e){function r(n,o){var i=[];o=o||0;for(var u=o||0;u<n.length;u++)i[u-o]=n[u];return i}e.exports=r},{}]},{},[1])(1)}const qo=Object.assign({"./v1_3_7.js":Object.freeze(Object.defineProperty({__proto__:null,default:Mo},Symbol.toStringTag,{value:"Module"}))}),zo=/v\d+_\d+_\d+/;function Xo(t){return typeof t=="function"}const Ae=Object.entries(qo).reduce((t,e)=>{var o;const r=e[1].default,n=(o=e[0].match(zo))==null?void 0:o[0];return Xo(r)&&n&&(t[n]=r()),t},{}),Or=t=>{if(t in Ae)return Ae[t];throw new Error(`Socket version ${t} not found`)},Wo={...Ae,getSocketVersion:Or,makeSocketVersion:(t,...e)=>Or(t)(...e)};var xr=(t=>(t.RINGING="Ringing",t.TALKING="Talking",t.DIALING="Dialing",t.HOLD="Hold",t))(xr||{}),Rr=(t=>(t.INCOMING="Incoming",t.OUTGOING="Outgoing",t))(Rr||{}),kt=(t=>(t.CONNECTED="connected",t.DISCONNECTED="disconnected",t.TRYING_TO_CONNECT="tryingToConnect",t))(kt||{}),Ir=(t=>(t.AUTOMATIC="Automatic",t.IVR="IVR",t))(Ir||{}),_r=(t=>(t.INCOMINC="Incoming",t.OUTGOING="Outgoing",t.SPY="Spy",t.CLICK2CALL="Click2Call",t))(_r||{}),Br=(t=>(t.RESPONSE_FROM_API_VALID="RESPONSE_FROM_API_VALID",t.RESPONSE_FROM_API_INVALID="RESPONSE_FROM_API_INVALID",t))(Br||{}),z=(t=>(t.ALL_DIALER_STATUS="AllDialersStatus",t.ALL_EXTENSION_STATUS="AllExtensionsStatus",t.ALL_USERS_STATUS="AllUsersStatus",t.CONNECT="connect",t.DISCONNECT="disconnect",t.CONNECT_ERROR_EVENT="connect_error",t.EXTENSION_EVENT="ExtensionEvent",t.KEEP_ALIVE="keepalive",t.KEEP_ALIVE_RESPONSE="keepaliveResponse",t.LOGIN_STATUS="loginStatus",t.LOGIN_SUCCESS="loginSuccess",t.QUEUE_EVENT="QueueEvent",t.ONLINE_STATUS_EVENT="onlineStatusEvent",t.DIALER_EVENT="DialerEvent",t.EXTENSIONS_UPDATED="ExtensionsUpdated",t))(z||{}),Te=(t=>(t.NEWCALL="NEWCALL",t.ANSWER="ANSWER",t.HOLD="HOLD",t.UNHOLD="UNHOLD",t.HANGUP="HANGUP",t.USER_STATUS_UPDATE="userStatusUpdate",t))(Te||{}),Lr=(t=>(t.NORMAL_HANGUP="Normal hangup",t.USER_BUSY="User busy",t.CALL_REJECTED="Call Rejected",t.UNALLOCATED_NUMBER="Unallocated (unassigned) number",t.UNKNOWN="Unknown",t.NO_USER_RESPONDING="No user responding",t.USER_ALERTING="User alerting, no answer",t.ANSWERED_ELSEWHERE="Answered elsewhere",t))(Lr||{}),Ur=(t=>(t.ANSWER="ANSWER",t.ABANDONED="ABANDONED",t.EXIT="EXIT",t.JOIN="JOIN",t))(Ur||{});class Ne{static mapExtensionEvent(e){var u,h;const r=e.reason;let n,o;e.data.currentCall&&(o=this.mapExtensionCall(e,e.data.currentCall));const i=this.mapExtensionData(e,e.data);return r===Te.HANGUP?n={...e,reason:r,data:{...i,currentCall:o?{...o,duration:o.callAnswered_UTC_CLIENT?Date.now()-o.callAnswered_UTC_CLIENT:0}:void 0,calls:(u=e.data.calls)==null?void 0:u.map(f=>{const c=this.mapExtensionCall(e,f);return{...c,duration:c.callAnswered_UTC_CLIENT?Date.now()-c.callAnswered_UTC_CLIENT:0}})}}:n={...e,data:{...i,currentCall:o,calls:(h=e.data.calls)==null?void 0:h.map(f=>this.mapExtensionCall(e,f))},reason:r},n}static mapAllExtensionStatus(e){return{...e,extensions:e.extensions.map(r=>{var n;return{...this.mapExtensionData(e,r),currentCall:r.currentCall?this.mapExtensionCall(e,r.currentCall):void 0,calls:(n=r.calls)==null?void 0:n.map(o=>this.mapExtensionCall(e,o))}})}}static mapExtensionData(e,r){return this.configureUTCForObject(r,[{key:"lastAnsweredCallEventEpoch",format:"sec"},{key:"lastCallEventEpoch",format:"sec"},{key:"lastHangupCallEpoch",format:"sec"},{key:"representativeUpdated",format:"ms"}],e.servertime,e.servertimeoffset)}static mapExtensionCall(e,r){return this.configureUTCForObject(r,[{key:"callAnswered",format:"sec"},{key:"callStarted",format:"sec"}],e.servertime,e.servertimeoffset)}static mapQueueEvent(e){var r;return{...e,data:{...e.data,Calls:(r=e.data.Calls)==null?void 0:r.map(n=>this.configureUTCForObject(n,[{key:"JoinTimeStamp",format:"sec"}],e.servertime,e.servertimeoffset))}}}static assignProperty(e,r,n){e[r]=n}static configureUTCForObject(e,r,n,o){const i=(n-o*60)*1e3,u=Date.now()-i,h={};return r.forEach(f=>{const c=e[f.key],l=f.key;if(c!==0&&typeof c=="number"&&!isNaN(c)){let p=c;f.format==="ms"&&(p=Math.floor(p/1e3));const a=(p-o*60)*1e3;this.assignProperty(h,`${l}_UTC`,a),this.assignProperty(h,`${l}_UTC_CLIENT`,a+u)}else this.assignProperty(h,`${l}_UTC`,0),this.assignProperty(h,`${l}_UTC_CLIENT`,0)}),{...e,...h}}}var Oe=(t=>(t.UPDATE_MONITORED_EXTENSIONS="updateMonitoredExtensions",t.KEEP_ALIVE="keepAlive",t))(Oe||{});class Ko{constructor(e){H(this,"io");H(this,"ioFunction");H(this,"lastEventTimestamp",new Date().getTime());H(this,"doReconnect",!0);H(this,"keepAliveInterval");H(this,"keepReconnectInterval");H(this,"connected",!1);this.eventsSdkClass=e,this.eventsSdkClass=e}getSocketIoFunction(e){const r=e.split("v="),n="v".concat(r[r.length-1]).replaceAll(".","_");this.ioFunction=Wo.getSocketVersion(n)}initSocketConnection(){const e=this.eventsSdkClass.authClass.token,r=this.eventsSdkClass.options.protocol,n=this.eventsSdkClass.server;try{const o=n?n.Domain:this.eventsSdkClass.URL,i=n?`${r}://${o}`:this.eventsSdkClass.URL;this.eventsSdkClass.eventEmitterClass.emit(z.ONLINE_STATUS_EVENT,{attemptToConnect:i,connectionStatus:kt.TRYING_TO_CONNECT});const u={reconnection:!1,upgrade:!1,transports:["websocket"],forceNew:!0,query:{token:e},timeout:this.eventsSdkClass.options.timeout};if(e&&(u.query={token:e}),this.ioFunction&&i)this.io=this.ioFunction(i,u),this.eventsSdkClass.loggerClass.log({Message:`${this.eventsSdkClass.options.loggerConfig.system} is trying to connect to WS server ${o}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Switching Protocols",StatusCode:101,Level:et.INFO,LogType:pt.INFO});else throw new Error("Socket server url no defined")}catch(o){this.eventsSdkClass.loggerClass.log({Message:`${o}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Connection error",StatusCode:500,Level:et.ERROR,LogType:pt.ERROR})}}clearKeepAliveInterval(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval)}initKeepAlive(){this.clearKeepAliveInterval(),this.keepAliveInterval=setInterval(async()=>{if(new Date().getTime()>this.lastEventTimestamp+this.eventsSdkClass.options.keepAliveTimeout&&this.io&&this.eventsSdkClass.authClass.token){this.eventsSdkClass.emit(Oe.KEEP_ALIVE,this.eventsSdkClass.authClass.token),this.eventsSdkClass.loggerClass.log({Message:`Keep alive event emitted with this token: ${this.eventsSdkClass.authClass.token}`,ActionName:ht.WSCONNECT,isShowClient:!1,Level:et.INFO,LogType:pt.INFO});return}},this.eventsSdkClass.options.keepAliveTimeout)}closeAllConnections(){var e;this.io&&(this.io.close(),(e=this.io)==null||e.disconnect(),this.io=void 0),Rt.clearSessionStorage()}initSocketEvents(){this.io&&this.io.on(z.LOGIN_SUCCESS,e=>this.onLoginSuccessEvent(e)).on(z.QUEUE_EVENT,e=>this.onQueueEvent(e)).on(z.EXTENSION_EVENT,e=>this.onExtensionEvent(e)).on(z.DIALER_EVENT,e=>this.onDialerEvent(e)).on(z.LOGIN_STATUS,e=>this.onLoginStatusEvent(e)).on(z.ALL_EXTENSION_STATUS,e=>this.onAllExtensionStatus(e)).on(z.ALL_DIALER_STATUS,e=>this.onAllDialerStatus(e)).on(z.KEEP_ALIVE_RESPONSE,e=>this.onKeepAliveResponse(e)).on(z.EXTENSIONS_UPDATED,e=>this.onExtensionsUpdatedEvent(e)).on(z.CONNECT,()=>this.onConnect()).on(z.DISCONNECT,e=>this.onDisconnect(e)).on(z.CONNECT_ERROR_EVENT,e=>this.onConnectError(e))}onLoginSuccessEvent(e){this.eventsSdkClass.eventEmitterClass.emit(z.LOGIN_SUCCESS,e)}onQueueEvent(e){this.eventsSdkClass.eventEmitterClass.emit(z.QUEUE_EVENT,Ne.mapQueueEvent(e))}onExtensionEvent(e){const r=Ne.mapExtensionEvent(e);r&&this.eventsSdkClass.eventEmitterClass.emit(z.EXTENSION_EVENT,r)}onDialerEvent(e){this.eventsSdkClass.eventEmitterClass.emit(z.DIALER_EVENT,e)}onLoginStatusEvent(e){this.eventsSdkClass.eventEmitterClass.emit(z.LOGIN_STATUS,e)}onAllExtensionStatus(e){const r=Ne.mapAllExtensionStatus(e);this.eventsSdkClass.eventEmitterClass.emit(z.ALL_EXTENSION_STATUS,r)}onAllDialerStatus(e){this.eventsSdkClass.eventEmitterClass.emit(z.ALL_DIALER_STATUS,e)}onKeepAliveResponse(e){if(e.errorCode){this.initSocketConnection();return}this.eventsSdkClass.loggerClass.log({Message:`Keep alive response: ${e}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Successful",StatusCode:200,Level:et.INFO,LogType:pt.INFO}),this.connected?this.lastEventTimestamp=new Date().getTime():this.initSocketConnection()}onExtensionsUpdatedEvent(e){this.eventsSdkClass.eventEmitterClass.emit(z.EXTENSIONS_UPDATED,e)}onConnect(){this.keepReconnectInterval&&clearInterval(this.keepReconnectInterval),this.connected=!0,this.eventsSdkClass.eventEmitterClass.emit(z.ONLINE_STATUS_EVENT,{connectionStatus:kt.CONNECTED}),this.eventsSdkClass.loggerClass.log({Message:`Sdk connected to the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Connection established",StatusCode:200,Level:et.INFO,LogType:pt.INFO})}onDisconnect(e){this.connected=!1,this.closeAllConnections(),this.eventsSdkClass.eventEmitterClass.emit(z.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?kt.TRYING_TO_CONNECT:kt.DISCONNECTED}),this.eventsSdkClass.loggerClass.log({Message:`Sdk disconnected from the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL} (${e})`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Connection closed",StatusCode:200,Level:et.INFO,LogType:pt.INFO}),this.doReconnect&&this.eventsSdkClass.connect(Ct.NEXT)}onConnectError(e){this.eventsSdkClass.eventEmitterClass.emit(z.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?kt.TRYING_TO_CONNECT:kt.DISCONNECTED}),this.eventsSdkClass.loggerClass.log({Message:`Sdk attempt to connect to the socket server ${this.eventsSdkClass.URL} failed (${e})`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Connection attempt error",StatusCode:500,Level:et.ERROR,LogType:pt.ERROR}),setTimeout(()=>{this.eventsSdkClass.connect(Ct.NEXT)},this.eventsSdkClass.options.reconnectionDelay)}}class Ho{constructor(e){H(this,"storageLogger");this.eventsSdkClass=e,this.eventsSdkClass=e}init(){if(!this.eventsSdkClass.options.useLogger)return;if(this.eventsSdkClass.options.storageLoggerInstance){this.storageLogger=this.eventsSdkClass.options.storageLoggerInstance;return}let e;this.eventsSdkClass.options.loggerSocketConnection&&(e=this.eventsSdkClass.options.loggerSocketConnection),this.eventsSdkClass.socketIoClass.ioFunction&&!e&&(e=this.eventsSdkClass.socketIoClass.ioFunction(this.eventsSdkClass.options.loggerServer,this.eventsSdkClass.options.loggerConnectOptions)),e&&(this.storageLogger=new Po({socket:e,loggerOptions:this.eventsSdkClass.options.loggerConfig}))}stop(){this.storageLogger&&this.storageLogger.stop()}log(e){this.eventsSdkClass.options.useLogger&&(this.storageLogger?e.Level===et.INFO?this.storageLogger.log(e):e.Level===et.ERROR&&this.storageLogger.error(e):e.Level===et.INFO?console.log(e):e.Level===et.ERROR&&console.error(e))}sdkInitializedLog(){const e={...this.eventsSdkClass.options,token:"CENSORED",password:"CENSORED"};this.log({Message:"Sdk initialized with provided options",Body:JSON.stringify(e,this.eventsSdkClass.getCircularReplacer()),ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Sdk initialized",StatusCode:200,Level:et.INFO,LogType:pt.INFO})}}class Jo{constructor(e){H(this,"listeners",{[z.ALL_EXTENSION_STATUS]:[],[z.ALL_DIALER_STATUS]:[],[z.ALL_USERS_STATUS]:[],[z.QUEUE_EVENT]:[],[z.EXTENSION_EVENT]:[],[z.DIALER_EVENT]:[],[z.LOGIN_SUCCESS]:[],[z.LOGIN_STATUS]:[],[z.KEEP_ALIVE_RESPONSE]:[],[z.ONLINE_STATUS_EVENT]:[],[z.EXTENSIONS_UPDATED]:[]});H(this,"allListeners",[]);this.eventsSdkClass=e,this.eventsSdkClass=e}on(e,r){e==="*"?this.allListeners.push(r):this.listeners[e].push(r)}off(e,r){if(e==="*")this.allListeners=this.allListeners.filter(n=>n!==r);else{const o=this.listeners[e].filter(i=>i!==r);this.listeners={...this.listeners,[e]:o}}}emit(e,r){this.eventsSdkClass.socketIoClass.lastEventTimestamp=new Date().getTime(),this.listeners[e].forEach(o=>o({name:e,data:r}));const n={name:e,data:r};this.allListeners.forEach(o=>o(n))}}class Vo{constructor(e){H(this,"options");H(this,"servers",[]);H(this,"URLList",[]);H(this,"server");H(this,"URL");H(this,"socket");H(this,"mainServer");H(this,"alreadyAttemptedOtherServers",[]);H(this,"authClass",new Fo(this));H(this,"socketIoClass",new Ko(this));H(this,"loggerClass",new Ho(this));H(this,"eventEmitterClass",new Jo(this));H(this,"getCircularReplacer",()=>{const e=new WeakSet;return(r,n)=>{if(!(r==="socket"||r==="io"||r==="nsps")){if(typeof n=="object"&&n!==null){if(e.has(n))return;e.add(n)}return n}}});this.options={...jo,...e}}on(e,r){this.eventEmitterClass.on(e,r)}emit(e,...r){this.socketIoClass.io&&this.socketIoClass.io.emit(e,...r)}connect(e){e===Ct.MAIN&&this.findMainServer(),e===Ct.NEXT&&this.findNextServer(),this.socketIoClass.doReconnect=!0;try{this.loggerClass.init()}catch(r){console.error(r)}this.socketIoClass.initSocketConnection(),this.socketIoClass.initSocketEvents(),this.socketIoClass.initKeepAlive()}disconnect(){this.socketIoClass.doReconnect=!1,this.socketIoClass.closeAllConnections(),this.loggerClass.stop()}clearKeepAliveInterval(){this.socketIoClass.clearKeepAliveInterval()}findMainServer(){this.servers.length?(this.mainServer=this.servers.reduce((e,r)=>r.Priority>e.Priority?r:e),this.server=this.mainServer):this.URLList.length&&(this.URL=this.URLList[0])}findNextServer(){if(this.servers.length&&this.server)if(this.server.Priority===this.mainServer.Priority){let e=this.servers.filter(r=>r.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(r.Priority)+1===0);e.length||(this.alreadyAttemptedOtherServers=[],e=this.servers.filter(r=>r.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(r.Priority)+1===0)),e.length&&(this.server=e.reduce((r,n)=>n.Priority>r.Priority?n:r),this.alreadyAttemptedOtherServers.push(this.server.Priority))}else this.server=this.mainServer;else if(this.URLList.length)if(this.URL===this.URLList[0]){let e=this.URLList.filter(r=>r!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(r)+1===0);e.length||(this.alreadyAttemptedOtherServers=[],e=this.URLList.filter(r=>r!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(r)+1===0)),e.length&&(this.URL=e[0],this.alreadyAttemptedOtherServers.push(this.URL))}else this.URL=this.URLList[0]}async init(){const e=await this.authClass.login();return e&&this.authClass.onLoginResponse(e),this.loggerClass.sdkInitializedLog(),!0}getCurrentMonitorServer(){return this.server}}return $.CallStatusEnum=xr,$.CallTypeEnum=Rr,$.ConnectionStatusEnum=kt,$.DialerTypeEnum=Ir,$.DirectionEnum=_r,$.DoNotCallMeStatusCodeEnum=Br,$.EventsEnum=z,$.ExtensionEventReasonEnum=Te,$.ExtensionHangupCauseEnum=Lr,$.LoginType=st,$.QueueEventReasonEnum=Ur,$.ServerListenerEventsEnum=Oe,$.default=Vo,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),$}({},ws);
8
20
  //# sourceMappingURL=voicenter-events-sdk.iife.js.map