{"ast":null,"code":"/* sockjs-client v1.5.2 | http://sockjs.org | MIT license */\n(function (f) {\n if (typeof exports === \"object\" && typeof module !== \"undefined\") {\n module.exports = f();\n } else if (typeof define === \"function\" && define.amd) {\n define([], f);\n } else {\n var g;\n\n if (typeof window !== \"undefined\") {\n g = window;\n } else if (typeof global !== \"undefined\") {\n g = global;\n } else if (typeof self !== \"undefined\") {\n g = self;\n } else {\n g = this;\n }\n\n g.SockJS = f();\n }\n})(function () {\n var define, module, exports;\n return function () {\n function r(e, n, t) {\n function o(i, f) {\n if (!n[i]) {\n if (!e[i]) {\n var c = \"function\" == typeof require && require;\n if (!f && c) return c(i, !0);\n if (u) return u(i, !0);\n var a = new Error(\"Cannot find module '\" + i + \"'\");\n throw a.code = \"MODULE_NOT_FOUND\", a;\n }\n\n var p = n[i] = {\n exports: {}\n };\n e[i][0].call(p.exports, function (r) {\n var n = e[i][1][r];\n return o(n || r);\n }, p, p.exports, r, e, n, t);\n }\n\n return n[i].exports;\n }\n\n for (var u = \"function\" == typeof require && require, i = 0; i < t.length; i++) o(t[i]);\n\n return o;\n }\n\n return r;\n }()({\n 1: [function (require, module, exports) {\n (function (global) {\n 'use strict';\n\n var transportList = require('./transport-list');\n\n module.exports = require('./main')(transportList); // TODO can't get rid of this until all servers do\n\n if ('_sockjs_onload' in global) {\n setTimeout(global._sockjs_onload, 1);\n }\n }).call(this, typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {});\n }, {\n \"./main\": 14,\n \"./transport-list\": 16\n }],\n 2: [function (require, module, exports) {\n 'use strict';\n\n var inherits = require('inherits'),\n Event = require('./event');\n\n function CloseEvent() {\n Event.call(this);\n this.initEvent('close', false, false);\n this.wasClean = false;\n this.code = 0;\n this.reason = '';\n }\n\n inherits(CloseEvent, Event);\n module.exports = CloseEvent;\n }, {\n \"./event\": 4,\n \"inherits\": 57\n }],\n 3: [function (require, module, exports) {\n 'use strict';\n\n var inherits = require('inherits'),\n EventTarget = require('./eventtarget');\n\n function EventEmitter() {\n EventTarget.call(this);\n }\n\n inherits(EventEmitter, EventTarget);\n\n EventEmitter.prototype.removeAllListeners = function (type) {\n if (type) {\n delete this._listeners[type];\n } else {\n this._listeners = {};\n }\n };\n\n EventEmitter.prototype.once = function (type, listener) {\n var self = this,\n fired = false;\n\n function g() {\n self.removeListener(type, g);\n\n if (!fired) {\n fired = true;\n listener.apply(this, arguments);\n }\n }\n\n this.on(type, g);\n };\n\n EventEmitter.prototype.emit = function () {\n var type = arguments[0];\n var listeners = this._listeners[type];\n\n if (!listeners) {\n return;\n } // equivalent of Array.prototype.slice.call(arguments, 1);\n\n\n var l = arguments.length;\n var args = new Array(l - 1);\n\n for (var ai = 1; ai < l; ai++) {\n args[ai - 1] = arguments[ai];\n }\n\n for (var i = 0; i < listeners.length; i++) {\n listeners[i].apply(this, args);\n }\n };\n\n EventEmitter.prototype.on = EventEmitter.prototype.addListener = EventTarget.prototype.addEventListener;\n EventEmitter.prototype.removeListener = EventTarget.prototype.removeEventListener;\n module.exports.EventEmitter = EventEmitter;\n }, {\n \"./eventtarget\": 5,\n \"inherits\": 57\n }],\n 4: [function (require, module, exports) {\n 'use strict';\n\n function Event(eventType) {\n this.type = eventType;\n }\n\n Event.prototype.initEvent = function (eventType, canBubble, cancelable) {\n this.type = eventType;\n this.bubbles = canBubble;\n this.cancelable = cancelable;\n this.timeStamp = +new Date();\n return this;\n };\n\n Event.prototype.stopPropagation = function () {};\n\n Event.prototype.preventDefault = function () {};\n\n Event.CAPTURING_PHASE = 1;\n Event.AT_TARGET = 2;\n Event.BUBBLING_PHASE = 3;\n module.exports = Event;\n }, {}],\n 5: [function (require, module, exports) {\n 'use strict';\n /* Simplified implementation of DOM2 EventTarget.\n * http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget\n */\n\n function EventTarget() {\n this._listeners = {};\n }\n\n EventTarget.prototype.addEventListener = function (eventType, listener) {\n if (!(eventType in this._listeners)) {\n this._listeners[eventType] = [];\n }\n\n var arr = this._listeners[eventType]; // #4\n\n if (arr.indexOf(listener) === -1) {\n // Make a copy so as not to interfere with a current dispatchEvent.\n arr = arr.concat([listener]);\n }\n\n this._listeners[eventType] = arr;\n };\n\n EventTarget.prototype.removeEventListener = function (eventType, listener) {\n var arr = this._listeners[eventType];\n\n if (!arr) {\n return;\n }\n\n var idx = arr.indexOf(listener);\n\n if (idx !== -1) {\n if (arr.length > 1) {\n // Make a copy so as not to interfere with a current dispatchEvent.\n this._listeners[eventType] = arr.slice(0, idx).concat(arr.slice(idx + 1));\n } else {\n delete this._listeners[eventType];\n }\n\n return;\n }\n };\n\n EventTarget.prototype.dispatchEvent = function () {\n var event = arguments[0];\n var t = event.type; // equivalent of Array.prototype.slice.call(arguments, 0);\n\n var args = arguments.length === 1 ? [event] : Array.apply(null, arguments); // TODO: This doesn't match the real behavior; per spec, onfoo get\n // their place in line from the /first/ time they're set from\n // non-null. Although WebKit bumps it to the end every time it's\n // set.\n\n if (this['on' + t]) {\n this['on' + t].apply(this, args);\n }\n\n if (t in this._listeners) {\n // Grab a reference to the listeners list. removeEventListener may alter the list.\n var listeners = this._listeners[t];\n\n for (var i = 0; i < listeners.length; i++) {\n listeners[i].apply(this, args);\n }\n }\n };\n\n module.exports = EventTarget;\n }, {}],\n 6: [function (require, module, exports) {\n 'use strict';\n\n var inherits = require('inherits'),\n Event = require('./event');\n\n function TransportMessageEvent(data) {\n Event.call(this);\n this.initEvent('message', false, false);\n this.data = data;\n }\n\n inherits(TransportMessageEvent, Event);\n module.exports = TransportMessageEvent;\n }, {\n \"./event\": 4,\n \"inherits\": 57\n }],\n 7: [function (require, module, exports) {\n 'use strict';\n\n var JSON3 = require('json3'),\n iframeUtils = require('./utils/iframe');\n\n function FacadeJS(transport) {\n this._transport = transport;\n transport.on('message', this._transportMessage.bind(this));\n transport.on('close', this._transportClose.bind(this));\n }\n\n FacadeJS.prototype._transportClose = function (code, reason) {\n iframeUtils.postMessage('c', JSON3.stringify([code, reason]));\n };\n\n FacadeJS.prototype._transportMessage = function (frame) {\n iframeUtils.postMessage('t', frame);\n };\n\n FacadeJS.prototype._send = function (data) {\n this._transport.send(data);\n };\n\n FacadeJS.prototype._close = function () {\n this._transport.close();\n\n this._transport.removeAllListeners();\n };\n\n module.exports = FacadeJS;\n }, {\n \"./utils/iframe\": 47,\n \"json3\": 58\n }],\n 8: [function (require, module, exports) {\n (function (process) {\n 'use strict';\n\n var urlUtils = require('./utils/url'),\n eventUtils = require('./utils/event'),\n JSON3 = require('json3'),\n FacadeJS = require('./facade'),\n InfoIframeReceiver = require('./info-iframe-receiver'),\n iframeUtils = require('./utils/iframe'),\n loc = require('./location');\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:iframe-bootstrap');\n }\n\n module.exports = function (SockJS, availableTransports) {\n var transportMap = {};\n availableTransports.forEach(function (at) {\n if (at.facadeTransport) {\n transportMap[at.facadeTransport.transportName] = at.facadeTransport;\n }\n }); // hard-coded for the info iframe\n // TODO see if we can make this more dynamic\n\n transportMap[InfoIframeReceiver.transportName] = InfoIframeReceiver;\n var parentOrigin;\n /* eslint-disable camelcase */\n\n SockJS.bootstrap_iframe = function () {\n /* eslint-enable camelcase */\n var facade;\n iframeUtils.currentWindowId = loc.hash.slice(1);\n\n var onMessage = function (e) {\n if (e.source !== parent) {\n return;\n }\n\n if (typeof parentOrigin === 'undefined') {\n parentOrigin = e.origin;\n }\n\n if (e.origin !== parentOrigin) {\n return;\n }\n\n var iframeMessage;\n\n try {\n iframeMessage = JSON3.parse(e.data);\n } catch (ignored) {\n debug('bad json', e.data);\n return;\n }\n\n if (iframeMessage.windowId !== iframeUtils.currentWindowId) {\n return;\n }\n\n switch (iframeMessage.type) {\n case 's':\n var p;\n\n try {\n p = JSON3.parse(iframeMessage.data);\n } catch (ignored) {\n debug('bad json', iframeMessage.data);\n break;\n }\n\n var version = p[0];\n var transport = p[1];\n var transUrl = p[2];\n var baseUrl = p[3];\n debug(version, transport, transUrl, baseUrl); // change this to semver logic\n\n if (version !== SockJS.version) {\n throw new Error('Incompatible SockJS! Main site uses:' + ' \"' + version + '\", the iframe:' + ' \"' + SockJS.version + '\".');\n }\n\n if (!urlUtils.isOriginEqual(transUrl, loc.href) || !urlUtils.isOriginEqual(baseUrl, loc.href)) {\n throw new Error('Can\\'t connect to different domain from within an ' + 'iframe. (' + loc.href + ', ' + transUrl + ', ' + baseUrl + ')');\n }\n\n facade = new FacadeJS(new transportMap[transport](transUrl, baseUrl));\n break;\n\n case 'm':\n facade._send(iframeMessage.data);\n\n break;\n\n case 'c':\n if (facade) {\n facade._close();\n }\n\n facade = null;\n break;\n }\n };\n\n eventUtils.attachEvent('message', onMessage); // Start\n\n iframeUtils.postMessage('s');\n };\n };\n }).call(this, {\n env: {}\n });\n }, {\n \"./facade\": 7,\n \"./info-iframe-receiver\": 10,\n \"./location\": 13,\n \"./utils/event\": 46,\n \"./utils/iframe\": 47,\n \"./utils/url\": 52,\n \"debug\": 55,\n \"json3\": 58\n }],\n 9: [function (require, module, exports) {\n (function (process) {\n 'use strict';\n\n var EventEmitter = require('events').EventEmitter,\n inherits = require('inherits'),\n JSON3 = require('json3'),\n objectUtils = require('./utils/object');\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:info-ajax');\n }\n\n function InfoAjax(url, AjaxObject) {\n EventEmitter.call(this);\n var self = this;\n var t0 = +new Date();\n this.xo = new AjaxObject('GET', url);\n this.xo.once('finish', function (status, text) {\n var info, rtt;\n\n if (status === 200) {\n rtt = +new Date() - t0;\n\n if (text) {\n try {\n info = JSON3.parse(text);\n } catch (e) {\n debug('bad json', text);\n }\n }\n\n if (!objectUtils.isObject(info)) {\n info = {};\n }\n }\n\n self.emit('finish', info, rtt);\n self.removeAllListeners();\n });\n }\n\n inherits(InfoAjax, EventEmitter);\n\n InfoAjax.prototype.close = function () {\n this.removeAllListeners();\n this.xo.close();\n };\n\n module.exports = InfoAjax;\n }).call(this, {\n env: {}\n });\n }, {\n \"./utils/object\": 49,\n \"debug\": 55,\n \"events\": 3,\n \"inherits\": 57,\n \"json3\": 58\n }],\n 10: [function (require, module, exports) {\n 'use strict';\n\n var inherits = require('inherits'),\n EventEmitter = require('events').EventEmitter,\n JSON3 = require('json3'),\n XHRLocalObject = require('./transport/sender/xhr-local'),\n InfoAjax = require('./info-ajax');\n\n function InfoReceiverIframe(transUrl) {\n var self = this;\n EventEmitter.call(this);\n this.ir = new InfoAjax(transUrl, XHRLocalObject);\n this.ir.once('finish', function (info, rtt) {\n self.ir = null;\n self.emit('message', JSON3.stringify([info, rtt]));\n });\n }\n\n inherits(InfoReceiverIframe, EventEmitter);\n InfoReceiverIframe.transportName = 'iframe-info-receiver';\n\n InfoReceiverIframe.prototype.close = function () {\n if (this.ir) {\n this.ir.close();\n this.ir = null;\n }\n\n this.removeAllListeners();\n };\n\n module.exports = InfoReceiverIframe;\n }, {\n \"./info-ajax\": 9,\n \"./transport/sender/xhr-local\": 37,\n \"events\": 3,\n \"inherits\": 57,\n \"json3\": 58\n }],\n 11: [function (require, module, exports) {\n (function (process, global) {\n 'use strict';\n\n var EventEmitter = require('events').EventEmitter,\n inherits = require('inherits'),\n JSON3 = require('json3'),\n utils = require('./utils/event'),\n IframeTransport = require('./transport/iframe'),\n InfoReceiverIframe = require('./info-iframe-receiver');\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:info-iframe');\n }\n\n function InfoIframe(baseUrl, url) {\n var self = this;\n EventEmitter.call(this);\n\n var go = function () {\n var ifr = self.ifr = new IframeTransport(InfoReceiverIframe.transportName, url, baseUrl);\n ifr.once('message', function (msg) {\n if (msg) {\n var d;\n\n try {\n d = JSON3.parse(msg);\n } catch (e) {\n debug('bad json', msg);\n self.emit('finish');\n self.close();\n return;\n }\n\n var info = d[0],\n rtt = d[1];\n self.emit('finish', info, rtt);\n }\n\n self.close();\n });\n ifr.once('close', function () {\n self.emit('finish');\n self.close();\n });\n }; // TODO this seems the same as the 'needBody' from transports\n\n\n if (!global.document.body) {\n utils.attachEvent('load', go);\n } else {\n go();\n }\n }\n\n inherits(InfoIframe, EventEmitter);\n\n InfoIframe.enabled = function () {\n return IframeTransport.enabled();\n };\n\n InfoIframe.prototype.close = function () {\n if (this.ifr) {\n this.ifr.close();\n }\n\n this.removeAllListeners();\n this.ifr = null;\n };\n\n module.exports = InfoIframe;\n }).call(this, {\n env: {}\n }, typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {});\n }, {\n \"./info-iframe-receiver\": 10,\n \"./transport/iframe\": 22,\n \"./utils/event\": 46,\n \"debug\": 55,\n \"events\": 3,\n \"inherits\": 57,\n \"json3\": 58\n }],\n 12: [function (require, module, exports) {\n (function (process) {\n 'use strict';\n\n var EventEmitter = require('events').EventEmitter,\n inherits = require('inherits'),\n urlUtils = require('./utils/url'),\n XDR = require('./transport/sender/xdr'),\n XHRCors = require('./transport/sender/xhr-cors'),\n XHRLocal = require('./transport/sender/xhr-local'),\n XHRFake = require('./transport/sender/xhr-fake'),\n InfoIframe = require('./info-iframe'),\n InfoAjax = require('./info-ajax');\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:info-receiver');\n }\n\n function InfoReceiver(baseUrl, urlInfo) {\n debug(baseUrl);\n var self = this;\n EventEmitter.call(this);\n setTimeout(function () {\n self.doXhr(baseUrl, urlInfo);\n }, 0);\n }\n\n inherits(InfoReceiver, EventEmitter); // TODO this is currently ignoring the list of available transports and the whitelist\n\n InfoReceiver._getReceiver = function (baseUrl, url, urlInfo) {\n // determine method of CORS support (if needed)\n if (urlInfo.sameOrigin) {\n return new InfoAjax(url, XHRLocal);\n }\n\n if (XHRCors.enabled) {\n return new InfoAjax(url, XHRCors);\n }\n\n if (XDR.enabled && urlInfo.sameScheme) {\n return new InfoAjax(url, XDR);\n }\n\n if (InfoIframe.enabled()) {\n return new InfoIframe(baseUrl, url);\n }\n\n return new InfoAjax(url, XHRFake);\n };\n\n InfoReceiver.prototype.doXhr = function (baseUrl, urlInfo) {\n var self = this,\n url = urlUtils.addPath(baseUrl, '/info');\n debug('doXhr', url);\n this.xo = InfoReceiver._getReceiver(baseUrl, url, urlInfo);\n this.timeoutRef = setTimeout(function () {\n debug('timeout');\n\n self._cleanup(false);\n\n self.emit('finish');\n }, InfoReceiver.timeout);\n this.xo.once('finish', function (info, rtt) {\n debug('finish', info, rtt);\n\n self._cleanup(true);\n\n self.emit('finish', info, rtt);\n });\n };\n\n InfoReceiver.prototype._cleanup = function (wasClean) {\n debug('_cleanup');\n clearTimeout(this.timeoutRef);\n this.timeoutRef = null;\n\n if (!wasClean && this.xo) {\n this.xo.close();\n }\n\n this.xo = null;\n };\n\n InfoReceiver.prototype.close = function () {\n debug('close');\n this.removeAllListeners();\n\n this._cleanup(false);\n };\n\n InfoReceiver.timeout = 8000;\n module.exports = InfoReceiver;\n }).call(this, {\n env: {}\n });\n }, {\n \"./info-ajax\": 9,\n \"./info-iframe\": 11,\n \"./transport/sender/xdr\": 34,\n \"./transport/sender/xhr-cors\": 35,\n \"./transport/sender/xhr-fake\": 36,\n \"./transport/sender/xhr-local\": 37,\n \"./utils/url\": 52,\n \"debug\": 55,\n \"events\": 3,\n \"inherits\": 57\n }],\n 13: [function (require, module, exports) {\n (function (global) {\n 'use strict';\n\n module.exports = global.location || {\n origin: 'http://localhost:80',\n protocol: 'http:',\n host: 'localhost',\n port: 80,\n href: 'http://localhost/',\n hash: ''\n };\n }).call(this, typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {});\n }, {}],\n 14: [function (require, module, exports) {\n (function (process, global) {\n 'use strict';\n\n require('./shims');\n\n var URL = require('url-parse'),\n inherits = require('inherits'),\n JSON3 = require('json3'),\n random = require('./utils/random'),\n escape = require('./utils/escape'),\n urlUtils = require('./utils/url'),\n eventUtils = require('./utils/event'),\n transport = require('./utils/transport'),\n objectUtils = require('./utils/object'),\n browser = require('./utils/browser'),\n log = require('./utils/log'),\n Event = require('./event/event'),\n EventTarget = require('./event/eventtarget'),\n loc = require('./location'),\n CloseEvent = require('./event/close'),\n TransportMessageEvent = require('./event/trans-message'),\n InfoReceiver = require('./info-receiver');\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:main');\n }\n\n var transports; // follow constructor steps defined at http://dev.w3.org/html5/websockets/#the-websocket-interface\n\n function SockJS(url, protocols, options) {\n if (!(this instanceof SockJS)) {\n return new SockJS(url, protocols, options);\n }\n\n if (arguments.length < 1) {\n throw new TypeError(\"Failed to construct 'SockJS: 1 argument required, but only 0 present\");\n }\n\n EventTarget.call(this);\n this.readyState = SockJS.CONNECTING;\n this.extensions = '';\n this.protocol = ''; // non-standard extension\n\n options = options || {};\n\n if (options.protocols_whitelist) {\n log.warn(\"'protocols_whitelist' is DEPRECATED. Use 'transports' instead.\");\n }\n\n this._transportsWhitelist = options.transports;\n this._transportOptions = options.transportOptions || {};\n this._timeout = options.timeout || 0;\n var sessionId = options.sessionId || 8;\n\n if (typeof sessionId === 'function') {\n this._generateSessionId = sessionId;\n } else if (typeof sessionId === 'number') {\n this._generateSessionId = function () {\n return random.string(sessionId);\n };\n } else {\n throw new TypeError('If sessionId is used in the options, it needs to be a number or a function.');\n }\n\n this._server = options.server || random.numberString(1000); // Step 1 of WS spec - parse and validate the url. Issue #8\n\n var parsedUrl = new URL(url);\n\n if (!parsedUrl.host || !parsedUrl.protocol) {\n throw new SyntaxError(\"The URL '\" + url + \"' is invalid\");\n } else if (parsedUrl.hash) {\n throw new SyntaxError('The URL must not contain a fragment');\n } else if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {\n throw new SyntaxError(\"The URL's scheme must be either 'http:' or 'https:'. '\" + parsedUrl.protocol + \"' is not allowed.\");\n }\n\n var secure = parsedUrl.protocol === 'https:'; // Step 2 - don't allow secure origin with an insecure protocol\n\n if (loc.protocol === 'https:' && !secure) {\n // exception is 127.0.0.0/8 and ::1 urls\n if (!urlUtils.isLoopbackAddr(parsedUrl.hostname)) {\n throw new Error('SecurityError: An insecure SockJS connection may not be initiated from a page loaded over HTTPS');\n }\n } // Step 3 - check port access - no need here\n // Step 4 - parse protocols argument\n\n\n if (!protocols) {\n protocols = [];\n } else if (!Array.isArray(protocols)) {\n protocols = [protocols];\n } // Step 5 - check protocols argument\n\n\n var sortedProtocols = protocols.sort();\n sortedProtocols.forEach(function (proto, i) {\n if (!proto) {\n throw new SyntaxError(\"The protocols entry '\" + proto + \"' is invalid.\");\n }\n\n if (i < sortedProtocols.length - 1 && proto === sortedProtocols[i + 1]) {\n throw new SyntaxError(\"The protocols entry '\" + proto + \"' is duplicated.\");\n }\n }); // Step 6 - convert origin\n\n var o = urlUtils.getOrigin(loc.href);\n this._origin = o ? o.toLowerCase() : null; // remove the trailing slash\n\n parsedUrl.set('pathname', parsedUrl.pathname.replace(/\\/+$/, '')); // store the sanitized url\n\n this.url = parsedUrl.href;\n debug('using url', this.url); // Step 7 - start connection in background\n // obtain server info\n // http://sockjs.github.io/sockjs-protocol/sockjs-protocol-0.3.3.html#section-26\n\n this._urlInfo = {\n nullOrigin: !browser.hasDomain(),\n sameOrigin: urlUtils.isOriginEqual(this.url, loc.href),\n sameScheme: urlUtils.isSchemeEqual(this.url, loc.href)\n };\n this._ir = new InfoReceiver(this.url, this._urlInfo);\n\n this._ir.once('finish', this._receiveInfo.bind(this));\n }\n\n inherits(SockJS, EventTarget);\n\n function userSetCode(code) {\n return code === 1000 || code >= 3000 && code <= 4999;\n }\n\n SockJS.prototype.close = function (code, reason) {\n // Step 1\n if (code && !userSetCode(code)) {\n throw new Error('InvalidAccessError: Invalid code');\n } // Step 2.4 states the max is 123 bytes, but we are just checking length\n\n\n if (reason && reason.length > 123) {\n throw new SyntaxError('reason argument has an invalid length');\n } // Step 3.1\n\n\n if (this.readyState === SockJS.CLOSING || this.readyState === SockJS.CLOSED) {\n return;\n } // TODO look at docs to determine how to set this\n\n\n var wasClean = true;\n\n this._close(code || 1000, reason || 'Normal closure', wasClean);\n };\n\n SockJS.prototype.send = function (data) {\n // #13 - convert anything non-string to string\n // TODO this currently turns objects into [object Object]\n if (typeof data !== 'string') {\n data = '' + data;\n }\n\n if (this.readyState === SockJS.CONNECTING) {\n throw new Error('InvalidStateError: The connection has not been established yet');\n }\n\n if (this.readyState !== SockJS.OPEN) {\n return;\n }\n\n this._transport.send(escape.quote(data));\n };\n\n SockJS.version = require('./version');\n SockJS.CONNECTING = 0;\n SockJS.OPEN = 1;\n SockJS.CLOSING = 2;\n SockJS.CLOSED = 3;\n\n SockJS.prototype._receiveInfo = function (info, rtt) {\n debug('_receiveInfo', rtt);\n this._ir = null;\n\n if (!info) {\n this._close(1002, 'Cannot connect to server');\n\n return;\n } // establish a round-trip timeout (RTO) based on the\n // round-trip time (RTT)\n\n\n this._rto = this.countRTO(rtt); // allow server to override url used for the actual transport\n\n this._transUrl = info.base_url ? info.base_url : this.url;\n info = objectUtils.extend(info, this._urlInfo);\n debug('info', info); // determine list of desired and supported transports\n\n var enabledTransports = transports.filterToEnabled(this._transportsWhitelist, info);\n this._transports = enabledTransports.main;\n debug(this._transports.length + ' enabled transports');\n\n this._connect();\n };\n\n SockJS.prototype._connect = function () {\n for (var Transport = this._transports.shift(); Transport; Transport = this._transports.shift()) {\n debug('attempt', Transport.transportName);\n\n if (Transport.needBody) {\n if (!global.document.body || typeof global.document.readyState !== 'undefined' && global.document.readyState !== 'complete' && global.document.readyState !== 'interactive') {\n debug('waiting for body');\n\n this._transports.unshift(Transport);\n\n eventUtils.attachEvent('load', this._connect.bind(this));\n return;\n }\n } // calculate timeout based on RTO and round trips. Default to 5s\n\n\n var timeoutMs = Math.max(this._timeout, this._rto * Transport.roundTrips || 5000);\n this._transportTimeoutId = setTimeout(this._transportTimeout.bind(this), timeoutMs);\n debug('using timeout', timeoutMs);\n var transportUrl = urlUtils.addPath(this._transUrl, '/' + this._server + '/' + this._generateSessionId());\n var options = this._transportOptions[Transport.transportName];\n debug('transport url', transportUrl);\n var transportObj = new Transport(transportUrl, this._transUrl, options);\n transportObj.on('message', this._transportMessage.bind(this));\n transportObj.once('close', this._transportClose.bind(this));\n transportObj.transportName = Transport.transportName;\n this._transport = transportObj;\n return;\n }\n\n this._close(2000, 'All transports failed', false);\n };\n\n SockJS.prototype._transportTimeout = function () {\n debug('_transportTimeout');\n\n if (this.readyState === SockJS.CONNECTING) {\n if (this._transport) {\n this._transport.close();\n }\n\n this._transportClose(2007, 'Transport timed out');\n }\n };\n\n SockJS.prototype._transportMessage = function (msg) {\n debug('_transportMessage', msg);\n var self = this,\n type = msg.slice(0, 1),\n content = msg.slice(1),\n payload; // first check for messages that don't need a payload\n\n switch (type) {\n case 'o':\n this._open();\n\n return;\n\n case 'h':\n this.dispatchEvent(new Event('heartbeat'));\n debug('heartbeat', this.transport);\n return;\n }\n\n if (content) {\n try {\n payload = JSON3.parse(content);\n } catch (e) {\n debug('bad json', content);\n }\n }\n\n if (typeof payload === 'undefined') {\n debug('empty payload', content);\n return;\n }\n\n switch (type) {\n case 'a':\n if (Array.isArray(payload)) {\n payload.forEach(function (p) {\n debug('message', self.transport, p);\n self.dispatchEvent(new TransportMessageEvent(p));\n });\n }\n\n break;\n\n case 'm':\n debug('message', this.transport, payload);\n this.dispatchEvent(new TransportMessageEvent(payload));\n break;\n\n case 'c':\n if (Array.isArray(payload) && payload.length === 2) {\n this._close(payload[0], payload[1], true);\n }\n\n break;\n }\n };\n\n SockJS.prototype._transportClose = function (code, reason) {\n debug('_transportClose', this.transport, code, reason);\n\n if (this._transport) {\n this._transport.removeAllListeners();\n\n this._transport = null;\n this.transport = null;\n }\n\n if (!userSetCode(code) && code !== 2000 && this.readyState === SockJS.CONNECTING) {\n this._connect();\n\n return;\n }\n\n this._close(code, reason);\n };\n\n SockJS.prototype._open = function () {\n debug('_open', this._transport && this._transport.transportName, this.readyState);\n\n if (this.readyState === SockJS.CONNECTING) {\n if (this._transportTimeoutId) {\n clearTimeout(this._transportTimeoutId);\n this._transportTimeoutId = null;\n }\n\n this.readyState = SockJS.OPEN;\n this.transport = this._transport.transportName;\n this.dispatchEvent(new Event('open'));\n debug('connected', this.transport);\n } else {\n // The server might have been restarted, and lost track of our\n // connection.\n this._close(1006, 'Server lost session');\n }\n };\n\n SockJS.prototype._close = function (code, reason, wasClean) {\n debug('_close', this.transport, code, reason, wasClean, this.readyState);\n var forceFail = false;\n\n if (this._ir) {\n forceFail = true;\n\n this._ir.close();\n\n this._ir = null;\n }\n\n if (this._transport) {\n this._transport.close();\n\n this._transport = null;\n this.transport = null;\n }\n\n if (this.readyState === SockJS.CLOSED) {\n throw new Error('InvalidStateError: SockJS has already been closed');\n }\n\n this.readyState = SockJS.CLOSING;\n setTimeout(function () {\n this.readyState = SockJS.CLOSED;\n\n if (forceFail) {\n this.dispatchEvent(new Event('error'));\n }\n\n var e = new CloseEvent('close');\n e.wasClean = wasClean || false;\n e.code = code || 1000;\n e.reason = reason;\n this.dispatchEvent(e);\n this.onmessage = this.onclose = this.onerror = null;\n debug('disconnected');\n }.bind(this), 0);\n }; // See: http://www.erg.abdn.ac.uk/~gerrit/dccp/notes/ccid2/rto_estimator/\n // and RFC 2988.\n\n\n SockJS.prototype.countRTO = function (rtt) {\n // In a local environment, when using IE8/9 and the `jsonp-polling`\n // transport the time needed to establish a connection (the time that pass\n // from the opening of the transport to the call of `_dispatchOpen`) is\n // around 200msec (the lower bound used in the article above) and this\n // causes spurious timeouts. For this reason we calculate a value slightly\n // larger than that used in the article.\n if (rtt > 100) {\n return 4 * rtt; // rto > 400msec\n }\n\n return 300 + rtt; // 300msec < rto <= 400msec\n };\n\n module.exports = function (availableTransports) {\n transports = transport(availableTransports);\n\n require('./iframe-bootstrap')(SockJS, availableTransports);\n\n return SockJS;\n };\n }).call(this, {\n env: {}\n }, typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {});\n }, {\n \"./event/close\": 2,\n \"./event/event\": 4,\n \"./event/eventtarget\": 5,\n \"./event/trans-message\": 6,\n \"./iframe-bootstrap\": 8,\n \"./info-receiver\": 12,\n \"./location\": 13,\n \"./shims\": 15,\n \"./utils/browser\": 44,\n \"./utils/escape\": 45,\n \"./utils/event\": 46,\n \"./utils/log\": 48,\n \"./utils/object\": 49,\n \"./utils/random\": 50,\n \"./utils/transport\": 51,\n \"./utils/url\": 52,\n \"./version\": 53,\n \"debug\": 55,\n \"inherits\": 57,\n \"json3\": 58,\n \"url-parse\": 61\n }],\n 15: [function (require, module, exports) {\n /* eslint-disable */\n\n /* jscs: disable */\n 'use strict'; // pulled specific shims from https://github.com/es-shims/es5-shim\n\n var ArrayPrototype = Array.prototype;\n var ObjectPrototype = Object.prototype;\n var FunctionPrototype = Function.prototype;\n var StringPrototype = String.prototype;\n var array_slice = ArrayPrototype.slice;\n var _toString = ObjectPrototype.toString;\n\n var isFunction = function (val) {\n return ObjectPrototype.toString.call(val) === '[object Function]';\n };\n\n var isArray = function isArray(obj) {\n return _toString.call(obj) === '[object Array]';\n };\n\n var isString = function isString(obj) {\n return _toString.call(obj) === '[object String]';\n };\n\n var supportsDescriptors = Object.defineProperty && function () {\n try {\n Object.defineProperty({}, 'x', {});\n return true;\n } catch (e) {\n /* this is ES3 */\n return false;\n }\n }(); // Define configurable, writable and non-enumerable props\n // if they don't exist.\n\n\n var defineProperty;\n\n if (supportsDescriptors) {\n defineProperty = function (object, name, method, forceAssign) {\n if (!forceAssign && name in object) {\n return;\n }\n\n Object.defineProperty(object, name, {\n configurable: true,\n enumerable: false,\n writable: true,\n value: method\n });\n };\n } else {\n defineProperty = function (object, name, method, forceAssign) {\n if (!forceAssign && name in object) {\n return;\n }\n\n object[name] = method;\n };\n }\n\n var defineProperties = function (object, map, forceAssign) {\n for (var name in map) {\n if (ObjectPrototype.hasOwnProperty.call(map, name)) {\n defineProperty(object, name, map[name], forceAssign);\n }\n }\n };\n\n var toObject = function (o) {\n if (o == null) {\n // this matches both null and undefined\n throw new TypeError(\"can't convert \" + o + ' to object');\n }\n\n return Object(o);\n }; //\n // Util\n // ======\n //\n // ES5 9.4\n // http://es5.github.com/#x9.4\n // http://jsperf.com/to-integer\n\n\n function toInteger(num) {\n var n = +num;\n\n if (n !== n) {\n // isNaN\n n = 0;\n } else if (n !== 0 && n !== 1 / 0 && n !== -(1 / 0)) {\n n = (n > 0 || -1) * Math.floor(Math.abs(n));\n }\n\n return n;\n }\n\n function ToUint32(x) {\n return x >>> 0;\n } //\n // Function\n // ========\n //\n // ES-5 15.3.4.5\n // http://es5.github.com/#x15.3.4.5\n\n\n function Empty() {}\n\n defineProperties(FunctionPrototype, {\n bind: function bind(that) {\n // .length is 1\n // 1. Let Target be the this value.\n var target = this; // 2. If IsCallable(Target) is false, throw a TypeError exception.\n\n if (!isFunction(target)) {\n throw new TypeError('Function.prototype.bind called on incompatible ' + target);\n } // 3. Let A be a new (possibly empty) internal list of all of the\n // argument values provided after thisArg (arg1, arg2 etc), in order.\n // XXX slicedArgs will stand in for \"A\" if used\n\n\n var args = array_slice.call(arguments, 1); // for normal call\n // 4. Let F be a new native ECMAScript object.\n // 11. Set the [[Prototype]] internal property of F to the standard\n // built-in Function prototype object as specified in 15.3.3.1.\n // 12. Set the [[Call]] internal property of F as described in\n // 15.3.4.5.1.\n // 13. Set the [[Construct]] internal property of F as described in\n // 15.3.4.5.2.\n // 14. Set the [[HasInstance]] internal property of F as described in\n // 15.3.4.5.3.\n\n var binder = function () {\n if (this instanceof bound) {\n // 15.3.4.5.2 [[Construct]]\n // When the [[Construct]] internal method of a function object,\n // F that was created using the bind function is called with a\n // list of arguments ExtraArgs, the following steps are taken:\n // 1. Let target be the value of F's [[TargetFunction]]\n // internal property.\n // 2. If target has no [[Construct]] internal method, a\n // TypeError exception is thrown.\n // 3. Let boundArgs be the value of F's [[BoundArgs]] internal\n // property.\n // 4. Let args be a new list containing the same values as the\n // list boundArgs in the same order followed by the same\n // values as the list ExtraArgs in the same order.\n // 5. Return the result of calling the [[Construct]] internal\n // method of target providing args as the arguments.\n var result = target.apply(this, args.concat(array_slice.call(arguments)));\n\n if (Object(result) === result) {\n return result;\n }\n\n return this;\n } else {\n // 15.3.4.5.1 [[Call]]\n // When the [[Call]] internal method of a function object, F,\n // which was created using the bind function is called with a\n // this value and a list of arguments ExtraArgs, the following\n // steps are taken:\n // 1. Let boundArgs be the value of F's [[BoundArgs]] internal\n // property.\n // 2. Let boundThis be the value of F's [[BoundThis]] internal\n // property.\n // 3. Let target be the value of F's [[TargetFunction]] internal\n // property.\n // 4. Let args be a new list containing the same values as the\n // list boundArgs in the same order followed by the same\n // values as the list ExtraArgs in the same order.\n // 5. Return the result of calling the [[Call]] internal method\n // of target providing boundThis as the this value and\n // providing args as the arguments.\n // equiv: target.call(this, ...boundArgs, ...args)\n return target.apply(that, args.concat(array_slice.call(arguments)));\n }\n }; // 15. If the [[Class]] internal property of Target is \"Function\", then\n // a. Let L be the length property of Target minus the length of A.\n // b. Set the length own property of F to either 0 or L, whichever is\n // larger.\n // 16. Else set the length own property of F to 0.\n\n\n var boundLength = Math.max(0, target.length - args.length); // 17. Set the attributes of the length own property of F to the values\n // specified in 15.3.5.1.\n\n var boundArgs = [];\n\n for (var i = 0; i < boundLength; i++) {\n boundArgs.push('$' + i);\n } // XXX Build a dynamic function with desired amount of arguments is the only\n // way to set the length property of a function.\n // In environments where Content Security Policies enabled (Chrome extensions,\n // for ex.) all use of eval or Function costructor throws an exception.\n // However in all of these environments Function.prototype.bind exists\n // and so this code will never be executed.\n\n\n var bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);\n\n if (target.prototype) {\n Empty.prototype = target.prototype;\n bound.prototype = new Empty(); // Clean up dangling references.\n\n Empty.prototype = null;\n } // TODO\n // 18. Set the [[Extensible]] internal property of F to true.\n // TODO\n // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).\n // 20. Call the [[DefineOwnProperty]] internal method of F with\n // arguments \"caller\", PropertyDescriptor {[[Get]]: thrower, [[Set]]:\n // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and\n // false.\n // 21. Call the [[DefineOwnProperty]] internal method of F with\n // arguments \"arguments\", PropertyDescriptor {[[Get]]: thrower,\n // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},\n // and false.\n // TODO\n // NOTE Function objects created using Function.prototype.bind do not\n // have a prototype property or the [[Code]], [[FormalParameters]], and\n // [[Scope]] internal properties.\n // XXX can't delete prototype in pure-js.\n // 22. Return F.\n\n\n return bound;\n }\n }); //\n // Array\n // =====\n //\n // ES5 15.4.3.2\n // http://es5.github.com/#x15.4.3.2\n // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray\n\n defineProperties(Array, {\n isArray: isArray\n });\n var boxedString = Object('a');\n var splitString = boxedString[0] !== 'a' || !(0 in boxedString);\n\n var properlyBoxesContext = function properlyBoxed(method) {\n // Check node 0.6.21 bug where third parameter is not boxed\n var properlyBoxesNonStrict = true;\n var properlyBoxesStrict = true;\n\n if (method) {\n method.call('foo', function (_, __, context) {\n if (typeof context !== 'object') {\n properlyBoxesNonStrict = false;\n }\n });\n method.call([1], function () {\n 'use strict';\n\n properlyBoxesStrict = typeof this === 'string';\n }, 'x');\n }\n\n return !!method && properlyBoxesNonStrict && properlyBoxesStrict;\n };\n\n defineProperties(ArrayPrototype, {\n forEach: function forEach(fun\n /*, thisp*/\n ) {\n var object = toObject(this),\n self = splitString && isString(this) ? this.split('') : object,\n thisp = arguments[1],\n i = -1,\n length = self.length >>> 0; // If no callback function or if callback is not a callable function\n\n if (!isFunction(fun)) {\n throw new TypeError(); // TODO message\n }\n\n while (++i < length) {\n if (i in self) {\n // Invoke the callback function with call, passing arguments:\n // context, property value, property key, thisArg object\n // context\n fun.call(thisp, self[i], i, object);\n }\n }\n }\n }, !properlyBoxesContext(ArrayPrototype.forEach)); // ES5 15.4.4.14\n // http://es5.github.com/#x15.4.4.14\n // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf\n\n var hasFirefox2IndexOfBug = Array.prototype.indexOf && [0, 1].indexOf(1, 2) !== -1;\n defineProperties(ArrayPrototype, {\n indexOf: function indexOf(sought\n /*, fromIndex */\n ) {\n var self = splitString && isString(this) ? this.split('') : toObject(this),\n length = self.length >>> 0;\n\n if (!length) {\n return -1;\n }\n\n var i = 0;\n\n if (arguments.length > 1) {\n i = toInteger(arguments[1]);\n } // handle negative indices\n\n\n i = i >= 0 ? i : Math.max(0, length + i);\n\n for (; i < length; i++) {\n if (i in self && self[i] === sought) {\n return i;\n }\n }\n\n return -1;\n }\n }, hasFirefox2IndexOfBug); //\n // String\n // ======\n //\n // ES5 15.5.4.14\n // http://es5.github.com/#x15.5.4.14\n // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]\n // Many browsers do not split properly with regular expressions or they\n // do not perform the split correctly under obscure conditions.\n // See http://blog.stevenlevithan.com/archives/cross-browser-split\n // I've tested in many browsers and this seems to cover the deviant ones:\n // 'ab'.split(/(?:ab)*/) should be [\"\", \"\"], not [\"\"]\n // '.'.split(/(.?)(.?)/) should be [\"\", \".\", \"\", \"\"], not [\"\", \"\"]\n // 'tesst'.split(/(s)*/) should be [\"t\", undefined, \"e\", \"s\", \"t\"], not\n // [undefined, \"t\", undefined, \"e\", ...]\n // ''.split(/.?/) should be [], not [\"\"]\n // '.'.split(/()()/) should be [\".\"], not [\"\", \"\", \".\"]\n\n var string_split = StringPrototype.split;\n\n if ('ab'.split(/(?:ab)*/).length !== 2 || '.'.split(/(.?)(.?)/).length !== 4 || 'tesst'.split(/(s)*/)[1] === 't' || 'test'.split(/(?:)/, -1).length !== 4 || ''.split(/.?/).length || '.'.split(/()()/).length > 1) {\n (function () {\n var compliantExecNpcg = /()??/.exec('')[1] === void 0; // NPCG: nonparticipating capturing group\n\n StringPrototype.split = function (separator, limit) {\n var string = this;\n\n if (separator === void 0 && limit === 0) {\n return [];\n } // If `separator` is not a regex, use native split\n\n\n if (_toString.call(separator) !== '[object RegExp]') {\n return string_split.call(this, separator, limit);\n }\n\n var output = [],\n flags = (separator.ignoreCase ? 'i' : '') + (separator.multiline ? 'm' : '') + (separator.extended ? 'x' : '') + ( // Proposed for ES6\n separator.sticky ? 'y' : ''),\n // Firefox 3+\n lastLastIndex = 0,\n // Make `global` and avoid `lastIndex` issues by working with a copy\n separator2,\n match,\n lastIndex,\n lastLength;\n separator = new RegExp(separator.source, flags + 'g');\n string += ''; // Type-convert\n\n if (!compliantExecNpcg) {\n // Doesn't need flags gy, but they don't hurt\n separator2 = new RegExp('^' + separator.source + '$(?!\\\\s)', flags);\n }\n /* Values for `limit`, per the spec:\n * If undefined: 4294967295 // Math.pow(2, 32) - 1\n * If 0, Infinity, or NaN: 0\n * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;\n * If negative number: 4294967296 - Math.floor(Math.abs(limit))\n * If other: Type-convert, then use the above rules\n */\n\n\n limit = limit === void 0 ? -1 >>> 0 : // Math.pow(2, 32) - 1\n ToUint32(limit);\n\n while (match = separator.exec(string)) {\n // `separator.lastIndex` is not reliable cross-browser\n lastIndex = match.index + match[0].length;\n\n if (lastIndex > lastLastIndex) {\n output.push(string.slice(lastLastIndex, match.index)); // Fix browsers whose `exec` methods don't consistently return `undefined` for\n // nonparticipating capturing groups\n\n if (!compliantExecNpcg && match.length > 1) {\n match[0].replace(separator2, function () {\n for (var i = 1; i < arguments.length - 2; i++) {\n if (arguments[i] === void 0) {\n match[i] = void 0;\n }\n }\n });\n }\n\n if (match.length > 1 && match.index < string.length) {\n ArrayPrototype.push.apply(output, match.slice(1));\n }\n\n lastLength = match[0].length;\n lastLastIndex = lastIndex;\n\n if (output.length >= limit) {\n break;\n }\n }\n\n if (separator.lastIndex === match.index) {\n separator.lastIndex++; // Avoid an infinite loop\n }\n }\n\n if (lastLastIndex === string.length) {\n if (lastLength || !separator.test('')) {\n output.push('');\n }\n } else {\n output.push(string.slice(lastLastIndex));\n }\n\n return output.length > limit ? output.slice(0, limit) : output;\n };\n })(); // [bugfix, chrome]\n // If separator is undefined, then the result array contains just one String,\n // which is the this value (converted to a String). If limit is not undefined,\n // then the output array is truncated so that it contains no more than limit\n // elements.\n // \"0\".split(undefined, 0) -> []\n\n } else if ('0'.split(void 0, 0).length) {\n StringPrototype.split = function split(separator, limit) {\n if (separator === void 0 && limit === 0) {\n return [];\n }\n\n return string_split.call(this, separator, limit);\n };\n } // ECMA-262, 3rd B.2.3\n // Not an ECMAScript standard, although ECMAScript 3rd Edition has a\n // non-normative section suggesting uniform semantics and it should be\n // normalized across all browsers\n // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE\n\n\n var string_substr = StringPrototype.substr;\n var hasNegativeSubstrBug = ''.substr && '0b'.substr(-1) !== 'b';\n defineProperties(StringPrototype, {\n substr: function substr(start, length) {\n return string_substr.call(this, start < 0 ? (start = this.length + start) < 0 ? 0 : start : start, length);\n }\n }, hasNegativeSubstrBug);\n }, {}],\n 16: [function (require, module, exports) {\n 'use strict';\n\n module.exports = [// streaming transports\n require('./transport/websocket'), require('./transport/xhr-streaming'), require('./transport/xdr-streaming'), require('./transport/eventsource'), require('./transport/lib/iframe-wrap')(require('./transport/eventsource')) // polling transports\n , require('./transport/htmlfile'), require('./transport/lib/iframe-wrap')(require('./transport/htmlfile')), require('./transport/xhr-polling'), require('./transport/xdr-polling'), require('./transport/lib/iframe-wrap')(require('./transport/xhr-polling')), require('./transport/jsonp-polling')];\n }, {\n \"./transport/eventsource\": 20,\n \"./transport/htmlfile\": 21,\n \"./transport/jsonp-polling\": 23,\n \"./transport/lib/iframe-wrap\": 26,\n \"./transport/websocket\": 38,\n \"./transport/xdr-polling\": 39,\n \"./transport/xdr-streaming\": 40,\n \"./transport/xhr-polling\": 41,\n \"./transport/xhr-streaming\": 42\n }],\n 17: [function (require, module, exports) {\n (function (process, global) {\n 'use strict';\n\n var EventEmitter = require('events').EventEmitter,\n inherits = require('inherits'),\n utils = require('../../utils/event'),\n urlUtils = require('../../utils/url'),\n XHR = global.XMLHttpRequest;\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:browser:xhr');\n }\n\n function AbstractXHRObject(method, url, payload, opts) {\n debug(method, url);\n var self = this;\n EventEmitter.call(this);\n setTimeout(function () {\n self._start(method, url, payload, opts);\n }, 0);\n }\n\n inherits(AbstractXHRObject, EventEmitter);\n\n AbstractXHRObject.prototype._start = function (method, url, payload, opts) {\n var self = this;\n\n try {\n this.xhr = new XHR();\n } catch (x) {// intentionally empty\n }\n\n if (!this.xhr) {\n debug('no xhr');\n this.emit('finish', 0, 'no xhr support');\n\n this._cleanup();\n\n return;\n } // several browsers cache POSTs\n\n\n url = urlUtils.addQuery(url, 't=' + +new Date()); // Explorer tends to keep connection open, even after the\n // tab gets closed: http://bugs.jquery.com/ticket/5280\n\n this.unloadRef = utils.unloadAdd(function () {\n debug('unload cleanup');\n\n self._cleanup(true);\n });\n\n try {\n this.xhr.open(method, url, true);\n\n if (this.timeout && 'timeout' in this.xhr) {\n this.xhr.timeout = this.timeout;\n\n this.xhr.ontimeout = function () {\n debug('xhr timeout');\n self.emit('finish', 0, '');\n\n self._cleanup(false);\n };\n }\n } catch (e) {\n debug('exception', e); // IE raises an exception on wrong port.\n\n this.emit('finish', 0, '');\n\n this._cleanup(false);\n\n return;\n }\n\n if ((!opts || !opts.noCredentials) && AbstractXHRObject.supportsCORS) {\n debug('withCredentials'); // Mozilla docs says https://developer.mozilla.org/en/XMLHttpRequest :\n // \"This never affects same-site requests.\"\n\n this.xhr.withCredentials = true;\n }\n\n if (opts && opts.headers) {\n for (var key in opts.headers) {\n this.xhr.setRequestHeader(key, opts.headers[key]);\n }\n }\n\n this.xhr.onreadystatechange = function () {\n if (self.xhr) {\n var x = self.xhr;\n var text, status;\n debug('readyState', x.readyState);\n\n switch (x.readyState) {\n case 3:\n // IE doesn't like peeking into responseText or status\n // on Microsoft.XMLHTTP and readystate=3\n try {\n status = x.status;\n text = x.responseText;\n } catch (e) {// intentionally empty\n }\n\n debug('status', status); // IE returns 1223 for 204: http://bugs.jquery.com/ticket/1450\n\n if (status === 1223) {\n status = 204;\n } // IE does return readystate == 3 for 404 answers.\n\n\n if (status === 200 && text && text.length > 0) {\n debug('chunk');\n self.emit('chunk', status, text);\n }\n\n break;\n\n case 4:\n status = x.status;\n debug('status', status); // IE returns 1223 for 204: http://bugs.jquery.com/ticket/1450\n\n if (status === 1223) {\n status = 204;\n } // IE returns this for a bad port\n // http://msdn.microsoft.com/en-us/library/windows/desktop/aa383770(v=vs.85).aspx\n\n\n if (status === 12005 || status === 12029) {\n status = 0;\n }\n\n debug('finish', status, x.responseText);\n self.emit('finish', status, x.responseText);\n\n self._cleanup(false);\n\n break;\n }\n }\n };\n\n try {\n self.xhr.send(payload);\n } catch (e) {\n self.emit('finish', 0, '');\n\n self._cleanup(false);\n }\n };\n\n AbstractXHRObject.prototype._cleanup = function (abort) {\n debug('cleanup');\n\n if (!this.xhr) {\n return;\n }\n\n this.removeAllListeners();\n utils.unloadDel(this.unloadRef); // IE needs this field to be a function\n\n this.xhr.onreadystatechange = function () {};\n\n if (this.xhr.ontimeout) {\n this.xhr.ontimeout = null;\n }\n\n if (abort) {\n try {\n this.xhr.abort();\n } catch (x) {// intentionally empty\n }\n }\n\n this.unloadRef = this.xhr = null;\n };\n\n AbstractXHRObject.prototype.close = function () {\n debug('close');\n\n this._cleanup(true);\n };\n\n AbstractXHRObject.enabled = !!XHR; // override XMLHttpRequest for IE6/7\n // obfuscate to avoid firewalls\n\n var axo = ['Active'].concat('Object').join('X');\n\n if (!AbstractXHRObject.enabled && axo in global) {\n debug('overriding xmlhttprequest');\n\n XHR = function () {\n try {\n return new global[axo]('Microsoft.XMLHTTP');\n } catch (e) {\n return null;\n }\n };\n\n AbstractXHRObject.enabled = !!new XHR();\n }\n\n var cors = false;\n\n try {\n cors = 'withCredentials' in new XHR();\n } catch (ignored) {// intentionally empty\n }\n\n AbstractXHRObject.supportsCORS = cors;\n module.exports = AbstractXHRObject;\n }).call(this, {\n env: {}\n }, typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {});\n }, {\n \"../../utils/event\": 46,\n \"../../utils/url\": 52,\n \"debug\": 55,\n \"events\": 3,\n \"inherits\": 57\n }],\n 18: [function (require, module, exports) {\n (function (global) {\n module.exports = global.EventSource;\n }).call(this, typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {});\n }, {}],\n 19: [function (require, module, exports) {\n (function (global) {\n 'use strict';\n\n var Driver = global.WebSocket || global.MozWebSocket;\n\n if (Driver) {\n module.exports = function WebSocketBrowserDriver(url) {\n return new Driver(url);\n };\n } else {\n module.exports = undefined;\n }\n }).call(this, typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {});\n }, {}],\n 20: [function (require, module, exports) {\n 'use strict';\n\n var inherits = require('inherits'),\n AjaxBasedTransport = require('./lib/ajax-based'),\n EventSourceReceiver = require('./receiver/eventsource'),\n XHRCorsObject = require('./sender/xhr-cors'),\n EventSourceDriver = require('eventsource');\n\n function EventSourceTransport(transUrl) {\n if (!EventSourceTransport.enabled()) {\n throw new Error('Transport created when disabled');\n }\n\n AjaxBasedTransport.call(this, transUrl, '/eventsource', EventSourceReceiver, XHRCorsObject);\n }\n\n inherits(EventSourceTransport, AjaxBasedTransport);\n\n EventSourceTransport.enabled = function () {\n return !!EventSourceDriver;\n };\n\n EventSourceTransport.transportName = 'eventsource';\n EventSourceTransport.roundTrips = 2;\n module.exports = EventSourceTransport;\n }, {\n \"./lib/ajax-based\": 24,\n \"./receiver/eventsource\": 29,\n \"./sender/xhr-cors\": 35,\n \"eventsource\": 18,\n \"inherits\": 57\n }],\n 21: [function (require, module, exports) {\n 'use strict';\n\n var inherits = require('inherits'),\n HtmlfileReceiver = require('./receiver/htmlfile'),\n XHRLocalObject = require('./sender/xhr-local'),\n AjaxBasedTransport = require('./lib/ajax-based');\n\n function HtmlFileTransport(transUrl) {\n if (!HtmlfileReceiver.enabled) {\n throw new Error('Transport created when disabled');\n }\n\n AjaxBasedTransport.call(this, transUrl, '/htmlfile', HtmlfileReceiver, XHRLocalObject);\n }\n\n inherits(HtmlFileTransport, AjaxBasedTransport);\n\n HtmlFileTransport.enabled = function (info) {\n return HtmlfileReceiver.enabled && info.sameOrigin;\n };\n\n HtmlFileTransport.transportName = 'htmlfile';\n HtmlFileTransport.roundTrips = 2;\n module.exports = HtmlFileTransport;\n }, {\n \"./lib/ajax-based\": 24,\n \"./receiver/htmlfile\": 30,\n \"./sender/xhr-local\": 37,\n \"inherits\": 57\n }],\n 22: [function (require, module, exports) {\n (function (process) {\n 'use strict'; // Few cool transports do work only for same-origin. In order to make\n // them work cross-domain we shall use iframe, served from the\n // remote domain. New browsers have capabilities to communicate with\n // cross domain iframe using postMessage(). In IE it was implemented\n // from IE 8+, but of course, IE got some details wrong:\n // http://msdn.microsoft.com/en-us/library/cc197015(v=VS.85).aspx\n // http://stevesouders.com/misc/test-postmessage.php\n\n var inherits = require('inherits'),\n JSON3 = require('json3'),\n EventEmitter = require('events').EventEmitter,\n version = require('../version'),\n urlUtils = require('../utils/url'),\n iframeUtils = require('../utils/iframe'),\n eventUtils = require('../utils/event'),\n random = require('../utils/random');\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:transport:iframe');\n }\n\n function IframeTransport(transport, transUrl, baseUrl) {\n if (!IframeTransport.enabled()) {\n throw new Error('Transport created when disabled');\n }\n\n EventEmitter.call(this);\n var self = this;\n this.origin = urlUtils.getOrigin(baseUrl);\n this.baseUrl = baseUrl;\n this.transUrl = transUrl;\n this.transport = transport;\n this.windowId = random.string(8);\n var iframeUrl = urlUtils.addPath(baseUrl, '/iframe.html') + '#' + this.windowId;\n debug(transport, transUrl, iframeUrl);\n this.iframeObj = iframeUtils.createIframe(iframeUrl, function (r) {\n debug('err callback');\n self.emit('close', 1006, 'Unable to load an iframe (' + r + ')');\n self.close();\n });\n this.onmessageCallback = this._message.bind(this);\n eventUtils.attachEvent('message', this.onmessageCallback);\n }\n\n inherits(IframeTransport, EventEmitter);\n\n IframeTransport.prototype.close = function () {\n debug('close');\n this.removeAllListeners();\n\n if (this.iframeObj) {\n eventUtils.detachEvent('message', this.onmessageCallback);\n\n try {\n // When the iframe is not loaded, IE raises an exception\n // on 'contentWindow'.\n this.postMessage('c');\n } catch (x) {// intentionally empty\n }\n\n this.iframeObj.cleanup();\n this.iframeObj = null;\n this.onmessageCallback = this.iframeObj = null;\n }\n };\n\n IframeTransport.prototype._message = function (e) {\n debug('message', e.data);\n\n if (!urlUtils.isOriginEqual(e.origin, this.origin)) {\n debug('not same origin', e.origin, this.origin);\n return;\n }\n\n var iframeMessage;\n\n try {\n iframeMessage = JSON3.parse(e.data);\n } catch (ignored) {\n debug('bad json', e.data);\n return;\n }\n\n if (iframeMessage.windowId !== this.windowId) {\n debug('mismatched window id', iframeMessage.windowId, this.windowId);\n return;\n }\n\n switch (iframeMessage.type) {\n case 's':\n this.iframeObj.loaded(); // window global dependency\n\n this.postMessage('s', JSON3.stringify([version, this.transport, this.transUrl, this.baseUrl]));\n break;\n\n case 't':\n this.emit('message', iframeMessage.data);\n break;\n\n case 'c':\n var cdata;\n\n try {\n cdata = JSON3.parse(iframeMessage.data);\n } catch (ignored) {\n debug('bad json', iframeMessage.data);\n return;\n }\n\n this.emit('close', cdata[0], cdata[1]);\n this.close();\n break;\n }\n };\n\n IframeTransport.prototype.postMessage = function (type, data) {\n debug('postMessage', type, data);\n this.iframeObj.post(JSON3.stringify({\n windowId: this.windowId,\n type: type,\n data: data || ''\n }), this.origin);\n };\n\n IframeTransport.prototype.send = function (message) {\n debug('send', message);\n this.postMessage('m', message);\n };\n\n IframeTransport.enabled = function () {\n return iframeUtils.iframeEnabled;\n };\n\n IframeTransport.transportName = 'iframe';\n IframeTransport.roundTrips = 2;\n module.exports = IframeTransport;\n }).call(this, {\n env: {}\n });\n }, {\n \"../utils/event\": 46,\n \"../utils/iframe\": 47,\n \"../utils/random\": 50,\n \"../utils/url\": 52,\n \"../version\": 53,\n \"debug\": 55,\n \"events\": 3,\n \"inherits\": 57,\n \"json3\": 58\n }],\n 23: [function (require, module, exports) {\n (function (global) {\n 'use strict'; // The simplest and most robust transport, using the well-know cross\n // domain hack - JSONP. This transport is quite inefficient - one\n // message could use up to one http request. But at least it works almost\n // everywhere.\n // Known limitations:\n // o you will get a spinning cursor\n // o for Konqueror a dumb timer is needed to detect errors\n\n var inherits = require('inherits'),\n SenderReceiver = require('./lib/sender-receiver'),\n JsonpReceiver = require('./receiver/jsonp'),\n jsonpSender = require('./sender/jsonp');\n\n function JsonPTransport(transUrl) {\n if (!JsonPTransport.enabled()) {\n throw new Error('Transport created when disabled');\n }\n\n SenderReceiver.call(this, transUrl, '/jsonp', jsonpSender, JsonpReceiver);\n }\n\n inherits(JsonPTransport, SenderReceiver);\n\n JsonPTransport.enabled = function () {\n return !!global.document;\n };\n\n JsonPTransport.transportName = 'jsonp-polling';\n JsonPTransport.roundTrips = 1;\n JsonPTransport.needBody = true;\n module.exports = JsonPTransport;\n }).call(this, typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {});\n }, {\n \"./lib/sender-receiver\": 28,\n \"./receiver/jsonp\": 31,\n \"./sender/jsonp\": 33,\n \"inherits\": 57\n }],\n 24: [function (require, module, exports) {\n (function (process) {\n 'use strict';\n\n var inherits = require('inherits'),\n urlUtils = require('../../utils/url'),\n SenderReceiver = require('./sender-receiver');\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:ajax-based');\n }\n\n function createAjaxSender(AjaxObject) {\n return function (url, payload, callback) {\n debug('create ajax sender', url, payload);\n var opt = {};\n\n if (typeof payload === 'string') {\n opt.headers = {\n 'Content-type': 'text/plain'\n };\n }\n\n var ajaxUrl = urlUtils.addPath(url, '/xhr_send');\n var xo = new AjaxObject('POST', ajaxUrl, payload, opt);\n xo.once('finish', function (status) {\n debug('finish', status);\n xo = null;\n\n if (status !== 200 && status !== 204) {\n return callback(new Error('http status ' + status));\n }\n\n callback();\n });\n return function () {\n debug('abort');\n xo.close();\n xo = null;\n var err = new Error('Aborted');\n err.code = 1000;\n callback(err);\n };\n };\n }\n\n function AjaxBasedTransport(transUrl, urlSuffix, Receiver, AjaxObject) {\n SenderReceiver.call(this, transUrl, urlSuffix, createAjaxSender(AjaxObject), Receiver, AjaxObject);\n }\n\n inherits(AjaxBasedTransport, SenderReceiver);\n module.exports = AjaxBasedTransport;\n }).call(this, {\n env: {}\n });\n }, {\n \"../../utils/url\": 52,\n \"./sender-receiver\": 28,\n \"debug\": 55,\n \"inherits\": 57\n }],\n 25: [function (require, module, exports) {\n (function (process) {\n 'use strict';\n\n var inherits = require('inherits'),\n EventEmitter = require('events').EventEmitter;\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:buffered-sender');\n }\n\n function BufferedSender(url, sender) {\n debug(url);\n EventEmitter.call(this);\n this.sendBuffer = [];\n this.sender = sender;\n this.url = url;\n }\n\n inherits(BufferedSender, EventEmitter);\n\n BufferedSender.prototype.send = function (message) {\n debug('send', message);\n this.sendBuffer.push(message);\n\n if (!this.sendStop) {\n this.sendSchedule();\n }\n }; // For polling transports in a situation when in the message callback,\n // new message is being send. If the sending connection was started\n // before receiving one, it is possible to saturate the network and\n // timeout due to the lack of receiving socket. To avoid that we delay\n // sending messages by some small time, in order to let receiving\n // connection be started beforehand. This is only a halfmeasure and\n // does not fix the big problem, but it does make the tests go more\n // stable on slow networks.\n\n\n BufferedSender.prototype.sendScheduleWait = function () {\n debug('sendScheduleWait');\n var self = this;\n var tref;\n\n this.sendStop = function () {\n debug('sendStop');\n self.sendStop = null;\n clearTimeout(tref);\n };\n\n tref = setTimeout(function () {\n debug('timeout');\n self.sendStop = null;\n self.sendSchedule();\n }, 25);\n };\n\n BufferedSender.prototype.sendSchedule = function () {\n debug('sendSchedule', this.sendBuffer.length);\n var self = this;\n\n if (this.sendBuffer.length > 0) {\n var payload = '[' + this.sendBuffer.join(',') + ']';\n this.sendStop = this.sender(this.url, payload, function (err) {\n self.sendStop = null;\n\n if (err) {\n debug('error', err);\n self.emit('close', err.code || 1006, 'Sending error: ' + err);\n self.close();\n } else {\n self.sendScheduleWait();\n }\n });\n this.sendBuffer = [];\n }\n };\n\n BufferedSender.prototype._cleanup = function () {\n debug('_cleanup');\n this.removeAllListeners();\n };\n\n BufferedSender.prototype.close = function () {\n debug('close');\n\n this._cleanup();\n\n if (this.sendStop) {\n this.sendStop();\n this.sendStop = null;\n }\n };\n\n module.exports = BufferedSender;\n }).call(this, {\n env: {}\n });\n }, {\n \"debug\": 55,\n \"events\": 3,\n \"inherits\": 57\n }],\n 26: [function (require, module, exports) {\n (function (global) {\n 'use strict';\n\n var inherits = require('inherits'),\n IframeTransport = require('../iframe'),\n objectUtils = require('../../utils/object');\n\n module.exports = function (transport) {\n function IframeWrapTransport(transUrl, baseUrl) {\n IframeTransport.call(this, transport.transportName, transUrl, baseUrl);\n }\n\n inherits(IframeWrapTransport, IframeTransport);\n\n IframeWrapTransport.enabled = function (url, info) {\n if (!global.document) {\n return false;\n }\n\n var iframeInfo = objectUtils.extend({}, info);\n iframeInfo.sameOrigin = true;\n return transport.enabled(iframeInfo) && IframeTransport.enabled();\n };\n\n IframeWrapTransport.transportName = 'iframe-' + transport.transportName;\n IframeWrapTransport.needBody = true;\n IframeWrapTransport.roundTrips = IframeTransport.roundTrips + transport.roundTrips - 1; // html, javascript (2) + transport - no CORS (1)\n\n IframeWrapTransport.facadeTransport = transport;\n return IframeWrapTransport;\n };\n }).call(this, typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {});\n }, {\n \"../../utils/object\": 49,\n \"../iframe\": 22,\n \"inherits\": 57\n }],\n 27: [function (require, module, exports) {\n (function (process) {\n 'use strict';\n\n var inherits = require('inherits'),\n EventEmitter = require('events').EventEmitter;\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:polling');\n }\n\n function Polling(Receiver, receiveUrl, AjaxObject) {\n debug(receiveUrl);\n EventEmitter.call(this);\n this.Receiver = Receiver;\n this.receiveUrl = receiveUrl;\n this.AjaxObject = AjaxObject;\n\n this._scheduleReceiver();\n }\n\n inherits(Polling, EventEmitter);\n\n Polling.prototype._scheduleReceiver = function () {\n debug('_scheduleReceiver');\n var self = this;\n var poll = this.poll = new this.Receiver(this.receiveUrl, this.AjaxObject);\n poll.on('message', function (msg) {\n debug('message', msg);\n self.emit('message', msg);\n });\n poll.once('close', function (code, reason) {\n debug('close', code, reason, self.pollIsClosing);\n self.poll = poll = null;\n\n if (!self.pollIsClosing) {\n if (reason === 'network') {\n self._scheduleReceiver();\n } else {\n self.emit('close', code || 1006, reason);\n self.removeAllListeners();\n }\n }\n });\n };\n\n Polling.prototype.abort = function () {\n debug('abort');\n this.removeAllListeners();\n this.pollIsClosing = true;\n\n if (this.poll) {\n this.poll.abort();\n }\n };\n\n module.exports = Polling;\n }).call(this, {\n env: {}\n });\n }, {\n \"debug\": 55,\n \"events\": 3,\n \"inherits\": 57\n }],\n 28: [function (require, module, exports) {\n (function (process) {\n 'use strict';\n\n var inherits = require('inherits'),\n urlUtils = require('../../utils/url'),\n BufferedSender = require('./buffered-sender'),\n Polling = require('./polling');\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:sender-receiver');\n }\n\n function SenderReceiver(transUrl, urlSuffix, senderFunc, Receiver, AjaxObject) {\n var pollUrl = urlUtils.addPath(transUrl, urlSuffix);\n debug(pollUrl);\n var self = this;\n BufferedSender.call(this, transUrl, senderFunc);\n this.poll = new Polling(Receiver, pollUrl, AjaxObject);\n this.poll.on('message', function (msg) {\n debug('poll message', msg);\n self.emit('message', msg);\n });\n this.poll.once('close', function (code, reason) {\n debug('poll close', code, reason);\n self.poll = null;\n self.emit('close', code, reason);\n self.close();\n });\n }\n\n inherits(SenderReceiver, BufferedSender);\n\n SenderReceiver.prototype.close = function () {\n BufferedSender.prototype.close.call(this);\n debug('close');\n this.removeAllListeners();\n\n if (this.poll) {\n this.poll.abort();\n this.poll = null;\n }\n };\n\n module.exports = SenderReceiver;\n }).call(this, {\n env: {}\n });\n }, {\n \"../../utils/url\": 52,\n \"./buffered-sender\": 25,\n \"./polling\": 27,\n \"debug\": 55,\n \"inherits\": 57\n }],\n 29: [function (require, module, exports) {\n (function (process) {\n 'use strict';\n\n var inherits = require('inherits'),\n EventEmitter = require('events').EventEmitter,\n EventSourceDriver = require('eventsource');\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:receiver:eventsource');\n }\n\n function EventSourceReceiver(url) {\n debug(url);\n EventEmitter.call(this);\n var self = this;\n var es = this.es = new EventSourceDriver(url);\n\n es.onmessage = function (e) {\n debug('message', e.data);\n self.emit('message', decodeURI(e.data));\n };\n\n es.onerror = function (e) {\n debug('error', es.readyState, e); // ES on reconnection has readyState = 0 or 1.\n // on network error it's CLOSED = 2\n\n var reason = es.readyState !== 2 ? 'network' : 'permanent';\n\n self._cleanup();\n\n self._close(reason);\n };\n }\n\n inherits(EventSourceReceiver, EventEmitter);\n\n EventSourceReceiver.prototype.abort = function () {\n debug('abort');\n\n this._cleanup();\n\n this._close('user');\n };\n\n EventSourceReceiver.prototype._cleanup = function () {\n debug('cleanup');\n var es = this.es;\n\n if (es) {\n es.onmessage = es.onerror = null;\n es.close();\n this.es = null;\n }\n };\n\n EventSourceReceiver.prototype._close = function (reason) {\n debug('close', reason);\n var self = this; // Safari and chrome < 15 crash if we close window before\n // waiting for ES cleanup. See:\n // https://code.google.com/p/chromium/issues/detail?id=89155\n\n setTimeout(function () {\n self.emit('close', null, reason);\n self.removeAllListeners();\n }, 200);\n };\n\n module.exports = EventSourceReceiver;\n }).call(this, {\n env: {}\n });\n }, {\n \"debug\": 55,\n \"events\": 3,\n \"eventsource\": 18,\n \"inherits\": 57\n }],\n 30: [function (require, module, exports) {\n (function (process, global) {\n 'use strict';\n\n var inherits = require('inherits'),\n iframeUtils = require('../../utils/iframe'),\n urlUtils = require('../../utils/url'),\n EventEmitter = require('events').EventEmitter,\n random = require('../../utils/random');\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:receiver:htmlfile');\n }\n\n function HtmlfileReceiver(url) {\n debug(url);\n EventEmitter.call(this);\n var self = this;\n iframeUtils.polluteGlobalNamespace();\n this.id = 'a' + random.string(6);\n url = urlUtils.addQuery(url, 'c=' + decodeURIComponent(iframeUtils.WPrefix + '.' + this.id));\n debug('using htmlfile', HtmlfileReceiver.htmlfileEnabled);\n var constructFunc = HtmlfileReceiver.htmlfileEnabled ? iframeUtils.createHtmlfile : iframeUtils.createIframe;\n global[iframeUtils.WPrefix][this.id] = {\n start: function () {\n debug('start');\n self.iframeObj.loaded();\n },\n message: function (data) {\n debug('message', data);\n self.emit('message', data);\n },\n stop: function () {\n debug('stop');\n\n self._cleanup();\n\n self._close('network');\n }\n };\n this.iframeObj = constructFunc(url, function () {\n debug('callback');\n\n self._cleanup();\n\n self._close('permanent');\n });\n }\n\n inherits(HtmlfileReceiver, EventEmitter);\n\n HtmlfileReceiver.prototype.abort = function () {\n debug('abort');\n\n this._cleanup();\n\n this._close('user');\n };\n\n HtmlfileReceiver.prototype._cleanup = function () {\n debug('_cleanup');\n\n if (this.iframeObj) {\n this.iframeObj.cleanup();\n this.iframeObj = null;\n }\n\n delete global[iframeUtils.WPrefix][this.id];\n };\n\n HtmlfileReceiver.prototype._close = function (reason) {\n debug('_close', reason);\n this.emit('close', null, reason);\n this.removeAllListeners();\n };\n\n HtmlfileReceiver.htmlfileEnabled = false; // obfuscate to avoid firewalls\n\n var axo = ['Active'].concat('Object').join('X');\n\n if (axo in global) {\n try {\n HtmlfileReceiver.htmlfileEnabled = !!new global[axo]('htmlfile');\n } catch (x) {// intentionally empty\n }\n }\n\n HtmlfileReceiver.enabled = HtmlfileReceiver.htmlfileEnabled || iframeUtils.iframeEnabled;\n module.exports = HtmlfileReceiver;\n }).call(this, {\n env: {}\n }, typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {});\n }, {\n \"../../utils/iframe\": 47,\n \"../../utils/random\": 50,\n \"../../utils/url\": 52,\n \"debug\": 55,\n \"events\": 3,\n \"inherits\": 57\n }],\n 31: [function (require, module, exports) {\n (function (process, global) {\n 'use strict';\n\n var utils = require('../../utils/iframe'),\n random = require('../../utils/random'),\n browser = require('../../utils/browser'),\n urlUtils = require('../../utils/url'),\n inherits = require('inherits'),\n EventEmitter = require('events').EventEmitter;\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:receiver:jsonp');\n }\n\n function JsonpReceiver(url) {\n debug(url);\n var self = this;\n EventEmitter.call(this);\n utils.polluteGlobalNamespace();\n this.id = 'a' + random.string(6);\n var urlWithId = urlUtils.addQuery(url, 'c=' + encodeURIComponent(utils.WPrefix + '.' + this.id));\n global[utils.WPrefix][this.id] = this._callback.bind(this);\n\n this._createScript(urlWithId); // Fallback mostly for Konqueror - stupid timer, 35 seconds shall be plenty.\n\n\n this.timeoutId = setTimeout(function () {\n debug('timeout');\n\n self._abort(new Error('JSONP script loaded abnormally (timeout)'));\n }, JsonpReceiver.timeout);\n }\n\n inherits(JsonpReceiver, EventEmitter);\n\n JsonpReceiver.prototype.abort = function () {\n debug('abort');\n\n if (global[utils.WPrefix][this.id]) {\n var err = new Error('JSONP user aborted read');\n err.code = 1000;\n\n this._abort(err);\n }\n };\n\n JsonpReceiver.timeout = 35000;\n JsonpReceiver.scriptErrorTimeout = 1000;\n\n JsonpReceiver.prototype._callback = function (data) {\n debug('_callback', data);\n\n this._cleanup();\n\n if (this.aborting) {\n return;\n }\n\n if (data) {\n debug('message', data);\n this.emit('message', data);\n }\n\n this.emit('close', null, 'network');\n this.removeAllListeners();\n };\n\n JsonpReceiver.prototype._abort = function (err) {\n debug('_abort', err);\n\n this._cleanup();\n\n this.aborting = true;\n this.emit('close', err.code, err.message);\n this.removeAllListeners();\n };\n\n JsonpReceiver.prototype._cleanup = function () {\n debug('_cleanup');\n clearTimeout(this.timeoutId);\n\n if (this.script2) {\n this.script2.parentNode.removeChild(this.script2);\n this.script2 = null;\n }\n\n if (this.script) {\n var script = this.script; // Unfortunately, you can't really abort script loading of\n // the script.\n\n script.parentNode.removeChild(script);\n script.onreadystatechange = script.onerror = script.onload = script.onclick = null;\n this.script = null;\n }\n\n delete global[utils.WPrefix][this.id];\n };\n\n JsonpReceiver.prototype._scriptError = function () {\n debug('_scriptError');\n var self = this;\n\n if (this.errorTimer) {\n return;\n }\n\n this.errorTimer = setTimeout(function () {\n if (!self.loadedOkay) {\n self._abort(new Error('JSONP script loaded abnormally (onerror)'));\n }\n }, JsonpReceiver.scriptErrorTimeout);\n };\n\n JsonpReceiver.prototype._createScript = function (url) {\n debug('_createScript', url);\n var self = this;\n var script = this.script = global.document.createElement('script');\n var script2; // Opera synchronous load trick.\n\n script.id = 'a' + random.string(8);\n script.src = url;\n script.type = 'text/javascript';\n script.charset = 'UTF-8';\n script.onerror = this._scriptError.bind(this);\n\n script.onload = function () {\n debug('onload');\n\n self._abort(new Error('JSONP script loaded abnormally (onload)'));\n }; // IE9 fires 'error' event after onreadystatechange or before, in random order.\n // Use loadedOkay to determine if actually errored\n\n\n script.onreadystatechange = function () {\n debug('onreadystatechange', script.readyState);\n\n if (/loaded|closed/.test(script.readyState)) {\n if (script && script.htmlFor && script.onclick) {\n self.loadedOkay = true;\n\n try {\n // In IE, actually execute the script.\n script.onclick();\n } catch (x) {// intentionally empty\n }\n }\n\n if (script) {\n self._abort(new Error('JSONP script loaded abnormally (onreadystatechange)'));\n }\n }\n }; // IE: event/htmlFor/onclick trick.\n // One can't rely on proper order for onreadystatechange. In order to\n // make sure, set a 'htmlFor' and 'event' properties, so that\n // script code will be installed as 'onclick' handler for the\n // script object. Later, onreadystatechange, manually execute this\n // code. FF and Chrome doesn't work with 'event' and 'htmlFor'\n // set. For reference see:\n // http://jaubourg.net/2010/07/loading-script-as-onclick-handler-of.html\n // Also, read on that about script ordering:\n // http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order\n\n\n if (typeof script.async === 'undefined' && global.document.attachEvent) {\n // According to mozilla docs, in recent browsers script.async defaults\n // to 'true', so we may use it to detect a good browser:\n // https://developer.mozilla.org/en/HTML/Element/script\n if (!browser.isOpera()) {\n // Naively assume we're in IE\n try {\n script.htmlFor = script.id;\n script.event = 'onclick';\n } catch (x) {// intentionally empty\n }\n\n script.async = true;\n } else {\n // Opera, second sync script hack\n script2 = this.script2 = global.document.createElement('script');\n script2.text = \"try{var a = document.getElementById('\" + script.id + \"'); if(a)a.onerror();}catch(x){};\";\n script.async = script2.async = false;\n }\n }\n\n if (typeof script.async !== 'undefined') {\n script.async = true;\n }\n\n var head = global.document.getElementsByTagName('head')[0];\n head.insertBefore(script, head.firstChild);\n\n if (script2) {\n head.insertBefore(script2, head.firstChild);\n }\n };\n\n module.exports = JsonpReceiver;\n }).call(this, {\n env: {}\n }, typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {});\n }, {\n \"../../utils/browser\": 44,\n \"../../utils/iframe\": 47,\n \"../../utils/random\": 50,\n \"../../utils/url\": 52,\n \"debug\": 55,\n \"events\": 3,\n \"inherits\": 57\n }],\n 32: [function (require, module, exports) {\n (function (process) {\n 'use strict';\n\n var inherits = require('inherits'),\n EventEmitter = require('events').EventEmitter;\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:receiver:xhr');\n }\n\n function XhrReceiver(url, AjaxObject) {\n debug(url);\n EventEmitter.call(this);\n var self = this;\n this.bufferPosition = 0;\n this.xo = new AjaxObject('POST', url, null);\n this.xo.on('chunk', this._chunkHandler.bind(this));\n this.xo.once('finish', function (status, text) {\n debug('finish', status, text);\n\n self._chunkHandler(status, text);\n\n self.xo = null;\n var reason = status === 200 ? 'network' : 'permanent';\n debug('close', reason);\n self.emit('close', null, reason);\n\n self._cleanup();\n });\n }\n\n inherits(XhrReceiver, EventEmitter);\n\n XhrReceiver.prototype._chunkHandler = function (status, text) {\n debug('_chunkHandler', status);\n\n if (status !== 200 || !text) {\n return;\n }\n\n for (var idx = -1;; this.bufferPosition += idx + 1) {\n var buf = text.slice(this.bufferPosition);\n idx = buf.indexOf('\\n');\n\n if (idx === -1) {\n break;\n }\n\n var msg = buf.slice(0, idx);\n\n if (msg) {\n debug('message', msg);\n this.emit('message', msg);\n }\n }\n };\n\n XhrReceiver.prototype._cleanup = function () {\n debug('_cleanup');\n this.removeAllListeners();\n };\n\n XhrReceiver.prototype.abort = function () {\n debug('abort');\n\n if (this.xo) {\n this.xo.close();\n debug('close');\n this.emit('close', null, 'user');\n this.xo = null;\n }\n\n this._cleanup();\n };\n\n module.exports = XhrReceiver;\n }).call(this, {\n env: {}\n });\n }, {\n \"debug\": 55,\n \"events\": 3,\n \"inherits\": 57\n }],\n 33: [function (require, module, exports) {\n (function (process, global) {\n 'use strict';\n\n var random = require('../../utils/random'),\n urlUtils = require('../../utils/url');\n\n var debug = function () {};\n\n if (process.env.NODE_ENV !== 'production') {\n debug = require('debug')('sockjs-client:sender:jsonp');\n }\n\n var form, area;\n\n function createIframe(id) {\n debug('createIframe', id);\n\n try {\n // ie6 dynamic iframes with target=\"\" support (thanks Chris Lambacher)\n return global.document.createElement('