@voicenter-team/events-sdk 0.0.99 → 0.0.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,19 @@
1
- var VoicenterEventsSDK=function($,ut){"use strict";var gs=Object.defineProperty;var ys=($,ut,gt)=>ut in $?gs($,ut,{enumerable:!0,configurable:!0,writable:!0,value:gt}):$[ut]=gt;var K=($,ut,gt)=>(ys($,typeof ut!="symbol"?ut+"":ut,gt),gt);function gt(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ce={exports:{}},he={exports:{}};(function(){var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={rotl:function(t,n){return t<<n|t>>>32-n},rotr:function(t,n){return t<<32-n|t>>>n},endian:function(t){if(t.constructor==Number)return e.rotl(t,8)&16711935|e.rotl(t,24)&4278255360;for(var n=0;n<t.length;n++)t[n]=e.endian(t[n]);return t},randomBytes:function(t){for(var n=[];t>0;t--)n.push(Math.floor(Math.random()*256));return n},bytesToWords:function(t){for(var n=[],r=0,o=0;r<t.length;r++,o+=8)n[o>>>5]|=t[r]<<24-o%32;return n},wordsToBytes:function(t){for(var n=[],r=0;r<t.length*32;r+=8)n.push(t[r>>>5]>>>24-r%32&255);return n},bytesToHex:function(t){for(var n=[],r=0;r<t.length;r++)n.push((t[r]>>>4).toString(16)),n.push((t[r]&15).toString(16));return n.join("")},hexToBytes:function(t){for(var n=[],r=0;r<t.length;r+=2)n.push(parseInt(t.substr(r,2),16));return n},bytesToBase64:function(t){for(var n=[],r=0;r<t.length;r+=3)for(var o=t[r]<<16|t[r+1]<<8|t[r+2],u=0;u<4;u++)r*8+u*6<=t.length*8?n.push(s.charAt(o>>>6*(3-u)&63)):n.push("=");return n.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/ig,"");for(var n=[],r=0,o=0;r<t.length;o=++r%4)o!=0&&n.push((s.indexOf(t.charAt(r-1))&Math.pow(2,-2*o+8)-1)<<o*2|s.indexOf(t.charAt(r))>>>6-o*2);return n}};he.exports=e})();var ze=he.exports,Bt={utf8:{stringToBytes:function(s){return Bt.bin.stringToBytes(unescape(encodeURIComponent(s)))},bytesToString:function(s){return decodeURIComponent(escape(Bt.bin.bytesToString(s)))}},bin:{stringToBytes:function(s){for(var e=[],t=0;t<s.length;t++)e.push(s.charCodeAt(t)&255);return e},bytesToString:function(s){for(var e=[],t=0;t<s.length;t++)e.push(String.fromCharCode(s[t]));return e.join("")}}},le=Bt;/*!
1
+ var VoicenterEventsSDK=function(z,ee,F){"use strict";var et=Object.defineProperty;var tt=(z,ee,F)=>ee in z?et(z,ee,{enumerable:!0,configurable:!0,writable:!0,value:F}):z[ee]=F;var V=(z,ee,F)=>(tt(z,typeof ee!="symbol"?ee+"":ee,F),F);function je(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Ee={exports:{}},we={exports:{}};(function(){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(e,s){return e<<s|e>>>32-s},rotr:function(e,s){return e<<32-s|e>>>s},endian:function(e){if(e.constructor==Number)return t.rotl(e,8)&16711935|t.rotl(e,24)&4278255360;for(var s=0;s<e.length;s++)e[s]=t.endian(e[s]);return e},randomBytes:function(e){for(var s=[];e>0;e--)s.push(Math.floor(Math.random()*256));return s},bytesToWords:function(e){for(var s=[],o=0,h=0;o<e.length;o++,h+=8)s[h>>>5]|=e[o]<<24-h%32;return s},wordsToBytes:function(e){for(var s=[],o=0;o<e.length*32;o+=8)s.push(e[o>>>5]>>>24-o%32&255);return s},bytesToHex:function(e){for(var s=[],o=0;o<e.length;o++)s.push((e[o]>>>4).toString(16)),s.push((e[o]&15).toString(16));return s.join("")},hexToBytes:function(e){for(var s=[],o=0;o<e.length;o+=2)s.push(parseInt(e.substr(o,2),16));return s},bytesToBase64:function(e){for(var s=[],o=0;o<e.length;o+=3)for(var h=e[o]<<16|e[o+1]<<8|e[o+2],f=0;f<4;f++)o*8+f*6<=e.length*8?s.push(a.charAt(h>>>6*(3-f)&63)):s.push("=");return s.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/ig,"");for(var s=[],o=0,h=0;o<e.length;h=++o%4)h!=0&&s.push((a.indexOf(e.charAt(o-1))&Math.pow(2,-2*h+8)-1)<<h*2|a.indexOf(e.charAt(o))>>>6-h*2);return s}};we.exports=t})();var Pe=we.exports,he={utf8:{stringToBytes:function(a){return he.bin.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(he.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=he;/*!
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 He=function(s){return s!=null&&(ue(s)||Ye(s)||!!s._isBuffer)};function ue(s){return!!s.constructor&&typeof s.constructor.isBuffer=="function"&&s.constructor.isBuffer(s)}function Ye(s){return typeof s.readFloatLE=="function"&&typeof s.slice=="function"&&ue(s.slice(0,0))}(function(){var s=ze,e=le.utf8,t=He,n=le.bin,r=function(o,u){o.constructor==String?u&&u.encoding==="binary"?o=n.stringToBytes(o):o=e.stringToBytes(o):t(o)?o=Array.prototype.slice.call(o,0):!Array.isArray(o)&&o.constructor!==Uint8Array&&(o=o.toString());for(var h=s.bytesToWords(o),d=o.length*8,c=1732584193,p=-271733879,l=-1732584194,i=271733878,a=0;a<h.length;a++)h[a]=(h[a]<<8|h[a]>>>24)&16711935|(h[a]<<24|h[a]>>>8)&4278255360;h[d>>>5]|=128<<d%32,h[(d+64>>>9<<4)+14]=d;for(var f=r._ff,g=r._gg,y=r._hh,E=r._ii,a=0;a<h.length;a+=16){var j=c,U=p,F=l,L=i;c=f(c,p,l,i,h[a+0],7,-680876936),i=f(i,c,p,l,h[a+1],12,-389564586),l=f(l,i,c,p,h[a+2],17,606105819),p=f(p,l,i,c,h[a+3],22,-1044525330),c=f(c,p,l,i,h[a+4],7,-176418897),i=f(i,c,p,l,h[a+5],12,1200080426),l=f(l,i,c,p,h[a+6],17,-1473231341),p=f(p,l,i,c,h[a+7],22,-45705983),c=f(c,p,l,i,h[a+8],7,1770035416),i=f(i,c,p,l,h[a+9],12,-1958414417),l=f(l,i,c,p,h[a+10],17,-42063),p=f(p,l,i,c,h[a+11],22,-1990404162),c=f(c,p,l,i,h[a+12],7,1804603682),i=f(i,c,p,l,h[a+13],12,-40341101),l=f(l,i,c,p,h[a+14],17,-1502002290),p=f(p,l,i,c,h[a+15],22,1236535329),c=g(c,p,l,i,h[a+1],5,-165796510),i=g(i,c,p,l,h[a+6],9,-1069501632),l=g(l,i,c,p,h[a+11],14,643717713),p=g(p,l,i,c,h[a+0],20,-373897302),c=g(c,p,l,i,h[a+5],5,-701558691),i=g(i,c,p,l,h[a+10],9,38016083),l=g(l,i,c,p,h[a+15],14,-660478335),p=g(p,l,i,c,h[a+4],20,-405537848),c=g(c,p,l,i,h[a+9],5,568446438),i=g(i,c,p,l,h[a+14],9,-1019803690),l=g(l,i,c,p,h[a+3],14,-187363961),p=g(p,l,i,c,h[a+8],20,1163531501),c=g(c,p,l,i,h[a+13],5,-1444681467),i=g(i,c,p,l,h[a+2],9,-51403784),l=g(l,i,c,p,h[a+7],14,1735328473),p=g(p,l,i,c,h[a+12],20,-1926607734),c=y(c,p,l,i,h[a+5],4,-378558),i=y(i,c,p,l,h[a+8],11,-2022574463),l=y(l,i,c,p,h[a+11],16,1839030562),p=y(p,l,i,c,h[a+14],23,-35309556),c=y(c,p,l,i,h[a+1],4,-1530992060),i=y(i,c,p,l,h[a+4],11,1272893353),l=y(l,i,c,p,h[a+7],16,-155497632),p=y(p,l,i,c,h[a+10],23,-1094730640),c=y(c,p,l,i,h[a+13],4,681279174),i=y(i,c,p,l,h[a+0],11,-358537222),l=y(l,i,c,p,h[a+3],16,-722521979),p=y(p,l,i,c,h[a+6],23,76029189),c=y(c,p,l,i,h[a+9],4,-640364487),i=y(i,c,p,l,h[a+12],11,-421815835),l=y(l,i,c,p,h[a+15],16,530742520),p=y(p,l,i,c,h[a+2],23,-995338651),c=E(c,p,l,i,h[a+0],6,-198630844),i=E(i,c,p,l,h[a+7],10,1126891415),l=E(l,i,c,p,h[a+14],15,-1416354905),p=E(p,l,i,c,h[a+5],21,-57434055),c=E(c,p,l,i,h[a+12],6,1700485571),i=E(i,c,p,l,h[a+3],10,-1894986606),l=E(l,i,c,p,h[a+10],15,-1051523),p=E(p,l,i,c,h[a+1],21,-2054922799),c=E(c,p,l,i,h[a+8],6,1873313359),i=E(i,c,p,l,h[a+15],10,-30611744),l=E(l,i,c,p,h[a+6],15,-1560198380),p=E(p,l,i,c,h[a+13],21,1309151649),c=E(c,p,l,i,h[a+4],6,-145523070),i=E(i,c,p,l,h[a+11],10,-1120210379),l=E(l,i,c,p,h[a+2],15,718787259),p=E(p,l,i,c,h[a+9],21,-343485551),c=c+j>>>0,p=p+U>>>0,l=l+F>>>0,i=i+L>>>0}return s.endian([c,p,l,i])};r._ff=function(o,u,h,d,c,p,l){var i=o+(u&h|~u&d)+(c>>>0)+l;return(i<<p|i>>>32-p)+u},r._gg=function(o,u,h,d,c,p,l){var i=o+(u&d|h&~d)+(c>>>0)+l;return(i<<p|i>>>32-p)+u},r._hh=function(o,u,h,d,c,p,l){var i=o+(u^h^d)+(c>>>0)+l;return(i<<p|i>>>32-p)+u},r._ii=function(o,u,h,d,c,p,l){var i=o+(h^(u|~d))+(c>>>0)+l;return(i<<p|i>>>32-p)+u},r._blocksize=16,r._digestsize=16,ce.exports=function(o,u){if(o==null)throw new Error("Illegal argument "+o);var h=s.wordsToBytes(r(o,u));return u&&u.asBytes?h:u&&u.asString?n.bytesToString(h):s.bytesToHex(h)}})();var Qe=ce.exports;const Ze=gt(Qe);var ft=(s=>(s.BOOTSTRAP="bootstrap",s.DEBUG_EXTENSIONS="debugExtensions",s.DEBUG_QUEUE="debugQueue",s.DEBUG_DIALER="debugDialer",s.FULL="full",s))(ft||{}),it=(s=>(s.MAIN="main",s.NEXT="next",s))(it||{}),rt=(s=>(s.USER="User",s.TOKEN="Token",s))(rt||{});class vt{static async getSessionStorageDataByKey(e,t=!0){if(typeof chrome<"u"&&typeof chrome.storage<"u"){const n=await chrome.storage.session.get(e);if(n[e])return t?JSON.parse(n[e]):n[e]}if(typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.getItem=="function"){const n=window.sessionStorage.getItem(e);if(n)return t?JSON.parse(n):n}}static async updateSessionStorageKey(e,t){typeof chrome<"u"&&typeof chrome.storage<"u"&&await chrome.storage.session.set({[e]:JSON.stringify(t)}),typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.setItem=="function"&&window.sessionStorage.setItem(e,JSON.stringify(t))}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 tn{constructor(e){K(this,"delay",1e3);K(this,"lastLoginTimestamp");K(this,"token");K(this,"refreshToken");K(this,"tokenExpiry");K(this,"storageKey");this.eventsSdkClass=e,this.eventsSdkClass=e,this.storageKey=""}async login(){const e={token:this.eventsSdkClass.options.token&&this.eventsSdkClass.options.token,email:this.eventsSdkClass.options.email&&this.eventsSdkClass.options.email,password:this.eventsSdkClass.options.password&&this.eventsSdkClass.options.password};if(this.storageKey=Ze(JSON.stringify({...this.eventsSdkClass.options,loggerSocketConnection:null},this.eventsSdkClass.getCircularReplacer())),this.lastLoginTimestamp&&this.lastLoginTimestamp+this.delay>new Date().getTime())return;this.updateLastLoginTimestamp();const t=await this.checkLoginStatus(this.storageKey);return t||(vt.clearSessionStorage(),await this.userLoginFunction(e,this.storageKey,this.eventsSdkClass.options.loginType))}updateLastLoginTimestamp(){this.lastLoginTimestamp=new Date().getTime()}async checkLoginStatus(e){const t=await vt.getSessionStorageDataByKey(e);if(t)return t}async userLoginFunction(e,t,n){let r,o,u;return this.eventsSdkClass.options.isNewStack?(r=await this.externalLogin(this.eventsSdkClass.options.loginUrl,e,n),o=await this.getSettings(r.Data.AccessToken),u={...r.Data,...o}):(r=await this.externalLogin(this.eventsSdkClass.options.loginUrl,e,n),u={...r.Data.Socket}),await vt.updateSessionStorageKey(t,u),u}onLoginResponse(e){if(!this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((t,n)=>t.Priority>n.Priority?t:n)),this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((t,n)=>t.Priority>n.Priority?t:n)),e.MonitorList&&e.MonitorList.length&&!this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...e.MonitorList],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((t,n)=>t.Priority>n.Priority?t:n)),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length&&e.URLList&&(this.eventsSdkClass.URLList=e.URLList),!this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.URLList.length&&!this.eventsSdkClass.servers.length)throw new Error("Socket servers not defined");if(this.eventsSdkClass.options.isNewStack&&!this.eventsSdkClass.servers.length)throw new Error("Socket servers not defined");this.eventsSdkClass.server&&this.eventsSdkClass.socketIoClass.getSocketIoFunction(`v=${this.eventsSdkClass.server.Version}`),!this.eventsSdkClass.server&&this.eventsSdkClass.URLList.length&&this.eventsSdkClass.socketIoClass.getSocketIoFunction(`v=${e.Version}`),e.IdentityCode&&(this.token=e.IdentityCode,this.eventsSdkClass.connect(it.MAIN)),e.Token&&(this.token=e.Token,this.eventsSdkClass.connect(it.MAIN)),e.RefreshToken&&e.IdentityCodeExpiry&&this.eventsSdkClass.options.loginType===rt.USER&&(this.refreshToken=e.RefreshToken,this.tokenExpiry=e.IdentityCodeExpiry,this.handleTokenExpiry()),e.RefreshToken&&e.TokenExpiry&&this.normalizeLoginType(this.eventsSdkClass.options.loginType)===rt.USER&&(this.refreshToken=e.RefreshToken,this.tokenExpiry=e.TokenExpiry,this.handleTokenExpiry())}handleTokenExpiry(){if(!this.eventsSdkClass.options.refreshTokenUrl)throw new Error("refreshTokenUrl not provided");let e;if(this.tokenExpiry)e=new Date(this.tokenExpiry);else return;const t=e.getTime()-new Date().getTime()-5e3,n=Math.min(t,2147483647);setTimeout(async()=>{if(this.refreshToken){this.eventsSdkClass.socketIoClass.closeAllConnections();let r,o;if(this.eventsSdkClass.options.isNewStack){const u=await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken);r=await this.getSettings(u.Data.AccessToken),o={...u.Data,...r}}else o={...(await this.externalRefreshToken(this.eventsSdkClass.options.refreshTokenUrl,this.refreshToken)).Data.Socket};this.onLoginResponse(o),await vt.updateSessionStorageKey(this.storageKey,o)}},n)}async externalLogin(e,{password:t,token:n,email:r},o){if(!e)throw new Error("loginUrl not provided");let u;this.eventsSdkClass.options.isNewStack?o===rt.TOKEN?u=JSON.stringify({identityType:rt.TOKEN,token:n}):u=JSON.stringify({identityType:rt.USER,username:r,password:t}):this.eventsSdkClass.options.loginType===rt.TOKEN?(u=JSON.stringify({token:n}),e=`${e}/${rt.TOKEN}`):(u=JSON.stringify({email:r,pin:t}),e=`${e}/${rt.USER}`);let h;try{const d=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:u});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 c=await d.json();if(c.error)throw new Error(c.error);return c}catch(d){throw this.eventsSdkClass.loggerClass.loginError(o,h,n,r),d}}async getSettings(e){try{if(!this.eventsSdkClass.options.getSettingsUrl)throw new Error("getSettingsUrl not provided");const t=await fetch(this.eventsSdkClass.options.getSettingsUrl,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok&&t.status===401)throw new Error("Unauthorized. Access token not provided or not valid");return t.json()}catch(t){throw this.eventsSdkClass.loggerClass.getSettingsError(e,t),t}}async externalRefreshToken(e,t){try{return(await fetch(e,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}})).json()}catch(n){throw this.eventsSdkClass.loggerClass.refreshTokenError(t,e,n),n}}normalizeLoginType(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}}const en={isNewStack:!1,loginUrl:"https://loginapi.voicenter.co.il/monitorAPI/Login",refreshTokenUrl:"https://loginapi.voicenter.co.il/monitorAPI/RefreshIdentityToken",forceNew:!0,reconnectionDelay:1e4,timeout:1e4,keepAliveTimeout:6e4,protocol:"https",useLogger:!0,loggerServer:"https://socketlog.voicenter.co",loggerConfig:{logToConsole:!0,overloadGlobalConsole:!1,system:"events-sdk",socketEmitInterval:1e4},loggerConnectOptions:{reconnection:!1,reconnectionDelay:5e3,reconnectionAttempts:10,perMessageDeflate:void 0,upgrade:!1,transports:["websocket"],debug:!1}};function nn(){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=ut,typeof self.navigator>"u"&&(self.navigator={userAgent:"node"})),function s(e,t,n){function r(h,d){if(!t[h]){if(!e[h]){var c=typeof require=="function"&&require;if(!d&&c)return c(h,!0);if(o)return o(h,!0);throw new Error("Cannot find module '"+h+"'")}var p=t[h]={exports:{}};e[h][0].call(p.exports,function(l){var i=e[h][1][l];return r(i||l)},p,p.exports,s,e,t,n)}return t[h].exports}for(var o=typeof require=="function"&&require,u=0;u<n.length;u++)r(n[u]);return r}({1:[function(s,e){e.exports=s("./lib/")},{"./lib/":2}],2:[function(s,e,t){function n(c,p){typeof c=="object"&&(p=c,c=void 0),p=p||{};var l,i=r(c),a=i.source,f=i.id;return p.forceNew||p["force new connection"]||p.multiplex===!1?(h("ignoring socket cache for %s",a),l=u(a,p)):(d[f]||(h("new io instance for %s",a),d[f]=u(a,p)),l=d[f]),l.socket(i.path)}var r=s("./url"),o=s("socket.io-parser"),u=s("./manager"),h=s("debug")("socket.io-client");e.exports=t=n;var d=t.managers={};t.protocol=o.protocol,t.connect=n,t.Manager=s("./manager"),t.Socket=s("./socket")},{"./manager":3,"./socket":5,"./url":6,debug:10,"socket.io-parser":44}],3:[function(s,e){function t(i,a){return this instanceof t?(i&&typeof i=="object"&&(a=i,i=void 0),a=a||{},a.path=a.path||"/socket.io",this.nsps={},this.subs=[],this.opts=a,this.reconnection(a.reconnection!==!1),this.reconnectionAttempts(a.reconnectionAttempts||1/0),this.reconnectionDelay(a.reconnectionDelay||1e3),this.reconnectionDelayMax(a.reconnectionDelayMax||5e3),this.randomizationFactor(a.randomizationFactor||.5),this.backoff=new l({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(a.timeout==null?2e4:a.timeout),this.readyState="closed",this.uri=i,this.connected=[],this.encoding=!1,this.packetBuffer=[],this.encoder=new u.Encoder,this.decoder=new u.Decoder,this.autoConnect=a.autoConnect!==!1,void(this.autoConnect&&this.open())):new t(i,a)}var n=(s("./url"),s("engine.io-client")),r=s("./socket"),o=s("component-emitter"),u=s("socket.io-parser"),h=s("./on"),d=s("component-bind"),c=(s("object-component"),s("debug")("socket.io-client:manager")),p=s("indexof"),l=s("backo2");e.exports=t,t.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var i in this.nsps)this.nsps[i].emit.apply(this.nsps[i],arguments)},t.prototype.updateSocketIds=function(){for(var i in this.nsps)this.nsps[i].id=this.engine.id},o(t.prototype),t.prototype.reconnection=function(i){return arguments.length?(this._reconnection=!!i,this):this._reconnection},t.prototype.reconnectionAttempts=function(i){return arguments.length?(this._reconnectionAttempts=i,this):this._reconnectionAttempts},t.prototype.reconnectionDelay=function(i){return arguments.length?(this._reconnectionDelay=i,this.backoff&&this.backoff.setMin(i),this):this._reconnectionDelay},t.prototype.randomizationFactor=function(i){return arguments.length?(this._randomizationFactor=i,this.backoff&&this.backoff.setJitter(i),this):this._randomizationFactor},t.prototype.reconnectionDelayMax=function(i){return arguments.length?(this._reconnectionDelayMax=i,this.backoff&&this.backoff.setMax(i),this):this._reconnectionDelayMax},t.prototype.timeout=function(i){return arguments.length?(this._timeout=i,this):this._timeout},t.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()},t.prototype.open=t.prototype.connect=function(i){if(c("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;c("opening %s",this.uri),this.engine=n(this.uri,this.opts);var a=this.engine,f=this;this.readyState="opening",this.skipReconnect=!1;var g=h(a,"open",function(){f.onopen(),i&&i()}),y=h(a,"error",function(U){if(c("connect_error"),f.cleanup(),f.readyState="closed",f.emitAll("connect_error",U),i){var F=new Error("Connection error");F.data=U,i(F)}else f.maybeReconnectOnOpen()});if(this._timeout!==!1){var E=this._timeout;c("connect attempt will timeout after %d",E);var j=setTimeout(function(){c("connect attempt timed out after %d",E),g.destroy(),a.close(),a.emit("error","timeout"),f.emitAll("connect_timeout",E)},E);this.subs.push({destroy:function(){clearTimeout(j)}})}return this.subs.push(g),this.subs.push(y),this},t.prototype.onopen=function(){c("open"),this.cleanup(),this.readyState="open",this.emit("open");var i=this.engine;this.subs.push(h(i,"data",d(this,"ondata"))),this.subs.push(h(this.decoder,"decoded",d(this,"ondecoded"))),this.subs.push(h(i,"error",d(this,"onerror"))),this.subs.push(h(i,"close",d(this,"onclose")))},t.prototype.ondata=function(i){this.decoder.add(i)},t.prototype.ondecoded=function(i){this.emit("packet",i)},t.prototype.onerror=function(i){c("error",i),this.emitAll("error",i)},t.prototype.socket=function(i){var a=this.nsps[i];if(!a){a=new r(this,i),this.nsps[i]=a;var f=this;a.on("connect",function(){a.id=f.engine.id,~p(f.connected,a)||f.connected.push(a)})}return a},t.prototype.destroy=function(i){var a=p(this.connected,i);~a&&this.connected.splice(a,1),this.connected.length||this.close()},t.prototype.packet=function(i){c("writing packet %j",i);var a=this;a.encoding?a.packetBuffer.push(i):(a.encoding=!0,this.encoder.encode(i,function(f){for(var g=0;g<f.length;g++)a.engine.write(f[g]);a.encoding=!1,a.processPacketQueue()}))},t.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var i=this.packetBuffer.shift();this.packet(i)}},t.prototype.cleanup=function(){for(var i;i=this.subs.shift();)i.destroy();this.packetBuffer=[],this.encoding=!1,this.decoder.destroy()},t.prototype.close=t.prototype.disconnect=function(){this.skipReconnect=!0,this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},t.prototype.onclose=function(i){c("close"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",i),this._reconnection&&!this.skipReconnect&&this.reconnect()},t.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var i=this;if(this.backoff.attempts>=this._reconnectionAttempts)c("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var a=this.backoff.duration();c("will wait %dms before reconnect attempt",a),this.reconnecting=!0;var f=setTimeout(function(){i.skipReconnect||(c("attempting reconnect"),i.emitAll("reconnect_attempt",i.backoff.attempts),i.emitAll("reconnecting",i.backoff.attempts),i.skipReconnect||i.open(function(g){g?(c("reconnect attempt error"),i.reconnecting=!1,i.reconnect(),i.emitAll("reconnect_error",g.data)):(c("reconnect success"),i.onreconnect())}))},a);this.subs.push({destroy:function(){clearTimeout(f)}})}},t.prototype.onreconnect=function(){var i=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",i)}},{"./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(s,e){function t(n,r,o){return n.on(r,o),{destroy:function(){n.removeListener(r,o)}}}e.exports=t},{}],5:[function(s,e,t){function n(a,f){this.io=a,this.nsp=f,this.json=this,this.ids=0,this.acks={},this.io.autoConnect&&this.open(),this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0}var r=s("socket.io-parser"),o=s("component-emitter"),u=s("to-array"),h=s("./on"),d=s("component-bind"),c=s("debug")("socket.io-client:socket"),p=s("has-binary");e.exports=n;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},i=o.prototype.emit;o(n.prototype),n.prototype.subEvents=function(){if(!this.subs){var a=this.io;this.subs=[h(a,"open",d(this,"onopen")),h(a,"packet",d(this,"onpacket")),h(a,"close",d(this,"onclose"))]}},n.prototype.open=n.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),this.io.readyState=="open"&&this.onopen(),this)},n.prototype.send=function(){var a=u(arguments);return a.unshift("message"),this.emit.apply(this,a),this},n.prototype.emit=function(a){if(l.hasOwnProperty(a))return i.apply(this,arguments),this;var f=u(arguments),g=r.EVENT;p(f)&&(g=r.BINARY_EVENT);var y={type:g,data:f};return typeof f[f.length-1]=="function"&&(c("emitting packet with ack id %d",this.ids),this.acks[this.ids]=f.pop(),y.id=this.ids++),this.connected?this.packet(y):this.sendBuffer.push(y),this},n.prototype.packet=function(a){a.nsp=this.nsp,this.io.packet(a)},n.prototype.onopen=function(){c("transport is open - connecting"),this.nsp!="/"&&this.packet({type:r.CONNECT})},n.prototype.onclose=function(a){c("close (%s)",a),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",a)},n.prototype.onpacket=function(a){if(a.nsp==this.nsp)switch(a.type){case r.CONNECT:this.onconnect();break;case r.EVENT:this.onevent(a);break;case r.BINARY_EVENT:this.onevent(a);break;case r.ACK:this.onack(a);break;case r.BINARY_ACK:this.onack(a);break;case r.DISCONNECT:this.ondisconnect();break;case r.ERROR:this.emit("error",a.data)}},n.prototype.onevent=function(a){var f=a.data||[];c("emitting event %j",f),a.id!=null&&(c("attaching ack callback to event"),f.push(this.ack(a.id))),this.connected?i.apply(this,f):this.receiveBuffer.push(f)},n.prototype.ack=function(a){var f=this,g=!1;return function(){if(!g){g=!0;var y=u(arguments);c("sending ack %j",y);var E=p(y)?r.BINARY_ACK:r.ACK;f.packet({type:E,id:a,data:y})}}},n.prototype.onack=function(a){c("calling ack %s with %j",a.id,a.data);var f=this.acks[a.id];f.apply(this,a.data),delete this.acks[a.id]},n.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},n.prototype.emitBuffered=function(){var a;for(a=0;a<this.receiveBuffer.length;a++)i.apply(this,this.receiveBuffer[a]);for(this.receiveBuffer=[],a=0;a<this.sendBuffer.length;a++)this.packet(this.sendBuffer[a]);this.sendBuffer=[]},n.prototype.ondisconnect=function(){c("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},n.prototype.destroy=function(){if(this.subs){for(var a=0;a<this.subs.length;a++)this.subs[a].destroy();this.subs=null}this.io.destroy(this)},n.prototype.close=n.prototype.disconnect=function(){return this.connected&&(c("performing disconnect (%s)",this.nsp),this.packet({type:r.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(s,e){(function(t){function n(u,c){var d=u,c=c||t.location;return u==null&&(u=c.protocol+"//"+c.host),typeof u=="string"&&(u.charAt(0)=="/"&&(u=u.charAt(1)=="/"?c.protocol+u:c.hostname+u),/^(https?|wss?):\/\//.test(u)||(o("protocol-less url %s",u),u=typeof c<"u"?c.protocol+"//"+u:"https://"+u),o("parse %s",u),d=r(u)),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+(c&&c.port==d.port?"":":"+d.port),d}var r=s("parseuri"),o=s("debug")("socket.io-client:url");e.exports=n}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{debug:10,parseuri:42}],7:[function(s,e){function t(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}e.exports=t,t.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var r=Math.random(),o=Math.floor(r*this.jitter*n);n=1&Math.floor(10*r)?n+o:n-o}return 0|Math.min(n,this.max)},t.prototype.reset=function(){this.attempts=0},t.prototype.setMin=function(n){this.ms=n},t.prototype.setMax=function(n){this.max=n},t.prototype.setJitter=function(n){this.jitter=n}},{}],8:[function(s,e){var t=[].slice;e.exports=function(n,r){if(typeof r=="string"&&(r=n[r]),typeof r!="function")throw new Error("bind() requires a function");var o=t.call(arguments,2);return function(){return r.apply(n,o.concat(t.call(arguments)))}}},{}],9:[function(s,e){function t(r){return r?n(r):void 0}function n(r){for(var o in t.prototype)r[o]=t.prototype[o];return r}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(r,o){return this._callbacks=this._callbacks||{},(this._callbacks[r]=this._callbacks[r]||[]).push(o),this},t.prototype.once=function(r,o){function u(){h.off(r,u),o.apply(this,arguments)}var h=this;return this._callbacks=this._callbacks||{},u.fn=o,this.on(r,u),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(r,o){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var u=this._callbacks[r];if(!u)return this;if(arguments.length==1)return delete this._callbacks[r],this;for(var h,d=0;d<u.length;d++)if(h=u[d],h===o||h.fn===o){u.splice(d,1);break}return this},t.prototype.emit=function(r){this._callbacks=this._callbacks||{};var o=[].slice.call(arguments,1),u=this._callbacks[r];if(u){u=u.slice(0);for(var h=0,d=u.length;d>h;++h)u[h].apply(this,o)}return this},t.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks[r]||[]},t.prototype.hasListeners=function(r){return!!this.listeners(r).length}},{}],10:[function(s,e){function t(r){return t.enabled(r)?function(o){o=n(o);var u=new Date,h=u-(t[r]||u);t[r]=u,o=r+" "+o+" +"+t.humanize(h),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}function n(r){return r instanceof Error?r.stack||r.message:r}e.exports=t,t.names=[],t.skips=[],t.enable=function(r){try{localStorage.debug=r}catch{}for(var o=(r||"").split(/[\s,]+/),u=o.length,h=0;u>h;h++)r=o[h].replace("*",".*?"),r[0]==="-"?t.skips.push(new RegExp("^"+r.substr(1)+"$")):t.names.push(new RegExp("^"+r+"$"))},t.disable=function(){t.enable("")},t.humanize=function(r){var o=1e3,u=6e4,h=60*u;return r>=h?(r/h).toFixed(1)+"h":r>=u?(r/u).toFixed(1)+"m":r>=o?(r/o|0)+"s":r+"ms"},t.enabled=function(r){for(var o=0,u=t.skips.length;u>o;o++)if(t.skips[o].test(r))return!1;for(var o=0,u=t.names.length;u>o;o++)if(t.names[o].test(r))return!0;return!1};try{window.localStorage&&t.enable(localStorage.debug)}catch{}},{}],11:[function(s,e){e.exports=s("./lib/")},{"./lib/":12}],12:[function(s,e){e.exports=s("./socket"),e.exports.parser=s("engine.io-parser")},{"./socket":13,"engine.io-parser":25}],13:[function(s,e){(function(t){function n(a,f){if(!(this instanceof n))return new n(a,f);if(f=f||{},a&&typeof a=="object"&&(f=a,a=null),a&&(a=p(a),f.host=a.host,f.secure=a.protocol=="https"||a.protocol=="wss",f.port=a.port,a.query&&(f.query=a.query)),this.secure=f.secure!=null?f.secure:t.location&&location.protocol=="https:",f.host){var g=f.host.split(":");f.hostname=g.shift(),g.length?f.port=g.pop():f.port||(f.port=this.secure?"443":"80")}this.agent=f.agent||!1,this.hostname=f.hostname||(t.location?location.hostname:"localhost"),this.port=f.port||(t.location&&location.port?location.port:this.secure?443:80),this.query=f.query||{},typeof this.query=="string"&&(this.query=i.decode(this.query)),this.upgrade=f.upgrade!==!1,this.path=(f.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!f.forceJSONP,this.jsonp=f.jsonp!==!1,this.forceBase64=!!f.forceBase64,this.enablesXDR=!!f.enablesXDR,this.timestampParam=f.timestampParam||"t",this.timestampRequests=f.timestampRequests,this.transports=f.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.callbackBuffer=[],this.policyPort=f.policyPort||843,this.rememberUpgrade=f.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=f.onlyBinaryUpgrades,this.pfx=f.pfx||null,this.key=f.key||null,this.passphrase=f.passphrase||null,this.cert=f.cert||null,this.ca=f.ca||null,this.ciphers=f.ciphers||null,this.rejectUnauthorized=f.rejectUnauthorized||null,this.open()}function r(a){var f={};for(var g in a)a.hasOwnProperty(g)&&(f[g]=a[g]);return f}var o=s("./transports"),u=s("component-emitter"),h=s("debug")("engine.io-client:socket"),d=s("indexof"),c=s("engine.io-parser"),p=s("parseuri"),l=s("parsejson"),i=s("parseqs");e.exports=n,n.priorWebsocketSuccess=!1,u(n.prototype),n.protocol=c.protocol,n.Socket=n,n.Transport=s("./transport"),n.transports=s("./transports"),n.parser=s("engine.io-parser"),n.prototype.createTransport=function(a){h('creating transport "%s"',a);var f=r(this.query);f.EIO=c.protocol,f.transport=a,this.id&&(f.sid=this.id);var g=new o[a]({agent:this.agent,hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:f,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},n.prototype.open=function(){var f;if(this.rememberUpgrade&&n.priorWebsocketSuccess&&this.transports.indexOf("websocket")!=-1)f="websocket";else{if(this.transports.length==0){var a=this;return void setTimeout(function(){a.emit("error","No transports available")},0)}f=this.transports[0]}this.readyState="opening";var f;try{f=this.createTransport(f)}catch{return this.transports.shift(),void this.open()}f.open(),this.setTransport(f)},n.prototype.setTransport=function(a){h("setting transport %s",a.name);var f=this;this.transport&&(h("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=a,a.on("drain",function(){f.onDrain()}).on("packet",function(g){f.onPacket(g)}).on("error",function(g){f.onError(g)}).on("close",function(){f.onClose("transport close")})},n.prototype.probe=function(a){function f(){if(T.onlyBinaryUpgrades){var A=!this.supportsBinary&&T.transport.supportsBinary;S=S||A}S||(h('probe transport "%s" opened',a),L.send([{type:"ping",data:"probe"}]),L.once("packet",function(m){if(!S)if(m.type=="pong"&&m.data=="probe"){if(h('probe transport "%s" pong',a),T.upgrading=!0,T.emit("upgrading",L),!L)return;n.priorWebsocketSuccess=L.name=="websocket",h('pausing current transport "%s"',T.transport.name),T.transport.pause(function(){S||T.readyState!="closed"&&(h("changing transport and sending upgrade packet"),F(),T.setTransport(L),L.send([{type:"upgrade"}]),T.emit("upgrade",L),L=null,T.upgrading=!1,T.flush())})}else{h('probe transport "%s" failed',a);var v=new Error("probe error");v.transport=L.name,T.emit("upgradeError",v)}}))}function g(){S||(S=!0,F(),L.close(),L=null)}function y(A){var m=new Error("probe error: "+A);m.transport=L.name,g(),h('probe transport "%s" failed because of error: %s',a,A),T.emit("upgradeError",m)}function E(){y("transport closed")}function j(){y("socket closed")}function U(A){L&&A.name!=L.name&&(h('"%s" works - aborting "%s"',A.name,L.name),g())}function F(){L.removeListener("open",f),L.removeListener("error",y),L.removeListener("close",E),T.removeListener("close",j),T.removeListener("upgrading",U)}h('probing transport "%s"',a);var L=this.createTransport(a,{probe:1}),S=!1,T=this;n.priorWebsocketSuccess=!1,L.once("open",f),L.once("error",y),L.once("close",E),this.once("close",j),this.once("upgrading",U),L.open()},n.prototype.onOpen=function(){if(h("socket open"),this.readyState="open",n.priorWebsocketSuccess=this.transport.name=="websocket",this.emit("open"),this.flush(),this.readyState=="open"&&this.upgrade&&this.transport.pause){h("starting upgrade probes");for(var a=0,f=this.upgrades.length;f>a;a++)this.probe(this.upgrades[a])}},n.prototype.onPacket=function(a){if(this.readyState=="opening"||this.readyState=="open")switch(h('socket receive: type "%s", data "%s"',a.type,a.data),this.emit("packet",a),this.emit("heartbeat"),a.type){case"open":this.onHandshake(l(a.data));break;case"pong":this.setPing();break;case"error":var f=new Error("server error");f.code=a.data,this.emit("error",f);break;case"message":this.emit("data",a.data),this.emit("message",a.data)}else h('packet received with socket readyState "%s"',this.readyState)},n.prototype.onHandshake=function(a){this.emit("handshake",a),this.id=a.sid,this.transport.query.sid=a.sid,this.upgrades=this.filterUpgrades(a.upgrades),this.pingInterval=a.pingInterval,this.pingTimeout=a.pingTimeout,this.onOpen(),this.readyState!="closed"&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},n.prototype.onHeartbeat=function(a){clearTimeout(this.pingTimeoutTimer);var f=this;f.pingTimeoutTimer=setTimeout(function(){f.readyState!="closed"&&f.onClose("ping timeout")},a||f.pingInterval+f.pingTimeout)},n.prototype.setPing=function(){var a=this;clearTimeout(a.pingIntervalTimer),a.pingIntervalTimer=setTimeout(function(){h("writing ping packet - expecting pong within %sms",a.pingTimeout),a.ping(),a.onHeartbeat(a.pingTimeout)},a.pingInterval)},n.prototype.ping=function(){this.sendPacket("ping")},n.prototype.onDrain=function(){for(var a=0;a<this.prevBufferLen;a++)this.callbackBuffer[a]&&this.callbackBuffer[a]();this.writeBuffer.splice(0,this.prevBufferLen),this.callbackBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length==0?this.emit("drain"):this.flush()},n.prototype.flush=function(){this.readyState!="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(h("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},n.prototype.write=n.prototype.send=function(a,f){return this.sendPacket("message",a,f),this},n.prototype.sendPacket=function(a,f,g){if(this.readyState!="closing"&&this.readyState!="closed"){var y={type:a,data:f};this.emit("packetCreate",y),this.writeBuffer.push(y),this.callbackBuffer.push(g),this.flush()}},n.prototype.close=function(){function a(){y.onClose("forced close"),h("socket closing - telling transport to close"),y.transport.close()}function f(){y.removeListener("upgrade",f),y.removeListener("upgradeError",f),a()}function g(){y.once("upgrade",f),y.once("upgradeError",f)}if(this.readyState=="opening"||this.readyState=="open"){this.readyState="closing";var y=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?g():a()}):this.upgrading?g():a()}return this},n.prototype.onError=function(a){h("socket error %j",a),n.priorWebsocketSuccess=!1,this.emit("error",a),this.onClose("transport error",a)},n.prototype.onClose=function(a,f){if(this.readyState=="opening"||this.readyState=="open"||this.readyState=="closing"){h('socket close with reason: "%s"',a);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",a,f)}},n.prototype.filterUpgrades=function(a){for(var f=[],g=0,y=a.length;y>g;g++)~d(this.transports,a[g])&&f.push(a[g]);return f}}).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(s,e){function t(o){this.path=o.path,this.hostname=o.hostname,this.port=o.port,this.secure=o.secure,this.query=o.query,this.timestampParam=o.timestampParam,this.timestampRequests=o.timestampRequests,this.readyState="",this.agent=o.agent||!1,this.socket=o.socket,this.enablesXDR=o.enablesXDR,this.pfx=o.pfx,this.key=o.key,this.passphrase=o.passphrase,this.cert=o.cert,this.ca=o.ca,this.ciphers=o.ciphers,this.rejectUnauthorized=o.rejectUnauthorized}var n=s("engine.io-parser"),r=s("component-emitter");e.exports=t,r(t.prototype),t.timestamps=0,t.prototype.onError=function(o,u){var h=new Error(o);return h.type="TransportError",h.description=u,this.emit("error",h),this},t.prototype.open=function(){return(this.readyState=="closed"||this.readyState=="")&&(this.readyState="opening",this.doOpen()),this},t.prototype.close=function(){return(this.readyState=="opening"||this.readyState=="open")&&(this.doClose(),this.onClose()),this},t.prototype.send=function(o){if(this.readyState!="open")throw new Error("Transport not open");this.write(o)},t.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},t.prototype.onData=function(o){var u=n.decodePacket(o,this.socket.binaryType);this.onPacket(u)},t.prototype.onPacket=function(o){this.emit("packet",o)},t.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},{"component-emitter":9,"engine.io-parser":25}],15:[function(s,e,t){(function(n){function r(c){var p,l=!1,i=!1,a=c.jsonp!==!1;if(n.location){var f=location.protocol=="https:",g=location.port;g||(g=f?443:80),l=c.hostname!=location.hostname||g!=c.port,i=c.secure!=f}if(c.xdomain=l,c.xscheme=i,p=new o(c),"open"in p&&!c.forceJSONP)return new u(c);if(!a)throw new Error("JSONP disabled");return new h(c)}var o=s("xmlhttprequest"),u=s("./polling-xhr"),h=s("./polling-jsonp"),d=s("./websocket");t.polling=r,t.websocket=d}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling-jsonp":16,"./polling-xhr":17,"./websocket":19,xmlhttprequest:20}],16:[function(s,e){(function(t){function n(){}function r(p){o.call(this,p),this.query=this.query||{},h||(t.___eio||(t.___eio=[]),h=t.___eio),this.index=h.length;var l=this;h.push(function(i){l.onData(i)}),this.query.j=this.index,t.document&&t.addEventListener&&t.addEventListener("beforeunload",function(){l.script&&(l.script.onerror=n)},!1)}var o=s("./polling"),u=s("component-inherit");e.exports=r;var h,d=/\n/g,c=/\\n/g;u(r,o),r.prototype.supportsBinary=!1,r.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),o.prototype.doClose.call(this)},r.prototype.doPoll=function(){var p=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(f){p.onError("jsonp poll error",f)};var i=document.getElementsByTagName("script")[0];i.parentNode.insertBefore(l,i),this.script=l;var a=typeof navigator<"u"&&/gecko/i.test(navigator.userAgent);a&&setTimeout(function(){var f=document.createElement("iframe");document.body.appendChild(f),document.body.removeChild(f)},100)},r.prototype.doWrite=function(p,l){function i(){a(),l()}function a(){if(f.iframe)try{f.form.removeChild(f.iframe)}catch(F){f.onError("jsonp polling iframe removal error",F)}try{var U='<iframe src="javascript:0" name="'+f.iframeId+'">';g=document.createElement(U)}catch{g=document.createElement("iframe"),g.name=f.iframeId,g.src="javascript:0"}g.id=f.iframeId,f.form.appendChild(g),f.iframe=g}var f=this;if(!this.form){var g,y=document.createElement("form"),E=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"),E.name="d",y.appendChild(E),document.body.appendChild(y),this.form=y,this.area=E}this.form.action=this.uri(),a(),p=p.replace(c,`\\
7
- `),this.area.value=p.replace(d,"\\n");try{this.form.submit()}catch{}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){f.iframe.readyState=="complete"&&i()}:this.iframe.onload=i}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-inherit":21}],17:[function(s,e){(function(t){function n(){}function r(i){if(d.call(this,i),t.location){var a=location.protocol=="https:",f=location.port;f||(f=a?443:80),this.xd=i.hostname!=t.location.hostname||f!=i.port,this.xs=i.secure!=a}}function o(i){this.method=i.method||"GET",this.uri=i.uri,this.xd=!!i.xd,this.xs=!!i.xs,this.async=i.async!==!1,this.data=i.data!=null?i.data:null,this.agent=i.agent,this.isBinary=i.isBinary,this.supportsBinary=i.supportsBinary,this.enablesXDR=i.enablesXDR,this.pfx=i.pfx,this.key=i.key,this.passphrase=i.passphrase,this.cert=i.cert,this.ca=i.ca,this.ciphers=i.ciphers,this.rejectUnauthorized=i.rejectUnauthorized,this.create()}function u(){for(var i in o.requests)o.requests.hasOwnProperty(i)&&o.requests[i].abort()}var h=s("xmlhttprequest"),d=s("./polling"),c=s("component-emitter"),p=s("component-inherit"),l=s("debug")("engine.io-client:polling-xhr");e.exports=r,e.exports.Request=o,p(r,d),r.prototype.supportsBinary=!0,r.prototype.request=function(i){return i=i||{},i.uri=this.uri(),i.xd=this.xd,i.xs=this.xs,i.agent=this.agent||!1,i.supportsBinary=this.supportsBinary,i.enablesXDR=this.enablesXDR,i.pfx=this.pfx,i.key=this.key,i.passphrase=this.passphrase,i.cert=this.cert,i.ca=this.ca,i.ciphers=this.ciphers,i.rejectUnauthorized=this.rejectUnauthorized,new o(i)},r.prototype.doWrite=function(i,a){var f=typeof i!="string"&&i!==void 0,g=this.request({method:"POST",data:i,isBinary:f}),y=this;g.on("success",a),g.on("error",function(E){y.onError("xhr post error",E)}),this.sendXhr=g},r.prototype.doPoll=function(){l("xhr poll");var i=this.request(),a=this;i.on("data",function(f){a.onData(f)}),i.on("error",function(f){a.onError("xhr poll error",f)}),this.pollXhr=i},c(o.prototype),o.prototype.create=function(){var i={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};i.pfx=this.pfx,i.key=this.key,i.passphrase=this.passphrase,i.cert=this.cert,i.ca=this.ca,i.ciphers=this.ciphers,i.rejectUnauthorized=this.rejectUnauthorized;var a=this.xhr=new h(i),f=this;try{if(l("xhr open %s: %s",this.method,this.uri),a.open(this.method,this.uri,this.async),this.supportsBinary&&(a.responseType="arraybuffer"),this.method=="POST")try{this.isBinary?a.setRequestHeader("Content-type","application/octet-stream"):a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}"withCredentials"in a&&(a.withCredentials=!0),this.hasXDR()?(a.onload=function(){f.onLoad()},a.onerror=function(){f.onError(a.responseText)}):a.onreadystatechange=function(){a.readyState==4&&(a.status==200||a.status==1223?f.onLoad():setTimeout(function(){f.onError(a.status)},0))},l("xhr data %s",this.data),a.send(this.data)}catch(g){return void setTimeout(function(){f.onError(g)},0)}t.document&&(this.index=o.requestsCount++,o.requests[this.index]=this)},o.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},o.prototype.onData=function(i){this.emit("data",i),this.onSuccess()},o.prototype.onError=function(i){this.emit("error",i),this.cleanup(!0)},o.prototype.cleanup=function(i){if(typeof this.xhr<"u"&&this.xhr!==null){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=n:this.xhr.onreadystatechange=n,i)try{this.xhr.abort()}catch{}t.document&&delete o.requests[this.index],this.xhr=null}},o.prototype.onLoad=function(){var i;try{var a;try{a=this.xhr.getResponseHeader("Content-Type").split(";")[0]}catch{}i=a==="application/octet-stream"?this.xhr.response:this.supportsBinary?"ok":this.xhr.responseText}catch(f){this.onError(f)}i!=null&&this.onData(i)},o.prototype.hasXDR=function(){return typeof t.XDomainRequest<"u"&&!this.xs&&this.enablesXDR},o.prototype.abort=function(){this.cleanup()},t.document&&(o.requestsCount=0,o.requests={},t.attachEvent?t.attachEvent("onunload",u):t.addEventListener&&t.addEventListener("beforeunload",u,!1))}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-emitter":9,"component-inherit":21,debug:22,xmlhttprequest:20}],18:[function(s,e){function t(c){var p=c&&c.forceBase64;(!d||p)&&(this.supportsBinary=!1),n.call(this,c)}var n=s("../transport"),r=s("parseqs"),o=s("engine.io-parser"),u=s("component-inherit"),h=s("debug")("engine.io-client:polling");e.exports=t;var d=function(){var c=s("xmlhttprequest"),p=new c({xdomain:!1});return p.responseType!=null}();u(t,n),t.prototype.name="polling",t.prototype.doOpen=function(){this.poll()},t.prototype.pause=function(c){function p(){h("paused"),l.readyState="paused",c()}var l=this;if(this.readyState="pausing",this.polling||!this.writable){var i=0;this.polling&&(h("we are currently polling - waiting to pause"),i++,this.once("pollComplete",function(){h("pre-pause polling complete"),--i||p()})),this.writable||(h("we are currently writing - waiting to pause"),i++,this.once("drain",function(){h("pre-pause writing complete"),--i||p()}))}else p()},t.prototype.poll=function(){h("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},t.prototype.onData=function(c){var p=this;h("polling got data %s",c);var l=function(i){return p.readyState=="opening"&&p.onOpen(),i.type=="close"?(p.onClose(),!1):void p.onPacket(i)};o.decodePayload(c,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))},t.prototype.doClose=function(){function c(){h("writing close packet"),p.write([{type:"close"}])}var p=this;this.readyState=="open"?(h("transport open - closing"),c()):(h("transport not open - deferring close"),this.once("open",c))},t.prototype.write=function(c){var l=this;this.writable=!1;var p=function(){l.writable=!0,l.emit("drain")},l=this;o.encodePayload(c,this.supportsBinary,function(i){l.doWrite(i,p)})},t.prototype.uri=function(){var c=this.query||{},p=this.secure?"https":"http",l="";return this.timestampRequests!==!1&&(c[this.timestampParam]=+new Date+"-"+n.timestamps++),this.supportsBinary||c.sid||(c.b64=1),c=r.encode(c),this.port&&(p=="https"&&this.port!=443||p=="http"&&this.port!=80)&&(l=":"+this.port),c.length&&(c="?"+c),p+"://"+this.hostname+l+this.path+c}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,xmlhttprequest:20}],19:[function(s,e){function t(c){var p=c&&c.forceBase64;p&&(this.supportsBinary=!1),n.call(this,c)}var n=s("../transport"),r=s("engine.io-parser"),o=s("parseqs"),u=s("component-inherit"),h=s("debug")("engine.io-client:websocket"),d=s("ws");e.exports=t,u(t,n),t.prototype.name="websocket",t.prototype.supportsBinary=!0,t.prototype.doOpen=function(){if(this.check()){var c=this.uri(),p=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(c,p,l),this.ws.binaryType===void 0&&(this.supportsBinary=!1),this.ws.binaryType="arraybuffer",this.addEventListeners()}},t.prototype.addEventListeners=function(){var c=this;this.ws.onopen=function(){c.onOpen()},this.ws.onclose=function(){c.onClose()},this.ws.onmessage=function(p){c.onData(p.data)},this.ws.onerror=function(p){c.onError("websocket error",p)}},typeof navigator<"u"&&/iPad|iPhone|iPod/i.test(navigator.userAgent)&&(t.prototype.onData=function(c){var p=this;setTimeout(function(){n.prototype.onData.call(p,c)},0)}),t.prototype.write=function(c){function p(){l.writable=!0,l.emit("drain")}var l=this;this.writable=!1;for(var i=0,a=c.length;a>i;i++)r.encodePacket(c[i],this.supportsBinary,function(f){try{l.ws.send(f)}catch{h("websocket closed before onclose event")}});setTimeout(p,0)},t.prototype.onClose=function(){n.prototype.onClose.call(this)},t.prototype.doClose=function(){typeof this.ws<"u"&&this.ws.close()},t.prototype.uri=function(){var c=this.query||{},p=this.secure?"wss":"ws",l="";return this.port&&(p=="wss"&&this.port!=443||p=="ws"&&this.port!=80)&&(l=":"+this.port),this.timestampRequests&&(c[this.timestampParam]=+new Date),this.supportsBinary||(c.b64=1),c=o.encode(c),c.length&&(c="?"+c),p+"://"+this.hostname+l+this.path+c},t.prototype.check=function(){return!(!d||"__initialize"in d&&this.name===t.prototype.name)}},{"../transport":14,"component-inherit":21,debug:22,"engine.io-parser":25,parseqs:33,ws:35}],20:[function(s,e){var t=s("has-cors");e.exports=function(n){var r=n.xdomain,o=n.xscheme,u=n.enablesXDR;try{if(typeof XMLHttpRequest<"u"&&(!r||t))return new XMLHttpRequest}catch{}try{if(typeof XDomainRequest<"u"&&!o&&u)return new XDomainRequest}catch{}if(!r)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch{}}},{"has-cors":38}],21:[function(s,e){e.exports=function(t,n){var r=function(){};r.prototype=n.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],22:[function(s,e,t){function n(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function r(){var d=arguments,c=this.useColors;if(d[0]=(c?"%c":"")+this.namespace+(c?" %c":" ")+d[0]+(c?"%c ":" ")+"+"+t.humanize(this.diff),!c)return d;var p="color: "+this.color;d=[d[0],p,"color: inherit"].concat(Array.prototype.slice.call(d,1));var l=0,i=0;return d[0].replace(/%[a-z%]/g,function(a){a!=="%%"&&(l++,a==="%c"&&(i=l))}),d.splice(i,0,p),d}function o(){return typeof console=="object"&&typeof console.log=="function"&&Function.prototype.apply.call(console.log,console,arguments)}function u(d){try{d==null?localStorage.removeItem("debug"):localStorage.debug=d}catch{}}function h(){var d;try{d=localStorage.debug}catch{}return d}t=e.exports=s("./debug"),t.log=o,t.formatArgs=r,t.save=u,t.load=h,t.useColors=n,t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(d){return JSON.stringify(d)},t.enable(h())},{"./debug":23}],23:[function(s,e,t){function n(){return t.colors[p++%t.colors.length]}function r(l){function i(){}function a(){var g=a,y=+new Date,E=y-(c||y);g.diff=E,g.prev=c,g.curr=y,c=y,g.useColors==null&&(g.useColors=t.useColors()),g.color==null&&g.useColors&&(g.color=n());var j=Array.prototype.slice.call(arguments);j[0]=t.coerce(j[0]),typeof j[0]!="string"&&(j=["%o"].concat(j));var U=0;j[0]=j[0].replace(/%([a-z%])/g,function(L,S){if(L==="%%")return L;U++;var T=t.formatters[S];if(typeof T=="function"){var A=j[U];L=T.call(g,A),j.splice(U,1),U--}return L}),typeof t.formatArgs=="function"&&(j=t.formatArgs.apply(g,j));var F=a.log||t.log||console.log.bind(console);F.apply(g,j)}i.enabled=!1,a.enabled=!0;var f=t.enabled(l)?a:i;return f.namespace=l,f}function o(l){t.save(l);for(var i=(l||"").split(/[\s,]+/),a=i.length,f=0;a>f;f++)i[f]&&(l=i[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.substr(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function u(){t.enable("")}function h(l){var i,a;for(i=0,a=t.skips.length;a>i;i++)if(t.skips[i].test(l))return!1;for(i=0,a=t.names.length;a>i;i++)if(t.names[i].test(l))return!0;return!1}function d(l){return l instanceof Error?l.stack||l.message:l}t=e.exports=r,t.coerce=d,t.disable=u,t.enable=o,t.enabled=h,t.humanize=s("ms"),t.names=[],t.skips=[],t.formatters={};var c,p=0},{ms:24}],24:[function(s,e){function t(l){var i=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(l);if(i){var a=parseFloat(i[1]),f=(i[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"y":return a*p;case"days":case"day":case"d":return a*c;case"hours":case"hour":case"h":return a*d;case"minutes":case"minute":case"m":return a*h;case"seconds":case"second":case"s":return a*u;case"ms":return a}}}function n(l){return l>=c?Math.round(l/c)+"d":l>=d?Math.round(l/d)+"h":l>=h?Math.round(l/h)+"m":l>=u?Math.round(l/u)+"s":l+"ms"}function r(l){return o(l,c,"day")||o(l,d,"hour")||o(l,h,"minute")||o(l,u,"second")||l+" ms"}function o(l,i,a){return i>l?void 0:1.5*i>l?Math.floor(l/i)+" "+a:Math.ceil(l/i)+" "+a+"s"}var u=1e3,h=60*u,d=60*h,c=24*d,p=365.25*c;e.exports=function(l,i){return i=i||{},typeof l=="string"?t(l):i.long?r(l):n(l)}},{}],25:[function(s,e,t){(function(n){function r(S,T){var A="b"+t.packets[S.type]+S.data.data;return T(A)}function o(S,T,A){if(!T)return t.encodeBase64Packet(S,A);var m=S.data,v=new Uint8Array(m),_=new Uint8Array(1+m.byteLength);_[0]=j[S.type];for(var I=0;I<v.length;I++)_[I+1]=v[I];return A(_.buffer)}function u(S,T,A){if(!T)return t.encodeBase64Packet(S,A);var m=new FileReader;return m.onload=function(){S.data=m.result,t.encodePacket(S,T,!0,A)},m.readAsArrayBuffer(S.data)}function h(S,T,A){if(!T)return t.encodeBase64Packet(S,A);if(E)return u(S,T,A);var m=new Uint8Array(1);m[0]=j[S.type];var v=new L([m.buffer,S.data]);return A(v)}function d(S,T,A){for(var m=new Array(S.length),v=a(S.length,A),_=function(R,k,W){T(k,function(G,Y){m[R]=Y,W(G,m)})},I=0;I<S.length;I++)_(I,S[I],v)}var c=s("./keys"),p=s("has-binary"),l=s("arraybuffer.slice"),i=s("base64-arraybuffer"),a=s("after"),f=s("utf8"),g=navigator.userAgent.match(/Android/i),y=/PhantomJS/i.test(navigator.userAgent),E=g||y;t.protocol=3;var j=t.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},U=c(j),F={type:"error",data:"parser error"},L=s("blob");t.encodePacket=function(S,T,A,m){typeof T=="function"&&(m=T,T=!1),typeof A=="function"&&(m=A,A=null);var v=S.data===void 0?void 0:S.data.buffer||S.data;if(n.ArrayBuffer&&v instanceof ArrayBuffer)return o(S,T,m);if(L&&v instanceof n.Blob)return h(S,T,m);if(v&&v.base64)return r(S,m);var _=j[S.type];return S.data!==void 0&&(_+=A?f.encode(String(S.data)):String(S.data)),m(""+_)},t.encodeBase64Packet=function(S,T){var A="b"+t.packets[S.type];if(L&&S.data instanceof L){var m=new FileReader;return m.onload=function(){var k=m.result.split(",")[1];T(A+k)},m.readAsDataURL(S.data)}var v;try{v=String.fromCharCode.apply(null,new Uint8Array(S.data))}catch{for(var _=new Uint8Array(S.data),I=new Array(_.length),R=0;R<_.length;R++)I[R]=_[R];v=String.fromCharCode.apply(null,I)}return A+=n.btoa(v),T(A)},t.decodePacket=function(S,T,A){if(typeof S=="string"||S===void 0){if(S.charAt(0)=="b")return t.decodeBase64Packet(S.substr(1),T);if(A)try{S=f.decode(S)}catch{return F}var v=S.charAt(0);return Number(v)==v&&U[v]?S.length>1?{type:U[v],data:S.substring(1)}:{type:U[v]}:F}var m=new Uint8Array(S),v=m[0],_=l(S,1);return L&&T==="blob"&&(_=new L([_])),{type:U[v],data:_}},t.decodeBase64Packet=function(S,T){var A=U[S.charAt(0)];if(!n.ArrayBuffer)return{type:A,data:{base64:!0,data:S.substr(1)}};var m=i.decode(S.substr(1));return T==="blob"&&L&&(m=new L([m])),{type:A,data:m}},t.encodePayload=function(S,T,A){function m(I){return I.length+":"+I}function v(I,R){t.encodePacket(I,_?T:!1,!0,function(k){R(null,m(k))})}typeof T=="function"&&(A=T,T=null);var _=p(S);return T&&_?L&&!E?t.encodePayloadAsBlob(S,A):t.encodePayloadAsArrayBuffer(S,A):S.length?void d(S,v,function(I,R){return A(R.join(""))}):A("0:")},t.decodePayload=function(S,T,A){if(typeof S!="string")return t.decodePayloadAsBinary(S,T,A);typeof T=="function"&&(A=T,T=null);var m;if(S=="")return A(F,0,1);for(var v,_,I="",R=0,k=S.length;k>R;R++){var W=S.charAt(R);if(W!=":")I+=W;else{if(I==""||I!=(v=Number(I))||(_=S.substr(R+1,v),I!=_.length))return A(F,0,1);if(_.length){if(m=t.decodePacket(_,T,!0),F.type==m.type&&F.data==m.data)return A(F,0,1);var G=A(m,R+v,k);if(G===!1)return}R+=v,I=""}}return I!=""?A(F,0,1):void 0},t.encodePayloadAsArrayBuffer=function(S,T){function A(m,v){t.encodePacket(m,!0,!0,function(_){return v(null,_)})}return S.length?void d(S,A,function(m,v){var _=v.reduce(function(k,W){var G;return G=typeof W=="string"?W.length:W.byteLength,k+G.toString().length+G+2},0),I=new Uint8Array(_),R=0;return v.forEach(function(k){var W=typeof k=="string",G=k;if(W){for(var Y=new Uint8Array(k.length),V=0;V<k.length;V++)Y[V]=k.charCodeAt(V);G=Y.buffer}I[R++]=W?0:1;for(var tt=G.byteLength.toString(),V=0;V<tt.length;V++)I[R++]=parseInt(tt[V]);I[R++]=255;for(var Y=new Uint8Array(G),V=0;V<Y.length;V++)I[R++]=Y[V]}),T(I.buffer)}):T(new ArrayBuffer(0))},t.encodePayloadAsBlob=function(S,T){function A(m,v){t.encodePacket(m,!0,!0,function(_){var I=new Uint8Array(1);if(I[0]=1,typeof _=="string"){for(var R=new Uint8Array(_.length),k=0;k<_.length;k++)R[k]=_.charCodeAt(k);_=R.buffer,I[0]=0}for(var W=_ instanceof ArrayBuffer?_.byteLength:_.size,G=W.toString(),Y=new Uint8Array(G.length+1),k=0;k<G.length;k++)Y[k]=parseInt(G[k]);if(Y[G.length]=255,L){var V=new L([I.buffer,Y.buffer,_]);v(null,V)}})}d(S,A,function(m,v){return T(new L(v))})},t.decodePayloadAsBinary=function(S,T,A){typeof T=="function"&&(A=T,T=null);for(var m=S,v=[],_=!1;m.byteLength>0;){for(var I=new Uint8Array(m),R=I[0]===0,k="",W=1;I[W]!=255;W++){if(k.length>310){_=!0;break}k+=I[W]}if(_)return A(F,0,1);m=l(m,2+k.length),k=parseInt(k);var G=l(m,0,k);if(R)try{G=String.fromCharCode.apply(null,new Uint8Array(G))}catch{var Y=new Uint8Array(G);G="";for(var W=0;W<Y.length;W++)G+=String.fromCharCode(Y[W])}v.push(G),m=l(m,k)}var V=v.length;v.forEach(function(tt,St){A(t.decodePacket(tt,T,!0),St,V)})}}).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(s,e){e.exports=Object.keys||function(t){var n=[],r=Object.prototype.hasOwnProperty;for(var o in t)r.call(t,o)&&n.push(o);return n}},{}],27:[function(s,e){function t(r,o,u){function h(c,p){if(h.count<=0)throw new Error("after called too many times");--h.count,c?(d=!0,o(c),o=u):h.count!==0||d||o(null,p)}var d=!1;return u=u||n,h.count=r,r===0?o():h}function n(){}e.exports=t},{}],28:[function(s,e){e.exports=function(t,n,r){var o=t.byteLength;if(n=n||0,r=r||o,t.slice)return t.slice(n,r);if(0>n&&(n+=o),0>r&&(r+=o),r>o&&(r=o),n>=o||n>=r||o===0)return new ArrayBuffer(0);for(var u=new Uint8Array(t),h=new Uint8Array(r-n),d=n,c=0;r>d;d++,c++)h[c]=u[d];return h.buffer}},{}],29:[function(s,e,t){(function(n){t.encode=function(r){var o,u=new Uint8Array(r),h=u.length,d="";for(o=0;h>o;o+=3)d+=n[u[o]>>2],d+=n[(3&u[o])<<4|u[o+1]>>4],d+=n[(15&u[o+1])<<2|u[o+2]>>6],d+=n[63&u[o+2]];return h%3===2?d=d.substring(0,d.length-1)+"=":h%3===1&&(d=d.substring(0,d.length-2)+"=="),d},t.decode=function(r){var o,u,h,d,c,p=.75*r.length,l=r.length,i=0;r[r.length-1]==="="&&(p--,r[r.length-2]==="="&&p--);var a=new ArrayBuffer(p),f=new Uint8Array(a);for(o=0;l>o;o+=4)u=n.indexOf(r[o]),h=n.indexOf(r[o+1]),d=n.indexOf(r[o+2]),c=n.indexOf(r[o+3]),f[i++]=u<<2|h>>4,f[i++]=(15&h)<<4|d>>2,f[i++]=(3&d)<<6|63&c;return a}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],30:[function(s,e){(function(t){function n(p){for(var l=0;l<p.length;l++){var i=p[l];if(i.buffer instanceof ArrayBuffer){var a=i.buffer;if(i.byteLength!==a.byteLength){var f=new Uint8Array(i.byteLength);f.set(new Uint8Array(a,i.byteOffset,i.byteLength)),a=f.buffer}p[l]=a}}}function r(p,l){l=l||{};var i=new u;n(p);for(var a=0;a<p.length;a++)i.append(p[a]);return l.type?i.getBlob(l.type):i.getBlob()}function o(p,l){return n(p),new Blob(p,l||{})}var u=t.BlobBuilder||t.WebKitBlobBuilder||t.MSBlobBuilder||t.MozBlobBuilder,h=function(){try{var p=new Blob(["hi"]);return p.size===2}catch{return!1}}(),d=h&&function(){try{var p=new Blob([new Uint8Array([1,2])]);return p.size===2}catch{return!1}}(),c=u&&u.prototype.append&&u.prototype.getBlob;e.exports=function(){return h?d?t.Blob:o:c?r:void 0}()}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],31:[function(s,e,t){(function(n){(function(r){function o(m){for(var v,_,I=[],R=0,k=m.length;k>R;)v=m.charCodeAt(R++),v>=55296&&56319>=v&&k>R?(_=m.charCodeAt(R++),(64512&_)==56320?I.push(((1023&v)<<10)+(1023&_)+65536):(I.push(v),R--)):I.push(v);return I}function u(m){for(var v,_=m.length,I=-1,R="";++I<_;)v=m[I],v>65535&&(v-=65536,R+=F(v>>>10&1023|55296),v=56320|1023&v),R+=F(v);return R}function h(m){if(m>=55296&&57343>=m)throw Error("Lone surrogate U+"+m.toString(16).toUpperCase()+" is not a scalar value")}function d(m,v){return F(m>>v&63|128)}function c(m){if(!(4294967168&m))return F(m);var v="";return 4294965248&m?4294901760&m?!(4292870144&m)&&(v=F(m>>18&7|240),v+=d(m,12),v+=d(m,6)):(h(m),v=F(m>>12&15|224),v+=d(m,6)):v=F(m>>6&31|192),v+=F(63&m|128)}function p(m){for(var v,_=o(m),I=_.length,R=-1,k="";++R<I;)v=_[R],k+=c(v);return k}function l(){if(U>=j)throw Error("Invalid byte index");var m=255&E[U];if(U++,(192&m)==128)return 63&m;throw Error("Invalid continuation byte")}function i(){var m,v,_,I,R;if(U>j)throw Error("Invalid byte index");if(U==j)return!1;if(m=255&E[U],U++,(128&m)==0)return m;if((224&m)==192){var v=l();if(R=(31&m)<<6|v,R>=128)return R;throw Error("Invalid continuation byte")}if((240&m)==224){if(v=l(),_=l(),R=(15&m)<<12|v<<6|_,R>=2048)return h(R),R;throw Error("Invalid continuation byte")}if((248&m)==240&&(v=l(),_=l(),I=l(),R=(15&m)<<18|v<<12|_<<6|I,R>=65536&&1114111>=R))return R;throw Error("Invalid UTF-8 detected")}function a(m){E=o(m),j=E.length,U=0;for(var v,_=[];(v=i())!==!1;)_.push(v);return u(_)}var f=typeof t=="object"&&t,g=typeof e=="object"&&e&&e.exports==f&&e,y=typeof n=="object"&&n;(y.global===y||y.window===y)&&(r=y);var E,j,U,F=String.fromCharCode,L={version:"2.0.0",encode:p,decode:a};if(f&&!f.nodeType)if(g)g.exports=L;else{var S={},T=S.hasOwnProperty;for(var A in L)T.call(L,A)&&(f[A]=L[A])}else r.utf8=L})(this)}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],32:[function(s,e){(function(t){var n=/^[\],:{}\s]*$/,r=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,o=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,u=/(?:^|:|,)(?:\s*\[)+/g,h=/^\s+/,d=/\s+$/;e.exports=function(c){return typeof c=="string"&&c?(c=c.replace(h,"").replace(d,""),t.JSON&&JSON.parse?JSON.parse(c):n.test(c.replace(r,"@").replace(o,"]").replace(u,""))?new Function("return "+c)():void 0):null}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],33:[function(s,e,t){t.encode=function(n){var r="";for(var o in n)n.hasOwnProperty(o)&&(r.length&&(r+="&"),r+=encodeURIComponent(o)+"="+encodeURIComponent(n[o]));return r},t.decode=function(n){for(var r={},o=n.split("&"),u=0,h=o.length;h>u;u++){var d=o[u].split("=");r[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return r}},{}],34:[function(s,e){var t=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];e.exports=function(r){var o=r,u=r.indexOf("["),h=r.indexOf("]");u!=-1&&h!=-1&&(r=r.substring(0,u)+r.substring(u,h).replace(/:/g,";")+r.substring(h,r.length));for(var d=t.exec(r||""),c={},p=14;p--;)c[n[p]]=d[p]||"";return u!=-1&&h!=-1&&(c.source=o,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c}},{}],35:[function(s,e){function t(o,u){return u?new r(o,u):new r(o)}var n=function(){return self}(),r=n.WebSocket||n.MozWebSocket;e.exports=r?t:null,r&&(t.prototype=r.prototype)},{}],36:[function(s,e){(function(t){function n(o){function u(h){if(!h)return!1;if(t.Buffer&&t.Buffer.isBuffer(h)||t.ArrayBuffer&&h instanceof ArrayBuffer||t.Blob&&h instanceof Blob||t.File&&h instanceof File)return!0;if(r(h)){for(var d=0;d<h.length;d++)if(u(h[d]))return!0}else if(h&&typeof h=="object"){h.toJSON&&(h=h.toJSON());for(var c in h)if(Object.prototype.hasOwnProperty.call(h,c)&&u(h[c]))return!0}return!1}return u(o)}var r=s("isarray");e.exports=n}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{isarray:37}],37:[function(s,e){e.exports=Array.isArray||function(t){return Object.prototype.toString.call(t)=="[object Array]"}},{}],38:[function(s,e){var t=s("global");try{e.exports="XMLHttpRequest"in t&&"withCredentials"in new t.XMLHttpRequest}catch{e.exports=!1}},{global:39}],39:[function(s,e){e.exports=function(){return this}()},{}],40:[function(s,e){var t=[].indexOf;e.exports=function(n,r){if(t)return n.indexOf(r);for(var o=0;o<n.length;++o)if(n[o]===r)return o;return-1}},{}],41:[function(s,e,t){var n=Object.prototype.hasOwnProperty;t.keys=Object.keys||function(r){var o=[];for(var u in r)n.call(r,u)&&o.push(u);return o},t.values=function(r){var o=[];for(var u in r)n.call(r,u)&&o.push(r[u]);return o},t.merge=function(r,o){for(var u in o)n.call(o,u)&&(r[u]=o[u]);return r},t.length=function(r){return t.keys(r).length},t.isEmpty=function(r){return t.length(r)==0}},{}],42:[function(s,e){var t=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];e.exports=function(r){for(var o=t.exec(r||""),u={},h=14;h--;)u[n[h]]=o[h]||"";return u}},{}],43:[function(s,e,t){(function(n){var r=s("isarray"),o=s("./is-buffer");t.deconstructPacket=function(u){function h(l){if(!l)return l;if(o(l)){var i={_placeholder:!0,num:d.length};return d.push(l),i}if(r(l)){for(var a=new Array(l.length),f=0;f<l.length;f++)a[f]=h(l[f]);return a}if(typeof l=="object"&&!(l instanceof Date)){var a={};for(var g in l)a[g]=h(l[g]);return a}return l}var d=[],c=u.data,p=u;return p.data=h(c),p.attachments=d.length,{packet:p,buffers:d}},t.reconstructPacket=function(u,h){function d(c){if(c&&c._placeholder){var p=h[c.num];return p}if(r(c)){for(var l=0;l<c.length;l++)c[l]=d(c[l]);return c}if(c&&typeof c=="object"){for(var i in c)c[i]=d(c[i]);return c}return c}return u.data=d(u.data),u.attachments=void 0,u},t.removeBlobs=function(u,h){function d(l,i,a){if(!l)return l;if(n.Blob&&l instanceof Blob||n.File&&l instanceof File){c++;var f=new FileReader;f.onload=function(){a?a[i]=this.result:p=this.result,--c||h(p)},f.readAsArrayBuffer(l)}else if(r(l))for(var g=0;g<l.length;g++)d(l[g],g,l);else if(l&&typeof l=="object"&&!o(l))for(var y in l)d(l[y],y,l)}var c=0,p=u;d(p),c||h(p)}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./is-buffer":45,isarray:46}],44:[function(s,e,t){function n(){}function r(g){var y="",E=!1;return y+=g.type,(t.BINARY_EVENT==g.type||t.BINARY_ACK==g.type)&&(y+=g.attachments,y+="-"),g.nsp&&g.nsp!="/"&&(E=!0,y+=g.nsp),g.id!=null&&(E&&(y+=",",E=!1),y+=g.id),g.data!=null&&(E&&(y+=","),y+=l.stringify(g.data)),p("encoded %j as %s",g,y),y}function o(g,y){function E(j){var U=a.deconstructPacket(j),F=r(U.packet),L=U.buffers;L.unshift(F),y(L)}a.removeBlobs(g,E)}function u(){this.reconstructor=null}function h(g){var y={},E=0;if(y.type=Number(g.charAt(0)),t.types[y.type]==null)return c();if(t.BINARY_EVENT==y.type||t.BINARY_ACK==y.type){for(var j="";g.charAt(++E)!="-"&&(j+=g.charAt(E),E!=g.length););if(j!=Number(j)||g.charAt(E)!="-")throw new Error("Illegal attachments");y.attachments=Number(j)}if(g.charAt(E+1)=="/")for(y.nsp="";++E;){var U=g.charAt(E);if(U==","||(y.nsp+=U,E==g.length))break}else y.nsp="/";var F=g.charAt(E+1);if(F!==""&&Number(F)==F){for(y.id="";++E;){var U=g.charAt(E);if(U==null||Number(U)!=U){--E;break}if(y.id+=g.charAt(E),E==g.length)break}y.id=Number(y.id)}if(g.charAt(++E))try{y.data=l.parse(g.substr(E))}catch{return c()}return p("decoded %s as %j",g,y),y}function d(g){this.reconPack=g,this.buffers=[]}function c(){return{type:t.ERROR,data:"parser error"}}var p=s("debug")("socket.io-parser"),l=s("json3"),i=(s("isarray"),s("component-emitter")),a=s("./binary"),f=s("./is-buffer");t.protocol=4,t.types=["CONNECT","DISCONNECT","EVENT","BINARY_EVENT","ACK","BINARY_ACK","ERROR"],t.CONNECT=0,t.DISCONNECT=1,t.EVENT=2,t.ACK=3,t.ERROR=4,t.BINARY_EVENT=5,t.BINARY_ACK=6,t.Encoder=n,t.Decoder=u,n.prototype.encode=function(g,y){if(p("encoding packet %j",g),t.BINARY_EVENT==g.type||t.BINARY_ACK==g.type)o(g,y);else{var E=r(g);y([E])}},i(u.prototype),u.prototype.add=function(g){var y;if(typeof g=="string")y=h(g),t.BINARY_EVENT==y.type||t.BINARY_ACK==y.type?(this.reconstructor=new d(y),this.reconstructor.reconPack.attachments===0&&this.emit("decoded",y)):this.emit("decoded",y);else{if(!f(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))}},u.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=a.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(s,e){(function(t){function n(r){return t.Buffer&&t.Buffer.isBuffer(r)||t.ArrayBuffer&&r instanceof ArrayBuffer}e.exports=n}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],46:[function(s,e){e.exports=s(37)},{}],47:[function(s,e,t){(function(n){function r(w){if(r[w]!==h)return r[w];var O;if(w=="bug-string-char-index")O=!1;else if(w=="json")O=r("json-stringify")&&r("json-parse");else{var C,D='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if(w=="json-stringify"){var b=p.stringify,x=typeof b=="function"&&l;if(x){(C=function(){return 1}).toJSON=C;try{x=b(0)==="0"&&b(new Number)==="0"&&b(new String)=='""'&&b(d)===h&&b(h)===h&&b()===h&&b(C)==="1"&&b([C])=="[1]"&&b([h])=="[null]"&&b(null)=="null"&&b([h,d,null])=="[null,null,null]"&&b({a:[C,!0,!1,null,`\0\b
8
- \f\r `]})==D&&b(null,C)==="1"&&b([1,2],null,1)==`[
6
+ */var Fe=function(a){return a!=null&&(be(a)||Me(a)||!!a._isBuffer)};function be(a){return!!a.constructor&&typeof a.constructor.isBuffer=="function"&&a.constructor.isBuffer(a)}function Me(a){return typeof a.readFloatLE=="function"&&typeof a.slice=="function"&&be(a.slice(0,0))}(function(){var a=Pe,t=Te.utf8,e=Fe,s=Te.bin,o=function(h,f){h.constructor==String?f&&f.encoding==="binary"?h=s.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,r=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,y=o._gg,v=o._hh,T=o._ii,n=0;n<l.length;n+=16){var P=i,U=u,q=c,O=r;i=p(i,u,c,r,l[n+0],7,-680876936),r=p(r,i,u,c,l[n+1],12,-389564586),c=p(c,r,i,u,l[n+2],17,606105819),u=p(u,c,r,i,l[n+3],22,-1044525330),i=p(i,u,c,r,l[n+4],7,-176418897),r=p(r,i,u,c,l[n+5],12,1200080426),c=p(c,r,i,u,l[n+6],17,-1473231341),u=p(u,c,r,i,l[n+7],22,-45705983),i=p(i,u,c,r,l[n+8],7,1770035416),r=p(r,i,u,c,l[n+9],12,-1958414417),c=p(c,r,i,u,l[n+10],17,-42063),u=p(u,c,r,i,l[n+11],22,-1990404162),i=p(i,u,c,r,l[n+12],7,1804603682),r=p(r,i,u,c,l[n+13],12,-40341101),c=p(c,r,i,u,l[n+14],17,-1502002290),u=p(u,c,r,i,l[n+15],22,1236535329),i=y(i,u,c,r,l[n+1],5,-165796510),r=y(r,i,u,c,l[n+6],9,-1069501632),c=y(c,r,i,u,l[n+11],14,643717713),u=y(u,c,r,i,l[n+0],20,-373897302),i=y(i,u,c,r,l[n+5],5,-701558691),r=y(r,i,u,c,l[n+10],9,38016083),c=y(c,r,i,u,l[n+15],14,-660478335),u=y(u,c,r,i,l[n+4],20,-405537848),i=y(i,u,c,r,l[n+9],5,568446438),r=y(r,i,u,c,l[n+14],9,-1019803690),c=y(c,r,i,u,l[n+3],14,-187363961),u=y(u,c,r,i,l[n+8],20,1163531501),i=y(i,u,c,r,l[n+13],5,-1444681467),r=y(r,i,u,c,l[n+2],9,-51403784),c=y(c,r,i,u,l[n+7],14,1735328473),u=y(u,c,r,i,l[n+12],20,-1926607734),i=v(i,u,c,r,l[n+5],4,-378558),r=v(r,i,u,c,l[n+8],11,-2022574463),c=v(c,r,i,u,l[n+11],16,1839030562),u=v(u,c,r,i,l[n+14],23,-35309556),i=v(i,u,c,r,l[n+1],4,-1530992060),r=v(r,i,u,c,l[n+4],11,1272893353),c=v(c,r,i,u,l[n+7],16,-155497632),u=v(u,c,r,i,l[n+10],23,-1094730640),i=v(i,u,c,r,l[n+13],4,681279174),r=v(r,i,u,c,l[n+0],11,-358537222),c=v(c,r,i,u,l[n+3],16,-722521979),u=v(u,c,r,i,l[n+6],23,76029189),i=v(i,u,c,r,l[n+9],4,-640364487),r=v(r,i,u,c,l[n+12],11,-421815835),c=v(c,r,i,u,l[n+15],16,530742520),u=v(u,c,r,i,l[n+2],23,-995338651),i=T(i,u,c,r,l[n+0],6,-198630844),r=T(r,i,u,c,l[n+7],10,1126891415),c=T(c,r,i,u,l[n+14],15,-1416354905),u=T(u,c,r,i,l[n+5],21,-57434055),i=T(i,u,c,r,l[n+12],6,1700485571),r=T(r,i,u,c,l[n+3],10,-1894986606),c=T(c,r,i,u,l[n+10],15,-1051523),u=T(u,c,r,i,l[n+1],21,-2054922799),i=T(i,u,c,r,l[n+8],6,1873313359),r=T(r,i,u,c,l[n+15],10,-30611744),c=T(c,r,i,u,l[n+6],15,-1560198380),u=T(u,c,r,i,l[n+13],21,1309151649),i=T(i,u,c,r,l[n+4],6,-145523070),r=T(r,i,u,c,l[n+11],10,-1120210379),c=T(c,r,i,u,l[n+2],15,718787259),u=T(u,c,r,i,l[n+9],21,-343485551),i=i+P>>>0,u=u+U>>>0,c=c+q>>>0,r=r+O>>>0}return a.endian([i,u,c,r])};o._ff=function(h,f,l,d,i,u,c){var r=h+(f&l|~f&d)+(i>>>0)+c;return(r<<u|r>>>32-u)+f},o._gg=function(h,f,l,d,i,u,c){var r=h+(f&d|l&~d)+(i>>>0)+c;return(r<<u|r>>>32-u)+f},o._hh=function(h,f,l,d,i,u,c){var r=h+(f^l^d)+(i>>>0)+c;return(r<<u|r>>>32-u)+f},o._ii=function(h,f,l,d,i,u,c){var r=h+(l^(f|~d))+(i>>>0)+c;return(r<<u|r>>>32-u)+f},o._blocksize=16,o._digestsize=16,Ee.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?s.bytesToString(l):a.bytesToHex(l)}})();var qe=Ee.exports;const Xe=je(qe);var ne=(a=>(a.BOOTSTRAP="bootstrap",a.DEBUG_EXTENSIONS="debugExtensions",a.DEBUG_QUEUE="debugQueue",a.DEBUG_DIALER="debugDialer",a.FULL="full",a))(ne||{}),Z=(a=>(a.MAIN="main",a.NEXT="next",a))(Z||{}),Q=(a=>(a.USER="User",a.TOKEN="Token",a))(Q||{});class se{static async getSessionStorageDataByKey(t,e=!0){if(typeof chrome<"u"&&typeof chrome.storage<"u"){const s=await chrome.storage.session.get(t);if(s[t])return e?JSON.parse(s[t]):s[t]}if(typeof window<"u"&&typeof window.sessionStorage<"u"&&typeof window.sessionStorage.getItem=="function"){const s=window.sessionStorage.getItem(t);if(s)return e?JSON.parse(s):s}}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 Ve{constructor(t){V(this,"delay",1e3);V(this,"lastLoginTimestamp");V(this,"token");V(this,"refreshToken");V(this,"tokenExpiry");V(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=Xe(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||(se.clearSessionStorage(),await this.userLoginFunction(t,this.storageKey,this.eventsSdkClass.options.loginType))}updateLastLoginTimestamp(){this.lastLoginTimestamp=new Date().getTime()}async checkLoginStatus(t){const e=await se.getSessionStorageDataByKey(t);if(e)return e}async userLoginFunction(t,e,s){let o,h,f;return this.eventsSdkClass.options.isNewStack?(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,s),h=await this.getSettings(o.Data.AccessToken),f={...o.Data,...h}):(o=await this.externalLogin(this.eventsSdkClass.options.loginUrl,t,s),f={...o.Data.Socket}),await se.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,s)=>e.Priority>s.Priority?e:s)),this.eventsSdkClass.options.isNewStack&&this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...this.eventsSdkClass.options.servers],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,s)=>e.Priority>s.Priority?e:s)),t.MonitorList&&t.MonitorList.length&&!this.eventsSdkClass.options.servers&&(this.eventsSdkClass.servers=[...t.MonitorList],this.eventsSdkClass.server=this.eventsSdkClass.servers.reduce((e,s)=>e.Priority>s.Priority?e:s)),!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(Z.MAIN)),t.Token&&(this.token=t.Token,this.eventsSdkClass.connect(Z.MAIN)),t.RefreshToken&&t.IdentityCodeExpiry&&this.eventsSdkClass.options.loginType===Q.USER&&(this.refreshToken=t.RefreshToken,this.tokenExpiry=t.IdentityCodeExpiry,this.handleTokenExpiry()),t.RefreshToken&&t.TokenExpiry&&this.normalizeLoginType(this.eventsSdkClass.options.loginType)===Q.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,s=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 se.updateSessionStorageKey(this.storageKey,h)}},s)}async externalLogin(t,{password:e,token:s,email:o},h){if(!t)throw new Error("loginUrl not provided");let f;this.eventsSdkClass.options.isNewStack?h===Q.TOKEN?f=JSON.stringify({identityType:Q.TOKEN,token:s}):f=JSON.stringify({identityType:Q.USER,username:o,password:e}):this.eventsSdkClass.options.loginType===Q.TOKEN?(f=JSON.stringify({token:s}),t=`${t}/${Q.TOKEN}`):(f=JSON.stringify({email:o,pin:e}),t=`${t}/${Q.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,s,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(s){throw this.eventsSdkClass.loggerClass.refreshTokenError(e,t,s),s}}normalizeLoginType(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}}const Ke={isNewStack:!1,loginUrl:"https://loginapi.voicenter.co.il/monitorAPI/Login",refreshTokenUrl:"https://loginapi.voicenter.co.il/monitorAPI/RefreshIdentityToken",forceNew:!0,reconnectionDelay:1e4,timeout:1e4,keepAliveTimeout:6e4,protocol:"https",useLogger:!0,loggerServer:"https://socketlog.voicenter.co",loggerConfig:{logToConsole:!0,overloadGlobalConsole:!1,system:"events-sdk",socketEmitInterval:1e4},loggerConnectOptions:{reconnection:!1,reconnectionDelay:5e3,reconnectionAttempts:10,perMessageDeflate:void 0,upgrade:!1,transports:["websocket"],debug:!1}};function $e(){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=ee,typeof self.navigator>"u"&&(self.navigator={userAgent:"node"})),function a(t,e,s){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 r=t[l][1][c];return o(r||c)},u,u.exports,a,t,e,s)}return e[l].exports}for(var h=typeof require=="function"&&require,f=0;f<s.length;f++)o(s[f]);return o}({1:[function(a,t){t.exports=a("./lib/")},{"./lib/":2}],2:[function(a,t,e){function s(i,u){typeof i=="object"&&(u=i,i=void 0),u=u||{};var c,r=o(i),n=r.source,p=r.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(r.path)}var o=a("./url"),h=a("socket.io-parser"),f=a("./manager"),l=a("debug")("socket.io-client");t.exports=e=s;var d=e.managers={};e.protocol=h.protocol,e.connect=s,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(r,n){return this instanceof e?(r&&typeof r=="object"&&(n=r,r=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=r,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(r,n)}var s=(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 r in this.nsps)this.nsps[r].emit.apply(this.nsps[r],arguments)},e.prototype.updateSocketIds=function(){for(var r in this.nsps)this.nsps[r].id=this.engine.id},h(e.prototype),e.prototype.reconnection=function(r){return arguments.length?(this._reconnection=!!r,this):this._reconnection},e.prototype.reconnectionAttempts=function(r){return arguments.length?(this._reconnectionAttempts=r,this):this._reconnectionAttempts},e.prototype.reconnectionDelay=function(r){return arguments.length?(this._reconnectionDelay=r,this.backoff&&this.backoff.setMin(r),this):this._reconnectionDelay},e.prototype.randomizationFactor=function(r){return arguments.length?(this._randomizationFactor=r,this.backoff&&this.backoff.setJitter(r),this):this._randomizationFactor},e.prototype.reconnectionDelayMax=function(r){return arguments.length?(this._reconnectionDelayMax=r,this.backoff&&this.backoff.setMax(r),this):this._reconnectionDelayMax},e.prototype.timeout=function(r){return arguments.length?(this._timeout=r,this):this._timeout},e.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()},e.prototype.open=e.prototype.connect=function(r){if(i("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;i("opening %s",this.uri),this.engine=s(this.uri,this.opts);var n=this.engine,p=this;this.readyState="opening",this.skipReconnect=!1;var y=l(n,"open",function(){p.onopen(),r&&r()}),v=l(n,"error",function(U){if(i("connect_error"),p.cleanup(),p.readyState="closed",p.emitAll("connect_error",U),r){var q=new Error("Connection error");q.data=U,r(q)}else p.maybeReconnectOnOpen()});if(this._timeout!==!1){var T=this._timeout;i("connect attempt will timeout after %d",T);var P=setTimeout(function(){i("connect attempt timed out after %d",T),y.destroy(),n.close(),n.emit("error","timeout"),p.emitAll("connect_timeout",T)},T);this.subs.push({destroy:function(){clearTimeout(P)}})}return this.subs.push(y),this.subs.push(v),this},e.prototype.onopen=function(){i("open"),this.cleanup(),this.readyState="open",this.emit("open");var r=this.engine;this.subs.push(l(r,"data",d(this,"ondata"))),this.subs.push(l(this.decoder,"decoded",d(this,"ondecoded"))),this.subs.push(l(r,"error",d(this,"onerror"))),this.subs.push(l(r,"close",d(this,"onclose")))},e.prototype.ondata=function(r){this.decoder.add(r)},e.prototype.ondecoded=function(r){this.emit("packet",r)},e.prototype.onerror=function(r){i("error",r),this.emitAll("error",r)},e.prototype.socket=function(r){var n=this.nsps[r];if(!n){n=new o(this,r),this.nsps[r]=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(r){var n=u(this.connected,r);~n&&this.connected.splice(n,1),this.connected.length||this.close()},e.prototype.packet=function(r){i("writing packet %j",r);var n=this;n.encoding?n.packetBuffer.push(r):(n.encoding=!0,this.encoder.encode(r,function(p){for(var y=0;y<p.length;y++)n.engine.write(p[y]);n.encoding=!1,n.processPacketQueue()}))},e.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var r=this.packetBuffer.shift();this.packet(r)}},e.prototype.cleanup=function(){for(var r;r=this.subs.shift();)r.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(r){i("close"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",r),this._reconnection&&!this.skipReconnect&&this.reconnect()},e.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var r=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(){r.skipReconnect||(i("attempting reconnect"),r.emitAll("reconnect_attempt",r.backoff.attempts),r.emitAll("reconnecting",r.backoff.attempts),r.skipReconnect||r.open(function(y){y?(i("reconnect attempt error"),r.reconnecting=!1,r.reconnect(),r.emitAll("reconnect_error",y.data)):(i("reconnect success"),r.onreconnect())}))},n);this.subs.push({destroy:function(){clearTimeout(p)}})}},e.prototype.onreconnect=function(){var r=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",r)}},{"./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(s,o,h){return s.on(o,h),{destroy:function(){s.removeListener(o,h)}}}t.exports=e},{}],5:[function(a,t,e){function s(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=s;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},r=h.prototype.emit;h(s.prototype),s.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"))]}},s.prototype.open=s.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),this.io.readyState=="open"&&this.onopen(),this)},s.prototype.send=function(){var n=f(arguments);return n.unshift("message"),this.emit.apply(this,n),this},s.prototype.emit=function(n){if(c.hasOwnProperty(n))return r.apply(this,arguments),this;var p=f(arguments),y=o.EVENT;u(p)&&(y=o.BINARY_EVENT);var v={type:y,data:p};return typeof p[p.length-1]=="function"&&(i("emitting packet with ack id %d",this.ids),this.acks[this.ids]=p.pop(),v.id=this.ids++),this.connected?this.packet(v):this.sendBuffer.push(v),this},s.prototype.packet=function(n){n.nsp=this.nsp,this.io.packet(n)},s.prototype.onopen=function(){i("transport is open - connecting"),this.nsp!="/"&&this.packet({type:o.CONNECT})},s.prototype.onclose=function(n){i("close (%s)",n),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",n)},s.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)}},s.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?r.apply(this,p):this.receiveBuffer.push(p)},s.prototype.ack=function(n){var p=this,y=!1;return function(){if(!y){y=!0;var v=f(arguments);i("sending ack %j",v);var T=u(v)?o.BINARY_ACK:o.ACK;p.packet({type:T,id:n,data:v})}}},s.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]},s.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},s.prototype.emitBuffered=function(){var n;for(n=0;n<this.receiveBuffer.length;n++)r.apply(this,this.receiveBuffer[n]);for(this.receiveBuffer=[],n=0;n<this.sendBuffer.length;n++)this.packet(this.sendBuffer[n]);this.sendBuffer=[]},s.prototype.ondisconnect=function(){i("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},s.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)},s.prototype.close=s.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 s(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=s}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{debug:10,parseuri:42}],7:[function(a,t){function e(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}t.exports=e,e.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var o=Math.random(),h=Math.floor(o*this.jitter*s);s=1&Math.floor(10*o)?s+h:s-h}return 0|Math.min(s,this.max)},e.prototype.reset=function(){this.attempts=0},e.prototype.setMin=function(s){this.ms=s},e.prototype.setMax=function(s){this.max=s},e.prototype.setJitter=function(s){this.jitter=s}},{}],8:[function(a,t){var e=[].slice;t.exports=function(s,o){if(typeof o=="string"&&(o=s[o]),typeof o!="function")throw new Error("bind() requires a function");var h=e.call(arguments,2);return function(){return o.apply(s,h.concat(e.call(arguments)))}}},{}],9:[function(a,t){function e(o){return o?s(o):void 0}function s(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=s(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 s(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 s(n,p){if(!(this instanceof s))return new s(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 y=p.host.split(":");p.hostname=y.shift(),y.length?p.port=y.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=r.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 y in n)n.hasOwnProperty(y)&&(p[y]=n[y]);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"),r=a("parseqs");t.exports=s,s.priorWebsocketSuccess=!1,f(s.prototype),s.protocol=i.protocol,s.Socket=s,s.Transport=a("./transport"),s.transports=a("./transports"),s.parser=a("engine.io-parser"),s.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 y=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 y},s.prototype.open=function(){var p;if(this.rememberUpgrade&&s.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)},s.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(y){p.onPacket(y)}).on("error",function(y){p.onError(y)}).on("close",function(){p.onClose("transport close")})},s.prototype.probe=function(n){function p(){if(b.onlyBinaryUpgrades){var A=!this.supportsBinary&&b.transport.supportsBinary;C=C||A}C||(l('probe transport "%s" opened',n),O.send([{type:"ping",data:"probe"}]),O.once("packet",function(g){if(!C)if(g.type=="pong"&&g.data=="probe"){if(l('probe transport "%s" pong',n),b.upgrading=!0,b.emit("upgrading",O),!O)return;s.priorWebsocketSuccess=O.name=="websocket",l('pausing current transport "%s"',b.transport.name),b.transport.pause(function(){C||b.readyState!="closed"&&(l("changing transport and sending upgrade packet"),q(),b.setTransport(O),O.send([{type:"upgrade"}]),b.emit("upgrade",O),O=null,b.upgrading=!1,b.flush())})}else{l('probe transport "%s" failed',n);var m=new Error("probe error");m.transport=O.name,b.emit("upgradeError",m)}}))}function y(){C||(C=!0,q(),O.close(),O=null)}function v(A){var g=new Error("probe error: "+A);g.transport=O.name,y(),l('probe transport "%s" failed because of error: %s',n,A),b.emit("upgradeError",g)}function T(){v("transport closed")}function P(){v("socket closed")}function U(A){O&&A.name!=O.name&&(l('"%s" works - aborting "%s"',A.name,O.name),y())}function q(){O.removeListener("open",p),O.removeListener("error",v),O.removeListener("close",T),b.removeListener("close",P),b.removeListener("upgrading",U)}l('probing transport "%s"',n);var O=this.createTransport(n,{probe:1}),C=!1,b=this;s.priorWebsocketSuccess=!1,O.once("open",p),O.once("error",v),O.once("close",T),this.once("close",P),this.once("upgrading",U),O.open()},s.prototype.onOpen=function(){if(l("socket open"),this.readyState="open",s.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])}},s.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)},s.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))},s.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)},s.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)},s.prototype.ping=function(){this.sendPacket("ping")},s.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()},s.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"))},s.prototype.write=s.prototype.send=function(n,p){return this.sendPacket("message",n,p),this},s.prototype.sendPacket=function(n,p,y){if(this.readyState!="closing"&&this.readyState!="closed"){var v={type:n,data:p};this.emit("packetCreate",v),this.writeBuffer.push(v),this.callbackBuffer.push(y),this.flush()}},s.prototype.close=function(){function n(){v.onClose("forced close"),l("socket closing - telling transport to close"),v.transport.close()}function p(){v.removeListener("upgrade",p),v.removeListener("upgradeError",p),n()}function y(){v.once("upgrade",p),v.once("upgradeError",p)}if(this.readyState=="opening"||this.readyState=="open"){this.readyState="closing";var v=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?y():n()}):this.upgrading?y():n()}return this},s.prototype.onError=function(n){l("socket error %j",n),s.priorWebsocketSuccess=!1,this.emit("error",n),this.onClose("transport error",n)},s.prototype.onClose=function(n,p){if(this.readyState=="opening"||this.readyState=="open"||this.readyState=="closing"){l('socket close with reason: "%s"',n);var y=this;clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),setTimeout(function(){y.writeBuffer=[],y.callbackBuffer=[],y.prevBufferLen=0},0),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",n,p)}},s.prototype.filterUpgrades=function(n){for(var p=[],y=0,v=n.length;v>y;y++)~d(this.transports,n[y])&&p.push(n[y]);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 s=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=s.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(s){function o(i){var u,c=!1,r=!1,n=i.jsonp!==!1;if(s.location){var p=location.protocol=="https:",y=location.port;y||(y=p?443:80),c=i.hostname!=location.hostname||y!=i.port,r=i.secure!=p}if(i.xdomain=c,i.xscheme=r,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 s(){}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(r){c.onData(r)}),this.query.j=this.index,e.document&&e.addEventListener&&e.addEventListener("beforeunload",function(){c.script&&(c.script.onerror=s)},!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 r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(c,r),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 r(){n(),c()}function n(){if(p.iframe)try{p.form.removeChild(p.iframe)}catch(q){p.onError("jsonp polling iframe removal error",q)}try{var U='<iframe src="javascript:0" name="'+p.iframeId+'">';y=document.createElement(U)}catch{y=document.createElement("iframe"),y.name=p.iframeId,y.src="javascript:0"}y.id=p.iframeId,p.form.appendChild(y),p.iframe=y}var p=this;if(!this.form){var y,v=document.createElement("form"),T=document.createElement("textarea"),P=this.iframeId="eio_iframe_"+this.index;v.className="socketio",v.style.position="absolute",v.style.top="-1000px",v.style.left="-1000px",v.target=P,v.method="POST",v.setAttribute("accept-charset","utf-8"),T.name="d",v.appendChild(T),document.body.appendChild(v),this.form=v,this.area=T}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"&&r()}:this.iframe.onload=r}}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{"./polling":18,"component-inherit":21}],17:[function(a,t){(function(e){function s(){}function o(r){if(d.call(this,r),e.location){var n=location.protocol=="https:",p=location.port;p||(p=n?443:80),this.xd=r.hostname!=e.location.hostname||p!=r.port,this.xs=r.secure!=n}}function h(r){this.method=r.method||"GET",this.uri=r.uri,this.xd=!!r.xd,this.xs=!!r.xs,this.async=r.async!==!1,this.data=r.data!=null?r.data:null,this.agent=r.agent,this.isBinary=r.isBinary,this.supportsBinary=r.supportsBinary,this.enablesXDR=r.enablesXDR,this.pfx=r.pfx,this.key=r.key,this.passphrase=r.passphrase,this.cert=r.cert,this.ca=r.ca,this.ciphers=r.ciphers,this.rejectUnauthorized=r.rejectUnauthorized,this.create()}function f(){for(var r in h.requests)h.requests.hasOwnProperty(r)&&h.requests[r].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(r){return r=r||{},r.uri=this.uri(),r.xd=this.xd,r.xs=this.xs,r.agent=this.agent||!1,r.supportsBinary=this.supportsBinary,r.enablesXDR=this.enablesXDR,r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized,new h(r)},o.prototype.doWrite=function(r,n){var p=typeof r!="string"&&r!==void 0,y=this.request({method:"POST",data:r,isBinary:p}),v=this;y.on("success",n),y.on("error",function(T){v.onError("xhr post error",T)}),this.sendXhr=y},o.prototype.doPoll=function(){c("xhr poll");var r=this.request(),n=this;r.on("data",function(p){n.onData(p)}),r.on("error",function(p){n.onError("xhr poll error",p)}),this.pollXhr=r},i(h.prototype),h.prototype.create=function(){var r={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized;var n=this.xhr=new l(r),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(y){return void setTimeout(function(){p.onError(y)},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(r){this.emit("data",r),this.onSuccess()},h.prototype.onError=function(r){this.emit("error",r),this.cleanup(!0)},h.prototype.cleanup=function(r){if(typeof this.xhr<"u"&&this.xhr!==null){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=s:this.xhr.onreadystatechange=s,r)try{this.xhr.abort()}catch{}e.document&&delete h.requests[this.index],this.xhr=null}},h.prototype.onLoad=function(){var r;try{var n;try{n=this.xhr.getResponseHeader("Content-Type").split(";")[0]}catch{}r=n==="application/octet-stream"?this.xhr.response:this.supportsBinary?"ok":this.xhr.responseText}catch(p){this.onError(p)}r!=null&&this.onData(r)},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),s.call(this,i)}var s=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,s),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 r=0;this.polling&&(l("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){l("pre-pause polling complete"),--r||u()})),this.writable||(l("we are currently writing - waiting to pause"),r++,this.once("drain",function(){l("pre-pause writing complete"),--r||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(r){return u.readyState=="opening"&&u.onOpen(),r.type=="close"?(u.onClose(),!1):void u.onPacket(r)};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(r){c.doWrite(r,u)})},e.prototype.uri=function(){var i=this.query||{},u=this.secure?"https":"http",c="";return this.timestampRequests!==!1&&(i[this.timestampParam]=+new Date+"-"+s.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),s.call(this,i)}var s=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,s),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(){s.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 r=0,n=i.length;n>r;r++)o.encodePacket(i[r],this.supportsBinary,function(p){try{c.ws.send(p)}catch{l("websocket closed before onclose event")}});setTimeout(u,0)},e.prototype.onClose=function(){s.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(s){var o=s.xdomain,h=s.xscheme,f=s.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,s){var o=function(){};o.prototype=s.prototype,e.prototype=new o,e.prototype.constructor=e}},{}],22:[function(a,t,e){function s(){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,r=0;return d[0].replace(/%[a-z%]/g,function(n){n!=="%%"&&(c++,n==="%c"&&(r=c))}),d.splice(r,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=s,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 s(){return e.colors[u++%e.colors.length]}function o(c){function r(){}function n(){var y=n,v=+new Date,T=v-(i||v);y.diff=T,y.prev=i,y.curr=v,i=v,y.useColors==null&&(y.useColors=e.useColors()),y.color==null&&y.useColors&&(y.color=s());var P=Array.prototype.slice.call(arguments);P[0]=e.coerce(P[0]),typeof P[0]!="string"&&(P=["%o"].concat(P));var U=0;P[0]=P[0].replace(/%([a-z%])/g,function(O,C){if(O==="%%")return O;U++;var b=e.formatters[C];if(typeof b=="function"){var A=P[U];O=b.call(y,A),P.splice(U,1),U--}return O}),typeof e.formatArgs=="function"&&(P=e.formatArgs.apply(y,P));var q=n.log||e.log||console.log.bind(console);q.apply(y,P)}r.enabled=!1,n.enabled=!0;var p=e.enabled(c)?n:r;return p.namespace=c,p}function h(c){e.save(c);for(var r=(c||"").split(/[\s,]+/),n=r.length,p=0;n>p;p++)r[p]&&(c=r[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 r,n;for(r=0,n=e.skips.length;n>r;r++)if(e.skips[r].test(c))return!1;for(r=0,n=e.names.length;n>r;r++)if(e.names[r].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 r=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(c);if(r){var n=parseFloat(r[1]),p=(r[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 s(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,r,n){return r>c?void 0:1.5*r>c?Math.floor(c/r)+" "+n:Math.ceil(c/r)+" "+n+"s"}var f=1e3,l=60*f,d=60*l,i=24*d,u=365.25*i;t.exports=function(c,r){return r=r||{},typeof c=="string"?e(c):r.long?o(c):s(c)}},{}],25:[function(a,t,e){(function(s){function o(C,b){var A="b"+e.packets[C.type]+C.data.data;return b(A)}function h(C,b,A){if(!b)return e.encodeBase64Packet(C,A);var g=C.data,m=new Uint8Array(g),L=new Uint8Array(1+g.byteLength);L[0]=P[C.type];for(var I=0;I<m.length;I++)L[I+1]=m[I];return A(L.buffer)}function f(C,b,A){if(!b)return e.encodeBase64Packet(C,A);var g=new FileReader;return g.onload=function(){C.data=g.result,e.encodePacket(C,b,!0,A)},g.readAsArrayBuffer(C.data)}function l(C,b,A){if(!b)return e.encodeBase64Packet(C,A);if(T)return f(C,b,A);var g=new Uint8Array(1);g[0]=P[C.type];var m=new O([g.buffer,C.data]);return A(m)}function d(C,b,A){for(var g=new Array(C.length),m=n(C.length,A),L=function(R,k,K){b(k,function($,J){g[R]=J,K($,g)})},I=0;I<C.length;I++)L(I,C[I],m)}var i=a("./keys"),u=a("has-binary"),c=a("arraybuffer.slice"),r=a("base64-arraybuffer"),n=a("after"),p=a("utf8"),y=navigator.userAgent.match(/Android/i),v=/PhantomJS/i.test(navigator.userAgent),T=y||v;e.protocol=3;var P=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},U=i(P),q={type:"error",data:"parser error"},O=a("blob");e.encodePacket=function(C,b,A,g){typeof b=="function"&&(g=b,b=!1),typeof A=="function"&&(g=A,A=null);var m=C.data===void 0?void 0:C.data.buffer||C.data;if(s.ArrayBuffer&&m instanceof ArrayBuffer)return h(C,b,g);if(O&&m instanceof s.Blob)return l(C,b,g);if(m&&m.base64)return o(C,g);var L=P[C.type];return C.data!==void 0&&(L+=A?p.encode(String(C.data)):String(C.data)),g(""+L)},e.encodeBase64Packet=function(C,b){var A="b"+e.packets[C.type];if(O&&C.data instanceof O){var g=new FileReader;return g.onload=function(){var k=g.result.split(",")[1];b(A+k)},g.readAsDataURL(C.data)}var m;try{m=String.fromCharCode.apply(null,new Uint8Array(C.data))}catch{for(var L=new Uint8Array(C.data),I=new Array(L.length),R=0;R<L.length;R++)I[R]=L[R];m=String.fromCharCode.apply(null,I)}return A+=s.btoa(m),b(A)},e.decodePacket=function(C,b,A){if(typeof C=="string"||C===void 0){if(C.charAt(0)=="b")return e.decodeBase64Packet(C.substr(1),b);if(A)try{C=p.decode(C)}catch{return q}var m=C.charAt(0);return Number(m)==m&&U[m]?C.length>1?{type:U[m],data:C.substring(1)}:{type:U[m]}:q}var g=new Uint8Array(C),m=g[0],L=c(C,1);return O&&b==="blob"&&(L=new O([L])),{type:U[m],data:L}},e.decodeBase64Packet=function(C,b){var A=U[C.charAt(0)];if(!s.ArrayBuffer)return{type:A,data:{base64:!0,data:C.substr(1)}};var g=r.decode(C.substr(1));return b==="blob"&&O&&(g=new O([g])),{type:A,data:g}},e.encodePayload=function(C,b,A){function g(I){return I.length+":"+I}function m(I,R){e.encodePacket(I,L?b:!1,!0,function(k){R(null,g(k))})}typeof b=="function"&&(A=b,b=null);var L=u(C);return b&&L?O&&!T?e.encodePayloadAsBlob(C,A):e.encodePayloadAsArrayBuffer(C,A):C.length?void d(C,m,function(I,R){return A(R.join(""))}):A("0:")},e.decodePayload=function(C,b,A){if(typeof C!="string")return e.decodePayloadAsBinary(C,b,A);typeof b=="function"&&(A=b,b=null);var g;if(C=="")return A(q,0,1);for(var m,L,I="",R=0,k=C.length;k>R;R++){var K=C.charAt(R);if(K!=":")I+=K;else{if(I==""||I!=(m=Number(I))||(L=C.substr(R+1,m),I!=L.length))return A(q,0,1);if(L.length){if(g=e.decodePacket(L,b,!0),q.type==g.type&&q.data==g.data)return A(q,0,1);var $=A(g,R+m,k);if($===!1)return}R+=m,I=""}}return I!=""?A(q,0,1):void 0},e.encodePayloadAsArrayBuffer=function(C,b){function A(g,m){e.encodePacket(g,!0,!0,function(L){return m(null,L)})}return C.length?void d(C,A,function(g,m){var L=m.reduce(function(k,K){var $;return $=typeof K=="string"?K.length:K.byteLength,k+$.toString().length+$+2},0),I=new Uint8Array(L),R=0;return m.forEach(function(k){var K=typeof k=="string",$=k;if(K){for(var J=new Uint8Array(k.length),X=0;X<k.length;X++)J[X]=k.charCodeAt(X);$=J.buffer}I[R++]=K?0:1;for(var W=$.byteLength.toString(),X=0;X<W.length;X++)I[R++]=parseInt(W[X]);I[R++]=255;for(var J=new Uint8Array($),X=0;X<J.length;X++)I[R++]=J[X]}),b(I.buffer)}):b(new ArrayBuffer(0))},e.encodePayloadAsBlob=function(C,b){function A(g,m){e.encodePacket(g,!0,!0,function(L){var I=new Uint8Array(1);if(I[0]=1,typeof L=="string"){for(var R=new Uint8Array(L.length),k=0;k<L.length;k++)R[k]=L.charCodeAt(k);L=R.buffer,I[0]=0}for(var K=L instanceof ArrayBuffer?L.byteLength:L.size,$=K.toString(),J=new Uint8Array($.length+1),k=0;k<$.length;k++)J[k]=parseInt($[k]);if(J[$.length]=255,O){var X=new O([I.buffer,J.buffer,L]);m(null,X)}})}d(C,A,function(g,m){return b(new O(m))})},e.decodePayloadAsBinary=function(C,b,A){typeof b=="function"&&(A=b,b=null);for(var g=C,m=[],L=!1;g.byteLength>0;){for(var I=new Uint8Array(g),R=I[0]===0,k="",K=1;I[K]!=255;K++){if(k.length>310){L=!0;break}k+=I[K]}if(L)return A(q,0,1);g=c(g,2+k.length),k=parseInt(k);var $=c(g,0,k);if(R)try{$=String.fromCharCode.apply(null,new Uint8Array($))}catch{var J=new Uint8Array($);$="";for(var K=0;K<J.length;K++)$+=String.fromCharCode(J[K])}m.push($),g=c(g,k)}var X=m.length;m.forEach(function(W,oe){A(e.decodePacket(W,b,!0),oe,X)})}}).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 s=[],o=Object.prototype.hasOwnProperty;for(var h in e)o.call(e,h)&&s.push(h);return s}},{}],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||s,l.count=o,o===0?h():l}function s(){}t.exports=e},{}],28:[function(a,t){t.exports=function(e,s,o){var h=e.byteLength;if(s=s||0,o=o||h,e.slice)return e.slice(s,o);if(0>s&&(s+=h),0>o&&(o+=h),o>h&&(o=h),s>=h||s>=o||h===0)return new ArrayBuffer(0);for(var f=new Uint8Array(e),l=new Uint8Array(o-s),d=s,i=0;o>d;d++,i++)l[i]=f[d];return l.buffer}},{}],29:[function(a,t,e){(function(s){e.encode=function(o){var h,f=new Uint8Array(o),l=f.length,d="";for(h=0;l>h;h+=3)d+=s[f[h]>>2],d+=s[(3&f[h])<<4|f[h+1]>>4],d+=s[(15&f[h+1])<<2|f[h+2]>>6],d+=s[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,r=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=s.indexOf(o[h]),l=s.indexOf(o[h+1]),d=s.indexOf(o[h+2]),i=s.indexOf(o[h+3]),p[r++]=f<<2|l>>4,p[r++]=(15&l)<<4|d>>2,p[r++]=(3&d)<<6|63&i;return n}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],30:[function(a,t){(function(e){function s(u){for(var c=0;c<u.length;c++){var r=u[c];if(r.buffer instanceof ArrayBuffer){var n=r.buffer;if(r.byteLength!==n.byteLength){var p=new Uint8Array(r.byteLength);p.set(new Uint8Array(n,r.byteOffset,r.byteLength)),n=p.buffer}u[c]=n}}}function o(u,c){c=c||{};var r=new f;s(u);for(var n=0;n<u.length;n++)r.append(u[n]);return c.type?r.getBlob(c.type):r.getBlob()}function h(u,c){return s(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(s){(function(o){function h(g){for(var m,L,I=[],R=0,k=g.length;k>R;)m=g.charCodeAt(R++),m>=55296&&56319>=m&&k>R?(L=g.charCodeAt(R++),(64512&L)==56320?I.push(((1023&m)<<10)+(1023&L)+65536):(I.push(m),R--)):I.push(m);return I}function f(g){for(var m,L=g.length,I=-1,R="";++I<L;)m=g[I],m>65535&&(m-=65536,R+=q(m>>>10&1023|55296),m=56320|1023&m),R+=q(m);return R}function l(g){if(g>=55296&&57343>=g)throw Error("Lone surrogate U+"+g.toString(16).toUpperCase()+" is not a scalar value")}function d(g,m){return q(g>>m&63|128)}function i(g){if(!(4294967168&g))return q(g);var m="";return 4294965248&g?4294901760&g?!(4292870144&g)&&(m=q(g>>18&7|240),m+=d(g,12),m+=d(g,6)):(l(g),m=q(g>>12&15|224),m+=d(g,6)):m=q(g>>6&31|192),m+=q(63&g|128)}function u(g){for(var m,L=h(g),I=L.length,R=-1,k="";++R<I;)m=L[R],k+=i(m);return k}function c(){if(U>=P)throw Error("Invalid byte index");var g=255&T[U];if(U++,(192&g)==128)return 63&g;throw Error("Invalid continuation byte")}function r(){var g,m,L,I,R;if(U>P)throw Error("Invalid byte index");if(U==P)return!1;if(g=255&T[U],U++,(128&g)==0)return g;if((224&g)==192){var m=c();if(R=(31&g)<<6|m,R>=128)return R;throw Error("Invalid continuation byte")}if((240&g)==224){if(m=c(),L=c(),R=(15&g)<<12|m<<6|L,R>=2048)return l(R),R;throw Error("Invalid continuation byte")}if((248&g)==240&&(m=c(),L=c(),I=c(),R=(15&g)<<18|m<<12|L<<6|I,R>=65536&&1114111>=R))return R;throw Error("Invalid UTF-8 detected")}function n(g){T=h(g),P=T.length,U=0;for(var m,L=[];(m=r())!==!1;)L.push(m);return f(L)}var p=typeof e=="object"&&e,y=typeof t=="object"&&t&&t.exports==p&&t,v=typeof s=="object"&&s;(v.global===v||v.window===v)&&(o=v);var T,P,U,q=String.fromCharCode,O={version:"2.0.0",encode:u,decode:n};if(p&&!p.nodeType)if(y)y.exports=O;else{var C={},b=C.hasOwnProperty;for(var A in O)b.call(O,A)&&(p[A]=O[A])}else o.utf8=O})(this)}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],32:[function(a,t){(function(e){var s=/^[\],:{}\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):s.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(s){var o="";for(var h in s)s.hasOwnProperty(h)&&(o.length&&(o+="&"),o+=encodeURIComponent(h)+"="+encodeURIComponent(s[h]));return o},e.decode=function(s){for(var o={},h=s.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*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,s=["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[s[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 s=function(){return self}(),o=s.WebSocket||s.MozWebSocket;t.exports=o?e:null,o&&(e.prototype=o.prototype)},{}],36:[function(a,t){(function(e){function s(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=s}).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(s,o){if(e)return s.indexOf(o);for(var h=0;h<s.length;++h)if(s[h]===o)return h;return-1}},{}],41:[function(a,t,e){var s=Object.prototype.hasOwnProperty;e.keys=Object.keys||function(o){var h=[];for(var f in o)s.call(o,f)&&h.push(f);return h},e.values=function(o){var h=[];for(var f in o)s.call(o,f)&&h.push(o[f]);return h},e.merge=function(o,h){for(var f in h)s.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*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,s=["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[s[l]]=h[l]||"";return f}},{}],43:[function(a,t,e){(function(s){var o=a("isarray"),h=a("./is-buffer");e.deconstructPacket=function(f){function l(c){if(!c)return c;if(h(c)){var r={_placeholder:!0,num:d.length};return d.push(c),r}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 y in c)n[y]=l(c[y]);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 r in i)i[r]=d(i[r]);return i}return i}return f.data=d(f.data),f.attachments=void 0,f},e.removeBlobs=function(f,l){function d(c,r,n){if(!c)return c;if(s.Blob&&c instanceof Blob||s.File&&c instanceof File){i++;var p=new FileReader;p.onload=function(){n?n[r]=this.result:u=this.result,--i||l(u)},p.readAsArrayBuffer(c)}else if(o(c))for(var y=0;y<c.length;y++)d(c[y],y,c);else if(c&&typeof c=="object"&&!h(c))for(var v in c)d(c[v],v,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 s(){}function o(y){var v="",T=!1;return v+=y.type,(e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type)&&(v+=y.attachments,v+="-"),y.nsp&&y.nsp!="/"&&(T=!0,v+=y.nsp),y.id!=null&&(T&&(v+=",",T=!1),v+=y.id),y.data!=null&&(T&&(v+=","),v+=c.stringify(y.data)),u("encoded %j as %s",y,v),v}function h(y,v){function T(P){var U=n.deconstructPacket(P),q=o(U.packet),O=U.buffers;O.unshift(q),v(O)}n.removeBlobs(y,T)}function f(){this.reconstructor=null}function l(y){var v={},T=0;if(v.type=Number(y.charAt(0)),e.types[v.type]==null)return i();if(e.BINARY_EVENT==v.type||e.BINARY_ACK==v.type){for(var P="";y.charAt(++T)!="-"&&(P+=y.charAt(T),T!=y.length););if(P!=Number(P)||y.charAt(T)!="-")throw new Error("Illegal attachments");v.attachments=Number(P)}if(y.charAt(T+1)=="/")for(v.nsp="";++T;){var U=y.charAt(T);if(U==","||(v.nsp+=U,T==y.length))break}else v.nsp="/";var q=y.charAt(T+1);if(q!==""&&Number(q)==q){for(v.id="";++T;){var U=y.charAt(T);if(U==null||Number(U)!=U){--T;break}if(v.id+=y.charAt(T),T==y.length)break}v.id=Number(v.id)}if(y.charAt(++T))try{v.data=c.parse(y.substr(T))}catch{return i()}return u("decoded %s as %j",y,v),v}function d(y){this.reconPack=y,this.buffers=[]}function i(){return{type:e.ERROR,data:"parser error"}}var u=a("debug")("socket.io-parser"),c=a("json3"),r=(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=s,e.Decoder=f,s.prototype.encode=function(y,v){if(u("encoding packet %j",y),e.BINARY_EVENT==y.type||e.BINARY_ACK==y.type)h(y,v);else{var T=o(y);v([T])}},r(f.prototype),f.prototype.add=function(y){var v;if(typeof y=="string")v=l(y),e.BINARY_EVENT==v.type||e.BINARY_ACK==v.type?(this.reconstructor=new d(v),this.reconstructor.reconPack.attachments===0&&this.emit("decoded",v)):this.emit("decoded",v);else{if(!p(y)&&!y.base64)throw new Error("Unknown type: "+y);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");v=this.reconstructor.takeBinaryData(y),v&&(this.reconstructor=null,this.emit("decoded",v))}},f.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},d.prototype.takeBinaryData=function(y){if(this.buffers.push(y),this.buffers.length==this.reconPack.attachments){var v=n.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),v}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 s(o){return e.Buffer&&e.Buffer.isBuffer(o)||e.ArrayBuffer&&o instanceof ArrayBuffer}t.exports=s}).call(this,typeof self<"u"?self:typeof window<"u"?window:{})},{}],46:[function(a,t){t.exports=a(37)},{}],47:[function(a,t,e){(function(s){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 w,D='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if(E=="json-stringify"){var S=u.stringify,x=typeof S=="function"&&c;if(x){(w=function(){return 1}).toJSON=w;try{x=S(0)==="0"&&S(new Number)==="0"&&S(new String)=='""'&&S(d)===l&&S(l)===l&&S()===l&&S(w)==="1"&&S([w])=="[1]"&&S([l])=="[null]"&&S(null)=="null"&&S([l,d,null])=="[null,null,null]"&&S({a:[w,!0,!1,null,`\0\b
8
+ \f\r `]})==D&&S(null,w)==="1"&&S([1,2],null,1)==`[
9
9
  1,
10
10
  2
11
- ]`&&b(new Date(-864e13))=='"-271821-04-20T00:00:00.000Z"'&&b(new Date(864e13))=='"+275760-09-13T00:00:00.000Z"'&&b(new Date(-621987552e5))=='"-000001-01-01T00:00:00.000Z"'&&b(new Date(-1))=='"1969-12-31T23:59:59.999Z"'}catch{x=!1}}O=x}if(w=="json-parse"){var B=p.parse;if(typeof B=="function")try{if(B("0")===0&&!B(!1)){C=B(D);var N=C.a.length==5&&C.a[0]===1;if(N){try{N=!B('" "')}catch{}if(N)try{N=B("01")!==1}catch{}if(N)try{N=B("1.")!==1}catch{}}}}catch{N=!1}O=N}}return r[w]=!!O}var o,u,h,d={}.toString,c=typeof JSON=="object"&&JSON,p=typeof t=="object"&&t&&!t.nodeType&&t;p&&c?(p.stringify=c.stringify,p.parse=c.parse):p=n.JSON=c||{};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(!r("json")){var i="[object Function]",a="[object Date]",f="[object Number]",g="[object String]",y="[object Array]",E="[object Boolean]",j=r("bug-string-char-index");if(!l)var U=Math.floor,F=[0,31,59,90,120,151,181,212,243,273,304,334],L=function(w,O){return F[O]+365*(w-1970)+U((w-1969+(O=+(O>1)))/4)-U((w-1901+O)/100)+U((w-1601+O)/400)};(o={}.hasOwnProperty)||(o=function(w){var O,C={};return(C.__proto__=null,C.__proto__={toString:1},C).toString!=d?o=function(D){var b=this.__proto__,x=D in(this.__proto__=null,this);return this.__proto__=b,x}:(O=C.constructor,o=function(D){var b=(this.constructor||O).prototype;return D in this&&!(D in b&&this[D]===b[D])}),C=null,o.call(this,w)});var S={boolean:1,number:1,string:1,undefined:1},T=function(w,O){var C=typeof w[O];return C=="object"?!!w[O]:!S[C]};if(u=function(w,O){var C,D,b,x=0;(C=function(){this.valueOf=0}).prototype.valueOf=0,D=new C;for(b in D)o.call(D,b)&&x++;return C=D=null,x?u=x==2?function(B,N){var q,J={},et=d.call(B)==i;for(q in B)et&&q=="prototype"||o.call(J,q)||!(J[q]=1)||!o.call(B,q)||N(q)}:function(B,N){var q,J,et=d.call(B)==i;for(q in B)et&&q=="prototype"||!o.call(B,q)||(J=q==="constructor")||N(q);(J||o.call(B,q="constructor"))&&N(q)}:(D=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],u=function(B,N){var q,J,et=d.call(B)==i,st=!et&&typeof B.constructor!="function"&&T(B,"hasOwnProperty")?B.hasOwnProperty:o;for(q in B)et&&q=="prototype"||!st.call(B,q)||N(q);for(J=D.length;q=D[--J];st.call(B,q)&&N(q));}),u(w,O)},!r("json-stringify")){var A={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},m="000000",v=function(w,O){return(m+(O||0)).slice(-w)},_="\\u00",I=function(w){var O,C='"',D=0,b=w.length,x=b>10&&j;for(x&&(O=w.split(""));b>D;D++){var B=w.charCodeAt(D);switch(B){case 8:case 9:case 10:case 12:case 13:case 34:case 92:C+=A[B];break;default:if(32>B){C+=_+v(2,B.toString(16));break}C+=x?O[D]:j?w.charAt(D):w[D]}}return C+'"'},R=function(w,O,C,D,b,x,B){var N,q,J,et,st,wt,te,ee,ne,se,pt,re,Ut,Ct,oe,ie;try{N=O[w]}catch{}if(typeof N=="object"&&N)if(q=d.call(N),q!=a||o.call(N,"toJSON"))typeof N.toJSON=="function"&&(q!=f&&q!=g&&q!=y||o.call(N,"toJSON"))&&(N=N.toJSON(w));else if(N>-1/0&&1/0>N){if(L){for(st=U(N/864e5),J=U(st/365.2425)+1970-1;L(J+1,0)<=st;J++);for(et=U((st-L(J,0))/30.42);L(J,et+1)<=st;et++);st=1+st-L(J,et),wt=(N%864e5+864e5)%864e5,te=U(wt/36e5)%24,ee=U(wt/6e4)%60,ne=U(wt/1e3)%60,se=wt%1e3}else J=N.getUTCFullYear(),et=N.getUTCMonth(),st=N.getUTCDate(),te=N.getUTCHours(),ee=N.getUTCMinutes(),ne=N.getUTCSeconds(),se=N.getUTCMilliseconds();N=(0>=J||J>=1e4?(0>J?"-":"+")+v(6,0>J?-J:J):v(4,J))+"-"+v(2,et+1)+"-"+v(2,st)+"T"+v(2,te)+":"+v(2,ee)+":"+v(2,ne)+"."+v(3,se)+"Z"}else N=null;if(C&&(N=C.call(O,w,N)),N===null)return"null";if(q=d.call(N),q==E)return""+N;if(q==f)return N>-1/0&&1/0>N?""+N:"null";if(q==g)return I(""+N);if(typeof N=="object"){for(Ct=B.length;Ct--;)if(B[Ct]===N)throw TypeError();if(B.push(N),pt=[],oe=x,x+=b,q==y){for(Ut=0,Ct=N.length;Ct>Ut;Ut++)re=R(Ut,N,C,D,b,x,B),pt.push(re===h?"null":re);ie=pt.length?b?`[
12
- `+x+pt.join(`,
11
+ ]`&&S(new Date(-864e13))=='"-271821-04-20T00:00:00.000Z"'&&S(new Date(864e13))=='"+275760-09-13T00:00:00.000Z"'&&S(new Date(-621987552e5))=='"-000001-01-01T00:00:00.000Z"'&&S(new Date(-1))=='"1969-12-31T23:59:59.999Z"'}catch{x=!1}}_=x}if(E=="json-parse"){var B=u.parse;if(typeof B=="function")try{if(B("0")===0&&!B(!1)){w=B(D);var N=w.a.length==5&&w.a[0]===1;if(N){try{N=!B('" "')}catch{}if(N)try{N=B("01")!==1}catch{}if(N)try{N=B("1.")!==1}catch{}}}}catch{N=!1}_=N}}return o[E]=!!_}var h,f,l,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=s.JSON=i||{};var c=new Date(-0xc782b5b800cec);try{c=c.getUTCFullYear()==-109252&&c.getUTCMonth()===0&&c.getUTCDate()===1&&c.getUTCHours()==10&&c.getUTCMinutes()==37&&c.getUTCSeconds()==6&&c.getUTCMilliseconds()==708}catch{}if(!o("json")){var r="[object Function]",n="[object Date]",p="[object Number]",y="[object String]",v="[object Array]",T="[object Boolean]",P=o("bug-string-char-index");if(!c)var U=Math.floor,q=[0,31,59,90,120,151,181,212,243,273,304,334],O=function(E,_){return q[_]+365*(E-1970)+U((E-1969+(_=+(_>1)))/4)-U((E-1901+_)/100)+U((E-1601+_)/400)};(h={}.hasOwnProperty)||(h=function(E){var _,w={};return(w.__proto__=null,w.__proto__={toString:1},w).toString!=d?h=function(D){var S=this.__proto__,x=D in(this.__proto__=null,this);return this.__proto__=S,x}:(_=w.constructor,h=function(D){var S=(this.constructor||_).prototype;return D in this&&!(D in S&&this[D]===S[D])}),w=null,h.call(this,E)});var C={boolean:1,number:1,string:1,undefined:1},b=function(E,_){var w=typeof E[_];return w=="object"?!!E[_]:!C[w]};if(f=function(E,_){var w,D,S,x=0;(w=function(){this.valueOf=0}).prototype.valueOf=0,D=new w;for(S in D)h.call(D,S)&&x++;return w=D=null,x?f=x==2?function(B,N){var M,G={},H=d.call(B)==r;for(M in B)H&&M=="prototype"||h.call(G,M)||!(G[M]=1)||!h.call(B,M)||N(M)}:function(B,N){var M,G,H=d.call(B)==r;for(M in B)H&&M=="prototype"||!h.call(B,M)||(G=M==="constructor")||N(M);(G||h.call(B,M="constructor"))&&N(M)}:(D=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],f=function(B,N){var M,G,H=d.call(B)==r,Y=!H&&typeof B.constructor!="function"&&b(B,"hasOwnProperty")?B.hasOwnProperty:h;for(M in B)H&&M=="prototype"||!Y.call(B,M)||N(M);for(G=D.length;M=D[--G];Y.call(B,M)&&N(M));}),f(E,_)},!o("json-stringify")){var A={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},g="000000",m=function(E,_){return(g+(_||0)).slice(-E)},L="\\u00",I=function(E){var _,w='"',D=0,S=E.length,x=S>10&&P;for(x&&(_=E.split(""));S>D;D++){var B=E.charCodeAt(D);switch(B){case 8:case 9:case 10:case 12:case 13:case 34:case 92:w+=A[B];break;default:if(32>B){w+=L+m(2,B.toString(16));break}w+=x?_[D]:P?E.charAt(D):E[D]}}return w+'"'},R=function(E,_,w,D,S,x,B){var N,M,G,H,Y,ie,de,ye,ve,ge,te,me,le,ae,ke,Se;try{N=_[E]}catch{}if(typeof N=="object"&&N)if(M=d.call(N),M!=n||h.call(N,"toJSON"))typeof N.toJSON=="function"&&(M!=p&&M!=y&&M!=v||h.call(N,"toJSON"))&&(N=N.toJSON(E));else if(N>-1/0&&1/0>N){if(O){for(Y=U(N/864e5),G=U(Y/365.2425)+1970-1;O(G+1,0)<=Y;G++);for(H=U((Y-O(G,0))/30.42);O(G,H+1)<=Y;H++);Y=1+Y-O(G,H),ie=(N%864e5+864e5)%864e5,de=U(ie/36e5)%24,ye=U(ie/6e4)%60,ve=U(ie/1e3)%60,ge=ie%1e3}else G=N.getUTCFullYear(),H=N.getUTCMonth(),Y=N.getUTCDate(),de=N.getUTCHours(),ye=N.getUTCMinutes(),ve=N.getUTCSeconds(),ge=N.getUTCMilliseconds();N=(0>=G||G>=1e4?(0>G?"-":"+")+m(6,0>G?-G:G):m(4,G))+"-"+m(2,H+1)+"-"+m(2,Y)+"T"+m(2,de)+":"+m(2,ye)+":"+m(2,ve)+"."+m(3,ge)+"Z"}else N=null;if(w&&(N=w.call(_,E,N)),N===null)return"null";if(M=d.call(N),M==T)return""+N;if(M==p)return N>-1/0&&1/0>N?""+N:"null";if(M==y)return I(""+N);if(typeof N=="object"){for(ae=B.length;ae--;)if(B[ae]===N)throw TypeError();if(B.push(N),te=[],ke=x,x+=S,M==v){for(le=0,ae=N.length;ae>le;le++)me=R(le,N,w,D,S,x,B),te.push(me===l?"null":me);Se=te.length?S?`[
12
+ `+x+te.join(`,
13
13
  `+x)+`
14
- `+oe+"]":"["+pt.join(",")+"]":"[]"}else u(D||N,function(ae){var $e=R(ae,N,C,D,b,x,B);$e!==h&&pt.push(I(ae)+":"+(b?" ":"")+$e)}),ie=pt.length?b?`{
15
- `+x+pt.join(`,
14
+ `+ke+"]":"["+te.join(",")+"]":"[]"}else f(D||N,function(Ce){var De=R(Ce,N,w,D,S,x,B);De!==l&&te.push(I(Ce)+":"+(S?" ":"")+De)}),Se=te.length?S?`{
15
+ `+x+te.join(`,
16
16
  `+x)+`
17
- `+oe+"}":"{"+pt.join(",")+"}":"{}";return B.pop(),ie}};p.stringify=function(w,O,C){var D,b,x,B;if(typeof O=="function"||typeof O=="object"&&O){if((B=d.call(O))==i)b=O;else if(B==y){x={};for(var N,q=0,J=O.length;J>q;N=O[q++],B=d.call(N),(B==g||B==f)&&(x[N]=1));}}if(C)if((B=d.call(C))==f){if((C-=C%1)>0)for(D="",C>10&&(C=10);D.length<C;D+=" ");}else B==g&&(D=C.length<=10?C:C.slice(0,10));return R("",(N={},N[""]=w,N),b,x,D,"",[])}}if(!r("json-parse")){var k,W,G=String.fromCharCode,Y={92:"\\",34:'"',47:"/",98:"\b",116:" ",110:`
18
- `,102:"\f",114:"\r"},V=function(){throw k=W=null,SyntaxError()},tt=function(){for(var w,O,C,D,b,x=W,B=x.length;B>k;)switch(b=x.charCodeAt(k)){case 9:case 10:case 13:case 32:k++;break;case 123:case 125:case 91:case 93:case 58:case 44:return w=j?x.charAt(k):x[k],k++,w;case 34:for(w="@",k++;B>k;)if(b=x.charCodeAt(k),32>b)V();else if(b==92)switch(b=x.charCodeAt(++k)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:w+=Y[b],k++;break;case 117:for(O=++k,C=k+4;C>k;k++)b=x.charCodeAt(k),b>=48&&57>=b||b>=97&&102>=b||b>=65&&70>=b||V();w+=G("0x"+x.slice(O,k));break;default:V()}else{if(b==34)break;for(b=x.charCodeAt(k),O=k;b>=32&&b!=92&&b!=34;)b=x.charCodeAt(++k);w+=x.slice(O,k)}if(x.charCodeAt(k)==34)return k++,w;V();default:if(O=k,b==45&&(D=!0,b=x.charCodeAt(++k)),b>=48&&57>=b){for(b==48&&(b=x.charCodeAt(k+1),b>=48&&57>=b)&&V(),D=!1;B>k&&(b=x.charCodeAt(k),b>=48&&57>=b);k++);if(x.charCodeAt(k)==46){for(C=++k;B>C&&(b=x.charCodeAt(C),b>=48&&57>=b);C++);C==k&&V(),k=C}if(b=x.charCodeAt(k),b==101||b==69){for(b=x.charCodeAt(++k),(b==43||b==45)&&k++,C=k;B>C&&(b=x.charCodeAt(C),b>=48&&57>=b);C++);C==k&&V(),k=C}return+x.slice(O,k)}if(D&&V(),x.slice(k,k+4)=="true")return k+=4,!0;if(x.slice(k,k+5)=="false")return k+=5,!1;if(x.slice(k,k+4)=="null")return k+=4,null;V()}return"$"},St=function(w){var O,C;if(w=="$"&&V(),typeof w=="string"){if((j?w.charAt(0):w[0])=="@")return w.slice(1);if(w=="["){for(O=[];w=tt(),w!="]";C||(C=!0))C&&(w==","?(w=tt(),w=="]"&&V()):V()),w==","&&V(),O.push(St(w));return O}if(w=="{"){for(O={};w=tt(),w!="}";C||(C=!0))C&&(w==","?(w=tt(),w=="}"&&V()):V()),(w==","||typeof w!="string"||(j?w.charAt(0):w[0])!="@"||tt()!=":")&&V(),O[w.slice(1)]=St(tt());return O}V()}return w},Je=function(w,O,C){var D=Xe(w,O,C);D===h?delete w[O]:w[O]=D},Xe=function(w,O,C){var D,b=w[O];if(typeof b=="object"&&b)if(d.call(b)==y)for(D=b.length;D--;)Je(b,D,C);else u(b,function(x){Je(b,x,C)});return C.call(w,O,b)};p.parse=function(w,O){var C,D;return k=0,W=""+w,C=St(tt()),tt()!="$"&&V(),k=W=null,O&&d.call(O)==i?Xe((D={},D[""]=C,D),"",O):C}}}})(this)},{}],48:[function(s,e){function t(n,r){var o=[];r=r||0;for(var u=r||0;u<n.length;u++)o[u-r]=n[u];return o}e.exports=t},{}]},{},[1])(1)}const sn=Object.assign({"./v1_3_7.js":Object.freeze(Object.defineProperty({__proto__:null,default:nn},Symbol.toStringTag,{value:"Module"}))}),rn=/v\d+_\d+_\d+/;function on(s){return typeof s=="function"}const Dt=Object.entries(sn).reduce((s,e)=>{var r;const t=e[1].default,n=(r=e[0].match(rn))==null?void 0:r[0];return on(t)&&n&&(s[n]=t()),s},{}),pe=s=>{if(s in Dt)return Dt[s];throw new Error(`Socket version ${s} not found`)},an={...Dt,getSocketVersion:pe,makeSocketVersion:(s,...e)=>pe(s)(...e)};var fe=(s=>(s.RINGING="Ringing",s.TALKING="Talking",s.DIALING="Dialing",s.HOLD="Hold",s))(fe||{}),de=(s=>(s.INCOMING="Incoming",s.OUTGOING="Outgoing",s))(de||{}),dt=(s=>(s.CONNECTED="connected",s.DISCONNECTED="disconnected",s.TRYING_TO_CONNECT="tryingToConnect",s))(dt||{}),ge=(s=>(s.AUTOMATIC="Automatic",s.IVR="IVR",s))(ge||{}),ye=(s=>(s.INCOMINC="Incoming",s.OUTGOING="Outgoing",s.SPY="Spy",s.CLICK2CALL="Click2Call",s))(ye||{}),me=(s=>(s.RESPONSE_FROM_API_VALID="RESPONSE_FROM_API_VALID",s.RESPONSE_FROM_API_INVALID="RESPONSE_FROM_API_INVALID",s))(me||{}),P=(s=>(s.ALL_DIALER_STATUS="AllDialersStatus",s.ALL_EXTENSION_STATUS="AllExtensionsStatus",s.ALL_USERS_STATUS="AllUsersStatus",s.CONNECT="connect",s.DISCONNECT="disconnect",s.CONNECT_ERROR_EVENT="connect_error",s.EXTENSION_EVENT="ExtensionEvent",s.KEEP_ALIVE="keepalive",s.KEEP_ALIVE_RESPONSE="keepaliveResponse",s.LOGIN_STATUS="loginStatus",s.LOGIN_SUCCESS="loginSuccess",s.QUEUE_EVENT="QueueEvent",s.ONLINE_STATUS_EVENT="onlineStatusEvent",s.DIALER_EVENT="DialerEvent",s.EXTENSIONS_UPDATED="ExtensionsUpdated",s))(P||{}),Pt=(s=>(s.NEWCALL="NEWCALL",s.ANSWER="ANSWER",s.HOLD="HOLD",s.UNHOLD="UNHOLD",s.HANGUP="HANGUP",s.USER_STATUS_UPDATE="userStatusUpdate",s))(Pt||{}),ve=(s=>(s.NORMAL_HANGUP="Normal hangup",s.USER_BUSY="User busy",s.CALL_REJECTED="Call Rejected",s.UNALLOCATED_NUMBER="Unallocated (unassigned) number",s.UNKNOWN="Unknown",s.NO_USER_RESPONDING="No user responding",s.USER_ALERTING="User alerting, no answer",s.ANSWERED_ELSEWHERE="Answered elsewhere",s))(ve||{}),ke=(s=>(s.ANSWER="ANSWER",s.ABANDONED="ABANDONED",s.EXIT="EXIT",s.JOIN="JOIN",s))(ke||{});class Et{static mapExtensionEvent(e){var u,h;const t=e.reason;let n,r;e.data.currentCall&&(r=this.mapExtensionCall(e,e.data.currentCall));const o=this.mapExtensionData(e,e.data);return t===Pt.HANGUP?n={...e,reason:t,data:{...o,currentCall:r?{...r,duration:r.callAnswered_UTC_CLIENT?Date.now()-r.callAnswered_UTC_CLIENT:0}:void 0,calls:(u=e.data.calls)==null?void 0:u.map(d=>{const c=this.mapExtensionCall(e,d);return{...c,duration:c.callAnswered_UTC_CLIENT?Date.now()-c.callAnswered_UTC_CLIENT:0}})}}:n={...e,data:{...o,currentCall:r,calls:(h=e.data.calls)==null?void 0:h.map(d=>this.mapExtensionCall(e,d))},reason:t},n}static mapAllExtensionStatus(e){return{...e,extensions:e.extensions.map(t=>{var n;return{...this.mapExtensionData(e,t),currentCall:t.currentCall?this.mapExtensionCall(e,t.currentCall):void 0,calls:(n=t.calls)==null?void 0:n.map(r=>this.mapExtensionCall(e,r))}})}}static mapExtensionData(e,t){return this.configureUTCForObject(t,[{key:"lastAnsweredCallEventEpoch",format:"sec"},{key:"lastCallEventEpoch",format:"sec"},{key:"lastHangupCallEpoch",format:"sec"},{key:"representativeUpdated",format:"ms"}],e.servertime,e.servertimeoffset)}static mapExtensionCall(e,t){return this.configureUTCForObject(t,[{key:"callAnswered",format:"sec"},{key:"callStarted",format:"sec"}],e.servertime,e.servertimeoffset)}static mapQueueCall(e,t){return this.configureUTCForObject(t,[{key:"JoinTimeStamp",format:"sec"},{key:"VHJoinTimeStamp",format:"sec"}],e.servertime,e.servertimeoffset)}static mapLoginStatusEvent(e){return{...e,queues:e.queues.map(t=>({...t,Calls:t.Calls.map(n=>this.mapQueueCall(e,n))}))}}static mapQueueEvent(e){return{...e,data:{...e.data,Calls:e.data.Calls.map(t=>this.mapQueueCall(e,t))}}}static assignProperty(e,t,n){e[t]=n}static configureUTCForObject(e,t,n,r){const o=(n-r*60)*1e3,u=Date.now()-o,h={};return t.forEach(d=>{const c=e[d.key],p=d.key;if(c!==0&&typeof c=="number"&&!isNaN(c)){let l=c;d.format==="ms"&&(l=Math.floor(l/1e3));const i=(l-r*60)*1e3;this.assignProperty(h,`${p}_UTC`,i),this.assignProperty(h,`${p}_UTC_CLIENT`,i+u)}else this.assignProperty(h,`${p}_UTC`,0),this.assignProperty(h,`${p}_UTC_CLIENT`,0)}),{...e,...h}}}var jt=(s=>(s.UPDATE_MONITORED_EXTENSIONS="updateMonitoredExtensions",s.KEEP_ALIVE="keepalive",s))(jt||{});class cn{constructor(e){K(this,"io");K(this,"ioFunction");K(this,"lastEventTimestamp",new Date().getTime());K(this,"doReconnect",!0);K(this,"keepAliveInterval");K(this,"keepReconnectInterval");K(this,"keepReconnectTimeout");K(this,"connected",!1);K(this,"reconnectionTime",20);this.eventsSdkClass=e,this.eventsSdkClass=e,typeof window<"u"&&(window.addEventListener("offline",()=>{this.closeAllConnections()}),window.addEventListener("online",()=>{setTimeout(()=>{this.keepReconnectTimeout&&clearTimeout(this.keepReconnectTimeout),this.eventsSdkClass.connect(it.NEXT)},5e3)})),typeof self<"u"&&typeof window>"u"&&typeof global>"u"&&(self.addEventListener("offline",()=>{this.closeAllConnections()}),self.addEventListener("online",()=>{setTimeout(()=>{this.keepReconnectTimeout&&clearTimeout(this.keepReconnectTimeout),this.eventsSdkClass.connect(it.NEXT)},5e3)}))}getSocketIoFunction(e){const t=e.split("v="),n="v".concat(t[t.length-1]).replaceAll(".","_");this.ioFunction=an.getSocketVersion(n)}initSocketConnection(){const e=this.eventsSdkClass.authClass.token,t=this.eventsSdkClass.options.protocol,n=this.eventsSdkClass.server;try{const r=n?n.Domain:this.eventsSdkClass.URL,o=n?`${t}://${r}`:this.eventsSdkClass.URL,u={reconnection:!1,upgrade:!1,transports:["websocket"],forceNew:!0,query:{token:e},timeout:this.eventsSdkClass.options.timeout};if(this.ioFunction&&o)this.io=this.ioFunction(o,u),this.eventsSdkClass.eventEmitterClass.emit(P.ONLINE_STATUS_EVENT,{attemptToConnect:o,connectionStatus:dt.TRYING_TO_CONNECT}),this.eventsSdkClass.loggerClass.sdkAttemptToConnect(r);else throw new Error("Socket server url no defined")}catch(r){this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(r)}}clearKeepAliveInterval(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval)}initKeepAlive(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveInterval=setInterval(async()=>{if(new Date().getTime()>this.lastEventTimestamp+this.eventsSdkClass.options.keepAliveTimeout&&this.io&&this.eventsSdkClass.authClass.token){this.eventsSdkClass.emit(jt.KEEP_ALIVE,this.eventsSdkClass.authClass.token),this.eventsSdkClass.loggerClass.keepAliveEmit();return}},this.eventsSdkClass.options.keepAliveTimeout)}closeAllConnections(){var e;this.io&&(this.io.close(),(e=this.io)==null||e.disconnect(),this.io=void 0),this.eventsSdkClass.loggerClass.stop(),vt.clearSessionStorage()}initSocketEvents(){this.io&&this.io.on(P.LOGIN_SUCCESS,e=>this.onLoginSuccessEvent(e,P.LOGIN_SUCCESS)).on(P.QUEUE_EVENT,e=>this.onQueueEvent(e,P.QUEUE_EVENT)).on(P.EXTENSION_EVENT,e=>this.onExtensionEvent(e,P.EXTENSION_EVENT)).on(P.DIALER_EVENT,e=>this.onDialerEvent(e,P.DIALER_EVENT)).on(P.LOGIN_STATUS,e=>this.onLoginStatusEvent(e,P.LOGIN_STATUS)).on(P.ALL_EXTENSION_STATUS,e=>this.onAllExtensionStatus(e,P.ALL_EXTENSION_STATUS)).on(P.ALL_DIALER_STATUS,e=>this.onAllDialerStatus(e,P.ALL_DIALER_STATUS)).on(P.KEEP_ALIVE_RESPONSE,e=>this.onKeepAliveResponse(e)).on(P.EXTENSIONS_UPDATED,e=>this.onExtensionsUpdatedEvent(e,P.EXTENSIONS_UPDATED)).on(P.CONNECT,()=>this.onConnect()).on(P.DISCONNECT,e=>this.onDisconnect(e)).on(P.CONNECT_ERROR_EVENT,e=>this.onConnectError(e))}onLoginSuccessEvent(e,t){this.eventsSdkClass.loggerClass.eventLog(t,e),this.eventsSdkClass.eventEmitterClass.emit(t,e)}onQueueEvent(e,t){this.eventsSdkClass.loggerClass.eventLog(t,e),this.eventsSdkClass.eventEmitterClass.emit(t,Et.mapQueueEvent(e))}onExtensionEvent(e,t){const n=Et.mapExtensionEvent(e);n&&(this.eventsSdkClass.loggerClass.eventLog(t,e),this.eventsSdkClass.eventEmitterClass.emit(t,n))}onDialerEvent(e,t){this.eventsSdkClass.loggerClass.eventLog(t,e),this.eventsSdkClass.eventEmitterClass.emit(t,e)}onLoginStatusEvent(e,t){this.eventsSdkClass.loggerClass.eventLog(t,e),this.eventsSdkClass.eventEmitterClass.emit(t,Et.mapLoginStatusEvent(e))}onAllExtensionStatus(e,t){const n=Et.mapAllExtensionStatus(e);this.eventsSdkClass.loggerClass.eventLog(t,e),this.eventsSdkClass.eventEmitterClass.emit(t,n)}onAllDialerStatus(e,t){this.eventsSdkClass.loggerClass.eventLog(t,e),this.eventsSdkClass.eventEmitterClass.emit(t,e)}onKeepAliveResponse(e){if(this.eventsSdkClass.loggerClass.keepAliveResponse(e),e.errorCode){this.initSocketConnection();return}this.connected?this.lastEventTimestamp=new Date().getTime():this.initSocketConnection()}onExtensionsUpdatedEvent(e,t){this.eventsSdkClass.loggerClass.eventLog(t,e),this.eventsSdkClass.eventEmitterClass.emit(t,e)}onConnect(){this.connected=!0,this.keepReconnectInterval&&clearInterval(this.keepReconnectInterval),this.eventsSdkClass.eventEmitterClass.emit(P.ONLINE_STATUS_EVENT,{connectionStatus:dt.CONNECTED}),this.eventsSdkClass.loggerClass.start().then(()=>{this.eventsSdkClass.loggerClass.sdkConnectionSuccess()})}onDisconnect(e){this.connected=!1,this.doReconnect&&(this.closeAllConnections(),this.eventsSdkClass.eventEmitterClass.emit(P.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?dt.TRYING_TO_CONNECT:dt.DISCONNECTED}),this.eventsSdkClass.loggerClass.sdkDisconnect([e]),this.keepReconnectTimeout=setTimeout(()=>{this.reconnectionTime=this.reconnectionTime+20,this.reconnectionTime>120&&(this.reconnectionTime=20),this.eventsSdkClass.connect(it.NEXT)},this.reconnectionTime*1e3))}onConnectError(e){this.eventsSdkClass.eventEmitterClass.emit(P.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?dt.TRYING_TO_CONNECT:dt.DISCONNECTED}),this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(e),this.keepReconnectTimeout=setTimeout(()=>{this.reconnectionTime=this.reconnectionTime+20,this.reconnectionTime>60&&(this.reconnectionTime=20),this.eventsSdkClass.connect(it.NEXT)},this.reconnectionTime*1e3)}}var hn=Object.defineProperty,ln=(s,e,t)=>e in s?hn(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,X=(s,e,t)=>(ln(s,typeof e!="symbol"?e+"":e,t),t);const at=Object.create(null);at.open="0",at.close="1",at.ping="2",at.pong="3",at.message="4",at.upgrade="5",at.noop="6";const Tt=Object.create(null);Object.keys(at).forEach(s=>{Tt[at[s]]=s});const qt={type:"error",data:"parser error"},be=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Se=typeof ArrayBuffer=="function",we=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,Ft=({type:s,data:e},t,n)=>be&&e instanceof Blob?t?n(e):Ce(e,n):Se&&(e instanceof ArrayBuffer||we(e))?t?n(e):Ce(new Blob([e]),n):n(at[s]+(e||"")),Ce=(s,e)=>{const t=new FileReader;return t.onload=function(){const n=t.result.split(",")[1];e("b"+(n||""))},t.readAsDataURL(s)};function Ee(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}let Mt;function un(s,e){if(be&&s.data instanceof Blob)return s.data.arrayBuffer().then(Ee).then(e);if(Se&&(s.data instanceof ArrayBuffer||we(s.data)))return e(Ee(s.data));Ft(s,!1,t=>{Mt||(Mt=new TextEncoder),e(Mt.encode(t))})}const Te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",kt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<Te.length;s++)kt[Te.charCodeAt(s)]=s;const pn=s=>{let e=s.length*.75,t=s.length,n,r=0,o,u,h,d;s[s.length-1]==="="&&(e--,s[s.length-2]==="="&&e--);const c=new ArrayBuffer(e),p=new Uint8Array(c);for(n=0;n<t;n+=4)o=kt[s.charCodeAt(n)],u=kt[s.charCodeAt(n+1)],h=kt[s.charCodeAt(n+2)],d=kt[s.charCodeAt(n+3)],p[r++]=o<<2|u>>4,p[r++]=(u&15)<<4|h>>2,p[r++]=(h&3)<<6|d&63;return c},fn=typeof ArrayBuffer=="function",Vt=(s,e)=>{if(typeof s!="string")return{type:"message",data:Ae(s,e)};const t=s.charAt(0);return t==="b"?{type:"message",data:dn(s.substring(1),e)}:Tt[t]?s.length>1?{type:Tt[t],data:s.substring(1)}:{type:Tt[t]}:qt},dn=(s,e)=>{if(fn){const t=pn(s);return Ae(t,e)}else return{base64:!0,data:s}},Ae=(s,e)=>{switch(e){case"blob":return s instanceof Blob?s:new Blob([s]);case"arraybuffer":default:return s instanceof ArrayBuffer?s:s.buffer}},Ne="",gn=(s,e)=>{const t=s.length,n=new Array(t);let r=0;s.forEach((o,u)=>{Ft(o,!1,h=>{n[u]=h,++r===t&&e(n.join(Ne))})})},yn=(s,e)=>{const t=s.split(Ne),n=[];for(let r=0;r<t.length;r++){const o=Vt(t[r],e);if(n.push(o),o.type==="error")break}return n};function mn(){return new TransformStream({transform(s,e){un(s,t=>{const n=t.length;let r;if(n<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,n);else if(n<65536){r=new Uint8Array(3);const o=new DataView(r.buffer);o.setUint8(0,126),o.setUint16(1,n)}else{r=new Uint8Array(9);const o=new DataView(r.buffer);o.setUint8(0,127),o.setBigUint64(1,BigInt(n))}s.data&&typeof s.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(t)})}})}let Kt;function At(s){return s.reduce((e,t)=>e+t.length,0)}function Nt(s,e){if(s[0].length===e)return s.shift();const t=new Uint8Array(e);let n=0;for(let r=0;r<e;r++)t[r]=s[0][n++],n===s[0].length&&(s.shift(),n=0);return s.length&&n<s[0].length&&(s[0]=s[0].slice(n)),t}function vn(s,e){Kt||(Kt=new TextDecoder);const t=[];let n=0,r=-1,o=!1;return new TransformStream({transform(u,h){for(t.push(u);;){if(n===0){if(At(t)<1)break;const d=Nt(t,1);o=(d[0]&128)===128,r=d[0]&127,r<126?n=3:r===126?n=1:n=2}else if(n===1){if(At(t)<2)break;const d=Nt(t,2);r=new DataView(d.buffer,d.byteOffset,d.length).getUint16(0),n=3}else if(n===2){if(At(t)<8)break;const d=Nt(t,8),c=new DataView(d.buffer,d.byteOffset,d.length),p=c.getUint32(0);if(p>Math.pow(2,21)-1){h.enqueue(qt);break}r=p*Math.pow(2,32)+c.getUint32(4),n=3}else{if(At(t)<r)break;const d=Nt(t,r);h.enqueue(Vt(o?d:Kt.decode(d),e)),n=0}if(r===0||r>s){h.enqueue(qt);break}}}})}const _e=4;function z(s){if(s)return kn(s)}function kn(s){for(var e in z.prototype)s[e]=z.prototype[e];return s}z.prototype.on=z.prototype.addEventListener=function(s,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+s]=this._callbacks["$"+s]||[]).push(e),this},z.prototype.once=function(s,e){function t(){this.off(s,t),e.apply(this,arguments)}return t.fn=e,this.on(s,t),this},z.prototype.off=z.prototype.removeListener=z.prototype.removeAllListeners=z.prototype.removeEventListener=function(s,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+s];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+s],this;for(var n,r=0;r<t.length;r++)if(n=t[r],n===e||n.fn===e){t.splice(r,1);break}return t.length===0&&delete this._callbacks["$"+s],this},z.prototype.emit=function(s){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+s],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,r=t.length;n<r;++n)t[n].apply(this,e)}return this},z.prototype.emitReserved=z.prototype.emit,z.prototype.listeners=function(s){return this._callbacks=this._callbacks||{},this._callbacks["$"+s]||[]},z.prototype.hasListeners=function(s){return!!this.listeners(s).length};const nt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")();function Oe(s,...e){return e.reduce((t,n)=>(s.hasOwnProperty(n)&&(t[n]=s[n]),t),{})}const bn=nt.setTimeout,Sn=nt.clearTimeout;function _t(s,e){e.useNativeTimers?(s.setTimeoutFn=bn.bind(nt),s.clearTimeoutFn=Sn.bind(nt)):(s.setTimeoutFn=nt.setTimeout.bind(nt),s.clearTimeoutFn=nt.clearTimeout.bind(nt))}const wn=1.33;function Cn(s){return typeof s=="string"?En(s):Math.ceil((s.byteLength||s.size)*wn)}function En(s){let e=0,t=0;for(let n=0,r=s.length;n<r;n++)e=s.charCodeAt(n),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(n++,t+=4);return t}function Tn(s){let e="";for(let t in s)s.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(s[t]));return e}function An(s){let e={},t=s.split("&");for(let n=0,r=t.length;n<r;n++){let o=t[n].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}class Nn extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class Wt extends z{constructor(e){super(),this.writable=!1,_t(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new Nn(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=Vt(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=Tn(e);return t.length?"?"+t:""}}const Le="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Gt=64,_n={};let Re=0,Ot=0,Ie;function xe(s){let e="";do e=Le[s%Gt]+e,s=Math.floor(s/Gt);while(s>0);return e}function Ue(){const s=xe(+new Date);return s!==Ie?(Re=0,Ie=s):s+"."+xe(Re++)}for(;Ot<Gt;Ot++)_n[Le[Ot]]=Ot;let Be=!1;try{Be=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const On=Be;function De(s){const e=s.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||On))return new XMLHttpRequest}catch{}if(!e)try{return new nt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function Ln(){}const Rn=function(){return new De({xdomain:!1}).responseType!=null}();class In extends Wt{constructor(e){if(super(e),this.polling=!1,typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}const t=e&&e.forceBase64;this.supportsBinary=Rn&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let n=0;this.polling&&(n++,this.once("pollComplete",function(){--n||t()})),this.writable||(n++,this.once("drain",function(){--n||t()}))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};yn(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,gn(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=Ue()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new ct(this.uri(),e)}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(r,o)=>{this.onError("xhr post error",r,o)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=e}}class ct extends z{constructor(e,t){super(),_t(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=t.data!==void 0?t.data:null,this.create()}create(){var e;const t=Oe(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const n=this.xhr=new De(t);try{n.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let r in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r)&&n.setRequestHeader(r,this.opts.extraHeaders[r])}}catch{}if(this.method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=()=>{var r;n.readyState===3&&((r=this.opts.cookieJar)===null||r===void 0||r.parseCookies(n)),n.readyState===4&&(n.status===200||n.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof n.status=="number"?n.status:0)},0))},n.send(this.data)}catch(r){this.setTimeoutFn(()=>{this.onError(r)},0);return}typeof document<"u"&&(this.index=ct.requestsCount++,ct.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=Ln,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete ct.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(ct.requestsCount=0,ct.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Pe);else if(typeof addEventListener=="function"){const s="onpagehide"in nt?"pagehide":"unload";addEventListener(s,Pe,!1)}}function Pe(){for(let s in ct.requests)ct.requests.hasOwnProperty(s)&&ct.requests[s].abort()}const Jt=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,e)=>e(s,0),Lt=nt.WebSocket||nt.MozWebSocket,je=!0,xn="arraybuffer",qe=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Un extends Wt{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,n=qe?{}:Oe(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=je&&!qe?t?new Lt(e,t):new Lt(e):new Lt(e,t,n)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;Ft(n,this.supportsBinary,o=>{try{je&&this.ws.send(o)}catch{}r&&Jt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Ue()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Lt}}class Bn extends Wt{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{const t=vn(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=mn();r.readable.pipeTo(e.writable),this.writer=r.writable.getWriter();const o=()=>{n.read().then(({done:h,value:d})=>{h||(this.onPacket(d),o())}).catch(h=>{})};o();const u={type:"open"};this.query.sid&&(u.data=`{"sid":"${this.query.sid}"}`),this.writer.write(u).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;this.writer.write(n).then(()=>{r&&Jt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}}const Dn={websocket:Un,webtransport:Bn,polling:In},Pn=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,jn=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Xt(s){if(s.length>2e3)throw"URI too long";const e=s,t=s.indexOf("["),n=s.indexOf("]");t!=-1&&n!=-1&&(s=s.substring(0,t)+s.substring(t,n).replace(/:/g,";")+s.substring(n,s.length));let r=Pn.exec(s||""),o={},u=14;for(;u--;)o[jn[u]]=r[u]||"";return t!=-1&&n!=-1&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=qn(o,o.path),o.queryKey=Fn(o,o.query),o}function qn(s,e){const t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function Fn(s,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,r,o){r&&(t[r]=o)}),t}let Fe=class mt extends z{constructor(e,t={}){super(),this.binaryType=xn,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=Xt(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=Xt(t.host).host),_t(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=An(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=_e,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new Dn[e](n)}open(){let e;if(this.opts.rememberUpgrade&&mt.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){let t=this.createTransport(e),n=!1;mt.priorWebsocketSuccess=!1;const r=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",l=>{if(!n)if(l.type==="pong"&&l.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;mt.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(p(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const i=new Error("probe error");i.transport=t.name,this.emitReserved("upgradeError",i)}}))};function o(){n||(n=!0,p(),t.close(),t=null)}const u=l=>{const i=new Error("probe error: "+l);i.transport=t.name,o(),this.emitReserved("upgradeError",i)};function h(){u("transport closed")}function d(){u("socket closed")}function c(l){t&&l.name!==t.name&&o()}const p=()=>{t.removeListener("open",r),t.removeListener("error",u),t.removeListener("close",h),this.off("close",d),this.off("upgrading",c)};t.once("open",r),t.once("error",u),t.once("close",h),this.once("close",d),this.once("upgrading",c),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onOpen(){if(this.readyState="open",mt.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const n=this.writeBuffer[t].data;if(n&&(e+=Cn(n)),t>0&&e>this.maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,r){if(typeof t=="function"&&(r=t,t=void 0),typeof n=="function"&&(r=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const o={type:e,data:t,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}onError(e){mt.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let n=0;const r=e.length;for(;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}};Fe.protocol=_e;function Mn(s,e="",t){let n=s;t=t||typeof location<"u"&&location,s==null&&(s=t.protocol+"//"+t.host),typeof s=="string"&&(s.charAt(0)==="/"&&(s.charAt(1)==="/"?s=t.protocol+s:s=t.host+s),/^(https?|wss?):\/\//.test(s)||(typeof t<"u"?s=t.protocol+"//"+s:s="https://"+s),n=Xt(s)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const r=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+r+":"+n.port+e,n.href=n.protocol+"://"+r+(t&&t.port===n.port?"":":"+n.port),n}const Vn=typeof ArrayBuffer=="function",Kn=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,Me=Object.prototype.toString,Wn=typeof Blob=="function"||typeof Blob<"u"&&Me.call(Blob)==="[object BlobConstructor]",Gn=typeof File=="function"||typeof File<"u"&&Me.call(File)==="[object FileConstructor]";function $t(s){return Vn&&(s instanceof ArrayBuffer||Kn(s))||Wn&&s instanceof Blob||Gn&&s instanceof File}function Rt(s,e){if(!s||typeof s!="object")return!1;if(Array.isArray(s)){for(let t=0,n=s.length;t<n;t++)if(Rt(s[t]))return!0;return!1}if($t(s))return!0;if(s.toJSON&&typeof s.toJSON=="function"&&arguments.length===1)return Rt(s.toJSON(),!0);for(const t in s)if(Object.prototype.hasOwnProperty.call(s,t)&&Rt(s[t]))return!0;return!1}function Jn(s){const e=[],t=s.data,n=s;return n.data=zt(t,e),n.attachments=e.length,{packet:n,buffers:e}}function zt(s,e){if(!s)return s;if($t(s)){const t={_placeholder:!0,num:e.length};return e.push(s),t}else if(Array.isArray(s)){const t=new Array(s.length);for(let n=0;n<s.length;n++)t[n]=zt(s[n],e);return t}else if(typeof s=="object"&&!(s instanceof Date)){const t={};for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=zt(s[n],e));return t}return s}function Xn(s,e){return s.data=Ht(s.data,e),delete s.attachments,s}function Ht(s,e){if(!s)return s;if(s&&s._placeholder===!0){if(typeof s.num=="number"&&s.num>=0&&s.num<e.length)return e[s.num];throw new Error("illegal attachments")}else if(Array.isArray(s))for(let t=0;t<s.length;t++)s[t]=Ht(s[t],e);else if(typeof s=="object")for(const t in s)Object.prototype.hasOwnProperty.call(s,t)&&(s[t]=Ht(s[t],e));return s}const $n=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],zn=5;var M;(function(s){s[s.CONNECT=0]="CONNECT",s[s.DISCONNECT=1]="DISCONNECT",s[s.EVENT=2]="EVENT",s[s.ACK=3]="ACK",s[s.CONNECT_ERROR=4]="CONNECT_ERROR",s[s.BINARY_EVENT=5]="BINARY_EVENT",s[s.BINARY_ACK=6]="BINARY_ACK"})(M||(M={}));class Hn{constructor(e){this.replacer=e}encode(e){return(e.type===M.EVENT||e.type===M.ACK)&&Rt(e)?this.encodeAsBinary({type:e.type===M.EVENT?M.BINARY_EVENT:M.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===M.BINARY_EVENT||e.type===M.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Jn(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}}function Ve(s){return Object.prototype.toString.call(s)==="[object Object]"}class Yt extends z{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===M.BINARY_EVENT;n||t.type===M.BINARY_ACK?(t.type=n?M.EVENT:M.ACK,this.reconstructor=new Yn(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if($t(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(M[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===M.BINARY_EVENT||n.type===M.BINARY_ACK){const o=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const u=e.substring(o,t);if(u!=Number(u)||e.charAt(t)!=="-")throw new Error("Illegal attachments");n.attachments=Number(u)}if(e.charAt(t+1)==="/"){const o=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););n.nsp=e.substring(o,t)}else n.nsp="/";const r=e.charAt(t+1);if(r!==""&&Number(r)==r){const o=t+1;for(;++t;){const u=e.charAt(t);if(u==null||Number(u)!=u){--t;break}if(t===e.length)break}n.id=Number(e.substring(o,t+1))}if(e.charAt(++t)){const o=this.tryParse(e.substr(t));if(Yt.isPayloadValid(n.type,o))n.data=o;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case M.CONNECT:return Ve(t);case M.DISCONNECT:return t===void 0;case M.CONNECT_ERROR:return typeof t=="string"||Ve(t);case M.EVENT:case M.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&$n.indexOf(t[0])===-1);case M.ACK:case M.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Yn{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=Xn(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Qn=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Yt,Encoder:Hn,get PacketType(){return M},protocol:zn},Symbol.toStringTag,{value:"Module"}));function ot(s,e,t){return s.on(e,t),function(){s.off(e,t)}}const Zn=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Ke extends z{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[ot(e,"open",this.onopen.bind(this)),ot(e,"packet",this.onpacket.bind(this)),ot(e,"error",this.onerror.bind(this)),ot(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(Zn.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const n={type:M.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const o=this.ids++,u=t.pop();this._registerAckCallback(o,u),n.id=o}const r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){var n;const r=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(r===void 0){this.acks[e]=t;return}const o=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let u=0;u<this.sendBuffer.length;u++)this.sendBuffer[u].id===e&&this.sendBuffer.splice(u,1);t.call(this,new Error("operation has timed out"))},r);this.acks[e]=(...u)=>{this.io.clearTimeoutFn(o),t.apply(this,[null,...u])}}emitWithAck(e,...t){const n=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((r,o)=>{t.push((u,h)=>n?u?o(u):r(h):r(u)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...o)=>n!==this._queue[0]?void 0:(r!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(r)):(this._queue.shift(),t&&t(null,...o)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:M.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case M.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case M.EVENT:case M.BINARY_EVENT:this.onevent(e);break;case M.ACK:case M.BINARY_ACK:this.onack(e);break;case M.DISCONNECT:this.ondisconnect();break;case M.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...r){n||(n=!0,t.packet({type:M.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:M.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}function yt(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}yt.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*s);s=Math.floor(e*10)&1?s+t:s-t}return Math.min(s,this.max)|0},yt.prototype.reset=function(){this.attempts=0},yt.prototype.setMin=function(s){this.ms=s},yt.prototype.setMax=function(s){this.max=s},yt.prototype.setJitter=function(s){this.jitter=s};class Qt extends z{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,_t(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new yt({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||Qn;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Fe(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const r=ot(t,"open",function(){n.onopen(),e&&e()}),o=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),e?e(h):this.maybeReconnectOnOpen()},u=ot(t,"error",o);if(this._timeout!==!1){const h=this._timeout,d=this.setTimeoutFn(()=>{r(),o(new Error("timeout")),t.close()},h);this.opts.autoUnref&&d.unref(),this.subs.push(()=>{this.clearTimeoutFn(d)})}return this.subs.push(r),this.subs.push(u),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(ot(e,"ping",this.onping.bind(this)),ot(e,"data",this.ondata.bind(this)),ot(e,"error",this.onerror.bind(this)),ot(e,"close",this.onclose.bind(this)),ot(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){Jt(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new Ke(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const n of t)if(this.nsps[n].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const bt={};function It(s,e){typeof s=="object"&&(e=s,s=void 0),e=e||{};const t=Mn(s,e.path||"/socket.io"),n=t.source,r=t.id,o=t.path,u=bt[r]&&o in bt[r].nsps,h=e.forceNew||e["force new connection"]||e.multiplex===!1||u;let d;return h?d=new Qt(n,e):(bt[r]||(bt[r]=new Qt(n,e)),d=bt[r]),t.query&&!e.query&&(e.query=t.queryKey),d.socket(t.path,e)}Object.assign(It,{Manager:Qt,Socket:Ke,io:It,connect:It});let xt;const ts=new Uint8Array(16);function es(){if(!xt&&(xt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!xt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return xt(ts)}const H=[];for(let s=0;s<256;++s)H.push((s+256).toString(16).slice(1));function ns(s,e=0){return H[s[e+0]]+H[s[e+1]]+H[s[e+2]]+H[s[e+3]]+"-"+H[s[e+4]]+H[s[e+5]]+"-"+H[s[e+6]]+H[s[e+7]]+"-"+H[s[e+8]]+H[s[e+9]]+"-"+H[s[e+10]]+H[s[e+11]]+H[s[e+12]]+H[s[e+13]]+H[s[e+14]]+H[s[e+15]]}const ss=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),We={randomUUID:ss};function rs(s,e,t){if(We.randomUUID&&!e&&!s)return We.randomUUID();s=s||{};const n=s.random||(s.rng||es)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(let r=0;r<16;++r)e[t+r]=n[r];return e}return ns(n)}function os(s,e){const t=e.map(r=>JSON.stringify(r)).join(" "),n=new Date().toISOString();return JSON.stringify({level:s,time:n,message:t})}function is(s,e){const t=JSON.parse(s);return e.forEach(n=>delete t[n]),t}function as(s){if(typeof s=="object"&&s!==null)return s;try{return JSON.parse(s)}catch{return{extraData:s}}}function cs(s){const e=/\(([^)]+)\)/,t=s.match(e);if(t&&t[1]){const n=t[1].split(";");for(let r of n)if(r=r.trim(),r.startsWith("Windows")||r.startsWith("Macintosh")||r.startsWith("Linux"))return r}return"Unknown"}function Ge(s){return(...e)=>new Promise((t,n)=>{try{const r=s(...e);t(r)}catch(r){n(r)}})}const hs={reconnection:!0,reconnectionDelay:5e3,reconnectionAttempts:10,upgrade:!1,transports:["websocket"],debug:!1},Zt={logToConsole:!0,overloadGlobalConsole:!1,socketEmitInterval:6e4},ht={CREATE:"Create",READ:"Read",UPDATE:"Update",DELETE:"Delete",CONVERT:"Convert",DOWNLOAD:"Download",UPLOAD:"Upload",ENCRYPT:"Encrypt",DECRYPT:"Decrypt",FILTER:"Filter",INPUT:"Input",OUTPUT:"Output",PLUGIN:"Plugin",LOGIN:"Login",LOGOUT:"Logout",REFRESH:"Refresh",CHECK:"Check",WEBHOOK:"Webhook",WSCONNECT:"WSConnect"},ls={Create:1,Read:2,Update:3,Delete:4,Convert:5,Download:6,Upload:7,Encrypt:8,Decrypt:9,Filter:10,Input:11,Output:12,Plugin:13,Login:14,Logout:15,Refresh:16,Check:17,Webhook:18,WSConnect:19},lt={INFO:"info",WARNING:"warning",MODIFY:"modify",ERROR:"error",VIEW:"view"},Q={INFO:"info",WARNING:"warning",ERROR:"error",DEBUG:"debug"};let Z=console;class us{constructor(e){X(this,"logToConsole"),X(this,"overloadGlobalConsole"),X(this,"system"),X(this,"socketEmitInterval"),X(this,"storageId"),X(this,"emitInProgress"),X(this,"queue"),X(this,"processing"),X(this,"storageInitialized"),X(this,"interval"),X(this,"logIndex"),X(this,"socket"),X(this,"requestUrl"),X(this,"staticObject",{}),X(this,"localObject",{}),X(this,"isGetItemAsync"),X(this,"isSetItemAsync"),X(this,"getItem"),X(this,"setItem"),X(this,"parseLog"),X(this,"_logMethod"),X(this,"_warnMethod"),X(this,"_errorMethod"),X(this,"_debugMethod");const{loggerOptions:t}=e;if(!t.system)throw new Error("Config property 'system' should be provided!");this.isGetItemAsync=t.isGetItemAsync||!1,this.isSetItemAsync=t.isSetItemAsync||!1,this.setupStorageFunctions(t.getItem,t.setItem,t.parseLog),this.system=t.system,this.socketEmitInterval=t.socketEmitInterval||Zt.socketEmitInterval,this.logToConsole=t.logToConsole!==void 0?t.logToConsole:Zt.logToConsole,this.overloadGlobalConsole=t.overloadGlobalConsole!==void 0?t.overloadGlobalConsole:Zt.overloadGlobalConsole,this.storageId=this.getStorageName(),this.queue=[],this.processing=!1,this.storageInitialized=!1,this.emitInProgress=!1,this.logIndex=0,this.init(e)}setupStorageFunctions(e,t,n){this.getItem=e&&typeof e=="function"?this.isGetItemAsync?e:Ge(e):this.defaultGetItemFunction,this.setItem=t&&typeof t=="function"?this.isSetItemAsync?t:Ge(t):this.defaultSetItemFunction,this.parseLog=n&&typeof n=="function"?n:os}sendHttpRequest(e){if(!this.requestUrl)throw new Error("requestUrl is not provided");const t={Data:e};return fetch(this.requestUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}init(e){const{socket:t,url:n,requestUrl:r,socketOptions:o={}}=e;this._logMethod=Z.log.bind(Z),this._warnMethod=Z.warn.bind(Z),this._errorMethod=Z.error.bind(Z),this._debugMethod=Z.debug.bind(Z),this.initStorage().then(()=>{if(t)this.socket=t;else if(n)this.socket=this.createConnection(n,o);else if(r)this.requestUrl=r;else throw new Error("Must provide either a 'socket', 'requestUrl' or a 'url' for logger requests");this.interval=setInterval(async()=>{await this.emitLogs()},this.socketEmitInterval),this.overloadGlobalConsole&&this._overloadConsole()})}createConnection(e,t){let n={...hs};return t&&(n={...n,...t}),It(e,n)}async emitLogs(){if(!this.emitInProgress)try{const e=await this.getItem(this.storageId),t=JSON.parse(e||"{}"),n={...this.localObject,...t};if(!Object.keys(n).length)return;const r=[];this.emitInProgress=!0;const o=Object.keys(n);if(!o.length)return;if((!this.socket||!this.socket.connected)&&!this.requestUrl)throw new Error("Log request can't be sent. Socket is disconnected or requestUrl is not provided");const u=[];for(const c of o){const p=as(n[c]),l={...this.staticObject,...p},i=this.populateSendingLog(l);this.socket?this.socket.emit("Log",JSON.stringify(i)):this.requestUrl&&u.push(i),r.push(c)}u.length&&await this.sendHttpRequest(u);const h=await this.getItem(this.storageId);if(!h)return;const d=is(h,r);this.localObject={},await this.setItem(this.storageId,JSON.stringify(d))}catch(e){this._errorMethod(e)}finally{this.emitInProgress=!1}}populateSendingLog(e){const t={...e},n=t.ActionName;return n&&(t.ActionID=ls[n]),t}setupStaticFields(e){this.staticObject={...e}}populateMetaData(){const e=new Date;let t;typeof window<"u"&&typeof window.document<"u"?t=window==null?void 0:window.navigator.userAgent:typeof self<"u"&&self.navigator&&(t=self.navigator.userAgent);let n;return t&&(n=cs(t)),{System:this.system,DateTime:e,UserAgent:t,OSVersion:n}}async stop(){!this.socket||!this.socket.connected||(clearInterval(this.interval),await this.emitLogs(),this.socket.disconnect())}async start(){var e;this.socket&&this.socket.connected||((e=this.socket)==null||e.connect(),this.interval=setInterval(async()=>{await this.emitLogs()},this.socketEmitInterval))}_overloadConsole(){Z=Object.assign(Z,{log:e=>{this.log(e)},warn:e=>{this.warn(e)},error:e=>{this.error(e)},debug:e=>{this.debug(e)}})}async initStorage(){const e=await this.getItem(this.storageId);(!e||typeof e!="string")&&(await this.setItem(this.storageId,JSON.stringify({})),this.storageInitialized=!0)}async resetStorage(){await this.setItem(this.storageId,JSON.stringify({}))}getStorageName(){const e=rs();return this.system.toString().toUpperCase()+e+Date.now()}async processLog(...e){try{if(e.length<2)return;const t=e[0],n=e[1],r=this.formItemKey(t);if(!this.storageInitialized){this.localObject={...this.localObject,[r]:n};return}const o=await this.getItem(this.storageId);if(!o)return;const u=JSON.parse(o);u[r]=JSON.stringify(n),await this.setItem(this.storageId,JSON.stringify(u))}catch(t){this._errorMethod(t)}}async processQueue(){if(this.processing||this.queue.length===0)return;const e=this.queue.shift();e&&(this.processing=!0,await this.processLog(...e).finally(()=>{this.processing=!1,this.processQueue()}))}log(e){const t={...this.populateMetaData(),...e},n=["INFO",t];this.queue.push(n),this.logToConsole&&this._logMethod.apply(Z,[t]),this.processQueue()}warn(e){const t=["WARN",e];this.queue.push(t),this.logToConsole&&this._warnMethod.apply(Z,[e]),this.processQueue()}error(e){const t=["ERROR",e];this.queue.push(t),this.logToConsole&&this._errorMethod.apply(Z,[e]),this.processQueue()}debug(e){const t=["DEBUG",e];this.queue.push(t),this.logToConsole&&this._debugMethod.apply(Z,[e]),this.processQueue()}async defaultGetItemFunction(e){return localStorage.getItem(e)}async defaultSetItemFunction(e,t){try{localStorage.setItem(e,t)}catch(n){this._errorMethod(n)}}formItemKey(e){const t=new Date().toISOString();return this.logIndex++,`${e}-${this.system}-${t}-${this.logIndex}`}}class ps{constructor(e){K(this,"storageLogger");this.eventsSdkClass=e,this.eventsSdkClass=e}init(){if(!this.eventsSdkClass.options.useLogger)return;if(this.eventsSdkClass.options.storageLoggerInstance){this.storageLogger=this.eventsSdkClass.options.storageLoggerInstance;return}let e;this.eventsSdkClass.options.loggerSocketConnection&&(e=this.eventsSdkClass.options.loggerSocketConnection),this.eventsSdkClass.socketIoClass.ioFunction&&!e&&(e=this.eventsSdkClass.socketIoClass.ioFunction(this.eventsSdkClass.options.loggerServer,this.eventsSdkClass.options.loggerConnectOptions)),e&&(this.storageLogger=new us({socket:e,loggerOptions:this.eventsSdkClass.options.loggerConfig}))}async start(){this.storageLogger&&await this.storageLogger.start()}stop(){this.storageLogger&&this.storageLogger.stop()}log(e){this.eventsSdkClass.options.useLogger&&(this.storageLogger?e.Level===Q.INFO?this.storageLogger.log(e):e.Level===Q.ERROR&&this.storageLogger.error(e):e.Level===Q.INFO?console.log(e):e.Level===Q.ERROR&&console.error(e))}sdkConnectionSuccess(){const e={...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(e,this.eventsSdkClass.getCircularReplacer()),ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Connection established",StatusCode:200,Level:Q.INFO,LogType:lt.INFO})}sdkDisconnect(e){this.log({Message:`Sdk disconnected from the socket server ${this.eventsSdkClass.server&&this.eventsSdkClass.server.Domain?this.eventsSdkClass.server.Domain:this.eventsSdkClass.URL} (${e})`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Connection closed",StatusCode:200,Level:Q.INFO,LogType:lt.INFO})}sdkAttemptToConnect(e){this.log({Message:`${this.eventsSdkClass.options.loggerConfig.system} is trying to connect to WS server ${e}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Switching Protocols",StatusCode:101,Level:Q.INFO,LogType:lt.INFO})}sdkAttemptToConnectError(e){this.log({Message:`${e}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Connection error",StatusCode:500,Level:Q.ERROR,LogType:lt.ERROR})}loginError(e,t,n,r){this.log({Message:`External login request error with the login type ${e} ${e===rt.TOKEN?n:r}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"External login error",StatusCode:t||400,Level:Q.ERROR,LogType:lt.ERROR})}getSettingsError(e,t){this.log({Message:`Get settings error with token ${e}, error: ${t}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:Q.ERROR,LogType:lt.ERROR})}refreshTokenError(e,t,n){this.log({Message:`Refresh token error with old refresh token ${e}, url: ${t}, error: ${n}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:Q.ERROR,LogType:lt.ERROR})}keepAliveEmit(){this.log({Message:`Keep alive event emitted with this token: ${this.eventsSdkClass.authClass.token}`,ActionName:ht.WSCONNECT,isShowClient:!1,Level:Q.INFO,LogType:lt.INFO})}keepAliveResponse(e){this.log({Message:`Keep alive response: ${JSON.stringify(e)}`,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Successful",StatusCode:200,Level:Q.INFO,LogType:lt.INFO})}eventLog(e,t){const n={[ft.FULL]:[],[ft.BOOTSTRAP]:[P.LOGIN_STATUS,P.LOGIN_SUCCESS,P.ALL_EXTENSION_STATUS,P.ALL_DIALER_STATUS],[ft.DEBUG_EXTENSIONS]:[P.ALL_EXTENSION_STATUS,P.EXTENSION_EVENT,P.EXTENSIONS_UPDATED],[ft.DEBUG_DIALER]:[P.ALL_DIALER_STATUS,P.DIALER_EVENT],[ft.DEBUG_QUEUE]:[P.QUEUE_EVENT]};this.eventsSdkClass.options.debugOption&&(n[this.eventsSdkClass.options.debugOption].includes(e)||this.eventsSdkClass.options.debugOption===ft.FULL)&&this.log({Message:`Event name: ${e}`,Body:t,ActionName:ht.WSCONNECT,isShowClient:!1,Status:"Successful",Level:Q.INFO,LogType:lt.INFO})}}class fs{constructor(e){K(this,"listeners",{[P.ALL_EXTENSION_STATUS]:[],[P.ALL_DIALER_STATUS]:[],[P.ALL_USERS_STATUS]:[],[P.QUEUE_EVENT]:[],[P.EXTENSION_EVENT]:[],[P.DIALER_EVENT]:[],[P.LOGIN_SUCCESS]:[],[P.LOGIN_STATUS]:[],[P.KEEP_ALIVE_RESPONSE]:[],[P.ONLINE_STATUS_EVENT]:[],[P.EXTENSIONS_UPDATED]:[]});K(this,"allListeners",[]);this.eventsSdkClass=e,this.eventsSdkClass=e}on(e,t){e==="*"?this.allListeners.push(t):this.listeners[e].push(t)}off(e,t){if(e==="*")this.allListeners=this.allListeners.filter(n=>n!==t);else{const r=this.listeners[e].filter(o=>o!==t);this.listeners={...this.listeners,[e]:r}}}emit(e,t){this.eventsSdkClass.socketIoClass.lastEventTimestamp=new Date().getTime(),this.listeners[e].forEach(r=>r({name:e,data:t}));const n={name:e,data:t};this.allListeners.forEach(r=>r(n))}}class ds{constructor(e){K(this,"options");K(this,"servers",[]);K(this,"URLList",[]);K(this,"server");K(this,"URL");K(this,"socket");K(this,"mainServer");K(this,"alreadyAttemptedOtherServers",[]);K(this,"authClass",new tn(this));K(this,"socketIoClass",new cn(this));K(this,"loggerClass",new ps(this));K(this,"eventEmitterClass",new fs(this));K(this,"getCircularReplacer",()=>{const e=new WeakSet;return(t,n)=>{if(!(t==="socket"||t==="io"||t==="nsps")){if(typeof n=="object"&&n!==null){if(e.has(n))return;e.add(n)}return n}}});this.options={...en,...e}}on(e,t){this.eventEmitterClass.on(e,t)}emit(e,...t){this.socketIoClass.io&&this.socketIoClass.io.emit(e,...t)}connect(e){e===it.MAIN&&this.findMainServer(),e===it.NEXT&&this.findNextServer(),this.socketIoClass.doReconnect=!0;try{this.loggerClass.init()}catch(t){console.error(t)}this.socketIoClass.initSocketConnection(),this.socketIoClass.initSocketEvents(),this.socketIoClass.initKeepAlive()}disconnect(){this.socketIoClass.doReconnect=!1,this.socketIoClass.closeAllConnections(),this.loggerClass.stop()}clearKeepAliveInterval(){this.socketIoClass.clearKeepAliveInterval()}findMainServer(){this.servers.length?(this.mainServer=this.servers.reduce((e,t)=>t.Priority>e.Priority?t:e),this.server=this.mainServer):this.URLList.length&&(this.URL=this.URLList[0])}findNextServer(){if(this.servers.length&&this.server)if(this.server.Priority===this.mainServer.Priority){let e=this.servers.filter(t=>t.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(t.Priority)+1===0);e.length||(this.alreadyAttemptedOtherServers=[],e=this.servers.filter(t=>t.Priority!==this.mainServer.Priority&&this.alreadyAttemptedOtherServers.indexOf(t.Priority)+1===0)),e.length&&(this.server=e.reduce((t,n)=>n.Priority>t.Priority?n:t),this.alreadyAttemptedOtherServers.push(this.server.Priority))}else this.server=this.mainServer;else if(this.URLList.length)if(this.URL===this.URLList[0]){let e=this.URLList.filter(t=>t!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(t)+1===0);e.length||(this.alreadyAttemptedOtherServers=[],e=this.URLList.filter(t=>t!==this.URLList[0]&&this.alreadyAttemptedOtherServers.indexOf(t)+1===0)),e.length&&(this.URL=e[0],this.alreadyAttemptedOtherServers.push(this.URL))}else this.URL=this.URLList[0]}async init(){const e=await this.authClass.login();return e&&this.authClass.onLoginResponse(e),!0}getCurrentMonitorServer(){return this.server}}return $.CallStatusEnum=fe,$.CallTypeEnum=de,$.ConnectionStatusEnum=dt,$.DebugOption=ft,$.DialerTypeEnum=ge,$.DirectionEnum=ye,$.DoNotCallMeStatusCodeEnum=me,$.EventsEnum=P,$.ExtensionEventReasonEnum=Pt,$.ExtensionHangupCauseEnum=ve,$.LoginType=rt,$.QueueEventReasonEnum=ke,$.ServerListenerEventsEnum=jt,$.ServerParameter=it,$.default=ds,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),$}({},ws);
17
+ `+ke+"}":"{"+te.join(",")+"}":"{}";return B.pop(),Se}};u.stringify=function(E,_,w){var D,S,x,B;if(typeof _=="function"||typeof _=="object"&&_){if((B=d.call(_))==r)S=_;else if(B==v){x={};for(var N,M=0,G=_.length;G>M;N=_[M++],B=d.call(N),(B==y||B==p)&&(x[N]=1));}}if(w)if((B=d.call(w))==p){if((w-=w%1)>0)for(D="",w>10&&(w=10);D.length<w;D+=" ");}else B==y&&(D=w.length<=10?w:w.slice(0,10));return R("",(N={},N[""]=E,N),S,x,D,"",[])}}if(!o("json-parse")){var k,K,$=String.fromCharCode,J={92:"\\",34:'"',47:"/",98:"\b",116:" ",110:`
18
+ `,102:"\f",114:"\r"},X=function(){throw k=K=null,SyntaxError()},W=function(){for(var E,_,w,D,S,x=K,B=x.length;B>k;)switch(S=x.charCodeAt(k)){case 9:case 10:case 13:case 32:k++;break;case 123:case 125:case 91:case 93:case 58:case 44:return E=P?x.charAt(k):x[k],k++,E;case 34:for(E="@",k++;B>k;)if(S=x.charCodeAt(k),32>S)X();else if(S==92)switch(S=x.charCodeAt(++k)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:E+=J[S],k++;break;case 117:for(_=++k,w=k+4;w>k;k++)S=x.charCodeAt(k),S>=48&&57>=S||S>=97&&102>=S||S>=65&&70>=S||X();E+=$("0x"+x.slice(_,k));break;default:X()}else{if(S==34)break;for(S=x.charCodeAt(k),_=k;S>=32&&S!=92&&S!=34;)S=x.charCodeAt(++k);E+=x.slice(_,k)}if(x.charCodeAt(k)==34)return k++,E;X();default:if(_=k,S==45&&(D=!0,S=x.charCodeAt(++k)),S>=48&&57>=S){for(S==48&&(S=x.charCodeAt(k+1),S>=48&&57>=S)&&X(),D=!1;B>k&&(S=x.charCodeAt(k),S>=48&&57>=S);k++);if(x.charCodeAt(k)==46){for(w=++k;B>w&&(S=x.charCodeAt(w),S>=48&&57>=S);w++);w==k&&X(),k=w}if(S=x.charCodeAt(k),S==101||S==69){for(S=x.charCodeAt(++k),(S==43||S==45)&&k++,w=k;B>w&&(S=x.charCodeAt(w),S>=48&&57>=S);w++);w==k&&X(),k=w}return+x.slice(_,k)}if(D&&X(),x.slice(k,k+4)=="true")return k+=4,!0;if(x.slice(k,k+5)=="false")return k+=5,!1;if(x.slice(k,k+4)=="null")return k+=4,null;X()}return"$"},oe=function(E){var _,w;if(E=="$"&&X(),typeof E=="string"){if((P?E.charAt(0):E[0])=="@")return E.slice(1);if(E=="["){for(_=[];E=W(),E!="]";w||(w=!0))w&&(E==","?(E=W(),E=="]"&&X()):X()),E==","&&X(),_.push(oe(E));return _}if(E=="{"){for(_={};E=W(),E!="}";w||(w=!0))w&&(E==","?(E=W(),E=="}"&&X()):X()),(E==","||typeof E!="string"||(P?E.charAt(0):E[0])!="@"||W()!=":")&&X(),_[E.slice(1)]=oe(W());return _}X()}return E},Ue=function(E,_,w){var D=Be(E,_,w);D===l?delete E[_]:E[_]=D},Be=function(E,_,w){var D,S=E[_];if(typeof S=="object"&&S)if(d.call(S)==v)for(D=S.length;D--;)Ue(S,D,w);else f(S,function(x){Ue(S,x,w)});return w.call(E,_,S)};u.parse=function(E,_){var w,D;return k=0,K=""+E,w=oe(W()),W()!="$"&&X(),k=K=null,_&&d.call(_)==r?Be((D={},D[""]=w,D),"",_):w}}}})(this)},{}],48:[function(a,t){function e(s,o){var h=[];o=o||0;for(var f=o||0;f<s.length;f++)h[f-o]=s[f];return h}t.exports=e},{}]},{},[1])(1)}const Ge=Object.assign({"./v1_3_7.js":Object.freeze(Object.defineProperty({__proto__:null,default:$e},Symbol.toStringTag,{value:"Module"}))}),ze=/v\d+_\d+_\d+/;function Je(a){return typeof a=="function"}const ue=Object.entries(Ge).reduce((a,t)=>{var o;const e=t[1].default,s=(o=t[0].match(ze))==null?void 0:o[0];return Je(e)&&s&&(a[s]=e()),a},{}),Ae=a=>{if(a in ue)return ue[a];throw new Error(`Socket version ${a} not found`)},We={...ue,getSocketVersion:Ae,makeSocketVersion:(a,...t)=>Ae(a)(...t)};var Ne=(a=>(a.RINGING="Ringing",a.TALKING="Talking",a.DIALING="Dialing",a.HOLD="Hold",a))(Ne||{}),Le=(a=>(a.INCOMING="Incoming",a.OUTGOING="Outgoing",a))(Le||{}),re=(a=>(a.CONNECTED="connected",a.DISCONNECTED="disconnected",a.TRYING_TO_CONNECT="tryingToConnect",a))(re||{}),_e=(a=>(a.AUTOMATIC="Automatic",a.IVR="IVR",a))(_e||{}),Oe=(a=>(a.INCOMINC="Incoming",a.OUTGOING="Outgoing",a.SPY="Spy",a.CLICK2CALL="Click2Call",a))(Oe||{}),Re=(a=>(a.RESPONSE_FROM_API_VALID="RESPONSE_FROM_API_VALID",a.RESPONSE_FROM_API_INVALID="RESPONSE_FROM_API_INVALID",a))(Re||{}),j=(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))(j||{}),pe=(a=>(a.NEWCALL="NEWCALL",a.ANSWER="ANSWER",a.HOLD="HOLD",a.UNHOLD="UNHOLD",a.HANGUP="HANGUP",a.USER_STATUS_UPDATE="userStatusUpdate",a))(pe||{}),Ie=(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))(Ie||{}),xe=(a=>(a.ANSWER="ANSWER",a.ABANDONED="ABANDONED",a.EXIT="EXIT",a.JOIN="JOIN",a))(xe||{});class ce{static mapExtensionEvent(t){var f,l;const e=t.reason;let s,o;t.data.currentCall&&(o=this.mapExtensionCall(t,t.data.currentCall));const h=this.mapExtensionData(t,t.data);return e===pe.HANGUP?s={...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}})}}:s={...t,data:{...h,currentCall:o,calls:(l=t.data.calls)==null?void 0:l.map(d=>this.mapExtensionCall(t,d))},reason:e},s}static mapAllExtensionStatus(t){return{...t,extensions:t.extensions.map(e=>{var s;return{...this.mapExtensionData(t,e),currentCall:e.currentCall?this.mapExtensionCall(t,e.currentCall):void 0,calls:(s=e.calls)==null?void 0:s.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(s=>this.mapQueueCall(t,s))}))}}static mapQueueEvent(t){return{...t,data:{...t.data,Calls:t.data.Calls.map(e=>this.mapQueueCall(t,e))}}}static assignProperty(t,e,s){t[e]=s}static configureUTCForObject(t,e,s,o){const h=(s-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 r=(c-o*60)*1e3;this.assignProperty(l,`${u}_UTC`,r),this.assignProperty(l,`${u}_UTC_CLIENT`,r+f)}else this.assignProperty(l,`${u}_UTC`,0),this.assignProperty(l,`${u}_UTC_CLIENT`,0)}),{...t,...l}}}var fe=(a=>(a.UPDATE_MONITORED_EXTENSIONS="updateMonitoredExtensions",a.KEEP_ALIVE="keepalive",a))(fe||{});class He{constructor(t){V(this,"io");V(this,"ioFunction");V(this,"lastEventTimestamp",new Date().getTime());V(this,"doReconnect",!0);V(this,"keepAliveInterval");V(this,"keepReconnectInterval");V(this,"keepReconnectTimeout");V(this,"connected",!1);V(this,"reconnectionTime",20);this.eventsSdkClass=t,this.eventsSdkClass=t,typeof window<"u"&&(window.addEventListener("offline",()=>{this.closeAllConnections()}),window.addEventListener("online",()=>{setTimeout(()=>{this.keepReconnectTimeout&&clearTimeout(this.keepReconnectTimeout),this.eventsSdkClass.connect(Z.NEXT)},5e3)})),typeof self<"u"&&typeof window>"u"&&typeof global>"u"&&(self.addEventListener("offline",()=>{this.closeAllConnections()}),self.addEventListener("online",()=>{setTimeout(()=>{this.keepReconnectTimeout&&clearTimeout(this.keepReconnectTimeout),this.eventsSdkClass.connect(Z.NEXT)},5e3)}))}getSocketIoFunction(t){const e=t.split("v="),s="v".concat(e[e.length-1]).replaceAll(".","_");this.ioFunction=We.getSocketVersion(s)}initSocketConnection(){const t=this.eventsSdkClass.authClass.token,e=this.eventsSdkClass.options.protocol,s=this.eventsSdkClass.server;try{const o=s?s.Domain:this.eventsSdkClass.URL,h=s?`${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.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{attemptToConnect:h,connectionStatus:re.TRYING_TO_CONNECT}),this.eventsSdkClass.loggerClass.sdkAttemptToConnect(o);else throw new Error("Socket server url no defined")}catch(o){this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(o)}}clearKeepAliveInterval(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval)}initKeepAlive(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveInterval=setInterval(async()=>{if(new Date().getTime()>this.lastEventTimestamp+this.eventsSdkClass.options.keepAliveTimeout&&this.io&&this.eventsSdkClass.authClass.token){this.eventsSdkClass.emit(fe.KEEP_ALIVE,this.eventsSdkClass.authClass.token),this.eventsSdkClass.loggerClass.keepAliveEmit();return}},this.eventsSdkClass.options.keepAliveTimeout)}closeAllConnections(){var t;this.io&&(this.io.close(),(t=this.io)==null||t.disconnect(),this.io=void 0),this.eventsSdkClass.loggerClass.stop(),se.clearSessionStorage()}initSocketEvents(){this.io&&this.io.on(j.LOGIN_SUCCESS,t=>this.onLoginSuccessEvent(t,j.LOGIN_SUCCESS)).on(j.QUEUE_EVENT,t=>this.onQueueEvent(t,j.QUEUE_EVENT)).on(j.EXTENSION_EVENT,t=>this.onExtensionEvent(t,j.EXTENSION_EVENT)).on(j.DIALER_EVENT,t=>this.onDialerEvent(t,j.DIALER_EVENT)).on(j.LOGIN_STATUS,t=>this.onLoginStatusEvent(t,j.LOGIN_STATUS)).on(j.ALL_EXTENSION_STATUS,t=>this.onAllExtensionStatus(t,j.ALL_EXTENSION_STATUS)).on(j.ALL_DIALER_STATUS,t=>this.onAllDialerStatus(t,j.ALL_DIALER_STATUS)).on(j.KEEP_ALIVE_RESPONSE,t=>this.onKeepAliveResponse(t)).on(j.EXTENSIONS_UPDATED,t=>this.onExtensionsUpdatedEvent(t,j.EXTENSIONS_UPDATED)).on(j.CONNECT,()=>this.onConnect()).on(j.DISCONNECT,t=>this.onDisconnect(t)).on(j.CONNECT_ERROR_EVENT,t=>this.onConnectError(t))}onLoginSuccessEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onQueueEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ce.mapQueueEvent(t))}onExtensionEvent(t,e){const s=ce.mapExtensionEvent(t);s&&(this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,s))}onDialerEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onLoginStatusEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,ce.mapLoginStatusEvent(t))}onAllExtensionStatus(t,e){const s=ce.mapAllExtensionStatus(t);this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,s)}onAllDialerStatus(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onKeepAliveResponse(t){if(this.eventsSdkClass.loggerClass.keepAliveResponse(t),t.errorCode){this.initSocketConnection();return}this.connected?this.lastEventTimestamp=new Date().getTime():this.initSocketConnection()}onExtensionsUpdatedEvent(t,e){this.eventsSdkClass.loggerClass.eventLog(e,t),this.eventsSdkClass.eventEmitterClass.emit(e,t)}onConnect(){this.connected=!0,this.keepReconnectInterval&&clearInterval(this.keepReconnectInterval),this.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{connectionStatus:re.CONNECTED}),this.eventsSdkClass.loggerClass.start().then(()=>{this.eventsSdkClass.loggerClass.sdkConnectionSuccess()})}onDisconnect(t){this.connected=!1,this.doReconnect&&(this.closeAllConnections(),this.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?re.TRYING_TO_CONNECT:re.DISCONNECTED}),this.eventsSdkClass.loggerClass.sdkDisconnect([t]),this.keepReconnectTimeout=setTimeout(()=>{this.reconnectionTime=this.reconnectionTime+20,this.reconnectionTime>120&&(this.reconnectionTime=20),this.eventsSdkClass.connect(Z.NEXT)},this.reconnectionTime*1e3))}onConnectError(t){this.eventsSdkClass.eventEmitterClass.emit(j.ONLINE_STATUS_EVENT,{connectionStatus:this.doReconnect?re.TRYING_TO_CONNECT:re.DISCONNECTED}),this.eventsSdkClass.loggerClass.sdkAttemptToConnectError(t),this.keepReconnectTimeout=setTimeout(()=>{this.reconnectionTime=this.reconnectionTime+20,this.reconnectionTime>60&&(this.reconnectionTime=20),this.eventsSdkClass.connect(Z.NEXT)},this.reconnectionTime*1e3)}}class Ye{constructor(t){V(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 F({socket:t,loggerOptions:this.eventsSdkClass.options.loggerConfig}))}async start(){this.storageLogger&&await this.storageLogger.start()}stop(){this.storageLogger&&this.storageLogger.stop()}log(t){if(this.eventsSdkClass.options.useLogger)if(this.storageLogger)switch(t.Level){case F.LevelEnum.INFO:this.storageLogger.log(t);break;case F.LevelEnum.DEBUG:this.storageLogger.debug(t);break;case F.LevelEnum.WARNING:this.storageLogger.warn(t);break;case F.LevelEnum.ERROR:this.storageLogger.error(t)}else t.Level===F.LevelEnum.INFO?console.log(t):t.Level===F.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:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection established",StatusCode:200,Level:F.LevelEnum.INFO,LogType:F.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:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection closed",StatusCode:200,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}sdkAttemptToConnect(t){this.log({Message:`${this.eventsSdkClass.options.loggerConfig.system} is trying to connect to WS server ${t}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Switching Protocols",StatusCode:101,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}sdkAttemptToConnectError(t){this.log({Message:`${t}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Connection error",StatusCode:500,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}loginError(t,e,s,o){this.log({Message:`External login request error with the login type ${t} ${t===Q.TOKEN?s:o}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"External login error",StatusCode:e||400,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}getSettingsError(t,e){this.log({Message:`Get settings error with token ${t}, error: ${e}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}refreshTokenError(t,e,s){this.log({Message:`Refresh token error with old refresh token ${t}, url: ${e}, error: ${s}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Get settings error",StatusCode:400,Level:F.LevelEnum.ERROR,LogType:F.LogTypeEnum.ERROR})}keepAliveEmit(){this.log({Message:`Keep alive event emitted with this token: ${this.eventsSdkClass.authClass.token}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}keepAliveResponse(t){this.log({Message:`Keep alive response: ${JSON.stringify(t)}`,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",StatusCode:200,Level:F.LevelEnum.INFO,LogType:F.LogTypeEnum.INFO})}eventLog(t,e){const s={[ne.FULL]:[],[ne.BOOTSTRAP]:[j.LOGIN_STATUS,j.LOGIN_SUCCESS,j.ALL_EXTENSION_STATUS,j.ALL_DIALER_STATUS],[ne.DEBUG_EXTENSIONS]:[j.ALL_EXTENSION_STATUS,j.EXTENSION_EVENT,j.EXTENSIONS_UPDATED],[ne.DEBUG_DIALER]:[j.ALL_DIALER_STATUS,j.DIALER_EVENT],[ne.DEBUG_QUEUE]:[j.QUEUE_EVENT]};this.eventsSdkClass.options.debugOption&&(s[this.eventsSdkClass.options.debugOption].includes(t)||this.eventsSdkClass.options.debugOption===ne.FULL)&&this.log({Message:`Event name: ${t}`,Body:e,ActionName:F.ActionNameEnum.WSCONNECT,isShowClient:!1,Status:"Successful",Level:F.LevelEnum.DEBUG,LogType:F.LogTypeEnum.INFO})}}class Qe{constructor(t){V(this,"listeners",{[j.ALL_EXTENSION_STATUS]:[],[j.ALL_DIALER_STATUS]:[],[j.ALL_USERS_STATUS]:[],[j.QUEUE_EVENT]:[],[j.EXTENSION_EVENT]:[],[j.DIALER_EVENT]:[],[j.LOGIN_SUCCESS]:[],[j.LOGIN_STATUS]:[],[j.KEEP_ALIVE_RESPONSE]:[],[j.ONLINE_STATUS_EVENT]:[],[j.EXTENSIONS_UPDATED]:[]});V(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(s=>s!==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 s={name:t,data:e};this.allListeners.forEach(o=>o(s))}}class Ze{constructor(t){V(this,"options");V(this,"servers",[]);V(this,"URLList",[]);V(this,"server");V(this,"URL");V(this,"socket");V(this,"mainServer");V(this,"alreadyAttemptedOtherServers",[]);V(this,"authClass",new Ve(this));V(this,"socketIoClass",new He(this));V(this,"loggerClass",new Ye(this));V(this,"eventEmitterClass",new Qe(this));V(this,"getCircularReplacer",()=>{const t=new WeakSet;return(e,s)=>{if(!(e==="socket"||e==="io"||e==="nsps")){if(typeof s=="object"&&s!==null){if(t.has(s))return;t.add(s)}return s}}});this.options={...Ke,...t}}on(t,e){this.eventEmitterClass.on(t,e)}emit(t,...e){this.socketIoClass.io&&this.socketIoClass.io.emit(t,...e)}connect(t){t===Z.MAIN&&this.findMainServer(),t===Z.NEXT&&this.findNextServer(),this.socketIoClass.doReconnect=!0;try{this.loggerClass.start()}catch(e){console.error(e)}this.socketIoClass.initSocketConnection(),this.socketIoClass.initSocketEvents(),this.socketIoClass.initKeepAlive()}disconnect(){this.socketIoClass.doReconnect=!1,this.socketIoClass.closeAllConnections(),this.loggerClass.stop()}clearKeepAliveInterval(){this.socketIoClass.clearKeepAliveInterval()}findMainServer(){this.servers.length?(this.mainServer=this.servers.reduce((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,s)=>s.Priority>e.Priority?s: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}}return z.CallStatusEnum=Ne,z.CallTypeEnum=Le,z.ConnectionStatusEnum=re,z.DebugOption=ne,z.DialerTypeEnum=_e,z.DirectionEnum=Oe,z.DoNotCallMeStatusCodeEnum=Re,z.EventsEnum=j,z.ExtensionEventReasonEnum=pe,z.ExtensionHangupCauseEnum=Ie,z.LoginType=Q,z.QueueEventReasonEnum=xe,z.ServerListenerEventsEnum=fe,z.ServerParameter=Z,z.default=Ze,Object.defineProperties(z,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),z}({},ws,StorageLogger);
19
19
  //# sourceMappingURL=voicenter-events-sdk.iife.js.map