[Service] Integrate DeviceHome and SignalingServer
[platform/framework/web/wrtjs.git] / device_home / node_modules / socket.io / node_modules / socket.io-client / dist / socket.io.dev.js
1 /*!
2  * Socket.IO v2.4.0
3  * (c) 2014-2021 Guillermo Rauch
4  * Released under the MIT License.
5  */
6 (function webpackUniversalModuleDefinition(root, factory) {
7         if(typeof exports === 'object' && typeof module === 'object')
8                 module.exports = factory();
9         else if(typeof define === 'function' && define.amd)
10                 define([], factory);
11         else if(typeof exports === 'object')
12                 exports["io"] = factory();
13         else
14                 root["io"] = factory();
15 })(this, function() {
16 return /******/ (function(modules) { // webpackBootstrap
17 /******/        // The module cache
18 /******/        var installedModules = {};
19 /******/
20 /******/        // The require function
21 /******/        function __webpack_require__(moduleId) {
22 /******/
23 /******/                // Check if module is in cache
24 /******/                if(installedModules[moduleId])
25 /******/                        return installedModules[moduleId].exports;
26 /******/
27 /******/                // Create a new module (and put it into the cache)
28 /******/                var module = installedModules[moduleId] = {
29 /******/                        exports: {},
30 /******/                        id: moduleId,
31 /******/                        loaded: false
32 /******/                };
33 /******/
34 /******/                // Execute the module function
35 /******/                modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
36 /******/
37 /******/                // Flag the module as loaded
38 /******/                module.loaded = true;
39 /******/
40 /******/                // Return the exports of the module
41 /******/                return module.exports;
42 /******/        }
43 /******/
44 /******/
45 /******/        // expose the modules object (__webpack_modules__)
46 /******/        __webpack_require__.m = modules;
47 /******/
48 /******/        // expose the module cache
49 /******/        __webpack_require__.c = installedModules;
50 /******/
51 /******/        // __webpack_public_path__
52 /******/        __webpack_require__.p = "";
53 /******/
54 /******/        // Load entry module and return exports
55 /******/        return __webpack_require__(0);
56 /******/ })
57 /************************************************************************/
58 /******/ ([
59 /* 0 */
60 /***/ (function(module, exports, __webpack_require__) {
61
62         
63         /**
64          * Module dependencies.
65          */
66         
67         var url = __webpack_require__(1);
68         var parser = __webpack_require__(7);
69         var Manager = __webpack_require__(12);
70         var debug = __webpack_require__(3)('socket.io-client');
71         
72         /**
73          * Module exports.
74          */
75         
76         module.exports = exports = lookup;
77         
78         /**
79          * Managers cache.
80          */
81         
82         var cache = exports.managers = {};
83         
84         /**
85          * Looks up an existing `Manager` for multiplexing.
86          * If the user summons:
87          *
88          *   `io('http://localhost/a');`
89          *   `io('http://localhost/b');`
90          *
91          * We reuse the existing instance based on same scheme/port/host,
92          * and we initialize sockets for each namespace.
93          *
94          * @api public
95          */
96         
97         function lookup (uri, opts) {
98           if (typeof uri === 'object') {
99             opts = uri;
100             uri = undefined;
101           }
102         
103           opts = opts || {};
104         
105           var parsed = url(uri);
106           var source = parsed.source;
107           var id = parsed.id;
108           var path = parsed.path;
109           var sameNamespace = cache[id] && path in cache[id].nsps;
110           var newConnection = opts.forceNew || opts['force new connection'] ||
111                               false === opts.multiplex || sameNamespace;
112         
113           var io;
114         
115           if (newConnection) {
116             debug('ignoring socket cache for %s', source);
117             io = Manager(source, opts);
118           } else {
119             if (!cache[id]) {
120               debug('new io instance for %s', source);
121               cache[id] = Manager(source, opts);
122             }
123             io = cache[id];
124           }
125           if (parsed.query && !opts.query) {
126             opts.query = parsed.query;
127           }
128           return io.socket(parsed.path, opts);
129         }
130         
131         /**
132          * Protocol version.
133          *
134          * @api public
135          */
136         
137         exports.protocol = parser.protocol;
138         
139         /**
140          * `connect`.
141          *
142          * @param {String} uri
143          * @api public
144          */
145         
146         exports.connect = lookup;
147         
148         /**
149          * Expose constructors for standalone build.
150          *
151          * @api public
152          */
153         
154         exports.Manager = __webpack_require__(12);
155         exports.Socket = __webpack_require__(37);
156
157
158 /***/ }),
159 /* 1 */
160 /***/ (function(module, exports, __webpack_require__) {
161
162         
163         /**
164          * Module dependencies.
165          */
166         
167         var parseuri = __webpack_require__(2);
168         var debug = __webpack_require__(3)('socket.io-client:url');
169         
170         /**
171          * Module exports.
172          */
173         
174         module.exports = url;
175         
176         /**
177          * URL parser.
178          *
179          * @param {String} url
180          * @param {Object} An object meant to mimic window.location.
181          *                 Defaults to window.location.
182          * @api public
183          */
184         
185         function url (uri, loc) {
186           var obj = uri;
187         
188           // default to window.location
189           loc = loc || (typeof location !== 'undefined' && location);
190           if (null == uri) uri = loc.protocol + '//' + loc.host;
191         
192           // relative path support
193           if ('string' === typeof uri) {
194             if ('/' === uri.charAt(0)) {
195               if ('/' === uri.charAt(1)) {
196                 uri = loc.protocol + uri;
197               } else {
198                 uri = loc.host + uri;
199               }
200             }
201         
202             if (!/^(https?|wss?):\/\//.test(uri)) {
203               debug('protocol-less url %s', uri);
204               if ('undefined' !== typeof loc) {
205                 uri = loc.protocol + '//' + uri;
206               } else {
207                 uri = 'https://' + uri;
208               }
209             }
210         
211             // parse
212             debug('parse %s', uri);
213             obj = parseuri(uri);
214           }
215         
216           // make sure we treat `localhost:80` and `localhost` equally
217           if (!obj.port) {
218             if (/^(http|ws)$/.test(obj.protocol)) {
219               obj.port = '80';
220             } else if (/^(http|ws)s$/.test(obj.protocol)) {
221               obj.port = '443';
222             }
223           }
224         
225           obj.path = obj.path || '/';
226         
227           var ipv6 = obj.host.indexOf(':') !== -1;
228           var host = ipv6 ? '[' + obj.host + ']' : obj.host;
229         
230           // define unique id
231           obj.id = obj.protocol + '://' + host + ':' + obj.port;
232           // define href
233           obj.href = obj.protocol + '://' + host + (loc && loc.port === obj.port ? '' : (':' + obj.port));
234         
235           return obj;
236         }
237
238
239 /***/ }),
240 /* 2 */
241 /***/ (function(module, exports) {
242
243         /**
244          * Parses an URI
245          *
246          * @author Steven Levithan <stevenlevithan.com> (MIT license)
247          * @api private
248          */
249         
250         var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
251         
252         var parts = [
253             'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
254         ];
255         
256         module.exports = function parseuri(str) {
257             var src = str,
258                 b = str.indexOf('['),
259                 e = str.indexOf(']');
260         
261             if (b != -1 && e != -1) {
262                 str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
263             }
264         
265             var m = re.exec(str || ''),
266                 uri = {},
267                 i = 14;
268         
269             while (i--) {
270                 uri[parts[i]] = m[i] || '';
271             }
272         
273             if (b != -1 && e != -1) {
274                 uri.source = src;
275                 uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
276                 uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
277                 uri.ipv6uri = true;
278             }
279         
280             uri.pathNames = pathNames(uri, uri['path']);
281             uri.queryKey = queryKey(uri, uri['query']);
282         
283             return uri;
284         };
285         
286         function pathNames(obj, path) {
287             var regx = /\/{2,9}/g,
288                 names = path.replace(regx, "/").split("/");
289         
290             if (path.substr(0, 1) == '/' || path.length === 0) {
291                 names.splice(0, 1);
292             }
293             if (path.substr(path.length - 1, 1) == '/') {
294                 names.splice(names.length - 1, 1);
295             }
296         
297             return names;
298         }
299         
300         function queryKey(uri, query) {
301             var data = {};
302         
303             query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) {
304                 if ($1) {
305                     data[$1] = $2;
306                 }
307             });
308         
309             return data;
310         }
311
312
313 /***/ }),
314 /* 3 */
315 /***/ (function(module, exports, __webpack_require__) {
316
317         /* WEBPACK VAR INJECTION */(function(process) {'use strict';
318         
319         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; };
320         
321         /**
322          * This is the web browser implementation of `debug()`.
323          *
324          * Expose `debug()` as the module.
325          */
326         
327         exports = module.exports = __webpack_require__(5);
328         exports.log = log;
329         exports.formatArgs = formatArgs;
330         exports.save = save;
331         exports.load = load;
332         exports.useColors = useColors;
333         exports.storage = 'undefined' != typeof chrome && 'undefined' != typeof chrome.storage ? chrome.storage.local : localstorage();
334         
335         /**
336          * Colors.
337          */
338         
339         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'];
340         
341         /**
342          * Currently only WebKit-based Web Inspectors, Firefox >= v31,
343          * and the Firebug extension (any Firefox version) are known
344          * to support "%c" CSS customizations.
345          *
346          * TODO: add a `localStorage` variable to explicitly enable/disable colors
347          */
348         
349         function useColors() {
350           // NB: In an Electron preload script, document will be defined but not fully
351           // initialized. Since we know we're in Chrome, we'll just detect this case
352           // explicitly
353           if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
354             return true;
355           }
356         
357           // Internet Explorer and Edge do not support colors.
358           if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
359             return false;
360           }
361         
362           // is webkit? http://stackoverflow.com/a/16459606/376773
363           // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
364           return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance ||
365           // is firebug? http://stackoverflow.com/a/398120/376773
366           typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) ||
367           // is firefox >= v31?
368           // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
369           typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 ||
370           // double check webkit in userAgent just in case we are in a worker
371           typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
372         }
373         
374         /**
375          * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
376          */
377         
378         exports.formatters.j = function (v) {
379           try {
380             return JSON.stringify(v);
381           } catch (err) {
382             return '[UnexpectedJSONParseError]: ' + err.message;
383           }
384         };
385         
386         /**
387          * Colorize log arguments if enabled.
388          *
389          * @api public
390          */
391         
392         function formatArgs(args) {
393           var useColors = this.useColors;
394         
395           args[0] = (useColors ? '%c' : '') + this.namespace + (useColors ? ' %c' : ' ') + args[0] + (useColors ? '%c ' : ' ') + '+' + exports.humanize(this.diff);
396         
397           if (!useColors) return;
398         
399           var c = 'color: ' + this.color;
400           args.splice(1, 0, c, 'color: inherit');
401         
402           // the final "%c" is somewhat tricky, because there could be other
403           // arguments passed either before or after the %c, so we need to
404           // figure out the correct index to insert the CSS into
405           var index = 0;
406           var lastC = 0;
407           args[0].replace(/%[a-zA-Z%]/g, function (match) {
408             if ('%%' === match) return;
409             index++;
410             if ('%c' === match) {
411               // we only are interested in the *last* %c
412               // (the user may have provided their own)
413               lastC = index;
414             }
415           });
416         
417           args.splice(lastC, 0, c);
418         }
419         
420         /**
421          * Invokes `console.log()` when available.
422          * No-op when `console.log` is not a "function".
423          *
424          * @api public
425          */
426         
427         function log() {
428           // this hackery is required for IE8/9, where
429           // the `console.log` function doesn't have 'apply'
430           return 'object' === (typeof console === 'undefined' ? 'undefined' : _typeof(console)) && console.log && Function.prototype.apply.call(console.log, console, arguments);
431         }
432         
433         /**
434          * Save `namespaces`.
435          *
436          * @param {String} namespaces
437          * @api private
438          */
439         
440         function save(namespaces) {
441           try {
442             if (null == namespaces) {
443               exports.storage.removeItem('debug');
444             } else {
445               exports.storage.debug = namespaces;
446             }
447           } catch (e) {}
448         }
449         
450         /**
451          * Load `namespaces`.
452          *
453          * @return {String} returns the previously persisted debug modes
454          * @api private
455          */
456         
457         function load() {
458           var r;
459           try {
460             r = exports.storage.debug;
461           } catch (e) {}
462         
463           // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
464           if (!r && typeof process !== 'undefined' && 'env' in process) {
465             r = process.env.DEBUG;
466           }
467         
468           return r;
469         }
470         
471         /**
472          * Enable namespaces listed in `localStorage.debug` initially.
473          */
474         
475         exports.enable(load());
476         
477         /**
478          * Localstorage attempts to return the localstorage.
479          *
480          * This is necessary because safari throws
481          * when a user disables cookies/localstorage
482          * and you attempt to access it.
483          *
484          * @return {LocalStorage}
485          * @api private
486          */
487         
488         function localstorage() {
489           try {
490             return window.localStorage;
491           } catch (e) {}
492         }
493         /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
494
495 /***/ }),
496 /* 4 */
497 /***/ (function(module, exports) {
498
499         // shim for using process in browser
500         var process = module.exports = {};
501         
502         // cached from whatever global is present so that test runners that stub it
503         // don't break things.  But we need to wrap it in a try catch in case it is
504         // wrapped in strict mode code which doesn't define any globals.  It's inside a
505         // function because try/catches deoptimize in certain engines.
506         
507         var cachedSetTimeout;
508         var cachedClearTimeout;
509         
510         function defaultSetTimout() {
511             throw new Error('setTimeout has not been defined');
512         }
513         function defaultClearTimeout () {
514             throw new Error('clearTimeout has not been defined');
515         }
516         (function () {
517             try {
518                 if (typeof setTimeout === 'function') {
519                     cachedSetTimeout = setTimeout;
520                 } else {
521                     cachedSetTimeout = defaultSetTimout;
522                 }
523             } catch (e) {
524                 cachedSetTimeout = defaultSetTimout;
525             }
526             try {
527                 if (typeof clearTimeout === 'function') {
528                     cachedClearTimeout = clearTimeout;
529                 } else {
530                     cachedClearTimeout = defaultClearTimeout;
531                 }
532             } catch (e) {
533                 cachedClearTimeout = defaultClearTimeout;
534             }
535         } ())
536         function runTimeout(fun) {
537             if (cachedSetTimeout === setTimeout) {
538                 //normal enviroments in sane situations
539                 return setTimeout(fun, 0);
540             }
541             // if setTimeout wasn't available but was latter defined
542             if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
543                 cachedSetTimeout = setTimeout;
544                 return setTimeout(fun, 0);
545             }
546             try {
547                 // when when somebody has screwed with setTimeout but no I.E. maddness
548                 return cachedSetTimeout(fun, 0);
549             } catch(e){
550                 try {
551                     // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
552                     return cachedSetTimeout.call(null, fun, 0);
553                 } catch(e){
554                     // 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
555                     return cachedSetTimeout.call(this, fun, 0);
556                 }
557             }
558         
559         
560         }
561         function runClearTimeout(marker) {
562             if (cachedClearTimeout === clearTimeout) {
563                 //normal enviroments in sane situations
564                 return clearTimeout(marker);
565             }
566             // if clearTimeout wasn't available but was latter defined
567             if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
568                 cachedClearTimeout = clearTimeout;
569                 return clearTimeout(marker);
570             }
571             try {
572                 // when when somebody has screwed with setTimeout but no I.E. maddness
573                 return cachedClearTimeout(marker);
574             } catch (e){
575                 try {
576                     // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
577                     return cachedClearTimeout.call(null, marker);
578                 } catch (e){
579                     // 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.
580                     // Some versions of I.E. have different rules for clearTimeout vs setTimeout
581                     return cachedClearTimeout.call(this, marker);
582                 }
583             }
584         
585         
586         
587         }
588         var queue = [];
589         var draining = false;
590         var currentQueue;
591         var queueIndex = -1;
592         
593         function cleanUpNextTick() {
594             if (!draining || !currentQueue) {
595                 return;
596             }
597             draining = false;
598             if (currentQueue.length) {
599                 queue = currentQueue.concat(queue);
600             } else {
601                 queueIndex = -1;
602             }
603             if (queue.length) {
604                 drainQueue();
605             }
606         }
607         
608         function drainQueue() {
609             if (draining) {
610                 return;
611             }
612             var timeout = runTimeout(cleanUpNextTick);
613             draining = true;
614         
615             var len = queue.length;
616             while(len) {
617                 currentQueue = queue;
618                 queue = [];
619                 while (++queueIndex < len) {
620                     if (currentQueue) {
621                         currentQueue[queueIndex].run();
622                     }
623                 }
624                 queueIndex = -1;
625                 len = queue.length;
626             }
627             currentQueue = null;
628             draining = false;
629             runClearTimeout(timeout);
630         }
631         
632         process.nextTick = function (fun) {
633             var args = new Array(arguments.length - 1);
634             if (arguments.length > 1) {
635                 for (var i = 1; i < arguments.length; i++) {
636                     args[i - 1] = arguments[i];
637                 }
638             }
639             queue.push(new Item(fun, args));
640             if (queue.length === 1 && !draining) {
641                 runTimeout(drainQueue);
642             }
643         };
644         
645         // v8 likes predictible objects
646         function Item(fun, array) {
647             this.fun = fun;
648             this.array = array;
649         }
650         Item.prototype.run = function () {
651             this.fun.apply(null, this.array);
652         };
653         process.title = 'browser';
654         process.browser = true;
655         process.env = {};
656         process.argv = [];
657         process.version = ''; // empty string to avoid regexp issues
658         process.versions = {};
659         
660         function noop() {}
661         
662         process.on = noop;
663         process.addListener = noop;
664         process.once = noop;
665         process.off = noop;
666         process.removeListener = noop;
667         process.removeAllListeners = noop;
668         process.emit = noop;
669         process.prependListener = noop;
670         process.prependOnceListener = noop;
671         
672         process.listeners = function (name) { return [] }
673         
674         process.binding = function (name) {
675             throw new Error('process.binding is not supported');
676         };
677         
678         process.cwd = function () { return '/' };
679         process.chdir = function (dir) {
680             throw new Error('process.chdir is not supported');
681         };
682         process.umask = function() { return 0; };
683
684
685 /***/ }),
686 /* 5 */
687 /***/ (function(module, exports, __webpack_require__) {
688
689         'use strict';
690         
691         /**
692          * This is the common logic for both the Node.js and web browser
693          * implementations of `debug()`.
694          *
695          * Expose `debug()` as the module.
696          */
697         
698         exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
699         exports.coerce = coerce;
700         exports.disable = disable;
701         exports.enable = enable;
702         exports.enabled = enabled;
703         exports.humanize = __webpack_require__(6);
704         
705         /**
706          * Active `debug` instances.
707          */
708         exports.instances = [];
709         
710         /**
711          * The currently active debug mode names, and names to skip.
712          */
713         
714         exports.names = [];
715         exports.skips = [];
716         
717         /**
718          * Map of special "%n" handling functions, for the debug "format" argument.
719          *
720          * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
721          */
722         
723         exports.formatters = {};
724         
725         /**
726          * Select a color.
727          * @param {String} namespace
728          * @return {Number}
729          * @api private
730          */
731         
732         function selectColor(namespace) {
733           var hash = 0,
734               i;
735         
736           for (i in namespace) {
737             hash = (hash << 5) - hash + namespace.charCodeAt(i);
738             hash |= 0; // Convert to 32bit integer
739           }
740         
741           return exports.colors[Math.abs(hash) % exports.colors.length];
742         }
743         
744         /**
745          * Create a debugger with the given `namespace`.
746          *
747          * @param {String} namespace
748          * @return {Function}
749          * @api public
750          */
751         
752         function createDebug(namespace) {
753         
754           var prevTime;
755         
756           function debug() {
757             // disabled?
758             if (!debug.enabled) return;
759         
760             var self = debug;
761         
762             // set `diff` timestamp
763             var curr = +new Date();
764             var ms = curr - (prevTime || curr);
765             self.diff = ms;
766             self.prev = prevTime;
767             self.curr = curr;
768             prevTime = curr;
769         
770             // turn the `arguments` into a proper Array
771             var args = new Array(arguments.length);
772             for (var i = 0; i < args.length; i++) {
773               args[i] = arguments[i];
774             }
775         
776             args[0] = exports.coerce(args[0]);
777         
778             if ('string' !== typeof args[0]) {
779               // anything else let's inspect with %O
780               args.unshift('%O');
781             }
782         
783             // apply any `formatters` transformations
784             var index = 0;
785             args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
786               // if we encounter an escaped % then don't increase the array index
787               if (match === '%%') return match;
788               index++;
789               var formatter = exports.formatters[format];
790               if ('function' === typeof formatter) {
791                 var val = args[index];
792                 match = formatter.call(self, val);
793         
794                 // now we need to remove `args[index]` since it's inlined in the `format`
795                 args.splice(index, 1);
796                 index--;
797               }
798               return match;
799             });
800         
801             // apply env-specific formatting (colors, etc.)
802             exports.formatArgs.call(self, args);
803         
804             var logFn = debug.log || exports.log || console.log.bind(console);
805             logFn.apply(self, args);
806           }
807         
808           debug.namespace = namespace;
809           debug.enabled = exports.enabled(namespace);
810           debug.useColors = exports.useColors();
811           debug.color = selectColor(namespace);
812           debug.destroy = destroy;
813         
814           // env-specific initialization logic for debug instances
815           if ('function' === typeof exports.init) {
816             exports.init(debug);
817           }
818         
819           exports.instances.push(debug);
820         
821           return debug;
822         }
823         
824         function destroy() {
825           var index = exports.instances.indexOf(this);
826           if (index !== -1) {
827             exports.instances.splice(index, 1);
828             return true;
829           } else {
830             return false;
831           }
832         }
833         
834         /**
835          * Enables a debug mode by namespaces. This can include modes
836          * separated by a colon and wildcards.
837          *
838          * @param {String} namespaces
839          * @api public
840          */
841         
842         function enable(namespaces) {
843           exports.save(namespaces);
844         
845           exports.names = [];
846           exports.skips = [];
847         
848           var i;
849           var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
850           var len = split.length;
851         
852           for (i = 0; i < len; i++) {
853             if (!split[i]) continue; // ignore empty strings
854             namespaces = split[i].replace(/\*/g, '.*?');
855             if (namespaces[0] === '-') {
856               exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
857             } else {
858               exports.names.push(new RegExp('^' + namespaces + '$'));
859             }
860           }
861         
862           for (i = 0; i < exports.instances.length; i++) {
863             var instance = exports.instances[i];
864             instance.enabled = exports.enabled(instance.namespace);
865           }
866         }
867         
868         /**
869          * Disable debug output.
870          *
871          * @api public
872          */
873         
874         function disable() {
875           exports.enable('');
876         }
877         
878         /**
879          * Returns true if the given mode name is enabled, false otherwise.
880          *
881          * @param {String} name
882          * @return {Boolean}
883          * @api public
884          */
885         
886         function enabled(name) {
887           if (name[name.length - 1] === '*') {
888             return true;
889           }
890           var i, len;
891           for (i = 0, len = exports.skips.length; i < len; i++) {
892             if (exports.skips[i].test(name)) {
893               return false;
894             }
895           }
896           for (i = 0, len = exports.names.length; i < len; i++) {
897             if (exports.names[i].test(name)) {
898               return true;
899             }
900           }
901           return false;
902         }
903         
904         /**
905          * Coerce `val`.
906          *
907          * @param {Mixed} val
908          * @return {Mixed}
909          * @api private
910          */
911         
912         function coerce(val) {
913           if (val instanceof Error) return val.stack || val.message;
914           return val;
915         }
916
917 /***/ }),
918 /* 6 */
919 /***/ (function(module, exports) {
920
921         /**
922          * Helpers.
923          */
924         
925         var s = 1000;
926         var m = s * 60;
927         var h = m * 60;
928         var d = h * 24;
929         var y = d * 365.25;
930         
931         /**
932          * Parse or format the given `val`.
933          *
934          * Options:
935          *
936          *  - `long` verbose formatting [false]
937          *
938          * @param {String|Number} val
939          * @param {Object} [options]
940          * @throws {Error} throw an error if val is not a non-empty string or a number
941          * @return {String|Number}
942          * @api public
943          */
944         
945         module.exports = function(val, options) {
946           options = options || {};
947           var type = typeof val;
948           if (type === 'string' && val.length > 0) {
949             return parse(val);
950           } else if (type === 'number' && isNaN(val) === false) {
951             return options.long ? fmtLong(val) : fmtShort(val);
952           }
953           throw new Error(
954             'val is not a non-empty string or a valid number. val=' +
955               JSON.stringify(val)
956           );
957         };
958         
959         /**
960          * Parse the given `str` and return milliseconds.
961          *
962          * @param {String} str
963          * @return {Number}
964          * @api private
965          */
966         
967         function parse(str) {
968           str = String(str);
969           if (str.length > 100) {
970             return;
971           }
972           var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
973             str
974           );
975           if (!match) {
976             return;
977           }
978           var n = parseFloat(match[1]);
979           var type = (match[2] || 'ms').toLowerCase();
980           switch (type) {
981             case 'years':
982             case 'year':
983             case 'yrs':
984             case 'yr':
985             case 'y':
986               return n * y;
987             case 'days':
988             case 'day':
989             case 'd':
990               return n * d;
991             case 'hours':
992             case 'hour':
993             case 'hrs':
994             case 'hr':
995             case 'h':
996               return n * h;
997             case 'minutes':
998             case 'minute':
999             case 'mins':
1000             case 'min':
1001             case 'm':
1002               return n * m;
1003             case 'seconds':
1004             case 'second':
1005             case 'secs':
1006             case 'sec':
1007             case 's':
1008               return n * s;
1009             case 'milliseconds':
1010             case 'millisecond':
1011             case 'msecs':
1012             case 'msec':
1013             case 'ms':
1014               return n;
1015             default:
1016               return undefined;
1017           }
1018         }
1019         
1020         /**
1021          * Short format for `ms`.
1022          *
1023          * @param {Number} ms
1024          * @return {String}
1025          * @api private
1026          */
1027         
1028         function fmtShort(ms) {
1029           if (ms >= d) {
1030             return Math.round(ms / d) + 'd';
1031           }
1032           if (ms >= h) {
1033             return Math.round(ms / h) + 'h';
1034           }
1035           if (ms >= m) {
1036             return Math.round(ms / m) + 'm';
1037           }
1038           if (ms >= s) {
1039             return Math.round(ms / s) + 's';
1040           }
1041           return ms + 'ms';
1042         }
1043         
1044         /**
1045          * Long format for `ms`.
1046          *
1047          * @param {Number} ms
1048          * @return {String}
1049          * @api private
1050          */
1051         
1052         function fmtLong(ms) {
1053           return plural(ms, d, 'day') ||
1054             plural(ms, h, 'hour') ||
1055             plural(ms, m, 'minute') ||
1056             plural(ms, s, 'second') ||
1057             ms + ' ms';
1058         }
1059         
1060         /**
1061          * Pluralization helper.
1062          */
1063         
1064         function plural(ms, n, name) {
1065           if (ms < n) {
1066             return;
1067           }
1068           if (ms < n * 1.5) {
1069             return Math.floor(ms / n) + ' ' + name;
1070           }
1071           return Math.ceil(ms / n) + ' ' + name + 's';
1072         }
1073
1074
1075 /***/ }),
1076 /* 7 */
1077 /***/ (function(module, exports, __webpack_require__) {
1078
1079         
1080         /**
1081          * Module dependencies.
1082          */
1083         
1084         var debug = __webpack_require__(3)('socket.io-parser');
1085         var Emitter = __webpack_require__(8);
1086         var binary = __webpack_require__(9);
1087         var isArray = __webpack_require__(10);
1088         var isBuf = __webpack_require__(11);
1089         
1090         /**
1091          * Protocol version.
1092          *
1093          * @api public
1094          */
1095         
1096         exports.protocol = 4;
1097         
1098         /**
1099          * Packet types.
1100          *
1101          * @api public
1102          */
1103         
1104         exports.types = [
1105           'CONNECT',
1106           'DISCONNECT',
1107           'EVENT',
1108           'ACK',
1109           'ERROR',
1110           'BINARY_EVENT',
1111           'BINARY_ACK'
1112         ];
1113         
1114         /**
1115          * Packet type `connect`.
1116          *
1117          * @api public
1118          */
1119         
1120         exports.CONNECT = 0;
1121         
1122         /**
1123          * Packet type `disconnect`.
1124          *
1125          * @api public
1126          */
1127         
1128         exports.DISCONNECT = 1;
1129         
1130         /**
1131          * Packet type `event`.
1132          *
1133          * @api public
1134          */
1135         
1136         exports.EVENT = 2;
1137         
1138         /**
1139          * Packet type `ack`.
1140          *
1141          * @api public
1142          */
1143         
1144         exports.ACK = 3;
1145         
1146         /**
1147          * Packet type `error`.
1148          *
1149          * @api public
1150          */
1151         
1152         exports.ERROR = 4;
1153         
1154         /**
1155          * Packet type 'binary event'
1156          *
1157          * @api public
1158          */
1159         
1160         exports.BINARY_EVENT = 5;
1161         
1162         /**
1163          * Packet type `binary ack`. For acks with binary arguments.
1164          *
1165          * @api public
1166          */
1167         
1168         exports.BINARY_ACK = 6;
1169         
1170         /**
1171          * Encoder constructor.
1172          *
1173          * @api public
1174          */
1175         
1176         exports.Encoder = Encoder;
1177         
1178         /**
1179          * Decoder constructor.
1180          *
1181          * @api public
1182          */
1183         
1184         exports.Decoder = Decoder;
1185         
1186         /**
1187          * A socket.io Encoder instance
1188          *
1189          * @api public
1190          */
1191         
1192         function Encoder() {}
1193         
1194         var ERROR_PACKET = exports.ERROR + '"encode error"';
1195         
1196         /**
1197          * Encode a packet as a single string if non-binary, or as a
1198          * buffer sequence, depending on packet type.
1199          *
1200          * @param {Object} obj - packet object
1201          * @param {Function} callback - function to handle encodings (likely engine.write)
1202          * @return Calls callback with Array of encodings
1203          * @api public
1204          */
1205         
1206         Encoder.prototype.encode = function(obj, callback){
1207           debug('encoding packet %j', obj);
1208         
1209           if (exports.BINARY_EVENT === obj.type || exports.BINARY_ACK === obj.type) {
1210             encodeAsBinary(obj, callback);
1211           } else {
1212             var encoding = encodeAsString(obj);
1213             callback([encoding]);
1214           }
1215         };
1216         
1217         /**
1218          * Encode packet as string.
1219          *
1220          * @param {Object} packet
1221          * @return {String} encoded
1222          * @api private
1223          */
1224         
1225         function encodeAsString(obj) {
1226         
1227           // first is type
1228           var str = '' + obj.type;
1229         
1230           // attachments if we have them
1231           if (exports.BINARY_EVENT === obj.type || exports.BINARY_ACK === obj.type) {
1232             str += obj.attachments + '-';
1233           }
1234         
1235           // if we have a namespace other than `/`
1236           // we append it followed by a comma `,`
1237           if (obj.nsp && '/' !== obj.nsp) {
1238             str += obj.nsp + ',';
1239           }
1240         
1241           // immediately followed by the id
1242           if (null != obj.id) {
1243             str += obj.id;
1244           }
1245         
1246           // json data
1247           if (null != obj.data) {
1248             var payload = tryStringify(obj.data);
1249             if (payload !== false) {
1250               str += payload;
1251             } else {
1252               return ERROR_PACKET;
1253             }
1254           }
1255         
1256           debug('encoded %j as %s', obj, str);
1257           return str;
1258         }
1259         
1260         function tryStringify(str) {
1261           try {
1262             return JSON.stringify(str);
1263           } catch(e){
1264             return false;
1265           }
1266         }
1267         
1268         /**
1269          * Encode packet as 'buffer sequence' by removing blobs, and
1270          * deconstructing packet into object with placeholders and
1271          * a list of buffers.
1272          *
1273          * @param {Object} packet
1274          * @return {Buffer} encoded
1275          * @api private
1276          */
1277         
1278         function encodeAsBinary(obj, callback) {
1279         
1280           function writeEncoding(bloblessData) {
1281             var deconstruction = binary.deconstructPacket(bloblessData);
1282             var pack = encodeAsString(deconstruction.packet);
1283             var buffers = deconstruction.buffers;
1284         
1285             buffers.unshift(pack); // add packet info to beginning of data list
1286             callback(buffers); // write all the buffers
1287           }
1288         
1289           binary.removeBlobs(obj, writeEncoding);
1290         }
1291         
1292         /**
1293          * A socket.io Decoder instance
1294          *
1295          * @return {Object} decoder
1296          * @api public
1297          */
1298         
1299         function Decoder() {
1300           this.reconstructor = null;
1301         }
1302         
1303         /**
1304          * Mix in `Emitter` with Decoder.
1305          */
1306         
1307         Emitter(Decoder.prototype);
1308         
1309         /**
1310          * Decodes an encoded packet string into packet JSON.
1311          *
1312          * @param {String} obj - encoded packet
1313          * @return {Object} packet
1314          * @api public
1315          */
1316         
1317         Decoder.prototype.add = function(obj) {
1318           var packet;
1319           if (typeof obj === 'string') {
1320             packet = decodeString(obj);
1321             if (exports.BINARY_EVENT === packet.type || exports.BINARY_ACK === packet.type) { // binary packet's json
1322               this.reconstructor = new BinaryReconstructor(packet);
1323         
1324               // no attachments, labeled binary but no binary data to follow
1325               if (this.reconstructor.reconPack.attachments === 0) {
1326                 this.emit('decoded', packet);
1327               }
1328             } else { // non-binary full packet
1329               this.emit('decoded', packet);
1330             }
1331           } else if (isBuf(obj) || obj.base64) { // raw binary data
1332             if (!this.reconstructor) {
1333               throw new Error('got binary data when not reconstructing a packet');
1334             } else {
1335               packet = this.reconstructor.takeBinaryData(obj);
1336               if (packet) { // received final buffer
1337                 this.reconstructor = null;
1338                 this.emit('decoded', packet);
1339               }
1340             }
1341           } else {
1342             throw new Error('Unknown type: ' + obj);
1343           }
1344         };
1345         
1346         /**
1347          * Decode a packet String (JSON data)
1348          *
1349          * @param {String} str
1350          * @return {Object} packet
1351          * @api private
1352          */
1353         
1354         function decodeString(str) {
1355           var i = 0;
1356           // look up type
1357           var p = {
1358             type: Number(str.charAt(0))
1359           };
1360         
1361           if (null == exports.types[p.type]) {
1362             return error('unknown packet type ' + p.type);
1363           }
1364         
1365           // look up attachments if type binary
1366           if (exports.BINARY_EVENT === p.type || exports.BINARY_ACK === p.type) {
1367             var buf = '';
1368             while (str.charAt(++i) !== '-') {
1369               buf += str.charAt(i);
1370               if (i == str.length) break;
1371             }
1372             if (buf != Number(buf) || str.charAt(i) !== '-') {
1373               throw new Error('Illegal attachments');
1374             }
1375             p.attachments = Number(buf);
1376           }
1377         
1378           // look up namespace (if any)
1379           if ('/' === str.charAt(i + 1)) {
1380             p.nsp = '';
1381             while (++i) {
1382               var c = str.charAt(i);
1383               if (',' === c) break;
1384               p.nsp += c;
1385               if (i === str.length) break;
1386             }
1387           } else {
1388             p.nsp = '/';
1389           }
1390         
1391           // look up id
1392           var next = str.charAt(i + 1);
1393           if ('' !== next && Number(next) == next) {
1394             p.id = '';
1395             while (++i) {
1396               var c = str.charAt(i);
1397               if (null == c || Number(c) != c) {
1398                 --i;
1399                 break;
1400               }
1401               p.id += str.charAt(i);
1402               if (i === str.length) break;
1403             }
1404             p.id = Number(p.id);
1405           }
1406         
1407           // look up json data
1408           if (str.charAt(++i)) {
1409             var payload = tryParse(str.substr(i));
1410             var isPayloadValid = payload !== false && (p.type === exports.ERROR || isArray(payload));
1411             if (isPayloadValid) {
1412               p.data = payload;
1413             } else {
1414               return error('invalid payload');
1415             }
1416           }
1417         
1418           debug('decoded %s as %j', str, p);
1419           return p;
1420         }
1421         
1422         function tryParse(str) {
1423           try {
1424             return JSON.parse(str);
1425           } catch(e){
1426             return false;
1427           }
1428         }
1429         
1430         /**
1431          * Deallocates a parser's resources
1432          *
1433          * @api public
1434          */
1435         
1436         Decoder.prototype.destroy = function() {
1437           if (this.reconstructor) {
1438             this.reconstructor.finishedReconstruction();
1439           }
1440         };
1441         
1442         /**
1443          * A manager of a binary event's 'buffer sequence'. Should
1444          * be constructed whenever a packet of type BINARY_EVENT is
1445          * decoded.
1446          *
1447          * @param {Object} packet
1448          * @return {BinaryReconstructor} initialized reconstructor
1449          * @api private
1450          */
1451         
1452         function BinaryReconstructor(packet) {
1453           this.reconPack = packet;
1454           this.buffers = [];
1455         }
1456         
1457         /**
1458          * Method to be called when binary data received from connection
1459          * after a BINARY_EVENT packet.
1460          *
1461          * @param {Buffer | ArrayBuffer} binData - the raw binary data received
1462          * @return {null | Object} returns null if more binary data is expected or
1463          *   a reconstructed packet object if all buffers have been received.
1464          * @api private
1465          */
1466         
1467         BinaryReconstructor.prototype.takeBinaryData = function(binData) {
1468           this.buffers.push(binData);
1469           if (this.buffers.length === this.reconPack.attachments) { // done with buffer list
1470             var packet = binary.reconstructPacket(this.reconPack, this.buffers);
1471             this.finishedReconstruction();
1472             return packet;
1473           }
1474           return null;
1475         };
1476         
1477         /**
1478          * Cleans up binary packet reconstruction variables.
1479          *
1480          * @api private
1481          */
1482         
1483         BinaryReconstructor.prototype.finishedReconstruction = function() {
1484           this.reconPack = null;
1485           this.buffers = [];
1486         };
1487         
1488         function error(msg) {
1489           return {
1490             type: exports.ERROR,
1491             data: 'parser error: ' + msg
1492           };
1493         }
1494
1495
1496 /***/ }),
1497 /* 8 */
1498 /***/ (function(module, exports, __webpack_require__) {
1499
1500         
1501         /**
1502          * Expose `Emitter`.
1503          */
1504         
1505         if (true) {
1506           module.exports = Emitter;
1507         }
1508         
1509         /**
1510          * Initialize a new `Emitter`.
1511          *
1512          * @api public
1513          */
1514         
1515         function Emitter(obj) {
1516           if (obj) return mixin(obj);
1517         };
1518         
1519         /**
1520          * Mixin the emitter properties.
1521          *
1522          * @param {Object} obj
1523          * @return {Object}
1524          * @api private
1525          */
1526         
1527         function mixin(obj) {
1528           for (var key in Emitter.prototype) {
1529             obj[key] = Emitter.prototype[key];
1530           }
1531           return obj;
1532         }
1533         
1534         /**
1535          * Listen on the given `event` with `fn`.
1536          *
1537          * @param {String} event
1538          * @param {Function} fn
1539          * @return {Emitter}
1540          * @api public
1541          */
1542         
1543         Emitter.prototype.on =
1544         Emitter.prototype.addEventListener = function(event, fn){
1545           this._callbacks = this._callbacks || {};
1546           (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
1547             .push(fn);
1548           return this;
1549         };
1550         
1551         /**
1552          * Adds an `event` listener that will be invoked a single
1553          * time then automatically removed.
1554          *
1555          * @param {String} event
1556          * @param {Function} fn
1557          * @return {Emitter}
1558          * @api public
1559          */
1560         
1561         Emitter.prototype.once = function(event, fn){
1562           function on() {
1563             this.off(event, on);
1564             fn.apply(this, arguments);
1565           }
1566         
1567           on.fn = fn;
1568           this.on(event, on);
1569           return this;
1570         };
1571         
1572         /**
1573          * Remove the given callback for `event` or all
1574          * registered callbacks.
1575          *
1576          * @param {String} event
1577          * @param {Function} fn
1578          * @return {Emitter}
1579          * @api public
1580          */
1581         
1582         Emitter.prototype.off =
1583         Emitter.prototype.removeListener =
1584         Emitter.prototype.removeAllListeners =
1585         Emitter.prototype.removeEventListener = function(event, fn){
1586           this._callbacks = this._callbacks || {};
1587         
1588           // all
1589           if (0 == arguments.length) {
1590             this._callbacks = {};
1591             return this;
1592           }
1593         
1594           // specific event
1595           var callbacks = this._callbacks['$' + event];
1596           if (!callbacks) return this;
1597         
1598           // remove all handlers
1599           if (1 == arguments.length) {
1600             delete this._callbacks['$' + event];
1601             return this;
1602           }
1603         
1604           // remove specific handler
1605           var cb;
1606           for (var i = 0; i < callbacks.length; i++) {
1607             cb = callbacks[i];
1608             if (cb === fn || cb.fn === fn) {
1609               callbacks.splice(i, 1);
1610               break;
1611             }
1612           }
1613         
1614           // Remove event specific arrays for event types that no
1615           // one is subscribed for to avoid memory leak.
1616           if (callbacks.length === 0) {
1617             delete this._callbacks['$' + event];
1618           }
1619         
1620           return this;
1621         };
1622         
1623         /**
1624          * Emit `event` with the given args.
1625          *
1626          * @param {String} event
1627          * @param {Mixed} ...
1628          * @return {Emitter}
1629          */
1630         
1631         Emitter.prototype.emit = function(event){
1632           this._callbacks = this._callbacks || {};
1633         
1634           var args = new Array(arguments.length - 1)
1635             , callbacks = this._callbacks['$' + event];
1636         
1637           for (var i = 1; i < arguments.length; i++) {
1638             args[i - 1] = arguments[i];
1639           }
1640         
1641           if (callbacks) {
1642             callbacks = callbacks.slice(0);
1643             for (var i = 0, len = callbacks.length; i < len; ++i) {
1644               callbacks[i].apply(this, args);
1645             }
1646           }
1647         
1648           return this;
1649         };
1650         
1651         /**
1652          * Return array of callbacks for `event`.
1653          *
1654          * @param {String} event
1655          * @return {Array}
1656          * @api public
1657          */
1658         
1659         Emitter.prototype.listeners = function(event){
1660           this._callbacks = this._callbacks || {};
1661           return this._callbacks['$' + event] || [];
1662         };
1663         
1664         /**
1665          * Check if this emitter has `event` handlers.
1666          *
1667          * @param {String} event
1668          * @return {Boolean}
1669          * @api public
1670          */
1671         
1672         Emitter.prototype.hasListeners = function(event){
1673           return !! this.listeners(event).length;
1674         };
1675
1676
1677 /***/ }),
1678 /* 9 */
1679 /***/ (function(module, exports, __webpack_require__) {
1680
1681         /*global Blob,File*/
1682         
1683         /**
1684          * Module requirements
1685          */
1686         
1687         var isArray = __webpack_require__(10);
1688         var isBuf = __webpack_require__(11);
1689         var toString = Object.prototype.toString;
1690         var withNativeBlob = typeof Blob === 'function' || (typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]');
1691         var withNativeFile = typeof File === 'function' || (typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]');
1692         
1693         /**
1694          * Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder.
1695          * Anything with blobs or files should be fed through removeBlobs before coming
1696          * here.
1697          *
1698          * @param {Object} packet - socket.io event packet
1699          * @return {Object} with deconstructed packet and list of buffers
1700          * @api public
1701          */
1702         
1703         exports.deconstructPacket = function(packet) {
1704           var buffers = [];
1705           var packetData = packet.data;
1706           var pack = packet;
1707           pack.data = _deconstructPacket(packetData, buffers);
1708           pack.attachments = buffers.length; // number of binary 'attachments'
1709           return {packet: pack, buffers: buffers};
1710         };
1711         
1712         function _deconstructPacket(data, buffers) {
1713           if (!data) return data;
1714         
1715           if (isBuf(data)) {
1716             var placeholder = { _placeholder: true, num: buffers.length };
1717             buffers.push(data);
1718             return placeholder;
1719           } else if (isArray(data)) {
1720             var newData = new Array(data.length);
1721             for (var i = 0; i < data.length; i++) {
1722               newData[i] = _deconstructPacket(data[i], buffers);
1723             }
1724             return newData;
1725           } else if (typeof data === 'object' && !(data instanceof Date)) {
1726             var newData = {};
1727             for (var key in data) {
1728               newData[key] = _deconstructPacket(data[key], buffers);
1729             }
1730             return newData;
1731           }
1732           return data;
1733         }
1734         
1735         /**
1736          * Reconstructs a binary packet from its placeholder packet and buffers
1737          *
1738          * @param {Object} packet - event packet with placeholders
1739          * @param {Array} buffers - binary buffers to put in placeholder positions
1740          * @return {Object} reconstructed packet
1741          * @api public
1742          */
1743         
1744         exports.reconstructPacket = function(packet, buffers) {
1745           packet.data = _reconstructPacket(packet.data, buffers);
1746           packet.attachments = undefined; // no longer useful
1747           return packet;
1748         };
1749         
1750         function _reconstructPacket(data, buffers) {
1751           if (!data) return data;
1752         
1753           if (data && data._placeholder) {
1754             return buffers[data.num]; // appropriate buffer (should be natural order anyway)
1755           } else if (isArray(data)) {
1756             for (var i = 0; i < data.length; i++) {
1757               data[i] = _reconstructPacket(data[i], buffers);
1758             }
1759           } else if (typeof data === 'object') {
1760             for (var key in data) {
1761               data[key] = _reconstructPacket(data[key], buffers);
1762             }
1763           }
1764         
1765           return data;
1766         }
1767         
1768         /**
1769          * Asynchronously removes Blobs or Files from data via
1770          * FileReader's readAsArrayBuffer method. Used before encoding
1771          * data as msgpack. Calls callback with the blobless data.
1772          *
1773          * @param {Object} data
1774          * @param {Function} callback
1775          * @api private
1776          */
1777         
1778         exports.removeBlobs = function(data, callback) {
1779           function _removeBlobs(obj, curKey, containingObject) {
1780             if (!obj) return obj;
1781         
1782             // convert any blob
1783             if ((withNativeBlob && obj instanceof Blob) ||
1784                 (withNativeFile && obj instanceof File)) {
1785               pendingBlobs++;
1786         
1787               // async filereader
1788               var fileReader = new FileReader();
1789               fileReader.onload = function() { // this.result == arraybuffer
1790                 if (containingObject) {
1791                   containingObject[curKey] = this.result;
1792                 }
1793                 else {
1794                   bloblessData = this.result;
1795                 }
1796         
1797                 // if nothing pending its callback time
1798                 if(! --pendingBlobs) {
1799                   callback(bloblessData);
1800                 }
1801               };
1802         
1803               fileReader.readAsArrayBuffer(obj); // blob -> arraybuffer
1804             } else if (isArray(obj)) { // handle array
1805               for (var i = 0; i < obj.length; i++) {
1806                 _removeBlobs(obj[i], i, obj);
1807               }
1808             } else if (typeof obj === 'object' && !isBuf(obj)) { // and object
1809               for (var key in obj) {
1810                 _removeBlobs(obj[key], key, obj);
1811               }
1812             }
1813           }
1814         
1815           var pendingBlobs = 0;
1816           var bloblessData = data;
1817           _removeBlobs(bloblessData);
1818           if (!pendingBlobs) {
1819             callback(bloblessData);
1820           }
1821         };
1822
1823
1824 /***/ }),
1825 /* 10 */
1826 /***/ (function(module, exports) {
1827
1828         var toString = {}.toString;
1829         
1830         module.exports = Array.isArray || function (arr) {
1831           return toString.call(arr) == '[object Array]';
1832         };
1833
1834
1835 /***/ }),
1836 /* 11 */
1837 /***/ (function(module, exports) {
1838
1839         
1840         module.exports = isBuf;
1841         
1842         var withNativeBuffer = typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function';
1843         var withNativeArrayBuffer = typeof ArrayBuffer === 'function';
1844         
1845         var isView = function (obj) {
1846           return typeof ArrayBuffer.isView === 'function' ? ArrayBuffer.isView(obj) : (obj.buffer instanceof ArrayBuffer);
1847         };
1848         
1849         /**
1850          * Returns true if obj is a buffer or an arraybuffer.
1851          *
1852          * @api private
1853          */
1854         
1855         function isBuf(obj) {
1856           return (withNativeBuffer && Buffer.isBuffer(obj)) ||
1857                   (withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj)));
1858         }
1859
1860
1861 /***/ }),
1862 /* 12 */
1863 /***/ (function(module, exports, __webpack_require__) {
1864
1865         
1866         /**
1867          * Module dependencies.
1868          */
1869         
1870         var eio = __webpack_require__(13);
1871         var Socket = __webpack_require__(37);
1872         var Emitter = __webpack_require__(8);
1873         var parser = __webpack_require__(7);
1874         var on = __webpack_require__(39);
1875         var bind = __webpack_require__(40);
1876         var debug = __webpack_require__(3)('socket.io-client:manager');
1877         var indexOf = __webpack_require__(36);
1878         var Backoff = __webpack_require__(41);
1879         
1880         /**
1881          * IE6+ hasOwnProperty
1882          */
1883         
1884         var has = Object.prototype.hasOwnProperty;
1885         
1886         /**
1887          * Module exports
1888          */
1889         
1890         module.exports = Manager;
1891         
1892         /**
1893          * `Manager` constructor.
1894          *
1895          * @param {String} engine instance or engine uri/opts
1896          * @param {Object} options
1897          * @api public
1898          */
1899         
1900         function Manager (uri, opts) {
1901           if (!(this instanceof Manager)) return new Manager(uri, opts);
1902           if (uri && ('object' === typeof uri)) {
1903             opts = uri;
1904             uri = undefined;
1905           }
1906           opts = opts || {};
1907         
1908           opts.path = opts.path || '/socket.io';
1909           this.nsps = {};
1910           this.subs = [];
1911           this.opts = opts;
1912           this.reconnection(opts.reconnection !== false);
1913           this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
1914           this.reconnectionDelay(opts.reconnectionDelay || 1000);
1915           this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);
1916           this.randomizationFactor(opts.randomizationFactor || 0.5);
1917           this.backoff = new Backoff({
1918             min: this.reconnectionDelay(),
1919             max: this.reconnectionDelayMax(),
1920             jitter: this.randomizationFactor()
1921           });
1922           this.timeout(null == opts.timeout ? 20000 : opts.timeout);
1923           this.readyState = 'closed';
1924           this.uri = uri;
1925           this.connecting = [];
1926           this.lastPing = null;
1927           this.encoding = false;
1928           this.packetBuffer = [];
1929           var _parser = opts.parser || parser;
1930           this.encoder = new _parser.Encoder();
1931           this.decoder = new _parser.Decoder();
1932           this.autoConnect = opts.autoConnect !== false;
1933           if (this.autoConnect) this.open();
1934         }
1935         
1936         /**
1937          * Propagate given event to sockets and emit on `this`
1938          *
1939          * @api private
1940          */
1941         
1942         Manager.prototype.emitAll = function () {
1943           this.emit.apply(this, arguments);
1944           for (var nsp in this.nsps) {
1945             if (has.call(this.nsps, nsp)) {
1946               this.nsps[nsp].emit.apply(this.nsps[nsp], arguments);
1947             }
1948           }
1949         };
1950         
1951         /**
1952          * Update `socket.id` of all sockets
1953          *
1954          * @api private
1955          */
1956         
1957         Manager.prototype.updateSocketIds = function () {
1958           for (var nsp in this.nsps) {
1959             if (has.call(this.nsps, nsp)) {
1960               this.nsps[nsp].id = this.generateId(nsp);
1961             }
1962           }
1963         };
1964         
1965         /**
1966          * generate `socket.id` for the given `nsp`
1967          *
1968          * @param {String} nsp
1969          * @return {String}
1970          * @api private
1971          */
1972         
1973         Manager.prototype.generateId = function (nsp) {
1974           return (nsp === '/' ? '' : (nsp + '#')) + this.engine.id;
1975         };
1976         
1977         /**
1978          * Mix in `Emitter`.
1979          */
1980         
1981         Emitter(Manager.prototype);
1982         
1983         /**
1984          * Sets the `reconnection` config.
1985          *
1986          * @param {Boolean} true/false if it should automatically reconnect
1987          * @return {Manager} self or value
1988          * @api public
1989          */
1990         
1991         Manager.prototype.reconnection = function (v) {
1992           if (!arguments.length) return this._reconnection;
1993           this._reconnection = !!v;
1994           return this;
1995         };
1996         
1997         /**
1998          * Sets the reconnection attempts config.
1999          *
2000          * @param {Number} max reconnection attempts before giving up
2001          * @return {Manager} self or value
2002          * @api public
2003          */
2004         
2005         Manager.prototype.reconnectionAttempts = function (v) {
2006           if (!arguments.length) return this._reconnectionAttempts;
2007           this._reconnectionAttempts = v;
2008           return this;
2009         };
2010         
2011         /**
2012          * Sets the delay between reconnections.
2013          *
2014          * @param {Number} delay
2015          * @return {Manager} self or value
2016          * @api public
2017          */
2018         
2019         Manager.prototype.reconnectionDelay = function (v) {
2020           if (!arguments.length) return this._reconnectionDelay;
2021           this._reconnectionDelay = v;
2022           this.backoff && this.backoff.setMin(v);
2023           return this;
2024         };
2025         
2026         Manager.prototype.randomizationFactor = function (v) {
2027           if (!arguments.length) return this._randomizationFactor;
2028           this._randomizationFactor = v;
2029           this.backoff && this.backoff.setJitter(v);
2030           return this;
2031         };
2032         
2033         /**
2034          * Sets the maximum delay between reconnections.
2035          *
2036          * @param {Number} delay
2037          * @return {Manager} self or value
2038          * @api public
2039          */
2040         
2041         Manager.prototype.reconnectionDelayMax = function (v) {
2042           if (!arguments.length) return this._reconnectionDelayMax;
2043           this._reconnectionDelayMax = v;
2044           this.backoff && this.backoff.setMax(v);
2045           return this;
2046         };
2047         
2048         /**
2049          * Sets the connection timeout. `false` to disable
2050          *
2051          * @return {Manager} self or value
2052          * @api public
2053          */
2054         
2055         Manager.prototype.timeout = function (v) {
2056           if (!arguments.length) return this._timeout;
2057           this._timeout = v;
2058           return this;
2059         };
2060         
2061         /**
2062          * Starts trying to reconnect if reconnection is enabled and we have not
2063          * started reconnecting yet
2064          *
2065          * @api private
2066          */
2067         
2068         Manager.prototype.maybeReconnectOnOpen = function () {
2069           // Only try to reconnect if it's the first time we're connecting
2070           if (!this.reconnecting && this._reconnection && this.backoff.attempts === 0) {
2071             // keeps reconnection from firing twice for the same reconnection loop
2072             this.reconnect();
2073           }
2074         };
2075         
2076         /**
2077          * Sets the current transport `socket`.
2078          *
2079          * @param {Function} optional, callback
2080          * @return {Manager} self
2081          * @api public
2082          */
2083         
2084         Manager.prototype.open =
2085         Manager.prototype.connect = function (fn, opts) {
2086           debug('readyState %s', this.readyState);
2087           if (~this.readyState.indexOf('open')) return this;
2088         
2089           debug('opening %s', this.uri);
2090           this.engine = eio(this.uri, this.opts);
2091           var socket = this.engine;
2092           var self = this;
2093           this.readyState = 'opening';
2094           this.skipReconnect = false;
2095         
2096           // emit `open`
2097           var openSub = on(socket, 'open', function () {
2098             self.onopen();
2099             fn && fn();
2100           });
2101         
2102           // emit `connect_error`
2103           var errorSub = on(socket, 'error', function (data) {
2104             debug('connect_error');
2105             self.cleanup();
2106             self.readyState = 'closed';
2107             self.emitAll('connect_error', data);
2108             if (fn) {
2109               var err = new Error('Connection error');
2110               err.data = data;
2111               fn(err);
2112             } else {
2113               // Only do this if there is no fn to handle the error
2114               self.maybeReconnectOnOpen();
2115             }
2116           });
2117         
2118           // emit `connect_timeout`
2119           if (false !== this._timeout) {
2120             var timeout = this._timeout;
2121             debug('connect attempt will timeout after %d', timeout);
2122         
2123             if (timeout === 0) {
2124               openSub.destroy(); // prevents a race condition with the 'open' event
2125             }
2126         
2127             // set timer
2128             var timer = setTimeout(function () {
2129               debug('connect attempt timed out after %d', timeout);
2130               openSub.destroy();
2131               socket.close();
2132               socket.emit('error', 'timeout');
2133               self.emitAll('connect_timeout', timeout);
2134             }, timeout);
2135         
2136             this.subs.push({
2137               destroy: function () {
2138                 clearTimeout(timer);
2139               }
2140             });
2141           }
2142         
2143           this.subs.push(openSub);
2144           this.subs.push(errorSub);
2145         
2146           return this;
2147         };
2148         
2149         /**
2150          * Called upon transport open.
2151          *
2152          * @api private
2153          */
2154         
2155         Manager.prototype.onopen = function () {
2156           debug('open');
2157         
2158           // clear old subs
2159           this.cleanup();
2160         
2161           // mark as open
2162           this.readyState = 'open';
2163           this.emit('open');
2164         
2165           // add new subs
2166           var socket = this.engine;
2167           this.subs.push(on(socket, 'data', bind(this, 'ondata')));
2168           this.subs.push(on(socket, 'ping', bind(this, 'onping')));
2169           this.subs.push(on(socket, 'pong', bind(this, 'onpong')));
2170           this.subs.push(on(socket, 'error', bind(this, 'onerror')));
2171           this.subs.push(on(socket, 'close', bind(this, 'onclose')));
2172           this.subs.push(on(this.decoder, 'decoded', bind(this, 'ondecoded')));
2173         };
2174         
2175         /**
2176          * Called upon a ping.
2177          *
2178          * @api private
2179          */
2180         
2181         Manager.prototype.onping = function () {
2182           this.lastPing = new Date();
2183           this.emitAll('ping');
2184         };
2185         
2186         /**
2187          * Called upon a packet.
2188          *
2189          * @api private
2190          */
2191         
2192         Manager.prototype.onpong = function () {
2193           this.emitAll('pong', new Date() - this.lastPing);
2194         };
2195         
2196         /**
2197          * Called with data.
2198          *
2199          * @api private
2200          */
2201         
2202         Manager.prototype.ondata = function (data) {
2203           this.decoder.add(data);
2204         };
2205         
2206         /**
2207          * Called when parser fully decodes a packet.
2208          *
2209          * @api private
2210          */
2211         
2212         Manager.prototype.ondecoded = function (packet) {
2213           this.emit('packet', packet);
2214         };
2215         
2216         /**
2217          * Called upon socket error.
2218          *
2219          * @api private
2220          */
2221         
2222         Manager.prototype.onerror = function (err) {
2223           debug('error', err);
2224           this.emitAll('error', err);
2225         };
2226         
2227         /**
2228          * Creates a new socket for the given `nsp`.
2229          *
2230          * @return {Socket}
2231          * @api public
2232          */
2233         
2234         Manager.prototype.socket = function (nsp, opts) {
2235           var socket = this.nsps[nsp];
2236           if (!socket) {
2237             socket = new Socket(this, nsp, opts);
2238             this.nsps[nsp] = socket;
2239             var self = this;
2240             socket.on('connecting', onConnecting);
2241             socket.on('connect', function () {
2242               socket.id = self.generateId(nsp);
2243             });
2244         
2245             if (this.autoConnect) {
2246               // manually call here since connecting event is fired before listening
2247               onConnecting();
2248             }
2249           }
2250         
2251           function onConnecting () {
2252             if (!~indexOf(self.connecting, socket)) {
2253               self.connecting.push(socket);
2254             }
2255           }
2256         
2257           return socket;
2258         };
2259         
2260         /**
2261          * Called upon a socket close.
2262          *
2263          * @param {Socket} socket
2264          */
2265         
2266         Manager.prototype.destroy = function (socket) {
2267           var index = indexOf(this.connecting, socket);
2268           if (~index) this.connecting.splice(index, 1);
2269           if (this.connecting.length) return;
2270         
2271           this.close();
2272         };
2273         
2274         /**
2275          * Writes a packet.
2276          *
2277          * @param {Object} packet
2278          * @api private
2279          */
2280         
2281         Manager.prototype.packet = function (packet) {
2282           debug('writing packet %j', packet);
2283           var self = this;
2284           if (packet.query && packet.type === 0) packet.nsp += '?' + packet.query;
2285         
2286           if (!self.encoding) {
2287             // encode, then write to engine with result
2288             self.encoding = true;
2289             this.encoder.encode(packet, function (encodedPackets) {
2290               for (var i = 0; i < encodedPackets.length; i++) {
2291                 self.engine.write(encodedPackets[i], packet.options);
2292               }
2293               self.encoding = false;
2294               self.processPacketQueue();
2295             });
2296           } else { // add packet to the queue
2297             self.packetBuffer.push(packet);
2298           }
2299         };
2300         
2301         /**
2302          * If packet buffer is non-empty, begins encoding the
2303          * next packet in line.
2304          *
2305          * @api private
2306          */
2307         
2308         Manager.prototype.processPacketQueue = function () {
2309           if (this.packetBuffer.length > 0 && !this.encoding) {
2310             var pack = this.packetBuffer.shift();
2311             this.packet(pack);
2312           }
2313         };
2314         
2315         /**
2316          * Clean up transport subscriptions and packet buffer.
2317          *
2318          * @api private
2319          */
2320         
2321         Manager.prototype.cleanup = function () {
2322           debug('cleanup');
2323         
2324           var subsLength = this.subs.length;
2325           for (var i = 0; i < subsLength; i++) {
2326             var sub = this.subs.shift();
2327             sub.destroy();
2328           }
2329         
2330           this.packetBuffer = [];
2331           this.encoding = false;
2332           this.lastPing = null;
2333         
2334           this.decoder.destroy();
2335         };
2336         
2337         /**
2338          * Close the current socket.
2339          *
2340          * @api private
2341          */
2342         
2343         Manager.prototype.close =
2344         Manager.prototype.disconnect = function () {
2345           debug('disconnect');
2346           this.skipReconnect = true;
2347           this.reconnecting = false;
2348           if ('opening' === this.readyState) {
2349             // `onclose` will not fire because
2350             // an open event never happened
2351             this.cleanup();
2352           }
2353           this.backoff.reset();
2354           this.readyState = 'closed';
2355           if (this.engine) this.engine.close();
2356         };
2357         
2358         /**
2359          * Called upon engine close.
2360          *
2361          * @api private
2362          */
2363         
2364         Manager.prototype.onclose = function (reason) {
2365           debug('onclose');
2366         
2367           this.cleanup();
2368           this.backoff.reset();
2369           this.readyState = 'closed';
2370           this.emit('close', reason);
2371         
2372           if (this._reconnection && !this.skipReconnect) {
2373             this.reconnect();
2374           }
2375         };
2376         
2377         /**
2378          * Attempt a reconnection.
2379          *
2380          * @api private
2381          */
2382         
2383         Manager.prototype.reconnect = function () {
2384           if (this.reconnecting || this.skipReconnect) return this;
2385         
2386           var self = this;
2387         
2388           if (this.backoff.attempts >= this._reconnectionAttempts) {
2389             debug('reconnect failed');
2390             this.backoff.reset();
2391             this.emitAll('reconnect_failed');
2392             this.reconnecting = false;
2393           } else {
2394             var delay = this.backoff.duration();
2395             debug('will wait %dms before reconnect attempt', delay);
2396         
2397             this.reconnecting = true;
2398             var timer = setTimeout(function () {
2399               if (self.skipReconnect) return;
2400         
2401               debug('attempting reconnect');
2402               self.emitAll('reconnect_attempt', self.backoff.attempts);
2403               self.emitAll('reconnecting', self.backoff.attempts);
2404         
2405               // check again for the case socket closed in above events
2406               if (self.skipReconnect) return;
2407         
2408               self.open(function (err) {
2409                 if (err) {
2410                   debug('reconnect attempt error');
2411                   self.reconnecting = false;
2412                   self.reconnect();
2413                   self.emitAll('reconnect_error', err.data);
2414                 } else {
2415                   debug('reconnect success');
2416                   self.onreconnect();
2417                 }
2418               });
2419             }, delay);
2420         
2421             this.subs.push({
2422               destroy: function () {
2423                 clearTimeout(timer);
2424               }
2425             });
2426           }
2427         };
2428         
2429         /**
2430          * Called upon successful reconnect.
2431          *
2432          * @api private
2433          */
2434         
2435         Manager.prototype.onreconnect = function () {
2436           var attempt = this.backoff.attempts;
2437           this.reconnecting = false;
2438           this.backoff.reset();
2439           this.updateSocketIds();
2440           this.emitAll('reconnect', attempt);
2441         };
2442
2443
2444 /***/ }),
2445 /* 13 */
2446 /***/ (function(module, exports, __webpack_require__) {
2447
2448         
2449         module.exports = __webpack_require__(14);
2450         
2451         /**
2452          * Exports parser
2453          *
2454          * @api public
2455          *
2456          */
2457         module.exports.parser = __webpack_require__(22);
2458
2459
2460 /***/ }),
2461 /* 14 */
2462 /***/ (function(module, exports, __webpack_require__) {
2463
2464         /**
2465          * Module dependencies.
2466          */
2467         
2468         var transports = __webpack_require__(15);
2469         var Emitter = __webpack_require__(8);
2470         var debug = __webpack_require__(3)('engine.io-client:socket');
2471         var index = __webpack_require__(36);
2472         var parser = __webpack_require__(22);
2473         var parseuri = __webpack_require__(2);
2474         var parseqs = __webpack_require__(30);
2475         
2476         /**
2477          * Module exports.
2478          */
2479         
2480         module.exports = Socket;
2481         
2482         /**
2483          * Socket constructor.
2484          *
2485          * @param {String|Object} uri or options
2486          * @param {Object} options
2487          * @api public
2488          */
2489         
2490         function Socket (uri, opts) {
2491           if (!(this instanceof Socket)) return new Socket(uri, opts);
2492         
2493           opts = opts || {};
2494         
2495           if (uri && 'object' === typeof uri) {
2496             opts = uri;
2497             uri = null;
2498           }
2499         
2500           if (uri) {
2501             uri = parseuri(uri);
2502             opts.hostname = uri.host;
2503             opts.secure = uri.protocol === 'https' || uri.protocol === 'wss';
2504             opts.port = uri.port;
2505             if (uri.query) opts.query = uri.query;
2506           } else if (opts.host) {
2507             opts.hostname = parseuri(opts.host).host;
2508           }
2509         
2510           this.secure = null != opts.secure ? opts.secure
2511             : (typeof location !== 'undefined' && 'https:' === location.protocol);
2512         
2513           if (opts.hostname && !opts.port) {
2514             // if no port is specified manually, use the protocol default
2515             opts.port = this.secure ? '443' : '80';
2516           }
2517         
2518           this.agent = opts.agent || false;
2519           this.hostname = opts.hostname ||
2520             (typeof location !== 'undefined' ? location.hostname : 'localhost');
2521           this.port = opts.port || (typeof location !== 'undefined' && location.port
2522               ? location.port
2523               : (this.secure ? 443 : 80));
2524           this.query = opts.query || {};
2525           if ('string' === typeof this.query) this.query = parseqs.decode(this.query);
2526           this.upgrade = false !== opts.upgrade;
2527           this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
2528           this.forceJSONP = !!opts.forceJSONP;
2529           this.jsonp = false !== opts.jsonp;
2530           this.forceBase64 = !!opts.forceBase64;
2531           this.enablesXDR = !!opts.enablesXDR;
2532           this.withCredentials = false !== opts.withCredentials;
2533           this.timestampParam = opts.timestampParam || 't';
2534           this.timestampRequests = opts.timestampRequests;
2535           this.transports = opts.transports || ['polling', 'websocket'];
2536           this.transportOptions = opts.transportOptions || {};
2537           this.readyState = '';
2538           this.writeBuffer = [];
2539           this.prevBufferLen = 0;
2540           this.policyPort = opts.policyPort || 843;
2541           this.rememberUpgrade = opts.rememberUpgrade || false;
2542           this.binaryType = null;
2543           this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades;
2544           this.perMessageDeflate = false !== opts.perMessageDeflate ? (opts.perMessageDeflate || {}) : false;
2545         
2546           if (true === this.perMessageDeflate) this.perMessageDeflate = {};
2547           if (this.perMessageDeflate && null == this.perMessageDeflate.threshold) {
2548             this.perMessageDeflate.threshold = 1024;
2549           }
2550         
2551           // SSL options for Node.js client
2552           this.pfx = opts.pfx || null;
2553           this.key = opts.key || null;
2554           this.passphrase = opts.passphrase || null;
2555           this.cert = opts.cert || null;
2556           this.ca = opts.ca || null;
2557           this.ciphers = opts.ciphers || null;
2558           this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? true : opts.rejectUnauthorized;
2559           this.forceNode = !!opts.forceNode;
2560         
2561           // detect ReactNative environment
2562           this.isReactNative = (typeof navigator !== 'undefined' && typeof navigator.product === 'string' && navigator.product.toLowerCase() === 'reactnative');
2563         
2564           // other options for Node.js or ReactNative client
2565           if (typeof self === 'undefined' || this.isReactNative) {
2566             if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) {
2567               this.extraHeaders = opts.extraHeaders;
2568             }
2569         
2570             if (opts.localAddress) {
2571               this.localAddress = opts.localAddress;
2572             }
2573           }
2574         
2575           // set on handshake
2576           this.id = null;
2577           this.upgrades = null;
2578           this.pingInterval = null;
2579           this.pingTimeout = null;
2580         
2581           // set on heartbeat
2582           this.pingIntervalTimer = null;
2583           this.pingTimeoutTimer = null;
2584         
2585           this.open();
2586         }
2587         
2588         Socket.priorWebsocketSuccess = false;
2589         
2590         /**
2591          * Mix in `Emitter`.
2592          */
2593         
2594         Emitter(Socket.prototype);
2595         
2596         /**
2597          * Protocol version.
2598          *
2599          * @api public
2600          */
2601         
2602         Socket.protocol = parser.protocol; // this is an int
2603         
2604         /**
2605          * Expose deps for legacy compatibility
2606          * and standalone browser access.
2607          */
2608         
2609         Socket.Socket = Socket;
2610         Socket.Transport = __webpack_require__(21);
2611         Socket.transports = __webpack_require__(15);
2612         Socket.parser = __webpack_require__(22);
2613         
2614         /**
2615          * Creates transport of the given type.
2616          *
2617          * @param {String} transport name
2618          * @return {Transport}
2619          * @api private
2620          */
2621         
2622         Socket.prototype.createTransport = function (name) {
2623           debug('creating transport "%s"', name);
2624           var query = clone(this.query);
2625         
2626           // append engine.io protocol identifier
2627           query.EIO = parser.protocol;
2628         
2629           // transport name
2630           query.transport = name;
2631         
2632           // per-transport options
2633           var options = this.transportOptions[name] || {};
2634         
2635           // session id if we already have one
2636           if (this.id) query.sid = this.id;
2637         
2638           var transport = new transports[name]({
2639             query: query,
2640             socket: this,
2641             agent: options.agent || this.agent,
2642             hostname: options.hostname || this.hostname,
2643             port: options.port || this.port,
2644             secure: options.secure || this.secure,
2645             path: options.path || this.path,
2646             forceJSONP: options.forceJSONP || this.forceJSONP,
2647             jsonp: options.jsonp || this.jsonp,
2648             forceBase64: options.forceBase64 || this.forceBase64,
2649             enablesXDR: options.enablesXDR || this.enablesXDR,
2650             withCredentials: options.withCredentials || this.withCredentials,
2651             timestampRequests: options.timestampRequests || this.timestampRequests,
2652             timestampParam: options.timestampParam || this.timestampParam,
2653             policyPort: options.policyPort || this.policyPort,
2654             pfx: options.pfx || this.pfx,
2655             key: options.key || this.key,
2656             passphrase: options.passphrase || this.passphrase,
2657             cert: options.cert || this.cert,
2658             ca: options.ca || this.ca,
2659             ciphers: options.ciphers || this.ciphers,
2660             rejectUnauthorized: options.rejectUnauthorized || this.rejectUnauthorized,
2661             perMessageDeflate: options.perMessageDeflate || this.perMessageDeflate,
2662             extraHeaders: options.extraHeaders || this.extraHeaders,
2663             forceNode: options.forceNode || this.forceNode,
2664             localAddress: options.localAddress || this.localAddress,
2665             requestTimeout: options.requestTimeout || this.requestTimeout,
2666             protocols: options.protocols || void (0),
2667             isReactNative: this.isReactNative
2668           });
2669         
2670           return transport;
2671         };
2672         
2673         function clone (obj) {
2674           var o = {};
2675           for (var i in obj) {
2676             if (obj.hasOwnProperty(i)) {
2677               o[i] = obj[i];
2678             }
2679           }
2680           return o;
2681         }
2682         
2683         /**
2684          * Initializes transport to use and starts probe.
2685          *
2686          * @api private
2687          */
2688         Socket.prototype.open = function () {
2689           var transport;
2690           if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') !== -1) {
2691             transport = 'websocket';
2692           } else if (0 === this.transports.length) {
2693             // Emit error on next tick so it can be listened to
2694             var self = this;
2695             setTimeout(function () {
2696               self.emit('error', 'No transports available');
2697             }, 0);
2698             return;
2699           } else {
2700             transport = this.transports[0];
2701           }
2702           this.readyState = 'opening';
2703         
2704           // Retry with the next transport if the transport is disabled (jsonp: false)
2705           try {
2706             transport = this.createTransport(transport);
2707           } catch (e) {
2708             this.transports.shift();
2709             this.open();
2710             return;
2711           }
2712         
2713           transport.open();
2714           this.setTransport(transport);
2715         };
2716         
2717         /**
2718          * Sets the current transport. Disables the existing one (if any).
2719          *
2720          * @api private
2721          */
2722         
2723         Socket.prototype.setTransport = function (transport) {
2724           debug('setting transport %s', transport.name);
2725           var self = this;
2726         
2727           if (this.transport) {
2728             debug('clearing existing transport %s', this.transport.name);
2729             this.transport.removeAllListeners();
2730           }
2731         
2732           // set up transport
2733           this.transport = transport;
2734         
2735           // set up transport listeners
2736           transport
2737           .on('drain', function () {
2738             self.onDrain();
2739           })
2740           .on('packet', function (packet) {
2741             self.onPacket(packet);
2742           })
2743           .on('error', function (e) {
2744             self.onError(e);
2745           })
2746           .on('close', function () {
2747             self.onClose('transport close');
2748           });
2749         };
2750         
2751         /**
2752          * Probes a transport.
2753          *
2754          * @param {String} transport name
2755          * @api private
2756          */
2757         
2758         Socket.prototype.probe = function (name) {
2759           debug('probing transport "%s"', name);
2760           var transport = this.createTransport(name, { probe: 1 });
2761           var failed = false;
2762           var self = this;
2763         
2764           Socket.priorWebsocketSuccess = false;
2765         
2766           function onTransportOpen () {
2767             if (self.onlyBinaryUpgrades) {
2768               var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;
2769               failed = failed || upgradeLosesBinary;
2770             }
2771             if (failed) return;
2772         
2773             debug('probe transport "%s" opened', name);
2774             transport.send([{ type: 'ping', data: 'probe' }]);
2775             transport.once('packet', function (msg) {
2776               if (failed) return;
2777               if ('pong' === msg.type && 'probe' === msg.data) {
2778                 debug('probe transport "%s" pong', name);
2779                 self.upgrading = true;
2780                 self.emit('upgrading', transport);
2781                 if (!transport) return;
2782                 Socket.priorWebsocketSuccess = 'websocket' === transport.name;
2783         
2784                 debug('pausing current transport "%s"', self.transport.name);
2785                 self.transport.pause(function () {
2786                   if (failed) return;
2787                   if ('closed' === self.readyState) return;
2788                   debug('changing transport and sending upgrade packet');
2789         
2790                   cleanup();
2791         
2792                   self.setTransport(transport);
2793                   transport.send([{ type: 'upgrade' }]);
2794                   self.emit('upgrade', transport);
2795                   transport = null;
2796                   self.upgrading = false;
2797                   self.flush();
2798                 });
2799               } else {
2800                 debug('probe transport "%s" failed', name);
2801                 var err = new Error('probe error');
2802                 err.transport = transport.name;
2803                 self.emit('upgradeError', err);
2804               }
2805             });
2806           }
2807         
2808           function freezeTransport () {
2809             if (failed) return;
2810         
2811             // Any callback called by transport should be ignored since now
2812             failed = true;
2813         
2814             cleanup();
2815         
2816             transport.close();
2817             transport = null;
2818           }
2819         
2820           // Handle any error that happens while probing
2821           function onerror (err) {
2822             var error = new Error('probe error: ' + err);
2823             error.transport = transport.name;
2824         
2825             freezeTransport();
2826         
2827             debug('probe transport "%s" failed because of error: %s', name, err);
2828         
2829             self.emit('upgradeError', error);
2830           }
2831         
2832           function onTransportClose () {
2833             onerror('transport closed');
2834           }
2835         
2836           // When the socket is closed while we're probing
2837           function onclose () {
2838             onerror('socket closed');
2839           }
2840         
2841           // When the socket is upgraded while we're probing
2842           function onupgrade (to) {
2843             if (transport && to.name !== transport.name) {
2844               debug('"%s" works - aborting "%s"', to.name, transport.name);
2845               freezeTransport();
2846             }
2847           }
2848         
2849           // Remove all listeners on the transport and on self
2850           function cleanup () {
2851             transport.removeListener('open', onTransportOpen);
2852             transport.removeListener('error', onerror);
2853             transport.removeListener('close', onTransportClose);
2854             self.removeListener('close', onclose);
2855             self.removeListener('upgrading', onupgrade);
2856           }
2857         
2858           transport.once('open', onTransportOpen);
2859           transport.once('error', onerror);
2860           transport.once('close', onTransportClose);
2861         
2862           this.once('close', onclose);
2863           this.once('upgrading', onupgrade);
2864         
2865           transport.open();
2866         };
2867         
2868         /**
2869          * Called when connection is deemed open.
2870          *
2871          * @api public
2872          */
2873         
2874         Socket.prototype.onOpen = function () {
2875           debug('socket open');
2876           this.readyState = 'open';
2877           Socket.priorWebsocketSuccess = 'websocket' === this.transport.name;
2878           this.emit('open');
2879           this.flush();
2880         
2881           // we check for `readyState` in case an `open`
2882           // listener already closed the socket
2883           if ('open' === this.readyState && this.upgrade && this.transport.pause) {
2884             debug('starting upgrade probes');
2885             for (var i = 0, l = this.upgrades.length; i < l; i++) {
2886               this.probe(this.upgrades[i]);
2887             }
2888           }
2889         };
2890         
2891         /**
2892          * Handles a packet.
2893          *
2894          * @api private
2895          */
2896         
2897         Socket.prototype.onPacket = function (packet) {
2898           if ('opening' === this.readyState || 'open' === this.readyState ||
2899               'closing' === this.readyState) {
2900             debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
2901         
2902             this.emit('packet', packet);
2903         
2904             // Socket is live - any packet counts
2905             this.emit('heartbeat');
2906         
2907             switch (packet.type) {
2908               case 'open':
2909                 this.onHandshake(JSON.parse(packet.data));
2910                 break;
2911         
2912               case 'pong':
2913                 this.setPing();
2914                 this.emit('pong');
2915                 break;
2916         
2917               case 'error':
2918                 var err = new Error('server error');
2919                 err.code = packet.data;
2920                 this.onError(err);
2921                 break;
2922         
2923               case 'message':
2924                 this.emit('data', packet.data);
2925                 this.emit('message', packet.data);
2926                 break;
2927             }
2928           } else {
2929             debug('packet received with socket readyState "%s"', this.readyState);
2930           }
2931         };
2932         
2933         /**
2934          * Called upon handshake completion.
2935          *
2936          * @param {Object} handshake obj
2937          * @api private
2938          */
2939         
2940         Socket.prototype.onHandshake = function (data) {
2941           this.emit('handshake', data);
2942           this.id = data.sid;
2943           this.transport.query.sid = data.sid;
2944           this.upgrades = this.filterUpgrades(data.upgrades);
2945           this.pingInterval = data.pingInterval;
2946           this.pingTimeout = data.pingTimeout;
2947           this.onOpen();
2948           // In case open handler closes socket
2949           if ('closed' === this.readyState) return;
2950           this.setPing();
2951         
2952           // Prolong liveness of socket on heartbeat
2953           this.removeListener('heartbeat', this.onHeartbeat);
2954           this.on('heartbeat', this.onHeartbeat);
2955         };
2956         
2957         /**
2958          * Resets ping timeout.
2959          *
2960          * @api private
2961          */
2962         
2963         Socket.prototype.onHeartbeat = function (timeout) {
2964           clearTimeout(this.pingTimeoutTimer);
2965           var self = this;
2966           self.pingTimeoutTimer = setTimeout(function () {
2967             if ('closed' === self.readyState) return;
2968             self.onClose('ping timeout');
2969           }, timeout || (self.pingInterval + self.pingTimeout));
2970         };
2971         
2972         /**
2973          * Pings server every `this.pingInterval` and expects response
2974          * within `this.pingTimeout` or closes connection.
2975          *
2976          * @api private
2977          */
2978         
2979         Socket.prototype.setPing = function () {
2980           var self = this;
2981           clearTimeout(self.pingIntervalTimer);
2982           self.pingIntervalTimer = setTimeout(function () {
2983             debug('writing ping packet - expecting pong within %sms', self.pingTimeout);
2984             self.ping();
2985             self.onHeartbeat(self.pingTimeout);
2986           }, self.pingInterval);
2987         };
2988         
2989         /**
2990         * Sends a ping packet.
2991         *
2992         * @api private
2993         */
2994         
2995         Socket.prototype.ping = function () {
2996           var self = this;
2997           this.sendPacket('ping', function () {
2998             self.emit('ping');
2999           });
3000         };
3001         
3002         /**
3003          * Called on `drain` event
3004          *
3005          * @api private
3006          */
3007         
3008         Socket.prototype.onDrain = function () {
3009           this.writeBuffer.splice(0, this.prevBufferLen);
3010         
3011           // setting prevBufferLen = 0 is very important
3012           // for example, when upgrading, upgrade packet is sent over,
3013           // and a nonzero prevBufferLen could cause problems on `drain`
3014           this.prevBufferLen = 0;
3015         
3016           if (0 === this.writeBuffer.length) {
3017             this.emit('drain');
3018           } else {
3019             this.flush();
3020           }
3021         };
3022         
3023         /**
3024          * Flush write buffers.
3025          *
3026          * @api private
3027          */
3028         
3029         Socket.prototype.flush = function () {
3030           if ('closed' !== this.readyState && this.transport.writable &&
3031             !this.upgrading && this.writeBuffer.length) {
3032             debug('flushing %d packets in socket', this.writeBuffer.length);
3033             this.transport.send(this.writeBuffer);
3034             // keep track of current length of writeBuffer
3035             // splice writeBuffer and callbackBuffer on `drain`
3036             this.prevBufferLen = this.writeBuffer.length;
3037             this.emit('flush');
3038           }
3039         };
3040         
3041         /**
3042          * Sends a message.
3043          *
3044          * @param {String} message.
3045          * @param {Function} callback function.
3046          * @param {Object} options.
3047          * @return {Socket} for chaining.
3048          * @api public
3049          */
3050         
3051         Socket.prototype.write =
3052         Socket.prototype.send = function (msg, options, fn) {
3053           this.sendPacket('message', msg, options, fn);
3054           return this;
3055         };
3056         
3057         /**
3058          * Sends a packet.
3059          *
3060          * @param {String} packet type.
3061          * @param {String} data.
3062          * @param {Object} options.
3063          * @param {Function} callback function.
3064          * @api private
3065          */
3066         
3067         Socket.prototype.sendPacket = function (type, data, options, fn) {
3068           if ('function' === typeof data) {
3069             fn = data;
3070             data = undefined;
3071           }
3072         
3073           if ('function' === typeof options) {
3074             fn = options;
3075             options = null;
3076           }
3077         
3078           if ('closing' === this.readyState || 'closed' === this.readyState) {
3079             return;
3080           }
3081         
3082           options = options || {};
3083           options.compress = false !== options.compress;
3084         
3085           var packet = {
3086             type: type,
3087             data: data,
3088             options: options
3089           };
3090           this.emit('packetCreate', packet);
3091           this.writeBuffer.push(packet);
3092           if (fn) this.once('flush', fn);
3093           this.flush();
3094         };
3095         
3096         /**
3097          * Closes the connection.
3098          *
3099          * @api private
3100          */
3101         
3102         Socket.prototype.close = function () {
3103           if ('opening' === this.readyState || 'open' === this.readyState) {
3104             this.readyState = 'closing';
3105         
3106             var self = this;
3107         
3108             if (this.writeBuffer.length) {
3109               this.once('drain', function () {
3110                 if (this.upgrading) {
3111                   waitForUpgrade();
3112                 } else {
3113                   close();
3114                 }
3115               });
3116             } else if (this.upgrading) {
3117               waitForUpgrade();
3118             } else {
3119               close();
3120             }
3121           }
3122         
3123           function close () {
3124             self.onClose('forced close');
3125             debug('socket closing - telling transport to close');
3126             self.transport.close();
3127           }
3128         
3129           function cleanupAndClose () {
3130             self.removeListener('upgrade', cleanupAndClose);
3131             self.removeListener('upgradeError', cleanupAndClose);
3132             close();
3133           }
3134         
3135           function waitForUpgrade () {
3136             // wait for upgrade to finish since we can't send packets while pausing a transport
3137             self.once('upgrade', cleanupAndClose);
3138             self.once('upgradeError', cleanupAndClose);
3139           }
3140         
3141           return this;
3142         };
3143         
3144         /**
3145          * Called upon transport error
3146          *
3147          * @api private
3148          */
3149         
3150         Socket.prototype.onError = function (err) {
3151           debug('socket error %j', err);
3152           Socket.priorWebsocketSuccess = false;
3153           this.emit('error', err);
3154           this.onClose('transport error', err);
3155         };
3156         
3157         /**
3158          * Called upon transport close.
3159          *
3160          * @api private
3161          */
3162         
3163         Socket.prototype.onClose = function (reason, desc) {
3164           if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState) {
3165             debug('socket close with reason: "%s"', reason);
3166             var self = this;
3167         
3168             // clear timers
3169             clearTimeout(this.pingIntervalTimer);
3170             clearTimeout(this.pingTimeoutTimer);
3171         
3172             // stop event from firing again for transport
3173             this.transport.removeAllListeners('close');
3174         
3175             // ensure transport won't stay open
3176             this.transport.close();
3177         
3178             // ignore further transport communication
3179             this.transport.removeAllListeners();
3180         
3181             // set ready state
3182             this.readyState = 'closed';
3183         
3184             // clear session id
3185             this.id = null;
3186         
3187             // emit close event
3188             this.emit('close', reason, desc);
3189         
3190             // clean buffers after, so users can still
3191             // grab the buffers on `close` event
3192             self.writeBuffer = [];
3193             self.prevBufferLen = 0;
3194           }
3195         };
3196         
3197         /**
3198          * Filters upgrades, returning only those matching client transports.
3199          *
3200          * @param {Array} server upgrades
3201          * @api private
3202          *
3203          */
3204         
3205         Socket.prototype.filterUpgrades = function (upgrades) {
3206           var filteredUpgrades = [];
3207           for (var i = 0, j = upgrades.length; i < j; i++) {
3208             if (~index(this.transports, upgrades[i])) filteredUpgrades.push(upgrades[i]);
3209           }
3210           return filteredUpgrades;
3211         };
3212
3213
3214 /***/ }),
3215 /* 15 */
3216 /***/ (function(module, exports, __webpack_require__) {
3217
3218         /**
3219          * Module dependencies
3220          */
3221         
3222         var XMLHttpRequest = __webpack_require__(16);
3223         var XHR = __webpack_require__(19);
3224         var JSONP = __webpack_require__(33);
3225         var websocket = __webpack_require__(34);
3226         
3227         /**
3228          * Export transports.
3229          */
3230         
3231         exports.polling = polling;
3232         exports.websocket = websocket;
3233         
3234         /**
3235          * Polling transport polymorphic constructor.
3236          * Decides on xhr vs jsonp based on feature detection.
3237          *
3238          * @api private
3239          */
3240         
3241         function polling (opts) {
3242           var xhr;
3243           var xd = false;
3244           var xs = false;
3245           var jsonp = false !== opts.jsonp;
3246         
3247           if (typeof location !== 'undefined') {
3248             var isSSL = 'https:' === location.protocol;
3249             var port = location.port;
3250         
3251             // some user agents have empty `location.port`
3252             if (!port) {
3253               port = isSSL ? 443 : 80;
3254             }
3255         
3256             xd = opts.hostname !== location.hostname || port !== opts.port;
3257             xs = opts.secure !== isSSL;
3258           }
3259         
3260           opts.xdomain = xd;
3261           opts.xscheme = xs;
3262           xhr = new XMLHttpRequest(opts);
3263         
3264           if ('open' in xhr && !opts.forceJSONP) {
3265             return new XHR(opts);
3266           } else {
3267             if (!jsonp) throw new Error('JSONP disabled');
3268             return new JSONP(opts);
3269           }
3270         }
3271
3272
3273 /***/ }),
3274 /* 16 */
3275 /***/ (function(module, exports, __webpack_require__) {
3276
3277         // browser shim for xmlhttprequest module
3278         
3279         var hasCORS = __webpack_require__(17);
3280         var globalThis = __webpack_require__(18);
3281         
3282         module.exports = function (opts) {
3283           var xdomain = opts.xdomain;
3284         
3285           // scheme must be same when usign XDomainRequest
3286           // http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
3287           var xscheme = opts.xscheme;
3288         
3289           // XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
3290           // https://github.com/Automattic/engine.io-client/pull/217
3291           var enablesXDR = opts.enablesXDR;
3292         
3293           // XMLHttpRequest can be disabled on IE
3294           try {
3295             if ('undefined' !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
3296               return new XMLHttpRequest();
3297             }
3298           } catch (e) { }
3299         
3300           // Use XDomainRequest for IE8 if enablesXDR is true
3301           // because loading bar keeps flashing when using jsonp-polling
3302           // https://github.com/yujiosaka/socke.io-ie8-loading-example
3303           try {
3304             if ('undefined' !== typeof XDomainRequest && !xscheme && enablesXDR) {
3305               return new XDomainRequest();
3306             }
3307           } catch (e) { }
3308         
3309           if (!xdomain) {
3310             try {
3311               return new globalThis[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP');
3312             } catch (e) { }
3313           }
3314         };
3315
3316
3317 /***/ }),
3318 /* 17 */
3319 /***/ (function(module, exports) {
3320
3321         
3322         /**
3323          * Module exports.
3324          *
3325          * Logic borrowed from Modernizr:
3326          *
3327          *   - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js
3328          */
3329         
3330         try {
3331           module.exports = typeof XMLHttpRequest !== 'undefined' &&
3332             'withCredentials' in new XMLHttpRequest();
3333         } catch (err) {
3334           // if XMLHttp support is disabled in IE then it will throw
3335           // when trying to create
3336           module.exports = false;
3337         }
3338
3339
3340 /***/ }),
3341 /* 18 */
3342 /***/ (function(module, exports) {
3343
3344         module.exports = (function () {
3345           if (typeof self !== 'undefined') {
3346             return self;
3347           } else if (typeof window !== 'undefined') {
3348             return window;
3349           } else {
3350             return Function('return this')(); // eslint-disable-line no-new-func
3351           }
3352         })();
3353
3354
3355 /***/ }),
3356 /* 19 */
3357 /***/ (function(module, exports, __webpack_require__) {
3358
3359         /* global attachEvent */
3360         
3361         /**
3362          * Module requirements.
3363          */
3364         
3365         var XMLHttpRequest = __webpack_require__(16);
3366         var Polling = __webpack_require__(20);
3367         var Emitter = __webpack_require__(8);
3368         var inherit = __webpack_require__(31);
3369         var debug = __webpack_require__(3)('engine.io-client:polling-xhr');
3370         var globalThis = __webpack_require__(18);
3371         
3372         /**
3373          * Module exports.
3374          */
3375         
3376         module.exports = XHR;
3377         module.exports.Request = Request;
3378         
3379         /**
3380          * Empty function
3381          */
3382         
3383         function empty () {}
3384         
3385         /**
3386          * XHR Polling constructor.
3387          *
3388          * @param {Object} opts
3389          * @api public
3390          */
3391         
3392         function XHR (opts) {
3393           Polling.call(this, opts);
3394           this.requestTimeout = opts.requestTimeout;
3395           this.extraHeaders = opts.extraHeaders;
3396         
3397           if (typeof location !== 'undefined') {
3398             var isSSL = 'https:' === location.protocol;
3399             var port = location.port;
3400         
3401             // some user agents have empty `location.port`
3402             if (!port) {
3403               port = isSSL ? 443 : 80;
3404             }
3405         
3406             this.xd = (typeof location !== 'undefined' && opts.hostname !== location.hostname) ||
3407               port !== opts.port;
3408             this.xs = opts.secure !== isSSL;
3409           }
3410         }
3411         
3412         /**
3413          * Inherits from Polling.
3414          */
3415         
3416         inherit(XHR, Polling);
3417         
3418         /**
3419          * XHR supports binary
3420          */
3421         
3422         XHR.prototype.supportsBinary = true;
3423         
3424         /**
3425          * Creates a request.
3426          *
3427          * @param {String} method
3428          * @api private
3429          */
3430         
3431         XHR.prototype.request = function (opts) {
3432           opts = opts || {};
3433           opts.uri = this.uri();
3434           opts.xd = this.xd;
3435           opts.xs = this.xs;
3436           opts.agent = this.agent || false;
3437           opts.supportsBinary = this.supportsBinary;
3438           opts.enablesXDR = this.enablesXDR;
3439           opts.withCredentials = this.withCredentials;
3440         
3441           // SSL options for Node.js client
3442           opts.pfx = this.pfx;
3443           opts.key = this.key;
3444           opts.passphrase = this.passphrase;
3445           opts.cert = this.cert;
3446           opts.ca = this.ca;
3447           opts.ciphers = this.ciphers;
3448           opts.rejectUnauthorized = this.rejectUnauthorized;
3449           opts.requestTimeout = this.requestTimeout;
3450         
3451           // other options for Node.js client
3452           opts.extraHeaders = this.extraHeaders;
3453         
3454           return new Request(opts);
3455         };
3456         
3457         /**
3458          * Sends data.
3459          *
3460          * @param {String} data to send.
3461          * @param {Function} called upon flush.
3462          * @api private
3463          */
3464         
3465         XHR.prototype.doWrite = function (data, fn) {
3466           var isBinary = typeof data !== 'string' && data !== undefined;
3467           var req = this.request({ method: 'POST', data: data, isBinary: isBinary });
3468           var self = this;
3469           req.on('success', fn);
3470           req.on('error', function (err) {
3471             self.onError('xhr post error', err);
3472           });
3473           this.sendXhr = req;
3474         };
3475         
3476         /**
3477          * Starts a poll cycle.
3478          *
3479          * @api private
3480          */
3481         
3482         XHR.prototype.doPoll = function () {
3483           debug('xhr poll');
3484           var req = this.request();
3485           var self = this;
3486           req.on('data', function (data) {
3487             self.onData(data);
3488           });
3489           req.on('error', function (err) {
3490             self.onError('xhr poll error', err);
3491           });
3492           this.pollXhr = req;
3493         };
3494         
3495         /**
3496          * Request constructor
3497          *
3498          * @param {Object} options
3499          * @api public
3500          */
3501         
3502         function Request (opts) {
3503           this.method = opts.method || 'GET';
3504           this.uri = opts.uri;
3505           this.xd = !!opts.xd;
3506           this.xs = !!opts.xs;
3507           this.async = false !== opts.async;
3508           this.data = undefined !== opts.data ? opts.data : null;
3509           this.agent = opts.agent;
3510           this.isBinary = opts.isBinary;
3511           this.supportsBinary = opts.supportsBinary;
3512           this.enablesXDR = opts.enablesXDR;
3513           this.withCredentials = opts.withCredentials;
3514           this.requestTimeout = opts.requestTimeout;
3515         
3516           // SSL options for Node.js client
3517           this.pfx = opts.pfx;
3518           this.key = opts.key;
3519           this.passphrase = opts.passphrase;
3520           this.cert = opts.cert;
3521           this.ca = opts.ca;
3522           this.ciphers = opts.ciphers;
3523           this.rejectUnauthorized = opts.rejectUnauthorized;
3524         
3525           // other options for Node.js client
3526           this.extraHeaders = opts.extraHeaders;
3527         
3528           this.create();
3529         }
3530         
3531         /**
3532          * Mix in `Emitter`.
3533          */
3534         
3535         Emitter(Request.prototype);
3536         
3537         /**
3538          * Creates the XHR object and sends the request.
3539          *
3540          * @api private
3541          */
3542         
3543         Request.prototype.create = function () {
3544           var opts = { agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR };
3545         
3546           // SSL options for Node.js client
3547           opts.pfx = this.pfx;
3548           opts.key = this.key;
3549           opts.passphrase = this.passphrase;
3550           opts.cert = this.cert;
3551           opts.ca = this.ca;
3552           opts.ciphers = this.ciphers;
3553           opts.rejectUnauthorized = this.rejectUnauthorized;
3554         
3555           var xhr = this.xhr = new XMLHttpRequest(opts);
3556           var self = this;
3557         
3558           try {
3559             debug('xhr open %s: %s', this.method, this.uri);
3560             xhr.open(this.method, this.uri, this.async);
3561             try {
3562               if (this.extraHeaders) {
3563                 xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
3564                 for (var i in this.extraHeaders) {
3565                   if (this.extraHeaders.hasOwnProperty(i)) {
3566                     xhr.setRequestHeader(i, this.extraHeaders[i]);
3567                   }
3568                 }
3569               }
3570             } catch (e) {}
3571         
3572             if ('POST' === this.method) {
3573               try {
3574                 if (this.isBinary) {
3575                   xhr.setRequestHeader('Content-type', 'application/octet-stream');
3576                 } else {
3577                   xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
3578                 }
3579               } catch (e) {}
3580             }
3581         
3582             try {
3583               xhr.setRequestHeader('Accept', '*/*');
3584             } catch (e) {}
3585         
3586             // ie6 check
3587             if ('withCredentials' in xhr) {
3588               xhr.withCredentials = this.withCredentials;
3589             }
3590         
3591             if (this.requestTimeout) {
3592               xhr.timeout = this.requestTimeout;
3593             }
3594         
3595             if (this.hasXDR()) {
3596               xhr.onload = function () {
3597                 self.onLoad();
3598               };
3599               xhr.onerror = function () {
3600                 self.onError(xhr.responseText);
3601               };
3602             } else {
3603               xhr.onreadystatechange = function () {
3604                 if (xhr.readyState === 2) {
3605                   try {
3606                     var contentType = xhr.getResponseHeader('Content-Type');
3607                     if (self.supportsBinary && contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') {
3608                       xhr.responseType = 'arraybuffer';
3609                     }
3610                   } catch (e) {}
3611                 }
3612                 if (4 !== xhr.readyState) return;
3613                 if (200 === xhr.status || 1223 === xhr.status) {
3614                   self.onLoad();
3615                 } else {
3616                   // make sure the `error` event handler that's user-set
3617                   // does not throw in the same tick and gets caught here
3618                   setTimeout(function () {
3619                     self.onError(typeof xhr.status === 'number' ? xhr.status : 0);
3620                   }, 0);
3621                 }
3622               };
3623             }
3624         
3625             debug('xhr data %s', this.data);
3626             xhr.send(this.data);
3627           } catch (e) {
3628             // Need to defer since .create() is called directly fhrom the constructor
3629             // and thus the 'error' event can only be only bound *after* this exception
3630             // occurs.  Therefore, also, we cannot throw here at all.
3631             setTimeout(function () {
3632               self.onError(e);
3633             }, 0);
3634             return;
3635           }
3636         
3637           if (typeof document !== 'undefined') {
3638             this.index = Request.requestsCount++;
3639             Request.requests[this.index] = this;
3640           }
3641         };
3642         
3643         /**
3644          * Called upon successful response.
3645          *
3646          * @api private
3647          */
3648         
3649         Request.prototype.onSuccess = function () {
3650           this.emit('success');
3651           this.cleanup();
3652         };
3653         
3654         /**
3655          * Called if we have data.
3656          *
3657          * @api private
3658          */
3659         
3660         Request.prototype.onData = function (data) {
3661           this.emit('data', data);
3662           this.onSuccess();
3663         };
3664         
3665         /**
3666          * Called upon error.
3667          *
3668          * @api private
3669          */
3670         
3671         Request.prototype.onError = function (err) {
3672           this.emit('error', err);
3673           this.cleanup(true);
3674         };
3675         
3676         /**
3677          * Cleans up house.
3678          *
3679          * @api private
3680          */
3681         
3682         Request.prototype.cleanup = function (fromError) {
3683           if ('undefined' === typeof this.xhr || null === this.xhr) {
3684             return;
3685           }
3686           // xmlhttprequest
3687           if (this.hasXDR()) {
3688             this.xhr.onload = this.xhr.onerror = empty;
3689           } else {
3690             this.xhr.onreadystatechange = empty;
3691           }
3692         
3693           if (fromError) {
3694             try {
3695               this.xhr.abort();
3696             } catch (e) {}
3697           }
3698         
3699           if (typeof document !== 'undefined') {
3700             delete Request.requests[this.index];
3701           }
3702         
3703           this.xhr = null;
3704         };
3705         
3706         /**
3707          * Called upon load.
3708          *
3709          * @api private
3710          */
3711         
3712         Request.prototype.onLoad = function () {
3713           var data;
3714           try {
3715             var contentType;
3716             try {
3717               contentType = this.xhr.getResponseHeader('Content-Type');
3718             } catch (e) {}
3719             if (contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') {
3720               data = this.xhr.response || this.xhr.responseText;
3721             } else {
3722               data = this.xhr.responseText;
3723             }
3724           } catch (e) {
3725             this.onError(e);
3726           }
3727           if (null != data) {
3728             this.onData(data);
3729           }
3730         };
3731         
3732         /**
3733          * Check if it has XDomainRequest.
3734          *
3735          * @api private
3736          */
3737         
3738         Request.prototype.hasXDR = function () {
3739           return typeof XDomainRequest !== 'undefined' && !this.xs && this.enablesXDR;
3740         };
3741         
3742         /**
3743          * Aborts the request.
3744          *
3745          * @api public
3746          */
3747         
3748         Request.prototype.abort = function () {
3749           this.cleanup();
3750         };
3751         
3752         /**
3753          * Aborts pending requests when unloading the window. This is needed to prevent
3754          * memory leaks (e.g. when using IE) and to ensure that no spurious error is
3755          * emitted.
3756          */
3757         
3758         Request.requestsCount = 0;
3759         Request.requests = {};
3760         
3761         if (typeof document !== 'undefined') {
3762           if (typeof attachEvent === 'function') {
3763             attachEvent('onunload', unloadHandler);
3764           } else if (typeof addEventListener === 'function') {
3765             var terminationEvent = 'onpagehide' in globalThis ? 'pagehide' : 'unload';
3766             addEventListener(terminationEvent, unloadHandler, false);
3767           }
3768         }
3769         
3770         function unloadHandler () {
3771           for (var i in Request.requests) {
3772             if (Request.requests.hasOwnProperty(i)) {
3773               Request.requests[i].abort();
3774             }
3775           }
3776         }
3777
3778
3779 /***/ }),
3780 /* 20 */
3781 /***/ (function(module, exports, __webpack_require__) {
3782
3783         /**
3784          * Module dependencies.
3785          */
3786         
3787         var Transport = __webpack_require__(21);
3788         var parseqs = __webpack_require__(30);
3789         var parser = __webpack_require__(22);
3790         var inherit = __webpack_require__(31);
3791         var yeast = __webpack_require__(32);
3792         var debug = __webpack_require__(3)('engine.io-client:polling');
3793         
3794         /**
3795          * Module exports.
3796          */
3797         
3798         module.exports = Polling;
3799         
3800         /**
3801          * Is XHR2 supported?
3802          */
3803         
3804         var hasXHR2 = (function () {
3805           var XMLHttpRequest = __webpack_require__(16);
3806           var xhr = new XMLHttpRequest({ xdomain: false });
3807           return null != xhr.responseType;
3808         })();
3809         
3810         /**
3811          * Polling interface.
3812          *
3813          * @param {Object} opts
3814          * @api private
3815          */
3816         
3817         function Polling (opts) {
3818           var forceBase64 = (opts && opts.forceBase64);
3819           if (!hasXHR2 || forceBase64) {
3820             this.supportsBinary = false;
3821           }
3822           Transport.call(this, opts);
3823         }
3824         
3825         /**
3826          * Inherits from Transport.
3827          */
3828         
3829         inherit(Polling, Transport);
3830         
3831         /**
3832          * Transport name.
3833          */
3834         
3835         Polling.prototype.name = 'polling';
3836         
3837         /**
3838          * Opens the socket (triggers polling). We write a PING message to determine
3839          * when the transport is open.
3840          *
3841          * @api private
3842          */
3843         
3844         Polling.prototype.doOpen = function () {
3845           this.poll();
3846         };
3847         
3848         /**
3849          * Pauses polling.
3850          *
3851          * @param {Function} callback upon buffers are flushed and transport is paused
3852          * @api private
3853          */
3854         
3855         Polling.prototype.pause = function (onPause) {
3856           var self = this;
3857         
3858           this.readyState = 'pausing';
3859         
3860           function pause () {
3861             debug('paused');
3862             self.readyState = 'paused';
3863             onPause();
3864           }
3865         
3866           if (this.polling || !this.writable) {
3867             var total = 0;
3868         
3869             if (this.polling) {
3870               debug('we are currently polling - waiting to pause');
3871               total++;
3872               this.once('pollComplete', function () {
3873                 debug('pre-pause polling complete');
3874                 --total || pause();
3875               });
3876             }
3877         
3878             if (!this.writable) {
3879               debug('we are currently writing - waiting to pause');
3880               total++;
3881               this.once('drain', function () {
3882                 debug('pre-pause writing complete');
3883                 --total || pause();
3884               });
3885             }
3886           } else {
3887             pause();
3888           }
3889         };
3890         
3891         /**
3892          * Starts polling cycle.
3893          *
3894          * @api public
3895          */
3896         
3897         Polling.prototype.poll = function () {
3898           debug('polling');
3899           this.polling = true;
3900           this.doPoll();
3901           this.emit('poll');
3902         };
3903         
3904         /**
3905          * Overloads onData to detect payloads.
3906          *
3907          * @api private
3908          */
3909         
3910         Polling.prototype.onData = function (data) {
3911           var self = this;
3912           debug('polling got data %s', data);
3913           var callback = function (packet, index, total) {
3914             // if its the first message we consider the transport open
3915             if ('opening' === self.readyState && packet.type === 'open') {
3916               self.onOpen();
3917             }
3918         
3919             // if its a close packet, we close the ongoing requests
3920             if ('close' === packet.type) {
3921               self.onClose();
3922               return false;
3923             }
3924         
3925             // otherwise bypass onData and handle the message
3926             self.onPacket(packet);
3927           };
3928         
3929           // decode payload
3930           parser.decodePayload(data, this.socket.binaryType, callback);
3931         
3932           // if an event did not trigger closing
3933           if ('closed' !== this.readyState) {
3934             // if we got data we're not polling
3935             this.polling = false;
3936             this.emit('pollComplete');
3937         
3938             if ('open' === this.readyState) {
3939               this.poll();
3940             } else {
3941               debug('ignoring poll - transport state "%s"', this.readyState);
3942             }
3943           }
3944         };
3945         
3946         /**
3947          * For polling, send a close packet.
3948          *
3949          * @api private
3950          */
3951         
3952         Polling.prototype.doClose = function () {
3953           var self = this;
3954         
3955           function close () {
3956             debug('writing close packet');
3957             self.write([{ type: 'close' }]);
3958           }
3959         
3960           if ('open' === this.readyState) {
3961             debug('transport open - closing');
3962             close();
3963           } else {
3964             // in case we're trying to close while
3965             // handshaking is in progress (GH-164)
3966             debug('transport not open - deferring close');
3967             this.once('open', close);
3968           }
3969         };
3970         
3971         /**
3972          * Writes a packets payload.
3973          *
3974          * @param {Array} data packets
3975          * @param {Function} drain callback
3976          * @api private
3977          */
3978         
3979         Polling.prototype.write = function (packets) {
3980           var self = this;
3981           this.writable = false;
3982           var callbackfn = function () {
3983             self.writable = true;
3984             self.emit('drain');
3985           };
3986         
3987           parser.encodePayload(packets, this.supportsBinary, function (data) {
3988             self.doWrite(data, callbackfn);
3989           });
3990         };
3991         
3992         /**
3993          * Generates uri for connection.
3994          *
3995          * @api private
3996          */
3997         
3998         Polling.prototype.uri = function () {
3999           var query = this.query || {};
4000           var schema = this.secure ? 'https' : 'http';
4001           var port = '';
4002         
4003           // cache busting is forced
4004           if (false !== this.timestampRequests) {
4005             query[this.timestampParam] = yeast();
4006           }
4007         
4008           if (!this.supportsBinary && !query.sid) {
4009             query.b64 = 1;
4010           }
4011         
4012           query = parseqs.encode(query);
4013         
4014           // avoid port if default for schema
4015           if (this.port && (('https' === schema && Number(this.port) !== 443) ||
4016              ('http' === schema && Number(this.port) !== 80))) {
4017             port = ':' + this.port;
4018           }
4019         
4020           // prepend ? to query
4021           if (query.length) {
4022             query = '?' + query;
4023           }
4024         
4025           var ipv6 = this.hostname.indexOf(':') !== -1;
4026           return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
4027         };
4028
4029
4030 /***/ }),
4031 /* 21 */
4032 /***/ (function(module, exports, __webpack_require__) {
4033
4034         /**
4035          * Module dependencies.
4036          */
4037         
4038         var parser = __webpack_require__(22);
4039         var Emitter = __webpack_require__(8);
4040         
4041         /**
4042          * Module exports.
4043          */
4044         
4045         module.exports = Transport;
4046         
4047         /**
4048          * Transport abstract constructor.
4049          *
4050          * @param {Object} options.
4051          * @api private
4052          */
4053         
4054         function Transport (opts) {
4055           this.path = opts.path;
4056           this.hostname = opts.hostname;
4057           this.port = opts.port;
4058           this.secure = opts.secure;
4059           this.query = opts.query;
4060           this.timestampParam = opts.timestampParam;
4061           this.timestampRequests = opts.timestampRequests;
4062           this.readyState = '';
4063           this.agent = opts.agent || false;
4064           this.socket = opts.socket;
4065           this.enablesXDR = opts.enablesXDR;
4066           this.withCredentials = opts.withCredentials;
4067         
4068           // SSL options for Node.js client
4069           this.pfx = opts.pfx;
4070           this.key = opts.key;
4071           this.passphrase = opts.passphrase;
4072           this.cert = opts.cert;
4073           this.ca = opts.ca;
4074           this.ciphers = opts.ciphers;
4075           this.rejectUnauthorized = opts.rejectUnauthorized;
4076           this.forceNode = opts.forceNode;
4077         
4078           // results of ReactNative environment detection
4079           this.isReactNative = opts.isReactNative;
4080         
4081           // other options for Node.js client
4082           this.extraHeaders = opts.extraHeaders;
4083           this.localAddress = opts.localAddress;
4084         }
4085         
4086         /**
4087          * Mix in `Emitter`.
4088          */
4089         
4090         Emitter(Transport.prototype);
4091         
4092         /**
4093          * Emits an error.
4094          *
4095          * @param {String} str
4096          * @return {Transport} for chaining
4097          * @api public
4098          */
4099         
4100         Transport.prototype.onError = function (msg, desc) {
4101           var err = new Error(msg);
4102           err.type = 'TransportError';
4103           err.description = desc;
4104           this.emit('error', err);
4105           return this;
4106         };
4107         
4108         /**
4109          * Opens the transport.
4110          *
4111          * @api public
4112          */
4113         
4114         Transport.prototype.open = function () {
4115           if ('closed' === this.readyState || '' === this.readyState) {
4116             this.readyState = 'opening';
4117             this.doOpen();
4118           }
4119         
4120           return this;
4121         };
4122         
4123         /**
4124          * Closes the transport.
4125          *
4126          * @api private
4127          */
4128         
4129         Transport.prototype.close = function () {
4130           if ('opening' === this.readyState || 'open' === this.readyState) {
4131             this.doClose();
4132             this.onClose();
4133           }
4134         
4135           return this;
4136         };
4137         
4138         /**
4139          * Sends multiple packets.
4140          *
4141          * @param {Array} packets
4142          * @api private
4143          */
4144         
4145         Transport.prototype.send = function (packets) {
4146           if ('open' === this.readyState) {
4147             this.write(packets);
4148           } else {
4149             throw new Error('Transport not open');
4150           }
4151         };
4152         
4153         /**
4154          * Called upon open
4155          *
4156          * @api private
4157          */
4158         
4159         Transport.prototype.onOpen = function () {
4160           this.readyState = 'open';
4161           this.writable = true;
4162           this.emit('open');
4163         };
4164         
4165         /**
4166          * Called with data.
4167          *
4168          * @param {String} data
4169          * @api private
4170          */
4171         
4172         Transport.prototype.onData = function (data) {
4173           var packet = parser.decodePacket(data, this.socket.binaryType);
4174           this.onPacket(packet);
4175         };
4176         
4177         /**
4178          * Called with a decoded packet.
4179          */
4180         
4181         Transport.prototype.onPacket = function (packet) {
4182           this.emit('packet', packet);
4183         };
4184         
4185         /**
4186          * Called upon close.
4187          *
4188          * @api private
4189          */
4190         
4191         Transport.prototype.onClose = function () {
4192           this.readyState = 'closed';
4193           this.emit('close');
4194         };
4195
4196
4197 /***/ }),
4198 /* 22 */
4199 /***/ (function(module, exports, __webpack_require__) {
4200
4201         /**
4202          * Module dependencies.
4203          */
4204         
4205         var keys = __webpack_require__(23);
4206         var hasBinary = __webpack_require__(24);
4207         var sliceBuffer = __webpack_require__(25);
4208         var after = __webpack_require__(26);
4209         var utf8 = __webpack_require__(27);
4210         
4211         var base64encoder;
4212         if (typeof ArrayBuffer !== 'undefined') {
4213           base64encoder = __webpack_require__(28);
4214         }
4215         
4216         /**
4217          * Check if we are running an android browser. That requires us to use
4218          * ArrayBuffer with polling transports...
4219          *
4220          * http://ghinda.net/jpeg-blob-ajax-android/
4221          */
4222         
4223         var isAndroid = typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent);
4224         
4225         /**
4226          * Check if we are running in PhantomJS.
4227          * Uploading a Blob with PhantomJS does not work correctly, as reported here:
4228          * https://github.com/ariya/phantomjs/issues/11395
4229          * @type boolean
4230          */
4231         var isPhantomJS = typeof navigator !== 'undefined' && /PhantomJS/i.test(navigator.userAgent);
4232         
4233         /**
4234          * When true, avoids using Blobs to encode payloads.
4235          * @type boolean
4236          */
4237         var dontSendBlobs = isAndroid || isPhantomJS;
4238         
4239         /**
4240          * Current protocol version.
4241          */
4242         
4243         exports.protocol = 3;
4244         
4245         /**
4246          * Packet types.
4247          */
4248         
4249         var packets = exports.packets = {
4250             open:     0    // non-ws
4251           , close:    1    // non-ws
4252           , ping:     2
4253           , pong:     3
4254           , message:  4
4255           , upgrade:  5
4256           , noop:     6
4257         };
4258         
4259         var packetslist = keys(packets);
4260         
4261         /**
4262          * Premade error packet.
4263          */
4264         
4265         var err = { type: 'error', data: 'parser error' };
4266         
4267         /**
4268          * Create a blob api even for blob builder when vendor prefixes exist
4269          */
4270         
4271         var Blob = __webpack_require__(29);
4272         
4273         /**
4274          * Encodes a packet.
4275          *
4276          *     <packet type id> [ <data> ]
4277          *
4278          * Example:
4279          *
4280          *     5hello world
4281          *     3
4282          *     4
4283          *
4284          * Binary is encoded in an identical principle
4285          *
4286          * @api private
4287          */
4288         
4289         exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
4290           if (typeof supportsBinary === 'function') {
4291             callback = supportsBinary;
4292             supportsBinary = false;
4293           }
4294         
4295           if (typeof utf8encode === 'function') {
4296             callback = utf8encode;
4297             utf8encode = null;
4298           }
4299         
4300           var data = (packet.data === undefined)
4301             ? undefined
4302             : packet.data.buffer || packet.data;
4303         
4304           if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) {
4305             return encodeArrayBuffer(packet, supportsBinary, callback);
4306           } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
4307             return encodeBlob(packet, supportsBinary, callback);
4308           }
4309         
4310           // might be an object with { base64: true, data: dataAsBase64String }
4311           if (data && data.base64) {
4312             return encodeBase64Object(packet, callback);
4313           }
4314         
4315           // Sending data as a utf-8 string
4316           var encoded = packets[packet.type];
4317         
4318           // data fragment is optional
4319           if (undefined !== packet.data) {
4320             encoded += utf8encode ? utf8.encode(String(packet.data), { strict: false }) : String(packet.data);
4321           }
4322         
4323           return callback('' + encoded);
4324         
4325         };
4326         
4327         function encodeBase64Object(packet, callback) {
4328           // packet data is an object { base64: true, data: dataAsBase64String }
4329           var message = 'b' + exports.packets[packet.type] + packet.data.data;
4330           return callback(message);
4331         }
4332         
4333         /**
4334          * Encode packet helpers for binary types
4335          */
4336         
4337         function encodeArrayBuffer(packet, supportsBinary, callback) {
4338           if (!supportsBinary) {
4339             return exports.encodeBase64Packet(packet, callback);
4340           }
4341         
4342           var data = packet.data;
4343           var contentArray = new Uint8Array(data);
4344           var resultBuffer = new Uint8Array(1 + data.byteLength);
4345         
4346           resultBuffer[0] = packets[packet.type];
4347           for (var i = 0; i < contentArray.length; i++) {
4348             resultBuffer[i+1] = contentArray[i];
4349           }
4350         
4351           return callback(resultBuffer.buffer);
4352         }
4353         
4354         function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) {
4355           if (!supportsBinary) {
4356             return exports.encodeBase64Packet(packet, callback);
4357           }
4358         
4359           var fr = new FileReader();
4360           fr.onload = function() {
4361             exports.encodePacket({ type: packet.type, data: fr.result }, supportsBinary, true, callback);
4362           };
4363           return fr.readAsArrayBuffer(packet.data);
4364         }
4365         
4366         function encodeBlob(packet, supportsBinary, callback) {
4367           if (!supportsBinary) {
4368             return exports.encodeBase64Packet(packet, callback);
4369           }
4370         
4371           if (dontSendBlobs) {
4372             return encodeBlobAsArrayBuffer(packet, supportsBinary, callback);
4373           }
4374         
4375           var length = new Uint8Array(1);
4376           length[0] = packets[packet.type];
4377           var blob = new Blob([length.buffer, packet.data]);
4378         
4379           return callback(blob);
4380         }
4381         
4382         /**
4383          * Encodes a packet with binary data in a base64 string
4384          *
4385          * @param {Object} packet, has `type` and `data`
4386          * @return {String} base64 encoded message
4387          */
4388         
4389         exports.encodeBase64Packet = function(packet, callback) {
4390           var message = 'b' + exports.packets[packet.type];
4391           if (typeof Blob !== 'undefined' && packet.data instanceof Blob) {
4392             var fr = new FileReader();
4393             fr.onload = function() {
4394               var b64 = fr.result.split(',')[1];
4395               callback(message + b64);
4396             };
4397             return fr.readAsDataURL(packet.data);
4398           }
4399         
4400           var b64data;
4401           try {
4402             b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data));
4403           } catch (e) {
4404             // iPhone Safari doesn't let you apply with typed arrays
4405             var typed = new Uint8Array(packet.data);
4406             var basic = new Array(typed.length);
4407             for (var i = 0; i < typed.length; i++) {
4408               basic[i] = typed[i];
4409             }
4410             b64data = String.fromCharCode.apply(null, basic);
4411           }
4412           message += btoa(b64data);
4413           return callback(message);
4414         };
4415         
4416         /**
4417          * Decodes a packet. Changes format to Blob if requested.
4418          *
4419          * @return {Object} with `type` and `data` (if any)
4420          * @api private
4421          */
4422         
4423         exports.decodePacket = function (data, binaryType, utf8decode) {
4424           if (data === undefined) {
4425             return err;
4426           }
4427           // String data
4428           if (typeof data === 'string') {
4429             if (data.charAt(0) === 'b') {
4430               return exports.decodeBase64Packet(data.substr(1), binaryType);
4431             }
4432         
4433             if (utf8decode) {
4434               data = tryDecode(data);
4435               if (data === false) {
4436                 return err;
4437               }
4438             }
4439             var type = data.charAt(0);
4440         
4441             if (Number(type) != type || !packetslist[type]) {
4442               return err;
4443             }
4444         
4445             if (data.length > 1) {
4446               return { type: packetslist[type], data: data.substring(1) };
4447             } else {
4448               return { type: packetslist[type] };
4449             }
4450           }
4451         
4452           var asArray = new Uint8Array(data);
4453           var type = asArray[0];
4454           var rest = sliceBuffer(data, 1);
4455           if (Blob && binaryType === 'blob') {
4456             rest = new Blob([rest]);
4457           }
4458           return { type: packetslist[type], data: rest };
4459         };
4460         
4461         function tryDecode(data) {
4462           try {
4463             data = utf8.decode(data, { strict: false });
4464           } catch (e) {
4465             return false;
4466           }
4467           return data;
4468         }
4469         
4470         /**
4471          * Decodes a packet encoded in a base64 string
4472          *
4473          * @param {String} base64 encoded message
4474          * @return {Object} with `type` and `data` (if any)
4475          */
4476         
4477         exports.decodeBase64Packet = function(msg, binaryType) {
4478           var type = packetslist[msg.charAt(0)];
4479           if (!base64encoder) {
4480             return { type: type, data: { base64: true, data: msg.substr(1) } };
4481           }
4482         
4483           var data = base64encoder.decode(msg.substr(1));
4484         
4485           if (binaryType === 'blob' && Blob) {
4486             data = new Blob([data]);
4487           }
4488         
4489           return { type: type, data: data };
4490         };
4491         
4492         /**
4493          * Encodes multiple messages (payload).
4494          *
4495          *     <length>:data
4496          *
4497          * Example:
4498          *
4499          *     11:hello world2:hi
4500          *
4501          * If any contents are binary, they will be encoded as base64 strings. Base64
4502          * encoded strings are marked with a b before the length specifier
4503          *
4504          * @param {Array} packets
4505          * @api private
4506          */
4507         
4508         exports.encodePayload = function (packets, supportsBinary, callback) {
4509           if (typeof supportsBinary === 'function') {
4510             callback = supportsBinary;
4511             supportsBinary = null;
4512           }
4513         
4514           var isBinary = hasBinary(packets);
4515         
4516           if (supportsBinary && isBinary) {
4517             if (Blob && !dontSendBlobs) {
4518               return exports.encodePayloadAsBlob(packets, callback);
4519             }
4520         
4521             return exports.encodePayloadAsArrayBuffer(packets, callback);
4522           }
4523         
4524           if (!packets.length) {
4525             return callback('0:');
4526           }
4527         
4528           function setLengthHeader(message) {
4529             return message.length + ':' + message;
4530           }
4531         
4532           function encodeOne(packet, doneCallback) {
4533             exports.encodePacket(packet, !isBinary ? false : supportsBinary, false, function(message) {
4534               doneCallback(null, setLengthHeader(message));
4535             });
4536           }
4537         
4538           map(packets, encodeOne, function(err, results) {
4539             return callback(results.join(''));
4540           });
4541         };
4542         
4543         /**
4544          * Async array map using after
4545          */
4546         
4547         function map(ary, each, done) {
4548           var result = new Array(ary.length);
4549           var next = after(ary.length, done);
4550         
4551           var eachWithIndex = function(i, el, cb) {
4552             each(el, function(error, msg) {
4553               result[i] = msg;
4554               cb(error, result);
4555             });
4556           };
4557         
4558           for (var i = 0; i < ary.length; i++) {
4559             eachWithIndex(i, ary[i], next);
4560           }
4561         }
4562         
4563         /*
4564          * Decodes data when a payload is maybe expected. Possible binary contents are
4565          * decoded from their base64 representation
4566          *
4567          * @param {String} data, callback method
4568          * @api public
4569          */
4570         
4571         exports.decodePayload = function (data, binaryType, callback) {
4572           if (typeof data !== 'string') {
4573             return exports.decodePayloadAsBinary(data, binaryType, callback);
4574           }
4575         
4576           if (typeof binaryType === 'function') {
4577             callback = binaryType;
4578             binaryType = null;
4579           }
4580         
4581           var packet;
4582           if (data === '') {
4583             // parser error - ignoring payload
4584             return callback(err, 0, 1);
4585           }
4586         
4587           var length = '', n, msg;
4588         
4589           for (var i = 0, l = data.length; i < l; i++) {
4590             var chr = data.charAt(i);
4591         
4592             if (chr !== ':') {
4593               length += chr;
4594               continue;
4595             }
4596         
4597             if (length === '' || (length != (n = Number(length)))) {
4598               // parser error - ignoring payload
4599               return callback(err, 0, 1);
4600             }
4601         
4602             msg = data.substr(i + 1, n);
4603         
4604             if (length != msg.length) {
4605               // parser error - ignoring payload
4606               return callback(err, 0, 1);
4607             }
4608         
4609             if (msg.length) {
4610               packet = exports.decodePacket(msg, binaryType, false);
4611         
4612               if (err.type === packet.type && err.data === packet.data) {
4613                 // parser error in individual packet - ignoring payload
4614                 return callback(err, 0, 1);
4615               }
4616         
4617               var ret = callback(packet, i + n, l);
4618               if (false === ret) return;
4619             }
4620         
4621             // advance cursor
4622             i += n;
4623             length = '';
4624           }
4625         
4626           if (length !== '') {
4627             // parser error - ignoring payload
4628             return callback(err, 0, 1);
4629           }
4630         
4631         };
4632         
4633         /**
4634          * Encodes multiple messages (payload) as binary.
4635          *
4636          * <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number
4637          * 255><data>
4638          *
4639          * Example:
4640          * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers
4641          *
4642          * @param {Array} packets
4643          * @return {ArrayBuffer} encoded payload
4644          * @api private
4645          */
4646         
4647         exports.encodePayloadAsArrayBuffer = function(packets, callback) {
4648           if (!packets.length) {
4649             return callback(new ArrayBuffer(0));
4650           }
4651         
4652           function encodeOne(packet, doneCallback) {
4653             exports.encodePacket(packet, true, true, function(data) {
4654               return doneCallback(null, data);
4655             });
4656           }
4657         
4658           map(packets, encodeOne, function(err, encodedPackets) {
4659             var totalLength = encodedPackets.reduce(function(acc, p) {
4660               var len;
4661               if (typeof p === 'string'){
4662                 len = p.length;
4663               } else {
4664                 len = p.byteLength;
4665               }
4666               return acc + len.toString().length + len + 2; // string/binary identifier + separator = 2
4667             }, 0);
4668         
4669             var resultArray = new Uint8Array(totalLength);
4670         
4671             var bufferIndex = 0;
4672             encodedPackets.forEach(function(p) {
4673               var isString = typeof p === 'string';
4674               var ab = p;
4675               if (isString) {
4676                 var view = new Uint8Array(p.length);
4677                 for (var i = 0; i < p.length; i++) {
4678                   view[i] = p.charCodeAt(i);
4679                 }
4680                 ab = view.buffer;
4681               }
4682         
4683               if (isString) { // not true binary
4684                 resultArray[bufferIndex++] = 0;
4685               } else { // true binary
4686                 resultArray[bufferIndex++] = 1;
4687               }
4688         
4689               var lenStr = ab.byteLength.toString();
4690               for (var i = 0; i < lenStr.length; i++) {
4691                 resultArray[bufferIndex++] = parseInt(lenStr[i]);
4692               }
4693               resultArray[bufferIndex++] = 255;
4694         
4695               var view = new Uint8Array(ab);
4696               for (var i = 0; i < view.length; i++) {
4697                 resultArray[bufferIndex++] = view[i];
4698               }
4699             });
4700         
4701             return callback(resultArray.buffer);
4702           });
4703         };
4704         
4705         /**
4706          * Encode as Blob
4707          */
4708         
4709         exports.encodePayloadAsBlob = function(packets, callback) {
4710           function encodeOne(packet, doneCallback) {
4711             exports.encodePacket(packet, true, true, function(encoded) {
4712               var binaryIdentifier = new Uint8Array(1);
4713               binaryIdentifier[0] = 1;
4714               if (typeof encoded === 'string') {
4715                 var view = new Uint8Array(encoded.length);
4716                 for (var i = 0; i < encoded.length; i++) {
4717                   view[i] = encoded.charCodeAt(i);
4718                 }
4719                 encoded = view.buffer;
4720                 binaryIdentifier[0] = 0;
4721               }
4722         
4723               var len = (encoded instanceof ArrayBuffer)
4724                 ? encoded.byteLength
4725                 : encoded.size;
4726         
4727               var lenStr = len.toString();
4728               var lengthAry = new Uint8Array(lenStr.length + 1);
4729               for (var i = 0; i < lenStr.length; i++) {
4730                 lengthAry[i] = parseInt(lenStr[i]);
4731               }
4732               lengthAry[lenStr.length] = 255;
4733         
4734               if (Blob) {
4735                 var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]);
4736                 doneCallback(null, blob);
4737               }
4738             });
4739           }
4740         
4741           map(packets, encodeOne, function(err, results) {
4742             return callback(new Blob(results));
4743           });
4744         };
4745         
4746         /*
4747          * Decodes data when a payload is maybe expected. Strings are decoded by
4748          * interpreting each byte as a key code for entries marked to start with 0. See
4749          * description of encodePayloadAsBinary
4750          *
4751          * @param {ArrayBuffer} data, callback method
4752          * @api public
4753          */
4754         
4755         exports.decodePayloadAsBinary = function (data, binaryType, callback) {
4756           if (typeof binaryType === 'function') {
4757             callback = binaryType;
4758             binaryType = null;
4759           }
4760         
4761           var bufferTail = data;
4762           var buffers = [];
4763         
4764           while (bufferTail.byteLength > 0) {
4765             var tailArray = new Uint8Array(bufferTail);
4766             var isString = tailArray[0] === 0;
4767             var msgLength = '';
4768         
4769             for (var i = 1; ; i++) {
4770               if (tailArray[i] === 255) break;
4771         
4772               // 310 = char length of Number.MAX_VALUE
4773               if (msgLength.length > 310) {
4774                 return callback(err, 0, 1);
4775               }
4776         
4777               msgLength += tailArray[i];
4778             }
4779         
4780             bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length);
4781             msgLength = parseInt(msgLength);
4782         
4783             var msg = sliceBuffer(bufferTail, 0, msgLength);
4784             if (isString) {
4785               try {
4786                 msg = String.fromCharCode.apply(null, new Uint8Array(msg));
4787               } catch (e) {
4788                 // iPhone Safari doesn't let you apply to typed arrays
4789                 var typed = new Uint8Array(msg);
4790                 msg = '';
4791                 for (var i = 0; i < typed.length; i++) {
4792                   msg += String.fromCharCode(typed[i]);
4793                 }
4794               }
4795             }
4796         
4797             buffers.push(msg);
4798             bufferTail = sliceBuffer(bufferTail, msgLength);
4799           }
4800         
4801           var total = buffers.length;
4802           buffers.forEach(function(buffer, i) {
4803             callback(exports.decodePacket(buffer, binaryType, true), i, total);
4804           });
4805         };
4806
4807
4808 /***/ }),
4809 /* 23 */
4810 /***/ (function(module, exports) {
4811
4812         
4813         /**
4814          * Gets the keys for an object.
4815          *
4816          * @return {Array} keys
4817          * @api private
4818          */
4819         
4820         module.exports = Object.keys || function keys (obj){
4821           var arr = [];
4822           var has = Object.prototype.hasOwnProperty;
4823         
4824           for (var i in obj) {
4825             if (has.call(obj, i)) {
4826               arr.push(i);
4827             }
4828           }
4829           return arr;
4830         };
4831
4832
4833 /***/ }),
4834 /* 24 */
4835 /***/ (function(module, exports, __webpack_require__) {
4836
4837         /* global Blob File */
4838         
4839         /*
4840          * Module requirements.
4841          */
4842         
4843         var isArray = __webpack_require__(10);
4844         
4845         var toString = Object.prototype.toString;
4846         var withNativeBlob = typeof Blob === 'function' ||
4847                                 typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]';
4848         var withNativeFile = typeof File === 'function' ||
4849                                 typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]';
4850         
4851         /**
4852          * Module exports.
4853          */
4854         
4855         module.exports = hasBinary;
4856         
4857         /**
4858          * Checks for binary data.
4859          *
4860          * Supports Buffer, ArrayBuffer, Blob and File.
4861          *
4862          * @param {Object} anything
4863          * @api public
4864          */
4865         
4866         function hasBinary (obj) {
4867           if (!obj || typeof obj !== 'object') {
4868             return false;
4869           }
4870         
4871           if (isArray(obj)) {
4872             for (var i = 0, l = obj.length; i < l; i++) {
4873               if (hasBinary(obj[i])) {
4874                 return true;
4875               }
4876             }
4877             return false;
4878           }
4879         
4880           if ((typeof Buffer === 'function' && Buffer.isBuffer && Buffer.isBuffer(obj)) ||
4881             (typeof ArrayBuffer === 'function' && obj instanceof ArrayBuffer) ||
4882             (withNativeBlob && obj instanceof Blob) ||
4883             (withNativeFile && obj instanceof File)
4884           ) {
4885             return true;
4886           }
4887         
4888           // see: https://github.com/Automattic/has-binary/pull/4
4889           if (obj.toJSON && typeof obj.toJSON === 'function' && arguments.length === 1) {
4890             return hasBinary(obj.toJSON(), true);
4891           }
4892         
4893           for (var key in obj) {
4894             if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
4895               return true;
4896             }
4897           }
4898         
4899           return false;
4900         }
4901
4902
4903 /***/ }),
4904 /* 25 */
4905 /***/ (function(module, exports) {
4906
4907         /**
4908          * An abstraction for slicing an arraybuffer even when
4909          * ArrayBuffer.prototype.slice is not supported
4910          *
4911          * @api public
4912          */
4913         
4914         module.exports = function(arraybuffer, start, end) {
4915           var bytes = arraybuffer.byteLength;
4916           start = start || 0;
4917           end = end || bytes;
4918         
4919           if (arraybuffer.slice) { return arraybuffer.slice(start, end); }
4920         
4921           if (start < 0) { start += bytes; }
4922           if (end < 0) { end += bytes; }
4923           if (end > bytes) { end = bytes; }
4924         
4925           if (start >= bytes || start >= end || bytes === 0) {
4926             return new ArrayBuffer(0);
4927           }
4928         
4929           var abv = new Uint8Array(arraybuffer);
4930           var result = new Uint8Array(end - start);
4931           for (var i = start, ii = 0; i < end; i++, ii++) {
4932             result[ii] = abv[i];
4933           }
4934           return result.buffer;
4935         };
4936
4937
4938 /***/ }),
4939 /* 26 */
4940 /***/ (function(module, exports) {
4941
4942         module.exports = after
4943         
4944         function after(count, callback, err_cb) {
4945             var bail = false
4946             err_cb = err_cb || noop
4947             proxy.count = count
4948         
4949             return (count === 0) ? callback() : proxy
4950         
4951             function proxy(err, result) {
4952                 if (proxy.count <= 0) {
4953                     throw new Error('after called too many times')
4954                 }
4955                 --proxy.count
4956         
4957                 // after first error, rest are passed to err_cb
4958                 if (err) {
4959                     bail = true
4960                     callback(err)
4961                     // future error callbacks will go to error handler
4962                     callback = err_cb
4963                 } else if (proxy.count === 0 && !bail) {
4964                     callback(null, result)
4965                 }
4966             }
4967         }
4968         
4969         function noop() {}
4970
4971
4972 /***/ }),
4973 /* 27 */
4974 /***/ (function(module, exports) {
4975
4976         /*! https://mths.be/utf8js v2.1.2 by @mathias */
4977         
4978         var stringFromCharCode = String.fromCharCode;
4979         
4980         // Taken from https://mths.be/punycode
4981         function ucs2decode(string) {
4982                 var output = [];
4983                 var counter = 0;
4984                 var length = string.length;
4985                 var value;
4986                 var extra;
4987                 while (counter < length) {
4988                         value = string.charCodeAt(counter++);
4989                         if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
4990                                 // high surrogate, and there is a next character
4991                                 extra = string.charCodeAt(counter++);
4992                                 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
4993                                         output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
4994                                 } else {
4995                                         // unmatched surrogate; only append this code unit, in case the next
4996                                         // code unit is the high surrogate of a surrogate pair
4997                                         output.push(value);
4998                                         counter--;
4999                                 }
5000                         } else {
5001                                 output.push(value);
5002                         }
5003                 }
5004                 return output;
5005         }
5006         
5007         // Taken from https://mths.be/punycode
5008         function ucs2encode(array) {
5009                 var length = array.length;
5010                 var index = -1;
5011                 var value;
5012                 var output = '';
5013                 while (++index < length) {
5014                         value = array[index];
5015                         if (value > 0xFFFF) {
5016                                 value -= 0x10000;
5017                                 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
5018                                 value = 0xDC00 | value & 0x3FF;
5019                         }
5020                         output += stringFromCharCode(value);
5021                 }
5022                 return output;
5023         }
5024         
5025         function checkScalarValue(codePoint, strict) {
5026                 if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
5027                         if (strict) {
5028                                 throw Error(
5029                                         'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
5030                                         ' is not a scalar value'
5031                                 );
5032                         }
5033                         return false;
5034                 }
5035                 return true;
5036         }
5037         /*--------------------------------------------------------------------------*/
5038         
5039         function createByte(codePoint, shift) {
5040                 return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
5041         }
5042         
5043         function encodeCodePoint(codePoint, strict) {
5044                 if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
5045                         return stringFromCharCode(codePoint);
5046                 }
5047                 var symbol = '';
5048                 if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
5049                         symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
5050                 }
5051                 else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
5052                         if (!checkScalarValue(codePoint, strict)) {
5053                                 codePoint = 0xFFFD;
5054                         }
5055                         symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
5056                         symbol += createByte(codePoint, 6);
5057                 }
5058                 else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
5059                         symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
5060                         symbol += createByte(codePoint, 12);
5061                         symbol += createByte(codePoint, 6);
5062                 }
5063                 symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
5064                 return symbol;
5065         }
5066         
5067         function utf8encode(string, opts) {
5068                 opts = opts || {};
5069                 var strict = false !== opts.strict;
5070         
5071                 var codePoints = ucs2decode(string);
5072                 var length = codePoints.length;
5073                 var index = -1;
5074                 var codePoint;
5075                 var byteString = '';
5076                 while (++index < length) {
5077                         codePoint = codePoints[index];
5078                         byteString += encodeCodePoint(codePoint, strict);
5079                 }
5080                 return byteString;
5081         }
5082         
5083         /*--------------------------------------------------------------------------*/
5084         
5085         function readContinuationByte() {
5086                 if (byteIndex >= byteCount) {
5087                         throw Error('Invalid byte index');
5088                 }
5089         
5090                 var continuationByte = byteArray[byteIndex] & 0xFF;
5091                 byteIndex++;
5092         
5093                 if ((continuationByte & 0xC0) == 0x80) {
5094                         return continuationByte & 0x3F;
5095                 }
5096         
5097                 // If we end up here, it’s not a continuation byte
5098                 throw Error('Invalid continuation byte');
5099         }
5100         
5101         function decodeSymbol(strict) {
5102                 var byte1;
5103                 var byte2;
5104                 var byte3;
5105                 var byte4;
5106                 var codePoint;
5107         
5108                 if (byteIndex > byteCount) {
5109                         throw Error('Invalid byte index');
5110                 }
5111         
5112                 if (byteIndex == byteCount) {
5113                         return false;
5114                 }
5115         
5116                 // Read first byte
5117                 byte1 = byteArray[byteIndex] & 0xFF;
5118                 byteIndex++;
5119         
5120                 // 1-byte sequence (no continuation bytes)
5121                 if ((byte1 & 0x80) == 0) {
5122                         return byte1;
5123                 }
5124         
5125                 // 2-byte sequence
5126                 if ((byte1 & 0xE0) == 0xC0) {
5127                         byte2 = readContinuationByte();
5128                         codePoint = ((byte1 & 0x1F) << 6) | byte2;
5129                         if (codePoint >= 0x80) {
5130                                 return codePoint;
5131                         } else {
5132                                 throw Error('Invalid continuation byte');
5133                         }
5134                 }
5135         
5136                 // 3-byte sequence (may include unpaired surrogates)
5137                 if ((byte1 & 0xF0) == 0xE0) {
5138                         byte2 = readContinuationByte();
5139                         byte3 = readContinuationByte();
5140                         codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
5141                         if (codePoint >= 0x0800) {
5142                                 return checkScalarValue(codePoint, strict) ? codePoint : 0xFFFD;
5143                         } else {
5144                                 throw Error('Invalid continuation byte');
5145                         }
5146                 }
5147         
5148                 // 4-byte sequence
5149                 if ((byte1 & 0xF8) == 0xF0) {
5150                         byte2 = readContinuationByte();
5151                         byte3 = readContinuationByte();
5152                         byte4 = readContinuationByte();
5153                         codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
5154                                 (byte3 << 0x06) | byte4;
5155                         if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
5156                                 return codePoint;
5157                         }
5158                 }
5159         
5160                 throw Error('Invalid UTF-8 detected');
5161         }
5162         
5163         var byteArray;
5164         var byteCount;
5165         var byteIndex;
5166         function utf8decode(byteString, opts) {
5167                 opts = opts || {};
5168                 var strict = false !== opts.strict;
5169         
5170                 byteArray = ucs2decode(byteString);
5171                 byteCount = byteArray.length;
5172                 byteIndex = 0;
5173                 var codePoints = [];
5174                 var tmp;
5175                 while ((tmp = decodeSymbol(strict)) !== false) {
5176                         codePoints.push(tmp);
5177                 }
5178                 return ucs2encode(codePoints);
5179         }
5180         
5181         module.exports = {
5182                 version: '2.1.2',
5183                 encode: utf8encode,
5184                 decode: utf8decode
5185         };
5186
5187
5188 /***/ }),
5189 /* 28 */
5190 /***/ (function(module, exports) {
5191
5192         /*
5193          * base64-arraybuffer
5194          * https://github.com/niklasvh/base64-arraybuffer
5195          *
5196          * Copyright (c) 2012 Niklas von Hertzen
5197          * Licensed under the MIT license.
5198          */
5199         (function(chars){
5200           "use strict";
5201         
5202           exports.encode = function(arraybuffer) {
5203             var bytes = new Uint8Array(arraybuffer),
5204             i, len = bytes.length, base64 = "";
5205         
5206             for (i = 0; i < len; i+=3) {
5207               base64 += chars[bytes[i] >> 2];
5208               base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
5209               base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
5210               base64 += chars[bytes[i + 2] & 63];
5211             }
5212         
5213             if ((len % 3) === 2) {
5214               base64 = base64.substring(0, base64.length - 1) + "=";
5215             } else if (len % 3 === 1) {
5216               base64 = base64.substring(0, base64.length - 2) + "==";
5217             }
5218         
5219             return base64;
5220           };
5221         
5222           exports.decode =  function(base64) {
5223             var bufferLength = base64.length * 0.75,
5224             len = base64.length, i, p = 0,
5225             encoded1, encoded2, encoded3, encoded4;
5226         
5227             if (base64[base64.length - 1] === "=") {
5228               bufferLength--;
5229               if (base64[base64.length - 2] === "=") {
5230                 bufferLength--;
5231               }
5232             }
5233         
5234             var arraybuffer = new ArrayBuffer(bufferLength),
5235             bytes = new Uint8Array(arraybuffer);
5236         
5237             for (i = 0; i < len; i+=4) {
5238               encoded1 = chars.indexOf(base64[i]);
5239               encoded2 = chars.indexOf(base64[i+1]);
5240               encoded3 = chars.indexOf(base64[i+2]);
5241               encoded4 = chars.indexOf(base64[i+3]);
5242         
5243               bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
5244               bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
5245               bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
5246             }
5247         
5248             return arraybuffer;
5249           };
5250         })("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
5251
5252
5253 /***/ }),
5254 /* 29 */
5255 /***/ (function(module, exports) {
5256
5257         /**
5258          * Create a blob builder even when vendor prefixes exist
5259          */
5260         
5261         var BlobBuilder = typeof BlobBuilder !== 'undefined' ? BlobBuilder :
5262           typeof WebKitBlobBuilder !== 'undefined' ? WebKitBlobBuilder :
5263           typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder :
5264           typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : 
5265           false;
5266         
5267         /**
5268          * Check if Blob constructor is supported
5269          */
5270         
5271         var blobSupported = (function() {
5272           try {
5273             var a = new Blob(['hi']);
5274             return a.size === 2;
5275           } catch(e) {
5276             return false;
5277           }
5278         })();
5279         
5280         /**
5281          * Check if Blob constructor supports ArrayBufferViews
5282          * Fails in Safari 6, so we need to map to ArrayBuffers there.
5283          */
5284         
5285         var blobSupportsArrayBufferView = blobSupported && (function() {
5286           try {
5287             var b = new Blob([new Uint8Array([1,2])]);
5288             return b.size === 2;
5289           } catch(e) {
5290             return false;
5291           }
5292         })();
5293         
5294         /**
5295          * Check if BlobBuilder is supported
5296          */
5297         
5298         var blobBuilderSupported = BlobBuilder
5299           && BlobBuilder.prototype.append
5300           && BlobBuilder.prototype.getBlob;
5301         
5302         /**
5303          * Helper function that maps ArrayBufferViews to ArrayBuffers
5304          * Used by BlobBuilder constructor and old browsers that didn't
5305          * support it in the Blob constructor.
5306          */
5307         
5308         function mapArrayBufferViews(ary) {
5309           return ary.map(function(chunk) {
5310             if (chunk.buffer instanceof ArrayBuffer) {
5311               var buf = chunk.buffer;
5312         
5313               // if this is a subarray, make a copy so we only
5314               // include the subarray region from the underlying buffer
5315               if (chunk.byteLength !== buf.byteLength) {
5316                 var copy = new Uint8Array(chunk.byteLength);
5317                 copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength));
5318                 buf = copy.buffer;
5319               }
5320         
5321               return buf;
5322             }
5323         
5324             return chunk;
5325           });
5326         }
5327         
5328         function BlobBuilderConstructor(ary, options) {
5329           options = options || {};
5330         
5331           var bb = new BlobBuilder();
5332           mapArrayBufferViews(ary).forEach(function(part) {
5333             bb.append(part);
5334           });
5335         
5336           return (options.type) ? bb.getBlob(options.type) : bb.getBlob();
5337         };
5338         
5339         function BlobConstructor(ary, options) {
5340           return new Blob(mapArrayBufferViews(ary), options || {});
5341         };
5342         
5343         if (typeof Blob !== 'undefined') {
5344           BlobBuilderConstructor.prototype = Blob.prototype;
5345           BlobConstructor.prototype = Blob.prototype;
5346         }
5347         
5348         module.exports = (function() {
5349           if (blobSupported) {
5350             return blobSupportsArrayBufferView ? Blob : BlobConstructor;
5351           } else if (blobBuilderSupported) {
5352             return BlobBuilderConstructor;
5353           } else {
5354             return undefined;
5355           }
5356         })();
5357
5358
5359 /***/ }),
5360 /* 30 */
5361 /***/ (function(module, exports) {
5362
5363         /**
5364          * Compiles a querystring
5365          * Returns string representation of the object
5366          *
5367          * @param {Object}
5368          * @api private
5369          */
5370         
5371         exports.encode = function (obj) {
5372           var str = '';
5373         
5374           for (var i in obj) {
5375             if (obj.hasOwnProperty(i)) {
5376               if (str.length) str += '&';
5377               str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
5378             }
5379           }
5380         
5381           return str;
5382         };
5383         
5384         /**
5385          * Parses a simple querystring into an object
5386          *
5387          * @param {String} qs
5388          * @api private
5389          */
5390         
5391         exports.decode = function(qs){
5392           var qry = {};
5393           var pairs = qs.split('&');
5394           for (var i = 0, l = pairs.length; i < l; i++) {
5395             var pair = pairs[i].split('=');
5396             qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
5397           }
5398           return qry;
5399         };
5400
5401
5402 /***/ }),
5403 /* 31 */
5404 /***/ (function(module, exports) {
5405
5406         
5407         module.exports = function(a, b){
5408           var fn = function(){};
5409           fn.prototype = b.prototype;
5410           a.prototype = new fn;
5411           a.prototype.constructor = a;
5412         };
5413
5414 /***/ }),
5415 /* 32 */
5416 /***/ (function(module, exports) {
5417
5418         'use strict';
5419         
5420         var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('')
5421           , length = 64
5422           , map = {}
5423           , seed = 0
5424           , i = 0
5425           , prev;
5426         
5427         /**
5428          * Return a string representing the specified number.
5429          *
5430          * @param {Number} num The number to convert.
5431          * @returns {String} The string representation of the number.
5432          * @api public
5433          */
5434         function encode(num) {
5435           var encoded = '';
5436         
5437           do {
5438             encoded = alphabet[num % length] + encoded;
5439             num = Math.floor(num / length);
5440           } while (num > 0);
5441         
5442           return encoded;
5443         }
5444         
5445         /**
5446          * Return the integer value specified by the given string.
5447          *
5448          * @param {String} str The string to convert.
5449          * @returns {Number} The integer value represented by the string.
5450          * @api public
5451          */
5452         function decode(str) {
5453           var decoded = 0;
5454         
5455           for (i = 0; i < str.length; i++) {
5456             decoded = decoded * length + map[str.charAt(i)];
5457           }
5458         
5459           return decoded;
5460         }
5461         
5462         /**
5463          * Yeast: A tiny growing id generator.
5464          *
5465          * @returns {String} A unique id.
5466          * @api public
5467          */
5468         function yeast() {
5469           var now = encode(+new Date());
5470         
5471           if (now !== prev) return seed = 0, prev = now;
5472           return now +'.'+ encode(seed++);
5473         }
5474         
5475         //
5476         // Map each character to its index.
5477         //
5478         for (; i < length; i++) map[alphabet[i]] = i;
5479         
5480         //
5481         // Expose the `yeast`, `encode` and `decode` functions.
5482         //
5483         yeast.encode = encode;
5484         yeast.decode = decode;
5485         module.exports = yeast;
5486
5487
5488 /***/ }),
5489 /* 33 */
5490 /***/ (function(module, exports, __webpack_require__) {
5491
5492         /**
5493          * Module requirements.
5494          */
5495         
5496         var Polling = __webpack_require__(20);
5497         var inherit = __webpack_require__(31);
5498         var globalThis = __webpack_require__(18);
5499         
5500         /**
5501          * Module exports.
5502          */
5503         
5504         module.exports = JSONPPolling;
5505         
5506         /**
5507          * Cached regular expressions.
5508          */
5509         
5510         var rNewline = /\n/g;
5511         var rEscapedNewline = /\\n/g;
5512         
5513         /**
5514          * Global JSONP callbacks.
5515          */
5516         
5517         var callbacks;
5518         
5519         /**
5520          * Noop.
5521          */
5522         
5523         function empty () { }
5524         
5525         /**
5526          * JSONP Polling constructor.
5527          *
5528          * @param {Object} opts.
5529          * @api public
5530          */
5531         
5532         function JSONPPolling (opts) {
5533           Polling.call(this, opts);
5534         
5535           this.query = this.query || {};
5536         
5537           // define global callbacks array if not present
5538           // we do this here (lazily) to avoid unneeded global pollution
5539           if (!callbacks) {
5540             // we need to consider multiple engines in the same page
5541             callbacks = globalThis.___eio = (globalThis.___eio || []);
5542           }
5543         
5544           // callback identifier
5545           this.index = callbacks.length;
5546         
5547           // add callback to jsonp global
5548           var self = this;
5549           callbacks.push(function (msg) {
5550             self.onData(msg);
5551           });
5552         
5553           // append to query string
5554           this.query.j = this.index;
5555         
5556           // prevent spurious errors from being emitted when the window is unloaded
5557           if (typeof addEventListener === 'function') {
5558             addEventListener('beforeunload', function () {
5559               if (self.script) self.script.onerror = empty;
5560             }, false);
5561           }
5562         }
5563         
5564         /**
5565          * Inherits from Polling.
5566          */
5567         
5568         inherit(JSONPPolling, Polling);
5569         
5570         /*
5571          * JSONP only supports binary as base64 encoded strings
5572          */
5573         
5574         JSONPPolling.prototype.supportsBinary = false;
5575         
5576         /**
5577          * Closes the socket.
5578          *
5579          * @api private
5580          */
5581         
5582         JSONPPolling.prototype.doClose = function () {
5583           if (this.script) {
5584             this.script.parentNode.removeChild(this.script);
5585             this.script = null;
5586           }
5587         
5588           if (this.form) {
5589             this.form.parentNode.removeChild(this.form);
5590             this.form = null;
5591             this.iframe = null;
5592           }
5593         
5594           Polling.prototype.doClose.call(this);
5595         };
5596         
5597         /**
5598          * Starts a poll cycle.
5599          *
5600          * @api private
5601          */
5602         
5603         JSONPPolling.prototype.doPoll = function () {
5604           var self = this;
5605           var script = document.createElement('script');
5606         
5607           if (this.script) {
5608             this.script.parentNode.removeChild(this.script);
5609             this.script = null;
5610           }
5611         
5612           script.async = true;
5613           script.src = this.uri();
5614           script.onerror = function (e) {
5615             self.onError('jsonp poll error', e);
5616           };
5617         
5618           var insertAt = document.getElementsByTagName('script')[0];
5619           if (insertAt) {
5620             insertAt.parentNode.insertBefore(script, insertAt);
5621           } else {
5622             (document.head || document.body).appendChild(script);
5623           }
5624           this.script = script;
5625         
5626           var isUAgecko = 'undefined' !== typeof navigator && /gecko/i.test(navigator.userAgent);
5627         
5628           if (isUAgecko) {
5629             setTimeout(function () {
5630               var iframe = document.createElement('iframe');
5631               document.body.appendChild(iframe);
5632               document.body.removeChild(iframe);
5633             }, 100);
5634           }
5635         };
5636         
5637         /**
5638          * Writes with a hidden iframe.
5639          *
5640          * @param {String} data to send
5641          * @param {Function} called upon flush.
5642          * @api private
5643          */
5644         
5645         JSONPPolling.prototype.doWrite = function (data, fn) {
5646           var self = this;
5647         
5648           if (!this.form) {
5649             var form = document.createElement('form');
5650             var area = document.createElement('textarea');
5651             var id = this.iframeId = 'eio_iframe_' + this.index;
5652             var iframe;
5653         
5654             form.className = 'socketio';
5655             form.style.position = 'absolute';
5656             form.style.top = '-1000px';
5657             form.style.left = '-1000px';
5658             form.target = id;
5659             form.method = 'POST';
5660             form.setAttribute('accept-charset', 'utf-8');
5661             area.name = 'd';
5662             form.appendChild(area);
5663             document.body.appendChild(form);
5664         
5665             this.form = form;
5666             this.area = area;
5667           }
5668         
5669           this.form.action = this.uri();
5670         
5671           function complete () {
5672             initIframe();
5673             fn();
5674           }
5675         
5676           function initIframe () {
5677             if (self.iframe) {
5678               try {
5679                 self.form.removeChild(self.iframe);
5680               } catch (e) {
5681                 self.onError('jsonp polling iframe removal error', e);
5682               }
5683             }
5684         
5685             try {
5686               // ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
5687               var html = '<iframe src="javascript:0" name="' + self.iframeId + '">';
5688               iframe = document.createElement(html);
5689             } catch (e) {
5690               iframe = document.createElement('iframe');
5691               iframe.name = self.iframeId;
5692               iframe.src = 'javascript:0';
5693             }
5694         
5695             iframe.id = self.iframeId;
5696         
5697             self.form.appendChild(iframe);
5698             self.iframe = iframe;
5699           }
5700         
5701           initIframe();
5702         
5703           // escape \n to prevent it from being converted into \r\n by some UAs
5704           // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side
5705           data = data.replace(rEscapedNewline, '\\\n');
5706           this.area.value = data.replace(rNewline, '\\n');
5707         
5708           try {
5709             this.form.submit();
5710           } catch (e) {}
5711         
5712           if (this.iframe.attachEvent) {
5713             this.iframe.onreadystatechange = function () {
5714               if (self.iframe.readyState === 'complete') {
5715                 complete();
5716               }
5717             };
5718           } else {
5719             this.iframe.onload = complete;
5720           }
5721         };
5722
5723
5724 /***/ }),
5725 /* 34 */
5726 /***/ (function(module, exports, __webpack_require__) {
5727
5728         /**
5729          * Module dependencies.
5730          */
5731         
5732         var Transport = __webpack_require__(21);
5733         var parser = __webpack_require__(22);
5734         var parseqs = __webpack_require__(30);
5735         var inherit = __webpack_require__(31);
5736         var yeast = __webpack_require__(32);
5737         var debug = __webpack_require__(3)('engine.io-client:websocket');
5738         
5739         var BrowserWebSocket, NodeWebSocket;
5740         
5741         if (typeof WebSocket !== 'undefined') {
5742           BrowserWebSocket = WebSocket;
5743         } else if (typeof self !== 'undefined') {
5744           BrowserWebSocket = self.WebSocket || self.MozWebSocket;
5745         }
5746         
5747         if (typeof window === 'undefined') {
5748           try {
5749             NodeWebSocket = __webpack_require__(35);
5750           } catch (e) { }
5751         }
5752         
5753         /**
5754          * Get either the `WebSocket` or `MozWebSocket` globals
5755          * in the browser or try to resolve WebSocket-compatible
5756          * interface exposed by `ws` for Node-like environment.
5757          */
5758         
5759         var WebSocketImpl = BrowserWebSocket || NodeWebSocket;
5760         
5761         /**
5762          * Module exports.
5763          */
5764         
5765         module.exports = WS;
5766         
5767         /**
5768          * WebSocket transport constructor.
5769          *
5770          * @api {Object} connection options
5771          * @api public
5772          */
5773         
5774         function WS (opts) {
5775           var forceBase64 = (opts && opts.forceBase64);
5776           if (forceBase64) {
5777             this.supportsBinary = false;
5778           }
5779           this.perMessageDeflate = opts.perMessageDeflate;
5780           this.usingBrowserWebSocket = BrowserWebSocket && !opts.forceNode;
5781           this.protocols = opts.protocols;
5782           if (!this.usingBrowserWebSocket) {
5783             WebSocketImpl = NodeWebSocket;
5784           }
5785           Transport.call(this, opts);
5786         }
5787         
5788         /**
5789          * Inherits from Transport.
5790          */
5791         
5792         inherit(WS, Transport);
5793         
5794         /**
5795          * Transport name.
5796          *
5797          * @api public
5798          */
5799         
5800         WS.prototype.name = 'websocket';
5801         
5802         /*
5803          * WebSockets support binary
5804          */
5805         
5806         WS.prototype.supportsBinary = true;
5807         
5808         /**
5809          * Opens socket.
5810          *
5811          * @api private
5812          */
5813         
5814         WS.prototype.doOpen = function () {
5815           if (!this.check()) {
5816             // let probe timeout
5817             return;
5818           }
5819         
5820           var uri = this.uri();
5821           var protocols = this.protocols;
5822         
5823           var opts = {};
5824         
5825           if (!this.isReactNative) {
5826             opts.agent = this.agent;
5827             opts.perMessageDeflate = this.perMessageDeflate;
5828         
5829             // SSL options for Node.js client
5830             opts.pfx = this.pfx;
5831             opts.key = this.key;
5832             opts.passphrase = this.passphrase;
5833             opts.cert = this.cert;
5834             opts.ca = this.ca;
5835             opts.ciphers = this.ciphers;
5836             opts.rejectUnauthorized = this.rejectUnauthorized;
5837           }
5838         
5839           if (this.extraHeaders) {
5840             opts.headers = this.extraHeaders;
5841           }
5842           if (this.localAddress) {
5843             opts.localAddress = this.localAddress;
5844           }
5845         
5846           try {
5847             this.ws =
5848               this.usingBrowserWebSocket && !this.isReactNative
5849                 ? protocols
5850                   ? new WebSocketImpl(uri, protocols)
5851                   : new WebSocketImpl(uri)
5852                 : new WebSocketImpl(uri, protocols, opts);
5853           } catch (err) {
5854             return this.emit('error', err);
5855           }
5856         
5857           if (this.ws.binaryType === undefined) {
5858             this.supportsBinary = false;
5859           }
5860         
5861           if (this.ws.supports && this.ws.supports.binary) {
5862             this.supportsBinary = true;
5863             this.ws.binaryType = 'nodebuffer';
5864           } else {
5865             this.ws.binaryType = 'arraybuffer';
5866           }
5867         
5868           this.addEventListeners();
5869         };
5870         
5871         /**
5872          * Adds event listeners to the socket
5873          *
5874          * @api private
5875          */
5876         
5877         WS.prototype.addEventListeners = function () {
5878           var self = this;
5879         
5880           this.ws.onopen = function () {
5881             self.onOpen();
5882           };
5883           this.ws.onclose = function () {
5884             self.onClose();
5885           };
5886           this.ws.onmessage = function (ev) {
5887             self.onData(ev.data);
5888           };
5889           this.ws.onerror = function (e) {
5890             self.onError('websocket error', e);
5891           };
5892         };
5893         
5894         /**
5895          * Writes data to socket.
5896          *
5897          * @param {Array} array of packets.
5898          * @api private
5899          */
5900         
5901         WS.prototype.write = function (packets) {
5902           var self = this;
5903           this.writable = false;
5904         
5905           // encodePacket efficient as it uses WS framing
5906           // no need for encodePayload
5907           var total = packets.length;
5908           for (var i = 0, l = total; i < l; i++) {
5909             (function (packet) {
5910               parser.encodePacket(packet, self.supportsBinary, function (data) {
5911                 if (!self.usingBrowserWebSocket) {
5912                   // always create a new object (GH-437)
5913                   var opts = {};
5914                   if (packet.options) {
5915                     opts.compress = packet.options.compress;
5916                   }
5917         
5918                   if (self.perMessageDeflate) {
5919                     var len = 'string' === typeof data ? Buffer.byteLength(data) : data.length;
5920                     if (len < self.perMessageDeflate.threshold) {
5921                       opts.compress = false;
5922                     }
5923                   }
5924                 }
5925         
5926                 // Sometimes the websocket has already been closed but the browser didn't
5927                 // have a chance of informing us about it yet, in that case send will
5928                 // throw an error
5929                 try {
5930                   if (self.usingBrowserWebSocket) {
5931                     // TypeError is thrown when passing the second argument on Safari
5932                     self.ws.send(data);
5933                   } else {
5934                     self.ws.send(data, opts);
5935                   }
5936                 } catch (e) {
5937                   debug('websocket closed before onclose event');
5938                 }
5939         
5940                 --total || done();
5941               });
5942             })(packets[i]);
5943           }
5944         
5945           function done () {
5946             self.emit('flush');
5947         
5948             // fake drain
5949             // defer to next tick to allow Socket to clear writeBuffer
5950             setTimeout(function () {
5951               self.writable = true;
5952               self.emit('drain');
5953             }, 0);
5954           }
5955         };
5956         
5957         /**
5958          * Called upon close
5959          *
5960          * @api private
5961          */
5962         
5963         WS.prototype.onClose = function () {
5964           Transport.prototype.onClose.call(this);
5965         };
5966         
5967         /**
5968          * Closes socket.
5969          *
5970          * @api private
5971          */
5972         
5973         WS.prototype.doClose = function () {
5974           if (typeof this.ws !== 'undefined') {
5975             this.ws.close();
5976           }
5977         };
5978         
5979         /**
5980          * Generates uri for connection.
5981          *
5982          * @api private
5983          */
5984         
5985         WS.prototype.uri = function () {
5986           var query = this.query || {};
5987           var schema = this.secure ? 'wss' : 'ws';
5988           var port = '';
5989         
5990           // avoid port if default for schema
5991           if (this.port && (('wss' === schema && Number(this.port) !== 443) ||
5992             ('ws' === schema && Number(this.port) !== 80))) {
5993             port = ':' + this.port;
5994           }
5995         
5996           // append timestamp to URI
5997           if (this.timestampRequests) {
5998             query[this.timestampParam] = yeast();
5999           }
6000         
6001           // communicate binary support capabilities
6002           if (!this.supportsBinary) {
6003             query.b64 = 1;
6004           }
6005         
6006           query = parseqs.encode(query);
6007         
6008           // prepend ? to query
6009           if (query.length) {
6010             query = '?' + query;
6011           }
6012         
6013           var ipv6 = this.hostname.indexOf(':') !== -1;
6014           return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
6015         };
6016         
6017         /**
6018          * Feature detection for WebSocket.
6019          *
6020          * @return {Boolean} whether this transport is available.
6021          * @api public
6022          */
6023         
6024         WS.prototype.check = function () {
6025           return !!WebSocketImpl && !('__initialize' in WebSocketImpl && this.name === WS.prototype.name);
6026         };
6027
6028
6029 /***/ }),
6030 /* 35 */
6031 /***/ (function(module, exports) {
6032
6033         /* (ignored) */
6034
6035 /***/ }),
6036 /* 36 */
6037 /***/ (function(module, exports) {
6038
6039         
6040         var indexOf = [].indexOf;
6041         
6042         module.exports = function(arr, obj){
6043           if (indexOf) return arr.indexOf(obj);
6044           for (var i = 0; i < arr.length; ++i) {
6045             if (arr[i] === obj) return i;
6046           }
6047           return -1;
6048         };
6049
6050 /***/ }),
6051 /* 37 */
6052 /***/ (function(module, exports, __webpack_require__) {
6053
6054         
6055         /**
6056          * Module dependencies.
6057          */
6058         
6059         var parser = __webpack_require__(7);
6060         var Emitter = __webpack_require__(8);
6061         var toArray = __webpack_require__(38);
6062         var on = __webpack_require__(39);
6063         var bind = __webpack_require__(40);
6064         var debug = __webpack_require__(3)('socket.io-client:socket');
6065         var parseqs = __webpack_require__(30);
6066         var hasBin = __webpack_require__(24);
6067         
6068         /**
6069          * Module exports.
6070          */
6071         
6072         module.exports = exports = Socket;
6073         
6074         /**
6075          * Internal events (blacklisted).
6076          * These events can't be emitted by the user.
6077          *
6078          * @api private
6079          */
6080         
6081         var events = {
6082           connect: 1,
6083           connect_error: 1,
6084           connect_timeout: 1,
6085           connecting: 1,
6086           disconnect: 1,
6087           error: 1,
6088           reconnect: 1,
6089           reconnect_attempt: 1,
6090           reconnect_failed: 1,
6091           reconnect_error: 1,
6092           reconnecting: 1,
6093           ping: 1,
6094           pong: 1
6095         };
6096         
6097         /**
6098          * Shortcut to `Emitter#emit`.
6099          */
6100         
6101         var emit = Emitter.prototype.emit;
6102         
6103         /**
6104          * `Socket` constructor.
6105          *
6106          * @api public
6107          */
6108         
6109         function Socket (io, nsp, opts) {
6110           this.io = io;
6111           this.nsp = nsp;
6112           this.json = this; // compat
6113           this.ids = 0;
6114           this.acks = {};
6115           this.receiveBuffer = [];
6116           this.sendBuffer = [];
6117           this.connected = false;
6118           this.disconnected = true;
6119           this.flags = {};
6120           if (opts && opts.query) {
6121             this.query = opts.query;
6122           }
6123           if (this.io.autoConnect) this.open();
6124         }
6125         
6126         /**
6127          * Mix in `Emitter`.
6128          */
6129         
6130         Emitter(Socket.prototype);
6131         
6132         /**
6133          * Subscribe to open, close and packet events
6134          *
6135          * @api private
6136          */
6137         
6138         Socket.prototype.subEvents = function () {
6139           if (this.subs) return;
6140         
6141           var io = this.io;
6142           this.subs = [
6143             on(io, 'open', bind(this, 'onopen')),
6144             on(io, 'packet', bind(this, 'onpacket')),
6145             on(io, 'close', bind(this, 'onclose'))
6146           ];
6147         };
6148         
6149         /**
6150          * "Opens" the socket.
6151          *
6152          * @api public
6153          */
6154         
6155         Socket.prototype.open =
6156         Socket.prototype.connect = function () {
6157           if (this.connected) return this;
6158         
6159           this.subEvents();
6160           if (!this.io.reconnecting) this.io.open(); // ensure open
6161           if ('open' === this.io.readyState) this.onopen();
6162           this.emit('connecting');
6163           return this;
6164         };
6165         
6166         /**
6167          * Sends a `message` event.
6168          *
6169          * @return {Socket} self
6170          * @api public
6171          */
6172         
6173         Socket.prototype.send = function () {
6174           var args = toArray(arguments);
6175           args.unshift('message');
6176           this.emit.apply(this, args);
6177           return this;
6178         };
6179         
6180         /**
6181          * Override `emit`.
6182          * If the event is in `events`, it's emitted normally.
6183          *
6184          * @param {String} event name
6185          * @return {Socket} self
6186          * @api public
6187          */
6188         
6189         Socket.prototype.emit = function (ev) {
6190           if (events.hasOwnProperty(ev)) {
6191             emit.apply(this, arguments);
6192             return this;
6193           }
6194         
6195           var args = toArray(arguments);
6196           var packet = {
6197             type: (this.flags.binary !== undefined ? this.flags.binary : hasBin(args)) ? parser.BINARY_EVENT : parser.EVENT,
6198             data: args
6199           };
6200         
6201           packet.options = {};
6202           packet.options.compress = !this.flags || false !== this.flags.compress;
6203         
6204           // event ack callback
6205           if ('function' === typeof args[args.length - 1]) {
6206             debug('emitting packet with ack id %d', this.ids);
6207             this.acks[this.ids] = args.pop();
6208             packet.id = this.ids++;
6209           }
6210         
6211           if (this.connected) {
6212             this.packet(packet);
6213           } else {
6214             this.sendBuffer.push(packet);
6215           }
6216         
6217           this.flags = {};
6218         
6219           return this;
6220         };
6221         
6222         /**
6223          * Sends a packet.
6224          *
6225          * @param {Object} packet
6226          * @api private
6227          */
6228         
6229         Socket.prototype.packet = function (packet) {
6230           packet.nsp = this.nsp;
6231           this.io.packet(packet);
6232         };
6233         
6234         /**
6235          * Called upon engine `open`.
6236          *
6237          * @api private
6238          */
6239         
6240         Socket.prototype.onopen = function () {
6241           debug('transport is open - connecting');
6242         
6243           // write connect packet if necessary
6244           if ('/' !== this.nsp) {
6245             if (this.query) {
6246               var query = typeof this.query === 'object' ? parseqs.encode(this.query) : this.query;
6247               debug('sending connect packet with query %s', query);
6248               this.packet({type: parser.CONNECT, query: query});
6249             } else {
6250               this.packet({type: parser.CONNECT});
6251             }
6252           }
6253         };
6254         
6255         /**
6256          * Called upon engine `close`.
6257          *
6258          * @param {String} reason
6259          * @api private
6260          */
6261         
6262         Socket.prototype.onclose = function (reason) {
6263           debug('close (%s)', reason);
6264           this.connected = false;
6265           this.disconnected = true;
6266           delete this.id;
6267           this.emit('disconnect', reason);
6268         };
6269         
6270         /**
6271          * Called with socket packet.
6272          *
6273          * @param {Object} packet
6274          * @api private
6275          */
6276         
6277         Socket.prototype.onpacket = function (packet) {
6278           var sameNamespace = packet.nsp === this.nsp;
6279           var rootNamespaceError = packet.type === parser.ERROR && packet.nsp === '/';
6280         
6281           if (!sameNamespace && !rootNamespaceError) return;
6282         
6283           switch (packet.type) {
6284             case parser.CONNECT:
6285               this.onconnect();
6286               break;
6287         
6288             case parser.EVENT:
6289               this.onevent(packet);
6290               break;
6291         
6292             case parser.BINARY_EVENT:
6293               this.onevent(packet);
6294               break;
6295         
6296             case parser.ACK:
6297               this.onack(packet);
6298               break;
6299         
6300             case parser.BINARY_ACK:
6301               this.onack(packet);
6302               break;
6303         
6304             case parser.DISCONNECT:
6305               this.ondisconnect();
6306               break;
6307         
6308             case parser.ERROR:
6309               this.emit('error', packet.data);
6310               break;
6311           }
6312         };
6313         
6314         /**
6315          * Called upon a server event.
6316          *
6317          * @param {Object} packet
6318          * @api private
6319          */
6320         
6321         Socket.prototype.onevent = function (packet) {
6322           var args = packet.data || [];
6323           debug('emitting event %j', args);
6324         
6325           if (null != packet.id) {
6326             debug('attaching ack callback to event');
6327             args.push(this.ack(packet.id));
6328           }
6329         
6330           if (this.connected) {
6331             emit.apply(this, args);
6332           } else {
6333             this.receiveBuffer.push(args);
6334           }
6335         };
6336         
6337         /**
6338          * Produces an ack callback to emit with an event.
6339          *
6340          * @api private
6341          */
6342         
6343         Socket.prototype.ack = function (id) {
6344           var self = this;
6345           var sent = false;
6346           return function () {
6347             // prevent double callbacks
6348             if (sent) return;
6349             sent = true;
6350             var args = toArray(arguments);
6351             debug('sending ack %j', args);
6352         
6353             self.packet({
6354               type: hasBin(args) ? parser.BINARY_ACK : parser.ACK,
6355               id: id,
6356               data: args
6357             });
6358           };
6359         };
6360         
6361         /**
6362          * Called upon a server acknowlegement.
6363          *
6364          * @param {Object} packet
6365          * @api private
6366          */
6367         
6368         Socket.prototype.onack = function (packet) {
6369           var ack = this.acks[packet.id];
6370           if ('function' === typeof ack) {
6371             debug('calling ack %s with %j', packet.id, packet.data);
6372             ack.apply(this, packet.data);
6373             delete this.acks[packet.id];
6374           } else {
6375             debug('bad ack %s', packet.id);
6376           }
6377         };
6378         
6379         /**
6380          * Called upon server connect.
6381          *
6382          * @api private
6383          */
6384         
6385         Socket.prototype.onconnect = function () {
6386           this.connected = true;
6387           this.disconnected = false;
6388           this.emit('connect');
6389           this.emitBuffered();
6390         };
6391         
6392         /**
6393          * Emit buffered events (received and emitted).
6394          *
6395          * @api private
6396          */
6397         
6398         Socket.prototype.emitBuffered = function () {
6399           var i;
6400           for (i = 0; i < this.receiveBuffer.length; i++) {
6401             emit.apply(this, this.receiveBuffer[i]);
6402           }
6403           this.receiveBuffer = [];
6404         
6405           for (i = 0; i < this.sendBuffer.length; i++) {
6406             this.packet(this.sendBuffer[i]);
6407           }
6408           this.sendBuffer = [];
6409         };
6410         
6411         /**
6412          * Called upon server disconnect.
6413          *
6414          * @api private
6415          */
6416         
6417         Socket.prototype.ondisconnect = function () {
6418           debug('server disconnect (%s)', this.nsp);
6419           this.destroy();
6420           this.onclose('io server disconnect');
6421         };
6422         
6423         /**
6424          * Called upon forced client/server side disconnections,
6425          * this method ensures the manager stops tracking us and
6426          * that reconnections don't get triggered for this.
6427          *
6428          * @api private.
6429          */
6430         
6431         Socket.prototype.destroy = function () {
6432           if (this.subs) {
6433             // clean subscriptions to avoid reconnections
6434             for (var i = 0; i < this.subs.length; i++) {
6435               this.subs[i].destroy();
6436             }
6437             this.subs = null;
6438           }
6439         
6440           this.io.destroy(this);
6441         };
6442         
6443         /**
6444          * Disconnects the socket manually.
6445          *
6446          * @return {Socket} self
6447          * @api public
6448          */
6449         
6450         Socket.prototype.close =
6451         Socket.prototype.disconnect = function () {
6452           if (this.connected) {
6453             debug('performing disconnect (%s)', this.nsp);
6454             this.packet({ type: parser.DISCONNECT });
6455           }
6456         
6457           // remove socket from pool
6458           this.destroy();
6459         
6460           if (this.connected) {
6461             // fire events
6462             this.onclose('io client disconnect');
6463           }
6464           return this;
6465         };
6466         
6467         /**
6468          * Sets the compress flag.
6469          *
6470          * @param {Boolean} if `true`, compresses the sending data
6471          * @return {Socket} self
6472          * @api public
6473          */
6474         
6475         Socket.prototype.compress = function (compress) {
6476           this.flags.compress = compress;
6477           return this;
6478         };
6479         
6480         /**
6481          * Sets the binary flag
6482          *
6483          * @param {Boolean} whether the emitted data contains binary
6484          * @return {Socket} self
6485          * @api public
6486          */
6487         
6488         Socket.prototype.binary = function (binary) {
6489           this.flags.binary = binary;
6490           return this;
6491         };
6492
6493
6494 /***/ }),
6495 /* 38 */
6496 /***/ (function(module, exports) {
6497
6498         module.exports = toArray
6499         
6500         function toArray(list, index) {
6501             var array = []
6502         
6503             index = index || 0
6504         
6505             for (var i = index || 0; i < list.length; i++) {
6506                 array[i - index] = list[i]
6507             }
6508         
6509             return array
6510         }
6511
6512
6513 /***/ }),
6514 /* 39 */
6515 /***/ (function(module, exports) {
6516
6517         
6518         /**
6519          * Module exports.
6520          */
6521         
6522         module.exports = on;
6523         
6524         /**
6525          * Helper for subscriptions.
6526          *
6527          * @param {Object|EventEmitter} obj with `Emitter` mixin or `EventEmitter`
6528          * @param {String} event name
6529          * @param {Function} callback
6530          * @api public
6531          */
6532         
6533         function on (obj, ev, fn) {
6534           obj.on(ev, fn);
6535           return {
6536             destroy: function () {
6537               obj.removeListener(ev, fn);
6538             }
6539           };
6540         }
6541
6542
6543 /***/ }),
6544 /* 40 */
6545 /***/ (function(module, exports) {
6546
6547         /**
6548          * Slice reference.
6549          */
6550         
6551         var slice = [].slice;
6552         
6553         /**
6554          * Bind `obj` to `fn`.
6555          *
6556          * @param {Object} obj
6557          * @param {Function|String} fn or string
6558          * @return {Function}
6559          * @api public
6560          */
6561         
6562         module.exports = function(obj, fn){
6563           if ('string' == typeof fn) fn = obj[fn];
6564           if ('function' != typeof fn) throw new Error('bind() requires a function');
6565           var args = slice.call(arguments, 2);
6566           return function(){
6567             return fn.apply(obj, args.concat(slice.call(arguments)));
6568           }
6569         };
6570
6571
6572 /***/ }),
6573 /* 41 */
6574 /***/ (function(module, exports) {
6575
6576         
6577         /**
6578          * Expose `Backoff`.
6579          */
6580         
6581         module.exports = Backoff;
6582         
6583         /**
6584          * Initialize backoff timer with `opts`.
6585          *
6586          * - `min` initial timeout in milliseconds [100]
6587          * - `max` max timeout [10000]
6588          * - `jitter` [0]
6589          * - `factor` [2]
6590          *
6591          * @param {Object} opts
6592          * @api public
6593          */
6594         
6595         function Backoff(opts) {
6596           opts = opts || {};
6597           this.ms = opts.min || 100;
6598           this.max = opts.max || 10000;
6599           this.factor = opts.factor || 2;
6600           this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
6601           this.attempts = 0;
6602         }
6603         
6604         /**
6605          * Return the backoff duration.
6606          *
6607          * @return {Number}
6608          * @api public
6609          */
6610         
6611         Backoff.prototype.duration = function(){
6612           var ms = this.ms * Math.pow(this.factor, this.attempts++);
6613           if (this.jitter) {
6614             var rand =  Math.random();
6615             var deviation = Math.floor(rand * this.jitter * ms);
6616             ms = (Math.floor(rand * 10) & 1) == 0  ? ms - deviation : ms + deviation;
6617           }
6618           return Math.min(ms, this.max) | 0;
6619         };
6620         
6621         /**
6622          * Reset the number of attempts.
6623          *
6624          * @api public
6625          */
6626         
6627         Backoff.prototype.reset = function(){
6628           this.attempts = 0;
6629         };
6630         
6631         /**
6632          * Set the minimum duration
6633          *
6634          * @api public
6635          */
6636         
6637         Backoff.prototype.setMin = function(min){
6638           this.ms = min;
6639         };
6640         
6641         /**
6642          * Set the maximum duration
6643          *
6644          * @api public
6645          */
6646         
6647         Backoff.prototype.setMax = function(max){
6648           this.max = max;
6649         };
6650         
6651         /**
6652          * Set the jitter
6653          *
6654          * @api public
6655          */
6656         
6657         Backoff.prototype.setJitter = function(jitter){
6658           this.jitter = jitter;
6659         };
6660         
6661
6662
6663 /***/ })
6664 /******/ ])
6665 });
6666 ;
6667 //# sourceMappingURL=socket.io.dev.js.map