@voicenter-team/events-sdk 0.0.114 → 0.0.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/voicenter-events-sdk.cjs.js +12 -12
- package/dist/voicenter-events-sdk.cjs.js.map +1 -1
- package/dist/voicenter-events-sdk.es.js +735 -664
- package/dist/voicenter-events-sdk.es.js.map +1 -1
- package/dist/voicenter-events-sdk.iife.js +8 -8
- package/dist/voicenter-events-sdk.iife.js.map +1 -1
- package/dist/voicenter-events-sdk.umd.js +8 -8
- package/dist/voicenter-events-sdk.umd.js.map +1 -1
- package/package.json +2 -3
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";var De=Object.defineProperty;var
|
|
1
|
+
"use strict";var De=Object.defineProperty;var Ve=(a,t,e)=>t in a?De(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var X=(a,t,e)=>(Ve(a,typeof t!="symbol"?t+"":t,e),e);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const je=require("ws"),M=require("@voicenter-team/socketio-storage-logger");function Pe(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var be={exports:{}},we={exports:{}};(function(){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(e,r){return e<<r|e>>>32-r},rotr:function(e,r){return e<<32-r|e>>>r},endian:function(e){if(e.constructor==Number)return t.rotl(e,8)&16711935|t.rotl(e,24)&4278255360;for(var r=0;r<e.length;r++)e[r]=t.endian(e[r]);return e},randomBytes:function(e){for(var r=[];e>0;e--)r.push(Math.floor(Math.random()*256));return r},bytesToWords:function(e){for(var r=[],o=0,c=0;o<e.length;o++,c+=8)r[c>>>5]|=e[o]<<24-c%32;return r},wordsToBytes:function(e){for(var r=[],o=0;o<e.length*32;o+=8)r.push(e[o>>>5]>>>24-o%32&255);return r},bytesToHex:function(e){for(var r=[],o=0;o<e.length;o++)r.push((e[o]>>>4).toString(16)),r.push((e[o]&15).toString(16));return r.join("")},hexToBytes:function(e){for(var r=[],o=0;o<e.length;o+=2)r.push(parseInt(e.substr(o,2),16));return r},bytesToBase64:function(e){for(var r=[],o=0;o<e.length;o+=3)for(var c=e[o]<<16|e[o+1]<<8|e[o+2],f=0;f<4;f++)o*8+f*6<=e.length*8?r.push(a.charAt(c>>>6*(3-f)&63)):r.push("=");return r.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/ig,"");for(var r=[],o=0,c=0;o<e.length;c=++o%4)c!=0&&r.push((a.indexOf(e.charAt(o-1))&Math.pow(2,-2*c+8)-1)<<c*2|a.indexOf(e.charAt(o))>>>6-c*2);return r}};we.exports=t})();var Fe=we.exports,ye={utf8:{stringToBytes:function(a){return ye.bin.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(ye.bin.bytesToString(a)))}},bin:{stringToBytes:function(a){for(var t=[],e=0;e<a.length;e++)t.push(a.charCodeAt(e)&255);return t},bytesToString:function(a){for(var t=[],e=0;e<a.length;e++)t.push(String.fromCharCode(a[e]));return t.join("")}}},Te=ye;/*!
|
|
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 Me=function(a){return a!=null&&(Ae(a)||qe(a)||!!a._isBuffer)};function Ae(a){return!!a.constructor&&typeof a.constructor.isBuffer=="function"&&a.constructor.isBuffer(a)}function qe(a){return typeof a.readFloatLE=="function"&&typeof a.slice=="function"&&Ae(a.slice(0,0))}(function(){var a=Ve,t=Te.utf8,e=Me,r=Te.bin,o=function(h,f){h.constructor==String?f&&f.encoding==="binary"?h=r.stringToBytes(h):h=t.stringToBytes(h):e(h)?h=Array.prototype.slice.call(h,0):!Array.isArray(h)&&h.constructor!==Uint8Array&&(h=h.toString());for(var l=a.bytesToWords(h),d=h.length*8,i=1732584193,u=-271733879,c=-1732584194,s=271733878,n=0;n<l.length;n++)l[n]=(l[n]<<8|l[n]>>>24)&16711935|(l[n]<<24|l[n]>>>8)&4278255360;l[d>>>5]|=128<<d%32,l[(d+64>>>9<<4)+14]=d;for(var p=o._ff,g=o._gg,y=o._hh,w=o._ii,n=0;n<l.length;n+=16){var j=i,x=u,V=c,I=s;i=p(i,u,c,s,l[n+0],7,-680876936),s=p(s,i,u,c,l[n+1],12,-389564586),c=p(c,s,i,u,l[n+2],17,606105819),u=p(u,c,s,i,l[n+3],22,-1044525330),i=p(i,u,c,s,l[n+4],7,-176418897),s=p(s,i,u,c,l[n+5],12,1200080426),c=p(c,s,i,u,l[n+6],17,-1473231341),u=p(u,c,s,i,l[n+7],22,-45705983),i=p(i,u,c,s,l[n+8],7,1770035416),s=p(s,i,u,c,l[n+9],12,-1958414417),c=p(c,s,i,u,l[n+10],17,-42063),u=p(u,c,s,i,l[n+11],22,-1990404162),i=p(i,u,c,s,l[n+12],7,1804603682),s=p(s,i,u,c,l[n+13],12,-40341101),c=p(c,s,i,u,l[n+14],17,-1502002290),u=p(u,c,s,i,l[n+15],22,1236535329),i=g(i,u,c,s,l[n+1],5,-165796510),s=g(s,i,u,c,l[n+6],9,-1069501632),c=g(c,s,i,u,l[n+11],14,643717713),u=g(u,c,s,i,l[n+0],20,-373897302),i=g(i,u,c,s,l[n+5],5,-701558691),s=g(s,i,u,c,l[n+10],9,38016083),c=g(c,s,i,u,l[n+15],14,-660478335),u=g(u,c,s,i,l[n+4],20,-405537848),i=g(i,u,c,s,l[n+9],5,568446438),s=g(s,i,u,c,l[n+14],9,-1019803690),c=g(c,s,i,u,l[n+3],14,-187363961),u=g(u,c,s,i,l[n+8],20,1163531501),i=g(i,u,c,s,l[n+13],5,-1444681467),s=g(s,i,u,c,l[n+2],9,-51403784),c=g(c,s,i,u,l[n+7],14,1735328473),u=g(u,c,s,i,l[n+12],20,-1926607734),i=y(i,u,c,s,l[n+5],4,-378558),s=y(s,i,u,c,l[n+8],11,-2022574463),c=y(c,s,i,u,l[n+11],16,1839030562),u=y(u,c,s,i,l[n+14],23,-35309556),i=y(i,u,c,s,l[n+1],4,-1530992060),s=y(s,i,u,c,l[n+4],11,1272893353),c=y(c,s,i,u,l[n+7],16,-155497632),u=y(u,c,s,i,l[n+10],23,-1094730640),i=y(i,u,c,s,l[n+13],4,681279174),s=y(s,i,u,c,l[n+0],11,-358537222),c=y(c,s,i,u,l[n+3],16,-722521979),u=y(u,c,s,i,l[n+6],23,76029189),i=y(i,u,c,s,l[n+9],4,-640364487),s=y(s,i,u,c,l[n+12],11,-421815835),c=y(c,s,i,u,l[n+15],16,530742520),u=y(u,c,s,i,l[n+2],23,-995338651),i=w(i,u,c,s,l[n+0],6,-198630844),s=w(s,i,u,c,l[n+7],10,1126891415),c=w(c,s,i,u,l[n+14],15,-1416354905),u=w(u,c,s,i,l[n+5],21,-57434055),i=w(i,u,c,s,l[n+12],6,1700485571),s=w(s,i,u,c,l[n+3],10,-1894986606),c=w(c,s,i,u,l[n+10],15,-1051523),u=w(u,c,s,i,l[n+1],21,-2054922799),i=w(i,u,c,s,l[n+8],6,1873313359),s=w(s,i,u,c,l[n+15],10,-30611744),c=w(c,s,i,u,l[n+6],15,-1560198380),u=w(u,c,s,i,l[n+13],21,1309151649),i=w(i,u,c,s,l[n+4],6,-145523070),s=w(s,i,u,c,l[n+11],10,-1120210379),c=w(c,s,i,u,l[n+2],15,718787259),u=w(u,c,s,i,l[n+9],21,-343485551),i=i+j>>>0,u=u+x>>>0,c=c+V>>>0,s=s+I>>>0}return a.endian([i,u,c,s])};o._ff=function(h,f,l,d,i,u,c){var s=h+(f&l|~f&d)+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._gg=function(h,f,l,d,i,u,c){var s=h+(f&d|l&~d)+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._hh=function(h,f,l,d,i,u,c){var s=h+(f^l^d)+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._ii=function(h,f,l,d,i,u,c){var s=h+(l^(f|~d))+(i>>>0)+c;return(s<<u|s>>>32-u)+f},o._blocksize=16,o._digestsize=16,we.exports=function(h,f){if(h==null)throw new Error("Illegal argument "+h);var l=a.wordsToBytes(o(h,f));return f&&f.asBytes?l:f&&f.asString?r.bytesToString(l):a.bytesToHex(l)}})();var Xe=we.exports;const Ke=Fe(Xe);var Z=(a=>(a.BOOTSTRAP="bootstrap",a.DEBUG_EXTENSIONS="debugExtensions",a.DEBUG_QUEUE="debugQueue",a.DEBUG_DIALER="debugDialer",a.FULL="full",a))(Z||{}),ee=(a=>(a.MAIN="main",a.NEXT="next",a))(ee||{}),Y=(a=>(a.USER="User",a.TOKEN="Token",a))(Y||{});class oe{static async getSessionStorageDataByKey(t,e=!0){if(typeof chrome<"u"&&typeof chrome.storage<"u"){const r=await chrome.storage.session.get(t);if(r[t])return e?JSON.parse(r[t]):r[t]}if(typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.getItem=="function"){const r=window.sessionStorage.getItem(t);if(r)return e?JSON.parse(r):r}}static async updateSessionStorageKey(t,e){typeof chrome<"u"&&typeof chrome.storage<"u"&&await chrome.storage.session.set({[t]:JSON.stringify(e)}),typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.setItem=="function"&&window.sessionStorage.setItem(t,JSON.stringify(e))}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()}}class $e{constructor(t){X(this,"delay",1e3);X(this,"lastLoginTimestamp");X(this,"token");X(this,"refreshToken");X(this,"tokenExpiry");X(this,"storageKey");this.eventsSdkClass=t,this.eventsSdkClass=t,this.storageKey=""}async login(){const t={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=Ke(JSON.stringify({...this.eventsSdkClass.options,loggerSocketConnection:null},this.eventsSdkClass.getCircularReplacer())),this.lastLoginTimestamp&&this.lastLoginTimestamp+this.delay>new Date().getTime())return;this.updateLastLoginTimestamp();const e=await this.checkLoginStatus(this.storageKey);return e||(oe.clearSessionStorage(),await this.userLoginFunction(t,this.storageKey,this.eventsSdkClass.options.loginType))}updateLastLoginTimestamp(){this.lastLoginTimestamp=new Date().getTime()}async checkLoginStatus(t){const e=await oe.getSessionStorageDataByKey(t);if(e)return e}async userLoginFunction(t,e,r){let o,h,f;return this.eventsSdkClass.options.isNewStack?(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,r),h=await this.getSettings(o.Data.AccessToken),f={...o.Data,...h}):(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,r),f={...o.Data.Socket}),await oe.updateSessionStorageKey(e,f),f}onLoginResponse(t){if(!this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),t.MonitorList&&t.MonitorList.length&&!this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...t.MonitorList],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length&&t.URLList&&(this.eventsSdkClass.URLList=t.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=${t.Version}`),t.IdentityCode&&(this.token=t.IdentityCode,this.eventsSdkClass.connect(ee.MAIN)),t.Token&&(this.token=t.Token,this.eventsSdkClass.connect(ee.MAIN)),t.RefreshToken&&t.IdentityCodeExpiry&&this.eventsSdkClass.options.loginType===Y.USER&&(this.refreshToken=t.RefreshToken,this.tokenExpiry=t.IdentityCodeExpiry,this.handleTokenExpiry()),t.RefreshToken&&t.TokenExpiry&&this.normalizeLoginType(this.eventsSdkClass.options.loginType)===Y.USER&&(this.refreshToken=t.RefreshToken,this.tokenExpiry=t.TokenExpiry,this.handleTokenExpiry())}handleTokenExpiry(){if(!this.eventsSdkClass.options.refreshTokenUrl)throw new Error("refreshTokenUrl not provided");let t;if(this.tokenExpiry)t=new Date(this.tokenExpiry);else return;const e=t.getTime()-new Date().getTime()-5e3,r=Math.min(e,2147483647);setTimeout(async()=>{if(this.refreshToken){this.eventsSdkClass.socketIoClass.closeAllConnections();let o,h;if(this.eventsSdkClass.options.isNewStack){const f=await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken);o=await this.getSettings(f.Data.AccessToken),h={...f.Data,...o}}else h={...(await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken)).Data.Socket};this.onLoginResponse(h),await oe.updateSessionStorageKey(this.storageKey,h)}},r)}async externalLogin(t,{password:e,token:r,email:o},h){if(!t)throw new Error("loginUrl not provided");let f;this.eventsSdkClass.options.isNewStack?h===Y.TOKEN?f=JSON.stringify({identityType:Y.TOKEN,token:r}):f=JSON.stringify({identityType:Y.USER,username:o,password:e}):this.eventsSdkClass.options.loginType===Y.TOKEN?(f=JSON.stringify({token:r}),t=`${t}/${Y.TOKEN}`):(f=JSON.stringify({email:o,pin:e}),t=`${t}/${Y.USER}`);let l;try{const d=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:f});if(!d.ok&&d.status===400)throw l=400,new Error("Bad body request. Login type or isNewStack values not correct or not provided");if(!d.ok&&d.status===401)throw l=401,new Error("Unauthorized. Invalid token provided");if(!d.ok&&d.status===403)throw l=403,new Error("Forbidden. Identity token not provided or not valid");const i=await d.json();if(i.error)throw new Error(i.error);return i}catch(d){throw this.eventsSdkClass.loggerClass.loginError(h,l,r,o),d}}async getSettings(t){try{if(!this.eventsSdkClass.options.getSettingsUrl)throw new Error("getSettingsUrl not provided");const e=await fetch(this.eventsSdkClass.options.getSettingsUrl,{headers:{Authorization:`Bearer ${t}`}});if(!e.ok&&e.status===401)throw new Error("Unauthorized. Access token not provided or not valid");return e.json()}catch(e){throw this.eventsSdkClass.loggerClass.getSettingsError(t,e),e}}async externalRefreshToken(t,e){try{return(await fetch(t,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}})).json()}catch(r){throw this.eventsSdkClass.loggerClass.refreshTokenError(e,t,r),r}}normalizeLoginType(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}}const Le={isNewStack:!1,loginUrl:"https://loginapi.voicenter.co.il/monitorAPI/Login",refreshTokenUrl:"https://loginapi.voicenter.co.il/monitorAPI/RefreshIdentityToken",forceNew:!0,reconnectionDelay:5,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:!1,reconnectionDelay:5e3,reconnectionAttempts:10,perMessageDeflate:void 0,upgrade:!1,transports:["websocket"],debug:!1}};function Ge(){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=je,typeof self.navigator>"u"&&(self.navigator={userAgent:"node"})),function a(t,e,r){function o(l,d){if(!e[l]){if(!t[l]){var i=typeof require=="function"&&require;if(!d&&i)return i(l,!0);if(h)return h(l,!0);throw new Error("Cannot find module '"+l+"'")}var u=e[l]={exports:{}};t[l][0].call(u.exports,function(c){var s=t[l][1][c];return o(s||c)},u,u.exports,a,t,e,r)}return e[l].exports}for(var h=typeof require=="function"&&require,f=0;f<r.length;f++)o(r[f]);return o}({1:[function(a,t){t.exports=a("./lib/")},{"./lib/":2}],2:[function(a,t,e){function r(i,u){typeof i=="object"&&(u=i,i=void 0),u=u||{};var c,s=o(i),n=s.source,p=s.id;return u.forceNew||u["force new connection"]||u.multiplex===!1?(l("ignoring socket cache for %s",n),c=f(n,u)):(d[p]||(l("new io instance for %s",n),d[p]=f(n,u)),c=d[p]),c.socket(s.path)}var o=a("./url"),h=a("socket.io-parser"),f=a("./manager"),l=a("debug")("socket.io-client");t.exports=e=r;var d=e.managers={};e.protocol=h.protocol,e.connect=r,e.Manager=a("./manager"),e.Socket=a("./socket")},{"./manager":3,"./socket":5,"./url":6,debug:10,"socket.io-parser":44}],3:[function(a,t){function e(s,n){return this instanceof e?(s&&typeof s=="object"&&(n=s,s=void 0),n=n||{},n.path=n.path||"/socket.io",this.nsps={},this.subs=[],this.opts=n,this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor(n.randomizationFactor||.5),this.backoff=new c({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this.readyState="closed",this.uri=s,this.connected=[],this.encoding=!1,this.packetBuffer=[],this.encoder=new f.Encoder,this.decoder=new f.Decoder,this.autoConnect=n.autoConnect!==!1,void(this.autoConnect&&this.open())):new e(s,n)}var r=(a("./url"),a("engine.io-client")),o=a("./socket"),h=a("component-emitter"),f=a("socket.io-parser"),l=a("./on"),d=a("component-bind"),i=(a("object-component"),a("debug")("socket.io-client:manager")),u=a("indexof"),c=a("backo2");t.exports=e,e.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var s in this.nsps)this.nsps[s].emit.apply(this.nsps[s],arguments)},e.prototype.updateSocketIds=function(){for(var s in this.nsps)this.nsps[s].id=this.engine.id},h(e.prototype),e.prototype.reconnection=function(s){return arguments.length?(this._reconnection=!!s,this):this._reconnection},e.prototype.reconnectionAttempts=function(s){return arguments.length?(this._reconnectionAttempts=s,this):this._reconnectionAttempts},e.prototype.reconnectionDelay=function(s){return arguments.length?(this._reconnectionDelay=s,this.backoff&&this.backoff.setMin(s),this):this._reconnectionDelay},e.prototype.randomizationFactor=function(s){return arguments.length?(this._randomizationFactor=s,this.backoff&&this.backoff.setJitter(s),this):this._randomizationFactor},e.prototype.reconnectionDelayMax=function(s){return arguments.length?(this._reconnectionDelayMax=s,this.backoff&&this.backoff.setMax(s),this):this._reconnectionDelayMax},e.prototype.timeout=function(s){return arguments.length?(this._timeout=s,this):this._timeout},e.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()},e.prototype.open=e.prototype.connect=function(s){if(i("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;i("opening %s",this.uri),this.engine=r(this.uri,this.opts);var n=this.engine,p=this;this.readyState="opening",this.skipReconnect=!1;var g=l(n,"open",function(){p.onopen(),s&&s()}),y=l(n,"error",function(x){if(i("connect_error"),p.cleanup(),p.readyState="closed",p.emitAll("connect_error",x),s){var V=new Error("Connection error");V.data=x,s(V)}else p.maybeReconnectOnOpen()});if(this._timeout!==!1){var w=this._timeout;i("connect attempt will timeout after %d",w);var j=setTimeout(function(){i("connect attempt timed out after %d",w),g.destroy(),n.close(),n.emit("error","timeout"),p.emitAll("connect_timeout",w)},w);this.subs.push({destroy:function(){clearTimeout(j)}})}return this.subs.push(g),this.subs.push(y),this},e.prototype.onopen=function(){i("open"),this.cleanup(),this.readyState="open",this.emit("open");var s=this.engine;this.subs.push(l(s,"data",d(this,"ondata"))),this.subs.push(l(this.decoder,"decoded",d(this,"ondecoded"))),this.subs.push(l(s,"error",d(this,"onerror"))),this.subs.push(l(s,"close",d(this,"onclose")))},e.prototype.ondata=function(s){this.decoder.add(s)},e.prototype.ondecoded=function(s){this.emit("packet",s)},e.prototype.onerror=function(s){i("error",s),this.emitAll("error",s)},e.prototype.socket=function(s){var n=this.nsps[s];if(!n){n=new o(this,s),this.nsps[s]=n;var p=this;n.on("connect",function(){n.id=p.engine.id,~u(p.connected,n)||p.connected.push(n)})}return n},e.prototype.destroy=function(s){var n=u(this.connected,s);~n&&this.connected.splice(n,1),this.connected.length||this.close()},e.prototype.packet=function(s){i("writing packet %j",s);var n=this;n.encoding?n.packetBuffer.push(s):(n.encoding=!0,this.encoder.encode(s,function(p){for(var g=0;g<p.length;g++)n.engine.write(p[g]);n.encoding=!1,n.processPacketQueue()}))},e.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var s=this.packetBuffer.shift();this.packet(s)}},e.prototype.cleanup=function(){for(var s;s=this.subs.shift();)s.destroy();this.packetBuffer=[],this.encoding=!1,this.decoder.destroy()},e.prototype.close=e.prototype.disconnect=function(){this.skipReconnect=!0,this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},e.prototype.onclose=function(s){i("close"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",s),this._reconnection&&!this.skipReconnect&&this.reconnect()},e.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var s=this;if(this.backoff.attempts>=this._reconnectionAttempts)i("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var n=this.backoff.duration();i("will wait %dms before reconnect attempt",n),this.reconnecting=!0;var p=setTimeout(function(){s.skipReconnect||(i("attempting reconnect"),s.emitAll("reconnect_attempt",s.backoff.attempts),s.emitAll("reconnecting",s.backoff.attempts),s.skipReconnect||s.open(function(g){g?(i("reconnect attempt error"),s.reconnecting=!1,s.reconnect(),s.emitAll("reconnect_error",g.data)):(i("reconnect success"),s.onreconnect())}))},n);this.subs.push({destroy:function(){clearTimeout(p)}})}},e.prototype.onreconnect=function(){var s=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",s)}},{"./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(a,t){function e(r,o,h){return r.on(o,h),{destroy:function(){r.removeListener(o,h)}}}t.exports=e},{}],5:[function(a,t,e){function r(n,p){this.io=n,this.nsp=p,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=a("socket.io-parser"),h=a("component-emitter"),f=a("to-array"),l=a("./on"),d=a("component-bind"),i=a("debug")("socket.io-client:socket"),u=a("has-binary");t.exports=r;var c={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},s=h.prototype.emit;h(r.prototype),r.prototype.subEvents=function(){if(!this.subs){var n=this.io;this.subs=[l(n,"open",d(this,"onopen")),l(n,"packet",d(this,"onpacket")),l(n,"close",d(this,"onclose"))]}},r.prototype.open=r.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),this.io.readyState=="open"&&this.onopen(),this)},r.prototype.send=function(){var n=f(arguments);return n.unshift("message"),this.emit.apply(this,n),this},r.prototype.emit=function(n){if(c.hasOwnProperty(n))return s.apply(this,arguments),this;var p=f(arguments),g=o.EVENT;u(p)&&(g=o.BINARY_EVENT);var y={type:g,data:p};return typeof p[p.length-1]=="function"&&(i("emitting packet with ack id %d",this.ids),this.acks[this.ids]=p.pop(),y.id=this.ids++),this.connected?this.packet(y):this.sendBuffer.push(y),this},r.prototype.packet=function(n){n.nsp=this.nsp,this.io.packet(n)},r.prototype.onopen=function(){i("transport is open - connecting"),this.nsp!="/"&&this.packet({type:o.CONNECT})},r.prototype.onclose=function(n){i("close (%s)",n),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",n)},r.prototype.onpacket=function(n){if(n.nsp==this.nsp)switch(n.type){case o.CONNECT:this.onconnect();break;case o.EVENT:this.onevent(n);break;case o.BINARY_EVENT:this.onevent(n);break;case o.ACK:this.onack(n);break;case o.BINARY_ACK:this.onack(n);break;case o.DISCONNECT:this.ondisconnect();break;case o.ERROR:this.emit("error",n.data)}},r.prototype.onevent=function(n){var p=n.data||[];i("emitting event %j",p),n.id!=null&&(i("attaching ack callback to event"),p.push(this.ack(n.id))),this.connected?s.apply(this,p):this.receiveBuffer.push(p)},r.prototype.ack=function(n){var p=this,g=!1;return function(){if(!g){g=!0;var y=f(arguments);i("sending ack %j",y);var w=u(y)?o.BINARY_ACK:o.ACK;p.packet({type:w,id:n,data:y})}}},r.prototype.onack=function(n){i("calling ack %s with %j",n.id,n.data);var p=this.acks[n.id];p.apply(this,n.data),delete this.acks[n.id]},r.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},r.prototype.emitBuffered=function(){var n;for(n=0;n<this.receiveBuffer.length;n++)s.apply(this,this.receiveBuffer[n]);for(this.receiveBuffer=[],n=0;n<this.sendBuffer.length;n++)this.packet(this.sendBuffer[n]);this.sendBuffer=[]},r.prototype.ondisconnect=function(){i("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},r.prototype.destroy=function(){if(this.subs){for(var n=0;n<this.subs.length;n++)this.subs[n].destroy();this.subs=null}this.io.destroy(this)},r.prototype.close=r.prototype.disconnect=function(){return this.connected&&(i("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(a,t){(function(e){function r(f,i){var d=f,i=i||e.location;return f==null&&(f=i.protocol+"//"+i.host),typeof f=="string"&&(f.charAt(0)=="/"&&(f=f.charAt(1)=="/"?i.protocol+f:i.hostname+f),/^(https?|wss?):\/\//.test(f)||(h("protocol-less url %s",f),f=typeof i<"u"?i.protocol+"//"+f:"https://"+f),h("parse %s",f),d=o(f)),d.port||(/^(http|ws)$/.test(d.protocol)?d.port="80":/^(http|ws)s$/.test(d.protocol)&&(d.port="443")),d.path=d.path||"/",d.id=d.protocol+"://"+d.host+":"+d.port,d.href=d.protocol+"://"+d.host+(i&&i.port==d.port?"":":"+d.port),d}var o=a("parseuri"),h=a("debug")("socket.io-client:url");t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{debug:10,parseuri:42}],7:[function(a,t){function e(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}t.exports=e,e.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var o=Math.random(),h=Math.floor(o*this.jitter*r);r=1&Math.floor(10*o)?r+h:r-h}return 0|Math.min(r,this.max)},e.prototype.reset=function(){this.attempts=0},e.prototype.setMin=function(r){this.ms=r},e.prototype.setMax=function(r){this.max=r},e.prototype.setJitter=function(r){this.jitter=r}},{}],8:[function(a,t){var e=[].slice;t.exports=function(r,o){if(typeof o=="string"&&(o=r[o]),typeof o!="function")throw new Error("bind() requires a function");var h=e.call(arguments,2);return function(){return o.apply(r,h.concat(e.call(arguments)))}}},{}],9:[function(a,t){function e(o){return o?r(o):void 0}function r(o){for(var h in e.prototype)o[h]=e.prototype[h];return o}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(o,h){return this._callbacks=this._callbacks||{},(this._callbacks[o]=this._callbacks[o]||[]).push(h),this},e.prototype.once=function(o,h){function f(){l.off(o,f),h.apply(this,arguments)}var l=this;return this._callbacks=this._callbacks||{},f.fn=h,this.on(o,f),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(o,h){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var f=this._callbacks[o];if(!f)return this;if(arguments.length==1)return delete this._callbacks[o],this;for(var l,d=0;d<f.length;d++)if(l=f[d],l===h||l.fn===h){f.splice(d,1);break}return this},e.prototype.emit=function(o){this._callbacks=this._callbacks||{};var h=[].slice.call(arguments,1),f=this._callbacks[o];if(f){f=f.slice(0);for(var l=0,d=f.length;d>l;++l)f[l].apply(this,h)}return this},e.prototype.listeners=function(o){return this._callbacks=this._callbacks||{},this._callbacks[o]||[]},e.prototype.hasListeners=function(o){return!!this.listeners(o).length}},{}],10:[function(a,t){function e(o){return e.enabled(o)?function(h){h=r(h);var f=new Date,l=f-(e[o]||f);e[o]=f,h=o+" "+h+" +"+e.humanize(l),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}function r(o){return o instanceof Error?o.stack||o.message:o}t.exports=e,e.names=[],e.skips=[],e.enable=function(o){try{localStorage.debug=o}catch{}for(var h=(o||"").split(/[\s,]+/),f=h.length,l=0;f>l;l++)o=h[l].replace("*",".*?"),o[0]==="-"?e.skips.push(new RegExp("^"+o.substr(1)+"$")):e.names.push(new RegExp("^"+o+"$"))},e.disable=function(){e.enable("")},e.humanize=function(o){var h=1e3,f=6e4,l=60*f;return o>=l?(o/l).toFixed(1)+"h":o>=f?(o/f).toFixed(1)+"m":o>=h?(o/h|0)+"s":o+"ms"},e.enabled=function(o){for(var h=0,f=e.skips.length;f>h;h++)if(e.skips[h].test(o))return!1;for(var h=0,f=e.names.length;f>h;h++)if(e.names[h].test(o))return!0;return!1};try{window.localStorage&&e.enable(localStorage.debug)}catch{}},{}],11:[function(a,t){t.exports=a("./lib/")},{"./lib/":12}],12:[function(a,t){t.exports=a("./socket"),t.exports.parser=a("engine.io-parser")},{"./socket":13,"engine.io-parser":25}],13:[function(a,t){(function(e){function r(n,p){if(!(this instanceof r))return new r(n,p);if(p=p||{},n&&typeof n=="object"&&(p=n,n=null),n&&(n=u(n),p.host=n.host,p.secure=n.protocol=="https"||n.protocol=="wss",p.port=n.port,n.query&&(p.query=n.query)),this.secure=p.secure!=null?p.secure:e.location&&location.protocol=="https:",p.host){var g=p.host.split(":");p.hostname=g.shift(),g.length?p.port=g.pop():p.port||(p.port=this.secure?"443":"80")}this.agent=p.agent||!1,this.hostname=p.hostname||(e.location?location.hostname:"localhost"),this.port=p.port||(e.location&&location.port?location.port:this.secure?443:80),this.query=p.query||{},typeof this.query=="string"&&(this.query=s.decode(this.query)),this.upgrade=p.upgrade!==!1,this.path=(p.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!p.forceJSONP,this.jsonp=p.jsonp!==!1,this.forceBase64=!!p.forceBase64,this.enablesXDR=!!p.enablesXDR,this.timestampParam=p.timestampParam||"t",this.timestampRequests=p.timestampRequests,this.transports=p.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.callbackBuffer=[],this.policyPort=p.policyPort||843,this.rememberUpgrade=p.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=p.onlyBinaryUpgrades,this.pfx=p.pfx||null,this.key=p.key||null,this.passphrase=p.passphrase||null,this.cert=p.cert||null,this.ca=p.ca||null,this.ciphers=p.ciphers||null,this.rejectUnauthorized=p.rejectUnauthorized||null,this.open()}function o(n){var p={};for(var g in n)n.hasOwnProperty(g)&&(p[g]=n[g]);return p}var h=a("./transports"),f=a("component-emitter"),l=a("debug")("engine.io-client:socket"),d=a("indexof"),i=a("engine.io-parser"),u=a("parseuri"),c=a("parsejson"),s=a("parseqs");t.exports=r,r.priorWebsocketSuccess=!1,f(r.prototype),r.protocol=i.protocol,r.Socket=r,r.Transport=a("./transport"),r.transports=a("./transports"),r.parser=a("engine.io-parser"),r.prototype.createTransport=function(n){l('creating transport "%s"',n);var p=o(this.query);p.EIO=i.protocol,p.transport=n,this.id&&(p.sid=this.id);var g=new h[n]({agent:this.agent,hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:p,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 g},r.prototype.open=function(){var p;if(this.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!=-1)p="websocket";else{if(this.transports.length==0){var n=this;return void setTimeout(function(){n.emit("error","No transports available")},0)}p=this.transports[0]}this.readyState="opening";var p;try{p=this.createTransport(p)}catch{return this.transports.shift(),void this.open()}p.open(),this.setTransport(p)},r.prototype.setTransport=function(n){l("setting transport %s",n.name);var p=this;this.transport&&(l("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=n,n.on("drain",function(){p.onDrain()}).on("packet",function(g){p.onPacket(g)}).on("error",function(g){p.onError(g)}).on("close",function(){p.onClose("transport close")})},r.prototype.probe=function(n){function p(){if(b.onlyBinaryUpgrades){var A=!this.supportsBinary&&b.transport.supportsBinary;k=k||A}k||(l('probe transport "%s" opened',n),I.send([{type:"ping",data:"probe"}]),I.once("packet",function(v){if(!k)if(v.type=="pong"&&v.data=="probe"){if(l('probe transport "%s" pong',n),b.upgrading=!0,b.emit("upgrading",I),!I)return;r.priorWebsocketSuccess=I.name=="websocket",l('pausing current transport "%s"',b.transport.name),b.transport.pause(function(){k||b.readyState!="closed"&&(l("changing transport and sending upgrade packet"),V(),b.setTransport(I),I.send([{type:"upgrade"}]),b.emit("upgrade",I),I=null,b.upgrading=!1,b.flush())})}else{l('probe transport "%s" failed',n);var m=new Error("probe error");m.transport=I.name,b.emit("upgradeError",m)}}))}function g(){k||(k=!0,V(),I.close(),I=null)}function y(A){var v=new Error("probe error: "+A);v.transport=I.name,g(),l('probe transport "%s" failed because of error: %s',n,A),b.emit("upgradeError",v)}function w(){y("transport closed")}function j(){y("socket closed")}function x(A){I&&A.name!=I.name&&(l('"%s" works - aborting "%s"',A.name,I.name),g())}function V(){I.removeListener("open",p),I.removeListener("error",y),I.removeListener("close",w),b.removeListener("close",j),b.removeListener("upgrading",x)}l('probing transport "%s"',n);var I=this.createTransport(n,{probe:1}),k=!1,b=this;r.priorWebsocketSuccess=!1,I.once("open",p),I.once("error",y),I.once("close",w),this.once("close",j),this.once("upgrading",x),I.open()},r.prototype.onOpen=function(){if(l("socket open"),this.readyState="open",r.priorWebsocketSuccess=this.transport.name=="websocket",this.emit("open"),this.flush(),this.readyState=="open"&&this.upgrade&&this.transport.pause){l("starting upgrade probes");for(var n=0,p=this.upgrades.length;p>n;n++)this.probe(this.upgrades[n])}},r.prototype.onPacket=function(n){if(this.readyState=="opening"||this.readyState=="open")switch(l('socket receive: type "%s", data "%s"',n.type,n.data),this.emit("packet",n),this.emit("heartbeat"),n.type){case"open":this.onHandshake(c(n.data));break;case"pong":this.setPing();break;case"error":var p=new Error("server error");p.code=n.data,this.emit("error",p);break;case"message":this.emit("data",n.data),this.emit("message",n.data)}else l('packet received with socket readyState "%s"',this.readyState)},r.prototype.onHandshake=function(n){this.emit("handshake",n),this.id=n.sid,this.transport.query.sid=n.sid,this.upgrades=this.filterUpgrades(n.upgrades),this.pingInterval=n.pingInterval,this.pingTimeout=n.pingTimeout,this.onOpen(),this.readyState!="closed"&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},r.prototype.onHeartbeat=function(n){clearTimeout(this.pingTimeoutTimer);var p=this;p.pingTimeoutTimer=setTimeout(function(){p.readyState!="closed"&&p.onClose("ping timeout")},n||p.pingInterval+p.pingTimeout)},r.prototype.setPing=function(){var n=this;clearTimeout(n.pingIntervalTimer),n.pingIntervalTimer=setTimeout(function(){l("writing ping packet - expecting pong within %sms",n.pingTimeout),n.ping(),n.onHeartbeat(n.pingTimeout)},n.pingInterval)},r.prototype.ping=function(){this.sendPacket("ping")},r.prototype.onDrain=function(){for(var n=0;n<this.prevBufferLen;n++)this.callbackBuffer[n]&&this.callbackBuffer[n]();this.writeBuffer.splice(0,this.prevBufferLen),this.callbackBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length==0?this.emit("drain"):this.flush()},r.prototype.flush=function(){this.readyState!="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(l("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},r.prototype.write=r.prototype.send=function(n,p){return this.sendPacket("message",n,p),this},r.prototype.sendPacket=function(n,p,g){if(this.readyState!="closing"&&this.readyState!="closed"){var y={type:n,data:p};this.emit("packetCreate",y),this.writeBuffer.push(y),this.callbackBuffer.push(g),this.flush()}},r.prototype.close=function(){function n(){y.onClose("forced close"),l("socket closing - telling transport to close"),y.transport.close()}function p(){y.removeListener("upgrade",p),y.removeListener("upgradeError",p),n()}function g(){y.once("upgrade",p),y.once("upgradeError",p)}if(this.readyState=="opening"||this.readyState=="open"){this.readyState="closing";var y=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?g():n()}):this.upgrading?g():n()}return this},r.prototype.onError=function(n){l("socket error %j",n),r.priorWebsocketSuccess=!1,this.emit("error",n),this.onClose("transport error",n)},r.prototype.onClose=function(n,p){if(this.readyState=="opening"||this.readyState=="open"||this.readyState=="closing"){l('socket close with reason: "%s"',n);var g=this;clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),setTimeout(function(){g.writeBuffer=[],g.callbackBuffer=[],g.prevBufferLen=0},0),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",n,p)}},r.prototype.filterUpgrades=function(n){for(var p=[],g=0,y=n.length;y>g;g++)~d(this.transports,n[g])&&p.push(n[g]);return p}}).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(a,t){function e(h){this.path=h.path,this.hostname=h.hostname,this.port=h.port,this.secure=h.secure,this.query=h.query,this.timestampParam=h.timestampParam,this.timestampRequests=h.timestampRequests,this.readyState="",this.agent=h.agent||!1,this.socket=h.socket,this.enablesXDR=h.enablesXDR,this.pfx=h.pfx,this.key=h.key,this.passphrase=h.passphrase,this.cert=h.cert,this.ca=h.ca,this.ciphers=h.ciphers,this.rejectUnauthorized=h.rejectUnauthorized}var r=a("engine.io-parser"),o=a("component-emitter");t.exports=e,o(e.prototype),e.timestamps=0,e.prototype.onError=function(h,f){var l=new Error(h);return l.type="TransportError",l.description=f,this.emit("error",l),this},e.prototype.open=function(){return(this.readyState=="closed"||this.readyState=="")&&(this.readyState="opening",this.doOpen()),this},e.prototype.close=function(){return(this.readyState=="opening"||this.readyState=="open")&&(this.doClose(),this.onClose()),this},e.prototype.send=function(h){if(this.readyState!="open")throw new Error("Transport not open");this.write(h)},e.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},e.prototype.onData=function(h){var f=r.decodePacket(h,this.socket.binaryType);this.onPacket(f)},e.prototype.onPacket=function(h){this.emit("packet",h)},e.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},{"component-emitter":9,"engine.io-parser":25}],15:[function(a,t,e){(function(r){function o(i){var u,c=!1,s=!1,n=i.jsonp!==!1;if(r.location){var p=location.protocol=="https:",g=location.port;g||(g=p?443:80),c=i.hostname!=location.hostname||g!=i.port,s=i.secure!=p}if(i.xdomain=c,i.xscheme=s,u=new h(i),"open"in u&&!i.forceJSONP)return new f(i);if(!n)throw new Error("JSONP disabled");return new l(i)}var h=a("xmlhttprequest"),f=a("./polling-xhr"),l=a("./polling-jsonp"),d=a("./websocket");e.polling=o,e.websocket=d}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling-jsonp":16,"./polling-xhr":17,"./websocket":19,xmlhttprequest:20}],16:[function(a,t){(function(e){function r(){}function o(u){h.call(this,u),this.query=this.query||{},l||(e.___eio||(e.___eio=[]),l=e.___eio),this.index=l.length;var c=this;l.push(function(s){c.onData(s)}),this.query.j=this.index,e.document&&e.addEventListener&&e.addEventListener("beforeunload",function(){c.script&&(c.script.onerror=r)},!1)}var h=a("./polling"),f=a("component-inherit");t.exports=o;var l,d=/\n/g,i=/\\n/g;f(o,h),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),h.prototype.doClose.call(this)},o.prototype.doPoll=function(){var u=this,c=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),c.async=!0,c.src=this.uri(),c.onerror=function(p){u.onError("jsonp poll error",p)};var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(c,s),this.script=c;var n=typeof navigator<"u"&&/gecko/i.test(navigator.userAgent);n&&setTimeout(function(){var p=document.createElement("iframe");document.body.appendChild(p),document.body.removeChild(p)},100)},o.prototype.doWrite=function(u,c){function s(){n(),c()}function n(){if(p.iframe)try{p.form.removeChild(p.iframe)}catch(V){p.onError("jsonp polling iframe removal error",V)}try{var x='<iframe src="javascript:0" name="'+p.iframeId+'">';g=document.createElement(x)}catch{g=document.createElement("iframe"),g.name=p.iframeId,g.src="javascript:0"}g.id=p.iframeId,p.form.appendChild(g),p.iframe=g}var p=this;if(!this.form){var g,y=document.createElement("form"),w=document.createElement("textarea"),j=this.iframeId="eio_iframe_"+this.index;y.className="socketio",y.style.position="absolute",y.style.top="-1000px",y.style.left="-1000px",y.target=j,y.method="POST",y.setAttribute("accept-charset","utf-8"),w.name="d",y.appendChild(w),document.body.appendChild(y),this.form=y,this.area=w}this.form.action=this.uri(),n(),u=u.replace(i,`\\
|
|
7
|
-
`),this.area.value=u.replace(d,"\\n");try{this.form.submit()}catch{}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){p.iframe.readyState=="complete"&&s()}:this.iframe.onload=s}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-inherit":21}],17:[function(a,t){(function(e){function r(){}function o(s){if(d.call(this,s),e.location){var n=location.protocol=="https:",p=location.port;p||(p=n?443:80),this.xd=s.hostname!=e.location.hostname||p!=s.port,this.xs=s.secure!=n}}function h(s){this.method=s.method||"GET",this.uri=s.uri,this.xd=!!s.xd,this.xs=!!s.xs,this.async=s.async!==!1,this.data=s.data!=null?s.data:null,this.agent=s.agent,this.isBinary=s.isBinary,this.supportsBinary=s.supportsBinary,this.enablesXDR=s.enablesXDR,this.pfx=s.pfx,this.key=s.key,this.passphrase=s.passphrase,this.cert=s.cert,this.ca=s.ca,this.ciphers=s.ciphers,this.rejectUnauthorized=s.rejectUnauthorized,this.create()}function f(){for(var s in h.requests)h.requests.hasOwnProperty(s)&&h.requests[s].abort()}var l=a("xmlhttprequest"),d=a("./polling"),i=a("component-emitter"),u=a("component-inherit"),c=a("debug")("engine.io-client:polling-xhr");t.exports=o,t.exports.Request=h,u(o,d),o.prototype.supportsBinary=!0,o.prototype.request=function(s){return s=s||{},s.uri=this.uri(),s.xd=this.xd,s.xs=this.xs,s.agent=this.agent||!1,s.supportsBinary=this.supportsBinary,s.enablesXDR=this.enablesXDR,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,new h(s)},o.prototype.doWrite=function(s,n){var p=typeof s!="string"&&s!==void 0,g=this.request({method:"POST",data:s,isBinary:p}),y=this;g.on("success",n),g.on("error",function(w){y.onError("xhr post error",w)}),this.sendXhr=g},o.prototype.doPoll=function(){c("xhr poll");var s=this.request(),n=this;s.on("data",function(p){n.onData(p)}),s.on("error",function(p){n.onError("xhr poll error",p)}),this.pollXhr=s},i(h.prototype),h.prototype.create=function(){var s={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};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;var n=this.xhr=new l(s),p=this;try{if(c("xhr open %s: %s",this.method,this.uri),n.open(this.method,this.uri,this.async),this.supportsBinary&&(n.responseType="arraybuffer"),this.method=="POST")try{this.isBinary?n.setRequestHeader("Content-type","application/octet-stream"):n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}"withCredentials"in n&&(n.withCredentials=!0),this.hasXDR()?(n.onload=function(){p.onLoad()},n.onerror=function(){p.onError(n.responseText)}):n.onreadystatechange=function(){n.readyState==4&&(n.status==200||n.status==1223?p.onLoad():setTimeout(function(){p.onError(n.status)},0))},c("xhr data %s",this.data),n.send(this.data)}catch(g){return void setTimeout(function(){p.onError(g)},0)}e.document&&(this.index=h.requestsCount++,h.requests[this.index]=this)},h.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},h.prototype.onData=function(s){this.emit("data",s),this.onSuccess()},h.prototype.onError=function(s){this.emit("error",s),this.cleanup(!0)},h.prototype.cleanup=function(s){if(typeof this.xhr<"u"&&this.xhr!==null){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=r:this.xhr.onreadystatechange=r,s)try{this.xhr.abort()}catch{}e.document&&delete h.requests[this.index],this.xhr=null}},h.prototype.onLoad=function(){var s;try{var n;try{n=this.xhr.getResponseHeader("Content-Type").split(";")[0]}catch{}s=n==="application/octet-stream"?this.xhr.response:this.supportsBinary?"ok":this.xhr.responseText}catch(p){this.onError(p)}s!=null&&this.onData(s)},h.prototype.hasXDR=function(){return typeof e.XDomainRequest<"u"&&!this.xs&&this.enablesXDR},h.prototype.abort=function(){this.cleanup()},e.document&&(h.requestsCount=0,h.requests={},e.attachEvent?e.attachEvent("onunload",f):e.addEventListener&&e.addEventListener("beforeunload",f,!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(a,t){function e(i){var u=i&&i.forceBase64;(!d||u)&&(this.supportsBinary=!1),r.call(this,i)}var r=a("../transport"),o=a("parseqs"),h=a("engine.io-parser"),f=a("component-inherit"),l=a("debug")("engine.io-client:polling");t.exports=e;var d=function(){var i=a("xmlhttprequest"),u=new i({xdomain:!1});return u.responseType!=null}();f(e,r),e.prototype.name="polling",e.prototype.doOpen=function(){this.poll()},e.prototype.pause=function(i){function u(){l("paused"),c.readyState="paused",i()}var c=this;if(this.readyState="pausing",this.polling||!this.writable){var s=0;this.polling&&(l("we are currently polling - waiting to pause"),s++,this.once("pollComplete",function(){l("pre-pause polling complete"),--s||u()})),this.writable||(l("we are currently writing - waiting to pause"),s++,this.once("drain",function(){l("pre-pause writing complete"),--s||u()}))}else u()},e.prototype.poll=function(){l("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},e.prototype.onData=function(i){var u=this;l("polling got data %s",i);var c=function(s){return u.readyState=="opening"&&u.onOpen(),s.type=="close"?(u.onClose(),!1):void u.onPacket(s)};h.decodePayload(i,this.socket.binaryType,c),this.readyState!="closed"&&(this.polling=!1,this.emit("pollComplete"),this.readyState=="open"?this.poll():l('ignoring poll - transport state "%s"',this.readyState))},e.prototype.doClose=function(){function i(){l("writing close packet"),u.write([{type:"close"}])}var u=this;this.readyState=="open"?(l("transport open - closing"),i()):(l("transport not open - deferring close"),this.once("open",i))},e.prototype.write=function(i){var c=this;this.writable=!1;var u=function(){c.writable=!0,c.emit("drain")},c=this;h.encodePayload(i,this.supportsBinary,function(s){c.doWrite(s,u)})},e.prototype.uri=function(){var i=this.query||{},u=this.secure?"https":"http",c="";return this.timestampRequests!==!1&&(i[this.timestampParam]=+new Date+"-"+r.timestamps++),this.supportsBinary||i.sid||(i.b64=1),i=o.encode(i),this.port&&(u=="https"&&this.port!=443||u=="http"&&this.port!=80)&&(c=":"+this.port),i.length&&(i="?"+i),u+"://"+this.hostname+c+this.path+i}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,xmlhttprequest:20}],19:[function(a,t){function e(i){var u=i&&i.forceBase64;u&&(this.supportsBinary=!1),r.call(this,i)}var r=a("../transport"),o=a("engine.io-parser"),h=a("parseqs"),f=a("component-inherit"),l=a("debug")("engine.io-client:websocket"),d=a("ws");t.exports=e,f(e,r),e.prototype.name="websocket",e.prototype.supportsBinary=!0,e.prototype.doOpen=function(){if(this.check()){var i=this.uri(),u=void 0,c={agent:this.agent};c.pfx=this.pfx,c.key=this.key,c.passphrase=this.passphrase,c.cert=this.cert,c.ca=this.ca,c.ciphers=this.ciphers,c.rejectUnauthorized=this.rejectUnauthorized,this.ws=new d(i,u,c),this.ws.binaryType===void 0&&(this.supportsBinary=!1),this.ws.binaryType="arraybuffer",this.addEventListeners()}},e.prototype.addEventListeners=function(){var i=this;this.ws.onopen=function(){i.onOpen()},this.ws.onclose=function(){i.onClose()},this.ws.onmessage=function(u){i.onData(u.data)},this.ws.onerror=function(u){i.onError("websocket error",u)}},typeof navigator<"u"&&/iPad|iPhone|iPod/i.test(navigator.userAgent)&&(e.prototype.onData=function(i){var u=this;setTimeout(function(){r.prototype.onData.call(u,i)},0)}),e.prototype.write=function(i){function u(){c.writable=!0,c.emit("drain")}var c=this;this.writable=!1;for(var s=0,n=i.length;n>s;s++)o.encodePacket(i[s],this.supportsBinary,function(p){try{c.ws.send(p)}catch{l("websocket closed before onclose event")}});setTimeout(u,0)},e.prototype.onClose=function(){r.prototype.onClose.call(this)},e.prototype.doClose=function(){typeof this.ws<"u"&&this.ws.close()},e.prototype.uri=function(){var i=this.query||{},u=this.secure?"wss":"ws",c="";return this.port&&(u=="wss"&&this.port!=443||u=="ws"&&this.port!=80)&&(c=":"+this.port),this.timestampRequests&&(i[this.timestampParam]=+new Date),this.supportsBinary||(i.b64=1),i=h.encode(i),i.length&&(i="?"+i),u+"://"+this.hostname+c+this.path+i},e.prototype.check=function(){return!(!d||"__initialize"in d&&this.name===e.prototype.name)}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,ws:35}],20:[function(a,t){var e=a("has-cors");t.exports=function(r){var o=r.xdomain,h=r.xscheme,f=r.enablesXDR;try{if(typeof XMLHttpRequest<"u"&&(!o||e))return new XMLHttpRequest}catch{}try{if(typeof XDomainRequest<"u"&&!h&&f)return new XDomainRequest}catch{}if(!o)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch{}}},{"has-cors":38}],21:[function(a,t){t.exports=function(e,r){var o=function(){};o.prototype=r.prototype,e.prototype=new o,e.prototype.constructor=e}},{}],22:[function(a,t,e){function r(){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 d=arguments,i=this.useColors;if(d[0]=(i?"%c":"")+this.namespace+(i?" %c":" ")+d[0]+(i?"%c ":" ")+"+"+e.humanize(this.diff),!i)return d;var u="color: "+this.color;d=[d[0],u,"color: inherit"].concat(Array.prototype.slice.call(d,1));var c=0,s=0;return d[0].replace(/%[a-z%]/g,function(n){n!=="%%"&&(c++,n==="%c"&&(s=c))}),d.splice(s,0,u),d}function h(){return typeof console=="object"&&typeof console.log=="function"&&Function.prototype.apply.call(console.log,console,arguments)}function f(d){try{d==null?localStorage.removeItem("debug"):localStorage.debug=d}catch{}}function l(){var d;try{d=localStorage.debug}catch{}return d}e=t.exports=a("./debug"),e.log=h,e.formatArgs=o,e.save=f,e.load=l,e.useColors=r,e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(d){return JSON.stringify(d)},e.enable(l())},{"./debug":23}],23:[function(a,t,e){function r(){return e.colors[u++%e.colors.length]}function o(c){function s(){}function n(){var g=n,y=+new Date,w=y-(i||y);g.diff=w,g.prev=i,g.curr=y,i=y,g.useColors==null&&(g.useColors=e.useColors()),g.color==null&&g.useColors&&(g.color=r());var j=Array.prototype.slice.call(arguments);j[0]=e.coerce(j[0]),typeof j[0]!="string"&&(j=["%o"].concat(j));var x=0;j[0]=j[0].replace(/%([a-z%])/g,function(I,k){if(I==="%%")return I;x++;var b=e.formatters[k];if(typeof b=="function"){var A=j[x];I=b.call(g,A),j.splice(x,1),x--}return I}),typeof e.formatArgs=="function"&&(j=e.formatArgs.apply(g,j));var V=n.log||e.log||console.log.bind(console);V.apply(g,j)}s.enabled=!1,n.enabled=!0;var p=e.enabled(c)?n:s;return p.namespace=c,p}function h(c){e.save(c);for(var s=(c||"").split(/[\s,]+/),n=s.length,p=0;n>p;p++)s[p]&&(c=s[p].replace(/\*/g,".*?"),c[0]==="-"?e.skips.push(new RegExp("^"+c.substr(1)+"$")):e.names.push(new RegExp("^"+c+"$")))}function f(){e.enable("")}function l(c){var s,n;for(s=0,n=e.skips.length;n>s;s++)if(e.skips[s].test(c))return!1;for(s=0,n=e.names.length;n>s;s++)if(e.names[s].test(c))return!0;return!1}function d(c){return c instanceof Error?c.stack||c.message:c}e=t.exports=o,e.coerce=d,e.disable=f,e.enable=h,e.enabled=l,e.humanize=a("ms"),e.names=[],e.skips=[],e.formatters={};var i,u=0},{ms:24}],24:[function(a,t){function e(c){var s=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(c);if(s){var n=parseFloat(s[1]),p=(s[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"y":return n*u;case"days":case"day":case"d":return n*i;case"hours":case"hour":case"h":return n*d;case"minutes":case"minute":case"m":return n*l;case"seconds":case"second":case"s":return n*f;case"ms":return n}}}function r(c){return c>=i?Math.round(c/i)+"d":c>=d?Math.round(c/d)+"h":c>=l?Math.round(c/l)+"m":c>=f?Math.round(c/f)+"s":c+"ms"}function o(c){return h(c,i,"day")||h(c,d,"hour")||h(c,l,"minute")||h(c,f,"second")||c+" ms"}function h(c,s,n){return s>c?void 0:1.5*s>c?Math.floor(c/s)+" "+n:Math.ceil(c/s)+" "+n+"s"}var f=1e3,l=60*f,d=60*l,i=24*d,u=365.25*i;t.exports=function(c,s){return s=s||{},typeof c=="string"?e(c):s.long?o(c):r(c)}},{}],25:[function(a,t,e){(function(r){function o(k,b){var A="b"+e.packets[k.type]+k.data.data;return b(A)}function h(k,b,A){if(!b)return e.encodeBase64Packet(k,A);var v=k.data,m=new Uint8Array(v),O=new Uint8Array(1+v.byteLength);O[0]=j[k.type];for(var B=0;B<m.length;B++)O[B+1]=m[B];return A(O.buffer)}function f(k,b,A){if(!b)return e.encodeBase64Packet(k,A);var v=new FileReader;return v.onload=function(){k.data=v.result,e.encodePacket(k,b,!0,A)},v.readAsArrayBuffer(k.data)}function l(k,b,A){if(!b)return e.encodeBase64Packet(k,A);if(w)return f(k,b,A);var v=new Uint8Array(1);v[0]=j[k.type];var m=new I([v.buffer,k.data]);return A(m)}function d(k,b,A){for(var v=new Array(k.length),m=n(k.length,A),O=function(R,S,K){b(S,function($,z){v[R]=z,K($,v)})},B=0;B<k.length;B++)O(B,k[B],m)}var i=a("./keys"),u=a("has-binary"),c=a("arraybuffer.slice"),s=a("base64-arraybuffer"),n=a("after"),p=a("utf8"),g=navigator.userAgent.match(/Android/i),y=/PhantomJS/i.test(navigator.userAgent),w=g||y;e.protocol=3;var j=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},x=i(j),V={type:"error",data:"parser error"},I=a("blob");e.encodePacket=function(k,b,A,v){typeof b=="function"&&(v=b,b=!1),typeof A=="function"&&(v=A,A=null);var m=k.data===void 0?void 0:k.data.buffer||k.data;if(r.ArrayBuffer&&m instanceof ArrayBuffer)return h(k,b,v);if(I&&m instanceof r.Blob)return l(k,b,v);if(m&&m.base64)return o(k,v);var O=j[k.type];return k.data!==void 0&&(O+=A?p.encode(String(k.data)):String(k.data)),v(""+O)},e.encodeBase64Packet=function(k,b){var A="b"+e.packets[k.type];if(I&&k.data instanceof I){var v=new FileReader;return v.onload=function(){var S=v.result.split(",")[1];b(A+S)},v.readAsDataURL(k.data)}var m;try{m=String.fromCharCode.apply(null,new Uint8Array(k.data))}catch{for(var O=new Uint8Array(k.data),B=new Array(O.length),R=0;R<O.length;R++)B[R]=O[R];m=String.fromCharCode.apply(null,B)}return A+=r.btoa(m),b(A)},e.decodePacket=function(k,b,A){if(typeof k=="string"||k===void 0){if(k.charAt(0)=="b")return e.decodeBase64Packet(k.substr(1),b);if(A)try{k=p.decode(k)}catch{return V}var m=k.charAt(0);return Number(m)==m&&x[m]?k.length>1?{type:x[m],data:k.substring(1)}:{type:x[m]}:V}var v=new Uint8Array(k),m=v[0],O=c(k,1);return I&&b==="blob"&&(O=new I([O])),{type:x[m],data:O}},e.decodeBase64Packet=function(k,b){var A=x[k.charAt(0)];if(!r.ArrayBuffer)return{type:A,data:{base64:!0,data:k.substr(1)}};var v=s.decode(k.substr(1));return b==="blob"&&I&&(v=new I([v])),{type:A,data:v}},e.encodePayload=function(k,b,A){function v(B){return B.length+":"+B}function m(B,R){e.encodePacket(B,O?b:!1,!0,function(S){R(null,v(S))})}typeof b=="function"&&(A=b,b=null);var O=u(k);return b&&O?I&&!w?e.encodePayloadAsBlob(k,A):e.encodePayloadAsArrayBuffer(k,A):k.length?void d(k,m,function(B,R){return A(R.join(""))}):A("0:")},e.decodePayload=function(k,b,A){if(typeof k!="string")return e.decodePayloadAsBinary(k,b,A);typeof b=="function"&&(A=b,b=null);var v;if(k=="")return A(V,0,1);for(var m,O,B="",R=0,S=k.length;S>R;R++){var K=k.charAt(R);if(K!=":")B+=K;else{if(B==""||B!=(m=Number(B))||(O=k.substr(R+1,m),B!=O.length))return A(V,0,1);if(O.length){if(v=e.decodePacket(O,b,!0),V.type==v.type&&V.data==v.data)return A(V,0,1);var $=A(v,R+m,S);if($===!1)return}R+=m,B=""}}return B!=""?A(V,0,1):void 0},e.encodePayloadAsArrayBuffer=function(k,b){function A(v,m){e.encodePacket(v,!0,!0,function(O){return m(null,O)})}return k.length?void d(k,A,function(v,m){var O=m.reduce(function(S,K){var $;return $=typeof K=="string"?K.length:K.byteLength,S+$.toString().length+$+2},0),B=new Uint8Array(O),R=0;return m.forEach(function(S){var K=typeof S=="string",$=S;if(K){for(var z=new Uint8Array(S.length),q=0;q<S.length;q++)z[q]=S.charCodeAt(q);$=z.buffer}B[R++]=K?0:1;for(var J=$.byteLength.toString(),q=0;q<J.length;q++)B[R++]=parseInt(J[q]);B[R++]=255;for(var z=new Uint8Array($),q=0;q<z.length;q++)B[R++]=z[q]}),b(B.buffer)}):b(new ArrayBuffer(0))},e.encodePayloadAsBlob=function(k,b){function A(v,m){e.encodePacket(v,!0,!0,function(O){var B=new Uint8Array(1);if(B[0]=1,typeof O=="string"){for(var R=new Uint8Array(O.length),S=0;S<O.length;S++)R[S]=O.charCodeAt(S);O=R.buffer,B[0]=0}for(var K=O instanceof ArrayBuffer?O.byteLength:O.size,$=K.toString(),z=new Uint8Array($.length+1),S=0;S<$.length;S++)z[S]=parseInt($[S]);if(z[$.length]=255,I){var q=new I([B.buffer,z.buffer,O]);m(null,q)}})}d(k,A,function(v,m){return b(new I(m))})},e.decodePayloadAsBinary=function(k,b,A){typeof b=="function"&&(A=b,b=null);for(var v=k,m=[],O=!1;v.byteLength>0;){for(var B=new Uint8Array(v),R=B[0]===0,S="",K=1;B[K]!=255;K++){if(S.length>310){O=!0;break}S+=B[K]}if(O)return A(V,0,1);v=c(v,2+S.length),S=parseInt(S);var $=c(v,0,S);if(R)try{$=String.fromCharCode.apply(null,new Uint8Array($))}catch{var z=new Uint8Array($);$="";for(var K=0;K<z.length;K++)$+=String.fromCharCode(z[K])}m.push($),v=c(v,S)}var q=m.length;m.forEach(function(J,ne){A(e.decodePacket(J,b,!0),ne,q)})}}).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(a,t){t.exports=Object.keys||function(e){var r=[],o=Object.prototype.hasOwnProperty;for(var h in e)o.call(e,h)&&r.push(h);return r}},{}],27:[function(a,t){function e(o,h,f){function l(i,u){if(l.count<=0)throw new Error("after called too many times");--l.count,i?(d=!0,h(i),h=f):l.count!==0||d||h(null,u)}var d=!1;return f=f||r,l.count=o,o===0?h():l}function r(){}t.exports=e},{}],28:[function(a,t){t.exports=function(e,r,o){var h=e.byteLength;if(r=r||0,o=o||h,e.slice)return e.slice(r,o);if(0>r&&(r+=h),0>o&&(o+=h),o>h&&(o=h),r>=h||r>=o||h===0)return new ArrayBuffer(0);for(var f=new Uint8Array(e),l=new Uint8Array(o-r),d=r,i=0;o>d;d++,i++)l[i]=f[d];return l.buffer}},{}],29:[function(a,t,e){(function(r){e.encode=function(o){var h,f=new Uint8Array(o),l=f.length,d="";for(h=0;l>h;h+=3)d+=r[f[h]>>2],d+=r[(3&f[h])<<4|f[h+1]>>4],d+=r[(15&f[h+1])<<2|f[h+2]>>6],d+=r[63&f[h+2]];return l%3===2?d=d.substring(0,d.length-1)+"=":l%3===1&&(d=d.substring(0,d.length-2)+"=="),d},e.decode=function(o){var h,f,l,d,i,u=.75*o.length,c=o.length,s=0;o[o.length-1]==="="&&(u--,o[o.length-2]==="="&&u--);var n=new ArrayBuffer(u),p=new Uint8Array(n);for(h=0;c>h;h+=4)f=r.indexOf(o[h]),l=r.indexOf(o[h+1]),d=r.indexOf(o[h+2]),i=r.indexOf(o[h+3]),p[s++]=f<<2|l>>4,p[s++]=(15&l)<<4|d>>2,p[s++]=(3&d)<<6|63&i;return n}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],30:[function(a,t){(function(e){function r(u){for(var c=0;c<u.length;c++){var s=u[c];if(s.buffer instanceof ArrayBuffer){var n=s.buffer;if(s.byteLength!==n.byteLength){var p=new Uint8Array(s.byteLength);p.set(new Uint8Array(n,s.byteOffset,s.byteLength)),n=p.buffer}u[c]=n}}}function o(u,c){c=c||{};var s=new f;r(u);for(var n=0;n<u.length;n++)s.append(u[n]);return c.type?s.getBlob(c.type):s.getBlob()}function h(u,c){return r(u),new Blob(u,c||{})}var f=e.BlobBuilder||e.WebKitBlobBuilder||e.MSBlobBuilder||e.MozBlobBuilder,l=function(){try{var u=new Blob(["hi"]);return u.size===2}catch{return!1}}(),d=l&&function(){try{var u=new Blob([new Uint8Array([1,2])]);return u.size===2}catch{return!1}}(),i=f&&f.prototype.append&&f.prototype.getBlob;t.exports=function(){return l?d?e.Blob:h:i?o:void 0}()}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],31:[function(a,t,e){(function(r){(function(o){function h(v){for(var m,O,B=[],R=0,S=v.length;S>R;)m=v.charCodeAt(R++),m>=55296&&56319>=m&&S>R?(O=v.charCodeAt(R++),(64512&O)==56320?B.push(((1023&m)<<10)+(1023&O)+65536):(B.push(m),R--)):B.push(m);return B}function f(v){for(var m,O=v.length,B=-1,R="";++B<O;)m=v[B],m>65535&&(m-=65536,R+=V(m>>>10&1023|55296),m=56320|1023&m),R+=V(m);return R}function l(v){if(v>=55296&&57343>=v)throw Error("Lone surrogate U+"+v.toString(16).toUpperCase()+" is not a scalar value")}function d(v,m){return V(v>>m&63|128)}function i(v){if(!(4294967168&v))return V(v);var m="";return 4294965248&v?4294901760&v?!(4292870144&v)&&(m=V(v>>18&7|240),m+=d(v,12),m+=d(v,6)):(l(v),m=V(v>>12&15|224),m+=d(v,6)):m=V(v>>6&31|192),m+=V(63&v|128)}function u(v){for(var m,O=h(v),B=O.length,R=-1,S="";++R<B;)m=O[R],S+=i(m);return S}function c(){if(x>=j)throw Error("Invalid byte index");var v=255&w[x];if(x++,(192&v)==128)return 63&v;throw Error("Invalid continuation byte")}function s(){var v,m,O,B,R;if(x>j)throw Error("Invalid byte index");if(x==j)return!1;if(v=255&w[x],x++,(128&v)==0)return v;if((224&v)==192){var m=c();if(R=(31&v)<<6|m,R>=128)return R;throw Error("Invalid continuation byte")}if((240&v)==224){if(m=c(),O=c(),R=(15&v)<<12|m<<6|O,R>=2048)return l(R),R;throw Error("Invalid continuation byte")}if((248&v)==240&&(m=c(),O=c(),B=c(),R=(15&v)<<18|m<<12|O<<6|B,R>=65536&&1114111>=R))return R;throw Error("Invalid UTF-8 detected")}function n(v){w=h(v),j=w.length,x=0;for(var m,O=[];(m=s())!==!1;)O.push(m);return f(O)}var p=typeof e=="object"&&e,g=typeof t=="object"&&t&&t.exports==p&&t,y=typeof r=="object"&&r;(y.global===y||y.window===y)&&(o=y);var w,j,x,V=String.fromCharCode,I={version:"2.0.0",encode:u,decode:n};if(p&&!p.nodeType)if(g)g.exports=I;else{var k={},b=k.hasOwnProperty;for(var A in I)b.call(I,A)&&(p[A]=I[A])}else o.utf8=I})(this)}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],32:[function(a,t){(function(e){var r=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,h=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,f=/(?:^|:|,)(?:\s*\[)+/g,l=/^\s+/,d=/\s+$/;t.exports=function(i){return typeof i=="string"&&i?(i=i.replace(l,"").replace(d,""),e.JSON&&JSON.parse?JSON.parse(i):r.test(i.replace(o,"@").replace(h,"]").replace(f,""))?new Function("return "+i)():void 0):null}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],33:[function(a,t,e){e.encode=function(r){var o="";for(var h in r)r.hasOwnProperty(h)&&(o.length&&(o+="&"),o+=encodeURIComponent(h)+"="+encodeURIComponent(r[h]));return o},e.decode=function(r){for(var o={},h=r.split("&"),f=0,l=h.length;l>f;f++){var d=h[f].split("=");o[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return o}},{}],34:[function(a,t){var e=/^(?:(?![^:@]+:[^:@\/]*@)(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"];t.exports=function(o){var h=o,f=o.indexOf("["),l=o.indexOf("]");f!=-1&&l!=-1&&(o=o.substring(0,f)+o.substring(f,l).replace(/:/g,";")+o.substring(l,o.length));for(var d=e.exec(o||""),i={},u=14;u--;)i[r[u]]=d[u]||"";return f!=-1&&l!=-1&&(i.source=h,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i}},{}],35:[function(a,t){function e(h,f){return f?new o(h,f):new o(h)}var r=function(){return self}(),o=r.WebSocket||r.MozWebSocket;t.exports=o?e:null,o&&(e.prototype=o.prototype)},{}],36:[function(a,t){(function(e){function r(h){function f(l){if(!l)return!1;if(e.Buffer&&e.Buffer.isBuffer(l)||e.ArrayBuffer&&l instanceof ArrayBuffer||e.Blob&&l instanceof Blob||e.File&&l instanceof File)return!0;if(o(l)){for(var d=0;d<l.length;d++)if(f(l[d]))return!0}else if(l&&typeof l=="object"){l.toJSON&&(l=l.toJSON());for(var i in l)if(Object.prototype.hasOwnProperty.call(l,i)&&f(l[i]))return!0}return!1}return f(h)}var o=a("isarray");t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{isarray:37}],37:[function(a,t){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],38:[function(a,t){var e=a("global");try{t.exports="XMLHttpRequest"in e&&"withCredentials"in new e.XMLHttpRequest}catch{t.exports=!1}},{global:39}],39:[function(a,t){t.exports=function(){return this}()},{}],40:[function(a,t){var e=[].indexOf;t.exports=function(r,o){if(e)return r.indexOf(o);for(var h=0;h<r.length;++h)if(r[h]===o)return h;return-1}},{}],41:[function(a,t,e){var r=Object.prototype.hasOwnProperty;e.keys=Object.keys||function(o){var h=[];for(var f in o)r.call(o,f)&&h.push(f);return h},e.values=function(o){var h=[];for(var f in o)r.call(o,f)&&h.push(o[f]);return h},e.merge=function(o,h){for(var f in h)r.call(h,f)&&(o[f]=h[f]);return o},e.length=function(o){return e.keys(o).length},e.isEmpty=function(o){return e.length(o)==0}},{}],42:[function(a,t){var e=/^(?:(?![^:@]+:[^:@\/]*@)(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"];t.exports=function(o){for(var h=e.exec(o||""),f={},l=14;l--;)f[r[l]]=h[l]||"";return f}},{}],43:[function(a,t,e){(function(r){var o=a("isarray"),h=a("./is-buffer");e.deconstructPacket=function(f){function l(c){if(!c)return c;if(h(c)){var s={_placeholder:!0,num:d.length};return d.push(c),s}if(o(c)){for(var n=new Array(c.length),p=0;p<c.length;p++)n[p]=l(c[p]);return n}if(typeof c=="object"&&!(c instanceof Date)){var n={};for(var g in c)n[g]=l(c[g]);return n}return c}var d=[],i=f.data,u=f;return u.data=l(i),u.attachments=d.length,{packet:u,buffers:d}},e.reconstructPacket=function(f,l){function d(i){if(i&&i._placeholder){var u=l[i.num];return u}if(o(i)){for(var c=0;c<i.length;c++)i[c]=d(i[c]);return i}if(i&&typeof i=="object"){for(var s in i)i[s]=d(i[s]);return i}return i}return f.data=d(f.data),f.attachments=void 0,f},e.removeBlobs=function(f,l){function d(c,s,n){if(!c)return c;if(r.Blob&&c instanceof Blob||r.File&&c instanceof File){i++;var p=new FileReader;p.onload=function(){n?n[s]=this.result:u=this.result,--i||l(u)},p.readAsArrayBuffer(c)}else if(o(c))for(var g=0;g<c.length;g++)d(c[g],g,c);else if(c&&typeof c=="object"&&!h(c))for(var y in c)d(c[y],y,c)}var i=0,u=f;d(u),i||l(u)}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./is-buffer":45,isarray:46}],44:[function(a,t,e){function r(){}function o(g){var y="",w=!1;return y+=g.type,(e.BINARY_EVENT==g.type||e.BINARY_ACK==g.type)&&(y+=g.attachments,y+="-"),g.nsp&&g.nsp!="/"&&(w=!0,y+=g.nsp),g.id!=null&&(w&&(y+=",",w=!1),y+=g.id),g.data!=null&&(w&&(y+=","),y+=c.stringify(g.data)),u("encoded %j as %s",g,y),y}function h(g,y){function w(j){var x=n.deconstructPacket(j),V=o(x.packet),I=x.buffers;I.unshift(V),y(I)}n.removeBlobs(g,w)}function f(){this.reconstructor=null}function l(g){var y={},w=0;if(y.type=Number(g.charAt(0)),e.types[y.type]==null)return i();if(e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type){for(var j="";g.charAt(++w)!="-"&&(j+=g.charAt(w),w!=g.length););if(j!=Number(j)||g.charAt(w)!="-")throw new Error("Illegal attachments");y.attachments=Number(j)}if(g.charAt(w+1)=="/")for(y.nsp="";++w;){var x=g.charAt(w);if(x==","||(y.nsp+=x,w==g.length))break}else y.nsp="/";var V=g.charAt(w+1);if(V!==""&&Number(V)==V){for(y.id="";++w;){var x=g.charAt(w);if(x==null||Number(x)!=x){--w;break}if(y.id+=g.charAt(w),w==g.length)break}y.id=Number(y.id)}if(g.charAt(++w))try{y.data=c.parse(g.substr(w))}catch{return i()}return u("decoded %s as %j",g,y),y}function d(g){this.reconPack=g,this.buffers=[]}function i(){return{type:e.ERROR,data:"parser error"}}var u=a("debug")("socket.io-parser"),c=a("json3"),s=(a("isarray"),a("component-emitter")),n=a("./binary"),p=a("./is-buffer");e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","BINARY_EVENT","ACK","BINARY_ACK","ERROR"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=r,e.Decoder=f,r.prototype.encode=function(g,y){if(u("encoding packet %j",g),e.BINARY_EVENT==g.type||e.BINARY_ACK==g.type)h(g,y);else{var w=o(g);y([w])}},s(f.prototype),f.prototype.add=function(g){var y;if(typeof g=="string")y=l(g),e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type?(this.reconstructor=new d(y),this.reconstructor.reconPack.attachments===0&&this.emit("decoded",y)):this.emit("decoded",y);else{if(!p(g)&&!g.base64)throw new Error("Unknown type: "+g);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");y=this.reconstructor.takeBinaryData(g),y&&(this.reconstructor=null,this.emit("decoded",y))}},f.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},d.prototype.takeBinaryData=function(g){if(this.buffers.push(g),this.buffers.length==this.reconPack.attachments){var y=n.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),y}return null},d.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},{"./binary":43,"./is-buffer":45,"component-emitter":9,debug:10,isarray:46,json3:47}],45:[function(a,t){(function(e){function r(o){return e.Buffer&&e.Buffer.isBuffer(o)||e.ArrayBuffer&&o instanceof ArrayBuffer}t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],46:[function(a,t){t.exports=a(37)},{}],47:[function(a,t,e){(function(r){function o(E){if(o[E]!==l)return o[E];var _;if(E=="bug-string-char-index")_=!1;else if(E=="json")_=o("json-stringify")&&o("json-parse");else{var T,P='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if(E=="json-stringify"){var C=u.stringify,U=typeof C=="function"&&c;if(U){(T=function(){return 1}).toJSON=T;try{U=C(0)==="0"&&C(new Number)==="0"&&C(new String)=='""'&&C(d)===l&&C(l)===l&&C()===l&&C(T)==="1"&&C([T])=="[1]"&&C([l])=="[null]"&&C(null)=="null"&&C([l,d,null])=="[null,null,null]"&&C({a:[T,!0,!1,null,`\0\b
|
|
8
|
-
\f\r `]})==
|
|
6
|
+
*/var Me=function(a){return a!=null&&(Ae(a)||qe(a)||!!a._isBuffer)};function Ae(a){return!!a.constructor&&typeof a.constructor.isBuffer=="function"&&a.constructor.isBuffer(a)}function qe(a){return typeof a.readFloatLE=="function"&&typeof a.slice=="function"&&Ae(a.slice(0,0))}(function(){var a=Fe,t=Te.utf8,e=Me,r=Te.bin,o=function(c,f){c.constructor==String?f&&f.encoding==="binary"?c=r.stringToBytes(c):c=t.stringToBytes(c):e(c)?c=Array.prototype.slice.call(c,0):!Array.isArray(c)&&c.constructor!==Uint8Array&&(c=c.toString());for(var h=a.bytesToWords(c),d=c.length*8,i=1732584193,u=-271733879,l=-1732584194,s=271733878,n=0;n<h.length;n++)h[n]=(h[n]<<8|h[n]>>>24)&16711935|(h[n]<<24|h[n]>>>8)&4278255360;h[d>>>5]|=128<<d%32,h[(d+64>>>9<<4)+14]=d;for(var p=o._ff,g=o._gg,y=o._hh,b=o._ii,n=0;n<h.length;n+=16){var j=i,U=u,F=l,I=s;i=p(i,u,l,s,h[n+0],7,-680876936),s=p(s,i,u,l,h[n+1],12,-389564586),l=p(l,s,i,u,h[n+2],17,606105819),u=p(u,l,s,i,h[n+3],22,-1044525330),i=p(i,u,l,s,h[n+4],7,-176418897),s=p(s,i,u,l,h[n+5],12,1200080426),l=p(l,s,i,u,h[n+6],17,-1473231341),u=p(u,l,s,i,h[n+7],22,-45705983),i=p(i,u,l,s,h[n+8],7,1770035416),s=p(s,i,u,l,h[n+9],12,-1958414417),l=p(l,s,i,u,h[n+10],17,-42063),u=p(u,l,s,i,h[n+11],22,-1990404162),i=p(i,u,l,s,h[n+12],7,1804603682),s=p(s,i,u,l,h[n+13],12,-40341101),l=p(l,s,i,u,h[n+14],17,-1502002290),u=p(u,l,s,i,h[n+15],22,1236535329),i=g(i,u,l,s,h[n+1],5,-165796510),s=g(s,i,u,l,h[n+6],9,-1069501632),l=g(l,s,i,u,h[n+11],14,643717713),u=g(u,l,s,i,h[n+0],20,-373897302),i=g(i,u,l,s,h[n+5],5,-701558691),s=g(s,i,u,l,h[n+10],9,38016083),l=g(l,s,i,u,h[n+15],14,-660478335),u=g(u,l,s,i,h[n+4],20,-405537848),i=g(i,u,l,s,h[n+9],5,568446438),s=g(s,i,u,l,h[n+14],9,-1019803690),l=g(l,s,i,u,h[n+3],14,-187363961),u=g(u,l,s,i,h[n+8],20,1163531501),i=g(i,u,l,s,h[n+13],5,-1444681467),s=g(s,i,u,l,h[n+2],9,-51403784),l=g(l,s,i,u,h[n+7],14,1735328473),u=g(u,l,s,i,h[n+12],20,-1926607734),i=y(i,u,l,s,h[n+5],4,-378558),s=y(s,i,u,l,h[n+8],11,-2022574463),l=y(l,s,i,u,h[n+11],16,1839030562),u=y(u,l,s,i,h[n+14],23,-35309556),i=y(i,u,l,s,h[n+1],4,-1530992060),s=y(s,i,u,l,h[n+4],11,1272893353),l=y(l,s,i,u,h[n+7],16,-155497632),u=y(u,l,s,i,h[n+10],23,-1094730640),i=y(i,u,l,s,h[n+13],4,681279174),s=y(s,i,u,l,h[n+0],11,-358537222),l=y(l,s,i,u,h[n+3],16,-722521979),u=y(u,l,s,i,h[n+6],23,76029189),i=y(i,u,l,s,h[n+9],4,-640364487),s=y(s,i,u,l,h[n+12],11,-421815835),l=y(l,s,i,u,h[n+15],16,530742520),u=y(u,l,s,i,h[n+2],23,-995338651),i=b(i,u,l,s,h[n+0],6,-198630844),s=b(s,i,u,l,h[n+7],10,1126891415),l=b(l,s,i,u,h[n+14],15,-1416354905),u=b(u,l,s,i,h[n+5],21,-57434055),i=b(i,u,l,s,h[n+12],6,1700485571),s=b(s,i,u,l,h[n+3],10,-1894986606),l=b(l,s,i,u,h[n+10],15,-1051523),u=b(u,l,s,i,h[n+1],21,-2054922799),i=b(i,u,l,s,h[n+8],6,1873313359),s=b(s,i,u,l,h[n+15],10,-30611744),l=b(l,s,i,u,h[n+6],15,-1560198380),u=b(u,l,s,i,h[n+13],21,1309151649),i=b(i,u,l,s,h[n+4],6,-145523070),s=b(s,i,u,l,h[n+11],10,-1120210379),l=b(l,s,i,u,h[n+2],15,718787259),u=b(u,l,s,i,h[n+9],21,-343485551),i=i+j>>>0,u=u+U>>>0,l=l+F>>>0,s=s+I>>>0}return a.endian([i,u,l,s])};o._ff=function(c,f,h,d,i,u,l){var s=c+(f&h|~f&d)+(i>>>0)+l;return(s<<u|s>>>32-u)+f},o._gg=function(c,f,h,d,i,u,l){var s=c+(f&d|h&~d)+(i>>>0)+l;return(s<<u|s>>>32-u)+f},o._hh=function(c,f,h,d,i,u,l){var s=c+(f^h^d)+(i>>>0)+l;return(s<<u|s>>>32-u)+f},o._ii=function(c,f,h,d,i,u,l){var s=c+(h^(f|~d))+(i>>>0)+l;return(s<<u|s>>>32-u)+f},o._blocksize=16,o._digestsize=16,be.exports=function(c,f){if(c==null)throw new Error("Illegal argument "+c);var h=a.wordsToBytes(o(c,f));return f&&f.asBytes?h:f&&f.asString?r.bytesToString(h):a.bytesToHex(h)}})();var Xe=be.exports;const Ke=Pe(Xe);var Z=(a=>(a.BOOTSTRAP="bootstrap",a.DEBUG_EXTENSIONS="debugExtensions",a.DEBUG_QUEUE="debugQueue",a.DEBUG_DIALER="debugDialer",a.FULL="full",a))(Z||{}),ee=(a=>(a.MAIN="main",a.NEXT="next",a))(ee||{}),Y=(a=>(a.USER="User",a.TOKEN="Token",a))(Y||{});class ie{static async getSessionStorageDataByKey(t,e=!0){if(typeof chrome<"u"&&typeof chrome.storage<"u"){const r=await chrome.storage.session.get(t);if(r[t])return e?JSON.parse(r[t]):r[t]}if(typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.getItem=="function"){const r=window.sessionStorage.getItem(t);if(r)return e?JSON.parse(r):r}}static async updateSessionStorageKey(t,e){typeof chrome<"u"&&typeof chrome.storage<"u"&&await chrome.storage.session.set({[t]:JSON.stringify(e)}),typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.setItem=="function"&&window.sessionStorage.setItem(t,JSON.stringify(e))}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()}}class $e{constructor(t){X(this,"delay",1e3);X(this,"lastLoginTimestamp");X(this,"token");X(this,"refreshToken");X(this,"tokenExpiry");X(this,"storageKey");this.eventsSdkClass=t,this.eventsSdkClass=t,this.storageKey=""}async login(){const t={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=Ke(JSON.stringify({...this.eventsSdkClass.options,loggerSocketConnection:null},this.eventsSdkClass.getCircularReplacer())),this.lastLoginTimestamp&&this.lastLoginTimestamp+this.delay>new Date().getTime())return;this.updateLastLoginTimestamp();const e=await this.checkLoginStatus(this.storageKey);return e||(ie.clearSessionStorage(),await this.userLoginFunction(t,this.storageKey,this.eventsSdkClass.options.loginType))}updateLastLoginTimestamp(){this.lastLoginTimestamp=new Date().getTime()}async checkLoginStatus(t){const e=await ie.getSessionStorageDataByKey(t);if(e)return e}async userLoginFunction(t,e,r){let o,c,f;return this.eventsSdkClass.options.isNewStack?(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,r),c=await this.getSettings(o.Data.AccessToken),f={...o.Data,...c}):(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,r),f={...o.Data.Socket}),await ie.updateSessionStorageKey(e,f),f}onLoginResponse(t){if(!this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),t.MonitorList&&t.MonitorList.length&&!this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...t.MonitorList],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,r)=>e.Priority>r.Priority?e:r)),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length&&t.URLList&&(this.eventsSdkClass.URLList=t.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=${t.Version}`),t.IdentityCode&&(this.token=t.IdentityCode,this.eventsSdkClass.connect(ee.MAIN)),t.Token&&(this.token=t.Token,this.eventsSdkClass.connect(ee.MAIN)),t.RefreshToken&&t.IdentityCodeExpiry&&this.eventsSdkClass.options.loginType===Y.USER&&(this.refreshToken=t.RefreshToken,this.tokenExpiry=t.IdentityCodeExpiry,this.handleTokenExpiry()),t.RefreshToken&&t.TokenExpiry&&this.normalizeLoginType(this.eventsSdkClass.options.loginType)===Y.USER&&(this.refreshToken=t.RefreshToken,this.tokenExpiry=t.TokenExpiry,this.handleTokenExpiry())}handleTokenExpiry(){if(!this.eventsSdkClass.options.refreshTokenUrl)throw new Error("refreshTokenUrl not provided");let t;if(this.tokenExpiry)t=new Date(this.tokenExpiry);else return;const e=t.getTime()-new Date().getTime()-5e3,r=Math.min(e,2147483647);setTimeout(async()=>{if(this.refreshToken){this.eventsSdkClass.socketIoClass.closeAllConnections();let o,c;if(this.eventsSdkClass.options.isNewStack){const f=await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken);o=await this.getSettings(f.Data.AccessToken),c={...f.Data,...o}}else c={...(await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken)).Data.Socket};this.onLoginResponse(c),await ie.updateSessionStorageKey(this.storageKey,c)}},r)}async externalLogin(t,{password:e,token:r,email:o},c){if(!t)throw new Error("loginUrl not provided");let f;this.eventsSdkClass.options.isNewStack?c===Y.TOKEN?f=JSON.stringify({identityType:Y.TOKEN,token:r}):f=JSON.stringify({identityType:Y.USER,username:o,password:e}):this.eventsSdkClass.options.loginType===Y.TOKEN?(f=JSON.stringify({token:r}),t=`${t}/${Y.TOKEN}`):(f=JSON.stringify({email:o,pin:e}),t=`${t}/${Y.USER}`);let h;try{const d=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:f});if(!d.ok&&d.status===400)throw h=400,new Error("Bad body request. Login type or isNewStack values not correct or not provided");if(!d.ok&&d.status===401)throw h=401,new Error("Unauthorized. Invalid token provided");if(!d.ok&&d.status===403)throw h=403,new Error("Forbidden. Identity token not provided or not valid");const i=await d.json();if(i.error)throw new Error(i.error);return i}catch(d){throw this.eventsSdkClass.loggerClass.loginError(c,h,r,o),d}}async getSettings(t){try{if(!this.eventsSdkClass.options.getSettingsUrl)throw new Error("getSettingsUrl not provided");const e=await fetch(this.eventsSdkClass.options.getSettingsUrl,{headers:{Authorization:`Bearer ${t}`}});if(!e.ok&&e.status===401)throw new Error("Unauthorized. Access token not provided or not valid");return e.json()}catch(e){throw this.eventsSdkClass.loggerClass.getSettingsError(t,e),e}}async externalRefreshToken(t,e){try{return(await fetch(t,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}})).json()}catch(r){throw this.eventsSdkClass.loggerClass.refreshTokenError(e,t,r),r}}normalizeLoginType(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}}const Le={isNewStack:!1,loginUrl:"https://loginapi.voicenter.co.il/monitorAPI/Login",refreshTokenUrl:"https://loginapi.voicenter.co.il/monitorAPI/RefreshIdentityToken",forceNew:!0,reconnectionDelay:5,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:!1,reconnectionDelay:5e3,reconnectionAttempts:10,perMessageDeflate:void 0,upgrade:!1,transports:["websocket"],debug:!1}};function Ge(){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=je,typeof self.navigator>"u"&&(self.navigator={userAgent:"node"})),function a(t,e,r){function o(h,d){if(!e[h]){if(!t[h]){var i=typeof require=="function"&&require;if(!d&&i)return i(h,!0);if(c)return c(h,!0);throw new Error("Cannot find module '"+h+"'")}var u=e[h]={exports:{}};t[h][0].call(u.exports,function(l){var s=t[h][1][l];return o(s||l)},u,u.exports,a,t,e,r)}return e[h].exports}for(var c=typeof require=="function"&&require,f=0;f<r.length;f++)o(r[f]);return o}({1:[function(a,t){t.exports=a("./lib/")},{"./lib/":2}],2:[function(a,t,e){function r(i,u){typeof i=="object"&&(u=i,i=void 0),u=u||{};var l,s=o(i),n=s.source,p=s.id;return u.forceNew||u["force new connection"]||u.multiplex===!1?(h("ignoring socket cache for %s",n),l=f(n,u)):(d[p]||(h("new io instance for %s",n),d[p]=f(n,u)),l=d[p]),l.socket(s.path)}var o=a("./url"),c=a("socket.io-parser"),f=a("./manager"),h=a("debug")("socket.io-client");t.exports=e=r;var d=e.managers={};e.protocol=c.protocol,e.connect=r,e.Manager=a("./manager"),e.Socket=a("./socket")},{"./manager":3,"./socket":5,"./url":6,debug:10,"socket.io-parser":44}],3:[function(a,t){function e(s,n){return this instanceof e?(s&&typeof s=="object"&&(n=s,s=void 0),n=n||{},n.path=n.path||"/socket.io",this.nsps={},this.subs=[],this.opts=n,this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor(n.randomizationFactor||.5),this.backoff=new l({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this.readyState="closed",this.uri=s,this.connected=[],this.encoding=!1,this.packetBuffer=[],this.encoder=new f.Encoder,this.decoder=new f.Decoder,this.autoConnect=n.autoConnect!==!1,void(this.autoConnect&&this.open())):new e(s,n)}var r=(a("./url"),a("engine.io-client")),o=a("./socket"),c=a("component-emitter"),f=a("socket.io-parser"),h=a("./on"),d=a("component-bind"),i=(a("object-component"),a("debug")("socket.io-client:manager")),u=a("indexof"),l=a("backo2");t.exports=e,e.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var s in this.nsps)this.nsps[s].emit.apply(this.nsps[s],arguments)},e.prototype.updateSocketIds=function(){for(var s in this.nsps)this.nsps[s].id=this.engine.id},c(e.prototype),e.prototype.reconnection=function(s){return arguments.length?(this._reconnection=!!s,this):this._reconnection},e.prototype.reconnectionAttempts=function(s){return arguments.length?(this._reconnectionAttempts=s,this):this._reconnectionAttempts},e.prototype.reconnectionDelay=function(s){return arguments.length?(this._reconnectionDelay=s,this.backoff&&this.backoff.setMin(s),this):this._reconnectionDelay},e.prototype.randomizationFactor=function(s){return arguments.length?(this._randomizationFactor=s,this.backoff&&this.backoff.setJitter(s),this):this._randomizationFactor},e.prototype.reconnectionDelayMax=function(s){return arguments.length?(this._reconnectionDelayMax=s,this.backoff&&this.backoff.setMax(s),this):this._reconnectionDelayMax},e.prototype.timeout=function(s){return arguments.length?(this._timeout=s,this):this._timeout},e.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()},e.prototype.open=e.prototype.connect=function(s){if(i("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;i("opening %s",this.uri),this.engine=r(this.uri,this.opts);var n=this.engine,p=this;this.readyState="opening",this.skipReconnect=!1;var g=h(n,"open",function(){p.onopen(),s&&s()}),y=h(n,"error",function(U){if(i("connect_error"),p.cleanup(),p.readyState="closed",p.emitAll("connect_error",U),s){var F=new Error("Connection error");F.data=U,s(F)}else p.maybeReconnectOnOpen()});if(this._timeout!==!1){var b=this._timeout;i("connect attempt will timeout after %d",b);var j=setTimeout(function(){i("connect attempt timed out after %d",b),g.destroy(),n.close(),n.emit("error","timeout"),p.emitAll("connect_timeout",b)},b);this.subs.push({destroy:function(){clearTimeout(j)}})}return this.subs.push(g),this.subs.push(y),this},e.prototype.onopen=function(){i("open"),this.cleanup(),this.readyState="open",this.emit("open");var s=this.engine;this.subs.push(h(s,"data",d(this,"ondata"))),this.subs.push(h(this.decoder,"decoded",d(this,"ondecoded"))),this.subs.push(h(s,"error",d(this,"onerror"))),this.subs.push(h(s,"close",d(this,"onclose")))},e.prototype.ondata=function(s){this.decoder.add(s)},e.prototype.ondecoded=function(s){this.emit("packet",s)},e.prototype.onerror=function(s){i("error",s),this.emitAll("error",s)},e.prototype.socket=function(s){var n=this.nsps[s];if(!n){n=new o(this,s),this.nsps[s]=n;var p=this;n.on("connect",function(){n.id=p.engine.id,~u(p.connected,n)||p.connected.push(n)})}return n},e.prototype.destroy=function(s){var n=u(this.connected,s);~n&&this.connected.splice(n,1),this.connected.length||this.close()},e.prototype.packet=function(s){i("writing packet %j",s);var n=this;n.encoding?n.packetBuffer.push(s):(n.encoding=!0,this.encoder.encode(s,function(p){for(var g=0;g<p.length;g++)n.engine.write(p[g]);n.encoding=!1,n.processPacketQueue()}))},e.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var s=this.packetBuffer.shift();this.packet(s)}},e.prototype.cleanup=function(){for(var s;s=this.subs.shift();)s.destroy();this.packetBuffer=[],this.encoding=!1,this.decoder.destroy()},e.prototype.close=e.prototype.disconnect=function(){this.skipReconnect=!0,this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},e.prototype.onclose=function(s){i("close"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",s),this._reconnection&&!this.skipReconnect&&this.reconnect()},e.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var s=this;if(this.backoff.attempts>=this._reconnectionAttempts)i("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var n=this.backoff.duration();i("will wait %dms before reconnect attempt",n),this.reconnecting=!0;var p=setTimeout(function(){s.skipReconnect||(i("attempting reconnect"),s.emitAll("reconnect_attempt",s.backoff.attempts),s.emitAll("reconnecting",s.backoff.attempts),s.skipReconnect||s.open(function(g){g?(i("reconnect attempt error"),s.reconnecting=!1,s.reconnect(),s.emitAll("reconnect_error",g.data)):(i("reconnect success"),s.onreconnect())}))},n);this.subs.push({destroy:function(){clearTimeout(p)}})}},e.prototype.onreconnect=function(){var s=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",s)}},{"./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(a,t){function e(r,o,c){return r.on(o,c),{destroy:function(){r.removeListener(o,c)}}}t.exports=e},{}],5:[function(a,t,e){function r(n,p){this.io=n,this.nsp=p,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=a("socket.io-parser"),c=a("component-emitter"),f=a("to-array"),h=a("./on"),d=a("component-bind"),i=a("debug")("socket.io-client:socket"),u=a("has-binary");t.exports=r;var l={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},s=c.prototype.emit;c(r.prototype),r.prototype.subEvents=function(){if(!this.subs){var n=this.io;this.subs=[h(n,"open",d(this,"onopen")),h(n,"packet",d(this,"onpacket")),h(n,"close",d(this,"onclose"))]}},r.prototype.open=r.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),this.io.readyState=="open"&&this.onopen(),this)},r.prototype.send=function(){var n=f(arguments);return n.unshift("message"),this.emit.apply(this,n),this},r.prototype.emit=function(n){if(l.hasOwnProperty(n))return s.apply(this,arguments),this;var p=f(arguments),g=o.EVENT;u(p)&&(g=o.BINARY_EVENT);var y={type:g,data:p};return typeof p[p.length-1]=="function"&&(i("emitting packet with ack id %d",this.ids),this.acks[this.ids]=p.pop(),y.id=this.ids++),this.connected?this.packet(y):this.sendBuffer.push(y),this},r.prototype.packet=function(n){n.nsp=this.nsp,this.io.packet(n)},r.prototype.onopen=function(){i("transport is open - connecting"),this.nsp!="/"&&this.packet({type:o.CONNECT})},r.prototype.onclose=function(n){i("close (%s)",n),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",n)},r.prototype.onpacket=function(n){if(n.nsp==this.nsp)switch(n.type){case o.CONNECT:this.onconnect();break;case o.EVENT:this.onevent(n);break;case o.BINARY_EVENT:this.onevent(n);break;case o.ACK:this.onack(n);break;case o.BINARY_ACK:this.onack(n);break;case o.DISCONNECT:this.ondisconnect();break;case o.ERROR:this.emit("error",n.data)}},r.prototype.onevent=function(n){var p=n.data||[];i("emitting event %j",p),n.id!=null&&(i("attaching ack callback to event"),p.push(this.ack(n.id))),this.connected?s.apply(this,p):this.receiveBuffer.push(p)},r.prototype.ack=function(n){var p=this,g=!1;return function(){if(!g){g=!0;var y=f(arguments);i("sending ack %j",y);var b=u(y)?o.BINARY_ACK:o.ACK;p.packet({type:b,id:n,data:y})}}},r.prototype.onack=function(n){i("calling ack %s with %j",n.id,n.data);var p=this.acks[n.id];p.apply(this,n.data),delete this.acks[n.id]},r.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},r.prototype.emitBuffered=function(){var n;for(n=0;n<this.receiveBuffer.length;n++)s.apply(this,this.receiveBuffer[n]);for(this.receiveBuffer=[],n=0;n<this.sendBuffer.length;n++)this.packet(this.sendBuffer[n]);this.sendBuffer=[]},r.prototype.ondisconnect=function(){i("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},r.prototype.destroy=function(){if(this.subs){for(var n=0;n<this.subs.length;n++)this.subs[n].destroy();this.subs=null}this.io.destroy(this)},r.prototype.close=r.prototype.disconnect=function(){return this.connected&&(i("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(a,t){(function(e){function r(f,i){var d=f,i=i||e.location;return f==null&&(f=i.protocol+"//"+i.host),typeof f=="string"&&(f.charAt(0)=="/"&&(f=f.charAt(1)=="/"?i.protocol+f:i.hostname+f),/^(https?|wss?):\/\//.test(f)||(c("protocol-less url %s",f),f=typeof i<"u"?i.protocol+"//"+f:"https://"+f),c("parse %s",f),d=o(f)),d.port||(/^(http|ws)$/.test(d.protocol)?d.port="80":/^(http|ws)s$/.test(d.protocol)&&(d.port="443")),d.path=d.path||"/",d.id=d.protocol+"://"+d.host+":"+d.port,d.href=d.protocol+"://"+d.host+(i&&i.port==d.port?"":":"+d.port),d}var o=a("parseuri"),c=a("debug")("socket.io-client:url");t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{debug:10,parseuri:42}],7:[function(a,t){function e(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}t.exports=e,e.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var o=Math.random(),c=Math.floor(o*this.jitter*r);r=1&Math.floor(10*o)?r+c:r-c}return 0|Math.min(r,this.max)},e.prototype.reset=function(){this.attempts=0},e.prototype.setMin=function(r){this.ms=r},e.prototype.setMax=function(r){this.max=r},e.prototype.setJitter=function(r){this.jitter=r}},{}],8:[function(a,t){var e=[].slice;t.exports=function(r,o){if(typeof o=="string"&&(o=r[o]),typeof o!="function")throw new Error("bind() requires a function");var c=e.call(arguments,2);return function(){return o.apply(r,c.concat(e.call(arguments)))}}},{}],9:[function(a,t){function e(o){return o?r(o):void 0}function r(o){for(var c in e.prototype)o[c]=e.prototype[c];return o}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(o,c){return this._callbacks=this._callbacks||{},(this._callbacks[o]=this._callbacks[o]||[]).push(c),this},e.prototype.once=function(o,c){function f(){h.off(o,f),c.apply(this,arguments)}var h=this;return this._callbacks=this._callbacks||{},f.fn=c,this.on(o,f),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(o,c){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var f=this._callbacks[o];if(!f)return this;if(arguments.length==1)return delete this._callbacks[o],this;for(var h,d=0;d<f.length;d++)if(h=f[d],h===c||h.fn===c){f.splice(d,1);break}return this},e.prototype.emit=function(o){this._callbacks=this._callbacks||{};var c=[].slice.call(arguments,1),f=this._callbacks[o];if(f){f=f.slice(0);for(var h=0,d=f.length;d>h;++h)f[h].apply(this,c)}return this},e.prototype.listeners=function(o){return this._callbacks=this._callbacks||{},this._callbacks[o]||[]},e.prototype.hasListeners=function(o){return!!this.listeners(o).length}},{}],10:[function(a,t){function e(o){return e.enabled(o)?function(c){c=r(c);var f=new Date,h=f-(e[o]||f);e[o]=f,c=o+" "+c+" +"+e.humanize(h),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}function r(o){return o instanceof Error?o.stack||o.message:o}t.exports=e,e.names=[],e.skips=[],e.enable=function(o){try{localStorage.debug=o}catch{}for(var c=(o||"").split(/[\s,]+/),f=c.length,h=0;f>h;h++)o=c[h].replace("*",".*?"),o[0]==="-"?e.skips.push(new RegExp("^"+o.substr(1)+"$")):e.names.push(new RegExp("^"+o+"$"))},e.disable=function(){e.enable("")},e.humanize=function(o){var c=1e3,f=6e4,h=60*f;return o>=h?(o/h).toFixed(1)+"h":o>=f?(o/f).toFixed(1)+"m":o>=c?(o/c|0)+"s":o+"ms"},e.enabled=function(o){for(var c=0,f=e.skips.length;f>c;c++)if(e.skips[c].test(o))return!1;for(var c=0,f=e.names.length;f>c;c++)if(e.names[c].test(o))return!0;return!1};try{window.localStorage&&e.enable(localStorage.debug)}catch{}},{}],11:[function(a,t){t.exports=a("./lib/")},{"./lib/":12}],12:[function(a,t){t.exports=a("./socket"),t.exports.parser=a("engine.io-parser")},{"./socket":13,"engine.io-parser":25}],13:[function(a,t){(function(e){function r(n,p){if(!(this instanceof r))return new r(n,p);if(p=p||{},n&&typeof n=="object"&&(p=n,n=null),n&&(n=u(n),p.host=n.host,p.secure=n.protocol=="https"||n.protocol=="wss",p.port=n.port,n.query&&(p.query=n.query)),this.secure=p.secure!=null?p.secure:e.location&&location.protocol=="https:",p.host){var g=p.host.split(":");p.hostname=g.shift(),g.length?p.port=g.pop():p.port||(p.port=this.secure?"443":"80")}this.agent=p.agent||!1,this.hostname=p.hostname||(e.location?location.hostname:"localhost"),this.port=p.port||(e.location&&location.port?location.port:this.secure?443:80),this.query=p.query||{},typeof this.query=="string"&&(this.query=s.decode(this.query)),this.upgrade=p.upgrade!==!1,this.path=(p.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!p.forceJSONP,this.jsonp=p.jsonp!==!1,this.forceBase64=!!p.forceBase64,this.enablesXDR=!!p.enablesXDR,this.timestampParam=p.timestampParam||"t",this.timestampRequests=p.timestampRequests,this.transports=p.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.callbackBuffer=[],this.policyPort=p.policyPort||843,this.rememberUpgrade=p.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=p.onlyBinaryUpgrades,this.pfx=p.pfx||null,this.key=p.key||null,this.passphrase=p.passphrase||null,this.cert=p.cert||null,this.ca=p.ca||null,this.ciphers=p.ciphers||null,this.rejectUnauthorized=p.rejectUnauthorized||null,this.open()}function o(n){var p={};for(var g in n)n.hasOwnProperty(g)&&(p[g]=n[g]);return p}var c=a("./transports"),f=a("component-emitter"),h=a("debug")("engine.io-client:socket"),d=a("indexof"),i=a("engine.io-parser"),u=a("parseuri"),l=a("parsejson"),s=a("parseqs");t.exports=r,r.priorWebsocketSuccess=!1,f(r.prototype),r.protocol=i.protocol,r.Socket=r,r.Transport=a("./transport"),r.transports=a("./transports"),r.parser=a("engine.io-parser"),r.prototype.createTransport=function(n){h('creating transport "%s"',n);var p=o(this.query);p.EIO=i.protocol,p.transport=n,this.id&&(p.sid=this.id);var g=new c[n]({agent:this.agent,hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:p,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 g},r.prototype.open=function(){var p;if(this.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!=-1)p="websocket";else{if(this.transports.length==0){var n=this;return void setTimeout(function(){n.emit("error","No transports available")},0)}p=this.transports[0]}this.readyState="opening";var p;try{p=this.createTransport(p)}catch{return this.transports.shift(),void this.open()}p.open(),this.setTransport(p)},r.prototype.setTransport=function(n){h("setting transport %s",n.name);var p=this;this.transport&&(h("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=n,n.on("drain",function(){p.onDrain()}).on("packet",function(g){p.onPacket(g)}).on("error",function(g){p.onError(g)}).on("close",function(){p.onClose("transport close")})},r.prototype.probe=function(n){function p(){if(w.onlyBinaryUpgrades){var A=!this.supportsBinary&&w.transport.supportsBinary;k=k||A}k||(h('probe transport "%s" opened',n),I.send([{type:"ping",data:"probe"}]),I.once("packet",function(v){if(!k)if(v.type=="pong"&&v.data=="probe"){if(h('probe transport "%s" pong',n),w.upgrading=!0,w.emit("upgrading",I),!I)return;r.priorWebsocketSuccess=I.name=="websocket",h('pausing current transport "%s"',w.transport.name),w.transport.pause(function(){k||w.readyState!="closed"&&(h("changing transport and sending upgrade packet"),F(),w.setTransport(I),I.send([{type:"upgrade"}]),w.emit("upgrade",I),I=null,w.upgrading=!1,w.flush())})}else{h('probe transport "%s" failed',n);var m=new Error("probe error");m.transport=I.name,w.emit("upgradeError",m)}}))}function g(){k||(k=!0,F(),I.close(),I=null)}function y(A){var v=new Error("probe error: "+A);v.transport=I.name,g(),h('probe transport "%s" failed because of error: %s',n,A),w.emit("upgradeError",v)}function b(){y("transport closed")}function j(){y("socket closed")}function U(A){I&&A.name!=I.name&&(h('"%s" works - aborting "%s"',A.name,I.name),g())}function F(){I.removeListener("open",p),I.removeListener("error",y),I.removeListener("close",b),w.removeListener("close",j),w.removeListener("upgrading",U)}h('probing transport "%s"',n);var I=this.createTransport(n,{probe:1}),k=!1,w=this;r.priorWebsocketSuccess=!1,I.once("open",p),I.once("error",y),I.once("close",b),this.once("close",j),this.once("upgrading",U),I.open()},r.prototype.onOpen=function(){if(h("socket open"),this.readyState="open",r.priorWebsocketSuccess=this.transport.name=="websocket",this.emit("open"),this.flush(),this.readyState=="open"&&this.upgrade&&this.transport.pause){h("starting upgrade probes");for(var n=0,p=this.upgrades.length;p>n;n++)this.probe(this.upgrades[n])}},r.prototype.onPacket=function(n){if(this.readyState=="opening"||this.readyState=="open")switch(h('socket receive: type "%s", data "%s"',n.type,n.data),this.emit("packet",n),this.emit("heartbeat"),n.type){case"open":this.onHandshake(l(n.data));break;case"pong":this.setPing();break;case"error":var p=new Error("server error");p.code=n.data,this.emit("error",p);break;case"message":this.emit("data",n.data),this.emit("message",n.data)}else h('packet received with socket readyState "%s"',this.readyState)},r.prototype.onHandshake=function(n){this.emit("handshake",n),this.id=n.sid,this.transport.query.sid=n.sid,this.upgrades=this.filterUpgrades(n.upgrades),this.pingInterval=n.pingInterval,this.pingTimeout=n.pingTimeout,this.onOpen(),this.readyState!="closed"&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},r.prototype.onHeartbeat=function(n){clearTimeout(this.pingTimeoutTimer);var p=this;p.pingTimeoutTimer=setTimeout(function(){p.readyState!="closed"&&p.onClose("ping timeout")},n||p.pingInterval+p.pingTimeout)},r.prototype.setPing=function(){var n=this;clearTimeout(n.pingIntervalTimer),n.pingIntervalTimer=setTimeout(function(){h("writing ping packet - expecting pong within %sms",n.pingTimeout),n.ping(),n.onHeartbeat(n.pingTimeout)},n.pingInterval)},r.prototype.ping=function(){this.sendPacket("ping")},r.prototype.onDrain=function(){for(var n=0;n<this.prevBufferLen;n++)this.callbackBuffer[n]&&this.callbackBuffer[n]();this.writeBuffer.splice(0,this.prevBufferLen),this.callbackBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length==0?this.emit("drain"):this.flush()},r.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"))},r.prototype.write=r.prototype.send=function(n,p){return this.sendPacket("message",n,p),this},r.prototype.sendPacket=function(n,p,g){if(this.readyState!="closing"&&this.readyState!="closed"){var y={type:n,data:p};this.emit("packetCreate",y),this.writeBuffer.push(y),this.callbackBuffer.push(g),this.flush()}},r.prototype.close=function(){function n(){y.onClose("forced close"),h("socket closing - telling transport to close"),y.transport.close()}function p(){y.removeListener("upgrade",p),y.removeListener("upgradeError",p),n()}function g(){y.once("upgrade",p),y.once("upgradeError",p)}if(this.readyState=="opening"||this.readyState=="open"){this.readyState="closing";var y=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?g():n()}):this.upgrading?g():n()}return this},r.prototype.onError=function(n){h("socket error %j",n),r.priorWebsocketSuccess=!1,this.emit("error",n),this.onClose("transport error",n)},r.prototype.onClose=function(n,p){if(this.readyState=="opening"||this.readyState=="open"||this.readyState=="closing"){h('socket close with reason: "%s"',n);var g=this;clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),setTimeout(function(){g.writeBuffer=[],g.callbackBuffer=[],g.prevBufferLen=0},0),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",n,p)}},r.prototype.filterUpgrades=function(n){for(var p=[],g=0,y=n.length;y>g;g++)~d(this.transports,n[g])&&p.push(n[g]);return p}}).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(a,t){function e(c){this.path=c.path,this.hostname=c.hostname,this.port=c.port,this.secure=c.secure,this.query=c.query,this.timestampParam=c.timestampParam,this.timestampRequests=c.timestampRequests,this.readyState="",this.agent=c.agent||!1,this.socket=c.socket,this.enablesXDR=c.enablesXDR,this.pfx=c.pfx,this.key=c.key,this.passphrase=c.passphrase,this.cert=c.cert,this.ca=c.ca,this.ciphers=c.ciphers,this.rejectUnauthorized=c.rejectUnauthorized}var r=a("engine.io-parser"),o=a("component-emitter");t.exports=e,o(e.prototype),e.timestamps=0,e.prototype.onError=function(c,f){var h=new Error(c);return h.type="TransportError",h.description=f,this.emit("error",h),this},e.prototype.open=function(){return(this.readyState=="closed"||this.readyState=="")&&(this.readyState="opening",this.doOpen()),this},e.prototype.close=function(){return(this.readyState=="opening"||this.readyState=="open")&&(this.doClose(),this.onClose()),this},e.prototype.send=function(c){if(this.readyState!="open")throw new Error("Transport not open");this.write(c)},e.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},e.prototype.onData=function(c){var f=r.decodePacket(c,this.socket.binaryType);this.onPacket(f)},e.prototype.onPacket=function(c){this.emit("packet",c)},e.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},{"component-emitter":9,"engine.io-parser":25}],15:[function(a,t,e){(function(r){function o(i){var u,l=!1,s=!1,n=i.jsonp!==!1;if(r.location){var p=location.protocol=="https:",g=location.port;g||(g=p?443:80),l=i.hostname!=location.hostname||g!=i.port,s=i.secure!=p}if(i.xdomain=l,i.xscheme=s,u=new c(i),"open"in u&&!i.forceJSONP)return new f(i);if(!n)throw new Error("JSONP disabled");return new h(i)}var c=a("xmlhttprequest"),f=a("./polling-xhr"),h=a("./polling-jsonp"),d=a("./websocket");e.polling=o,e.websocket=d}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling-jsonp":16,"./polling-xhr":17,"./websocket":19,xmlhttprequest:20}],16:[function(a,t){(function(e){function r(){}function o(u){c.call(this,u),this.query=this.query||{},h||(e.___eio||(e.___eio=[]),h=e.___eio),this.index=h.length;var l=this;h.push(function(s){l.onData(s)}),this.query.j=this.index,e.document&&e.addEventListener&&e.addEventListener("beforeunload",function(){l.script&&(l.script.onerror=r)},!1)}var c=a("./polling"),f=a("component-inherit");t.exports=o;var h,d=/\n/g,i=/\\n/g;f(o,c),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),c.prototype.doClose.call(this)},o.prototype.doPoll=function(){var u=this,l=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),l.async=!0,l.src=this.uri(),l.onerror=function(p){u.onError("jsonp poll error",p)};var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(l,s),this.script=l;var n=typeof navigator<"u"&&/gecko/i.test(navigator.userAgent);n&&setTimeout(function(){var p=document.createElement("iframe");document.body.appendChild(p),document.body.removeChild(p)},100)},o.prototype.doWrite=function(u,l){function s(){n(),l()}function n(){if(p.iframe)try{p.form.removeChild(p.iframe)}catch(F){p.onError("jsonp polling iframe removal error",F)}try{var U='<iframe src="javascript:0" name="'+p.iframeId+'">';g=document.createElement(U)}catch{g=document.createElement("iframe"),g.name=p.iframeId,g.src="javascript:0"}g.id=p.iframeId,p.form.appendChild(g),p.iframe=g}var p=this;if(!this.form){var g,y=document.createElement("form"),b=document.createElement("textarea"),j=this.iframeId="eio_iframe_"+this.index;y.className="socketio",y.style.position="absolute",y.style.top="-1000px",y.style.left="-1000px",y.target=j,y.method="POST",y.setAttribute("accept-charset","utf-8"),b.name="d",y.appendChild(b),document.body.appendChild(y),this.form=y,this.area=b}this.form.action=this.uri(),n(),u=u.replace(i,`\\
|
|
7
|
+
`),this.area.value=u.replace(d,"\\n");try{this.form.submit()}catch{}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){p.iframe.readyState=="complete"&&s()}:this.iframe.onload=s}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-inherit":21}],17:[function(a,t){(function(e){function r(){}function o(s){if(d.call(this,s),e.location){var n=location.protocol=="https:",p=location.port;p||(p=n?443:80),this.xd=s.hostname!=e.location.hostname||p!=s.port,this.xs=s.secure!=n}}function c(s){this.method=s.method||"GET",this.uri=s.uri,this.xd=!!s.xd,this.xs=!!s.xs,this.async=s.async!==!1,this.data=s.data!=null?s.data:null,this.agent=s.agent,this.isBinary=s.isBinary,this.supportsBinary=s.supportsBinary,this.enablesXDR=s.enablesXDR,this.pfx=s.pfx,this.key=s.key,this.passphrase=s.passphrase,this.cert=s.cert,this.ca=s.ca,this.ciphers=s.ciphers,this.rejectUnauthorized=s.rejectUnauthorized,this.create()}function f(){for(var s in c.requests)c.requests.hasOwnProperty(s)&&c.requests[s].abort()}var h=a("xmlhttprequest"),d=a("./polling"),i=a("component-emitter"),u=a("component-inherit"),l=a("debug")("engine.io-client:polling-xhr");t.exports=o,t.exports.Request=c,u(o,d),o.prototype.supportsBinary=!0,o.prototype.request=function(s){return s=s||{},s.uri=this.uri(),s.xd=this.xd,s.xs=this.xs,s.agent=this.agent||!1,s.supportsBinary=this.supportsBinary,s.enablesXDR=this.enablesXDR,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,new c(s)},o.prototype.doWrite=function(s,n){var p=typeof s!="string"&&s!==void 0,g=this.request({method:"POST",data:s,isBinary:p}),y=this;g.on("success",n),g.on("error",function(b){y.onError("xhr post error",b)}),this.sendXhr=g},o.prototype.doPoll=function(){l("xhr poll");var s=this.request(),n=this;s.on("data",function(p){n.onData(p)}),s.on("error",function(p){n.onError("xhr poll error",p)}),this.pollXhr=s},i(c.prototype),c.prototype.create=function(){var s={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};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;var n=this.xhr=new h(s),p=this;try{if(l("xhr open %s: %s",this.method,this.uri),n.open(this.method,this.uri,this.async),this.supportsBinary&&(n.responseType="arraybuffer"),this.method=="POST")try{this.isBinary?n.setRequestHeader("Content-type","application/octet-stream"):n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}"withCredentials"in n&&(n.withCredentials=!0),this.hasXDR()?(n.onload=function(){p.onLoad()},n.onerror=function(){p.onError(n.responseText)}):n.onreadystatechange=function(){n.readyState==4&&(n.status==200||n.status==1223?p.onLoad():setTimeout(function(){p.onError(n.status)},0))},l("xhr data %s",this.data),n.send(this.data)}catch(g){return void setTimeout(function(){p.onError(g)},0)}e.document&&(this.index=c.requestsCount++,c.requests[this.index]=this)},c.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},c.prototype.onData=function(s){this.emit("data",s),this.onSuccess()},c.prototype.onError=function(s){this.emit("error",s),this.cleanup(!0)},c.prototype.cleanup=function(s){if(typeof this.xhr<"u"&&this.xhr!==null){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=r:this.xhr.onreadystatechange=r,s)try{this.xhr.abort()}catch{}e.document&&delete c.requests[this.index],this.xhr=null}},c.prototype.onLoad=function(){var s;try{var n;try{n=this.xhr.getResponseHeader("Content-Type").split(";")[0]}catch{}s=n==="application/octet-stream"?this.xhr.response:this.supportsBinary?"ok":this.xhr.responseText}catch(p){this.onError(p)}s!=null&&this.onData(s)},c.prototype.hasXDR=function(){return typeof e.XDomainRequest<"u"&&!this.xs&&this.enablesXDR},c.prototype.abort=function(){this.cleanup()},e.document&&(c.requestsCount=0,c.requests={},e.attachEvent?e.attachEvent("onunload",f):e.addEventListener&&e.addEventListener("beforeunload",f,!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(a,t){function e(i){var u=i&&i.forceBase64;(!d||u)&&(this.supportsBinary=!1),r.call(this,i)}var r=a("../transport"),o=a("parseqs"),c=a("engine.io-parser"),f=a("component-inherit"),h=a("debug")("engine.io-client:polling");t.exports=e;var d=function(){var i=a("xmlhttprequest"),u=new i({xdomain:!1});return u.responseType!=null}();f(e,r),e.prototype.name="polling",e.prototype.doOpen=function(){this.poll()},e.prototype.pause=function(i){function u(){h("paused"),l.readyState="paused",i()}var l=this;if(this.readyState="pausing",this.polling||!this.writable){var s=0;this.polling&&(h("we are currently polling - waiting to pause"),s++,this.once("pollComplete",function(){h("pre-pause polling complete"),--s||u()})),this.writable||(h("we are currently writing - waiting to pause"),s++,this.once("drain",function(){h("pre-pause writing complete"),--s||u()}))}else u()},e.prototype.poll=function(){h("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},e.prototype.onData=function(i){var u=this;h("polling got data %s",i);var l=function(s){return u.readyState=="opening"&&u.onOpen(),s.type=="close"?(u.onClose(),!1):void u.onPacket(s)};c.decodePayload(i,this.socket.binaryType,l),this.readyState!="closed"&&(this.polling=!1,this.emit("pollComplete"),this.readyState=="open"?this.poll():h('ignoring poll - transport state "%s"',this.readyState))},e.prototype.doClose=function(){function i(){h("writing close packet"),u.write([{type:"close"}])}var u=this;this.readyState=="open"?(h("transport open - closing"),i()):(h("transport not open - deferring close"),this.once("open",i))},e.prototype.write=function(i){var l=this;this.writable=!1;var u=function(){l.writable=!0,l.emit("drain")},l=this;c.encodePayload(i,this.supportsBinary,function(s){l.doWrite(s,u)})},e.prototype.uri=function(){var i=this.query||{},u=this.secure?"https":"http",l="";return this.timestampRequests!==!1&&(i[this.timestampParam]=+new Date+"-"+r.timestamps++),this.supportsBinary||i.sid||(i.b64=1),i=o.encode(i),this.port&&(u=="https"&&this.port!=443||u=="http"&&this.port!=80)&&(l=":"+this.port),i.length&&(i="?"+i),u+"://"+this.hostname+l+this.path+i}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,xmlhttprequest:20}],19:[function(a,t){function e(i){var u=i&&i.forceBase64;u&&(this.supportsBinary=!1),r.call(this,i)}var r=a("../transport"),o=a("engine.io-parser"),c=a("parseqs"),f=a("component-inherit"),h=a("debug")("engine.io-client:websocket"),d=a("ws");t.exports=e,f(e,r),e.prototype.name="websocket",e.prototype.supportsBinary=!0,e.prototype.doOpen=function(){if(this.check()){var i=this.uri(),u=void 0,l={agent:this.agent};l.pfx=this.pfx,l.key=this.key,l.passphrase=this.passphrase,l.cert=this.cert,l.ca=this.ca,l.ciphers=this.ciphers,l.rejectUnauthorized=this.rejectUnauthorized,this.ws=new d(i,u,l),this.ws.binaryType===void 0&&(this.supportsBinary=!1),this.ws.binaryType="arraybuffer",this.addEventListeners()}},e.prototype.addEventListeners=function(){var i=this;this.ws.onopen=function(){i.onOpen()},this.ws.onclose=function(){i.onClose()},this.ws.onmessage=function(u){i.onData(u.data)},this.ws.onerror=function(u){i.onError("websocket error",u)}},typeof navigator<"u"&&/iPad|iPhone|iPod/i.test(navigator.userAgent)&&(e.prototype.onData=function(i){var u=this;setTimeout(function(){r.prototype.onData.call(u,i)},0)}),e.prototype.write=function(i){function u(){l.writable=!0,l.emit("drain")}var l=this;this.writable=!1;for(var s=0,n=i.length;n>s;s++)o.encodePacket(i[s],this.supportsBinary,function(p){try{l.ws.send(p)}catch{h("websocket closed before onclose event")}});setTimeout(u,0)},e.prototype.onClose=function(){r.prototype.onClose.call(this)},e.prototype.doClose=function(){typeof this.ws<"u"&&this.ws.close()},e.prototype.uri=function(){var i=this.query||{},u=this.secure?"wss":"ws",l="";return this.port&&(u=="wss"&&this.port!=443||u=="ws"&&this.port!=80)&&(l=":"+this.port),this.timestampRequests&&(i[this.timestampParam]=+new Date),this.supportsBinary||(i.b64=1),i=c.encode(i),i.length&&(i="?"+i),u+"://"+this.hostname+l+this.path+i},e.prototype.check=function(){return!(!d||"__initialize"in d&&this.name===e.prototype.name)}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,ws:35}],20:[function(a,t){var e=a("has-cors");t.exports=function(r){var o=r.xdomain,c=r.xscheme,f=r.enablesXDR;try{if(typeof XMLHttpRequest<"u"&&(!o||e))return new XMLHttpRequest}catch{}try{if(typeof XDomainRequest<"u"&&!c&&f)return new XDomainRequest}catch{}if(!o)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch{}}},{"has-cors":38}],21:[function(a,t){t.exports=function(e,r){var o=function(){};o.prototype=r.prototype,e.prototype=new o,e.prototype.constructor=e}},{}],22:[function(a,t,e){function r(){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 d=arguments,i=this.useColors;if(d[0]=(i?"%c":"")+this.namespace+(i?" %c":" ")+d[0]+(i?"%c ":" ")+"+"+e.humanize(this.diff),!i)return d;var u="color: "+this.color;d=[d[0],u,"color: inherit"].concat(Array.prototype.slice.call(d,1));var l=0,s=0;return d[0].replace(/%[a-z%]/g,function(n){n!=="%%"&&(l++,n==="%c"&&(s=l))}),d.splice(s,0,u),d}function c(){return typeof console=="object"&&typeof console.log=="function"&&Function.prototype.apply.call(console.log,console,arguments)}function f(d){try{d==null?localStorage.removeItem("debug"):localStorage.debug=d}catch{}}function h(){var d;try{d=localStorage.debug}catch{}return d}e=t.exports=a("./debug"),e.log=c,e.formatArgs=o,e.save=f,e.load=h,e.useColors=r,e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(d){return JSON.stringify(d)},e.enable(h())},{"./debug":23}],23:[function(a,t,e){function r(){return e.colors[u++%e.colors.length]}function o(l){function s(){}function n(){var g=n,y=+new Date,b=y-(i||y);g.diff=b,g.prev=i,g.curr=y,i=y,g.useColors==null&&(g.useColors=e.useColors()),g.color==null&&g.useColors&&(g.color=r());var j=Array.prototype.slice.call(arguments);j[0]=e.coerce(j[0]),typeof j[0]!="string"&&(j=["%o"].concat(j));var U=0;j[0]=j[0].replace(/%([a-z%])/g,function(I,k){if(I==="%%")return I;U++;var w=e.formatters[k];if(typeof w=="function"){var A=j[U];I=w.call(g,A),j.splice(U,1),U--}return I}),typeof e.formatArgs=="function"&&(j=e.formatArgs.apply(g,j));var F=n.log||e.log||console.log.bind(console);F.apply(g,j)}s.enabled=!1,n.enabled=!0;var p=e.enabled(l)?n:s;return p.namespace=l,p}function c(l){e.save(l);for(var s=(l||"").split(/[\s,]+/),n=s.length,p=0;n>p;p++)s[p]&&(l=s[p].replace(/\*/g,".*?"),l[0]==="-"?e.skips.push(new RegExp("^"+l.substr(1)+"$")):e.names.push(new RegExp("^"+l+"$")))}function f(){e.enable("")}function h(l){var s,n;for(s=0,n=e.skips.length;n>s;s++)if(e.skips[s].test(l))return!1;for(s=0,n=e.names.length;n>s;s++)if(e.names[s].test(l))return!0;return!1}function d(l){return l instanceof Error?l.stack||l.message:l}e=t.exports=o,e.coerce=d,e.disable=f,e.enable=c,e.enabled=h,e.humanize=a("ms"),e.names=[],e.skips=[],e.formatters={};var i,u=0},{ms:24}],24:[function(a,t){function e(l){var s=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(l);if(s){var n=parseFloat(s[1]),p=(s[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"y":return n*u;case"days":case"day":case"d":return n*i;case"hours":case"hour":case"h":return n*d;case"minutes":case"minute":case"m":return n*h;case"seconds":case"second":case"s":return n*f;case"ms":return n}}}function r(l){return l>=i?Math.round(l/i)+"d":l>=d?Math.round(l/d)+"h":l>=h?Math.round(l/h)+"m":l>=f?Math.round(l/f)+"s":l+"ms"}function o(l){return c(l,i,"day")||c(l,d,"hour")||c(l,h,"minute")||c(l,f,"second")||l+" ms"}function c(l,s,n){return s>l?void 0:1.5*s>l?Math.floor(l/s)+" "+n:Math.ceil(l/s)+" "+n+"s"}var f=1e3,h=60*f,d=60*h,i=24*d,u=365.25*i;t.exports=function(l,s){return s=s||{},typeof l=="string"?e(l):s.long?o(l):r(l)}},{}],25:[function(a,t,e){(function(r){function o(k,w){var A="b"+e.packets[k.type]+k.data.data;return w(A)}function c(k,w,A){if(!w)return e.encodeBase64Packet(k,A);var v=k.data,m=new Uint8Array(v),O=new Uint8Array(1+v.byteLength);O[0]=j[k.type];for(var x=0;x<m.length;x++)O[x+1]=m[x];return A(O.buffer)}function f(k,w,A){if(!w)return e.encodeBase64Packet(k,A);var v=new FileReader;return v.onload=function(){k.data=v.result,e.encodePacket(k,w,!0,A)},v.readAsArrayBuffer(k.data)}function h(k,w,A){if(!w)return e.encodeBase64Packet(k,A);if(b)return f(k,w,A);var v=new Uint8Array(1);v[0]=j[k.type];var m=new I([v.buffer,k.data]);return A(m)}function d(k,w,A){for(var v=new Array(k.length),m=n(k.length,A),O=function(R,S,K){w(S,function($,z){v[R]=z,K($,v)})},x=0;x<k.length;x++)O(x,k[x],m)}var i=a("./keys"),u=a("has-binary"),l=a("arraybuffer.slice"),s=a("base64-arraybuffer"),n=a("after"),p=a("utf8"),g=navigator.userAgent.match(/Android/i),y=/PhantomJS/i.test(navigator.userAgent),b=g||y;e.protocol=3;var j=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},U=i(j),F={type:"error",data:"parser error"},I=a("blob");e.encodePacket=function(k,w,A,v){typeof w=="function"&&(v=w,w=!1),typeof A=="function"&&(v=A,A=null);var m=k.data===void 0?void 0:k.data.buffer||k.data;if(r.ArrayBuffer&&m instanceof ArrayBuffer)return c(k,w,v);if(I&&m instanceof r.Blob)return h(k,w,v);if(m&&m.base64)return o(k,v);var O=j[k.type];return k.data!==void 0&&(O+=A?p.encode(String(k.data)):String(k.data)),v(""+O)},e.encodeBase64Packet=function(k,w){var A="b"+e.packets[k.type];if(I&&k.data instanceof I){var v=new FileReader;return v.onload=function(){var S=v.result.split(",")[1];w(A+S)},v.readAsDataURL(k.data)}var m;try{m=String.fromCharCode.apply(null,new Uint8Array(k.data))}catch{for(var O=new Uint8Array(k.data),x=new Array(O.length),R=0;R<O.length;R++)x[R]=O[R];m=String.fromCharCode.apply(null,x)}return A+=r.btoa(m),w(A)},e.decodePacket=function(k,w,A){if(typeof k=="string"||k===void 0){if(k.charAt(0)=="b")return e.decodeBase64Packet(k.substr(1),w);if(A)try{k=p.decode(k)}catch{return F}var m=k.charAt(0);return Number(m)==m&&U[m]?k.length>1?{type:U[m],data:k.substring(1)}:{type:U[m]}:F}var v=new Uint8Array(k),m=v[0],O=l(k,1);return I&&w==="blob"&&(O=new I([O])),{type:U[m],data:O}},e.decodeBase64Packet=function(k,w){var A=U[k.charAt(0)];if(!r.ArrayBuffer)return{type:A,data:{base64:!0,data:k.substr(1)}};var v=s.decode(k.substr(1));return w==="blob"&&I&&(v=new I([v])),{type:A,data:v}},e.encodePayload=function(k,w,A){function v(x){return x.length+":"+x}function m(x,R){e.encodePacket(x,O?w:!1,!0,function(S){R(null,v(S))})}typeof w=="function"&&(A=w,w=null);var O=u(k);return w&&O?I&&!b?e.encodePayloadAsBlob(k,A):e.encodePayloadAsArrayBuffer(k,A):k.length?void d(k,m,function(x,R){return A(R.join(""))}):A("0:")},e.decodePayload=function(k,w,A){if(typeof k!="string")return e.decodePayloadAsBinary(k,w,A);typeof w=="function"&&(A=w,w=null);var v;if(k=="")return A(F,0,1);for(var m,O,x="",R=0,S=k.length;S>R;R++){var K=k.charAt(R);if(K!=":")x+=K;else{if(x==""||x!=(m=Number(x))||(O=k.substr(R+1,m),x!=O.length))return A(F,0,1);if(O.length){if(v=e.decodePacket(O,w,!0),F.type==v.type&&F.data==v.data)return A(F,0,1);var $=A(v,R+m,S);if($===!1)return}R+=m,x=""}}return x!=""?A(F,0,1):void 0},e.encodePayloadAsArrayBuffer=function(k,w){function A(v,m){e.encodePacket(v,!0,!0,function(O){return m(null,O)})}return k.length?void d(k,A,function(v,m){var O=m.reduce(function(S,K){var $;return $=typeof K=="string"?K.length:K.byteLength,S+$.toString().length+$+2},0),x=new Uint8Array(O),R=0;return m.forEach(function(S){var K=typeof S=="string",$=S;if(K){for(var z=new Uint8Array(S.length),q=0;q<S.length;q++)z[q]=S.charCodeAt(q);$=z.buffer}x[R++]=K?0:1;for(var J=$.byteLength.toString(),q=0;q<J.length;q++)x[R++]=parseInt(J[q]);x[R++]=255;for(var z=new Uint8Array($),q=0;q<z.length;q++)x[R++]=z[q]}),w(x.buffer)}):w(new ArrayBuffer(0))},e.encodePayloadAsBlob=function(k,w){function A(v,m){e.encodePacket(v,!0,!0,function(O){var x=new Uint8Array(1);if(x[0]=1,typeof O=="string"){for(var R=new Uint8Array(O.length),S=0;S<O.length;S++)R[S]=O.charCodeAt(S);O=R.buffer,x[0]=0}for(var K=O instanceof ArrayBuffer?O.byteLength:O.size,$=K.toString(),z=new Uint8Array($.length+1),S=0;S<$.length;S++)z[S]=parseInt($[S]);if(z[$.length]=255,I){var q=new I([x.buffer,z.buffer,O]);m(null,q)}})}d(k,A,function(v,m){return w(new I(m))})},e.decodePayloadAsBinary=function(k,w,A){typeof w=="function"&&(A=w,w=null);for(var v=k,m=[],O=!1;v.byteLength>0;){for(var x=new Uint8Array(v),R=x[0]===0,S="",K=1;x[K]!=255;K++){if(S.length>310){O=!0;break}S+=x[K]}if(O)return A(F,0,1);v=l(v,2+S.length),S=parseInt(S);var $=l(v,0,S);if(R)try{$=String.fromCharCode.apply(null,new Uint8Array($))}catch{var z=new Uint8Array($);$="";for(var K=0;K<z.length;K++)$+=String.fromCharCode(z[K])}m.push($),v=l(v,S)}var q=m.length;m.forEach(function(J,se){A(e.decodePacket(J,w,!0),se,q)})}}).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(a,t){t.exports=Object.keys||function(e){var r=[],o=Object.prototype.hasOwnProperty;for(var c in e)o.call(e,c)&&r.push(c);return r}},{}],27:[function(a,t){function e(o,c,f){function h(i,u){if(h.count<=0)throw new Error("after called too many times");--h.count,i?(d=!0,c(i),c=f):h.count!==0||d||c(null,u)}var d=!1;return f=f||r,h.count=o,o===0?c():h}function r(){}t.exports=e},{}],28:[function(a,t){t.exports=function(e,r,o){var c=e.byteLength;if(r=r||0,o=o||c,e.slice)return e.slice(r,o);if(0>r&&(r+=c),0>o&&(o+=c),o>c&&(o=c),r>=c||r>=o||c===0)return new ArrayBuffer(0);for(var f=new Uint8Array(e),h=new Uint8Array(o-r),d=r,i=0;o>d;d++,i++)h[i]=f[d];return h.buffer}},{}],29:[function(a,t,e){(function(r){e.encode=function(o){var c,f=new Uint8Array(o),h=f.length,d="";for(c=0;h>c;c+=3)d+=r[f[c]>>2],d+=r[(3&f[c])<<4|f[c+1]>>4],d+=r[(15&f[c+1])<<2|f[c+2]>>6],d+=r[63&f[c+2]];return h%3===2?d=d.substring(0,d.length-1)+"=":h%3===1&&(d=d.substring(0,d.length-2)+"=="),d},e.decode=function(o){var c,f,h,d,i,u=.75*o.length,l=o.length,s=0;o[o.length-1]==="="&&(u--,o[o.length-2]==="="&&u--);var n=new ArrayBuffer(u),p=new Uint8Array(n);for(c=0;l>c;c+=4)f=r.indexOf(o[c]),h=r.indexOf(o[c+1]),d=r.indexOf(o[c+2]),i=r.indexOf(o[c+3]),p[s++]=f<<2|h>>4,p[s++]=(15&h)<<4|d>>2,p[s++]=(3&d)<<6|63&i;return n}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],30:[function(a,t){(function(e){function r(u){for(var l=0;l<u.length;l++){var s=u[l];if(s.buffer instanceof ArrayBuffer){var n=s.buffer;if(s.byteLength!==n.byteLength){var p=new Uint8Array(s.byteLength);p.set(new Uint8Array(n,s.byteOffset,s.byteLength)),n=p.buffer}u[l]=n}}}function o(u,l){l=l||{};var s=new f;r(u);for(var n=0;n<u.length;n++)s.append(u[n]);return l.type?s.getBlob(l.type):s.getBlob()}function c(u,l){return r(u),new Blob(u,l||{})}var f=e.BlobBuilder||e.WebKitBlobBuilder||e.MSBlobBuilder||e.MozBlobBuilder,h=function(){try{var u=new Blob(["hi"]);return u.size===2}catch{return!1}}(),d=h&&function(){try{var u=new Blob([new Uint8Array([1,2])]);return u.size===2}catch{return!1}}(),i=f&&f.prototype.append&&f.prototype.getBlob;t.exports=function(){return h?d?e.Blob:c:i?o:void 0}()}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],31:[function(a,t,e){(function(r){(function(o){function c(v){for(var m,O,x=[],R=0,S=v.length;S>R;)m=v.charCodeAt(R++),m>=55296&&56319>=m&&S>R?(O=v.charCodeAt(R++),(64512&O)==56320?x.push(((1023&m)<<10)+(1023&O)+65536):(x.push(m),R--)):x.push(m);return x}function f(v){for(var m,O=v.length,x=-1,R="";++x<O;)m=v[x],m>65535&&(m-=65536,R+=F(m>>>10&1023|55296),m=56320|1023&m),R+=F(m);return R}function h(v){if(v>=55296&&57343>=v)throw Error("Lone surrogate U+"+v.toString(16).toUpperCase()+" is not a scalar value")}function d(v,m){return F(v>>m&63|128)}function i(v){if(!(4294967168&v))return F(v);var m="";return 4294965248&v?4294901760&v?!(4292870144&v)&&(m=F(v>>18&7|240),m+=d(v,12),m+=d(v,6)):(h(v),m=F(v>>12&15|224),m+=d(v,6)):m=F(v>>6&31|192),m+=F(63&v|128)}function u(v){for(var m,O=c(v),x=O.length,R=-1,S="";++R<x;)m=O[R],S+=i(m);return S}function l(){if(U>=j)throw Error("Invalid byte index");var v=255&b[U];if(U++,(192&v)==128)return 63&v;throw Error("Invalid continuation byte")}function s(){var v,m,O,x,R;if(U>j)throw Error("Invalid byte index");if(U==j)return!1;if(v=255&b[U],U++,(128&v)==0)return v;if((224&v)==192){var m=l();if(R=(31&v)<<6|m,R>=128)return R;throw Error("Invalid continuation byte")}if((240&v)==224){if(m=l(),O=l(),R=(15&v)<<12|m<<6|O,R>=2048)return h(R),R;throw Error("Invalid continuation byte")}if((248&v)==240&&(m=l(),O=l(),x=l(),R=(15&v)<<18|m<<12|O<<6|x,R>=65536&&1114111>=R))return R;throw Error("Invalid UTF-8 detected")}function n(v){b=c(v),j=b.length,U=0;for(var m,O=[];(m=s())!==!1;)O.push(m);return f(O)}var p=typeof e=="object"&&e,g=typeof t=="object"&&t&&t.exports==p&&t,y=typeof r=="object"&&r;(y.global===y||y.window===y)&&(o=y);var b,j,U,F=String.fromCharCode,I={version:"2.0.0",encode:u,decode:n};if(p&&!p.nodeType)if(g)g.exports=I;else{var k={},w=k.hasOwnProperty;for(var A in I)w.call(I,A)&&(p[A]=I[A])}else o.utf8=I})(this)}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],32:[function(a,t){(function(e){var r=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,c=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,f=/(?:^|:|,)(?:\s*\[)+/g,h=/^\s+/,d=/\s+$/;t.exports=function(i){return typeof i=="string"&&i?(i=i.replace(h,"").replace(d,""),e.JSON&&JSON.parse?JSON.parse(i):r.test(i.replace(o,"@").replace(c,"]").replace(f,""))?new Function("return "+i)():void 0):null}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],33:[function(a,t,e){e.encode=function(r){var o="";for(var c in r)r.hasOwnProperty(c)&&(o.length&&(o+="&"),o+=encodeURIComponent(c)+"="+encodeURIComponent(r[c]));return o},e.decode=function(r){for(var o={},c=r.split("&"),f=0,h=c.length;h>f;f++){var d=c[f].split("=");o[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return o}},{}],34:[function(a,t){var e=/^(?:(?![^:@]+:[^:@\/]*@)(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"];t.exports=function(o){var c=o,f=o.indexOf("["),h=o.indexOf("]");f!=-1&&h!=-1&&(o=o.substring(0,f)+o.substring(f,h).replace(/:/g,";")+o.substring(h,o.length));for(var d=e.exec(o||""),i={},u=14;u--;)i[r[u]]=d[u]||"";return f!=-1&&h!=-1&&(i.source=c,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i}},{}],35:[function(a,t){function e(c,f){return f?new o(c,f):new o(c)}var r=function(){return self}(),o=r.WebSocket||r.MozWebSocket;t.exports=o?e:null,o&&(e.prototype=o.prototype)},{}],36:[function(a,t){(function(e){function r(c){function f(h){if(!h)return!1;if(e.Buffer&&e.Buffer.isBuffer(h)||e.ArrayBuffer&&h instanceof ArrayBuffer||e.Blob&&h instanceof Blob||e.File&&h instanceof File)return!0;if(o(h)){for(var d=0;d<h.length;d++)if(f(h[d]))return!0}else if(h&&typeof h=="object"){h.toJSON&&(h=h.toJSON());for(var i in h)if(Object.prototype.hasOwnProperty.call(h,i)&&f(h[i]))return!0}return!1}return f(c)}var o=a("isarray");t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{isarray:37}],37:[function(a,t){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],38:[function(a,t){var e=a("global");try{t.exports="XMLHttpRequest"in e&&"withCredentials"in new e.XMLHttpRequest}catch{t.exports=!1}},{global:39}],39:[function(a,t){t.exports=function(){return this}()},{}],40:[function(a,t){var e=[].indexOf;t.exports=function(r,o){if(e)return r.indexOf(o);for(var c=0;c<r.length;++c)if(r[c]===o)return c;return-1}},{}],41:[function(a,t,e){var r=Object.prototype.hasOwnProperty;e.keys=Object.keys||function(o){var c=[];for(var f in o)r.call(o,f)&&c.push(f);return c},e.values=function(o){var c=[];for(var f in o)r.call(o,f)&&c.push(o[f]);return c},e.merge=function(o,c){for(var f in c)r.call(c,f)&&(o[f]=c[f]);return o},e.length=function(o){return e.keys(o).length},e.isEmpty=function(o){return e.length(o)==0}},{}],42:[function(a,t){var e=/^(?:(?![^:@]+:[^:@\/]*@)(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"];t.exports=function(o){for(var c=e.exec(o||""),f={},h=14;h--;)f[r[h]]=c[h]||"";return f}},{}],43:[function(a,t,e){(function(r){var o=a("isarray"),c=a("./is-buffer");e.deconstructPacket=function(f){function h(l){if(!l)return l;if(c(l)){var s={_placeholder:!0,num:d.length};return d.push(l),s}if(o(l)){for(var n=new Array(l.length),p=0;p<l.length;p++)n[p]=h(l[p]);return n}if(typeof l=="object"&&!(l instanceof Date)){var n={};for(var g in l)n[g]=h(l[g]);return n}return l}var d=[],i=f.data,u=f;return u.data=h(i),u.attachments=d.length,{packet:u,buffers:d}},e.reconstructPacket=function(f,h){function d(i){if(i&&i._placeholder){var u=h[i.num];return u}if(o(i)){for(var l=0;l<i.length;l++)i[l]=d(i[l]);return i}if(i&&typeof i=="object"){for(var s in i)i[s]=d(i[s]);return i}return i}return f.data=d(f.data),f.attachments=void 0,f},e.removeBlobs=function(f,h){function d(l,s,n){if(!l)return l;if(r.Blob&&l instanceof Blob||r.File&&l instanceof File){i++;var p=new FileReader;p.onload=function(){n?n[s]=this.result:u=this.result,--i||h(u)},p.readAsArrayBuffer(l)}else if(o(l))for(var g=0;g<l.length;g++)d(l[g],g,l);else if(l&&typeof l=="object"&&!c(l))for(var y in l)d(l[y],y,l)}var i=0,u=f;d(u),i||h(u)}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./is-buffer":45,isarray:46}],44:[function(a,t,e){function r(){}function o(g){var y="",b=!1;return y+=g.type,(e.BINARY_EVENT==g.type||e.BINARY_ACK==g.type)&&(y+=g.attachments,y+="-"),g.nsp&&g.nsp!="/"&&(b=!0,y+=g.nsp),g.id!=null&&(b&&(y+=",",b=!1),y+=g.id),g.data!=null&&(b&&(y+=","),y+=l.stringify(g.data)),u("encoded %j as %s",g,y),y}function c(g,y){function b(j){var U=n.deconstructPacket(j),F=o(U.packet),I=U.buffers;I.unshift(F),y(I)}n.removeBlobs(g,b)}function f(){this.reconstructor=null}function h(g){var y={},b=0;if(y.type=Number(g.charAt(0)),e.types[y.type]==null)return i();if(e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type){for(var j="";g.charAt(++b)!="-"&&(j+=g.charAt(b),b!=g.length););if(j!=Number(j)||g.charAt(b)!="-")throw new Error("Illegal attachments");y.attachments=Number(j)}if(g.charAt(b+1)=="/")for(y.nsp="";++b;){var U=g.charAt(b);if(U==","||(y.nsp+=U,b==g.length))break}else y.nsp="/";var F=g.charAt(b+1);if(F!==""&&Number(F)==F){for(y.id="";++b;){var U=g.charAt(b);if(U==null||Number(U)!=U){--b;break}if(y.id+=g.charAt(b),b==g.length)break}y.id=Number(y.id)}if(g.charAt(++b))try{y.data=l.parse(g.substr(b))}catch{return i()}return u("decoded %s as %j",g,y),y}function d(g){this.reconPack=g,this.buffers=[]}function i(){return{type:e.ERROR,data:"parser error"}}var u=a("debug")("socket.io-parser"),l=a("json3"),s=(a("isarray"),a("component-emitter")),n=a("./binary"),p=a("./is-buffer");e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","BINARY_EVENT","ACK","BINARY_ACK","ERROR"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=r,e.Decoder=f,r.prototype.encode=function(g,y){if(u("encoding packet %j",g),e.BINARY_EVENT==g.type||e.BINARY_ACK==g.type)c(g,y);else{var b=o(g);y([b])}},s(f.prototype),f.prototype.add=function(g){var y;if(typeof g=="string")y=h(g),e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type?(this.reconstructor=new d(y),this.reconstructor.reconPack.attachments===0&&this.emit("decoded",y)):this.emit("decoded",y);else{if(!p(g)&&!g.base64)throw new Error("Unknown type: "+g);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");y=this.reconstructor.takeBinaryData(g),y&&(this.reconstructor=null,this.emit("decoded",y))}},f.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},d.prototype.takeBinaryData=function(g){if(this.buffers.push(g),this.buffers.length==this.reconPack.attachments){var y=n.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),y}return null},d.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},{"./binary":43,"./is-buffer":45,"component-emitter":9,debug:10,isarray:46,json3:47}],45:[function(a,t){(function(e){function r(o){return e.Buffer&&e.Buffer.isBuffer(o)||e.ArrayBuffer&&o instanceof ArrayBuffer}t.exports=r}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],46:[function(a,t){t.exports=a(37)},{}],47:[function(a,t,e){(function(r){function o(E){if(o[E]!==h)return o[E];var _;if(E=="bug-string-char-index")_=!1;else if(E=="json")_=o("json-stringify")&&o("json-parse");else{var T,V='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if(E=="json-stringify"){var C=u.stringify,B=typeof C=="function"&&l;if(B){(T=function(){return 1}).toJSON=T;try{B=C(0)==="0"&&C(new Number)==="0"&&C(new String)=='""'&&C(d)===h&&C(h)===h&&C()===h&&C(T)==="1"&&C([T])=="[1]"&&C([h])=="[null]"&&C(null)=="null"&&C([h,d,null])=="[null,null,null]"&&C({a:[T,!0,!1,null,`\0\b
|
|
8
|
+
\f\r `]})==V&&C(null,T)==="1"&&C([1,2],null,1)==`[
|
|
9
9
|
1,
|
|
10
10
|
2
|
|
11
|
-
]`&&C(new Date(-864e13))=='"-271821-04-20T00:00:00.000Z"'&&C(new Date(864e13))=='"+275760-09-13T00:00:00.000Z"'&&C(new Date(-621987552e5))=='"-000001-01-01T00:00:00.000Z"'&&C(new Date(-1))=='"1969-12-31T23:59:59.999Z"'}catch{
|
|
12
|
-
`+
|
|
13
|
-
`+
|
|
14
|
-
`+fe+"]":"["+Q.join(",")+"]":"[]"}else f(
|
|
15
|
-
`+
|
|
16
|
-
`+
|
|
17
|
-
`+fe+"}":"{"+Q.join(",")+"}":"{}";return D.pop(),de}};u.stringify=function(E,_,T){var
|
|
18
|
-
`,102:"\f",114:"\r"},q=function(){throw S=K=null,SyntaxError()},J=function(){for(var E,_,T,P,C,U=K,D=U.length;D>S;)switch(C=U.charCodeAt(S)){case 9:case 10:case 13:case 32:S++;break;case 123:case 125:case 91:case 93:case 58:case 44:return E=j?U.charAt(S):U[S],S++,E;case 34:for(E="@",S++;D>S;)if(C=U.charCodeAt(S),32>C)q();else if(C==92)switch(C=U.charCodeAt(++S)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:E+=z[C],S++;break;case 117:for(_=++S,T=S+4;T>S;S++)C=U.charCodeAt(S),C>=48&&57>=C||C>=97&&102>=C||C>=65&&70>=C||q();E+=$("0x"+U.slice(_,S));break;default:q()}else{if(C==34)break;for(C=U.charCodeAt(S),_=S;C>=32&&C!=92&&C!=34;)C=U.charCodeAt(++S);E+=U.slice(_,S)}if(U.charCodeAt(S)==34)return S++,E;q();default:if(_=S,C==45&&(P=!0,C=U.charCodeAt(++S)),C>=48&&57>=C){for(C==48&&(C=U.charCodeAt(S+1),C>=48&&57>=C)&&q(),P=!1;D>S&&(C=U.charCodeAt(S),C>=48&&57>=C);S++);if(U.charCodeAt(S)==46){for(T=++S;D>T&&(C=U.charCodeAt(T),C>=48&&57>=C);T++);T==S&&q(),S=T}if(C=U.charCodeAt(S),C==101||C==69){for(C=U.charCodeAt(++S),(C==43||C==45)&&S++,T=S;D>T&&(C=U.charCodeAt(T),C>=48&&57>=C);T++);T==S&&q(),S=T}return+U.slice(_,S)}if(P&&q(),U.slice(S,S+4)=="true")return S+=4,!0;if(U.slice(S,S+5)=="false")return S+=5,!1;if(U.slice(S,S+4)=="null")return S+=4,null;q()}return"$"},ne=function(E){var _,T;if(E=="$"&&q(),typeof E=="string"){if((j?E.charAt(0):E[0])=="@")return E.slice(1);if(E=="["){for(_=[];E=J(),E!="]";T||(T=!0))T&&(E==","?(E=J(),E=="]"&&q()):q()),E==","&&q(),_.push(ne(E));return _}if(E=="{"){for(_={};E=J(),E!="}";T||(T=!0))T&&(E==","?(E=J(),E=="}"&&q()):q()),(E==","||typeof E!="string"||(j?E.charAt(0):E[0])!="@"||J()!=":")&&q(),_[E.slice(1)]=ne(J());return _}q()}return E},Ce=function(E,_,T){var P=ke(E,_,T);P===l?delete E[_]:E[_]=P},ke=function(E,_,T){var P,C=E[_];if(typeof C=="object"&&C)if(d.call(C)==y)for(P=C.length;P--;)Ce(C,P,T);else f(C,function(U){Ce(C,U,T)});return T.call(E,_,C)};u.parse=function(E,_){var T,P;return S=0,K=""+E,T=ne(J()),J()!="$"&&q(),S=K=null,_&&d.call(_)==s?ke((P={},P[""]=T,P),"",_):T}}}})(this)},{}],48:[function(a,t){function e(r,o){var h=[];o=o||0;for(var f=o||0;f<r.length;f++)h[f-o]=r[f];return h}t.exports=e},{}]},{},[1])(1)}const ze=Object.freeze(Object.defineProperty({__proto__:null,default:Ge},Symbol.toStringTag,{value:"Module"})),Je=Object.assign({"./v1_3_7.js":ze}),We=/v\d+_\d+_\d+/;function He(a){return typeof a=="function"}const ve=Object.entries(Je).reduce((a,t)=>{var o;const e=t[1].default,r=(o=t[0].match(We))==null?void 0:o[0];return He(e)&&r&&(a[r]=e()),a},{}),Ne=a=>{if(a in ve)return ve[a];throw new Error(`Socket version ${a} not found`)},Ye=(a,...t)=>Ne(a)(...t),Qe={...ve,getSocketVersion:Ne,makeSocketVersion:Ye};var Oe=(a=>(a.RINGING="Ringing",a.TALKING="Talking",a.DIALING="Dialing",a.HOLD="Hold",a))(Oe||{}),_e=(a=>(a.INCOMING="Incoming",a.OUTGOING="Outgoing",a))(_e||{}),te=(a=>(a.CONNECTED="connected",a.DISCONNECTED="disconnected",a.TRYING_TO_CONNECT="tryingToConnect",a))(te||{}),Ie=(a=>(a.AUTOMATIC="Automatic",a.IVR="IVR",a))(Ie||{}),Re=(a=>(a.INCOMINC="Incoming",a.OUTGOING="Outgoing",a.SPY="Spy",a.CLICK2CALL="Click2Call",a))(Re||{}),Be=(a=>(a.RESPONSE_FROM_API_VALID="RESPONSE_FROM_API_VALID",a.RESPONSE_FROM_API_INVALID="RESPONSE_FROM_API_INVALID",a))(Be||{}),L=(a=>(a.ALL_DIALER_STATUS="AllDialersStatus",a.ALL_EXTENSION_STATUS="AllExtensionsStatus",a.ALL_USERS_STATUS="AllUsersStatus",a.CONNECT="connect",a.DISCONNECT="disconnect",a.CONNECT_ERROR_EVENT="connect_error",a.EXTENSION_EVENT="ExtensionEvent",a.KEEP_ALIVE="keepalive",a.KEEP_ALIVE_RESPONSE="keepaliveResponse",a.LOGIN_STATUS="loginStatus",a.LOGIN_SUCCESS="loginSuccess",a.QUEUE_EVENT="QueueEvent",a.ONLINE_STATUS_EVENT="onlineStatusEvent",a.DIALER_EVENT="DialerEvent",a.EXTENSIONS_UPDATED="ExtensionsUpdated",a.ALL_VOICEBOTS_STATUS="AllVoicebotsStatus",a.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED="subscribeToCallFailed",a.VOICEBOT_SUBSCRIBED_TO_CALL="subscribedToCall",a.VOICEBOT_INITIAL_CALL_HISTORY="initialCallHistory",a.VOICEBOT_UNSUBSCRIBED_FROM_CALL="unsubscribedFromCall",a.VOICEBOT_EVENT="VoicebotEvent",a))(L||{}),me=(a=>(a.NEWCALL="NEWCALL",a.ANSWER="ANSWER",a.HOLD="HOLD",a.UNHOLD="UNHOLD",a.HANGUP="HANGUP",a.USER_STATUS_UPDATE="userStatusUpdate",a))(me||{}),Ue=(a=>(a.NORMAL_HANGUP="Normal hangup",a.USER_BUSY="User busy",a.CALL_REJECTED="Call Rejected",a.UNALLOCATED_NUMBER="Unallocated (unassigned) number",a.UNKNOWN="Unknown",a.NO_USER_RESPONDING="No user responding",a.USER_ALERTING="User alerting, no answer",a.ANSWERED_ELSEWHERE="Answered elsewhere",a))(Ue||{}),xe=(a=>(a.ANSWER="ANSWER",a.ABANDONED="ABANDONED",a.EXIT="EXIT",a.JOIN="JOIN",a))(xe||{});class ae{static mapExtensionEvent(t){var f,l;const e=t.reason;let r,o;t.data.currentCall&&(o=this.mapExtensionCall(t,t.data.currentCall));const h=this.mapExtensionData(t,t.data);return e===me.HANGUP?r={...t,reason:e,data:{...h,currentCall:o?{...o,duration:o.callAnswered_UTC_CLIENT?Date.now()-o.callAnswered_UTC_CLIENT:0}:void 0,calls:(f=t.data.calls)==null?void 0:f.map(d=>{const i=this.mapExtensionCall(t,d);return{...i,duration:i.callAnswered_UTC_CLIENT?Date.now()-i.callAnswered_UTC_CLIENT:0}})}}:r={...t,data:{...h,currentCall:o,calls:(l=t.data.calls)==null?void 0:l.map(d=>this.mapExtensionCall(t,d))},reason:e},r}static mapAllExtensionStatus(t){return{...t,extensions:t.extensions.map(e=>{var r;return{...this.mapExtensionData(t,e),currentCall:e.currentCall?this.mapExtensionCall(t,e.currentCall):void 0,calls:(r=e.calls)==null?void 0:r.map(o=>this.mapExtensionCall(t,o))}})}}static mapExtensionData(t,e){return this.configureUTCForObject(e,[{key:"lastAnsweredCallEventEpoch",format:"sec"},{key:"lastCallEventEpoch",format:"sec"},{key:"lastHangupCallEpoch",format:"sec"},{key:"representativeUpdated",format:"ms"}],t.servertime,t.servertimeoffset)}static mapExtensionCall(t,e){return this.configureUTCForObject(e,[{key:"callAnswered",format:"sec"},{key:"callStarted",format:"sec"}],t.servertime,t.servertimeoffset)}static mapQueueCall(t,e){return this.configureUTCForObject(e,[{key:"JoinTimeStamp",format:"sec"},{key:"VHJoinTimeStamp",format:"sec"}],t.servertime,t.servertimeoffset)}static mapLoginStatusEvent(t){return{...t,queues:t.queues.map(e=>({...e,Calls:e.Calls.map(r=>this.mapQueueCall(t,r))}))}}static mapQueueEvent(t){return{...t,data:{...t.data,Calls:t.data.Calls.map(e=>this.mapQueueCall(t,e))}}}static assignProperty(t,e,r){t[e]=r}static configureUTCForObject(t,e,r,o){const h=(r-o*60)*1e3,f=Date.now()-h,l={};return e.forEach(d=>{const i=t[d.key],u=d.key;if(i!==0&&typeof i=="number"&&!isNaN(i)){let c=i;d.format==="ms"&&(c=Math.floor(c/1e3));const s=(c-o*60)*1e3;this.assignProperty(l,`${u}_UTC`,s),this.assignProperty(l,`${u}_UTC_CLIENT`,s+f)}else this.assignProperty(l,`${u}_UTC`,0),this.assignProperty(l,`${u}_UTC_CLIENT`,0)}),{...t,...l}}}var Se=(a=>(a.UPDATE_MONITORED_EXTENSIONS="updateMonitoredExtensions",a.KEEP_ALIVE="keepalive",a.SUBSCRIBE_VOICEBOT_CALL_UPDATES="subscribeVoicebotCallUpdates",a.UNSUBSCRIBE_VOICEBOT_CALL_UPDATES="unsubscribeVoicebotCallUpdates",a))(Se||{});class Ze{constructor(t){X(this,"io");X(this,"ioFunction");X(this,"lastEventTimestamp",new Date().getTime());X(this,"doReconnect",!0);X(this,"connectionState","disconnected");X(this,"keepAliveInterval");X(this,"reconnectTimeout");X(this,"networkReconnectTimeout");X(this,"reconnectionTime",Le.reconnectionDelay);X(this,"maxReconnectionDelay",120);X(this,"networkCleanup",[]);this.eventsSdkClass=t,this.reconnectionTime=t.options.reconnectionDelay,this.setupNetworkListeners()}setupNetworkListeners(){const t=()=>this.closeAllConnections(),e=()=>this.handleNetworkOnline();typeof window<"u"&&"addEventListener"in window&&typeof window.addEventListener=="function"?(window.addEventListener("offline",t),window.addEventListener("online",e),this.networkCleanup.push(()=>window.removeEventListener("offline",t),()=>window.removeEventListener("online",e))):typeof self<"u"&&"addEventListener"in self&&typeof self.addEventListener=="function"&&(self.addEventListener("offline",t),self.addEventListener("online",e),this.networkCleanup.push(()=>self.removeEventListener("offline",t),()=>self.removeEventListener("online",e)))}handleNetworkOnline(){this.networkReconnectTimeout&&clearTimeout(this.networkReconnectTimeout),this.networkReconnectTimeout=setTimeout(()=>{this.connectionState==="disconnected"&&this.doReconnect&&this.eventsSdkClass.connect(ee.NEXT)},500)}getSocketIoFunction(t){const e=t.split("v="),r="v".concat(e[e.length-1]).replaceAll(".","_");this.ioFunction=Qe.getSocketVersion(r)}initSocketConnection(){if(this.connectionState!=="disconnected")return;this.connectionState="connecting";const t=this.eventsSdkClass.authClass.token,e=this.eventsSdkClass.options.protocol,r=this.eventsSdkClass.server;try{const o=r?r.Domain:this.eventsSdkClass.URL,h=r?`${e}://${o}`:this.eventsSdkClass.URL,f={reconnection:!1,upgrade:!1,transports:["websocket"],forceNew:!0,query:{token:t},timeout:this.eventsSdkClass.options.timeout};if(this.ioFunction&&h)this.io=this.ioFunction(h,f),this.initSocketEvents(),this.eventsSdkClass.eventEmitterClass.emit(L.ONLINE_STATUS_EVENT,{attemptToConnect:h,connectionStatus:te.TRYING_TO_CONNECT}),this.eventsSdkClass.loggerClass.sdkAttemptToConnect(o);else throw new Error("Socket server url not defined")}catch(o){this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(o)}}clearKeepAliveInterval(){this.keepAliveInterval&&(clearInterval(this.keepAliveInterval),this.keepAliveInterval=void 0)}initKeepAlive(){this.clearKeepAliveInterval(),this.keepAliveInterval=setInterval(async()=>{new Date().getTime()>this.lastEventTimestamp+this.eventsSdkClass.options.keepAliveTimeout&&this.io&&this.connectionState==="connected"&&this.eventsSdkClass.authClass.token&&(this.eventsSdkClass.emit(Se.KEEP_ALIVE,this.eventsSdkClass.authClass.token),this.eventsSdkClass.loggerClass.keepAliveEmit())},this.eventsSdkClass.options.keepAliveTimeout)}async closeAllConnections(){if(this.clearKeepAliveInterval(),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.networkReconnectTimeout&&(clearTimeout(this.networkReconnectTimeout),this.networkReconnectTimeout=void 0),this.io){const t=this.io;this.io=void 0;try{await Promise.race([new Promise(e=>{t.on("disconnect",()=>e()),t.removeAllListeners(),t.close(),t.disconnect()}),new Promise(e=>setTimeout(e,1e3))])}catch{}}this.connectionState="disconnected",this.eventsSdkClass.loggerClass.stop(),oe.clearSessionStorage()}initSocketEvents(){this.io&&(this.io.removeAllListeners(),this.io.on(L.LOGIN_SUCCESS,t=>this.onLoginSuccessEvent(t,L.LOGIN_SUCCESS)).on(L.QUEUE_EVENT,t=>this.onQueueEvent(t,L.QUEUE_EVENT)).on(L.EXTENSION_EVENT,t=>this.onExtensionEvent(t,L.EXTENSION_EVENT)).on(L.DIALER_EVENT,t=>this.onDialerEvent(t,L.DIALER_EVENT)).on(L.LOGIN_STATUS,t=>this.onLoginStatusEvent(t,L.LOGIN_STATUS)).on(L.ALL_EXTENSION_STATUS,t=>this.onAllExtensionStatus(t,L.ALL_EXTENSION_STATUS)).on(L.ALL_DIALER_STATUS,t=>this.onAllDialerStatus(t,L.ALL_DIALER_STATUS)).on(L.KEEP_ALIVE_RESPONSE,t=>this.onKeepAliveResponse(t)).on(L.EXTENSIONS_UPDATED,t=>this.onExtensionsUpdatedEvent(t,L.EXTENSIONS_UPDATED)).on(L.CONNECT,()=>this.onConnect()).on(L.DISCONNECT,t=>this.onDisconnect(t)).on(L.CONNECT_ERROR_EVENT,t=>this.onConnectError(t)).on(L.ALL_VOICEBOTS_STATUS,t=>this.onAllVoicebotsStatus(t,L.ALL_VOICEBOTS_STATUS)).on(L.VOICEBOT_EVENT,t=>this.onVoicebotEvent(t,L.VOICEBOT_EVENT)).on(L.VOICEBOT_SUBSCRIBED_TO_CALL,t=>this.onVoicebotSubscribedToCall(t,L.VOICEBOT_SUBSCRIBED_TO_CALL)).on(L.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED,t=>this.onVoicebotSubscribeToCallFailed(t,L.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED)).on(L.VOICEBOT_INITIAL_CALL_HISTORY,t=>this.onVoicebotInitialCallHistory(t,L.VOICEBOT_INITIAL_CALL_HISTORY)).on(L.VOICEBOT_UNSUBSCRIBED_FROM_CALL,t=>this.onVoicebotUnsubscribedFromCall(t,L.VOICEBOT_UNSUBSCRIBED_FROM_CALL)))}updateEventTimestamp(){this.lastEventTimestamp=new Date().getTime()}onLoginSuccessEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onQueueEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ae.mapQueueEvent(t))}onExtensionEvent(t,e){this.updateEventTimestamp();const r=ae.mapExtensionEvent(t);r&&(this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,r))}onDialerEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onAllVoicebotsStatus(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotSubscribedToCall(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotSubscribeToCallFailed(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotInitialCallHistory(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotUnsubscribedFromCall(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onLoginStatusEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ae.mapLoginStatusEvent(t))}onAllExtensionStatus(t,e){this.updateEventTimestamp();const r=ae.mapAllExtensionStatus(t);this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,r)}onAllDialerStatus(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onKeepAliveResponse(t){if(this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.keepAliveResponse(t),t.errorCode){this.closeAllConnections().then(()=>{this.doReconnect&&this.connectionState==="disconnected"&&this.scheduleReconnect()});return}}onExtensionsUpdatedEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onConnect(){this.connectionState="connected",this.reconnectionTime=this.eventsSdkClass.options.reconnectionDelay,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.eventsSdkClass.eventEmitterClass.emit(L.ONLINE_STATUS_EVENT,{connectionStatus:te.CONNECTED}),this.eventsSdkClass.loggerClass.start().then(()=>{this.eventsSdkClass.loggerClass.sdkConnectionSuccess()})}scheduleReconnect(){!this.doReconnect||this.reconnectTimeout||(this.eventsSdkClass.eventEmitterClass.emit(L.ONLINE_STATUS_EVENT,{connectionStatus:te.TRYING_TO_CONNECT}),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=void 0,this.reconnectionTime=Math.min(this.reconnectionTime*2,this.maxReconnectionDelay),this.reconnectionTime>this.maxReconnectionDelay&&(this.reconnectionTime=this.eventsSdkClass.options.reconnectionDelay),this.eventsSdkClass.connect(ee.NEXT)},this.reconnectionTime*1e3))}onDisconnect(t){if(this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkDisconnect([t]),!this.doReconnect){this.eventsSdkClass.eventEmitterClass.emit(L.ONLINE_STATUS_EVENT,{connectionStatus:te.DISCONNECTED});return}this.closeAllConnections(),this.scheduleReconnect()}onConnectError(t){this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(t),this.doReconnect?this.scheduleReconnect():this.eventsSdkClass.eventEmitterClass.emit(L.ONLINE_STATUS_EVENT,{connectionStatus:te.DISCONNECTED})}async destroy(){this.doReconnect=!1,this.networkCleanup.forEach(t=>t()),await this.closeAllConnections()}}class et{constructor(t){X(this,"storageLogger");this.eventsSdkClass=t,this.eventsSdkClass=t}init(){if(!this.eventsSdkClass.options.useLogger)return;if(this.eventsSdkClass.options.storageLoggerInstance){this.storageLogger=this.eventsSdkClass.options.storageLoggerInstance;return}let t;this.eventsSdkClass.options.loggerSocketConnection&&(t=this.eventsSdkClass.options.loggerSocketConnection),this.eventsSdkClass.socketIoClass.ioFunction&&!t&&(t=this.eventsSdkClass.socketIoClass.ioFunction(this.eventsSdkClass.options.loggerServer,this.eventsSdkClass.options.loggerConnectOptions)),t&&(this.storageLogger=new M({socket:t,loggerOptions:this.eventsSdkClass.options.loggerConfig}))}async start(){this.storageLogger&&await this.storageLogger.start()}async stop(){this.storageLogger&&await this.storageLogger.stop()}log(t){if(this.eventsSdkClass.options.useLogger)if(this.storageLogger)switch(t.Level){case M.LevelEnum.INFO:this.storageLogger.log(t);break;case M.LevelEnum.DEBUG:this.storageLogger.debug(t);break;case M.LevelEnum.WARNING:this.storageLogger.warn(t);break;case M.LevelEnum.ERROR:this.storageLogger.error(t)}else t.Level===M.LevelEnum.INFO?console.log(t):t.Level===M.LevelEnum.ERROR&&console.error(t)}sdkConnectionSuccess(){const t={...this.eventsSdkClass.options,token:"CENSORED",password:"CENSORED"};this.log({Message:`Sdk connected to the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL}`,Body:JSON.stringify(t,this.eventsSdkClass.getCircularReplacer()),ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection established",StatusCode:200,Level:M.LevelEnum.INFO,LogType:M.LogTypeEnum.INFO})}sdkDisconnect(t){this.log({Message:`Sdk disconnected from the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL} (${t})`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection closed",StatusCode:200,Level:M.LevelEnum.INFO,LogType:M.LogTypeEnum.INFO})}sdkAttemptToConnect(t){this.log({Message:`${this.eventsSdkClass.options.loggerConfig.system} is trying to connect to WS server ${t}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Switching Protocols",StatusCode:101,Level:M.LevelEnum.INFO,LogType:M.LogTypeEnum.INFO})}sdkAttemptToConnectError(t){this.log({Message:`${t}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection error",StatusCode:500,Level:M.LevelEnum.ERROR,LogType:M.LogTypeEnum.ERROR})}loginError(t,e,r,o){this.log({Message:`External login request error with the login type ${t} ${t===Y.TOKEN?r:o}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"External login error",StatusCode:e||400,Level:M.LevelEnum.ERROR,LogType:M.LogTypeEnum.ERROR})}getSettingsError(t,e){this.log({Message:`Get settings error with token ${t}, error: ${e}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:M.LevelEnum.ERROR,LogType:M.LogTypeEnum.ERROR})}refreshTokenError(t,e,r){this.log({Message:`Refresh token error with old refresh token ${t}, url: ${e}, error: ${r}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:M.LevelEnum.ERROR,LogType:M.LogTypeEnum.ERROR})}keepAliveEmit(){this.log({Message:`Keep alive event emitted with this token: ${this.eventsSdkClass.authClass.token}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Level:M.LevelEnum.INFO,LogType:M.LogTypeEnum.INFO})}keepAliveResponse(t){this.log({Message:`Keep alive response: ${JSON.stringify(t)}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",StatusCode:200,Level:M.LevelEnum.INFO,LogType:M.LogTypeEnum.INFO})}eventLog(t,e){const r={[Z.FULL]:[],[Z.BOOTSTRAP]:[L.LOGIN_STATUS,L.LOGIN_SUCCESS,L.ALL_EXTENSION_STATUS,L.ALL_DIALER_STATUS],[Z.DEBUG_EXTENSIONS]:[L.ALL_EXTENSION_STATUS,L.EXTENSION_EVENT,L.EXTENSIONS_UPDATED],[Z.DEBUG_DIALER]:[L.ALL_DIALER_STATUS,L.DIALER_EVENT],[Z.DEBUG_QUEUE]:[L.QUEUE_EVENT]};this.eventsSdkClass.options.debugOption&&(r[this.eventsSdkClass.options.debugOption].includes(t)||this.eventsSdkClass.options.debugOption===Z.FULL)&&this.log({Message:`Event name: ${t}`,Body:{...this.getStaticData(),...e},ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",Level:M.LevelEnum.DEBUG,LogType:M.LogTypeEnum.INFO})}getStaticData(){return{SocketId:this.eventsSdkClass.socketIoClass&&this.eventsSdkClass.socketIoClass.io?this.eventsSdkClass.socketIoClass.io.id:""}}}class tt{constructor(t){X(this,"listeners",{[L.ALL_EXTENSION_STATUS]:[],[L.ALL_DIALER_STATUS]:[],[L.ALL_USERS_STATUS]:[],[L.ALL_VOICEBOTS_STATUS]:[],[L.QUEUE_EVENT]:[],[L.EXTENSION_EVENT]:[],[L.DIALER_EVENT]:[],[L.LOGIN_SUCCESS]:[],[L.LOGIN_STATUS]:[],[L.KEEP_ALIVE_RESPONSE]:[],[L.ONLINE_STATUS_EVENT]:[],[L.EXTENSIONS_UPDATED]:[],[L.VOICEBOT_SUBSCRIBED_TO_CALL]:[],[L.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED]:[],[L.VOICEBOT_INITIAL_CALL_HISTORY]:[],[L.VOICEBOT_UNSUBSCRIBED_FROM_CALL]:[],[L.VOICEBOT_EVENT]:[]});X(this,"allListeners",[]);this.eventsSdkClass=t,this.eventsSdkClass=t}on(t,e){t==="*"?this.allListeners.push(e):this.listeners[t].push(e)}off(t,e){if(t==="*")this.allListeners=this.allListeners.filter(r=>r!==e);else{const o=this.listeners[t].filter(h=>h!==e);this.listeners={...this.listeners,[t]:o}}}emit(t,e){this.eventsSdkClass.socketIoClass.lastEventTimestamp=new Date().getTime(),this.listeners[t].forEach(o=>o({name:t,data:e}));const r={name:t,data:e};this.allListeners.forEach(o=>o(r))}}class nt{constructor(t){X(this,"options");X(this,"servers",[]);X(this,"URLList",[]);X(this,"server");X(this,"URL");X(this,"socket");X(this,"mainServer");X(this,"alreadyAttemptedOtherServers",[]);X(this,"authClass",new $e(this));X(this,"socketIoClass");X(this,"loggerClass",new et(this));X(this,"eventEmitterClass",new tt(this));X(this,"getCircularReplacer",()=>{const t=new WeakSet;return(e,r)=>{if(!(e==="socket"||e==="io"||e==="nsps")){if(typeof r=="object"&&r!==null){if(t.has(r))return;t.add(r)}return r}}});this.options={...Le,...t},this.socketIoClass=new Ze(this)}on(t,e){this.eventEmitterClass.on(t,e)}emit(t,...e){this.socketIoClass.io&&this.socketIoClass.io.emit(t,...e)}connect(t){t===ee.MAIN&&this.findMainServer(),t===ee.NEXT&&this.findNextServer(),this.socketIoClass.doReconnect=!0;try{this.loggerClass.init()}catch(e){console.error(e)}this.socketIoClass.initSocketConnection(),this.socketIoClass.initKeepAlive()}async disconnect(){this.socketIoClass.doReconnect=!1,await this.socketIoClass.closeAllConnections(),await this.loggerClass.stop()}clearKeepAliveInterval(){this.socketIoClass.clearKeepAliveInterval()}findMainServer(){this.servers.length?(this.mainServer=this.servers.reduce((t,e)=>e.Priority>t.Priority?e:t),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 t=this.servers.filter(e=>e.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(e.Priority)+1===0);t.length||(this.alreadyAttemptedOtherServers=[],t=this.servers.filter(e=>e.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(e.Priority)+1===0)),t.length&&(this.server=t.reduce((e,r)=>r.Priority>e.Priority?r:e),this.alreadyAttemptedOtherServers.push(this.server.Priority))}else this.server=this.mainServer;else if(this.URLList.length)if(this.URL===this.URLList[0]){let t=this.URLList.filter(e=>e!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(e)+1===0);t.length||(this.alreadyAttemptedOtherServers=[],t=this.URLList.filter(e=>e!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(e)+1===0)),t.length&&(this.URL=t[0],this.alreadyAttemptedOtherServers.push(this.URL))}else this.URL=this.URLList[0]}async init(){const t=await this.authClass.login();return t&&this.authClass.onLoginResponse(t),!0}getCurrentMonitorServer(){return this.server}}exports.CallStatusEnum=Oe;exports.CallTypeEnum=_e;exports.ConnectionStatusEnum=te;exports.DebugOption=Z;exports.DialerTypeEnum=Ie;exports.DirectionEnum=Re;exports.DoNotCallMeStatusCodeEnum=Be;exports.EventsEnum=L;exports.ExtensionEventReasonEnum=me;exports.ExtensionHangupCauseEnum=Ue;exports.LoginType=Y;exports.QueueEventReasonEnum=xe;exports.ServerListenerEventsEnum=Se;exports.ServerParameter=ee;exports.default=nt;
|
|
11
|
+
]`&&C(new Date(-864e13))=='"-271821-04-20T00:00:00.000Z"'&&C(new Date(864e13))=='"+275760-09-13T00:00:00.000Z"'&&C(new Date(-621987552e5))=='"-000001-01-01T00:00:00.000Z"'&&C(new Date(-1))=='"1969-12-31T23:59:59.999Z"'}catch{B=!1}}_=B}if(E=="json-parse"){var D=u.parse;if(typeof D=="function")try{if(D("0")===0&&!D(!1)){T=D(V);var N=T.a.length==5&&T.a[0]===1;if(N){try{N=!D('" "')}catch{}if(N)try{N=D("01")!==1}catch{}if(N)try{N=D("1.")!==1}catch{}}}}catch{N=!1}_=N}}return o[E]=!!_}var c,f,h,d={}.toString,i=typeof JSON=="object"&&JSON,u=typeof e=="object"&&e&&!e.nodeType&&e;u&&i?(u.stringify=i.stringify,u.parse=i.parse):u=r.JSON=i||{};var l=new Date(-0xc782b5b800cec);try{l=l.getUTCFullYear()==-109252&&l.getUTCMonth()===0&&l.getUTCDate()===1&&l.getUTCHours()==10&&l.getUTCMinutes()==37&&l.getUTCSeconds()==6&&l.getUTCMilliseconds()==708}catch{}if(!o("json")){var s="[object Function]",n="[object Date]",p="[object Number]",g="[object String]",y="[object Array]",b="[object Boolean]",j=o("bug-string-char-index");if(!l)var U=Math.floor,F=[0,31,59,90,120,151,181,212,243,273,304,334],I=function(E,_){return F[_]+365*(E-1970)+U((E-1969+(_=+(_>1)))/4)-U((E-1901+_)/100)+U((E-1601+_)/400)};(c={}.hasOwnProperty)||(c=function(E){var _,T={};return(T.__proto__=null,T.__proto__={toString:1},T).toString!=d?c=function(V){var C=this.__proto__,B=V in(this.__proto__=null,this);return this.__proto__=C,B}:(_=T.constructor,c=function(V){var C=(this.constructor||_).prototype;return V in this&&!(V in C&&this[V]===C[V])}),T=null,c.call(this,E)});var k={boolean:1,number:1,string:1,undefined:1},w=function(E,_){var T=typeof E[_];return T=="object"?!!E[_]:!k[T]};if(f=function(E,_){var T,V,C,B=0;(T=function(){this.valueOf=0}).prototype.valueOf=0,V=new T;for(C in V)c.call(V,C)&&B++;return T=V=null,B?f=B==2?function(D,N){var P,G={},W=d.call(D)==s;for(P in D)W&&P=="prototype"||c.call(G,P)||!(G[P]=1)||!c.call(D,P)||N(P)}:function(D,N){var P,G,W=d.call(D)==s;for(P in D)W&&P=="prototype"||!c.call(D,P)||(G=P==="constructor")||N(P);(G||c.call(D,P="constructor"))&&N(P)}:(V=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],f=function(D,N){var P,G,W=d.call(D)==s,H=!W&&typeof D.constructor!="function"&&w(D,"hasOwnProperty")?D.hasOwnProperty:c;for(P in D)W&&P=="prototype"||!H.call(D,P)||N(P);for(G=V.length;P=V[--G];H.call(D,P)&&N(P));}),f(E,_)},!o("json-stringify")){var A={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},v="000000",m=function(E,_){return(v+(_||0)).slice(-E)},O="\\u00",x=function(E){var _,T='"',V=0,C=E.length,B=C>10&&j;for(B&&(_=E.split(""));C>V;V++){var D=E.charCodeAt(V);switch(D){case 8:case 9:case 10:case 12:case 13:case 34:case 92:T+=A[D];break;default:if(32>D){T+=O+m(2,D.toString(16));break}T+=B?_[V]:j?E.charAt(V):E[V]}}return T+'"'},R=function(E,_,T,V,C,B,D){var N,P,G,W,H,re,ce,le,he,ue,Q,pe,ae,oe,fe,de;try{N=_[E]}catch{}if(typeof N=="object"&&N)if(P=d.call(N),P!=n||c.call(N,"toJSON"))typeof N.toJSON=="function"&&(P!=p&&P!=g&&P!=y||c.call(N,"toJSON"))&&(N=N.toJSON(E));else if(N>-1/0&&1/0>N){if(I){for(H=U(N/864e5),G=U(H/365.2425)+1970-1;I(G+1,0)<=H;G++);for(W=U((H-I(G,0))/30.42);I(G,W+1)<=H;W++);H=1+H-I(G,W),re=(N%864e5+864e5)%864e5,ce=U(re/36e5)%24,le=U(re/6e4)%60,he=U(re/1e3)%60,ue=re%1e3}else G=N.getUTCFullYear(),W=N.getUTCMonth(),H=N.getUTCDate(),ce=N.getUTCHours(),le=N.getUTCMinutes(),he=N.getUTCSeconds(),ue=N.getUTCMilliseconds();N=(0>=G||G>=1e4?(0>G?"-":"+")+m(6,0>G?-G:G):m(4,G))+"-"+m(2,W+1)+"-"+m(2,H)+"T"+m(2,ce)+":"+m(2,le)+":"+m(2,he)+"."+m(3,ue)+"Z"}else N=null;if(T&&(N=T.call(_,E,N)),N===null)return"null";if(P=d.call(N),P==b)return""+N;if(P==p)return N>-1/0&&1/0>N?""+N:"null";if(P==g)return x(""+N);if(typeof N=="object"){for(oe=D.length;oe--;)if(D[oe]===N)throw TypeError();if(D.push(N),Q=[],fe=B,B+=C,P==y){for(ae=0,oe=N.length;oe>ae;ae++)pe=R(ae,N,T,V,C,B,D),Q.push(pe===h?"null":pe);de=Q.length?C?`[
|
|
12
|
+
`+B+Q.join(`,
|
|
13
|
+
`+B)+`
|
|
14
|
+
`+fe+"]":"["+Q.join(",")+"]":"[]"}else f(V||N,function(ge){var Ee=R(ge,N,T,V,C,B,D);Ee!==h&&Q.push(x(ge)+":"+(C?" ":"")+Ee)}),de=Q.length?C?`{
|
|
15
|
+
`+B+Q.join(`,
|
|
16
|
+
`+B)+`
|
|
17
|
+
`+fe+"}":"{"+Q.join(",")+"}":"{}";return D.pop(),de}};u.stringify=function(E,_,T){var V,C,B,D;if(typeof _=="function"||typeof _=="object"&&_){if((D=d.call(_))==s)C=_;else if(D==y){B={};for(var N,P=0,G=_.length;G>P;N=_[P++],D=d.call(N),(D==g||D==p)&&(B[N]=1));}}if(T)if((D=d.call(T))==p){if((T-=T%1)>0)for(V="",T>10&&(T=10);V.length<T;V+=" ");}else D==g&&(V=T.length<=10?T:T.slice(0,10));return R("",(N={},N[""]=E,N),C,B,V,"",[])}}if(!o("json-parse")){var S,K,$=String.fromCharCode,z={92:"\\",34:'"',47:"/",98:"\b",116:" ",110:`
|
|
18
|
+
`,102:"\f",114:"\r"},q=function(){throw S=K=null,SyntaxError()},J=function(){for(var E,_,T,V,C,B=K,D=B.length;D>S;)switch(C=B.charCodeAt(S)){case 9:case 10:case 13:case 32:S++;break;case 123:case 125:case 91:case 93:case 58:case 44:return E=j?B.charAt(S):B[S],S++,E;case 34:for(E="@",S++;D>S;)if(C=B.charCodeAt(S),32>C)q();else if(C==92)switch(C=B.charCodeAt(++S)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:E+=z[C],S++;break;case 117:for(_=++S,T=S+4;T>S;S++)C=B.charCodeAt(S),C>=48&&57>=C||C>=97&&102>=C||C>=65&&70>=C||q();E+=$("0x"+B.slice(_,S));break;default:q()}else{if(C==34)break;for(C=B.charCodeAt(S),_=S;C>=32&&C!=92&&C!=34;)C=B.charCodeAt(++S);E+=B.slice(_,S)}if(B.charCodeAt(S)==34)return S++,E;q();default:if(_=S,C==45&&(V=!0,C=B.charCodeAt(++S)),C>=48&&57>=C){for(C==48&&(C=B.charCodeAt(S+1),C>=48&&57>=C)&&q(),V=!1;D>S&&(C=B.charCodeAt(S),C>=48&&57>=C);S++);if(B.charCodeAt(S)==46){for(T=++S;D>T&&(C=B.charCodeAt(T),C>=48&&57>=C);T++);T==S&&q(),S=T}if(C=B.charCodeAt(S),C==101||C==69){for(C=B.charCodeAt(++S),(C==43||C==45)&&S++,T=S;D>T&&(C=B.charCodeAt(T),C>=48&&57>=C);T++);T==S&&q(),S=T}return+B.slice(_,S)}if(V&&q(),B.slice(S,S+4)=="true")return S+=4,!0;if(B.slice(S,S+5)=="false")return S+=5,!1;if(B.slice(S,S+4)=="null")return S+=4,null;q()}return"$"},se=function(E){var _,T;if(E=="$"&&q(),typeof E=="string"){if((j?E.charAt(0):E[0])=="@")return E.slice(1);if(E=="["){for(_=[];E=J(),E!="]";T||(T=!0))T&&(E==","?(E=J(),E=="]"&&q()):q()),E==","&&q(),_.push(se(E));return _}if(E=="{"){for(_={};E=J(),E!="}";T||(T=!0))T&&(E==","?(E=J(),E=="}"&&q()):q()),(E==","||typeof E!="string"||(j?E.charAt(0):E[0])!="@"||J()!=":")&&q(),_[E.slice(1)]=se(J());return _}q()}return E},Ce=function(E,_,T){var V=ke(E,_,T);V===h?delete E[_]:E[_]=V},ke=function(E,_,T){var V,C=E[_];if(typeof C=="object"&&C)if(d.call(C)==y)for(V=C.length;V--;)Ce(C,V,T);else f(C,function(B){Ce(C,B,T)});return T.call(E,_,C)};u.parse=function(E,_){var T,V;return S=0,K=""+E,T=se(J()),J()!="$"&&q(),S=K=null,_&&d.call(_)==s?ke((V={},V[""]=T,V),"",_):T}}}})(this)},{}],48:[function(a,t){function e(r,o){var c=[];o=o||0;for(var f=o||0;f<r.length;f++)c[f-o]=r[f];return c}t.exports=e},{}]},{},[1])(1)}const ze=Object.freeze(Object.defineProperty({__proto__:null,default:Ge},Symbol.toStringTag,{value:"Module"})),Je=Object.assign({"./v1_3_7.js":ze}),We=/v\d+_\d+_\d+/;function He(a){return typeof a=="function"}const ve=Object.entries(Je).reduce((a,t)=>{var o;const e=t[1].default,r=(o=t[0].match(We))==null?void 0:o[0];return He(e)&&r&&(a[r]=e()),a},{}),Ne=a=>{if(a in ve)return ve[a];throw new Error(`Socket version ${a} not found`)},Ye=(a,...t)=>Ne(a)(...t),Qe={...ve,getSocketVersion:Ne,makeSocketVersion:Ye};var Oe=(a=>(a.RINGING="Ringing",a.TALKING="Talking",a.DIALING="Dialing",a.HOLD="Hold",a))(Oe||{}),_e=(a=>(a.INCOMING="Incoming",a.OUTGOING="Outgoing",a))(_e||{}),ne=(a=>(a.CONNECTED="connected",a.DISCONNECTED="disconnected",a.TRYING_TO_CONNECT="tryingToConnect",a))(ne||{}),Ie=(a=>(a.AUTOMATIC="Automatic",a.IVR="IVR",a))(Ie||{}),Re=(a=>(a.INCOMINC="Incoming",a.OUTGOING="Outgoing",a.SPY="Spy",a.CLICK2CALL="Click2Call",a))(Re||{}),xe=(a=>(a.RESPONSE_FROM_API_VALID="RESPONSE_FROM_API_VALID",a.RESPONSE_FROM_API_INVALID="RESPONSE_FROM_API_INVALID",a))(xe||{}),L=(a=>(a.ALL_DIALER_STATUS="AllDialersStatus",a.ALL_EXTENSION_STATUS="AllExtensionsStatus",a.ALL_USERS_STATUS="AllUsersStatus",a.CONNECT="connect",a.DISCONNECT="disconnect",a.CONNECT_ERROR_EVENT="connect_error",a.EXTENSION_EVENT="ExtensionEvent",a.KEEP_ALIVE="keepalive",a.KEEP_ALIVE_RESPONSE="keepaliveResponse",a.LOGIN_STATUS="loginStatus",a.LOGIN_SUCCESS="loginSuccess",a.QUEUE_EVENT="QueueEvent",a.ONLINE_STATUS_EVENT="onlineStatusEvent",a.DIALER_EVENT="DialerEvent",a.EXTENSIONS_UPDATED="ExtensionsUpdated",a.ALL_VOICEBOTS_STATUS="AllVoicebotsStatus",a.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED="subscribeToCallFailed",a.VOICEBOT_SUBSCRIBED_TO_CALL="subscribedToCall",a.VOICEBOT_INITIAL_CALL_HISTORY="initialCallHistory",a.VOICEBOT_UNSUBSCRIBED_FROM_CALL="unsubscribedFromCall",a.VOICEBOT_EVENT="VoicebotEvent",a))(L||{}),me=(a=>(a.NEWCALL="NEWCALL",a.ANSWER="ANSWER",a.HOLD="HOLD",a.UNHOLD="UNHOLD",a.HANGUP="HANGUP",a.USER_STATUS_UPDATE="userStatusUpdate",a))(me||{}),Be=(a=>(a.NORMAL_HANGUP="Normal hangup",a.USER_BUSY="User busy",a.CALL_REJECTED="Call Rejected",a.UNALLOCATED_NUMBER="Unallocated (unassigned) number",a.UNKNOWN="Unknown",a.NO_USER_RESPONDING="No user responding",a.USER_ALERTING="User alerting, no answer",a.ANSWERED_ELSEWHERE="Answered elsewhere",a))(Be||{}),Ue=(a=>(a.ANSWER="ANSWER",a.ABANDONED="ABANDONED",a.EXIT="EXIT",a.JOIN="JOIN",a))(Ue||{});class te{static mapExtensionEvent(t){var f,h;const e=t.reason;let r,o;t.data.currentCall&&(o=this.mapExtensionCall(t,t.data.currentCall));const c=this.mapExtensionData(t,t.data);return e===me.HANGUP?r={...t,reason:e,data:{...c,currentCall:o?{...o,duration:o.callAnswered_UTC_CLIENT?Date.now()-o.callAnswered_UTC_CLIENT:0}:void 0,calls:(f=t.data.calls)==null?void 0:f.map(d=>{const i=this.mapExtensionCall(t,d);return{...i,duration:i.callAnswered_UTC_CLIENT?Date.now()-i.callAnswered_UTC_CLIENT:0}})}}:r={...t,data:{...c,currentCall:o,calls:(h=t.data.calls)==null?void 0:h.map(d=>this.mapExtensionCall(t,d))},reason:e},r}static mapAllExtensionStatus(t){return{...t,extensions:t.extensions.map(e=>{var r;return{...this.mapExtensionData(t,e),currentCall:e.currentCall?this.mapExtensionCall(t,e.currentCall):void 0,calls:(r=e.calls)==null?void 0:r.map(o=>this.mapExtensionCall(t,o))}})}}static mapAllVoicebotStatus(t){return{...t,voicebots:t.voicebots.map(e=>({...e,Calls:e.Calls.map(r=>{var o;return{...this.mapVoicebotCall(t,r),eventsData:(o=r==null?void 0:r.eventsData)==null?void 0:o.map(c=>this.mapVoicebotEventsData(t,c))}})}))}}static mapVoicebotEvent(t){var e,r;return{...t,data:{...t.data,Call:{...this.mapVoicebotCall(t,t.data.Call),eventsData:(r=(e=t.data.Call)==null?void 0:e.eventsData)==null?void 0:r.map(o=>this.mapVoicebotEventsData(t,o))}}}}static mapVoicebotInitialCallHistory(t){return{...t,history:t.history.map(e=>({...this.mapVoicebotCall(t,e),eventsData:this.mapVoicebotEventsData(t,e)}))}}static mapVoicebotCall(t,e){return this.configureUTCForObject(e,[{key:"callStarted",format:"sec"}],t.servertime,t.servertimeoffset)}static mapVoicebotEventsData(t,e){return this.configureUTCForObject(e,[{key:"Timestamp",format:"sec"}],t.servertime,t.servertimeoffset)}static mapExtensionData(t,e){return this.configureUTCForObject(e,[{key:"lastAnsweredCallEventEpoch",format:"sec"},{key:"lastCallEventEpoch",format:"sec"},{key:"lastHangupCallEpoch",format:"sec"},{key:"representativeUpdated",format:"ms"}],t.servertime,t.servertimeoffset)}static mapExtensionCall(t,e){return this.configureUTCForObject(e,[{key:"callAnswered",format:"sec"},{key:"callStarted",format:"sec"}],t.servertime,t.servertimeoffset)}static mapQueueCall(t,e){return this.configureUTCForObject(e,[{key:"JoinTimeStamp",format:"sec"},{key:"VHJoinTimeStamp",format:"sec"}],t.servertime,t.servertimeoffset)}static mapLoginStatusEvent(t){return{...t,queues:t.queues.map(e=>({...e,Calls:e.Calls.map(r=>this.mapQueueCall(t,r))}))}}static mapQueueEvent(t){return{...t,data:{...t.data,Calls:t.data.Calls.map(e=>this.mapQueueCall(t,e))}}}static assignProperty(t,e,r){t[e]=r}static configureUTCForObject(t,e,r,o){const c=(r-o*60)*1e3,f=Date.now()-c,h={};return e.forEach(d=>{const i=t[d.key],u=d.key;if(i!==0&&typeof i=="number"&&!isNaN(i)){let l=i;d.format==="ms"&&(l=Math.floor(l/1e3));const s=(l-o*60)*1e3;this.assignProperty(h,`${u}_UTC`,s),this.assignProperty(h,`${u}_UTC_CLIENT`,s+f)}else this.assignProperty(h,`${u}_UTC`,0),this.assignProperty(h,`${u}_UTC_CLIENT`,0)}),{...t,...h}}}var Se=(a=>(a.UPDATE_MONITORED_EXTENSIONS="updateMonitoredExtensions",a.KEEP_ALIVE="keepalive",a.SUBSCRIBE_VOICEBOT_CALL_UPDATES="subscribeVoicebotCallUpdates",a.UNSUBSCRIBE_VOICEBOT_CALL_UPDATES="unsubscribeVoicebotCallUpdates",a))(Se||{});class Ze{constructor(t){X(this,"io");X(this,"ioFunction");X(this,"lastEventTimestamp",new Date().getTime());X(this,"doReconnect",!0);X(this,"connectionState","disconnected");X(this,"keepAliveInterval");X(this,"reconnectTimeout");X(this,"networkReconnectTimeout");X(this,"reconnectionTime",Le.reconnectionDelay);X(this,"maxReconnectionDelay",120);X(this,"networkCleanup",[]);this.eventsSdkClass=t,this.reconnectionTime=t.options.reconnectionDelay,this.setupNetworkListeners()}setupNetworkListeners(){const t=()=>this.closeAllConnections(),e=()=>this.handleNetworkOnline();typeof window<"u"&&"addEventListener"in window&&typeof window.addEventListener=="function"?(window.addEventListener("offline",t),window.addEventListener("online",e),this.networkCleanup.push(()=>window.removeEventListener("offline",t),()=>window.removeEventListener("online",e))):typeof self<"u"&&"addEventListener"in self&&typeof self.addEventListener=="function"&&(self.addEventListener("offline",t),self.addEventListener("online",e),this.networkCleanup.push(()=>self.removeEventListener("offline",t),()=>self.removeEventListener("online",e)))}handleNetworkOnline(){this.networkReconnectTimeout&&clearTimeout(this.networkReconnectTimeout),this.networkReconnectTimeout=setTimeout(()=>{this.connectionState==="disconnected"&&this.doReconnect&&this.eventsSdkClass.connect(ee.NEXT)},500)}getSocketIoFunction(t){const e=t.split("v="),r="v".concat(e[e.length-1]).replaceAll(".","_");this.ioFunction=Qe.getSocketVersion(r)}initSocketConnection(){if(this.connectionState!=="disconnected")return;this.connectionState="connecting";const t=this.eventsSdkClass.authClass.token,e=this.eventsSdkClass.options.protocol,r=this.eventsSdkClass.server;try{const o=r?r.Domain:this.eventsSdkClass.URL,c=r?`${e}://${o}`:this.eventsSdkClass.URL,f={reconnection:!1,upgrade:!1,transports:["websocket"],forceNew:!0,query:{token:t},timeout:this.eventsSdkClass.options.timeout};if(this.ioFunction&&c)this.io=this.ioFunction(c,f),this.initSocketEvents(),this.eventsSdkClass.eventEmitterClass.emit(L.ONLINE_STATUS_EVENT,{attemptToConnect:c,connectionStatus:ne.TRYING_TO_CONNECT}),this.eventsSdkClass.loggerClass.sdkAttemptToConnect(o);else throw new Error("Socket server url not defined")}catch(o){this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(o)}}clearKeepAliveInterval(){this.keepAliveInterval&&(clearInterval(this.keepAliveInterval),this.keepAliveInterval=void 0)}initKeepAlive(){this.clearKeepAliveInterval(),this.keepAliveInterval=setInterval(async()=>{new Date().getTime()>this.lastEventTimestamp+this.eventsSdkClass.options.keepAliveTimeout&&this.io&&this.connectionState==="connected"&&this.eventsSdkClass.authClass.token&&(this.eventsSdkClass.emit(Se.KEEP_ALIVE,this.eventsSdkClass.authClass.token),this.eventsSdkClass.loggerClass.keepAliveEmit())},this.eventsSdkClass.options.keepAliveTimeout)}async closeAllConnections(){if(this.clearKeepAliveInterval(),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.networkReconnectTimeout&&(clearTimeout(this.networkReconnectTimeout),this.networkReconnectTimeout=void 0),this.io){const t=this.io;this.io=void 0;try{await Promise.race([new Promise(e=>{t.on("disconnect",()=>e()),t.removeAllListeners(),t.close(),t.disconnect()}),new Promise(e=>setTimeout(e,1e3))])}catch{}}this.connectionState="disconnected",this.eventsSdkClass.loggerClass.stop(),ie.clearSessionStorage()}initSocketEvents(){this.io&&(this.io.removeAllListeners(),this.io.on(L.LOGIN_SUCCESS,t=>this.onLoginSuccessEvent(t,L.LOGIN_SUCCESS)).on(L.QUEUE_EVENT,t=>this.onQueueEvent(t,L.QUEUE_EVENT)).on(L.EXTENSION_EVENT,t=>this.onExtensionEvent(t,L.EXTENSION_EVENT)).on(L.DIALER_EVENT,t=>this.onDialerEvent(t,L.DIALER_EVENT)).on(L.LOGIN_STATUS,t=>this.onLoginStatusEvent(t,L.LOGIN_STATUS)).on(L.ALL_EXTENSION_STATUS,t=>this.onAllExtensionStatus(t,L.ALL_EXTENSION_STATUS)).on(L.ALL_DIALER_STATUS,t=>this.onAllDialerStatus(t,L.ALL_DIALER_STATUS)).on(L.KEEP_ALIVE_RESPONSE,t=>this.onKeepAliveResponse(t)).on(L.EXTENSIONS_UPDATED,t=>this.onExtensionsUpdatedEvent(t,L.EXTENSIONS_UPDATED)).on(L.CONNECT,()=>this.onConnect()).on(L.DISCONNECT,t=>this.onDisconnect(t)).on(L.CONNECT_ERROR_EVENT,t=>this.onConnectError(t)).on(L.ALL_VOICEBOTS_STATUS,t=>this.onAllVoicebotsStatus(t,L.ALL_VOICEBOTS_STATUS)).on(L.VOICEBOT_EVENT,t=>this.onVoicebotEvent(t,L.VOICEBOT_EVENT)).on(L.VOICEBOT_SUBSCRIBED_TO_CALL,t=>this.onVoicebotSubscribedToCall(t,L.VOICEBOT_SUBSCRIBED_TO_CALL)).on(L.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED,t=>this.onVoicebotSubscribeToCallFailed(t,L.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED)).on(L.VOICEBOT_INITIAL_CALL_HISTORY,t=>this.onVoicebotInitialCallHistory(t,L.VOICEBOT_INITIAL_CALL_HISTORY)).on(L.VOICEBOT_UNSUBSCRIBED_FROM_CALL,t=>this.onVoicebotUnsubscribedFromCall(t,L.VOICEBOT_UNSUBSCRIBED_FROM_CALL)))}updateEventTimestamp(){this.lastEventTimestamp=new Date().getTime()}onLoginSuccessEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onQueueEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,te.mapQueueEvent(t))}onExtensionEvent(t,e){this.updateEventTimestamp();const r=te.mapExtensionEvent(t);r&&(this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,r))}onDialerEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotEvent(t,e){this.updateEventTimestamp();const r=te.mapVoicebotEvent(t);this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,r)}onAllVoicebotsStatus(t,e){this.updateEventTimestamp();const r=te.mapAllVoicebotStatus(t);this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,r)}onVoicebotSubscribedToCall(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotSubscribeToCallFailed(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onVoicebotInitialCallHistory(t,e){this.updateEventTimestamp();const r=te.mapVoicebotInitialCallHistory(t);this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,r)}onVoicebotUnsubscribedFromCall(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onLoginStatusEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,te.mapLoginStatusEvent(t))}onAllExtensionStatus(t,e){this.updateEventTimestamp();const r=te.mapAllExtensionStatus(t);this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,r)}onAllDialerStatus(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onKeepAliveResponse(t){if(this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.keepAliveResponse(t),t.errorCode){this.closeAllConnections().then(()=>{this.doReconnect&&this.connectionState==="disconnected"&&this.scheduleReconnect()});return}}onExtensionsUpdatedEvent(t,e){this.updateEventTimestamp(),this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onConnect(){this.connectionState="connected",this.reconnectionTime=this.eventsSdkClass.options.reconnectionDelay,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.eventsSdkClass.eventEmitterClass.emit(L.ONLINE_STATUS_EVENT,{connectionStatus:ne.CONNECTED}),this.eventsSdkClass.loggerClass.start().then(()=>{this.eventsSdkClass.loggerClass.sdkConnectionSuccess()})}scheduleReconnect(){!this.doReconnect||this.reconnectTimeout||(this.eventsSdkClass.eventEmitterClass.emit(L.ONLINE_STATUS_EVENT,{connectionStatus:ne.TRYING_TO_CONNECT}),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=void 0,this.reconnectionTime=Math.min(this.reconnectionTime*2,this.maxReconnectionDelay),this.reconnectionTime>this.maxReconnectionDelay&&(this.reconnectionTime=this.eventsSdkClass.options.reconnectionDelay),this.eventsSdkClass.connect(ee.NEXT)},this.reconnectionTime*1e3))}onDisconnect(t){if(this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkDisconnect([t]),!this.doReconnect){this.eventsSdkClass.eventEmitterClass.emit(L.ONLINE_STATUS_EVENT,{connectionStatus:ne.DISCONNECTED});return}this.closeAllConnections(),this.scheduleReconnect()}onConnectError(t){this.connectionState="disconnected",this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(t),this.doReconnect?this.scheduleReconnect():this.eventsSdkClass.eventEmitterClass.emit(L.ONLINE_STATUS_EVENT,{connectionStatus:ne.DISCONNECTED})}async destroy(){this.doReconnect=!1,this.networkCleanup.forEach(t=>t()),await this.closeAllConnections()}}class et{constructor(t){X(this,"storageLogger");this.eventsSdkClass=t,this.eventsSdkClass=t}init(){if(!this.eventsSdkClass.options.useLogger)return;if(this.eventsSdkClass.options.storageLoggerInstance){this.storageLogger=this.eventsSdkClass.options.storageLoggerInstance;return}let t;this.eventsSdkClass.options.loggerSocketConnection&&(t=this.eventsSdkClass.options.loggerSocketConnection),this.eventsSdkClass.socketIoClass.ioFunction&&!t&&(t=this.eventsSdkClass.socketIoClass.ioFunction(this.eventsSdkClass.options.loggerServer,this.eventsSdkClass.options.loggerConnectOptions)),t&&(this.storageLogger=new M({socket:t,loggerOptions:this.eventsSdkClass.options.loggerConfig}))}async start(){this.storageLogger&&await this.storageLogger.start()}async stop(){this.storageLogger&&await this.storageLogger.stop()}log(t){if(this.eventsSdkClass.options.useLogger)if(this.storageLogger)switch(t.Level){case M.LevelEnum.INFO:this.storageLogger.log(t);break;case M.LevelEnum.DEBUG:this.storageLogger.debug(t);break;case M.LevelEnum.WARNING:this.storageLogger.warn(t);break;case M.LevelEnum.ERROR:this.storageLogger.error(t)}else t.Level===M.LevelEnum.INFO?console.log(t):t.Level===M.LevelEnum.ERROR&&console.error(t)}sdkConnectionSuccess(){const t={...this.eventsSdkClass.options,token:"CENSORED",password:"CENSORED"};this.log({Message:`Sdk connected to the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL}`,Body:JSON.stringify(t,this.eventsSdkClass.getCircularReplacer()),ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection established",StatusCode:200,Level:M.LevelEnum.INFO,LogType:M.LogTypeEnum.INFO})}sdkDisconnect(t){this.log({Message:`Sdk disconnected from the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL} (${t})`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection closed",StatusCode:200,Level:M.LevelEnum.INFO,LogType:M.LogTypeEnum.INFO})}sdkAttemptToConnect(t){this.log({Message:`${this.eventsSdkClass.options.loggerConfig.system} is trying to connect to WS server ${t}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Switching Protocols",StatusCode:101,Level:M.LevelEnum.INFO,LogType:M.LogTypeEnum.INFO})}sdkAttemptToConnectError(t){this.log({Message:`${t}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection error",StatusCode:500,Level:M.LevelEnum.ERROR,LogType:M.LogTypeEnum.ERROR})}loginError(t,e,r,o){this.log({Message:`External login request error with the login type ${t} ${t===Y.TOKEN?r:o}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"External login error",StatusCode:e||400,Level:M.LevelEnum.ERROR,LogType:M.LogTypeEnum.ERROR})}getSettingsError(t,e){this.log({Message:`Get settings error with token ${t}, error: ${e}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:M.LevelEnum.ERROR,LogType:M.LogTypeEnum.ERROR})}refreshTokenError(t,e,r){this.log({Message:`Refresh token error with old refresh token ${t}, url: ${e}, error: ${r}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:M.LevelEnum.ERROR,LogType:M.LogTypeEnum.ERROR})}keepAliveEmit(){this.log({Message:`Keep alive event emitted with this token: ${this.eventsSdkClass.authClass.token}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Level:M.LevelEnum.INFO,LogType:M.LogTypeEnum.INFO})}keepAliveResponse(t){this.log({Message:`Keep alive response: ${JSON.stringify(t)}`,ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",StatusCode:200,Level:M.LevelEnum.INFO,LogType:M.LogTypeEnum.INFO})}eventLog(t,e){const r={[Z.FULL]:[],[Z.BOOTSTRAP]:[L.LOGIN_STATUS,L.LOGIN_SUCCESS,L.ALL_EXTENSION_STATUS,L.ALL_DIALER_STATUS],[Z.DEBUG_EXTENSIONS]:[L.ALL_EXTENSION_STATUS,L.EXTENSION_EVENT,L.EXTENSIONS_UPDATED],[Z.DEBUG_DIALER]:[L.ALL_DIALER_STATUS,L.DIALER_EVENT],[Z.DEBUG_QUEUE]:[L.QUEUE_EVENT]};this.eventsSdkClass.options.debugOption&&(r[this.eventsSdkClass.options.debugOption].includes(t)||this.eventsSdkClass.options.debugOption===Z.FULL)&&this.log({Message:`Event name: ${t}`,Body:{...this.getStaticData(),...e},ActionName:M.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",Level:M.LevelEnum.DEBUG,LogType:M.LogTypeEnum.INFO})}getStaticData(){return{SocketId:this.eventsSdkClass.socketIoClass&&this.eventsSdkClass.socketIoClass.io?this.eventsSdkClass.socketIoClass.io.id:""}}}class tt{constructor(t){X(this,"listeners",{[L.ALL_EXTENSION_STATUS]:[],[L.ALL_DIALER_STATUS]:[],[L.ALL_USERS_STATUS]:[],[L.ALL_VOICEBOTS_STATUS]:[],[L.QUEUE_EVENT]:[],[L.EXTENSION_EVENT]:[],[L.DIALER_EVENT]:[],[L.LOGIN_SUCCESS]:[],[L.LOGIN_STATUS]:[],[L.KEEP_ALIVE_RESPONSE]:[],[L.ONLINE_STATUS_EVENT]:[],[L.EXTENSIONS_UPDATED]:[],[L.VOICEBOT_SUBSCRIBED_TO_CALL]:[],[L.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED]:[],[L.VOICEBOT_INITIAL_CALL_HISTORY]:[],[L.VOICEBOT_UNSUBSCRIBED_FROM_CALL]:[],[L.VOICEBOT_EVENT]:[]});X(this,"allListeners",[]);this.eventsSdkClass=t,this.eventsSdkClass=t}on(t,e){t==="*"?this.allListeners.push(e):this.listeners[t].push(e)}off(t,e){if(t==="*")this.allListeners=this.allListeners.filter(r=>r!==e);else{const o=this.listeners[t].filter(c=>c!==e);this.listeners={...this.listeners,[t]:o}}}emit(t,e){this.eventsSdkClass.socketIoClass.lastEventTimestamp=new Date().getTime(),this.listeners[t].forEach(o=>o({name:t,data:e}));const r={name:t,data:e};this.allListeners.forEach(o=>o(r))}}class nt{constructor(t){X(this,"options");X(this,"servers",[]);X(this,"URLList",[]);X(this,"server");X(this,"URL");X(this,"socket");X(this,"mainServer");X(this,"alreadyAttemptedOtherServers",[]);X(this,"authClass",new $e(this));X(this,"socketIoClass");X(this,"loggerClass",new et(this));X(this,"eventEmitterClass",new tt(this));X(this,"getCircularReplacer",()=>{const t=new WeakSet;return(e,r)=>{if(!(e==="socket"||e==="io"||e==="nsps")){if(typeof r=="object"&&r!==null){if(t.has(r))return;t.add(r)}return r}}});this.options={...Le,...t},this.socketIoClass=new Ze(this)}on(t,e){this.eventEmitterClass.on(t,e)}emit(t,...e){this.socketIoClass.io&&this.socketIoClass.io.emit(t,...e)}connect(t){t===ee.MAIN&&this.findMainServer(),t===ee.NEXT&&this.findNextServer(),this.socketIoClass.doReconnect=!0;try{this.loggerClass.init()}catch(e){console.error(e)}this.socketIoClass.initSocketConnection(),this.socketIoClass.initKeepAlive()}async disconnect(){this.socketIoClass.doReconnect=!1,await this.socketIoClass.closeAllConnections(),await this.loggerClass.stop()}clearKeepAliveInterval(){this.socketIoClass.clearKeepAliveInterval()}findMainServer(){this.servers.length?(this.mainServer=this.servers.reduce((t,e)=>e.Priority>t.Priority?e:t),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 t=this.servers.filter(e=>e.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(e.Priority)+1===0);t.length||(this.alreadyAttemptedOtherServers=[],t=this.servers.filter(e=>e.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(e.Priority)+1===0)),t.length&&(this.server=t.reduce((e,r)=>r.Priority>e.Priority?r:e),this.alreadyAttemptedOtherServers.push(this.server.Priority))}else this.server=this.mainServer;else if(this.URLList.length)if(this.URL===this.URLList[0]){let t=this.URLList.filter(e=>e!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(e)+1===0);t.length||(this.alreadyAttemptedOtherServers=[],t=this.URLList.filter(e=>e!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(e)+1===0)),t.length&&(this.URL=t[0],this.alreadyAttemptedOtherServers.push(this.URL))}else this.URL=this.URLList[0]}async init(){const t=await this.authClass.login();return t&&this.authClass.onLoginResponse(t),!0}getCurrentMonitorServer(){return this.server}}exports.CallStatusEnum=Oe;exports.CallTypeEnum=_e;exports.ConnectionStatusEnum=ne;exports.DebugOption=Z;exports.DialerTypeEnum=Ie;exports.DirectionEnum=Re;exports.DoNotCallMeStatusCodeEnum=xe;exports.EventsEnum=L;exports.ExtensionEventReasonEnum=me;exports.ExtensionHangupCauseEnum=Be;exports.LoginType=Y;exports.QueueEventReasonEnum=Ue;exports.ServerListenerEventsEnum=Se;exports.ServerParameter=ee;exports.default=nt;
|
|
19
19
|
//# sourceMappingURL=voicenter-events-sdk.cjs.js.map
|