diff --git a/README.md b/README.md index 8f814533..5c037ec7 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ The SDK constructor accepts multiple options when initializing which can be used | Option | Type | Default | Description | |-----------|---------------|---------------|---------------| +| environment | String | browser | Could be 'browser'/'chrome_extension' | | token | String | Null | Monitor code token to use for login | | user | String | Can be used to login with "user" or "account" login type | | | password | String | Used for login with "user" or "account" login type. Must be used together with user property | | @@ -117,6 +118,11 @@ The SDK constructor accepts multiple options when initializing which can be used | store | object | Vuex store to use in order to register an extensions module. This should simplify the end usage of the SDK | | | extensionsModuleName | string | Vuex store extension module name. Defaults to `sdkExtensions` | | | queuesModuleName | string | Vuex store queue module name. Defaults to `sdkQueues` | | +| useLogger | boolean | `false` | Determines if the SDK will use logger +| loggerSocketConnection | socketIo | `null` | Socket connection which will be used by logger +| loggerServer | string | `http://127.0.0.1:3000/` | Server url which logger uses to send logs to +| loggerConfig | object | `{ logToConsole: true, overloadGlobalConsole: false, namespace: "events-sdk",socketEmitInterval: 10000}` | Logger options +| loggerConnectOptions | object | `{ reconnection: true, reconnectionDelay: 5000, reconnectionAttempts: 10, perMessageDeflate: false, upgrade: false, transports: ['websocket'], debug: false}` | Logger's socket connect options Servers array format ```js diff --git a/bili.config.js b/bili.config.js index 484a1a3a..ab48f862 100644 --- a/bili.config.js +++ b/bili.config.js @@ -1,12 +1,18 @@ +function getDistName (input) { + return input.includes('extension-sdk') ? 'ext-voicenter-events-sdk': 'voicenter-events-sdk' +} + module.exports = { - input: 'src/index.js', + input: ["src/versions/sdk.js", "src/versions/extension-sdk.js"], presets: ['bili/babel'], output: { format: ['esm', 'cjs', 'umd-min'], moduleName: 'VoicenterEventsSDK', - fileName({ format }) { - return `voicenter-events-sdk.${format}.js` - } + }, + extendRollupConfig: config => { + const distName = getDistName(config.inputConfig.input[0]) + config.outputConfig.entryFileNames = `${distName}.${config.outputConfig.format}.js` + return config }, externals: ['socket.io-client', 'socket.io-client/socket.io'], globals: { diff --git a/dist/ext-voicenter-events-sdk.cjs.js b/dist/ext-voicenter-events-sdk.cjs.js new file mode 100644 index 00000000..2c87afc3 --- /dev/null +++ b/dist/ext-voicenter-events-sdk.cjs.js @@ -0,0 +1,3695 @@ +'use strict'; + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var debounce = _interopDefault(require('lodash/debounce')); +var md5 = _interopDefault(require('js-md5')); +var AsyncStorageLogger = require('@voicenter-team/socketio-storage-logger/build/AsyncStorageLogger'); + +function _typeof(o) { + "@babel/helpers - typeof"; + + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, _typeof(o); +} +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); + } +} +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); + return Constructor; +} +function _defineProperty(obj, key, value) { + key = _toPropertyKey(key); + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); +} +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; +} +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} +function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); +} +function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + return typeof key === "symbol" ? key : String(key); +} + +var eventTypes = { + LOGIN_STATUS: 'loginStatus', + LOGIN: 'login', + LOGIN_USER: 'loginUser', + LOGIN_CODE: 'loginUserCode', + LOGIN_ACCOUNT: 'loginAccount', + LOGIN_RESPONSE: 'loginResponse', + QUEUE_EVENT: 'QueueEvent', + QUEUES_UPDATED: 'QueuesUpdated', + DIALERS_UPDATED: 'DialersUpdated', + EXTENSION_EVENT: 'ExtensionEvent', + EXTENSION_UPDATED: 'ExtensionsUpdated', + ALL_EXTENSION_STATUS: 'AllExtensionsStatus', + CONNECT: 'connect', + CONNECT_ERROR: 'connect_error', + CONNECT_TIMEOUT: 'connect_timeout', + DISCONNECT: 'disconnect', + PONG: 'pong', + RECONNECT: 'reconnect', + RECONNECT_ATTEMPT: 'reconnect_attempt', + RESYNC: 'resync', + RECONNECTING: 'reconnecting', + RECONNECT_ERROR: 'reconnect_error', + RECONNECT_FAILED: 'reconnect_failed', + KEEP_ALIVE: 'keepalive', + KEEP_ALIVE_RESPONSE: 'keepaliveResponse', + CLOSE: 'closeme', + ERROR: 'error', + ALL_DIALERS_STATUS: 'AllDialersStatus', + DIALER_EVENT: 'DialerEvent' +}; + +var environments = { + BROWSER: 'browser', + CHROME_EXTENSION: 'chrome-extension' +}; + +var defaultServers = [{ + 'URLID': 59, + 'Priority': 5, + 'Version': 2, + 'Domain': 'monitor1.voicenter.co' +}, { + 'URLID': 3, + 'Priority': 4, + 'Version': 2, + 'Domain': 'monitor3.voicenter.co.il' +}, { + 'URLID': 4, + 'Priority': 3, + 'Version': 2, + 'Domain': 'monitor4.voicenter.co.il' +}, { + 'URLID': 11, + 'Priority': 2, + 'Version': 2, + 'Domain': 'monitor11.voicenter.co' +}, { + 'URLID': 5, + 'Priority': 0, + 'Version': 2, + 'Domain': 'monitor5.voicenter.co.il' +}]; + +var sdkEventReasons = { + NEWCALL: 'NEWCALL', + ANSWER: 'ANSWER', + HANGUP: 'HANGUP' +}; +var offlineEvents = [eventTypes.CONNECT_ERROR, eventTypes.CONNECT_TIMEOUT, eventTypes.DISCONNECT, eventTypes.RECONNECT_ATTEMPT, eventTypes.RECONNECTING, eventTypes.RECONNECT_ERROR, eventTypes.RECONNECT_FAILED, sdkEventReasons.CLOSE]; +function isSocketOffline(event) { + var name = event.name; + return offlineEvents.includes(name); +} +function onNewEvent(_ref) { + var eventData = _ref.eventData, + store = _ref.store, + extensionsModuleName = _ref.extensionsModuleName, + queuesModuleName = _ref.queuesModuleName, + dialersModuleName = _ref.dialersModuleName; + var name = eventData.name, + data = eventData.data; + store.commit("".concat(extensionsModuleName, "/SET_IS_SOCKET_OFFLINE"), isSocketOffline(eventData)); + switch (name) { + case eventTypes.ALL_EXTENSION_STATUS: + store.dispatch("".concat(extensionsModuleName, "/setExtensions"), data.extensions); + break; + case eventTypes.EXTENSION_EVENT: + var extension = data.data; + // Event reason: NEWCALL/ANSWER/HANGUP + extension['lastEvent'] = { + reason: data.reason, + ivrid: data.ivruniqueid + }; + var extensions = store.state[extensionsModuleName].extensions; + var extensionIndex = extensions.findIndex(function (e) { + return e.userID === extension.userID; + }); + if (extensionIndex !== -1) { + store.dispatch("".concat(extensionsModuleName, "/updateExtension"), { + index: extensionIndex, + extension: extension + }); + } + break; + case eventTypes.LOGIN_STATUS: + store.commit("".concat(extensionsModuleName, "/SET_SERVER_TIME"), data); + store.dispatch("".concat(queuesModuleName, "/setQueues"), data.queues); + break; + case eventTypes.QUEUE_EVENT: + var queue = data.data; + var allQueues = store.state[queuesModuleName].all || []; + var queueIndex = allQueues.findIndex(function (e) { + return e.QueueID === queue.QueueID; + }); + if (queueIndex !== -1) { + store.dispatch("".concat(queuesModuleName, "/updateQueue"), { + index: queueIndex, + queue: queue + }); + } + break; + case eventTypes.ALL_DIALERS_STATUS: + store.dispatch("".concat(dialersModuleName, "/setDialers"), data.dialers); + break; + case eventTypes.DIALER_EVENT: + var dialer = data.data; + var allDialers = store.state[dialersModuleName].all || []; + var dialerIndex = allDialers.findIndex(function (e) { + return e.campaignID === dialer.campaignID; + }); + if (dialerIndex !== -1) { + store.dispatch("".concat(dialersModuleName, "/updateDialers"), { + index: dialerIndex, + dialer: dialer + }); + } + break; + } +} + +var callStatuses = { + CALLING: 100, + HOLD: 101 +}; + +var _mutations; +var ISRAEL_TIMEZONE_OFFSET = 180 * 60 * 1000; +var MINUTE = 60 * 1000; +var LOGOUT_STATUS = 2; +var HOLD_STATUS = 'hold'; +var types = { + SET_EXTENSIONS: 'SET_EXTENSIONS', + UPDATE_EXTENSIONS: 'UPDATE_EXTENSIONS', + SET_SERVER_TIME: 'SET_SERVER_TIME', + SET_IS_SOCKET_OFFLINE: 'SET_IS_SOCKET_OFFLINE' +}; +var state = { + extensions: [], + serverTime: null, + serverDelta: 0, + serverOffset: 0, + isSocketOffline: false, + offlineSocketTimestamp: null +}; +var mutations = (_mutations = {}, _defineProperty(_mutations, types.SET_EXTENSIONS, function (state, value) { + state.extensions = value; +}), _defineProperty(_mutations, types.UPDATE_EXTENSIONS, function (state, _ref) { + var index = _ref.index, + extension = _ref.extension; + state.extensions.splice(index, 1, extension); +}), _defineProperty(_mutations, types.SET_SERVER_TIME, function (state, value) { + state.serverOffset = value.servertimeoffset * 60 * 1000 || ISRAEL_TIMEZONE_OFFSET; + state.serverTime = value.servertime * 1000 - state.serverOffset; + state.serverDelta = new Date().getTime() - state.serverTime; +}), _defineProperty(_mutations, types.SET_IS_SOCKET_OFFLINE, function (state, value) { + state.isSocketOffline = value; + if (value) { + state.offlineSocketTimestamp = new Date().getTime(); + } else { + state.offlineSocketTimestamp = null; + } +}), _mutations); +var actions = { + setExtensions: async function setExtensions(_ref2, value) { + var commit = _ref2.commit; + commit(types.SET_EXTENSIONS, value); + }, + updateExtension: async function updateExtension(_ref3, value) { + var commit = _ref3.commit; + commit(types.UPDATE_EXTENSIONS, value); + } +}; +function isCallOnHold() { + var call = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var status = call.callstatus || ''; + status = status.toLowerCase(); + return call.answered && status === HOLD_STATUS; +} +var getters = { + isSocketOffline: function isSocketOffline(state) { + if (!state.offlineSocketTimestamp || isNaN(state.offlineSocketTimestamp)) { + return false; + } + var now = new Date().getTime(); + // show after 1 minute of disconnect + return state.isSocketOffline && now - state.offlineSocketTimestamp > MINUTE; + }, + extensionsWithCalls: function extensionsWithCalls(state) { + return function (hideLoggedOutUsers) { + var groupedExtensions = []; + state.extensions.forEach(function (extension) { + if (extension.calls.length > 0) { + if (extension.calls.filter(isCallOnHold).length) { + extension['representativeStatus'] = callStatuses.HOLD; + } else { + extension['representativeStatus'] = callStatuses.CALLING; + } + } + groupedExtensions.push(extension); + }); + if (hideLoggedOutUsers) { + return groupedExtensions.filter(function (e) { + return e.representativeStatus !== LOGOUT_STATUS; + }); + } + return groupedExtensions; + }; + }, + extensionCountByStatus: function extensionCountByStatus(state, getters) { + return function (status) { + return getters.extensionsWithCalls.filter(function (el) { + return el.representativeStatus === status; + }).length || 0; + }; + } +}; +var extensionsModule = { + namespaced: true, + state: state, + mutations: mutations, + actions: actions, + getters: getters +}; + +var _mutations$1; +var types$1 = { + SET_QUEUES: 'SET_QUEUES', + UPDATE_QUEUES: 'UPDATE_QUEUES' +}; +var state$1 = { + all: [] +}; +var mutations$1 = (_mutations$1 = {}, _defineProperty(_mutations$1, types$1.SET_QUEUES, function (state, value) { + state.all = value; +}), _defineProperty(_mutations$1, types$1.UPDATE_QUEUES, function (state, _ref) { + var index = _ref.index, + queue = _ref.queue; + state.all.splice(index, 1, queue); +}), _mutations$1); +var actions$1 = { + setQueues: async function setQueues(_ref2, value) { + var commit = _ref2.commit; + commit(types$1.SET_QUEUES, value); + }, + updateQueue: async function updateQueue(_ref3, value) { + var commit = _ref3.commit; + commit(types$1.UPDATE_QUEUES, value); + } +}; +var getters$1 = { + queueWithActiveCalls: function queueWithActiveCalls(state) { + return state.all.filter(function (el) { + return el.Calls.length; + }); + }, + allQueueCalls: function allQueueCalls(state, getters) { + var allCalls = []; + getters.queueWithActiveCalls.forEach(function (queue) { + var calls = queue.Calls || []; + allCalls.push.apply(allCalls, _toConsumableArray(calls)); + }); + return allCalls; + }, + filterQueuesByIds: function filterQueuesByIds(state) { + return function (queueIds) { + if (!queueIds || !Array.isArray(queueIds)) { + return state.all; + } + return state.all.filter(function (e) { + return queueIds.includes(e.QueueID); + }); + }; + } +}; +var queuesModule = { + namespaced: true, + state: state$1, + mutations: mutations$1, + actions: actions$1, + getters: getters$1 +}; + +var _mutations$2; +var types$2 = { + SET_DIALERS: 'SET_DIALERS', + UPDATE_DIALERS: 'UPDATE_DIALERS' +}; +var state$2 = { + all: [] +}; +var mutations$2 = (_mutations$2 = {}, _defineProperty(_mutations$2, types$2.SET_DIALERS, function (state, value) { + state.all = value; +}), _defineProperty(_mutations$2, types$2.UPDATE_DIALERS, function (state, _ref) { + var index = _ref.index, + dialer = _ref.dialer; + state.all.splice(index, 1, dialer); +}), _mutations$2); +var actions$2 = { + setDialers: async function setDialers(_ref2, value) { + var commit = _ref2.commit; + commit(types$2.SET_DIALERS, value); + }, + updateDialers: async function updateDialers(_ref3, value) { + var commit = _ref3.commit; + commit(types$2.UPDATE_DIALERS, value); + } +}; +var getters$2 = { + getAllDialers: function getAllDialers(state) { + return state.all; + }, + getAllDialersWithTypeIVR: function getAllDialersWithTypeIVR(state) { + return state.all.filter(function (el) { + return el.type === 'IVR'; + }); + }, + getAllDialersWithTypeAUTOMATIC: function getAllDialersWithTypeAUTOMATIC(state) { + return state.all.filter(function (el) { + return el.type === 'Automatic'; + }); + } +}; +var dialersModule = { + namespaced: true, + state: state$2, + mutations: mutations$2, + actions: actions$2, + getters: getters$2 +}; + +function getServerWithHighestPriority(servers) { + // Highest priority server is the one with lowest Priority value + var chosenServer = null; + var maxPriority = Number.MAX_SAFE_INTEGER; + servers.forEach(function (server) { + if (server.Priority < maxPriority) { + maxPriority = server.Priority; + chosenServer = server; + } + }); + return chosenServer; +} +function isValidDate(date) { + return !isNaN(date.getTime()); +} + +async function externalLogin(url, _ref) { + var email = _ref.email, + password = _ref.password, + token = _ref.token, + username = _ref.username; + var body = null; + if (token) { + body = JSON.stringify({ + token: token + }); + } else if (username) { + body = JSON.stringify({ + username: username, + password: password + }); + } else { + body = JSON.stringify({ + email: email, + pin: password + }); + } + var res = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: body + }); + var data = await res.json(); + if (data.error) { + throw new Error(data.error); + } + return data.Data.Socket; +} +function getExternalLoginUrl(baseUrl, loginType) { + if (loginType === 'user') { + return "".concat(baseUrl, "/User"); + } else if (loginType === 'token') { + return "".concat(baseUrl, "/Token"); + } else if (loginType === 'account') { + return "".concat(baseUrl, "/Account"); + } + return baseUrl; +} +async function refreshToken(url, oldRefreshToken) { + var res = await fetch(url, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'Authorization': "Bearer ".concat(oldRefreshToken) + } + }); + return res.json(); +} + +/* eslint-disable */ +function s1_3_7 () { + return function e(t, n, r) { + function o(s, a) { + if (!n[s]) { + if (!t[s]) { + var c = "function" == typeof require && require; + if (!a && c) return c(s, !0); + if (i) return i(s, !0); + throw new Error("Cannot find module '" + s + "'"); + } + var p = n[s] = { + exports: {} + }; + t[s][0].call(p.exports, function (e) { + var n = t[s][1][e]; + return o(n ? n : e); + }, p, p.exports, e, t, n, r); + } + return n[s].exports; + } + for (var i = "function" == typeof require && require, s = 0; s < r.length; s++) o(r[s]); + return o; + }({ + 1: [function (t, e) { + e.exports = t("./lib/"); + }, { + "./lib/": 2 + }], + 2: [function (t, e, n) { + function r(t, e) { + "object" == _typeof(t) && (e = t, t = void 0), e = e || {}; + var n, + r = o(t), + i = r.source, + p = r.id; + return e.forceNew || e["force new connection"] || !1 === e.multiplex ? (a("ignoring socket cache for %s", i), n = s(i, e)) : (c[p] || (a("new io instance for %s", i), c[p] = s(i, e)), n = c[p]), n.socket(r.path); + } + var o = t("./url"), + i = t("socket.io-parser"), + s = t("./manager"), + a = t("debug")("socket.io-client"); + e.exports = n = r; + var c = n.managers = {}; + n.protocol = i.protocol, n.connect = r, n.Manager = t("./manager"), n.Socket = t("./socket"); + }, { + "./manager": 3, + "./socket": 5, + "./url": 6, + debug: 10, + "socket.io-parser": 44 + }], + 3: [function (t, e) { + function n(t, e) { + return this instanceof n ? (t && "object" == _typeof(t) && (e = t, t = void 0), e = e || {}, e.path = e.path || "/socket.io", this.nsps = {}, this.subs = [], this.opts = e, this.reconnection(e.reconnection !== !1), this.reconnectionAttempts(e.reconnectionAttempts || 1 / 0), this.reconnectionDelay(e.reconnectionDelay || 1e3), this.reconnectionDelayMax(e.reconnectionDelayMax || 5e3), this.randomizationFactor(e.randomizationFactor || .5), this.backoff = new f({ + min: this.reconnectionDelay(), + max: this.reconnectionDelayMax(), + jitter: this.randomizationFactor() + }), this.timeout(null == e.timeout ? 2e4 : e.timeout), this.readyState = "closed", this.uri = t, this.connected = [], this.encoding = !1, this.packetBuffer = [], this.encoder = new s.Encoder(), this.decoder = new s.Decoder(), this.autoConnect = e.autoConnect !== !1, void (this.autoConnect && this.open())) : new n(t, e); + } + var r = (t("./url"), t("engine.io-client")), + o = t("./socket"), + i = t("component-emitter"), + s = t("socket.io-parser"), + a = t("./on"), + c = t("component-bind"), + p = (t("object-component"), t("debug")("socket.io-client:manager")), + u = t("indexof"), + f = t("backo2"); + e.exports = n, n.prototype.emitAll = function () { + this.emit.apply(this, arguments); + for (var t in this.nsps) this.nsps[t].emit.apply(this.nsps[t], arguments); + }, n.prototype.updateSocketIds = function () { + for (var t in this.nsps) this.nsps[t].id = this.engine.id; + }, i(n.prototype), n.prototype.reconnection = function (t) { + return arguments.length ? (this._reconnection = !!t, this) : this._reconnection; + }, n.prototype.reconnectionAttempts = function (t) { + return arguments.length ? (this._reconnectionAttempts = t, this) : this._reconnectionAttempts; + }, n.prototype.reconnectionDelay = function (t) { + return arguments.length ? (this._reconnectionDelay = t, this.backoff && this.backoff.setMin(t), this) : this._reconnectionDelay; + }, n.prototype.randomizationFactor = function (t) { + return arguments.length ? (this._randomizationFactor = t, this.backoff && this.backoff.setJitter(t), this) : this._randomizationFactor; + }, n.prototype.reconnectionDelayMax = function (t) { + return arguments.length ? (this._reconnectionDelayMax = t, this.backoff && this.backoff.setMax(t), this) : this._reconnectionDelayMax; + }, n.prototype.timeout = function (t) { + return arguments.length ? (this._timeout = t, this) : this._timeout; + }, n.prototype.maybeReconnectOnOpen = function () { + !this.reconnecting && this._reconnection && 0 === this.backoff.attempts && this.reconnect(); + }, n.prototype.open = n.prototype.connect = function (t) { + if (p("readyState %s", this.readyState), ~this.readyState.indexOf("open")) return this; + p("opening %s", this.uri), this.engine = r(this.uri, this.opts); + var e = this.engine, + n = this; + this.readyState = "opening", this.skipReconnect = !1; + var o = a(e, "open", function () { + n.onopen(), t && t(); + }), + i = a(e, "error", function (e) { + if (p("connect_error"), n.cleanup(), n.readyState = "closed", n.emitAll("connect_error", e), t) { + var r = new Error("Connection error"); + r.data = e, t(r); + } else n.maybeReconnectOnOpen(); + }); + if (!1 !== this._timeout) { + var s = this._timeout; + p("connect attempt will timeout after %d", s); + var c = setTimeout(function () { + p("connect attempt timed out after %d", s), o.destroy(), e.close(), e.emit("error", "timeout"), n.emitAll("connect_timeout", s); + }, s); + this.subs.push({ + destroy: function destroy() { + clearTimeout(c); + } + }); + } + return this.subs.push(o), this.subs.push(i), this; + }, n.prototype.onopen = function () { + p("open"), this.cleanup(), this.readyState = "open", this.emit("open"); + var t = this.engine; + this.subs.push(a(t, "data", c(this, "ondata"))), this.subs.push(a(this.decoder, "decoded", c(this, "ondecoded"))), this.subs.push(a(t, "error", c(this, "onerror"))), this.subs.push(a(t, "close", c(this, "onclose"))); + }, n.prototype.ondata = function (t) { + this.decoder.add(t); + }, n.prototype.ondecoded = function (t) { + this.emit("packet", t); + }, n.prototype.onerror = function (t) { + p("error", t), this.emitAll("error", t); + }, n.prototype.socket = function (t) { + var e = this.nsps[t]; + if (!e) { + e = new o(this, t), this.nsps[t] = e; + var n = this; + e.on("connect", function () { + e.id = n.engine.id, ~u(n.connected, e) || n.connected.push(e); + }); + } + return e; + }, n.prototype.destroy = function (t) { + var e = u(this.connected, t); + ~e && this.connected.splice(e, 1), this.connected.length || this.close(); + }, n.prototype.packet = function (t) { + p("writing packet %j", t); + var e = this; + e.encoding ? e.packetBuffer.push(t) : (e.encoding = !0, this.encoder.encode(t, function (t) { + for (var n = 0; n < t.length; n++) e.engine.write(t[n]); + e.encoding = !1, e.processPacketQueue(); + })); + }, n.prototype.processPacketQueue = function () { + if (this.packetBuffer.length > 0 && !this.encoding) { + var t = this.packetBuffer.shift(); + this.packet(t); + } + }, n.prototype.cleanup = function () { + for (var t; t = this.subs.shift();) t.destroy(); + this.packetBuffer = [], this.encoding = !1, this.decoder.destroy(); + }, n.prototype.close = n.prototype.disconnect = function () { + this.skipReconnect = !0, this.backoff.reset(), this.readyState = "closed", this.engine && this.engine.close(); + }, n.prototype.onclose = function (t) { + p("close"), this.cleanup(), this.backoff.reset(), this.readyState = "closed", this.emit("close", t), this._reconnection && !this.skipReconnect && this.reconnect(); + }, n.prototype.reconnect = function () { + if (this.reconnecting || this.skipReconnect) return this; + var t = this; + if (this.backoff.attempts >= this._reconnectionAttempts) p("reconnect failed"), this.backoff.reset(), this.emitAll("reconnect_failed"), this.reconnecting = !1;else { + var e = this.backoff.duration(); + p("will wait %dms before reconnect attempt", e), this.reconnecting = !0; + var n = setTimeout(function () { + t.skipReconnect || (p("attempting reconnect"), t.emitAll("reconnect_attempt", t.backoff.attempts), t.emitAll("reconnecting", t.backoff.attempts), t.skipReconnect || t.open(function (e) { + e ? (p("reconnect attempt error"), t.reconnecting = !1, t.reconnect(), t.emitAll("reconnect_error", e.data)) : (p("reconnect success"), t.onreconnect()); + })); + }, e); + this.subs.push({ + destroy: function destroy() { + clearTimeout(n); + } + }); + } + }, n.prototype.onreconnect = function () { + var t = this.backoff.attempts; + this.reconnecting = !1, this.backoff.reset(), this.updateSocketIds(), this.emitAll("reconnect", t); + }; + }, { + "./on": 4, + "./socket": 5, + "./url": 6, + backo2: 7, + "component-bind": 8, + "component-emitter": 9, + debug: 10, + "engine.io-client": 11, + indexof: 40, + "object-component": 41, + "socket.io-parser": 44 + }], + 4: [function (t, e) { + function n(t, e, n) { + return t.on(e, n), { + destroy: function destroy() { + t.removeListener(e, n); + } + }; + } + e.exports = n; + }, {}], + 5: [function (t, e, n) { + function r(t, e) { + this.io = t, this.nsp = e, this.json = this, this.ids = 0, this.acks = {}, this.io.autoConnect && this.open(), this.receiveBuffer = [], this.sendBuffer = [], this.connected = !1, this.disconnected = !0; + } + var o = t("socket.io-parser"), + i = t("component-emitter"), + s = t("to-array"), + a = t("./on"), + c = t("component-bind"), + p = t("debug")("socket.io-client:socket"), + u = t("has-binary"); + e.exports = n = r; + var f = { + 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 + }, + h = i.prototype.emit; + i(r.prototype), r.prototype.subEvents = function () { + if (!this.subs) { + var t = this.io; + this.subs = [a(t, "open", c(this, "onopen")), a(t, "packet", c(this, "onpacket")), a(t, "close", c(this, "onclose"))]; + } + }, r.prototype.open = r.prototype.connect = function () { + return this.connected ? this : (this.subEvents(), this.io.open(), "open" == this.io.readyState && this.onopen(), this); + }, r.prototype.send = function () { + var t = s(arguments); + return t.unshift("message"), this.emit.apply(this, t), this; + }, r.prototype.emit = function (t) { + if (f.hasOwnProperty(t)) return h.apply(this, arguments), this; + var e = s(arguments), + n = o.EVENT; + u(e) && (n = o.BINARY_EVENT); + var r = { + type: n, + data: e + }; + return "function" == typeof e[e.length - 1] && (p("emitting packet with ack id %d", this.ids), this.acks[this.ids] = e.pop(), r.id = this.ids++), this.connected ? this.packet(r) : this.sendBuffer.push(r), this; + }, r.prototype.packet = function (t) { + t.nsp = this.nsp, this.io.packet(t); + }, r.prototype.onopen = function () { + p("transport is open - connecting"), "/" != this.nsp && this.packet({ + type: o.CONNECT + }); + }, r.prototype.onclose = function (t) { + p("close (%s)", t), this.connected = !1, this.disconnected = !0, delete this.id, this.emit("disconnect", t); + }, r.prototype.onpacket = function (t) { + if (t.nsp == this.nsp) switch (t.type) { + case o.CONNECT: + this.onconnect(); + break; + case o.EVENT: + this.onevent(t); + break; + case o.BINARY_EVENT: + this.onevent(t); + break; + case o.ACK: + this.onack(t); + break; + case o.BINARY_ACK: + this.onack(t); + break; + case o.DISCONNECT: + this.ondisconnect(); + break; + case o.ERROR: + this.emit("error", t.data); + } + }, r.prototype.onevent = function (t) { + var e = t.data || []; + p("emitting event %j", e), null != t.id && (p("attaching ack callback to event"), e.push(this.ack(t.id))), this.connected ? h.apply(this, e) : this.receiveBuffer.push(e); + }, r.prototype.ack = function (t) { + var e = this, + n = !1; + return function () { + if (!n) { + n = !0; + var r = s(arguments); + p("sending ack %j", r); + var i = u(r) ? o.BINARY_ACK : o.ACK; + e.packet({ + type: i, + id: t, + data: r + }); + } + }; + }, r.prototype.onack = function (t) { + p("calling ack %s with %j", t.id, t.data); + var e = this.acks[t.id]; + e.apply(this, t.data), delete this.acks[t.id]; + }, r.prototype.onconnect = function () { + this.connected = !0, this.disconnected = !1, this.emit("connect"), this.emitBuffered(); + }, r.prototype.emitBuffered = function () { + var t; + for (t = 0; t < this.receiveBuffer.length; t++) h.apply(this, this.receiveBuffer[t]); + for (this.receiveBuffer = [], t = 0; t < this.sendBuffer.length; t++) this.packet(this.sendBuffer[t]); + this.sendBuffer = []; + }, r.prototype.ondisconnect = function () { + p("server disconnect (%s)", this.nsp), this.destroy(), this.onclose("io server disconnect"); + }, r.prototype.destroy = function () { + if (this.subs) { + for (var t = 0; t < this.subs.length; t++) this.subs[t].destroy(); + this.subs = null; + } + this.io.destroy(this); + }, r.prototype.close = r.prototype.disconnect = function () { + return this.connected && (p("performing disconnect (%s)", this.nsp), this.packet({ + type: o.DISCONNECT + })), this.destroy(), this.connected && this.onclose("io client disconnect"), this; + }; + }, { + "./on": 4, + "component-bind": 8, + "component-emitter": 9, + debug: 10, + "has-binary": 36, + "socket.io-parser": 44, + "to-array": 48 + }], + 6: [function (t, e) { + (function (n) { + function r(t, e) { + var r = t, + e = e || n.location; + return null == t && (t = e.protocol + "//" + e.host), "string" == typeof t && ("/" == t.charAt(0) && (t = "/" == t.charAt(1) ? e.protocol + t : e.hostname + t), /^(https?|wss?):\/\//.test(t) || (i("protocol-less url %s", t), t = "undefined" != typeof e ? e.protocol + "//" + t : "https://" + t), i("parse %s", t), r = o(t)), r.port || (/^(http|ws)$/.test(r.protocol) ? r.port = "80" : /^(http|ws)s$/.test(r.protocol) && (r.port = "443")), r.path = r.path || "/", r.id = r.protocol + "://" + r.host + ":" + r.port, r.href = r.protocol + "://" + r.host + (e && e.port == r.port ? "" : ":" + r.port), r; + } + var o = t("parseuri"), + i = t("debug")("socket.io-client:url"); + e.exports = r; + }).call(this, "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}); + }, { + debug: 10, + parseuri: 42 + }], + 7: [function (t, e) { + function n(t) { + t = t || {}, this.ms = t.min || 100, this.max = t.max || 1e4, this.factor = t.factor || 2, this.jitter = t.jitter > 0 && t.jitter <= 1 ? t.jitter : 0, this.attempts = 0; + } + e.exports = n, n.prototype.duration = function () { + var t = this.ms * Math.pow(this.factor, this.attempts++); + if (this.jitter) { + var e = Math.random(), + n = Math.floor(e * this.jitter * t); + t = 0 == (1 & Math.floor(10 * e)) ? t - n : t + n; + } + return 0 | Math.min(t, this.max); + }, n.prototype.reset = function () { + this.attempts = 0; + }, n.prototype.setMin = function (t) { + this.ms = t; + }, n.prototype.setMax = function (t) { + this.max = t; + }, n.prototype.setJitter = function (t) { + this.jitter = t; + }; + }, {}], + 8: [function (t, e) { + var n = [].slice; + e.exports = function (t, e) { + if ("string" == typeof e && (e = t[e]), "function" != typeof e) throw new Error("bind() requires a function"); + var r = n.call(arguments, 2); + return function () { + return e.apply(t, r.concat(n.call(arguments))); + }; + }; + }, {}], + 9: [function (t, e) { + function n(t) { + return t ? r(t) : void 0; + } + function r(t) { + for (var e in n.prototype) t[e] = n.prototype[e]; + return t; + } + e.exports = n, n.prototype.on = n.prototype.addEventListener = function (t, e) { + return this._callbacks = this._callbacks || {}, (this._callbacks[t] = this._callbacks[t] || []).push(e), this; + }, n.prototype.once = function (t, e) { + function n() { + r.off(t, n), e.apply(this, arguments); + } + var r = this; + return this._callbacks = this._callbacks || {}, n.fn = e, this.on(t, n), this; + }, n.prototype.off = n.prototype.removeListener = n.prototype.removeAllListeners = n.prototype.removeEventListener = function (t, e) { + if (this._callbacks = this._callbacks || {}, 0 == arguments.length) return this._callbacks = {}, this; + var n = this._callbacks[t]; + if (!n) return this; + if (1 == arguments.length) return delete this._callbacks[t], this; + for (var r, o = 0; o < n.length; o++) if (r = n[o], r === e || r.fn === e) { + n.splice(o, 1); + break; + } + return this; + }, n.prototype.emit = function (t) { + this._callbacks = this._callbacks || {}; + var e = [].slice.call(arguments, 1), + n = this._callbacks[t]; + if (n) { + n = n.slice(0); + for (var r = 0, o = n.length; o > r; ++r) n[r].apply(this, e); + } + return this; + }, n.prototype.listeners = function (t) { + return this._callbacks = this._callbacks || {}, this._callbacks[t] || []; + }, n.prototype.hasListeners = function (t) { + return !!this.listeners(t).length; + }; + }, {}], + 10: [function (t, e) { + function n(t) { + return n.enabled(t) ? function (e) { + e = r(e); + var o = new Date(), + i = o - (n[t] || o); + n[t] = o, e = t + " " + e + " +" + n.humanize(i), window.console && console.log && Function.prototype.apply.call(console.log, console, arguments); + } : function () {}; + } + function r(t) { + return t instanceof Error ? t.stack || t.message : t; + } + e.exports = n, n.names = [], n.skips = [], n.enable = function (t) { + try { + localStorage.debug = t; + } catch (e) {} + for (var r = (t || "").split(/[\s,]+/), o = r.length, i = 0; o > i; i++) t = r[i].replace("*", ".*?"), "-" === t[0] ? n.skips.push(new RegExp("^" + t.substr(1) + "$")) : n.names.push(new RegExp("^" + t + "$")); + }, n.disable = function () { + n.enable(""); + }, n.humanize = function (t) { + var e = 1e3, + n = 6e4, + r = 60 * n; + return t >= r ? (t / r).toFixed(1) + "h" : t >= n ? (t / n).toFixed(1) + "m" : t >= e ? (t / e | 0) + "s" : t + "ms"; + }, n.enabled = function (t) { + for (var e = 0, r = n.skips.length; r > e; e++) if (n.skips[e].test(t)) return !1; + for (var e = 0, r = n.names.length; r > e; e++) if (n.names[e].test(t)) return !0; + return !1; + }; + try { + window.localStorage && n.enable(localStorage.debug); + } catch (o) {} + }, {}], + 11: [function (t, e) { + e.exports = t("./lib/"); + }, { + "./lib/": 12 + }], + 12: [function (t, e) { + e.exports = t("./socket"), e.exports.parser = t("engine.io-parser"); + }, { + "./socket": 13, + "engine.io-parser": 25 + }], + 13: [function (t, e) { + (function (n) { + function r(t, e) { + if (!(this instanceof r)) return new r(t, e); + if (e = e || {}, t && "object" == _typeof(t) && (e = t, t = null), t && (t = u(t), e.host = t.host, e.secure = "https" == t.protocol || "wss" == t.protocol, e.port = t.port, t.query && (e.query = t.query)), this.secure = null != e.secure ? e.secure : n.location && "https:" == location.protocol, e.host) { + var o = e.host.split(":"); + e.hostname = o.shift(), o.length ? e.port = o.pop() : e.port || (e.port = this.secure ? "443" : "80"); + } + this.agent = e.agent || !1, this.hostname = e.hostname || (n.location ? location.hostname : "localhost"), this.port = e.port || (n.location && location.port ? location.port : this.secure ? 443 : 80), this.query = e.query || {}, "string" == typeof this.query && (this.query = h.decode(this.query)), this.upgrade = !1 !== e.upgrade, this.path = (e.path || "/engine.io").replace(/\/$/, "") + "/", this.forceJSONP = !!e.forceJSONP, this.jsonp = !1 !== e.jsonp, this.forceBase64 = !!e.forceBase64, this.enablesXDR = !!e.enablesXDR, this.timestampParam = e.timestampParam || "t", this.timestampRequests = e.timestampRequests, this.transports = e.transports || ["polling", "websocket"], this.readyState = "", this.writeBuffer = [], this.callbackBuffer = [], this.policyPort = e.policyPort || 843, this.rememberUpgrade = e.rememberUpgrade || !1, this.binaryType = null, this.onlyBinaryUpgrades = e.onlyBinaryUpgrades, this.pfx = e.pfx || null, this.key = e.key || null, this.passphrase = e.passphrase || null, this.cert = e.cert || null, this.ca = e.ca || null, this.ciphers = e.ciphers || null, this.rejectUnauthorized = e.rejectUnauthorized || null, this.open(); + } + function o(t) { + var e = {}; + for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]); + return e; + } + var i = t("./transports"), + s = t("component-emitter"), + a = t("debug")("engine.io-client:socket"), + c = t("indexof"), + p = t("engine.io-parser"), + u = t("parseuri"), + f = t("parsejson"), + h = t("parseqs"); + e.exports = r, r.priorWebsocketSuccess = !1, s(r.prototype), r.protocol = p.protocol, r.Socket = r, r.Transport = t("./transport"), r.transports = t("./transports"), r.parser = t("engine.io-parser"), r.prototype.createTransport = function (t) { + a('creating transport "%s"', t); + var e = o(this.query); + e.EIO = p.protocol, e.transport = t, this.id && (e.sid = this.id); + var n = new i[t]({ + agent: this.agent, + hostname: this.hostname, + port: this.port, + secure: this.secure, + path: this.path, + query: e, + 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 n; + }, r.prototype.open = function () { + var t; + if (this.rememberUpgrade && r.priorWebsocketSuccess && -1 != this.transports.indexOf("websocket")) t = "websocket";else { + if (0 == this.transports.length) { + var e = this; + return void setTimeout(function () { + e.emit("error", "No transports available"); + }, 0); + } + t = this.transports[0]; + } + this.readyState = "opening"; + var t; + try { + t = this.createTransport(t); + } catch (n) { + return this.transports.shift(), void this.open(); + } + t.open(), this.setTransport(t); + }, r.prototype.setTransport = function (t) { + a("setting transport %s", t.name); + var e = this; + this.transport && (a("clearing existing transport %s", this.transport.name), this.transport.removeAllListeners()), this.transport = t, t.on("drain", function () { + e.onDrain(); + }).on("packet", function (t) { + e.onPacket(t); + }).on("error", function (t) { + e.onError(t); + }).on("close", function () { + e.onClose("transport close"); + }); + }, r.prototype.probe = function (t) { + function e() { + if (h.onlyBinaryUpgrades) { + var e = !this.supportsBinary && h.transport.supportsBinary; + f = f || e; + } + f || (a('probe transport "%s" opened', t), u.send([{ + type: "ping", + data: "probe" + }]), u.once("packet", function (e) { + if (!f) if ("pong" == e.type && "probe" == e.data) { + if (a('probe transport "%s" pong', t), h.upgrading = !0, h.emit("upgrading", u), !u) return; + r.priorWebsocketSuccess = "websocket" == u.name, a('pausing current transport "%s"', h.transport.name), h.transport.pause(function () { + f || "closed" != h.readyState && (a("changing transport and sending upgrade packet"), p(), h.setTransport(u), u.send([{ + type: "upgrade" + }]), h.emit("upgrade", u), u = null, h.upgrading = !1, h.flush()); + }); + } else { + a('probe transport "%s" failed', t); + var n = new Error("probe error"); + n.transport = u.name, h.emit("upgradeError", n); + } + })); + } + function n() { + f || (f = !0, p(), u.close(), u = null); + } + function o(e) { + var r = new Error("probe error: " + e); + r.transport = u.name, n(), a('probe transport "%s" failed because of error: %s', t, e), h.emit("upgradeError", r); + } + function i() { + o("transport closed"); + } + function s() { + o("socket closed"); + } + function c(t) { + u && t.name != u.name && (a('"%s" works - aborting "%s"', t.name, u.name), n()); + } + function p() { + u.removeListener("open", e), u.removeListener("error", o), u.removeListener("close", i), h.removeListener("close", s), h.removeListener("upgrading", c); + } + a('probing transport "%s"', t); + var u = this.createTransport(t, { + probe: 1 + }), + f = !1, + h = this; + r.priorWebsocketSuccess = !1, u.once("open", e), u.once("error", o), u.once("close", i), this.once("close", s), this.once("upgrading", c), u.open(); + }, r.prototype.onOpen = function () { + if (a("socket open"), this.readyState = "open", r.priorWebsocketSuccess = "websocket" == this.transport.name, this.emit("open"), this.flush(), "open" == this.readyState && this.upgrade && this.transport.pause) { + a("starting upgrade probes"); + for (var t = 0, e = this.upgrades.length; e > t; t++) this.probe(this.upgrades[t]); + } + }, r.prototype.onPacket = function (t) { + if ("opening" == this.readyState || "open" == this.readyState) switch (a('socket receive: type "%s", data "%s"', t.type, t.data), this.emit("packet", t), this.emit("heartbeat"), t.type) { + case "open": + this.onHandshake(f(t.data)); + break; + case "pong": + this.setPing(); + break; + case "error": + var e = new Error("server error"); + e.code = t.data, this.emit("error", e); + break; + case "message": + this.emit("data", t.data), this.emit("message", t.data); + } else a('packet received with socket readyState "%s"', this.readyState); + }, r.prototype.onHandshake = function (t) { + this.emit("handshake", t), this.id = t.sid, this.transport.query.sid = t.sid, this.upgrades = this.filterUpgrades(t.upgrades), this.pingInterval = t.pingInterval, this.pingTimeout = t.pingTimeout, this.onOpen(), "closed" != this.readyState && (this.setPing(), this.removeListener("heartbeat", this.onHeartbeat), this.on("heartbeat", this.onHeartbeat)); + }, r.prototype.onHeartbeat = function (t) { + clearTimeout(this.pingTimeoutTimer); + var e = this; + e.pingTimeoutTimer = setTimeout(function () { + "closed" != e.readyState && e.onClose("ping timeout"); + }, t || e.pingInterval + e.pingTimeout); + }, r.prototype.setPing = function () { + var t = this; + clearTimeout(t.pingIntervalTimer), t.pingIntervalTimer = setTimeout(function () { + a("writing ping packet - expecting pong within %sms", t.pingTimeout), t.ping(), t.onHeartbeat(t.pingTimeout); + }, t.pingInterval); + }, r.prototype.ping = function () { + this.sendPacket("ping"); + }, r.prototype.onDrain = function () { + for (var t = 0; t < this.prevBufferLen; t++) this.callbackBuffer[t] && this.callbackBuffer[t](); + this.writeBuffer.splice(0, this.prevBufferLen), this.callbackBuffer.splice(0, this.prevBufferLen), this.prevBufferLen = 0, 0 == this.writeBuffer.length ? this.emit("drain") : this.flush(); + }, r.prototype.flush = function () { + "closed" != this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length && (a("flushing %d packets in socket", this.writeBuffer.length), this.transport.send(this.writeBuffer), this.prevBufferLen = this.writeBuffer.length, this.emit("flush")); + }, r.prototype.write = r.prototype.send = function (t, e) { + return this.sendPacket("message", t, e), this; + }, r.prototype.sendPacket = function (t, e, n) { + if ("closing" != this.readyState && "closed" != this.readyState) { + var r = { + type: t, + data: e + }; + this.emit("packetCreate", r), this.writeBuffer.push(r), this.callbackBuffer.push(n), this.flush(); + } + }, r.prototype.close = function () { + function t() { + r.onClose("forced close"), a("socket closing - telling transport to close"), r.transport.close(); + } + function e() { + r.removeListener("upgrade", e), r.removeListener("upgradeError", e), t(); + } + function n() { + r.once("upgrade", e), r.once("upgradeError", e); + } + if ("opening" == this.readyState || "open" == this.readyState) { + this.readyState = "closing"; + var r = this; + this.writeBuffer.length ? this.once("drain", function () { + this.upgrading ? n() : t(); + }) : this.upgrading ? n() : t(); + } + return this; + }, r.prototype.onError = function (t) { + a("socket error %j", t), r.priorWebsocketSuccess = !1, this.emit("error", t), this.onClose("transport error", t); + }, r.prototype.onClose = function (t, e) { + if ("opening" == this.readyState || "open" == this.readyState || "closing" == this.readyState) { + a('socket close with reason: "%s"', t); + var n = this; + clearTimeout(this.pingIntervalTimer), clearTimeout(this.pingTimeoutTimer), setTimeout(function () { + n.writeBuffer = [], n.callbackBuffer = [], n.prevBufferLen = 0; + }, 0), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), this.readyState = "closed", this.id = null, this.emit("close", t, e); + } + }, r.prototype.filterUpgrades = function (t) { + for (var e = [], n = 0, r = t.length; r > n; n++) ~c(this.transports, t[n]) && e.push(t[n]); + return e; + }; + }).call(this, "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}); + }, { + "./transport": 14, + "./transports": 15, + "component-emitter": 9, + debug: 22, + "engine.io-parser": 25, + indexof: 40, + parsejson: 32, + parseqs: 33, + parseuri: 34 + }], + 14: [function (t, e) { + function n(t) { + this.path = t.path, this.hostname = t.hostname, this.port = t.port, this.secure = t.secure, this.query = t.query, this.timestampParam = t.timestampParam, this.timestampRequests = t.timestampRequests, this.readyState = "", this.agent = t.agent || !1, this.socket = t.socket, this.enablesXDR = t.enablesXDR, this.pfx = t.pfx, this.key = t.key, this.passphrase = t.passphrase, this.cert = t.cert, this.ca = t.ca, this.ciphers = t.ciphers, this.rejectUnauthorized = t.rejectUnauthorized; + } + var r = t("engine.io-parser"), + o = t("component-emitter"); + e.exports = n, o(n.prototype), n.timestamps = 0, n.prototype.onError = function (t, e) { + var n = new Error(t); + return n.type = "TransportError", n.description = e, this.emit("error", n), this; + }, n.prototype.open = function () { + return ("closed" == this.readyState || "" == this.readyState) && (this.readyState = "opening", this.doOpen()), this; + }, n.prototype.close = function () { + return ("opening" == this.readyState || "open" == this.readyState) && (this.doClose(), this.onClose()), this; + }, n.prototype.send = function (t) { + if ("open" != this.readyState) throw new Error("Transport not open"); + this.write(t); + }, n.prototype.onOpen = function () { + this.readyState = "open", this.writable = !0, this.emit("open"); + }, n.prototype.onData = function (t) { + var e = r.decodePacket(t, this.socket.binaryType); + this.onPacket(e); + }, n.prototype.onPacket = function (t) { + this.emit("packet", t); + }, n.prototype.onClose = function () { + this.readyState = "closed", this.emit("close"); + }; + }, { + "component-emitter": 9, + "engine.io-parser": 25 + }], + 15: [function (t, e, n) { + (function (e) { + function r(t) { + var n, + r = !1, + a = !1, + c = !1 !== t.jsonp; + if (e.location) { + var p = "https:" == location.protocol, + u = location.port; + u || (u = p ? 443 : 80), r = t.hostname != location.hostname || u != t.port, a = t.secure != p; + } + if (t.xdomain = r, t.xscheme = a, n = new o(t), "open" in n && !t.forceJSONP) return new i(t); + if (!c) throw new Error("JSONP disabled"); + return new s(t); + } + var o = t("xmlhttprequest"), + i = t("./polling-xhr"), + s = t("./polling-jsonp"), + a = t("./websocket"); + n.polling = r, n.websocket = a; + }).call(this, "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}); + }, { + "./polling-jsonp": 16, + "./polling-xhr": 17, + "./websocket": 19, + xmlhttprequest: 20 + }], + 16: [function (t, e) { + (function (n) { + function r() {} + function o(t) { + i.call(this, t), this.query = this.query || {}, a || (n.___eio || (n.___eio = []), a = n.___eio), this.index = a.length; + var e = this; + a.push(function (t) { + e.onData(t); + }), this.query.j = this.index, n.document && n.addEventListener && n.addEventListener("beforeunload", function () { + e.script && (e.script.onerror = r); + }, !1); + } + var i = t("./polling"), + s = t("component-inherit"); + e.exports = o; + var a, + c = /\n/g, + p = /\\n/g; + s(o, i), o.prototype.supportsBinary = !1, o.prototype.doClose = function () { + this.script && (this.script.parentNode.removeChild(this.script), this.script = null), this.form && (this.form.parentNode.removeChild(this.form), this.form = null, this.iframe = null), i.prototype.doClose.call(this); + }, o.prototype.doPoll = function () { + var t = this, + e = document.createElement("script"); + this.script && (this.script.parentNode.removeChild(this.script), this.script = null), e.async = !0, e.src = this.uri(), e.onerror = function (e) { + t.onError("jsonp poll error", e); + }; + var n = document.getElementsByTagName("script")[0]; + n.parentNode.insertBefore(e, n), this.script = e; + var r = "undefined" != typeof navigator && /gecko/i.test(navigator.userAgent); + r && setTimeout(function () { + var t = document.createElement("iframe"); + document.body.appendChild(t), document.body.removeChild(t); + }, 100); + }, o.prototype.doWrite = function (t, e) { + function n() { + r(), e(); + } + function r() { + if (o.iframe) try { + o.form.removeChild(o.iframe); + } catch (t) { + o.onError("jsonp polling iframe removal error", t); + } + try { + var e = '