{"ast":null,"code":"var _classCallCheck = require(\"C:/laragon/www/iot.mksolusi/DriverOPCDA/frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/classCallCheck\");\n\nvar _createClass = require(\"C:/laragon/www/iot.mksolusi/DriverOPCDA/frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/createClass\");\n\nvar _inherits = require(\"C:/laragon/www/iot.mksolusi/DriverOPCDA/frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/inherits\");\n\nvar _createSuper = require(\"C:/laragon/www/iot.mksolusi/DriverOPCDA/frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/createSuper\");\n\nvar transports = require(\"./transports/index\");\n\nvar Emitter = require(\"component-emitter\");\n\nvar debug = require(\"debug\")(\"engine.io-client:socket\");\n\nvar parser = require(\"engine.io-parser\");\n\nvar parseuri = require(\"parseuri\");\n\nvar parseqs = require(\"parseqs\");\n\nvar Socket = /*#__PURE__*/function (_Emitter) {\n  \"use strict\";\n\n  _inherits(Socket, _Emitter);\n\n  var _super = _createSuper(Socket);\n\n  /**\n   * Socket constructor.\n   *\n   * @param {String|Object} uri or options\n   * @param {Object} options\n   * @api public\n   */\n  function Socket(uri) {\n    var _this;\n\n    var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n    _classCallCheck(this, Socket);\n\n    _this = _super.call(this);\n\n    if (uri && \"object\" === typeof uri) {\n      opts = uri;\n      uri = null;\n    }\n\n    if (uri) {\n      uri = parseuri(uri);\n      opts.hostname = uri.host;\n      opts.secure = uri.protocol === \"https\" || uri.protocol === \"wss\";\n      opts.port = uri.port;\n      if (uri.query) opts.query = uri.query;\n    } else if (opts.host) {\n      opts.hostname = parseuri(opts.host).host;\n    }\n\n    _this.secure = null != opts.secure ? opts.secure : typeof location !== \"undefined\" && \"https:\" === location.protocol;\n\n    if (opts.hostname && !opts.port) {\n      // if no port is specified manually, use the protocol default\n      opts.port = _this.secure ? \"443\" : \"80\";\n    }\n\n    _this.hostname = opts.hostname || (typeof location !== \"undefined\" ? location.hostname : \"localhost\");\n    _this.port = opts.port || (typeof location !== \"undefined\" && location.port ? location.port : _this.secure ? 443 : 80);\n    _this.transports = opts.transports || [\"polling\", \"websocket\"];\n    _this.readyState = \"\";\n    _this.writeBuffer = [];\n    _this.prevBufferLen = 0;\n    _this.opts = Object.assign({\n      path: \"/engine.io\",\n      agent: false,\n      withCredentials: false,\n      upgrade: true,\n      jsonp: true,\n      timestampParam: \"t\",\n      rememberUpgrade: false,\n      rejectUnauthorized: true,\n      perMessageDeflate: {\n        threshold: 1024\n      },\n      transportOptions: {}\n    }, opts);\n    _this.opts.path = _this.opts.path.replace(/\\/$/, \"\") + \"/\";\n\n    if (typeof _this.opts.query === \"string\") {\n      _this.opts.query = parseqs.decode(_this.opts.query);\n    } // set on handshake\n\n\n    _this.id = null;\n    _this.upgrades = null;\n    _this.pingInterval = null;\n    _this.pingTimeout = null; // set on heartbeat\n\n    _this.pingTimeoutTimer = null;\n\n    if (typeof addEventListener === \"function\") {\n      addEventListener(\"beforeunload\", function () {\n        if (_this.transport) {\n          // silently close the transport\n          _this.transport.removeAllListeners();\n\n          _this.transport.close();\n        }\n      }, false);\n\n      if (_this.hostname !== \"localhost\") {\n        _this.offlineEventListener = function () {\n          _this.onClose(\"transport close\");\n        };\n\n        addEventListener(\"offline\", _this.offlineEventListener, false);\n      }\n    }\n\n    _this.open();\n\n    return _this;\n  }\n  /**\n   * Creates transport of the given type.\n   *\n   * @param {String} transport name\n   * @return {Transport}\n   * @api private\n   */\n\n\n  _createClass(Socket, [{\n    key: \"createTransport\",\n    value: function createTransport(name) {\n      debug('creating transport \"%s\"', name);\n      var query = clone(this.opts.query); // append engine.io protocol identifier\n\n      query.EIO = parser.protocol; // transport name\n\n      query.transport = name; // session id if we already have one\n\n      if (this.id) query.sid = this.id;\n      var opts = Object.assign({}, this.opts.transportOptions[name], this.opts, {\n        query: query,\n        socket: this,\n        hostname: this.hostname,\n        secure: this.secure,\n        port: this.port\n      });\n      debug(\"options: %j\", opts);\n      return new transports[name](opts);\n    }\n    /**\n     * Initializes transport to use and starts probe.\n     *\n     * @api private\n     */\n\n  }, {\n    key: \"open\",\n    value: function open() {\n      var transport;\n\n      if (this.opts.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf(\"websocket\") !== -1) {\n        transport = \"websocket\";\n      } else if (0 === this.transports.length) {\n        // Emit error on next tick so it can be listened to\n        var self = this;\n        setTimeout(function () {\n          self.emit(\"error\", \"No transports available\");\n        }, 0);\n        return;\n      } else {\n        transport = this.transports[0];\n      }\n\n      this.readyState = \"opening\"; // Retry with the next transport if the transport is disabled (jsonp: false)\n\n      try {\n        transport = this.createTransport(transport);\n      } catch (e) {\n        debug(\"error while creating transport: %s\", e);\n        this.transports.shift();\n        this.open();\n        return;\n      }\n\n      transport.open();\n      this.setTransport(transport);\n    }\n    /**\n     * Sets the current transport. Disables the existing one (if any).\n     *\n     * @api private\n     */\n\n  }, {\n    key: \"setTransport\",\n    value: function setTransport(transport) {\n      debug(\"setting transport %s\", transport.name);\n      var self = this;\n\n      if (this.transport) {\n        debug(\"clearing existing transport %s\", this.transport.name);\n        this.transport.removeAllListeners();\n      } // set up transport\n\n\n      this.transport = transport; // set up transport listeners\n\n      transport.on(\"drain\", function () {\n        self.onDrain();\n      }).on(\"packet\", function (packet) {\n        self.onPacket(packet);\n      }).on(\"error\", function (e) {\n        self.onError(e);\n      }).on(\"close\", function () {\n        self.onClose(\"transport close\");\n      });\n    }\n    /**\n     * Probes a transport.\n     *\n     * @param {String} transport name\n     * @api private\n     */\n\n  }, {\n    key: \"probe\",\n    value: function probe(name) {\n      debug('probing transport \"%s\"', name);\n      var transport = this.createTransport(name, {\n        probe: 1\n      });\n      var failed = false;\n      var self = this;\n      Socket.priorWebsocketSuccess = false;\n\n      function onTransportOpen() {\n        if (self.onlyBinaryUpgrades) {\n          var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;\n          failed = failed || upgradeLosesBinary;\n        }\n\n        if (failed) return;\n        debug('probe transport \"%s\" opened', name);\n        transport.send([{\n          type: \"ping\",\n          data: \"probe\"\n        }]);\n        transport.once(\"packet\", function (msg) {\n          if (failed) return;\n\n          if (\"pong\" === msg.type && \"probe\" === msg.data) {\n            debug('probe transport \"%s\" pong', name);\n            self.upgrading = true;\n            self.emit(\"upgrading\", transport);\n            if (!transport) return;\n            Socket.priorWebsocketSuccess = \"websocket\" === transport.name;\n            debug('pausing current transport \"%s\"', self.transport.name);\n            self.transport.pause(function () {\n              if (failed) return;\n              if (\"closed\" === self.readyState) return;\n              debug(\"changing transport and sending upgrade packet\");\n              cleanup();\n              self.setTransport(transport);\n              transport.send([{\n                type: \"upgrade\"\n              }]);\n              self.emit(\"upgrade\", transport);\n              transport = null;\n              self.upgrading = false;\n              self.flush();\n            });\n          } else {\n            debug('probe transport \"%s\" failed', name);\n            var err = new Error(\"probe error\");\n            err.transport = transport.name;\n            self.emit(\"upgradeError\", err);\n          }\n        });\n      }\n\n      function freezeTransport() {\n        if (failed) return; // Any callback called by transport should be ignored since now\n\n        failed = true;\n        cleanup();\n        transport.close();\n        transport = null;\n      } // Handle any error that happens while probing\n\n\n      function onerror(err) {\n        var error = new Error(\"probe error: \" + err);\n        error.transport = transport.name;\n        freezeTransport();\n        debug('probe transport \"%s\" failed because of error: %s', name, err);\n        self.emit(\"upgradeError\", error);\n      }\n\n      function onTransportClose() {\n        onerror(\"transport closed\");\n      } // When the socket is closed while we're probing\n\n\n      function onclose() {\n        onerror(\"socket closed\");\n      } // When the socket is upgraded while we're probing\n\n\n      function onupgrade(to) {\n        if (transport && to.name !== transport.name) {\n          debug('\"%s\" works - aborting \"%s\"', to.name, transport.name);\n          freezeTransport();\n        }\n      } // Remove all listeners on the transport and on self\n\n\n      function cleanup() {\n        transport.removeListener(\"open\", onTransportOpen);\n        transport.removeListener(\"error\", onerror);\n        transport.removeListener(\"close\", onTransportClose);\n        self.removeListener(\"close\", onclose);\n        self.removeListener(\"upgrading\", onupgrade);\n      }\n\n      transport.once(\"open\", onTransportOpen);\n      transport.once(\"error\", onerror);\n      transport.once(\"close\", onTransportClose);\n      this.once(\"close\", onclose);\n      this.once(\"upgrading\", onupgrade);\n      transport.open();\n    }\n    /**\n     * Called when connection is deemed open.\n     *\n     * @api public\n     */\n\n  }, {\n    key: \"onOpen\",\n    value: function onOpen() {\n      debug(\"socket open\");\n      this.readyState = \"open\";\n      Socket.priorWebsocketSuccess = \"websocket\" === this.transport.name;\n      this.emit(\"open\");\n      this.flush(); // we check for `readyState` in case an `open`\n      // listener already closed the socket\n\n      if (\"open\" === this.readyState && this.opts.upgrade && this.transport.pause) {\n        debug(\"starting upgrade probes\");\n        var i = 0;\n        var l = this.upgrades.length;\n\n        for (; i < l; i++) {\n          this.probe(this.upgrades[i]);\n        }\n      }\n    }\n    /**\n     * Handles a packet.\n     *\n     * @api private\n     */\n\n  }, {\n    key: \"onPacket\",\n    value: function onPacket(packet) {\n      if (\"opening\" === this.readyState || \"open\" === this.readyState || \"closing\" === this.readyState) {\n        debug('socket receive: type \"%s\", data \"%s\"', packet.type, packet.data);\n        this.emit(\"packet\", packet); // Socket is live - any packet counts\n\n        this.emit(\"heartbeat\");\n\n        switch (packet.type) {\n          case \"open\":\n            this.onHandshake(JSON.parse(packet.data));\n            break;\n\n          case \"ping\":\n            this.resetPingTimeout();\n            this.sendPacket(\"pong\");\n            this.emit(\"pong\");\n            break;\n\n          case \"error\":\n            var err = new Error(\"server error\");\n            err.code = packet.data;\n            this.onError(err);\n            break;\n\n          case \"message\":\n            this.emit(\"data\", packet.data);\n            this.emit(\"message\", packet.data);\n            break;\n        }\n      } else {\n        debug('packet received with socket readyState \"%s\"', this.readyState);\n      }\n    }\n    /**\n     * Called upon handshake completion.\n     *\n     * @param {Object} handshake obj\n     * @api private\n     */\n\n  }, {\n    key: \"onHandshake\",\n    value: function onHandshake(data) {\n      this.emit(\"handshake\", data);\n      this.id = data.sid;\n      this.transport.query.sid = data.sid;\n      this.upgrades = this.filterUpgrades(data.upgrades);\n      this.pingInterval = data.pingInterval;\n      this.pingTimeout = data.pingTimeout;\n      this.onOpen(); // In case open handler closes socket\n\n      if (\"closed\" === this.readyState) return;\n      this.resetPingTimeout();\n    }\n    /**\n     * Sets and resets ping timeout timer based on server pings.\n     *\n     * @api private\n     */\n\n  }, {\n    key: \"resetPingTimeout\",\n    value: function resetPingTimeout() {\n      var _this2 = this;\n\n      clearTimeout(this.pingTimeoutTimer);\n      this.pingTimeoutTimer = setTimeout(function () {\n        _this2.onClose(\"ping timeout\");\n      }, this.pingInterval + this.pingTimeout);\n\n      if (this.opts.autoUnref) {\n        this.pingTimeoutTimer.unref();\n      }\n    }\n    /**\n     * Called on `drain` event\n     *\n     * @api private\n     */\n\n  }, {\n    key: \"onDrain\",\n    value: function onDrain() {\n      this.writeBuffer.splice(0, this.prevBufferLen); // setting prevBufferLen = 0 is very important\n      // for example, when upgrading, upgrade packet is sent over,\n      // and a nonzero prevBufferLen could cause problems on `drain`\n\n      this.prevBufferLen = 0;\n\n      if (0 === this.writeBuffer.length) {\n        this.emit(\"drain\");\n      } else {\n        this.flush();\n      }\n    }\n    /**\n     * Flush write buffers.\n     *\n     * @api private\n     */\n\n  }, {\n    key: \"flush\",\n    value: function flush() {\n      if (\"closed\" !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length) {\n        debug(\"flushing %d packets in socket\", this.writeBuffer.length);\n        this.transport.send(this.writeBuffer); // keep track of current length of writeBuffer\n        // splice writeBuffer and callbackBuffer on `drain`\n\n        this.prevBufferLen = this.writeBuffer.length;\n        this.emit(\"flush\");\n      }\n    }\n    /**\n     * Sends a message.\n     *\n     * @param {String} message.\n     * @param {Function} callback function.\n     * @param {Object} options.\n     * @return {Socket} for chaining.\n     * @api public\n     */\n\n  }, {\n    key: \"write\",\n    value: function write(msg, options, fn) {\n      this.sendPacket(\"message\", msg, options, fn);\n      return this;\n    }\n  }, {\n    key: \"send\",\n    value: function send(msg, options, fn) {\n      this.sendPacket(\"message\", msg, options, fn);\n      return this;\n    }\n    /**\n     * Sends a packet.\n     *\n     * @param {String} packet type.\n     * @param {String} data.\n     * @param {Object} options.\n     * @param {Function} callback function.\n     * @api private\n     */\n\n  }, {\n    key: \"sendPacket\",\n    value: function sendPacket(type, data, options, fn) {\n      if (\"function\" === typeof data) {\n        fn = data;\n        data = undefined;\n      }\n\n      if (\"function\" === typeof options) {\n        fn = options;\n        options = null;\n      }\n\n      if (\"closing\" === this.readyState || \"closed\" === this.readyState) {\n        return;\n      }\n\n      options = options || {};\n      options.compress = false !== options.compress;\n      var packet = {\n        type: type,\n        data: data,\n        options: options\n      };\n      this.emit(\"packetCreate\", packet);\n      this.writeBuffer.push(packet);\n      if (fn) this.once(\"flush\", fn);\n      this.flush();\n    }\n    /**\n     * Closes the connection.\n     *\n     * @api private\n     */\n\n  }, {\n    key: \"close\",\n    value: function close() {\n      var self = this;\n\n      if (\"opening\" === this.readyState || \"open\" === this.readyState) {\n        this.readyState = \"closing\";\n\n        if (this.writeBuffer.length) {\n          this.once(\"drain\", function () {\n            if (this.upgrading) {\n              waitForUpgrade();\n            } else {\n              close();\n            }\n          });\n        } else if (this.upgrading) {\n          waitForUpgrade();\n        } else {\n          close();\n        }\n      }\n\n      function close() {\n        self.onClose(\"forced close\");\n        debug(\"socket closing - telling transport to close\");\n        self.transport.close();\n      }\n\n      function cleanupAndClose() {\n        self.removeListener(\"upgrade\", cleanupAndClose);\n        self.removeListener(\"upgradeError\", cleanupAndClose);\n        close();\n      }\n\n      function waitForUpgrade() {\n        // wait for upgrade to finish since we can't send packets while pausing a transport\n        self.once(\"upgrade\", cleanupAndClose);\n        self.once(\"upgradeError\", cleanupAndClose);\n      }\n\n      return this;\n    }\n    /**\n     * Called upon transport error\n     *\n     * @api private\n     */\n\n  }, {\n    key: \"onError\",\n    value: function onError(err) {\n      debug(\"socket error %j\", err);\n      Socket.priorWebsocketSuccess = false;\n      this.emit(\"error\", err);\n      this.onClose(\"transport error\", err);\n    }\n    /**\n     * Called upon transport close.\n     *\n     * @api private\n     */\n\n  }, {\n    key: \"onClose\",\n    value: function onClose(reason, desc) {\n      if (\"opening\" === this.readyState || \"open\" === this.readyState || \"closing\" === this.readyState) {\n        debug('socket close with reason: \"%s\"', reason);\n        var self = this; // clear timers\n\n        clearTimeout(this.pingIntervalTimer);\n        clearTimeout(this.pingTimeoutTimer); // stop event from firing again for transport\n\n        this.transport.removeAllListeners(\"close\"); // ensure transport won't stay open\n\n        this.transport.close(); // ignore further transport communication\n\n        this.transport.removeAllListeners();\n\n        if (typeof removeEventListener === \"function\") {\n          removeEventListener(\"offline\", this.offlineEventListener, false);\n        } // set ready state\n\n\n        this.readyState = \"closed\"; // clear session id\n\n        this.id = null; // emit close event\n\n        this.emit(\"close\", reason, desc); // clean buffers after, so users can still\n        // grab the buffers on `close` event\n\n        self.writeBuffer = [];\n        self.prevBufferLen = 0;\n      }\n    }\n    /**\n     * Filters upgrades, returning only those matching client transports.\n     *\n     * @param {Array} server upgrades\n     * @api private\n     *\n     */\n\n  }, {\n    key: \"filterUpgrades\",\n    value: function filterUpgrades(upgrades) {\n      var filteredUpgrades = [];\n      var i = 0;\n      var j = upgrades.length;\n\n      for (; i < j; i++) {\n        if (~this.transports.indexOf(upgrades[i])) filteredUpgrades.push(upgrades[i]);\n      }\n\n      return filteredUpgrades;\n    }\n  }]);\n\n  return Socket;\n}(Emitter);\n\nSocket.priorWebsocketSuccess = false;\n/**\n * Protocol version.\n *\n * @api public\n */\n\nSocket.protocol = parser.protocol; // this is an int\n\nfunction clone(obj) {\n  var o = {};\n\n  for (var i in obj) {\n    if (obj.hasOwnProperty(i)) {\n      o[i] = obj[i];\n    }\n  }\n\n  return o;\n}\n\nmodule.exports = Socket;","map":{"version":3,"sources":["C:/laragon/www/iot.mksolusi/DriverOPCDA/frontend/node_modules/engine.io-client/lib/socket.js"],"names":["transports","require","Emitter","debug","parser","parseuri","parseqs","Socket","uri","opts","hostname","host","secure","protocol","port","query","location","readyState","writeBuffer","prevBufferLen","Object","assign","path","agent","withCredentials","upgrade","jsonp","timestampParam","rememberUpgrade","rejectUnauthorized","perMessageDeflate","threshold","transportOptions","replace","decode","id","upgrades","pingInterval","pingTimeout","pingTimeoutTimer","addEventListener","transport","removeAllListeners","close","offlineEventListener","onClose","open","name","clone","EIO","sid","socket","priorWebsocketSuccess","indexOf","length","self","setTimeout","emit","createTransport","e","shift","setTransport","on","onDrain","packet","onPacket","onError","probe","failed","onTransportOpen","onlyBinaryUpgrades","upgradeLosesBinary","supportsBinary","send","type","data","once","msg","upgrading","pause","cleanup","flush","err","Error","freezeTransport","onerror","error","onTransportClose","onclose","onupgrade","to","removeListener","i","l","onHandshake","JSON","parse","resetPingTimeout","sendPacket","code","filterUpgrades","onOpen","clearTimeout","autoUnref","unref","splice","writable","options","fn","undefined","compress","push","waitForUpgrade","cleanupAndClose","reason","desc","pingIntervalTimer","removeEventListener","filteredUpgrades","j","obj","o","hasOwnProperty","module","exports"],"mappings":";;;;;;;;AAAA,IAAMA,UAAU,GAAGC,OAAO,CAAC,oBAAD,CAA1B;;AACA,IAAMC,OAAO,GAAGD,OAAO,CAAC,mBAAD,CAAvB;;AACA,IAAME,KAAK,GAAGF,OAAO,CAAC,OAAD,CAAP,CAAiB,yBAAjB,CAAd;;AACA,IAAMG,MAAM,GAAGH,OAAO,CAAC,kBAAD,CAAtB;;AACA,IAAMI,QAAQ,GAAGJ,OAAO,CAAC,UAAD,CAAxB;;AACA,IAAMK,OAAO,GAAGL,OAAO,CAAC,SAAD,CAAvB;;IAEMM,M;;;;;;;AACJ;AACF;AACA;AACA;AACA;AACA;AACA;AACE,kBAAYC,GAAZ,EAA4B;AAAA;;AAAA,QAAXC,IAAW,uEAAJ,EAAI;;AAAA;;AAC1B;;AAEA,QAAID,GAAG,IAAI,aAAa,OAAOA,GAA/B,EAAoC;AAClCC,MAAAA,IAAI,GAAGD,GAAP;AACAA,MAAAA,GAAG,GAAG,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AAwBjB,QAAQ,CAACwD,CAAD,CAAhC,CAAL,EACE0B,gBAAgB,CAACP,IAAjB,CAAsB3E,QAAQ,CAACwD,CAAD,CAA9B;AACH;;AACD,aAAO0B,gBAAP;AACD;;;;EAtpBkBpH,O;;AAypBrBK,MAAM,CAAC6C,qBAAP,GAA+B,KAA/B;AAEA;AACA;AACA;AACA;AACA;;AAEA7C,MAAM,CAACM,QAAP,GAAkBT,MAAM,CAACS,QAAzB,C,CAAmC;;AAEnC,SAASmC,KAAT,CAAewE,GAAf,EAAoB;AAClB,MAAMC,CAAC,GAAG,EAAV;;AACA,OAAK,IAAI7B,CAAT,IAAc4B,GAAd,EAAmB;AACjB,QAAIA,GAAG,CAACE,cAAJ,CAAmB9B,CAAnB,CAAJ,EAA2B;AACzB6B,MAAAA,CAAC,CAAC7B,CAAD,CAAD,GAAO4B,GAAG,CAAC5B,CAAD,CAAV;AACD;AACF;;AACD,SAAO6B,CAAP;AACD;;AAEDE,MAAM,CAACC,OAAP,GAAiBrH,MAAjB","sourcesContent":["const transports = require(\"./transports/index\");\nconst Emitter = require(\"component-emitter\");\nconst debug = require(\"debug\")(\"engine.io-client:socket\");\nconst parser = require(\"engine.io-parser\");\nconst parseuri = require(\"parseuri\");\nconst parseqs = require(\"parseqs\");\n\nclass Socket extends Emitter {\n  /**\n   * Socket constructor.\n   *\n   * @param {String|Object} uri or options\n   * @param {Object} options\n   * @api public\n   */\n  constructor(uri, opts = {}) {\n    super();\n\n    if (uri && \"object\" === typeof uri) {\n      opts = uri;\n      uri = null;\n    }\n\n    if (uri) {\n      uri = parseuri(uri);\n      opts.hostname = uri.host;\n      opts.secure = uri.protocol === \"https\" || uri.protocol === \"wss\";\n      opts.port = uri.port;\n      if (uri.query) opts.query = uri.query;\n    } else if (opts.host) {\n      opts.hostname = parseuri(opts.host).host;\n    }\n\n    this.secure =\n      null != opts.secure\n        ? opts.secure\n        : typeof location !== \"undefined\" && \"https:\" === location.protocol;\n\n    if (opts.hostname && !opts.port) {\n      // if no port is specified manually, use the protocol default\n      opts.port = this.secure ? \"443\" : \"80\";\n    }\n\n    this.hostname =\n      opts.hostname ||\n      (typeof location !== \"undefined\" ? location.hostname : \"localhost\");\n    this.port =\n      opts.port ||\n      (typeof location !== \"undefined\" && location.port\n        ? location.port\n        : this.secure\n        ? 443\n        : 80);\n\n    this.transports = opts.transports || [\"polling\", \"websocket\"];\n    this.readyState = \"\";\n    this.writeBuffer = [];\n    this.prevBufferLen = 0;\n\n    this.opts = Object.assign(\n      {\n        path: \"/engine.io\",\n        agent: false,\n        withCredentials: false,\n        upgrade: true,\n        jsonp: true,\n        timestampParam: \"t\",\n        rememberUpgrade: false,\n        rejectUnauthorized: true,\n        perMessageDeflate: {\n          threshold: 1024\n        },\n        transportOptions: {}\n      },\n      opts\n    );\n\n    this.opts.path = this.opts.path.replace(/\\/$/, \"\") + \"/\";\n\n    if (typeof this.opts.query === \"string\") {\n      this.opts.query = parseqs.decode(this.opts.query);\n    }\n\n    // set on handshake\n    this.id = null;\n    this.upgrades = null;\n    this.pingInterval = null;\n    this.pingTimeout = null;\n\n    // set on heartbeat\n    this.pingTimeoutTimer = null;\n\n    if (typeof addEventListener === \"function\") {\n      addEventListener(\n        \"beforeunload\",\n        () => {\n          if (this.transport) {\n            // silently close the transport\n            this.transport.removeAllListeners();\n            this.transport.close();\n          }\n        },\n        false\n      );\n      if (this.hostname !== \"localhost\") {\n        this.offlineEventListener = () => {\n          this.onClose(\"transport close\");\n        };\n        addEventListener(\"offline\", this.offlineEventListener, false);\n      }\n    }\n\n    this.open();\n  }\n\n  /**\n   * Creates transport of the given type.\n   *\n   * @param {String} transport name\n   * @return {Transport}\n   * @api private\n   */\n  createTransport(name) {\n    debug('creating transport \"%s\"', name);\n    const query = clone(this.opts.query);\n\n    // append engine.io protocol identifier\n    query.EIO = parser.protocol;\n\n    // transport name\n    query.transport = name;\n\n    // session id if we already have one\n    if (this.id) query.sid = this.id;\n\n    const opts = Object.assign(\n      {},\n      this.opts.transportOptions[name],\n      this.opts,\n      {\n        query,\n        socket: this,\n        hostname: this.hostname,\n        secure: this.secure,\n        port: this.port\n      }\n    );\n\n    debug(\"options: %j\", opts);\n\n    return new transports[name](opts);\n  }\n\n  /**\n   * Initializes transport to use and starts probe.\n   *\n   * @api private\n   */\n  open() {\n    let transport;\n    if (\n      this.opts.rememberUpgrade &&\n      Socket.priorWebsocketSuccess &&\n      this.transports.indexOf(\"websocket\") !== -1\n    ) {\n      transport = \"websocket\";\n    } else if (0 === this.transports.length) {\n      // Emit error on next tick so it can be listened to\n      const self = this;\n      setTimeout(function() {\n        self.emit(\"error\", \"No transports available\");\n      }, 0);\n      return;\n    } else {\n      transport = this.transports[0];\n    }\n    this.readyState = \"opening\";\n\n    // Retry with the next transport if the transport is disabled (jsonp: false)\n    try {\n      transport = this.createTransport(transport);\n    } catch (e) {\n      debug(\"error while creating transport: %s\", e);\n      this.transports.shift();\n      this.open();\n      return;\n    }\n\n    transport.open();\n    this.setTransport(transport);\n  }\n\n  /**\n   * Sets the current transport. Disables the existing one (if any).\n   *\n   * @api private\n   */\n  setTransport(transport) {\n    debug(\"setting transport %s\", transport.name);\n    const self = this;\n\n    if (this.transport) {\n      debug(\"clearing existing transport %s\", this.transport.name);\n      this.transport.removeAllListeners();\n    }\n\n    // set up transport\n    this.transport = transport;\n\n    // set up transport listeners\n    transport\n      .on(\"drain\", function() {\n        self.onDrain();\n      })\n      .on(\"packet\", function(packet) {\n        self.onPacket(packet);\n      })\n      .on(\"error\", function(e) {\n        self.onError(e);\n      })\n      .on(\"close\", function() {\n        self.onClose(\"transport close\");\n      });\n  }\n\n  /**\n   * Probes a transport.\n   *\n   * @param {String} transport name\n   * @api private\n   */\n  probe(name) {\n    debug('probing transport \"%s\"', name);\n    let transport = this.createTransport(name, { probe: 1 });\n    let failed = false;\n    const self = this;\n\n    Socket.priorWebsocketSuccess = false;\n\n    function onTransportOpen() {\n      if (self.onlyBinaryUpgrades) {\n        const upgradeLosesBinary =\n          !this.supportsBinary && self.transport.supportsBinary;\n        failed = failed || upgradeLosesBinary;\n      }\n      if (failed) return;\n\n      debug('probe transport \"%s\" opened', name);\n      transport.send([{ type: \"ping\", data: \"probe\" }]);\n      transport.once(\"packet\", function(msg) {\n        if (failed) return;\n        if (\"pong\" === msg.type && \"probe\" === msg.data) {\n          debug('probe transport \"%s\" pong', name);\n          self.upgrading = true;\n          self.emit(\"upgrading\", transport);\n          if (!transport) return;\n          Socket.priorWebsocketSuccess = \"websocket\" === transport.name;\n\n          debug('pausing current transport \"%s\"', self.transport.name);\n          self.transport.pause(function() {\n            if (failed) return;\n            if (\"closed\" === self.readyState) return;\n            debug(\"changing transport and sending upgrade packet\");\n\n            cleanup();\n\n            self.setTransport(transport);\n            transport.send([{ type: \"upgrade\" }]);\n            self.emit(\"upgrade\", transport);\n            transport = null;\n            self.upgrading = false;\n            self.flush();\n          });\n        } else {\n          debug('probe transport \"%s\" failed', name);\n          const err = new Error(\"probe error\");\n          err.transport = transport.name;\n          self.emit(\"upgradeError\", err);\n        }\n      });\n    }\n\n    function freezeTransport() {\n      if (failed) return;\n\n      // Any callback called by transport should be ignored since now\n      failed = true;\n\n      cleanup();\n\n      transport.close();\n      transport = null;\n    }\n\n    // Handle any error that happens while probing\n    function onerror(err) {\n      const error = new Error(\"probe error: \" + err);\n      error.transport = transport.name;\n\n      freezeTransport();\n\n      debug('probe transport \"%s\" failed because of error: %s', name, err);\n\n      self.emit(\"upgradeError\", error);\n    }\n\n    function onTransportClose() {\n      onerror(\"transport closed\");\n    }\n\n    // When the socket is closed while we're probing\n    function onclose() {\n      onerror(\"socket closed\");\n    }\n\n    // When the socket is upgraded while we're probing\n    function onupgrade(to) {\n      if (transport && to.name !== transport.name) {\n        debug('\"%s\" works - aborting \"%s\"', to.name, transport.name);\n        freezeTransport();\n      }\n    }\n\n    // Remove all listeners on the transport and on self\n    function cleanup() {\n      transport.removeListener(\"open\", onTransportOpen);\n      transport.removeListener(\"error\", onerror);\n      transport.removeListener(\"close\", onTransportClose);\n      self.removeListener(\"close\", onclose);\n      self.removeListener(\"upgrading\", onupgrade);\n    }\n\n    transport.once(\"open\", onTransportOpen);\n    transport.once(\"error\", onerror);\n    transport.once(\"close\", onTransportClose);\n\n    this.once(\"close\", onclose);\n    this.once(\"upgrading\", onupgrade);\n\n    transport.open();\n  }\n\n  /**\n   * Called when connection is deemed open.\n   *\n   * @api public\n   */\n  onOpen() {\n    debug(\"socket open\");\n    this.readyState = \"open\";\n    Socket.priorWebsocketSuccess = \"websocket\" === this.transport.name;\n    this.emit(\"open\");\n    this.flush();\n\n    // we check for `readyState` in case an `open`\n    // listener already closed the socket\n    if (\n      \"open\" === this.readyState &&\n      this.opts.upgrade &&\n      this.transport.pause\n    ) {\n      debug(\"starting upgrade probes\");\n      let i = 0;\n      const l = this.upgrades.length;\n      for (; i < l; i++) {\n        this.probe(this.upgrades[i]);\n      }\n    }\n  }\n\n  /**\n   * Handles a packet.\n   *\n   * @api private\n   */\n  onPacket(packet) {\n    if (\n      \"opening\" === this.readyState ||\n      \"open\" === this.readyState ||\n      \"closing\" === this.readyState\n    ) {\n      debug('socket receive: type \"%s\", data \"%s\"', packet.type, packet.data);\n\n      this.emit(\"packet\", packet);\n\n      // Socket is live - any packet counts\n      this.emit(\"heartbeat\");\n\n      switch (packet.type) {\n        case \"open\":\n          this.onHandshake(JSON.parse(packet.data));\n          break;\n\n        case \"ping\":\n          this.resetPingTimeout();\n          this.sendPacket(\"pong\");\n          this.emit(\"pong\");\n          break;\n\n        case \"error\":\n          const err = new Error(\"server error\");\n          err.code = packet.data;\n          this.onError(err);\n          break;\n\n        case \"message\":\n          this.emit(\"data\", packet.data);\n          this.emit(\"message\", packet.data);\n          break;\n      }\n    } else {\n      debug('packet received with socket readyState \"%s\"', this.readyState);\n    }\n  }\n\n  /**\n   * Called upon handshake completion.\n   *\n   * @param {Object} handshake obj\n   * @api private\n   */\n  onHandshake(data) {\n    this.emit(\"handshake\", data);\n    this.id = data.sid;\n    this.transport.query.sid = data.sid;\n    this.upgrades = this.filterUpgrades(data.upgrades);\n    this.pingInterval = data.pingInterval;\n    this.pingTimeout = data.pingTimeout;\n    this.onOpen();\n    // In case open handler closes socket\n    if (\"closed\" === this.readyState) return;\n    this.resetPingTimeout();\n  }\n\n  /**\n   * Sets and resets ping timeout timer based on server pings.\n   *\n   * @api private\n   */\n  resetPingTimeout() {\n    clearTimeout(this.pingTimeoutTimer);\n    this.pingTimeoutTimer = setTimeout(() => {\n      this.onClose(\"ping timeout\");\n    }, this.pingInterval + this.pingTimeout);\n    if (this.opts.autoUnref) {\n      this.pingTimeoutTimer.unref();\n    }\n  }\n\n  /**\n   * Called on `drain` event\n   *\n   * @api private\n   */\n  onDrain() {\n    this.writeBuffer.splice(0, this.prevBufferLen);\n\n    // setting prevBufferLen = 0 is very important\n    // for example, when upgrading, upgrade packet is sent over,\n    // and a nonzero prevBufferLen could cause problems on `drain`\n    this.prevBufferLen = 0;\n\n    if (0 === this.writeBuffer.length) {\n      this.emit(\"drain\");\n    } else {\n      this.flush();\n    }\n  }\n\n  /**\n   * Flush write buffers.\n   *\n   * @api private\n   */\n  flush() {\n    if (\n      \"closed\" !== this.readyState &&\n      this.transport.writable &&\n      !this.upgrading &&\n      this.writeBuffer.length\n    ) {\n      debug(\"flushing %d packets in socket\", this.writeBuffer.length);\n      this.transport.send(this.writeBuffer);\n      // keep track of current length of writeBuffer\n      // splice writeBuffer and callbackBuffer on `drain`\n      this.prevBufferLen = this.writeBuffer.length;\n      this.emit(\"flush\");\n    }\n  }\n\n  /**\n   * Sends a message.\n   *\n   * @param {String} message.\n   * @param {Function} callback function.\n   * @param {Object} options.\n   * @return {Socket} for chaining.\n   * @api public\n   */\n  write(msg, options, fn) {\n    this.sendPacket(\"message\", msg, options, fn);\n    return this;\n  }\n\n  send(msg, options, fn) {\n    this.sendPacket(\"message\", msg, options, fn);\n    return this;\n  }\n\n  /**\n   * Sends a packet.\n   *\n   * @param {String} packet type.\n   * @param {String} data.\n   * @param {Object} options.\n   * @param {Function} callback function.\n   * @api private\n   */\n  sendPacket(type, data, options, fn) {\n    if (\"function\" === typeof data) {\n      fn = data;\n      data = undefined;\n    }\n\n    if (\"function\" === typeof options) {\n      fn = options;\n      options = null;\n    }\n\n    if (\"closing\" === this.readyState || \"closed\" === this.readyState) {\n      return;\n    }\n\n    options = options || {};\n    options.compress = false !== options.compress;\n\n    const packet = {\n      type: type,\n      data: data,\n      options: options\n    };\n    this.emit(\"packetCreate\", packet);\n    this.writeBuffer.push(packet);\n    if (fn) this.once(\"flush\", fn);\n    this.flush();\n  }\n\n  /**\n   * Closes the connection.\n   *\n   * @api private\n   */\n  close() {\n    const self = this;\n\n    if (\"opening\" === this.readyState || \"open\" === this.readyState) {\n      this.readyState = \"closing\";\n\n      if (this.writeBuffer.length) {\n        this.once(\"drain\", function() {\n          if (this.upgrading) {\n            waitForUpgrade();\n          } else {\n            close();\n          }\n        });\n      } else if (this.upgrading) {\n        waitForUpgrade();\n      } else {\n        close();\n      }\n    }\n\n    function close() {\n      self.onClose(\"forced close\");\n      debug(\"socket closing - telling transport to close\");\n      self.transport.close();\n    }\n\n    function cleanupAndClose() {\n      self.removeListener(\"upgrade\", cleanupAndClose);\n      self.removeListener(\"upgradeError\", cleanupAndClose);\n      close();\n    }\n\n    function waitForUpgrade() {\n      // wait for upgrade to finish since we can't send packets while pausing a transport\n      self.once(\"upgrade\", cleanupAndClose);\n      self.once(\"upgradeError\", cleanupAndClose);\n    }\n\n    return this;\n  }\n\n  /**\n   * Called upon transport error\n   *\n   * @api private\n   */\n  onError(err) {\n    debug(\"socket error %j\", err);\n    Socket.priorWebsocketSuccess = false;\n    this.emit(\"error\", err);\n    this.onClose(\"transport error\", err);\n  }\n\n  /**\n   * Called upon transport close.\n   *\n   * @api private\n   */\n  onClose(reason, desc) {\n    if (\n      \"opening\" === this.readyState ||\n      \"open\" === this.readyState ||\n      \"closing\" === this.readyState\n    ) {\n      debug('socket close with reason: \"%s\"', reason);\n      const self = this;\n\n      // clear timers\n      clearTimeout(this.pingIntervalTimer);\n      clearTimeout(this.pingTimeoutTimer);\n\n      // stop event from firing again for transport\n      this.transport.removeAllListeners(\"close\");\n\n      // ensure transport won't stay open\n      this.transport.close();\n\n      // ignore further transport communication\n      this.transport.removeAllListeners();\n\n      if (typeof removeEventListener === \"function\") {\n        removeEventListener(\"offline\", this.offlineEventListener, false);\n      }\n\n      // set ready state\n      this.readyState = \"closed\";\n\n      // clear session id\n      this.id = null;\n\n      // emit close event\n      this.emit(\"close\", reason, desc);\n\n      // clean buffers after, so users can still\n      // grab the buffers on `close` event\n      self.writeBuffer = [];\n      self.prevBufferLen = 0;\n    }\n  }\n\n  /**\n   * Filters upgrades, returning only those matching client transports.\n   *\n   * @param {Array} server upgrades\n   * @api private\n   *\n   */\n  filterUpgrades(upgrades) {\n    const filteredUpgrades = [];\n    let i = 0;\n    const j = upgrades.length;\n    for (; i < j; i++) {\n      if (~this.transports.indexOf(upgrades[i]))\n        filteredUpgrades.push(upgrades[i]);\n    }\n    return filteredUpgrades;\n  }\n}\n\nSocket.priorWebsocketSuccess = false;\n\n/**\n * Protocol version.\n *\n * @api public\n */\n\nSocket.protocol = parser.protocol; // this is an int\n\nfunction clone(obj) {\n  const o = {};\n  for (let i in obj) {\n    if (obj.hasOwnProperty(i)) {\n      o[i] = obj[i];\n    }\n  }\n  return o;\n}\n\nmodule.exports = Socket;\n"]},"metadata":{},"sourceType":"script"}