[SignalingServer] Optimize dependent modules
[platform/framework/web/wrtjs.git] / signaling_server / service / node_modules / engine.io-client / engine.io.js
1 (function webpackUniversalModuleDefinition(root, factory) {
2         if(typeof exports === 'object' && typeof module === 'object')
3                 module.exports = factory();
4         else if(typeof define === 'function' && define.amd)
5                 define([], factory);
6         else if(typeof exports === 'object')
7                 exports["eio"] = factory();
8         else
9                 root["eio"] = factory();
10 })(this, function() {
11 return /******/ (function(modules) { // webpackBootstrap
12 /******/        // The module cache
13 /******/        var installedModules = {};
14
15 /******/        // The require function
16 /******/        function __webpack_require__(moduleId) {
17
18 /******/                // Check if module is in cache
19 /******/                if(installedModules[moduleId])
20 /******/                        return installedModules[moduleId].exports;
21
22 /******/                // Create a new module (and put it into the cache)
23 /******/                var module = installedModules[moduleId] = {
24 /******/                        exports: {},
25 /******/                        id: moduleId,
26 /******/                        loaded: false
27 /******/                };
28
29 /******/                // Execute the module function
30 /******/                modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
32 /******/                // Flag the module as loaded
33 /******/                module.loaded = true;
34
35 /******/                // Return the exports of the module
36 /******/                return module.exports;
37 /******/        }
38
39
40 /******/        // expose the modules object (__webpack_modules__)
41 /******/        __webpack_require__.m = modules;
42
43 /******/        // expose the module cache
44 /******/        __webpack_require__.c = installedModules;
45
46 /******/        // __webpack_public_path__
47 /******/        __webpack_require__.p = "";
48
49 /******/        // Load entry module and return exports
50 /******/        return __webpack_require__(0);
51 /******/ })
52 /************************************************************************/
53 /******/ ([
54 /* 0 */
55 /***/ function(module, exports, __webpack_require__) {
56
57         
58         module.exports = __webpack_require__(1);
59
60         /**
61          * Exports parser
62          *
63          * @api public
64          *
65          */
66         module.exports.parser = __webpack_require__(9);
67
68
69 /***/ },
70 /* 1 */
71 /***/ function(module, exports, __webpack_require__) {
72
73         /**
74          * Module dependencies.
75          */
76
77         var transports = __webpack_require__(2);
78         var Emitter = __webpack_require__(18);
79         var debug = __webpack_require__(22)('engine.io-client:socket');
80         var index = __webpack_require__(29);
81         var parser = __webpack_require__(9);
82         var parseuri = __webpack_require__(30);
83         var parseqs = __webpack_require__(19);
84
85         /**
86          * Module exports.
87          */
88
89         module.exports = Socket;
90
91         /**
92          * Socket constructor.
93          *
94          * @param {String|Object} uri or options
95          * @param {Object} options
96          * @api public
97          */
98
99         function Socket (uri, opts) {
100           if (!(this instanceof Socket)) return new Socket(uri, opts);
101
102           opts = opts || {};
103
104           if (uri && 'object' === typeof uri) {
105             opts = uri;
106             uri = null;
107           }
108
109           if (uri) {
110             uri = parseuri(uri);
111             opts.hostname = uri.host;
112             opts.secure = uri.protocol === 'https' || uri.protocol === 'wss';
113             opts.port = uri.port;
114             if (uri.query) opts.query = uri.query;
115           } else if (opts.host) {
116             opts.hostname = parseuri(opts.host).host;
117           }
118
119           this.secure = null != opts.secure ? opts.secure
120             : (typeof location !== 'undefined' && 'https:' === location.protocol);
121
122           if (opts.hostname && !opts.port) {
123             // if no port is specified manually, use the protocol default
124             opts.port = this.secure ? '443' : '80';
125           }
126
127           this.agent = opts.agent || false;
128           this.hostname = opts.hostname ||
129             (typeof location !== 'undefined' ? location.hostname : 'localhost');
130           this.port = opts.port || (typeof location !== 'undefined' && location.port
131               ? location.port
132               : (this.secure ? 443 : 80));
133           this.query = opts.query || {};
134           if ('string' === typeof this.query) this.query = parseqs.decode(this.query);
135           this.upgrade = false !== opts.upgrade;
136           this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
137           this.forceJSONP = !!opts.forceJSONP;
138           this.jsonp = false !== opts.jsonp;
139           this.forceBase64 = !!opts.forceBase64;
140           this.enablesXDR = !!opts.enablesXDR;
141           this.withCredentials = false !== opts.withCredentials;
142           this.timestampParam = opts.timestampParam || 't';
143           this.timestampRequests = opts.timestampRequests;
144           this.transports = opts.transports || ['polling', 'websocket'];
145           this.transportOptions = opts.transportOptions || {};
146           this.readyState = '';
147           this.writeBuffer = [];
148           this.prevBufferLen = 0;
149           this.policyPort = opts.policyPort || 843;
150           this.rememberUpgrade = opts.rememberUpgrade || false;
151           this.binaryType = null;
152           this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades;
153           this.perMessageDeflate = false !== opts.perMessageDeflate ? (opts.perMessageDeflate || {}) : false;
154
155           if (true === this.perMessageDeflate) this.perMessageDeflate = {};
156           if (this.perMessageDeflate && null == this.perMessageDeflate.threshold) {
157             this.perMessageDeflate.threshold = 1024;
158           }
159
160           // SSL options for Node.js client
161           this.pfx = opts.pfx || undefined;
162           this.key = opts.key || undefined;
163           this.passphrase = opts.passphrase || undefined;
164           this.cert = opts.cert || undefined;
165           this.ca = opts.ca || undefined;
166           this.ciphers = opts.ciphers || undefined;
167           this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? true : opts.rejectUnauthorized;
168           this.forceNode = !!opts.forceNode;
169
170           // detect ReactNative environment
171           this.isReactNative = (typeof navigator !== 'undefined' && typeof navigator.product === 'string' && navigator.product.toLowerCase() === 'reactnative');
172
173           // other options for Node.js or ReactNative client
174           if (typeof self === 'undefined' || this.isReactNative) {
175             if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) {
176               this.extraHeaders = opts.extraHeaders;
177             }
178
179             if (opts.localAddress) {
180               this.localAddress = opts.localAddress;
181             }
182           }
183
184           // set on handshake
185           this.id = null;
186           this.upgrades = null;
187           this.pingInterval = null;
188           this.pingTimeout = null;
189
190           // set on heartbeat
191           this.pingIntervalTimer = null;
192           this.pingTimeoutTimer = null;
193
194           this.open();
195         }
196
197         Socket.priorWebsocketSuccess = false;
198
199         /**
200          * Mix in `Emitter`.
201          */
202
203         Emitter(Socket.prototype);
204
205         /**
206          * Protocol version.
207          *
208          * @api public
209          */
210
211         Socket.protocol = parser.protocol; // this is an int
212
213         /**
214          * Expose deps for legacy compatibility
215          * and standalone browser access.
216          */
217
218         Socket.Socket = Socket;
219         Socket.Transport = __webpack_require__(8);
220         Socket.transports = __webpack_require__(2);
221         Socket.parser = __webpack_require__(9);
222
223         /**
224          * Creates transport of the given type.
225          *
226          * @param {String} transport name
227          * @return {Transport}
228          * @api private
229          */
230
231         Socket.prototype.createTransport = function (name) {
232           debug('creating transport "%s"', name);
233           var query = clone(this.query);
234
235           // append engine.io protocol identifier
236           query.EIO = parser.protocol;
237
238           // transport name
239           query.transport = name;
240
241           // per-transport options
242           var options = this.transportOptions[name] || {};
243
244           // session id if we already have one
245           if (this.id) query.sid = this.id;
246
247           var transport = new transports[name]({
248             query: query,
249             socket: this,
250             agent: options.agent || this.agent,
251             hostname: options.hostname || this.hostname,
252             port: options.port || this.port,
253             secure: options.secure || this.secure,
254             path: options.path || this.path,
255             forceJSONP: options.forceJSONP || this.forceJSONP,
256             jsonp: options.jsonp || this.jsonp,
257             forceBase64: options.forceBase64 || this.forceBase64,
258             enablesXDR: options.enablesXDR || this.enablesXDR,
259             withCredentials: options.withCredentials || this.withCredentials,
260             timestampRequests: options.timestampRequests || this.timestampRequests,
261             timestampParam: options.timestampParam || this.timestampParam,
262             policyPort: options.policyPort || this.policyPort,
263             pfx: options.pfx || this.pfx,
264             key: options.key || this.key,
265             passphrase: options.passphrase || this.passphrase,
266             cert: options.cert || this.cert,
267             ca: options.ca || this.ca,
268             ciphers: options.ciphers || this.ciphers,
269             rejectUnauthorized: options.rejectUnauthorized || this.rejectUnauthorized,
270             perMessageDeflate: options.perMessageDeflate || this.perMessageDeflate,
271             extraHeaders: options.extraHeaders || this.extraHeaders,
272             forceNode: options.forceNode || this.forceNode,
273             localAddress: options.localAddress || this.localAddress,
274             requestTimeout: options.requestTimeout || this.requestTimeout,
275             protocols: options.protocols || void (0),
276             isReactNative: this.isReactNative
277           });
278
279           return transport;
280         };
281
282         function clone (obj) {
283           var o = {};
284           for (var i in obj) {
285             if (obj.hasOwnProperty(i)) {
286               o[i] = obj[i];
287             }
288           }
289           return o;
290         }
291
292         /**
293          * Initializes transport to use and starts probe.
294          *
295          * @api private
296          */
297         Socket.prototype.open = function () {
298           var transport;
299           if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') !== -1) {
300             transport = 'websocket';
301           } else if (0 === this.transports.length) {
302             // Emit error on next tick so it can be listened to
303             var self = this;
304             setTimeout(function () {
305               self.emit('error', 'No transports available');
306             }, 0);
307             return;
308           } else {
309             transport = this.transports[0];
310           }
311           this.readyState = 'opening';
312
313           // Retry with the next transport if the transport is disabled (jsonp: false)
314           try {
315             transport = this.createTransport(transport);
316           } catch (e) {
317             this.transports.shift();
318             this.open();
319             return;
320           }
321
322           transport.open();
323           this.setTransport(transport);
324         };
325
326         /**
327          * Sets the current transport. Disables the existing one (if any).
328          *
329          * @api private
330          */
331
332         Socket.prototype.setTransport = function (transport) {
333           debug('setting transport %s', transport.name);
334           var self = this;
335
336           if (this.transport) {
337             debug('clearing existing transport %s', this.transport.name);
338             this.transport.removeAllListeners();
339           }
340
341           // set up transport
342           this.transport = transport;
343
344           // set up transport listeners
345           transport
346           .on('drain', function () {
347             self.onDrain();
348           })
349           .on('packet', function (packet) {
350             self.onPacket(packet);
351           })
352           .on('error', function (e) {
353             self.onError(e);
354           })
355           .on('close', function () {
356             self.onClose('transport close');
357           });
358         };
359
360         /**
361          * Probes a transport.
362          *
363          * @param {String} transport name
364          * @api private
365          */
366
367         Socket.prototype.probe = function (name) {
368           debug('probing transport "%s"', name);
369           var transport = this.createTransport(name, { probe: 1 });
370           var failed = false;
371           var self = this;
372
373           Socket.priorWebsocketSuccess = false;
374
375           function onTransportOpen () {
376             if (self.onlyBinaryUpgrades) {
377               var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;
378               failed = failed || upgradeLosesBinary;
379             }
380             if (failed) return;
381
382             debug('probe transport "%s" opened', name);
383             transport.send([{ type: 'ping', data: 'probe' }]);
384             transport.once('packet', function (msg) {
385               if (failed) return;
386               if ('pong' === msg.type && 'probe' === msg.data) {
387                 debug('probe transport "%s" pong', name);
388                 self.upgrading = true;
389                 self.emit('upgrading', transport);
390                 if (!transport) return;
391                 Socket.priorWebsocketSuccess = 'websocket' === transport.name;
392
393                 debug('pausing current transport "%s"', self.transport.name);
394                 self.transport.pause(function () {
395                   if (failed) return;
396                   if ('closed' === self.readyState) return;
397                   debug('changing transport and sending upgrade packet');
398
399                   cleanup();
400
401                   self.setTransport(transport);
402                   transport.send([{ type: 'upgrade' }]);
403                   self.emit('upgrade', transport);
404                   transport = null;
405                   self.upgrading = false;
406                   self.flush();
407                 });
408               } else {
409                 debug('probe transport "%s" failed', name);
410                 var err = new Error('probe error');
411                 err.transport = transport.name;
412                 self.emit('upgradeError', err);
413               }
414             });
415           }
416
417           function freezeTransport () {
418             if (failed) return;
419
420             // Any callback called by transport should be ignored since now
421             failed = true;
422
423             cleanup();
424
425             transport.close();
426             transport = null;
427           }
428
429           // Handle any error that happens while probing
430           function onerror (err) {
431             var error = new Error('probe error: ' + err);
432             error.transport = transport.name;
433
434             freezeTransport();
435
436             debug('probe transport "%s" failed because of error: %s', name, err);
437
438             self.emit('upgradeError', error);
439           }
440
441           function onTransportClose () {
442             onerror('transport closed');
443           }
444
445           // When the socket is closed while we're probing
446           function onclose () {
447             onerror('socket closed');
448           }
449
450           // When the socket is upgraded while we're probing
451           function onupgrade (to) {
452             if (transport && to.name !== transport.name) {
453               debug('"%s" works - aborting "%s"', to.name, transport.name);
454               freezeTransport();
455             }
456           }
457
458           // Remove all listeners on the transport and on self
459           function cleanup () {
460             transport.removeListener('open', onTransportOpen);
461             transport.removeListener('error', onerror);
462             transport.removeListener('close', onTransportClose);
463             self.removeListener('close', onclose);
464             self.removeListener('upgrading', onupgrade);
465           }
466
467           transport.once('open', onTransportOpen);
468           transport.once('error', onerror);
469           transport.once('close', onTransportClose);
470
471           this.once('close', onclose);
472           this.once('upgrading', onupgrade);
473
474           transport.open();
475         };
476
477         /**
478          * Called when connection is deemed open.
479          *
480          * @api public
481          */
482
483         Socket.prototype.onOpen = function () {
484           debug('socket open');
485           this.readyState = 'open';
486           Socket.priorWebsocketSuccess = 'websocket' === this.transport.name;
487           this.emit('open');
488           this.flush();
489
490           // we check for `readyState` in case an `open`
491           // listener already closed the socket
492           if ('open' === this.readyState && this.upgrade && this.transport.pause) {
493             debug('starting upgrade probes');
494             for (var i = 0, l = this.upgrades.length; i < l; i++) {
495               this.probe(this.upgrades[i]);
496             }
497           }
498         };
499
500         /**
501          * Handles a packet.
502          *
503          * @api private
504          */
505
506         Socket.prototype.onPacket = function (packet) {
507           if ('opening' === this.readyState || 'open' === this.readyState ||
508               'closing' === this.readyState) {
509             debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
510
511             this.emit('packet', packet);
512
513             // Socket is live - any packet counts
514             this.emit('heartbeat');
515
516             switch (packet.type) {
517               case 'open':
518                 this.onHandshake(JSON.parse(packet.data));
519                 break;
520
521               case 'pong':
522                 this.setPing();
523                 this.emit('pong');
524                 break;
525
526               case 'error':
527                 var err = new Error('server error');
528                 err.code = packet.data;
529                 this.onError(err);
530                 break;
531
532               case 'message':
533                 this.emit('data', packet.data);
534                 this.emit('message', packet.data);
535                 break;
536             }
537           } else {
538             debug('packet received with socket readyState "%s"', this.readyState);
539           }
540         };
541
542         /**
543          * Called upon handshake completion.
544          *
545          * @param {Object} handshake obj
546          * @api private
547          */
548
549         Socket.prototype.onHandshake = function (data) {
550           this.emit('handshake', data);
551           this.id = data.sid;
552           this.transport.query.sid = data.sid;
553           this.upgrades = this.filterUpgrades(data.upgrades);
554           this.pingInterval = data.pingInterval;
555           this.pingTimeout = data.pingTimeout;
556           this.onOpen();
557           // In case open handler closes socket
558           if ('closed' === this.readyState) return;
559           this.setPing();
560
561           // Prolong liveness of socket on heartbeat
562           this.removeListener('heartbeat', this.onHeartbeat);
563           this.on('heartbeat', this.onHeartbeat);
564         };
565
566         /**
567          * Resets ping timeout.
568          *
569          * @api private
570          */
571
572         Socket.prototype.onHeartbeat = function (timeout) {
573           clearTimeout(this.pingTimeoutTimer);
574           var self = this;
575           self.pingTimeoutTimer = setTimeout(function () {
576             if ('closed' === self.readyState) return;
577             self.onClose('ping timeout');
578           }, timeout || (self.pingInterval + self.pingTimeout));
579         };
580
581         /**
582          * Pings server every `this.pingInterval` and expects response
583          * within `this.pingTimeout` or closes connection.
584          *
585          * @api private
586          */
587
588         Socket.prototype.setPing = function () {
589           var self = this;
590           clearTimeout(self.pingIntervalTimer);
591           self.pingIntervalTimer = setTimeout(function () {
592             debug('writing ping packet - expecting pong within %sms', self.pingTimeout);
593             self.ping();
594             self.onHeartbeat(self.pingTimeout);
595           }, self.pingInterval);
596         };
597
598         /**
599         * Sends a ping packet.
600         *
601         * @api private
602         */
603
604         Socket.prototype.ping = function () {
605           var self = this;
606           this.sendPacket('ping', function () {
607             self.emit('ping');
608           });
609         };
610
611         /**
612          * Called on `drain` event
613          *
614          * @api private
615          */
616
617         Socket.prototype.onDrain = function () {
618           this.writeBuffer.splice(0, this.prevBufferLen);
619
620           // setting prevBufferLen = 0 is very important
621           // for example, when upgrading, upgrade packet is sent over,
622           // and a nonzero prevBufferLen could cause problems on `drain`
623           this.prevBufferLen = 0;
624
625           if (0 === this.writeBuffer.length) {
626             this.emit('drain');
627           } else {
628             this.flush();
629           }
630         };
631
632         /**
633          * Flush write buffers.
634          *
635          * @api private
636          */
637
638         Socket.prototype.flush = function () {
639           if ('closed' !== this.readyState && this.transport.writable &&
640             !this.upgrading && this.writeBuffer.length) {
641             debug('flushing %d packets in socket', this.writeBuffer.length);
642             this.transport.send(this.writeBuffer);
643             // keep track of current length of writeBuffer
644             // splice writeBuffer and callbackBuffer on `drain`
645             this.prevBufferLen = this.writeBuffer.length;
646             this.emit('flush');
647           }
648         };
649
650         /**
651          * Sends a message.
652          *
653          * @param {String} message.
654          * @param {Function} callback function.
655          * @param {Object} options.
656          * @return {Socket} for chaining.
657          * @api public
658          */
659
660         Socket.prototype.write =
661         Socket.prototype.send = function (msg, options, fn) {
662           this.sendPacket('message', msg, options, fn);
663           return this;
664         };
665
666         /**
667          * Sends a packet.
668          *
669          * @param {String} packet type.
670          * @param {String} data.
671          * @param {Object} options.
672          * @param {Function} callback function.
673          * @api private
674          */
675
676         Socket.prototype.sendPacket = function (type, data, options, fn) {
677           if ('function' === typeof data) {
678             fn = data;
679             data = undefined;
680           }
681
682           if ('function' === typeof options) {
683             fn = options;
684             options = null;
685           }
686
687           if ('closing' === this.readyState || 'closed' === this.readyState) {
688             return;
689           }
690
691           options = options || {};
692           options.compress = false !== options.compress;
693
694           var packet = {
695             type: type,
696             data: data,
697             options: options
698           };
699           this.emit('packetCreate', packet);
700           this.writeBuffer.push(packet);
701           if (fn) this.once('flush', fn);
702           this.flush();
703         };
704
705         /**
706          * Closes the connection.
707          *
708          * @api private
709          */
710
711         Socket.prototype.close = function () {
712           if ('opening' === this.readyState || 'open' === this.readyState) {
713             this.readyState = 'closing';
714
715             var self = this;
716
717             if (this.writeBuffer.length) {
718               this.once('drain', function () {
719                 if (this.upgrading) {
720                   waitForUpgrade();
721                 } else {
722                   close();
723                 }
724               });
725             } else if (this.upgrading) {
726               waitForUpgrade();
727             } else {
728               close();
729             }
730           }
731
732           function close () {
733             self.onClose('forced close');
734             debug('socket closing - telling transport to close');
735             self.transport.close();
736           }
737
738           function cleanupAndClose () {
739             self.removeListener('upgrade', cleanupAndClose);
740             self.removeListener('upgradeError', cleanupAndClose);
741             close();
742           }
743
744           function waitForUpgrade () {
745             // wait for upgrade to finish since we can't send packets while pausing a transport
746             self.once('upgrade', cleanupAndClose);
747             self.once('upgradeError', cleanupAndClose);
748           }
749
750           return this;
751         };
752
753         /**
754          * Called upon transport error
755          *
756          * @api private
757          */
758
759         Socket.prototype.onError = function (err) {
760           debug('socket error %j', err);
761           Socket.priorWebsocketSuccess = false;
762           this.emit('error', err);
763           this.onClose('transport error', err);
764         };
765
766         /**
767          * Called upon transport close.
768          *
769          * @api private
770          */
771
772         Socket.prototype.onClose = function (reason, desc) {
773           if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState) {
774             debug('socket close with reason: "%s"', reason);
775             var self = this;
776
777             // clear timers
778             clearTimeout(this.pingIntervalTimer);
779             clearTimeout(this.pingTimeoutTimer);
780
781             // stop event from firing again for transport
782             this.transport.removeAllListeners('close');
783
784             // ensure transport won't stay open
785             this.transport.close();
786
787             // ignore further transport communication
788             this.transport.removeAllListeners();
789
790             // set ready state
791             this.readyState = 'closed';
792
793             // clear session id
794             this.id = null;
795
796             // emit close event
797             this.emit('close', reason, desc);
798
799             // clean buffers after, so users can still
800             // grab the buffers on `close` event
801             self.writeBuffer = [];
802             self.prevBufferLen = 0;
803           }
804         };
805
806         /**
807          * Filters upgrades, returning only those matching client transports.
808          *
809          * @param {Array} server upgrades
810          * @api private
811          *
812          */
813
814         Socket.prototype.filterUpgrades = function (upgrades) {
815           var filteredUpgrades = [];
816           for (var i = 0, j = upgrades.length; i < j; i++) {
817             if (~index(this.transports, upgrades[i])) filteredUpgrades.push(upgrades[i]);
818           }
819           return filteredUpgrades;
820         };
821
822
823 /***/ },
824 /* 2 */
825 /***/ function(module, exports, __webpack_require__) {
826
827         /**
828          * Module dependencies
829          */
830
831         var XMLHttpRequest = __webpack_require__(3);
832         var XHR = __webpack_require__(6);
833         var JSONP = __webpack_require__(26);
834         var websocket = __webpack_require__(27);
835
836         /**
837          * Export transports.
838          */
839
840         exports.polling = polling;
841         exports.websocket = websocket;
842
843         /**
844          * Polling transport polymorphic constructor.
845          * Decides on xhr vs jsonp based on feature detection.
846          *
847          * @api private
848          */
849
850         function polling (opts) {
851           var xhr;
852           var xd = false;
853           var xs = false;
854           var jsonp = false !== opts.jsonp;
855
856           if (typeof location !== 'undefined') {
857             var isSSL = 'https:' === location.protocol;
858             var port = location.port;
859
860             // some user agents have empty `location.port`
861             if (!port) {
862               port = isSSL ? 443 : 80;
863             }
864
865             xd = opts.hostname !== location.hostname || port !== opts.port;
866             xs = opts.secure !== isSSL;
867           }
868
869           opts.xdomain = xd;
870           opts.xscheme = xs;
871           xhr = new XMLHttpRequest(opts);
872
873           if ('open' in xhr && !opts.forceJSONP) {
874             return new XHR(opts);
875           } else {
876             if (!jsonp) throw new Error('JSONP disabled');
877             return new JSONP(opts);
878           }
879         }
880
881
882 /***/ },
883 /* 3 */
884 /***/ function(module, exports, __webpack_require__) {
885
886         // browser shim for xmlhttprequest module
887
888         var hasCORS = __webpack_require__(4);
889         var globalThis = __webpack_require__(5);
890
891         module.exports = function (opts) {
892           var xdomain = opts.xdomain;
893
894           // scheme must be same when usign XDomainRequest
895           // http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
896           var xscheme = opts.xscheme;
897
898           // XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
899           // https://github.com/Automattic/engine.io-client/pull/217
900           var enablesXDR = opts.enablesXDR;
901
902           // XMLHttpRequest can be disabled on IE
903           try {
904             if ('undefined' !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
905               return new XMLHttpRequest();
906             }
907           } catch (e) { }
908
909           // Use XDomainRequest for IE8 if enablesXDR is true
910           // because loading bar keeps flashing when using jsonp-polling
911           // https://github.com/yujiosaka/socke.io-ie8-loading-example
912           try {
913             if ('undefined' !== typeof XDomainRequest && !xscheme && enablesXDR) {
914               return new XDomainRequest();
915             }
916           } catch (e) { }
917
918           if (!xdomain) {
919             try {
920               return new globalThis[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP');
921             } catch (e) { }
922           }
923         };
924
925
926 /***/ },
927 /* 4 */
928 /***/ function(module, exports) {
929
930         
931         /**
932          * Module exports.
933          *
934          * Logic borrowed from Modernizr:
935          *
936          *   - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js
937          */
938
939         try {
940           module.exports = typeof XMLHttpRequest !== 'undefined' &&
941             'withCredentials' in new XMLHttpRequest();
942         } catch (err) {
943           // if XMLHttp support is disabled in IE then it will throw
944           // when trying to create
945           module.exports = false;
946         }
947
948
949 /***/ },
950 /* 5 */
951 /***/ function(module, exports) {
952
953         module.exports = (function () {
954           if (typeof self !== 'undefined') {
955             return self;
956           } else if (typeof window !== 'undefined') {
957             return window;
958           } else {
959             return Function('return this')(); // eslint-disable-line no-new-func
960           }
961         })();
962
963
964 /***/ },
965 /* 6 */
966 /***/ function(module, exports, __webpack_require__) {
967
968         /* global attachEvent */
969
970         /**
971          * Module requirements.
972          */
973
974         var XMLHttpRequest = __webpack_require__(3);
975         var Polling = __webpack_require__(7);
976         var Emitter = __webpack_require__(18);
977         var inherit = __webpack_require__(20);
978         var debug = __webpack_require__(22)('engine.io-client:polling-xhr');
979         var globalThis = __webpack_require__(5);
980
981         /**
982          * Module exports.
983          */
984
985         module.exports = XHR;
986         module.exports.Request = Request;
987
988         /**
989          * Empty function
990          */
991
992         function empty () {}
993
994         /**
995          * XHR Polling constructor.
996          *
997          * @param {Object} opts
998          * @api public
999          */
1000
1001         function XHR (opts) {
1002           Polling.call(this, opts);
1003           this.requestTimeout = opts.requestTimeout;
1004           this.extraHeaders = opts.extraHeaders;
1005
1006           if (typeof location !== 'undefined') {
1007             var isSSL = 'https:' === location.protocol;
1008             var port = location.port;
1009
1010             // some user agents have empty `location.port`
1011             if (!port) {
1012               port = isSSL ? 443 : 80;
1013             }
1014
1015             this.xd = (typeof location !== 'undefined' && opts.hostname !== location.hostname) ||
1016               port !== opts.port;
1017             this.xs = opts.secure !== isSSL;
1018           }
1019         }
1020
1021         /**
1022          * Inherits from Polling.
1023          */
1024
1025         inherit(XHR, Polling);
1026
1027         /**
1028          * XHR supports binary
1029          */
1030
1031         XHR.prototype.supportsBinary = true;
1032
1033         /**
1034          * Creates a request.
1035          *
1036          * @param {String} method
1037          * @api private
1038          */
1039
1040         XHR.prototype.request = function (opts) {
1041           opts = opts || {};
1042           opts.uri = this.uri();
1043           opts.xd = this.xd;
1044           opts.xs = this.xs;
1045           opts.agent = this.agent || false;
1046           opts.supportsBinary = this.supportsBinary;
1047           opts.enablesXDR = this.enablesXDR;
1048           opts.withCredentials = this.withCredentials;
1049
1050           // SSL options for Node.js client
1051           opts.pfx = this.pfx;
1052           opts.key = this.key;
1053           opts.passphrase = this.passphrase;
1054           opts.cert = this.cert;
1055           opts.ca = this.ca;
1056           opts.ciphers = this.ciphers;
1057           opts.rejectUnauthorized = this.rejectUnauthorized;
1058           opts.requestTimeout = this.requestTimeout;
1059
1060           // other options for Node.js client
1061           opts.extraHeaders = this.extraHeaders;
1062
1063           return new Request(opts);
1064         };
1065
1066         /**
1067          * Sends data.
1068          *
1069          * @param {String} data to send.
1070          * @param {Function} called upon flush.
1071          * @api private
1072          */
1073
1074         XHR.prototype.doWrite = function (data, fn) {
1075           var isBinary = typeof data !== 'string' && data !== undefined;
1076           var req = this.request({ method: 'POST', data: data, isBinary: isBinary });
1077           var self = this;
1078           req.on('success', fn);
1079           req.on('error', function (err) {
1080             self.onError('xhr post error', err);
1081           });
1082           this.sendXhr = req;
1083         };
1084
1085         /**
1086          * Starts a poll cycle.
1087          *
1088          * @api private
1089          */
1090
1091         XHR.prototype.doPoll = function () {
1092           debug('xhr poll');
1093           var req = this.request();
1094           var self = this;
1095           req.on('data', function (data) {
1096             self.onData(data);
1097           });
1098           req.on('error', function (err) {
1099             self.onError('xhr poll error', err);
1100           });
1101           this.pollXhr = req;
1102         };
1103
1104         /**
1105          * Request constructor
1106          *
1107          * @param {Object} options
1108          * @api public
1109          */
1110
1111         function Request (opts) {
1112           this.method = opts.method || 'GET';
1113           this.uri = opts.uri;
1114           this.xd = !!opts.xd;
1115           this.xs = !!opts.xs;
1116           this.async = false !== opts.async;
1117           this.data = undefined !== opts.data ? opts.data : null;
1118           this.agent = opts.agent;
1119           this.isBinary = opts.isBinary;
1120           this.supportsBinary = opts.supportsBinary;
1121           this.enablesXDR = opts.enablesXDR;
1122           this.withCredentials = opts.withCredentials;
1123           this.requestTimeout = opts.requestTimeout;
1124
1125           // SSL options for Node.js client
1126           this.pfx = opts.pfx;
1127           this.key = opts.key;
1128           this.passphrase = opts.passphrase;
1129           this.cert = opts.cert;
1130           this.ca = opts.ca;
1131           this.ciphers = opts.ciphers;
1132           this.rejectUnauthorized = opts.rejectUnauthorized;
1133
1134           // other options for Node.js client
1135           this.extraHeaders = opts.extraHeaders;
1136
1137           this.create();
1138         }
1139
1140         /**
1141          * Mix in `Emitter`.
1142          */
1143
1144         Emitter(Request.prototype);
1145
1146         /**
1147          * Creates the XHR object and sends the request.
1148          *
1149          * @api private
1150          */
1151
1152         Request.prototype.create = function () {
1153           var opts = { agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR };
1154
1155           // SSL options for Node.js client
1156           opts.pfx = this.pfx;
1157           opts.key = this.key;
1158           opts.passphrase = this.passphrase;
1159           opts.cert = this.cert;
1160           opts.ca = this.ca;
1161           opts.ciphers = this.ciphers;
1162           opts.rejectUnauthorized = this.rejectUnauthorized;
1163
1164           var xhr = this.xhr = new XMLHttpRequest(opts);
1165           var self = this;
1166
1167           try {
1168             debug('xhr open %s: %s', this.method, this.uri);
1169             xhr.open(this.method, this.uri, this.async);
1170             try {
1171               if (this.extraHeaders) {
1172                 xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
1173                 for (var i in this.extraHeaders) {
1174                   if (this.extraHeaders.hasOwnProperty(i)) {
1175                     xhr.setRequestHeader(i, this.extraHeaders[i]);
1176                   }
1177                 }
1178               }
1179             } catch (e) {}
1180
1181             if ('POST' === this.method) {
1182               try {
1183                 if (this.isBinary) {
1184                   xhr.setRequestHeader('Content-type', 'application/octet-stream');
1185                 } else {
1186                   xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
1187                 }
1188               } catch (e) {}
1189             }
1190
1191             try {
1192               xhr.setRequestHeader('Accept', '*/*');
1193             } catch (e) {}
1194
1195             // ie6 check
1196             if ('withCredentials' in xhr) {
1197               xhr.withCredentials = this.withCredentials;
1198             }
1199
1200             if (this.requestTimeout) {
1201               xhr.timeout = this.requestTimeout;
1202             }
1203
1204             if (this.hasXDR()) {
1205               xhr.onload = function () {
1206                 self.onLoad();
1207               };
1208               xhr.onerror = function () {
1209                 self.onError(xhr.responseText);
1210               };
1211             } else {
1212               xhr.onreadystatechange = function () {
1213                 if (xhr.readyState === 2) {
1214                   try {
1215                     var contentType = xhr.getResponseHeader('Content-Type');
1216                     if (self.supportsBinary && contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') {
1217                       xhr.responseType = 'arraybuffer';
1218                     }
1219                   } catch (e) {}
1220                 }
1221                 if (4 !== xhr.readyState) return;
1222                 if (200 === xhr.status || 1223 === xhr.status) {
1223                   self.onLoad();
1224                 } else {
1225                   // make sure the `error` event handler that's user-set
1226                   // does not throw in the same tick and gets caught here
1227                   setTimeout(function () {
1228                     self.onError(typeof xhr.status === 'number' ? xhr.status : 0);
1229                   }, 0);
1230                 }
1231               };
1232             }
1233
1234             debug('xhr data %s', this.data);
1235             xhr.send(this.data);
1236           } catch (e) {
1237             // Need to defer since .create() is called directly fhrom the constructor
1238             // and thus the 'error' event can only be only bound *after* this exception
1239             // occurs.  Therefore, also, we cannot throw here at all.
1240             setTimeout(function () {
1241               self.onError(e);
1242             }, 0);
1243             return;
1244           }
1245
1246           if (typeof document !== 'undefined') {
1247             this.index = Request.requestsCount++;
1248             Request.requests[this.index] = this;
1249           }
1250         };
1251
1252         /**
1253          * Called upon successful response.
1254          *
1255          * @api private
1256          */
1257
1258         Request.prototype.onSuccess = function () {
1259           this.emit('success');
1260           this.cleanup();
1261         };
1262
1263         /**
1264          * Called if we have data.
1265          *
1266          * @api private
1267          */
1268
1269         Request.prototype.onData = function (data) {
1270           this.emit('data', data);
1271           this.onSuccess();
1272         };
1273
1274         /**
1275          * Called upon error.
1276          *
1277          * @api private
1278          */
1279
1280         Request.prototype.onError = function (err) {
1281           this.emit('error', err);
1282           this.cleanup(true);
1283         };
1284
1285         /**
1286          * Cleans up house.
1287          *
1288          * @api private
1289          */
1290
1291         Request.prototype.cleanup = function (fromError) {
1292           if ('undefined' === typeof this.xhr || null === this.xhr) {
1293             return;
1294           }
1295           // xmlhttprequest
1296           if (this.hasXDR()) {
1297             this.xhr.onload = this.xhr.onerror = empty;
1298           } else {
1299             this.xhr.onreadystatechange = empty;
1300           }
1301
1302           if (fromError) {
1303             try {
1304               this.xhr.abort();
1305             } catch (e) {}
1306           }
1307
1308           if (typeof document !== 'undefined') {
1309             delete Request.requests[this.index];
1310           }
1311
1312           this.xhr = null;
1313         };
1314
1315         /**
1316          * Called upon load.
1317          *
1318          * @api private
1319          */
1320
1321         Request.prototype.onLoad = function () {
1322           var data;
1323           try {
1324             var contentType;
1325             try {
1326               contentType = this.xhr.getResponseHeader('Content-Type');
1327             } catch (e) {}
1328             if (contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') {
1329               data = this.xhr.response || this.xhr.responseText;
1330             } else {
1331               data = this.xhr.responseText;
1332             }
1333           } catch (e) {
1334             this.onError(e);
1335           }
1336           if (null != data) {
1337             this.onData(data);
1338           }
1339         };
1340
1341         /**
1342          * Check if it has XDomainRequest.
1343          *
1344          * @api private
1345          */
1346
1347         Request.prototype.hasXDR = function () {
1348           return typeof XDomainRequest !== 'undefined' && !this.xs && this.enablesXDR;
1349         };
1350
1351         /**
1352          * Aborts the request.
1353          *
1354          * @api public
1355          */
1356
1357         Request.prototype.abort = function () {
1358           this.cleanup();
1359         };
1360
1361         /**
1362          * Aborts pending requests when unloading the window. This is needed to prevent
1363          * memory leaks (e.g. when using IE) and to ensure that no spurious error is
1364          * emitted.
1365          */
1366
1367         Request.requestsCount = 0;
1368         Request.requests = {};
1369
1370         if (typeof document !== 'undefined') {
1371           if (typeof attachEvent === 'function') {
1372             attachEvent('onunload', unloadHandler);
1373           } else if (typeof addEventListener === 'function') {
1374             var terminationEvent = 'onpagehide' in globalThis ? 'pagehide' : 'unload';
1375             addEventListener(terminationEvent, unloadHandler, false);
1376           }
1377         }
1378
1379         function unloadHandler () {
1380           for (var i in Request.requests) {
1381             if (Request.requests.hasOwnProperty(i)) {
1382               Request.requests[i].abort();
1383             }
1384           }
1385         }
1386
1387
1388 /***/ },
1389 /* 7 */
1390 /***/ function(module, exports, __webpack_require__) {
1391
1392         /**
1393          * Module dependencies.
1394          */
1395
1396         var Transport = __webpack_require__(8);
1397         var parseqs = __webpack_require__(19);
1398         var parser = __webpack_require__(9);
1399         var inherit = __webpack_require__(20);
1400         var yeast = __webpack_require__(21);
1401         var debug = __webpack_require__(22)('engine.io-client:polling');
1402
1403         /**
1404          * Module exports.
1405          */
1406
1407         module.exports = Polling;
1408
1409         /**
1410          * Is XHR2 supported?
1411          */
1412
1413         var hasXHR2 = (function () {
1414           var XMLHttpRequest = __webpack_require__(3);
1415           var xhr = new XMLHttpRequest({ xdomain: false });
1416           return null != xhr.responseType;
1417         })();
1418
1419         /**
1420          * Polling interface.
1421          *
1422          * @param {Object} opts
1423          * @api private
1424          */
1425
1426         function Polling (opts) {
1427           var forceBase64 = (opts && opts.forceBase64);
1428           if (!hasXHR2 || forceBase64) {
1429             this.supportsBinary = false;
1430           }
1431           Transport.call(this, opts);
1432         }
1433
1434         /**
1435          * Inherits from Transport.
1436          */
1437
1438         inherit(Polling, Transport);
1439
1440         /**
1441          * Transport name.
1442          */
1443
1444         Polling.prototype.name = 'polling';
1445
1446         /**
1447          * Opens the socket (triggers polling). We write a PING message to determine
1448          * when the transport is open.
1449          *
1450          * @api private
1451          */
1452
1453         Polling.prototype.doOpen = function () {
1454           this.poll();
1455         };
1456
1457         /**
1458          * Pauses polling.
1459          *
1460          * @param {Function} callback upon buffers are flushed and transport is paused
1461          * @api private
1462          */
1463
1464         Polling.prototype.pause = function (onPause) {
1465           var self = this;
1466
1467           this.readyState = 'pausing';
1468
1469           function pause () {
1470             debug('paused');
1471             self.readyState = 'paused';
1472             onPause();
1473           }
1474
1475           if (this.polling || !this.writable) {
1476             var total = 0;
1477
1478             if (this.polling) {
1479               debug('we are currently polling - waiting to pause');
1480               total++;
1481               this.once('pollComplete', function () {
1482                 debug('pre-pause polling complete');
1483                 --total || pause();
1484               });
1485             }
1486
1487             if (!this.writable) {
1488               debug('we are currently writing - waiting to pause');
1489               total++;
1490               this.once('drain', function () {
1491                 debug('pre-pause writing complete');
1492                 --total || pause();
1493               });
1494             }
1495           } else {
1496             pause();
1497           }
1498         };
1499
1500         /**
1501          * Starts polling cycle.
1502          *
1503          * @api public
1504          */
1505
1506         Polling.prototype.poll = function () {
1507           debug('polling');
1508           this.polling = true;
1509           this.doPoll();
1510           this.emit('poll');
1511         };
1512
1513         /**
1514          * Overloads onData to detect payloads.
1515          *
1516          * @api private
1517          */
1518
1519         Polling.prototype.onData = function (data) {
1520           var self = this;
1521           debug('polling got data %s', data);
1522           var callback = function (packet, index, total) {
1523             // if its the first message we consider the transport open
1524             if ('opening' === self.readyState && packet.type === 'open') {
1525               self.onOpen();
1526             }
1527
1528             // if its a close packet, we close the ongoing requests
1529             if ('close' === packet.type) {
1530               self.onClose();
1531               return false;
1532             }
1533
1534             // otherwise bypass onData and handle the message
1535             self.onPacket(packet);
1536           };
1537
1538           // decode payload
1539           parser.decodePayload(data, this.socket.binaryType, callback);
1540
1541           // if an event did not trigger closing
1542           if ('closed' !== this.readyState) {
1543             // if we got data we're not polling
1544             this.polling = false;
1545             this.emit('pollComplete');
1546
1547             if ('open' === this.readyState) {
1548               this.poll();
1549             } else {
1550               debug('ignoring poll - transport state "%s"', this.readyState);
1551             }
1552           }
1553         };
1554
1555         /**
1556          * For polling, send a close packet.
1557          *
1558          * @api private
1559          */
1560
1561         Polling.prototype.doClose = function () {
1562           var self = this;
1563
1564           function close () {
1565             debug('writing close packet');
1566             self.write([{ type: 'close' }]);
1567           }
1568
1569           if ('open' === this.readyState) {
1570             debug('transport open - closing');
1571             close();
1572           } else {
1573             // in case we're trying to close while
1574             // handshaking is in progress (GH-164)
1575             debug('transport not open - deferring close');
1576             this.once('open', close);
1577           }
1578         };
1579
1580         /**
1581          * Writes a packets payload.
1582          *
1583          * @param {Array} data packets
1584          * @param {Function} drain callback
1585          * @api private
1586          */
1587
1588         Polling.prototype.write = function (packets) {
1589           var self = this;
1590           this.writable = false;
1591           var callbackfn = function () {
1592             self.writable = true;
1593             self.emit('drain');
1594           };
1595
1596           parser.encodePayload(packets, this.supportsBinary, function (data) {
1597             self.doWrite(data, callbackfn);
1598           });
1599         };
1600
1601         /**
1602          * Generates uri for connection.
1603          *
1604          * @api private
1605          */
1606
1607         Polling.prototype.uri = function () {
1608           var query = this.query || {};
1609           var schema = this.secure ? 'https' : 'http';
1610           var port = '';
1611
1612           // cache busting is forced
1613           if (false !== this.timestampRequests) {
1614             query[this.timestampParam] = yeast();
1615           }
1616
1617           if (!this.supportsBinary && !query.sid) {
1618             query.b64 = 1;
1619           }
1620
1621           query = parseqs.encode(query);
1622
1623           // avoid port if default for schema
1624           if (this.port && (('https' === schema && Number(this.port) !== 443) ||
1625              ('http' === schema && Number(this.port) !== 80))) {
1626             port = ':' + this.port;
1627           }
1628
1629           // prepend ? to query
1630           if (query.length) {
1631             query = '?' + query;
1632           }
1633
1634           var ipv6 = this.hostname.indexOf(':') !== -1;
1635           return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
1636         };
1637
1638
1639 /***/ },
1640 /* 8 */
1641 /***/ function(module, exports, __webpack_require__) {
1642
1643         /**
1644          * Module dependencies.
1645          */
1646
1647         var parser = __webpack_require__(9);
1648         var Emitter = __webpack_require__(18);
1649
1650         /**
1651          * Module exports.
1652          */
1653
1654         module.exports = Transport;
1655
1656         /**
1657          * Transport abstract constructor.
1658          *
1659          * @param {Object} options.
1660          * @api private
1661          */
1662
1663         function Transport (opts) {
1664           this.path = opts.path;
1665           this.hostname = opts.hostname;
1666           this.port = opts.port;
1667           this.secure = opts.secure;
1668           this.query = opts.query;
1669           this.timestampParam = opts.timestampParam;
1670           this.timestampRequests = opts.timestampRequests;
1671           this.readyState = '';
1672           this.agent = opts.agent || false;
1673           this.socket = opts.socket;
1674           this.enablesXDR = opts.enablesXDR;
1675           this.withCredentials = opts.withCredentials;
1676
1677           // SSL options for Node.js client
1678           this.pfx = opts.pfx;
1679           this.key = opts.key;
1680           this.passphrase = opts.passphrase;
1681           this.cert = opts.cert;
1682           this.ca = opts.ca;
1683           this.ciphers = opts.ciphers;
1684           this.rejectUnauthorized = opts.rejectUnauthorized;
1685           this.forceNode = opts.forceNode;
1686
1687           // results of ReactNative environment detection
1688           this.isReactNative = opts.isReactNative;
1689
1690           // other options for Node.js client
1691           this.extraHeaders = opts.extraHeaders;
1692           this.localAddress = opts.localAddress;
1693         }
1694
1695         /**
1696          * Mix in `Emitter`.
1697          */
1698
1699         Emitter(Transport.prototype);
1700
1701         /**
1702          * Emits an error.
1703          *
1704          * @param {String} str
1705          * @return {Transport} for chaining
1706          * @api public
1707          */
1708
1709         Transport.prototype.onError = function (msg, desc) {
1710           var err = new Error(msg);
1711           err.type = 'TransportError';
1712           err.description = desc;
1713           this.emit('error', err);
1714           return this;
1715         };
1716
1717         /**
1718          * Opens the transport.
1719          *
1720          * @api public
1721          */
1722
1723         Transport.prototype.open = function () {
1724           if ('closed' === this.readyState || '' === this.readyState) {
1725             this.readyState = 'opening';
1726             this.doOpen();
1727           }
1728
1729           return this;
1730         };
1731
1732         /**
1733          * Closes the transport.
1734          *
1735          * @api private
1736          */
1737
1738         Transport.prototype.close = function () {
1739           if ('opening' === this.readyState || 'open' === this.readyState) {
1740             this.doClose();
1741             this.onClose();
1742           }
1743
1744           return this;
1745         };
1746
1747         /**
1748          * Sends multiple packets.
1749          *
1750          * @param {Array} packets
1751          * @api private
1752          */
1753
1754         Transport.prototype.send = function (packets) {
1755           if ('open' === this.readyState) {
1756             this.write(packets);
1757           } else {
1758             throw new Error('Transport not open');
1759           }
1760         };
1761
1762         /**
1763          * Called upon open
1764          *
1765          * @api private
1766          */
1767
1768         Transport.prototype.onOpen = function () {
1769           this.readyState = 'open';
1770           this.writable = true;
1771           this.emit('open');
1772         };
1773
1774         /**
1775          * Called with data.
1776          *
1777          * @param {String} data
1778          * @api private
1779          */
1780
1781         Transport.prototype.onData = function (data) {
1782           var packet = parser.decodePacket(data, this.socket.binaryType);
1783           this.onPacket(packet);
1784         };
1785
1786         /**
1787          * Called with a decoded packet.
1788          */
1789
1790         Transport.prototype.onPacket = function (packet) {
1791           this.emit('packet', packet);
1792         };
1793
1794         /**
1795          * Called upon close.
1796          *
1797          * @api private
1798          */
1799
1800         Transport.prototype.onClose = function () {
1801           this.readyState = 'closed';
1802           this.emit('close');
1803         };
1804
1805
1806 /***/ },
1807 /* 9 */
1808 /***/ function(module, exports, __webpack_require__) {
1809
1810         /**
1811          * Module dependencies.
1812          */
1813
1814         var keys = __webpack_require__(10);
1815         var hasBinary = __webpack_require__(11);
1816         var sliceBuffer = __webpack_require__(13);
1817         var after = __webpack_require__(14);
1818         var utf8 = __webpack_require__(15);
1819
1820         var base64encoder;
1821         if (typeof ArrayBuffer !== 'undefined') {
1822           base64encoder = __webpack_require__(16);
1823         }
1824
1825         /**
1826          * Check if we are running an android browser. That requires us to use
1827          * ArrayBuffer with polling transports...
1828          *
1829          * http://ghinda.net/jpeg-blob-ajax-android/
1830          */
1831
1832         var isAndroid = typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent);
1833
1834         /**
1835          * Check if we are running in PhantomJS.
1836          * Uploading a Blob with PhantomJS does not work correctly, as reported here:
1837          * https://github.com/ariya/phantomjs/issues/11395
1838          * @type boolean
1839          */
1840         var isPhantomJS = typeof navigator !== 'undefined' && /PhantomJS/i.test(navigator.userAgent);
1841
1842         /**
1843          * When true, avoids using Blobs to encode payloads.
1844          * @type boolean
1845          */
1846         var dontSendBlobs = isAndroid || isPhantomJS;
1847
1848         /**
1849          * Current protocol version.
1850          */
1851
1852         exports.protocol = 3;
1853
1854         /**
1855          * Packet types.
1856          */
1857
1858         var packets = exports.packets = {
1859             open:     0    // non-ws
1860           , close:    1    // non-ws
1861           , ping:     2
1862           , pong:     3
1863           , message:  4
1864           , upgrade:  5
1865           , noop:     6
1866         };
1867
1868         var packetslist = keys(packets);
1869
1870         /**
1871          * Premade error packet.
1872          */
1873
1874         var err = { type: 'error', data: 'parser error' };
1875
1876         /**
1877          * Create a blob api even for blob builder when vendor prefixes exist
1878          */
1879
1880         var Blob = __webpack_require__(17);
1881
1882         /**
1883          * Encodes a packet.
1884          *
1885          *     <packet type id> [ <data> ]
1886          *
1887          * Example:
1888          *
1889          *     5hello world
1890          *     3
1891          *     4
1892          *
1893          * Binary is encoded in an identical principle
1894          *
1895          * @api private
1896          */
1897
1898         exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
1899           if (typeof supportsBinary === 'function') {
1900             callback = supportsBinary;
1901             supportsBinary = false;
1902           }
1903
1904           if (typeof utf8encode === 'function') {
1905             callback = utf8encode;
1906             utf8encode = null;
1907           }
1908
1909           var data = (packet.data === undefined)
1910             ? undefined
1911             : packet.data.buffer || packet.data;
1912
1913           if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) {
1914             return encodeArrayBuffer(packet, supportsBinary, callback);
1915           } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
1916             return encodeBlob(packet, supportsBinary, callback);
1917           }
1918
1919           // might be an object with { base64: true, data: dataAsBase64String }
1920           if (data && data.base64) {
1921             return encodeBase64Object(packet, callback);
1922           }
1923
1924           // Sending data as a utf-8 string
1925           var encoded = packets[packet.type];
1926
1927           // data fragment is optional
1928           if (undefined !== packet.data) {
1929             encoded += utf8encode ? utf8.encode(String(packet.data), { strict: false }) : String(packet.data);
1930           }
1931
1932           return callback('' + encoded);
1933
1934         };
1935
1936         function encodeBase64Object(packet, callback) {
1937           // packet data is an object { base64: true, data: dataAsBase64String }
1938           var message = 'b' + exports.packets[packet.type] + packet.data.data;
1939           return callback(message);
1940         }
1941
1942         /**
1943          * Encode packet helpers for binary types
1944          */
1945
1946         function encodeArrayBuffer(packet, supportsBinary, callback) {
1947           if (!supportsBinary) {
1948             return exports.encodeBase64Packet(packet, callback);
1949           }
1950
1951           var data = packet.data;
1952           var contentArray = new Uint8Array(data);
1953           var resultBuffer = new Uint8Array(1 + data.byteLength);
1954
1955           resultBuffer[0] = packets[packet.type];
1956           for (var i = 0; i < contentArray.length; i++) {
1957             resultBuffer[i+1] = contentArray[i];
1958           }
1959
1960           return callback(resultBuffer.buffer);
1961         }
1962
1963         function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) {
1964           if (!supportsBinary) {
1965             return exports.encodeBase64Packet(packet, callback);
1966           }
1967
1968           var fr = new FileReader();
1969           fr.onload = function() {
1970             exports.encodePacket({ type: packet.type, data: fr.result }, supportsBinary, true, callback);
1971           };
1972           return fr.readAsArrayBuffer(packet.data);
1973         }
1974
1975         function encodeBlob(packet, supportsBinary, callback) {
1976           if (!supportsBinary) {
1977             return exports.encodeBase64Packet(packet, callback);
1978           }
1979
1980           if (dontSendBlobs) {
1981             return encodeBlobAsArrayBuffer(packet, supportsBinary, callback);
1982           }
1983
1984           var length = new Uint8Array(1);
1985           length[0] = packets[packet.type];
1986           var blob = new Blob([length.buffer, packet.data]);
1987
1988           return callback(blob);
1989         }
1990
1991         /**
1992          * Encodes a packet with binary data in a base64 string
1993          *
1994          * @param {Object} packet, has `type` and `data`
1995          * @return {String} base64 encoded message
1996          */
1997
1998         exports.encodeBase64Packet = function(packet, callback) {
1999           var message = 'b' + exports.packets[packet.type];
2000           if (typeof Blob !== 'undefined' && packet.data instanceof Blob) {
2001             var fr = new FileReader();
2002             fr.onload = function() {
2003               var b64 = fr.result.split(',')[1];
2004               callback(message + b64);
2005             };
2006             return fr.readAsDataURL(packet.data);
2007           }
2008
2009           var b64data;
2010           try {
2011             b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data));
2012           } catch (e) {
2013             // iPhone Safari doesn't let you apply with typed arrays
2014             var typed = new Uint8Array(packet.data);
2015             var basic = new Array(typed.length);
2016             for (var i = 0; i < typed.length; i++) {
2017               basic[i] = typed[i];
2018             }
2019             b64data = String.fromCharCode.apply(null, basic);
2020           }
2021           message += btoa(b64data);
2022           return callback(message);
2023         };
2024
2025         /**
2026          * Decodes a packet. Changes format to Blob if requested.
2027          *
2028          * @return {Object} with `type` and `data` (if any)
2029          * @api private
2030          */
2031
2032         exports.decodePacket = function (data, binaryType, utf8decode) {
2033           if (data === undefined) {
2034             return err;
2035           }
2036           // String data
2037           if (typeof data === 'string') {
2038             if (data.charAt(0) === 'b') {
2039               return exports.decodeBase64Packet(data.substr(1), binaryType);
2040             }
2041
2042             if (utf8decode) {
2043               data = tryDecode(data);
2044               if (data === false) {
2045                 return err;
2046               }
2047             }
2048             var type = data.charAt(0);
2049
2050             if (Number(type) != type || !packetslist[type]) {
2051               return err;
2052             }
2053
2054             if (data.length > 1) {
2055               return { type: packetslist[type], data: data.substring(1) };
2056             } else {
2057               return { type: packetslist[type] };
2058             }
2059           }
2060
2061           var asArray = new Uint8Array(data);
2062           var type = asArray[0];
2063           var rest = sliceBuffer(data, 1);
2064           if (Blob && binaryType === 'blob') {
2065             rest = new Blob([rest]);
2066           }
2067           return { type: packetslist[type], data: rest };
2068         };
2069
2070         function tryDecode(data) {
2071           try {
2072             data = utf8.decode(data, { strict: false });
2073           } catch (e) {
2074             return false;
2075           }
2076           return data;
2077         }
2078
2079         /**
2080          * Decodes a packet encoded in a base64 string
2081          *
2082          * @param {String} base64 encoded message
2083          * @return {Object} with `type` and `data` (if any)
2084          */
2085
2086         exports.decodeBase64Packet = function(msg, binaryType) {
2087           var type = packetslist[msg.charAt(0)];
2088           if (!base64encoder) {
2089             return { type: type, data: { base64: true, data: msg.substr(1) } };
2090           }
2091
2092           var data = base64encoder.decode(msg.substr(1));
2093
2094           if (binaryType === 'blob' && Blob) {
2095             data = new Blob([data]);
2096           }
2097
2098           return { type: type, data: data };
2099         };
2100
2101         /**
2102          * Encodes multiple messages (payload).
2103          *
2104          *     <length>:data
2105          *
2106          * Example:
2107          *
2108          *     11:hello world2:hi
2109          *
2110          * If any contents are binary, they will be encoded as base64 strings. Base64
2111          * encoded strings are marked with a b before the length specifier
2112          *
2113          * @param {Array} packets
2114          * @api private
2115          */
2116
2117         exports.encodePayload = function (packets, supportsBinary, callback) {
2118           if (typeof supportsBinary === 'function') {
2119             callback = supportsBinary;
2120             supportsBinary = null;
2121           }
2122
2123           var isBinary = hasBinary(packets);
2124
2125           if (supportsBinary && isBinary) {
2126             if (Blob && !dontSendBlobs) {
2127               return exports.encodePayloadAsBlob(packets, callback);
2128             }
2129
2130             return exports.encodePayloadAsArrayBuffer(packets, callback);
2131           }
2132
2133           if (!packets.length) {
2134             return callback('0:');
2135           }
2136
2137           function setLengthHeader(message) {
2138             return message.length + ':' + message;
2139           }
2140
2141           function encodeOne(packet, doneCallback) {
2142             exports.encodePacket(packet, !isBinary ? false : supportsBinary, false, function(message) {
2143               doneCallback(null, setLengthHeader(message));
2144             });
2145           }
2146
2147           map(packets, encodeOne, function(err, results) {
2148             return callback(results.join(''));
2149           });
2150         };
2151
2152         /**
2153          * Async array map using after
2154          */
2155
2156         function map(ary, each, done) {
2157           var result = new Array(ary.length);
2158           var next = after(ary.length, done);
2159
2160           var eachWithIndex = function(i, el, cb) {
2161             each(el, function(error, msg) {
2162               result[i] = msg;
2163               cb(error, result);
2164             });
2165           };
2166
2167           for (var i = 0; i < ary.length; i++) {
2168             eachWithIndex(i, ary[i], next);
2169           }
2170         }
2171
2172         /*
2173          * Decodes data when a payload is maybe expected. Possible binary contents are
2174          * decoded from their base64 representation
2175          *
2176          * @param {String} data, callback method
2177          * @api public
2178          */
2179
2180         exports.decodePayload = function (data, binaryType, callback) {
2181           if (typeof data !== 'string') {
2182             return exports.decodePayloadAsBinary(data, binaryType, callback);
2183           }
2184
2185           if (typeof binaryType === 'function') {
2186             callback = binaryType;
2187             binaryType = null;
2188           }
2189
2190           var packet;
2191           if (data === '') {
2192             // parser error - ignoring payload
2193             return callback(err, 0, 1);
2194           }
2195
2196           var length = '', n, msg;
2197
2198           for (var i = 0, l = data.length; i < l; i++) {
2199             var chr = data.charAt(i);
2200
2201             if (chr !== ':') {
2202               length += chr;
2203               continue;
2204             }
2205
2206             if (length === '' || (length != (n = Number(length)))) {
2207               // parser error - ignoring payload
2208               return callback(err, 0, 1);
2209             }
2210
2211             msg = data.substr(i + 1, n);
2212
2213             if (length != msg.length) {
2214               // parser error - ignoring payload
2215               return callback(err, 0, 1);
2216             }
2217
2218             if (msg.length) {
2219               packet = exports.decodePacket(msg, binaryType, false);
2220
2221               if (err.type === packet.type && err.data === packet.data) {
2222                 // parser error in individual packet - ignoring payload
2223                 return callback(err, 0, 1);
2224               }
2225
2226               var ret = callback(packet, i + n, l);
2227               if (false === ret) return;
2228             }
2229
2230             // advance cursor
2231             i += n;
2232             length = '';
2233           }
2234
2235           if (length !== '') {
2236             // parser error - ignoring payload
2237             return callback(err, 0, 1);
2238           }
2239
2240         };
2241
2242         /**
2243          * Encodes multiple messages (payload) as binary.
2244          *
2245          * <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number
2246          * 255><data>
2247          *
2248          * Example:
2249          * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers
2250          *
2251          * @param {Array} packets
2252          * @return {ArrayBuffer} encoded payload
2253          * @api private
2254          */
2255
2256         exports.encodePayloadAsArrayBuffer = function(packets, callback) {
2257           if (!packets.length) {
2258             return callback(new ArrayBuffer(0));
2259           }
2260
2261           function encodeOne(packet, doneCallback) {
2262             exports.encodePacket(packet, true, true, function(data) {
2263               return doneCallback(null, data);
2264             });
2265           }
2266
2267           map(packets, encodeOne, function(err, encodedPackets) {
2268             var totalLength = encodedPackets.reduce(function(acc, p) {
2269               var len;
2270               if (typeof p === 'string'){
2271                 len = p.length;
2272               } else {
2273                 len = p.byteLength;
2274               }
2275               return acc + len.toString().length + len + 2; // string/binary identifier + separator = 2
2276             }, 0);
2277
2278             var resultArray = new Uint8Array(totalLength);
2279
2280             var bufferIndex = 0;
2281             encodedPackets.forEach(function(p) {
2282               var isString = typeof p === 'string';
2283               var ab = p;
2284               if (isString) {
2285                 var view = new Uint8Array(p.length);
2286                 for (var i = 0; i < p.length; i++) {
2287                   view[i] = p.charCodeAt(i);
2288                 }
2289                 ab = view.buffer;
2290               }
2291
2292               if (isString) { // not true binary
2293                 resultArray[bufferIndex++] = 0;
2294               } else { // true binary
2295                 resultArray[bufferIndex++] = 1;
2296               }
2297
2298               var lenStr = ab.byteLength.toString();
2299               for (var i = 0; i < lenStr.length; i++) {
2300                 resultArray[bufferIndex++] = parseInt(lenStr[i]);
2301               }
2302               resultArray[bufferIndex++] = 255;
2303
2304               var view = new Uint8Array(ab);
2305               for (var i = 0; i < view.length; i++) {
2306                 resultArray[bufferIndex++] = view[i];
2307               }
2308             });
2309
2310             return callback(resultArray.buffer);
2311           });
2312         };
2313
2314         /**
2315          * Encode as Blob
2316          */
2317
2318         exports.encodePayloadAsBlob = function(packets, callback) {
2319           function encodeOne(packet, doneCallback) {
2320             exports.encodePacket(packet, true, true, function(encoded) {
2321               var binaryIdentifier = new Uint8Array(1);
2322               binaryIdentifier[0] = 1;
2323               if (typeof encoded === 'string') {
2324                 var view = new Uint8Array(encoded.length);
2325                 for (var i = 0; i < encoded.length; i++) {
2326                   view[i] = encoded.charCodeAt(i);
2327                 }
2328                 encoded = view.buffer;
2329                 binaryIdentifier[0] = 0;
2330               }
2331
2332               var len = (encoded instanceof ArrayBuffer)
2333                 ? encoded.byteLength
2334                 : encoded.size;
2335
2336               var lenStr = len.toString();
2337               var lengthAry = new Uint8Array(lenStr.length + 1);
2338               for (var i = 0; i < lenStr.length; i++) {
2339                 lengthAry[i] = parseInt(lenStr[i]);
2340               }
2341               lengthAry[lenStr.length] = 255;
2342
2343               if (Blob) {
2344                 var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]);
2345                 doneCallback(null, blob);
2346               }
2347             });
2348           }
2349
2350           map(packets, encodeOne, function(err, results) {
2351             return callback(new Blob(results));
2352           });
2353         };
2354
2355         /*
2356          * Decodes data when a payload is maybe expected. Strings are decoded by
2357          * interpreting each byte as a key code for entries marked to start with 0. See
2358          * description of encodePayloadAsBinary
2359          *
2360          * @param {ArrayBuffer} data, callback method
2361          * @api public
2362          */
2363
2364         exports.decodePayloadAsBinary = function (data, binaryType, callback) {
2365           if (typeof binaryType === 'function') {
2366             callback = binaryType;
2367             binaryType = null;
2368           }
2369
2370           var bufferTail = data;
2371           var buffers = [];
2372
2373           while (bufferTail.byteLength > 0) {
2374             var tailArray = new Uint8Array(bufferTail);
2375             var isString = tailArray[0] === 0;
2376             var msgLength = '';
2377
2378             for (var i = 1; ; i++) {
2379               if (tailArray[i] === 255) break;
2380
2381               // 310 = char length of Number.MAX_VALUE
2382               if (msgLength.length > 310) {
2383                 return callback(err, 0, 1);
2384               }
2385
2386               msgLength += tailArray[i];
2387             }
2388
2389             bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length);
2390             msgLength = parseInt(msgLength);
2391
2392             var msg = sliceBuffer(bufferTail, 0, msgLength);
2393             if (isString) {
2394               try {
2395                 msg = String.fromCharCode.apply(null, new Uint8Array(msg));
2396               } catch (e) {
2397                 // iPhone Safari doesn't let you apply to typed arrays
2398                 var typed = new Uint8Array(msg);
2399                 msg = '';
2400                 for (var i = 0; i < typed.length; i++) {
2401                   msg += String.fromCharCode(typed[i]);
2402                 }
2403               }
2404             }
2405
2406             buffers.push(msg);
2407             bufferTail = sliceBuffer(bufferTail, msgLength);
2408           }
2409
2410           var total = buffers.length;
2411           buffers.forEach(function(buffer, i) {
2412             callback(exports.decodePacket(buffer, binaryType, true), i, total);
2413           });
2414         };
2415
2416
2417 /***/ },
2418 /* 10 */
2419 /***/ function(module, exports) {
2420
2421         
2422         /**
2423          * Gets the keys for an object.
2424          *
2425          * @return {Array} keys
2426          * @api private
2427          */
2428
2429         module.exports = Object.keys || function keys (obj){
2430           var arr = [];
2431           var has = Object.prototype.hasOwnProperty;
2432
2433           for (var i in obj) {
2434             if (has.call(obj, i)) {
2435               arr.push(i);
2436             }
2437           }
2438           return arr;
2439         };
2440
2441
2442 /***/ },
2443 /* 11 */
2444 /***/ function(module, exports, __webpack_require__) {
2445
2446         /* global Blob File */
2447
2448         /*
2449          * Module requirements.
2450          */
2451
2452         var isArray = __webpack_require__(12);
2453
2454         var toString = Object.prototype.toString;
2455         var withNativeBlob = typeof Blob === 'function' ||
2456                                 typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]';
2457         var withNativeFile = typeof File === 'function' ||
2458                                 typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]';
2459
2460         /**
2461          * Module exports.
2462          */
2463
2464         module.exports = hasBinary;
2465
2466         /**
2467          * Checks for binary data.
2468          *
2469          * Supports Buffer, ArrayBuffer, Blob and File.
2470          *
2471          * @param {Object} anything
2472          * @api public
2473          */
2474
2475         function hasBinary (obj) {
2476           if (!obj || typeof obj !== 'object') {
2477             return false;
2478           }
2479
2480           if (isArray(obj)) {
2481             for (var i = 0, l = obj.length; i < l; i++) {
2482               if (hasBinary(obj[i])) {
2483                 return true;
2484               }
2485             }
2486             return false;
2487           }
2488
2489           if ((typeof Buffer === 'function' && Buffer.isBuffer && Buffer.isBuffer(obj)) ||
2490             (typeof ArrayBuffer === 'function' && obj instanceof ArrayBuffer) ||
2491             (withNativeBlob && obj instanceof Blob) ||
2492             (withNativeFile && obj instanceof File)
2493           ) {
2494             return true;
2495           }
2496
2497           // see: https://github.com/Automattic/has-binary/pull/4
2498           if (obj.toJSON && typeof obj.toJSON === 'function' && arguments.length === 1) {
2499             return hasBinary(obj.toJSON(), true);
2500           }
2501
2502           for (var key in obj) {
2503             if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
2504               return true;
2505             }
2506           }
2507
2508           return false;
2509         }
2510
2511
2512 /***/ },
2513 /* 12 */
2514 /***/ function(module, exports) {
2515
2516         var toString = {}.toString;
2517
2518         module.exports = Array.isArray || function (arr) {
2519           return toString.call(arr) == '[object Array]';
2520         };
2521
2522
2523 /***/ },
2524 /* 13 */
2525 /***/ function(module, exports) {
2526
2527         /**
2528          * An abstraction for slicing an arraybuffer even when
2529          * ArrayBuffer.prototype.slice is not supported
2530          *
2531          * @api public
2532          */
2533
2534         module.exports = function(arraybuffer, start, end) {
2535           var bytes = arraybuffer.byteLength;
2536           start = start || 0;
2537           end = end || bytes;
2538
2539           if (arraybuffer.slice) { return arraybuffer.slice(start, end); }
2540
2541           if (start < 0) { start += bytes; }
2542           if (end < 0) { end += bytes; }
2543           if (end > bytes) { end = bytes; }
2544
2545           if (start >= bytes || start >= end || bytes === 0) {
2546             return new ArrayBuffer(0);
2547           }
2548
2549           var abv = new Uint8Array(arraybuffer);
2550           var result = new Uint8Array(end - start);
2551           for (var i = start, ii = 0; i < end; i++, ii++) {
2552             result[ii] = abv[i];
2553           }
2554           return result.buffer;
2555         };
2556
2557
2558 /***/ },
2559 /* 14 */
2560 /***/ function(module, exports) {
2561
2562         module.exports = after
2563
2564         function after(count, callback, err_cb) {
2565             var bail = false
2566             err_cb = err_cb || noop
2567             proxy.count = count
2568
2569             return (count === 0) ? callback() : proxy
2570
2571             function proxy(err, result) {
2572                 if (proxy.count <= 0) {
2573                     throw new Error('after called too many times')
2574                 }
2575                 --proxy.count
2576
2577                 // after first error, rest are passed to err_cb
2578                 if (err) {
2579                     bail = true
2580                     callback(err)
2581                     // future error callbacks will go to error handler
2582                     callback = err_cb
2583                 } else if (proxy.count === 0 && !bail) {
2584                     callback(null, result)
2585                 }
2586             }
2587         }
2588
2589         function noop() {}
2590
2591
2592 /***/ },
2593 /* 15 */
2594 /***/ function(module, exports) {
2595
2596         /*! https://mths.be/utf8js v2.1.2 by @mathias */
2597
2598         var stringFromCharCode = String.fromCharCode;
2599
2600         // Taken from https://mths.be/punycode
2601         function ucs2decode(string) {
2602                 var output = [];
2603                 var counter = 0;
2604                 var length = string.length;
2605                 var value;
2606                 var extra;
2607                 while (counter < length) {
2608                         value = string.charCodeAt(counter++);
2609                         if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
2610                                 // high surrogate, and there is a next character
2611                                 extra = string.charCodeAt(counter++);
2612                                 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
2613                                         output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
2614                                 } else {
2615                                         // unmatched surrogate; only append this code unit, in case the next
2616                                         // code unit is the high surrogate of a surrogate pair
2617                                         output.push(value);
2618                                         counter--;
2619                                 }
2620                         } else {
2621                                 output.push(value);
2622                         }
2623                 }
2624                 return output;
2625         }
2626
2627         // Taken from https://mths.be/punycode
2628         function ucs2encode(array) {
2629                 var length = array.length;
2630                 var index = -1;
2631                 var value;
2632                 var output = '';
2633                 while (++index < length) {
2634                         value = array[index];
2635                         if (value > 0xFFFF) {
2636                                 value -= 0x10000;
2637                                 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
2638                                 value = 0xDC00 | value & 0x3FF;
2639                         }
2640                         output += stringFromCharCode(value);
2641                 }
2642                 return output;
2643         }
2644
2645         function checkScalarValue(codePoint, strict) {
2646                 if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
2647                         if (strict) {
2648                                 throw Error(
2649                                         'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
2650                                         ' is not a scalar value'
2651                                 );
2652                         }
2653                         return false;
2654                 }
2655                 return true;
2656         }
2657         /*--------------------------------------------------------------------------*/
2658
2659         function createByte(codePoint, shift) {
2660                 return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
2661         }
2662
2663         function encodeCodePoint(codePoint, strict) {
2664                 if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
2665                         return stringFromCharCode(codePoint);
2666                 }
2667                 var symbol = '';
2668                 if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
2669                         symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
2670                 }
2671                 else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
2672                         if (!checkScalarValue(codePoint, strict)) {
2673                                 codePoint = 0xFFFD;
2674                         }
2675                         symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
2676                         symbol += createByte(codePoint, 6);
2677                 }
2678                 else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
2679                         symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
2680                         symbol += createByte(codePoint, 12);
2681                         symbol += createByte(codePoint, 6);
2682                 }
2683                 symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
2684                 return symbol;
2685         }
2686
2687         function utf8encode(string, opts) {
2688                 opts = opts || {};
2689                 var strict = false !== opts.strict;
2690
2691                 var codePoints = ucs2decode(string);
2692                 var length = codePoints.length;
2693                 var index = -1;
2694                 var codePoint;
2695                 var byteString = '';
2696                 while (++index < length) {
2697                         codePoint = codePoints[index];
2698                         byteString += encodeCodePoint(codePoint, strict);
2699                 }
2700                 return byteString;
2701         }
2702
2703         /*--------------------------------------------------------------------------*/
2704
2705         function readContinuationByte() {
2706                 if (byteIndex >= byteCount) {
2707                         throw Error('Invalid byte index');
2708                 }
2709
2710                 var continuationByte = byteArray[byteIndex] & 0xFF;
2711                 byteIndex++;
2712
2713                 if ((continuationByte & 0xC0) == 0x80) {
2714                         return continuationByte & 0x3F;
2715                 }
2716
2717                 // If we end up here, it’s not a continuation byte
2718                 throw Error('Invalid continuation byte');
2719         }
2720
2721         function decodeSymbol(strict) {
2722                 var byte1;
2723                 var byte2;
2724                 var byte3;
2725                 var byte4;
2726                 var codePoint;
2727
2728                 if (byteIndex > byteCount) {
2729                         throw Error('Invalid byte index');
2730                 }
2731
2732                 if (byteIndex == byteCount) {
2733                         return false;
2734                 }
2735
2736                 // Read first byte
2737                 byte1 = byteArray[byteIndex] & 0xFF;
2738                 byteIndex++;
2739
2740                 // 1-byte sequence (no continuation bytes)
2741                 if ((byte1 & 0x80) == 0) {
2742                         return byte1;
2743                 }
2744
2745                 // 2-byte sequence
2746                 if ((byte1 & 0xE0) == 0xC0) {
2747                         byte2 = readContinuationByte();
2748                         codePoint = ((byte1 & 0x1F) << 6) | byte2;
2749                         if (codePoint >= 0x80) {
2750                                 return codePoint;
2751                         } else {
2752                                 throw Error('Invalid continuation byte');
2753                         }
2754                 }
2755
2756                 // 3-byte sequence (may include unpaired surrogates)
2757                 if ((byte1 & 0xF0) == 0xE0) {
2758                         byte2 = readContinuationByte();
2759                         byte3 = readContinuationByte();
2760                         codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
2761                         if (codePoint >= 0x0800) {
2762                                 return checkScalarValue(codePoint, strict) ? codePoint : 0xFFFD;
2763                         } else {
2764                                 throw Error('Invalid continuation byte');
2765                         }
2766                 }
2767
2768                 // 4-byte sequence
2769                 if ((byte1 & 0xF8) == 0xF0) {
2770                         byte2 = readContinuationByte();
2771                         byte3 = readContinuationByte();
2772                         byte4 = readContinuationByte();
2773                         codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
2774                                 (byte3 << 0x06) | byte4;
2775                         if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
2776                                 return codePoint;
2777                         }
2778                 }
2779
2780                 throw Error('Invalid UTF-8 detected');
2781         }
2782
2783         var byteArray;
2784         var byteCount;
2785         var byteIndex;
2786         function utf8decode(byteString, opts) {
2787                 opts = opts || {};
2788                 var strict = false !== opts.strict;
2789
2790                 byteArray = ucs2decode(byteString);
2791                 byteCount = byteArray.length;
2792                 byteIndex = 0;
2793                 var codePoints = [];
2794                 var tmp;
2795                 while ((tmp = decodeSymbol(strict)) !== false) {
2796                         codePoints.push(tmp);
2797                 }
2798                 return ucs2encode(codePoints);
2799         }
2800
2801         module.exports = {
2802                 version: '2.1.2',
2803                 encode: utf8encode,
2804                 decode: utf8decode
2805         };
2806
2807
2808 /***/ },
2809 /* 16 */
2810 /***/ function(module, exports) {
2811
2812         /*
2813          * base64-arraybuffer
2814          * https://github.com/niklasvh/base64-arraybuffer
2815          *
2816          * Copyright (c) 2012 Niklas von Hertzen
2817          * Licensed under the MIT license.
2818          */
2819         (function(){
2820           "use strict";
2821
2822           var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2823
2824           // Use a lookup table to find the index.
2825           var lookup = new Uint8Array(256);
2826           for (var i = 0; i < chars.length; i++) {
2827             lookup[chars.charCodeAt(i)] = i;
2828           }
2829
2830           exports.encode = function(arraybuffer) {
2831             var bytes = new Uint8Array(arraybuffer),
2832             i, len = bytes.length, base64 = "";
2833
2834             for (i = 0; i < len; i+=3) {
2835               base64 += chars[bytes[i] >> 2];
2836               base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
2837               base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
2838               base64 += chars[bytes[i + 2] & 63];
2839             }
2840
2841             if ((len % 3) === 2) {
2842               base64 = base64.substring(0, base64.length - 1) + "=";
2843             } else if (len % 3 === 1) {
2844               base64 = base64.substring(0, base64.length - 2) + "==";
2845             }
2846
2847             return base64;
2848           };
2849
2850           exports.decode =  function(base64) {
2851             var bufferLength = base64.length * 0.75,
2852             len = base64.length, i, p = 0,
2853             encoded1, encoded2, encoded3, encoded4;
2854
2855             if (base64[base64.length - 1] === "=") {
2856               bufferLength--;
2857               if (base64[base64.length - 2] === "=") {
2858                 bufferLength--;
2859               }
2860             }
2861
2862             var arraybuffer = new ArrayBuffer(bufferLength),
2863             bytes = new Uint8Array(arraybuffer);
2864
2865             for (i = 0; i < len; i+=4) {
2866               encoded1 = lookup[base64.charCodeAt(i)];
2867               encoded2 = lookup[base64.charCodeAt(i+1)];
2868               encoded3 = lookup[base64.charCodeAt(i+2)];
2869               encoded4 = lookup[base64.charCodeAt(i+3)];
2870
2871               bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
2872               bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
2873               bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
2874             }
2875
2876             return arraybuffer;
2877           };
2878         })();
2879
2880
2881 /***/ },
2882 /* 17 */
2883 /***/ function(module, exports) {
2884
2885         /**\r
2886          * Create a blob builder even when vendor prefixes exist\r
2887          */\r
2888 \r
2889         var BlobBuilder = typeof BlobBuilder !== 'undefined' ? BlobBuilder :\r
2890           typeof WebKitBlobBuilder !== 'undefined' ? WebKitBlobBuilder :\r
2891           typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder :\r
2892           typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : \r
2893           false;\r
2894 \r
2895         /**\r
2896          * Check if Blob constructor is supported\r
2897          */\r
2898 \r
2899         var blobSupported = (function() {\r
2900           try {\r
2901             var a = new Blob(['hi']);\r
2902             return a.size === 2;\r
2903           } catch(e) {\r
2904             return false;\r
2905           }\r
2906         })();\r
2907 \r
2908         /**\r
2909          * Check if Blob constructor supports ArrayBufferViews\r
2910          * Fails in Safari 6, so we need to map to ArrayBuffers there.\r
2911          */\r
2912 \r
2913         var blobSupportsArrayBufferView = blobSupported && (function() {\r
2914           try {\r
2915             var b = new Blob([new Uint8Array([1,2])]);\r
2916             return b.size === 2;\r
2917           } catch(e) {\r
2918             return false;\r
2919           }\r
2920         })();\r
2921 \r
2922         /**\r
2923          * Check if BlobBuilder is supported\r
2924          */\r
2925 \r
2926         var blobBuilderSupported = BlobBuilder\r
2927           && BlobBuilder.prototype.append\r
2928           && BlobBuilder.prototype.getBlob;\r
2929 \r
2930         /**\r
2931          * Helper function that maps ArrayBufferViews to ArrayBuffers\r
2932          * Used by BlobBuilder constructor and old browsers that didn't\r
2933          * support it in the Blob constructor.\r
2934          */\r
2935 \r
2936         function mapArrayBufferViews(ary) {\r
2937           return ary.map(function(chunk) {\r
2938             if (chunk.buffer instanceof ArrayBuffer) {\r
2939               var buf = chunk.buffer;\r
2940 \r
2941               // if this is a subarray, make a copy so we only\r
2942               // include the subarray region from the underlying buffer\r
2943               if (chunk.byteLength !== buf.byteLength) {\r
2944                 var copy = new Uint8Array(chunk.byteLength);\r
2945                 copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength));\r
2946                 buf = copy.buffer;\r
2947               }\r
2948 \r
2949               return buf;\r
2950             }\r
2951 \r
2952             return chunk;\r
2953           });\r
2954         }\r
2955 \r
2956         function BlobBuilderConstructor(ary, options) {\r
2957           options = options || {};\r
2958 \r
2959           var bb = new BlobBuilder();\r
2960           mapArrayBufferViews(ary).forEach(function(part) {\r
2961             bb.append(part);\r
2962           });\r
2963 \r
2964           return (options.type) ? bb.getBlob(options.type) : bb.getBlob();\r
2965         };\r
2966 \r
2967         function BlobConstructor(ary, options) {\r
2968           return new Blob(mapArrayBufferViews(ary), options || {});\r
2969         };\r
2970 \r
2971         if (typeof Blob !== 'undefined') {\r
2972           BlobBuilderConstructor.prototype = Blob.prototype;\r
2973           BlobConstructor.prototype = Blob.prototype;\r
2974         }\r
2975 \r
2976         module.exports = (function() {\r
2977           if (blobSupported) {\r
2978             return blobSupportsArrayBufferView ? Blob : BlobConstructor;\r
2979           } else if (blobBuilderSupported) {\r
2980             return BlobBuilderConstructor;\r
2981           } else {\r
2982             return undefined;\r
2983           }\r
2984         })();\r
2985
2986
2987 /***/ },
2988 /* 18 */
2989 /***/ function(module, exports, __webpack_require__) {
2990
2991         \r
2992         /**\r
2993          * Expose `Emitter`.\r
2994          */\r
2995 \r
2996         if (true) {\r
2997           module.exports = Emitter;\r
2998         }\r
2999 \r
3000         /**\r
3001          * Initialize a new `Emitter`.\r
3002          *\r
3003          * @api public\r
3004          */\r
3005 \r
3006         function Emitter(obj) {\r
3007           if (obj) return mixin(obj);\r
3008         };\r
3009 \r
3010         /**\r
3011          * Mixin the emitter properties.\r
3012          *\r
3013          * @param {Object} obj\r
3014          * @return {Object}\r
3015          * @api private\r
3016          */\r
3017 \r
3018         function mixin(obj) {\r
3019           for (var key in Emitter.prototype) {\r
3020             obj[key] = Emitter.prototype[key];\r
3021           }\r
3022           return obj;\r
3023         }\r
3024 \r
3025         /**\r
3026          * Listen on the given `event` with `fn`.\r
3027          *\r
3028          * @param {String} event\r
3029          * @param {Function} fn\r
3030          * @return {Emitter}\r
3031          * @api public\r
3032          */\r
3033 \r
3034         Emitter.prototype.on =\r
3035         Emitter.prototype.addEventListener = function(event, fn){\r
3036           this._callbacks = this._callbacks || {};\r
3037           (this._callbacks['$' + event] = this._callbacks['$' + event] || [])\r
3038             .push(fn);\r
3039           return this;\r
3040         };\r
3041 \r
3042         /**\r
3043          * Adds an `event` listener that will be invoked a single\r
3044          * time then automatically removed.\r
3045          *\r
3046          * @param {String} event\r
3047          * @param {Function} fn\r
3048          * @return {Emitter}\r
3049          * @api public\r
3050          */\r
3051 \r
3052         Emitter.prototype.once = function(event, fn){\r
3053           function on() {\r
3054             this.off(event, on);\r
3055             fn.apply(this, arguments);\r
3056           }\r
3057 \r
3058           on.fn = fn;\r
3059           this.on(event, on);\r
3060           return this;\r
3061         };\r
3062 \r
3063         /**\r
3064          * Remove the given callback for `event` or all\r
3065          * registered callbacks.\r
3066          *\r
3067          * @param {String} event\r
3068          * @param {Function} fn\r
3069          * @return {Emitter}\r
3070          * @api public\r
3071          */\r
3072 \r
3073         Emitter.prototype.off =\r
3074         Emitter.prototype.removeListener =\r
3075         Emitter.prototype.removeAllListeners =\r
3076         Emitter.prototype.removeEventListener = function(event, fn){\r
3077           this._callbacks = this._callbacks || {};\r
3078 \r
3079           // all\r
3080           if (0 == arguments.length) {\r
3081             this._callbacks = {};\r
3082             return this;\r
3083           }\r
3084 \r
3085           // specific event\r
3086           var callbacks = this._callbacks['$' + event];\r
3087           if (!callbacks) return this;\r
3088 \r
3089           // remove all handlers\r
3090           if (1 == arguments.length) {\r
3091             delete this._callbacks['$' + event];\r
3092             return this;\r
3093           }\r
3094 \r
3095           // remove specific handler\r
3096           var cb;\r
3097           for (var i = 0; i < callbacks.length; i++) {\r
3098             cb = callbacks[i];\r
3099             if (cb === fn || cb.fn === fn) {\r
3100               callbacks.splice(i, 1);\r
3101               break;\r
3102             }\r
3103           }\r
3104 \r
3105           // Remove event specific arrays for event types that no\r
3106           // one is subscribed for to avoid memory leak.\r
3107           if (callbacks.length === 0) {\r
3108             delete this._callbacks['$' + event];\r
3109           }\r
3110 \r
3111           return this;\r
3112         };\r
3113 \r
3114         /**\r
3115          * Emit `event` with the given args.\r
3116          *\r
3117          * @param {String} event\r
3118          * @param {Mixed} ...\r
3119          * @return {Emitter}\r
3120          */\r
3121 \r
3122         Emitter.prototype.emit = function(event){\r
3123           this._callbacks = this._callbacks || {};\r
3124 \r
3125           var args = new Array(arguments.length - 1)\r
3126             , callbacks = this._callbacks['$' + event];\r
3127 \r
3128           for (var i = 1; i < arguments.length; i++) {\r
3129             args[i - 1] = arguments[i];\r
3130           }\r
3131 \r
3132           if (callbacks) {\r
3133             callbacks = callbacks.slice(0);\r
3134             for (var i = 0, len = callbacks.length; i < len; ++i) {\r
3135               callbacks[i].apply(this, args);\r
3136             }\r
3137           }\r
3138 \r
3139           return this;\r
3140         };\r
3141 \r
3142         /**\r
3143          * Return array of callbacks for `event`.\r
3144          *\r
3145          * @param {String} event\r
3146          * @return {Array}\r
3147          * @api public\r
3148          */\r
3149 \r
3150         Emitter.prototype.listeners = function(event){\r
3151           this._callbacks = this._callbacks || {};\r
3152           return this._callbacks['$' + event] || [];\r
3153         };\r
3154 \r
3155         /**\r
3156          * Check if this emitter has `event` handlers.\r
3157          *\r
3158          * @param {String} event\r
3159          * @return {Boolean}\r
3160          * @api public\r
3161          */\r
3162 \r
3163         Emitter.prototype.hasListeners = function(event){\r
3164           return !! this.listeners(event).length;\r
3165         };\r
3166
3167
3168 /***/ },
3169 /* 19 */
3170 /***/ function(module, exports) {
3171
3172         /**
3173          * Compiles a querystring
3174          * Returns string representation of the object
3175          *
3176          * @param {Object}
3177          * @api private
3178          */
3179
3180         exports.encode = function (obj) {
3181           var str = '';
3182
3183           for (var i in obj) {
3184             if (obj.hasOwnProperty(i)) {
3185               if (str.length) str += '&';
3186               str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
3187             }
3188           }
3189
3190           return str;
3191         };
3192
3193         /**
3194          * Parses a simple querystring into an object
3195          *
3196          * @param {String} qs
3197          * @api private
3198          */
3199
3200         exports.decode = function(qs){
3201           var qry = {};
3202           var pairs = qs.split('&');
3203           for (var i = 0, l = pairs.length; i < l; i++) {
3204             var pair = pairs[i].split('=');
3205             qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
3206           }
3207           return qry;
3208         };
3209
3210
3211 /***/ },
3212 /* 20 */
3213 /***/ function(module, exports) {
3214
3215         
3216         module.exports = function(a, b){
3217           var fn = function(){};
3218           fn.prototype = b.prototype;
3219           a.prototype = new fn;
3220           a.prototype.constructor = a;
3221         };
3222
3223 /***/ },
3224 /* 21 */
3225 /***/ function(module, exports) {
3226
3227         'use strict';
3228
3229         var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('')
3230           , length = 64
3231           , map = {}
3232           , seed = 0
3233           , i = 0
3234           , prev;
3235
3236         /**
3237          * Return a string representing the specified number.
3238          *
3239          * @param {Number} num The number to convert.
3240          * @returns {String} The string representation of the number.
3241          * @api public
3242          */
3243         function encode(num) {
3244           var encoded = '';
3245
3246           do {
3247             encoded = alphabet[num % length] + encoded;
3248             num = Math.floor(num / length);
3249           } while (num > 0);
3250
3251           return encoded;
3252         }
3253
3254         /**
3255          * Return the integer value specified by the given string.
3256          *
3257          * @param {String} str The string to convert.
3258          * @returns {Number} The integer value represented by the string.
3259          * @api public
3260          */
3261         function decode(str) {
3262           var decoded = 0;
3263
3264           for (i = 0; i < str.length; i++) {
3265             decoded = decoded * length + map[str.charAt(i)];
3266           }
3267
3268           return decoded;
3269         }
3270
3271         /**
3272          * Yeast: A tiny growing id generator.
3273          *
3274          * @returns {String} A unique id.
3275          * @api public
3276          */
3277         function yeast() {
3278           var now = encode(+new Date());
3279
3280           if (now !== prev) return seed = 0, prev = now;
3281           return now +'.'+ encode(seed++);
3282         }
3283
3284         //
3285         // Map each character to its index.
3286         //
3287         for (; i < length; i++) map[alphabet[i]] = i;
3288
3289         //
3290         // Expose the `yeast`, `encode` and `decode` functions.
3291         //
3292         yeast.encode = encode;
3293         yeast.decode = decode;
3294         module.exports = yeast;
3295
3296
3297 /***/ },
3298 /* 22 */
3299 /***/ function(module, exports, __webpack_require__) {
3300
3301         /* WEBPACK VAR INJECTION */(function(process) {'use strict';
3302
3303         var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
3304
3305         /**
3306          * This is the web browser implementation of `debug()`.
3307          *
3308          * Expose `debug()` as the module.
3309          */
3310
3311         exports = module.exports = __webpack_require__(24);
3312         exports.log = log;
3313         exports.formatArgs = formatArgs;
3314         exports.save = save;
3315         exports.load = load;
3316         exports.useColors = useColors;
3317         exports.storage = 'undefined' != typeof chrome && 'undefined' != typeof chrome.storage ? chrome.storage.local : localstorage();
3318
3319         /**
3320          * Colors.
3321          */
3322
3323         exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
3324
3325         /**
3326          * Currently only WebKit-based Web Inspectors, Firefox >= v31,
3327          * and the Firebug extension (any Firefox version) are known
3328          * to support "%c" CSS customizations.
3329          *
3330          * TODO: add a `localStorage` variable to explicitly enable/disable colors
3331          */
3332
3333         function useColors() {
3334           // NB: In an Electron preload script, document will be defined but not fully
3335           // initialized. Since we know we're in Chrome, we'll just detect this case
3336           // explicitly
3337           if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
3338             return true;
3339           }
3340
3341           // Internet Explorer and Edge do not support colors.
3342           if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
3343             return false;
3344           }
3345
3346           // is webkit? http://stackoverflow.com/a/16459606/376773
3347           // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
3348           return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance ||
3349           // is firebug? http://stackoverflow.com/a/398120/376773
3350           typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) ||
3351           // is firefox >= v31?
3352           // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
3353           typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 ||
3354           // double check webkit in userAgent just in case we are in a worker
3355           typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
3356         }
3357
3358         /**
3359          * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
3360          */
3361
3362         exports.formatters.j = function (v) {
3363           try {
3364             return JSON.stringify(v);
3365           } catch (err) {
3366             return '[UnexpectedJSONParseError]: ' + err.message;
3367           }
3368         };
3369
3370         /**
3371          * Colorize log arguments if enabled.
3372          *
3373          * @api public
3374          */
3375
3376         function formatArgs(args) {
3377           var useColors = this.useColors;
3378
3379           args[0] = (useColors ? '%c' : '') + this.namespace + (useColors ? ' %c' : ' ') + args[0] + (useColors ? '%c ' : ' ') + '+' + exports.humanize(this.diff);
3380
3381           if (!useColors) return;
3382
3383           var c = 'color: ' + this.color;
3384           args.splice(1, 0, c, 'color: inherit');
3385
3386           // the final "%c" is somewhat tricky, because there could be other
3387           // arguments passed either before or after the %c, so we need to
3388           // figure out the correct index to insert the CSS into
3389           var index = 0;
3390           var lastC = 0;
3391           args[0].replace(/%[a-zA-Z%]/g, function (match) {
3392             if ('%%' === match) return;
3393             index++;
3394             if ('%c' === match) {
3395               // we only are interested in the *last* %c
3396               // (the user may have provided their own)
3397               lastC = index;
3398             }
3399           });
3400
3401           args.splice(lastC, 0, c);
3402         }
3403
3404         /**
3405          * Invokes `console.log()` when available.
3406          * No-op when `console.log` is not a "function".
3407          *
3408          * @api public
3409          */
3410
3411         function log() {
3412           // this hackery is required for IE8/9, where
3413           // the `console.log` function doesn't have 'apply'
3414           return 'object' === (typeof console === 'undefined' ? 'undefined' : _typeof(console)) && console.log && Function.prototype.apply.call(console.log, console, arguments);
3415         }
3416
3417         /**
3418          * Save `namespaces`.
3419          *
3420          * @param {String} namespaces
3421          * @api private
3422          */
3423
3424         function save(namespaces) {
3425           try {
3426             if (null == namespaces) {
3427               exports.storage.removeItem('debug');
3428             } else {
3429               exports.storage.debug = namespaces;
3430             }
3431           } catch (e) {}
3432         }
3433
3434         /**
3435          * Load `namespaces`.
3436          *
3437          * @return {String} returns the previously persisted debug modes
3438          * @api private
3439          */
3440
3441         function load() {
3442           var r;
3443           try {
3444             r = exports.storage.debug;
3445           } catch (e) {}
3446
3447           // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
3448           if (!r && typeof process !== 'undefined' && 'env' in process) {
3449             r = process.env.DEBUG;
3450           }
3451
3452           return r;
3453         }
3454
3455         /**
3456          * Enable namespaces listed in `localStorage.debug` initially.
3457          */
3458
3459         exports.enable(load());
3460
3461         /**
3462          * Localstorage attempts to return the localstorage.
3463          *
3464          * This is necessary because safari throws
3465          * when a user disables cookies/localstorage
3466          * and you attempt to access it.
3467          *
3468          * @return {LocalStorage}
3469          * @api private
3470          */
3471
3472         function localstorage() {
3473           try {
3474             return window.localStorage;
3475           } catch (e) {}
3476         }
3477         /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(23)))
3478
3479 /***/ },
3480 /* 23 */
3481 /***/ function(module, exports) {
3482
3483         // shim for using process in browser
3484         var process = module.exports = {};
3485
3486         // cached from whatever global is present so that test runners that stub it
3487         // don't break things.  But we need to wrap it in a try catch in case it is
3488         // wrapped in strict mode code which doesn't define any globals.  It's inside a
3489         // function because try/catches deoptimize in certain engines.
3490
3491         var cachedSetTimeout;
3492         var cachedClearTimeout;
3493
3494         function defaultSetTimout() {
3495             throw new Error('setTimeout has not been defined');
3496         }
3497         function defaultClearTimeout () {
3498             throw new Error('clearTimeout has not been defined');
3499         }
3500         (function () {
3501             try {
3502                 if (typeof setTimeout === 'function') {
3503                     cachedSetTimeout = setTimeout;
3504                 } else {
3505                     cachedSetTimeout = defaultSetTimout;
3506                 }
3507             } catch (e) {
3508                 cachedSetTimeout = defaultSetTimout;
3509             }
3510             try {
3511                 if (typeof clearTimeout === 'function') {
3512                     cachedClearTimeout = clearTimeout;
3513                 } else {
3514                     cachedClearTimeout = defaultClearTimeout;
3515                 }
3516             } catch (e) {
3517                 cachedClearTimeout = defaultClearTimeout;
3518             }
3519         } ())
3520         function runTimeout(fun) {
3521             if (cachedSetTimeout === setTimeout) {
3522                 //normal enviroments in sane situations
3523                 return setTimeout(fun, 0);
3524             }
3525             // if setTimeout wasn't available but was latter defined
3526             if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
3527                 cachedSetTimeout = setTimeout;
3528                 return setTimeout(fun, 0);
3529             }
3530             try {
3531                 // when when somebody has screwed with setTimeout but no I.E. maddness
3532                 return cachedSetTimeout(fun, 0);
3533             } catch(e){
3534                 try {
3535                     // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
3536                     return cachedSetTimeout.call(null, fun, 0);
3537                 } catch(e){
3538                     // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
3539                     return cachedSetTimeout.call(this, fun, 0);
3540                 }
3541             }
3542
3543
3544         }
3545         function runClearTimeout(marker) {
3546             if (cachedClearTimeout === clearTimeout) {
3547                 //normal enviroments in sane situations
3548                 return clearTimeout(marker);
3549             }
3550             // if clearTimeout wasn't available but was latter defined
3551             if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
3552                 cachedClearTimeout = clearTimeout;
3553                 return clearTimeout(marker);
3554             }
3555             try {
3556                 // when when somebody has screwed with setTimeout but no I.E. maddness
3557                 return cachedClearTimeout(marker);
3558             } catch (e){
3559                 try {
3560                     // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
3561                     return cachedClearTimeout.call(null, marker);
3562                 } catch (e){
3563                     // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
3564                     // Some versions of I.E. have different rules for clearTimeout vs setTimeout
3565                     return cachedClearTimeout.call(this, marker);
3566                 }
3567             }
3568
3569
3570
3571         }
3572         var queue = [];
3573         var draining = false;
3574         var currentQueue;
3575         var queueIndex = -1;
3576
3577         function cleanUpNextTick() {
3578             if (!draining || !currentQueue) {
3579                 return;
3580             }
3581             draining = false;
3582             if (currentQueue.length) {
3583                 queue = currentQueue.concat(queue);
3584             } else {
3585                 queueIndex = -1;
3586             }
3587             if (queue.length) {
3588                 drainQueue();
3589             }
3590         }
3591
3592         function drainQueue() {
3593             if (draining) {
3594                 return;
3595             }
3596             var timeout = runTimeout(cleanUpNextTick);
3597             draining = true;
3598
3599             var len = queue.length;
3600             while(len) {
3601                 currentQueue = queue;
3602                 queue = [];
3603                 while (++queueIndex < len) {
3604                     if (currentQueue) {
3605                         currentQueue[queueIndex].run();
3606                     }
3607                 }
3608                 queueIndex = -1;
3609                 len = queue.length;
3610             }
3611             currentQueue = null;
3612             draining = false;
3613             runClearTimeout(timeout);
3614         }
3615
3616         process.nextTick = function (fun) {
3617             var args = new Array(arguments.length - 1);
3618             if (arguments.length > 1) {
3619                 for (var i = 1; i < arguments.length; i++) {
3620                     args[i - 1] = arguments[i];
3621                 }
3622             }
3623             queue.push(new Item(fun, args));
3624             if (queue.length === 1 && !draining) {
3625                 runTimeout(drainQueue);
3626             }
3627         };
3628
3629         // v8 likes predictible objects
3630         function Item(fun, array) {
3631             this.fun = fun;
3632             this.array = array;
3633         }
3634         Item.prototype.run = function () {
3635             this.fun.apply(null, this.array);
3636         };
3637         process.title = 'browser';
3638         process.browser = true;
3639         process.env = {};
3640         process.argv = [];
3641         process.version = ''; // empty string to avoid regexp issues
3642         process.versions = {};
3643
3644         function noop() {}
3645
3646         process.on = noop;
3647         process.addListener = noop;
3648         process.once = noop;
3649         process.off = noop;
3650         process.removeListener = noop;
3651         process.removeAllListeners = noop;
3652         process.emit = noop;
3653         process.prependListener = noop;
3654         process.prependOnceListener = noop;
3655
3656         process.listeners = function (name) { return [] }
3657
3658         process.binding = function (name) {
3659             throw new Error('process.binding is not supported');
3660         };
3661
3662         process.cwd = function () { return '/' };
3663         process.chdir = function (dir) {
3664             throw new Error('process.chdir is not supported');
3665         };
3666         process.umask = function() { return 0; };
3667
3668
3669 /***/ },
3670 /* 24 */
3671 /***/ function(module, exports, __webpack_require__) {
3672
3673         'use strict';
3674
3675         /**
3676          * This is the common logic for both the Node.js and web browser
3677          * implementations of `debug()`.
3678          *
3679          * Expose `debug()` as the module.
3680          */
3681
3682         exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
3683         exports.coerce = coerce;
3684         exports.disable = disable;
3685         exports.enable = enable;
3686         exports.enabled = enabled;
3687         exports.humanize = __webpack_require__(25);
3688
3689         /**
3690          * Active `debug` instances.
3691          */
3692         exports.instances = [];
3693
3694         /**
3695          * The currently active debug mode names, and names to skip.
3696          */
3697
3698         exports.names = [];
3699         exports.skips = [];
3700
3701         /**
3702          * Map of special "%n" handling functions, for the debug "format" argument.
3703          *
3704          * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
3705          */
3706
3707         exports.formatters = {};
3708
3709         /**
3710          * Select a color.
3711          * @param {String} namespace
3712          * @return {Number}
3713          * @api private
3714          */
3715
3716         function selectColor(namespace) {
3717           var hash = 0,
3718               i;
3719
3720           for (i in namespace) {
3721             hash = (hash << 5) - hash + namespace.charCodeAt(i);
3722             hash |= 0; // Convert to 32bit integer
3723           }
3724
3725           return exports.colors[Math.abs(hash) % exports.colors.length];
3726         }
3727
3728         /**
3729          * Create a debugger with the given `namespace`.
3730          *
3731          * @param {String} namespace
3732          * @return {Function}
3733          * @api public
3734          */
3735
3736         function createDebug(namespace) {
3737
3738           var prevTime;
3739
3740           function debug() {
3741             // disabled?
3742             if (!debug.enabled) return;
3743
3744             var self = debug;
3745
3746             // set `diff` timestamp
3747             var curr = +new Date();
3748             var ms = curr - (prevTime || curr);
3749             self.diff = ms;
3750             self.prev = prevTime;
3751             self.curr = curr;
3752             prevTime = curr;
3753
3754             // turn the `arguments` into a proper Array
3755             var args = new Array(arguments.length);
3756             for (var i = 0; i < args.length; i++) {
3757               args[i] = arguments[i];
3758             }
3759
3760             args[0] = exports.coerce(args[0]);
3761
3762             if ('string' !== typeof args[0]) {
3763               // anything else let's inspect with %O
3764               args.unshift('%O');
3765             }
3766
3767             // apply any `formatters` transformations
3768             var index = 0;
3769             args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
3770               // if we encounter an escaped % then don't increase the array index
3771               if (match === '%%') return match;
3772               index++;
3773               var formatter = exports.formatters[format];
3774               if ('function' === typeof formatter) {
3775                 var val = args[index];
3776                 match = formatter.call(self, val);
3777
3778                 // now we need to remove `args[index]` since it's inlined in the `format`
3779                 args.splice(index, 1);
3780                 index--;
3781               }
3782               return match;
3783             });
3784
3785             // apply env-specific formatting (colors, etc.)
3786             exports.formatArgs.call(self, args);
3787
3788             var logFn = debug.log || exports.log || console.log.bind(console);
3789             logFn.apply(self, args);
3790           }
3791
3792           debug.namespace = namespace;
3793           debug.enabled = exports.enabled(namespace);
3794           debug.useColors = exports.useColors();
3795           debug.color = selectColor(namespace);
3796           debug.destroy = destroy;
3797
3798           // env-specific initialization logic for debug instances
3799           if ('function' === typeof exports.init) {
3800             exports.init(debug);
3801           }
3802
3803           exports.instances.push(debug);
3804
3805           return debug;
3806         }
3807
3808         function destroy() {
3809           var index = exports.instances.indexOf(this);
3810           if (index !== -1) {
3811             exports.instances.splice(index, 1);
3812             return true;
3813           } else {
3814             return false;
3815           }
3816         }
3817
3818         /**
3819          * Enables a debug mode by namespaces. This can include modes
3820          * separated by a colon and wildcards.
3821          *
3822          * @param {String} namespaces
3823          * @api public
3824          */
3825
3826         function enable(namespaces) {
3827           exports.save(namespaces);
3828
3829           exports.names = [];
3830           exports.skips = [];
3831
3832           var i;
3833           var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
3834           var len = split.length;
3835
3836           for (i = 0; i < len; i++) {
3837             if (!split[i]) continue; // ignore empty strings
3838             namespaces = split[i].replace(/\*/g, '.*?');
3839             if (namespaces[0] === '-') {
3840               exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
3841             } else {
3842               exports.names.push(new RegExp('^' + namespaces + '$'));
3843             }
3844           }
3845
3846           for (i = 0; i < exports.instances.length; i++) {
3847             var instance = exports.instances[i];
3848             instance.enabled = exports.enabled(instance.namespace);
3849           }
3850         }
3851
3852         /**
3853          * Disable debug output.
3854          *
3855          * @api public
3856          */
3857
3858         function disable() {
3859           exports.enable('');
3860         }
3861
3862         /**
3863          * Returns true if the given mode name is enabled, false otherwise.
3864          *
3865          * @param {String} name
3866          * @return {Boolean}
3867          * @api public
3868          */
3869
3870         function enabled(name) {
3871           if (name[name.length - 1] === '*') {
3872             return true;
3873           }
3874           var i, len;
3875           for (i = 0, len = exports.skips.length; i < len; i++) {
3876             if (exports.skips[i].test(name)) {
3877               return false;
3878             }
3879           }
3880           for (i = 0, len = exports.names.length; i < len; i++) {
3881             if (exports.names[i].test(name)) {
3882               return true;
3883             }
3884           }
3885           return false;
3886         }
3887
3888         /**
3889          * Coerce `val`.
3890          *
3891          * @param {Mixed} val
3892          * @return {Mixed}
3893          * @api private
3894          */
3895
3896         function coerce(val) {
3897           if (val instanceof Error) return val.stack || val.message;
3898           return val;
3899         }
3900
3901 /***/ },
3902 /* 25 */
3903 /***/ function(module, exports) {
3904
3905         /**
3906          * Helpers.
3907          */
3908
3909         var s = 1000;
3910         var m = s * 60;
3911         var h = m * 60;
3912         var d = h * 24;
3913         var y = d * 365.25;
3914
3915         /**
3916          * Parse or format the given `val`.
3917          *
3918          * Options:
3919          *
3920          *  - `long` verbose formatting [false]
3921          *
3922          * @param {String|Number} val
3923          * @param {Object} [options]
3924          * @throws {Error} throw an error if val is not a non-empty string or a number
3925          * @return {String|Number}
3926          * @api public
3927          */
3928
3929         module.exports = function(val, options) {
3930           options = options || {};
3931           var type = typeof val;
3932           if (type === 'string' && val.length > 0) {
3933             return parse(val);
3934           } else if (type === 'number' && isNaN(val) === false) {
3935             return options.long ? fmtLong(val) : fmtShort(val);
3936           }
3937           throw new Error(
3938             'val is not a non-empty string or a valid number. val=' +
3939               JSON.stringify(val)
3940           );
3941         };
3942
3943         /**
3944          * Parse the given `str` and return milliseconds.
3945          *
3946          * @param {String} str
3947          * @return {Number}
3948          * @api private
3949          */
3950
3951         function parse(str) {
3952           str = String(str);
3953           if (str.length > 100) {
3954             return;
3955           }
3956           var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
3957             str
3958           );
3959           if (!match) {
3960             return;
3961           }
3962           var n = parseFloat(match[1]);
3963           var type = (match[2] || 'ms').toLowerCase();
3964           switch (type) {
3965             case 'years':
3966             case 'year':
3967             case 'yrs':
3968             case 'yr':
3969             case 'y':
3970               return n * y;
3971             case 'days':
3972             case 'day':
3973             case 'd':
3974               return n * d;
3975             case 'hours':
3976             case 'hour':
3977             case 'hrs':
3978             case 'hr':
3979             case 'h':
3980               return n * h;
3981             case 'minutes':
3982             case 'minute':
3983             case 'mins':
3984             case 'min':
3985             case 'm':
3986               return n * m;
3987             case 'seconds':
3988             case 'second':
3989             case 'secs':
3990             case 'sec':
3991             case 's':
3992               return n * s;
3993             case 'milliseconds':
3994             case 'millisecond':
3995             case 'msecs':
3996             case 'msec':
3997             case 'ms':
3998               return n;
3999             default:
4000               return undefined;
4001           }
4002         }
4003
4004         /**
4005          * Short format for `ms`.
4006          *
4007          * @param {Number} ms
4008          * @return {String}
4009          * @api private
4010          */
4011
4012         function fmtShort(ms) {
4013           if (ms >= d) {
4014             return Math.round(ms / d) + 'd';
4015           }
4016           if (ms >= h) {
4017             return Math.round(ms / h) + 'h';
4018           }
4019           if (ms >= m) {
4020             return Math.round(ms / m) + 'm';
4021           }
4022           if (ms >= s) {
4023             return Math.round(ms / s) + 's';
4024           }
4025           return ms + 'ms';
4026         }
4027
4028         /**
4029          * Long format for `ms`.
4030          *
4031          * @param {Number} ms
4032          * @return {String}
4033          * @api private
4034          */
4035
4036         function fmtLong(ms) {
4037           return plural(ms, d, 'day') ||
4038             plural(ms, h, 'hour') ||
4039             plural(ms, m, 'minute') ||
4040             plural(ms, s, 'second') ||
4041             ms + ' ms';
4042         }
4043
4044         /**
4045          * Pluralization helper.
4046          */
4047
4048         function plural(ms, n, name) {
4049           if (ms < n) {
4050             return;
4051           }
4052           if (ms < n * 1.5) {
4053             return Math.floor(ms / n) + ' ' + name;
4054           }
4055           return Math.ceil(ms / n) + ' ' + name + 's';
4056         }
4057
4058
4059 /***/ },
4060 /* 26 */
4061 /***/ function(module, exports, __webpack_require__) {
4062
4063         /**
4064          * Module requirements.
4065          */
4066
4067         var Polling = __webpack_require__(7);
4068         var inherit = __webpack_require__(20);
4069         var globalThis = __webpack_require__(5);
4070
4071         /**
4072          * Module exports.
4073          */
4074
4075         module.exports = JSONPPolling;
4076
4077         /**
4078          * Cached regular expressions.
4079          */
4080
4081         var rNewline = /\n/g;
4082         var rEscapedNewline = /\\n/g;
4083
4084         /**
4085          * Global JSONP callbacks.
4086          */
4087
4088         var callbacks;
4089
4090         /**
4091          * Noop.
4092          */
4093
4094         function empty () { }
4095
4096         /**
4097          * JSONP Polling constructor.
4098          *
4099          * @param {Object} opts.
4100          * @api public
4101          */
4102
4103         function JSONPPolling (opts) {
4104           Polling.call(this, opts);
4105
4106           this.query = this.query || {};
4107
4108           // define global callbacks array if not present
4109           // we do this here (lazily) to avoid unneeded global pollution
4110           if (!callbacks) {
4111             // we need to consider multiple engines in the same page
4112             callbacks = globalThis.___eio = (globalThis.___eio || []);
4113           }
4114
4115           // callback identifier
4116           this.index = callbacks.length;
4117
4118           // add callback to jsonp global
4119           var self = this;
4120           callbacks.push(function (msg) {
4121             self.onData(msg);
4122           });
4123
4124           // append to query string
4125           this.query.j = this.index;
4126
4127           // prevent spurious errors from being emitted when the window is unloaded
4128           if (typeof addEventListener === 'function') {
4129             addEventListener('beforeunload', function () {
4130               if (self.script) self.script.onerror = empty;
4131             }, false);
4132           }
4133         }
4134
4135         /**
4136          * Inherits from Polling.
4137          */
4138
4139         inherit(JSONPPolling, Polling);
4140
4141         /*
4142          * JSONP only supports binary as base64 encoded strings
4143          */
4144
4145         JSONPPolling.prototype.supportsBinary = false;
4146
4147         /**
4148          * Closes the socket.
4149          *
4150          * @api private
4151          */
4152
4153         JSONPPolling.prototype.doClose = function () {
4154           if (this.script) {
4155             this.script.parentNode.removeChild(this.script);
4156             this.script = null;
4157           }
4158
4159           if (this.form) {
4160             this.form.parentNode.removeChild(this.form);
4161             this.form = null;
4162             this.iframe = null;
4163           }
4164
4165           Polling.prototype.doClose.call(this);
4166         };
4167
4168         /**
4169          * Starts a poll cycle.
4170          *
4171          * @api private
4172          */
4173
4174         JSONPPolling.prototype.doPoll = function () {
4175           var self = this;
4176           var script = document.createElement('script');
4177
4178           if (this.script) {
4179             this.script.parentNode.removeChild(this.script);
4180             this.script = null;
4181           }
4182
4183           script.async = true;
4184           script.src = this.uri();
4185           script.onerror = function (e) {
4186             self.onError('jsonp poll error', e);
4187           };
4188
4189           var insertAt = document.getElementsByTagName('script')[0];
4190           if (insertAt) {
4191             insertAt.parentNode.insertBefore(script, insertAt);
4192           } else {
4193             (document.head || document.body).appendChild(script);
4194           }
4195           this.script = script;
4196
4197           var isUAgecko = 'undefined' !== typeof navigator && /gecko/i.test(navigator.userAgent);
4198
4199           if (isUAgecko) {
4200             setTimeout(function () {
4201               var iframe = document.createElement('iframe');
4202               document.body.appendChild(iframe);
4203               document.body.removeChild(iframe);
4204             }, 100);
4205           }
4206         };
4207
4208         /**
4209          * Writes with a hidden iframe.
4210          *
4211          * @param {String} data to send
4212          * @param {Function} called upon flush.
4213          * @api private
4214          */
4215
4216         JSONPPolling.prototype.doWrite = function (data, fn) {
4217           var self = this;
4218
4219           if (!this.form) {
4220             var form = document.createElement('form');
4221             var area = document.createElement('textarea');
4222             var id = this.iframeId = 'eio_iframe_' + this.index;
4223             var iframe;
4224
4225             form.className = 'socketio';
4226             form.style.position = 'absolute';
4227             form.style.top = '-1000px';
4228             form.style.left = '-1000px';
4229             form.target = id;
4230             form.method = 'POST';
4231             form.setAttribute('accept-charset', 'utf-8');
4232             area.name = 'd';
4233             form.appendChild(area);
4234             document.body.appendChild(form);
4235
4236             this.form = form;
4237             this.area = area;
4238           }
4239
4240           this.form.action = this.uri();
4241
4242           function complete () {
4243             initIframe();
4244             fn();
4245           }
4246
4247           function initIframe () {
4248             if (self.iframe) {
4249               try {
4250                 self.form.removeChild(self.iframe);
4251               } catch (e) {
4252                 self.onError('jsonp polling iframe removal error', e);
4253               }
4254             }
4255
4256             try {
4257               // ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
4258               var html = '<iframe src="javascript:0" name="' + self.iframeId + '">';
4259               iframe = document.createElement(html);
4260             } catch (e) {
4261               iframe = document.createElement('iframe');
4262               iframe.name = self.iframeId;
4263               iframe.src = 'javascript:0';
4264             }
4265
4266             iframe.id = self.iframeId;
4267
4268             self.form.appendChild(iframe);
4269             self.iframe = iframe;
4270           }
4271
4272           initIframe();
4273
4274           // escape \n to prevent it from being converted into \r\n by some UAs
4275           // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side
4276           data = data.replace(rEscapedNewline, '\\\n');
4277           this.area.value = data.replace(rNewline, '\\n');
4278
4279           try {
4280             this.form.submit();
4281           } catch (e) {}
4282
4283           if (this.iframe.attachEvent) {
4284             this.iframe.onreadystatechange = function () {
4285               if (self.iframe.readyState === 'complete') {
4286                 complete();
4287               }
4288             };
4289           } else {
4290             this.iframe.onload = complete;
4291           }
4292         };
4293
4294
4295 /***/ },
4296 /* 27 */
4297 /***/ function(module, exports, __webpack_require__) {
4298
4299         /**
4300          * Module dependencies.
4301          */
4302
4303         var Transport = __webpack_require__(8);
4304         var parser = __webpack_require__(9);
4305         var parseqs = __webpack_require__(19);
4306         var inherit = __webpack_require__(20);
4307         var yeast = __webpack_require__(21);
4308         var debug = __webpack_require__(22)('engine.io-client:websocket');
4309
4310         var BrowserWebSocket, NodeWebSocket;
4311
4312         if (typeof WebSocket !== 'undefined') {
4313           BrowserWebSocket = WebSocket;
4314         } else if (typeof self !== 'undefined') {
4315           BrowserWebSocket = self.WebSocket || self.MozWebSocket;
4316         }
4317
4318         if (typeof window === 'undefined') {
4319           try {
4320             NodeWebSocket = __webpack_require__(28);
4321           } catch (e) { }
4322         }
4323
4324         /**
4325          * Get either the `WebSocket` or `MozWebSocket` globals
4326          * in the browser or try to resolve WebSocket-compatible
4327          * interface exposed by `ws` for Node-like environment.
4328          */
4329
4330         var WebSocketImpl = BrowserWebSocket || NodeWebSocket;
4331
4332         /**
4333          * Module exports.
4334          */
4335
4336         module.exports = WS;
4337
4338         /**
4339          * WebSocket transport constructor.
4340          *
4341          * @api {Object} connection options
4342          * @api public
4343          */
4344
4345         function WS (opts) {
4346           var forceBase64 = (opts && opts.forceBase64);
4347           if (forceBase64) {
4348             this.supportsBinary = false;
4349           }
4350           this.perMessageDeflate = opts.perMessageDeflate;
4351           this.usingBrowserWebSocket = BrowserWebSocket && !opts.forceNode;
4352           this.protocols = opts.protocols;
4353           if (!this.usingBrowserWebSocket) {
4354             WebSocketImpl = NodeWebSocket;
4355           }
4356           Transport.call(this, opts);
4357         }
4358
4359         /**
4360          * Inherits from Transport.
4361          */
4362
4363         inherit(WS, Transport);
4364
4365         /**
4366          * Transport name.
4367          *
4368          * @api public
4369          */
4370
4371         WS.prototype.name = 'websocket';
4372
4373         /*
4374          * WebSockets support binary
4375          */
4376
4377         WS.prototype.supportsBinary = true;
4378
4379         /**
4380          * Opens socket.
4381          *
4382          * @api private
4383          */
4384
4385         WS.prototype.doOpen = function () {
4386           if (!this.check()) {
4387             // let probe timeout
4388             return;
4389           }
4390
4391           var uri = this.uri();
4392           var protocols = this.protocols;
4393
4394           var opts = {};
4395
4396           if (!this.isReactNative) {
4397             opts.agent = this.agent;
4398             opts.perMessageDeflate = this.perMessageDeflate;
4399
4400             // SSL options for Node.js client
4401             opts.pfx = this.pfx;
4402             opts.key = this.key;
4403             opts.passphrase = this.passphrase;
4404             opts.cert = this.cert;
4405             opts.ca = this.ca;
4406             opts.ciphers = this.ciphers;
4407             opts.rejectUnauthorized = this.rejectUnauthorized;
4408           }
4409
4410           if (this.extraHeaders) {
4411             opts.headers = this.extraHeaders;
4412           }
4413           if (this.localAddress) {
4414             opts.localAddress = this.localAddress;
4415           }
4416
4417           try {
4418             this.ws =
4419               this.usingBrowserWebSocket && !this.isReactNative
4420                 ? protocols
4421                   ? new WebSocketImpl(uri, protocols)
4422                   : new WebSocketImpl(uri)
4423                 : new WebSocketImpl(uri, protocols, opts);
4424           } catch (err) {
4425             return this.emit('error', err);
4426           }
4427
4428           if (this.ws.binaryType === undefined) {
4429             this.supportsBinary = false;
4430           }
4431
4432           if (this.ws.supports && this.ws.supports.binary) {
4433             this.supportsBinary = true;
4434             this.ws.binaryType = 'nodebuffer';
4435           } else {
4436             this.ws.binaryType = 'arraybuffer';
4437           }
4438
4439           this.addEventListeners();
4440         };
4441
4442         /**
4443          * Adds event listeners to the socket
4444          *
4445          * @api private
4446          */
4447
4448         WS.prototype.addEventListeners = function () {
4449           var self = this;
4450
4451           this.ws.onopen = function () {
4452             self.onOpen();
4453           };
4454           this.ws.onclose = function () {
4455             self.onClose();
4456           };
4457           this.ws.onmessage = function (ev) {
4458             self.onData(ev.data);
4459           };
4460           this.ws.onerror = function (e) {
4461             self.onError('websocket error', e);
4462           };
4463         };
4464
4465         /**
4466          * Writes data to socket.
4467          *
4468          * @param {Array} array of packets.
4469          * @api private
4470          */
4471
4472         WS.prototype.write = function (packets) {
4473           var self = this;
4474           this.writable = false;
4475
4476           // encodePacket efficient as it uses WS framing
4477           // no need for encodePayload
4478           var total = packets.length;
4479           for (var i = 0, l = total; i < l; i++) {
4480             (function (packet) {
4481               parser.encodePacket(packet, self.supportsBinary, function (data) {
4482                 if (!self.usingBrowserWebSocket) {
4483                   // always create a new object (GH-437)
4484                   var opts = {};
4485                   if (packet.options) {
4486                     opts.compress = packet.options.compress;
4487                   }
4488
4489                   if (self.perMessageDeflate) {
4490                     var len = 'string' === typeof data ? Buffer.byteLength(data) : data.length;
4491                     if (len < self.perMessageDeflate.threshold) {
4492                       opts.compress = false;
4493                     }
4494                   }
4495                 }
4496
4497                 // Sometimes the websocket has already been closed but the browser didn't
4498                 // have a chance of informing us about it yet, in that case send will
4499                 // throw an error
4500                 try {
4501                   if (self.usingBrowserWebSocket) {
4502                     // TypeError is thrown when passing the second argument on Safari
4503                     self.ws.send(data);
4504                   } else {
4505                     self.ws.send(data, opts);
4506                   }
4507                 } catch (e) {
4508                   debug('websocket closed before onclose event');
4509                 }
4510
4511                 --total || done();
4512               });
4513             })(packets[i]);
4514           }
4515
4516           function done () {
4517             self.emit('flush');
4518
4519             // fake drain
4520             // defer to next tick to allow Socket to clear writeBuffer
4521             setTimeout(function () {
4522               self.writable = true;
4523               self.emit('drain');
4524             }, 0);
4525           }
4526         };
4527
4528         /**
4529          * Called upon close
4530          *
4531          * @api private
4532          */
4533
4534         WS.prototype.onClose = function () {
4535           Transport.prototype.onClose.call(this);
4536         };
4537
4538         /**
4539          * Closes socket.
4540          *
4541          * @api private
4542          */
4543
4544         WS.prototype.doClose = function () {
4545           if (typeof this.ws !== 'undefined') {
4546             this.ws.close();
4547           }
4548         };
4549
4550         /**
4551          * Generates uri for connection.
4552          *
4553          * @api private
4554          */
4555
4556         WS.prototype.uri = function () {
4557           var query = this.query || {};
4558           var schema = this.secure ? 'wss' : 'ws';
4559           var port = '';
4560
4561           // avoid port if default for schema
4562           if (this.port && (('wss' === schema && Number(this.port) !== 443) ||
4563             ('ws' === schema && Number(this.port) !== 80))) {
4564             port = ':' + this.port;
4565           }
4566
4567           // append timestamp to URI
4568           if (this.timestampRequests) {
4569             query[this.timestampParam] = yeast();
4570           }
4571
4572           // communicate binary support capabilities
4573           if (!this.supportsBinary) {
4574             query.b64 = 1;
4575           }
4576
4577           query = parseqs.encode(query);
4578
4579           // prepend ? to query
4580           if (query.length) {
4581             query = '?' + query;
4582           }
4583
4584           var ipv6 = this.hostname.indexOf(':') !== -1;
4585           return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
4586         };
4587
4588         /**
4589          * Feature detection for WebSocket.
4590          *
4591          * @return {Boolean} whether this transport is available.
4592          * @api public
4593          */
4594
4595         WS.prototype.check = function () {
4596           return !!WebSocketImpl && !('__initialize' in WebSocketImpl && this.name === WS.prototype.name);
4597         };
4598
4599
4600 /***/ },
4601 /* 28 */
4602 /***/ function(module, exports) {
4603
4604         /* (ignored) */
4605
4606 /***/ },
4607 /* 29 */
4608 /***/ function(module, exports) {
4609
4610         
4611         var indexOf = [].indexOf;
4612
4613         module.exports = function(arr, obj){
4614           if (indexOf) return arr.indexOf(obj);
4615           for (var i = 0; i < arr.length; ++i) {
4616             if (arr[i] === obj) return i;
4617           }
4618           return -1;
4619         };
4620
4621 /***/ },
4622 /* 30 */
4623 /***/ function(module, exports) {
4624
4625         /**
4626          * Parses an URI
4627          *
4628          * @author Steven Levithan <stevenlevithan.com> (MIT license)
4629          * @api private
4630          */
4631
4632         var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
4633
4634         var parts = [
4635             'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
4636         ];
4637
4638         module.exports = function parseuri(str) {
4639             var src = str,
4640                 b = str.indexOf('['),
4641                 e = str.indexOf(']');
4642
4643             if (b != -1 && e != -1) {
4644                 str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
4645             }
4646
4647             var m = re.exec(str || ''),
4648                 uri = {},
4649                 i = 14;
4650
4651             while (i--) {
4652                 uri[parts[i]] = m[i] || '';
4653             }
4654
4655             if (b != -1 && e != -1) {
4656                 uri.source = src;
4657                 uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
4658                 uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
4659                 uri.ipv6uri = true;
4660             }
4661
4662             uri.pathNames = pathNames(uri, uri['path']);
4663             uri.queryKey = queryKey(uri, uri['query']);
4664
4665             return uri;
4666         };
4667
4668         function pathNames(obj, path) {
4669             var regx = /\/{2,9}/g,
4670                 names = path.replace(regx, "/").split("/");
4671
4672             if (path.substr(0, 1) == '/' || path.length === 0) {
4673                 names.splice(0, 1);
4674             }
4675             if (path.substr(path.length - 1, 1) == '/') {
4676                 names.splice(names.length - 1, 1);
4677             }
4678
4679             return names;
4680         }
4681
4682         function queryKey(uri, query) {
4683             var data = {};
4684
4685             query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) {
4686                 if ($1) {
4687                     data[$1] = $2;
4688                 }
4689             });
4690
4691             return data;
4692         }
4693
4694
4695 /***/ }
4696 /******/ ])
4697 });
4698 ;