UNPKG

36.7 kBJavaScriptView Raw
1!function(e,t,n,r){t[e]=n.call(t);for(var o=0;o<r.length;o++)r[o](t[e]);"undefined"!=typeof module&&module.exports?module.exports=t[e]:"function"==typeof define&&define.amd&&define(function(){return t[e]})}("Primus",this||{},function(){return function i(s,c,a){function u(t,e){if(!c[t]){if(!s[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(f)return f(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var o=c[t]={exports:{}};s[t][0].call(o.exports,function(e){return u(s[t][1][e]||e)},o,o.exports,i,s,c,a)}return c[t].exports}for(var f="function"==typeof require&&require,e=0;e<a.length;e++)u(a[e]);return u}({1:[function(e,t,n){"use strict";t.exports=function(r,i){var s=/[, ]+/;function o(e,t){if(i[e]){if("string"==typeof i[e]&&(i[e]=i[e].split(s)),"function"==typeof i[e])return i[e].call(t);for(var n,r,o=0;o<i[e].length;o++)"function"==(n=typeof(r=i[e][o]))?r.call(t):"string"==n&&"function"==typeof t[r]&&t[r]()}}return i=i||{},"string"==typeof(r=r||[])&&(r=r.split(s)),function(){var e,t=this,n=0;if(null===t[r[0]])return!1;for(o("before",t);n<r.length;n++)t[e=r[n]]&&("function"==typeof t[e].destroy&&t[e].destroy(),t[e]=null);return t.emit&&t.emit("destroy"),o("after",t),!0}}},{}],2:[function(e,t,n){"use strict";t.exports=function(){for(var r,o=this,e=0,t=arguments.length,i=new Array(t);e<t;e++)i[e]=arguments[e];return"function"!=typeof i[i.length-1]?function(){for(var e=0,t=arguments.length,n=new Array(t);e<t;e++)n[e]=arguments[e];return o.emit.apply(o,i.concat(n))}:(r=i.pop(),function(){for(var e=0,t=arguments.length,n=new Array(t+1);e<t;e++)n[e+1]=arguments[e];return n[0]=function(e,t){if(e)return o.emit("error",e);n=void 0===t?n.slice(1):null===t?[]:t,o.emit.apply(o,i.concat(n))},r.apply(o,n),!0})}},{}],3:[function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty,h="~";function o(){}function c(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,n,r,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var i=new c(n,r||e,o),s=h?h+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function u(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function s(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(h=!1)),s.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(h?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},s.prototype.listeners=function(e){var t=h?h+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,o=n.length,i=new Array(o);r<o;r++)i[r]=n[r].fn;return i},s.prototype.listenerCount=function(e){var t=h?h+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,r,o,i){var s=h?h+e:e;if(!this._events[s])return!1;var c,a,u=this._events[s],f=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),f){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,r),!0;case 5:return u.fn.call(u.context,t,n,r,o),!0;case 6:return u.fn.call(u.context,t,n,r,o,i),!0}for(a=1,c=new Array(f-1);a<f;a++)c[a-1]=arguments[a];u.fn.apply(u.context,c)}else{var l,p=u.length;for(a=0;a<p;a++)switch(u[a].once&&this.removeListener(e,u[a].fn,void 0,!0),f){case 1:u[a].fn.call(u[a].context);break;case 2:u[a].fn.call(u[a].context,t);break;case 3:u[a].fn.call(u[a].context,t,n);break;case 4:u[a].fn.call(u[a].context,t,n,r);break;default:if(!c)for(l=1,c=new Array(f-1);l<f;l++)c[l-1]=arguments[l];u[a].fn.apply(u[a].context,c)}}return!0},s.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,n,r){var o=h?h+e:e;if(!this._events[o])return this;if(!t)return u(this,o),this;var i=this._events[o];if(i.fn)i.fn!==t||r&&!i.once||n&&i.context!==n||u(this,o);else{for(var s=0,c=[],a=i.length;s<a;s++)(i[s].fn!==t||r&&!i[s].once||n&&i[s].context!==n)&&c.push(i[s]);c.length?this._events[o]=1===c.length?c[0]:c:u(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=h?h+e:e,this._events[t]&&u(this,t)):(this._events=new o,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=h,s.EventEmitter=s,void 0!==t&&(t.exports=s)},{}],4:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;function n(){}n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],5:[function(e,t,n){"use strict";var o=new RegExp("^((?:\\d+)?\\.?\\d+) *("+["milliseconds?","msecs?","ms","seconds?","secs?","s","minutes?","mins?","m","hours?","hrs?","h","days?","d","weeks?","wks?","w","years?","yrs?","y"].join("|")+")?$","i");t.exports=function(e){var t,n,r=typeof e;if("number"==r)return e;if("string"!=r||"0"===e||!e)return 0;if(+e)return+e;if(1e4<e.length||!(n=o.exec(e)))return 0;switch(t=parseFloat(n[1]),n[2].toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 31536e6*t;case"weeks":case"week":case"wks":case"wk":case"w":return 6048e5*t;case"days":case"day":case"d":return 864e5*t;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*t;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*t;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*t;default:return t}}},{}],6:[function(e,t,n){"use strict";t.exports=function(e){var t,n=0;function r(){return n||(n=1,t=e.apply(this,arguments),e=null),t}return r.displayName=e.displayName||e.name||r.displayName||r.name,r}},{}],7:[function(e,t,n){var r,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function c(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{o="function"==typeof clearTimeout?clearTimeout:c}catch(e){o=c}}();var u,f=[],l=!1,p=-1;function h(){l&&u&&(l=!1,u.length?f=u.concat(f):p=-1,f.length&&m())}function m(){if(!l){var e=a(h);l=!0;for(var t=f.length;t;){for(u=f,f=[];++p<t;)u&&u[p].run();p=-1,t=f.length}u=null,l=!1,function(t){if(o===clearTimeout)return clearTimeout(t);if((o===c||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(t);try{o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new d(e,t)),1!==f.length||l||a(m)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],8:[function(e,t,n){"use strict";var i=Object.prototype.hasOwnProperty;function s(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}n.stringify=function(e,t){t=t||"";var n,r,o=[];for(r in"string"!=typeof t&&(t="?"),e)if(i.call(e,r)){if((n=e[r])||null!=n&&!isNaN(n)||(n=""),r=encodeURIComponent(r),n=encodeURIComponent(n),null===r||null===n)continue;o.push(r+"="+n)}return o.length?t+o.join("&"):""},n.parse=function(e){for(var t,n=/([^=?&]+)=?([^&]*)/g,r={};t=n.exec(e);){var o=s(t[1]),i=s(t[2]);null===o||null===i||o in r||(r[o]=i)}return r}},{}],9:[function(e,t,n){"use strict";var r=e("eventemitter3"),o=e("millisecond"),i=e("demolish"),s=e("tick-tock"),c=e("one-time");function a(e,t,n){return o(e in n?n[e]:e in t?t[e]:u[e])}function u(e){var t=this;if(!(t instanceof u))return new u(e);e=e||{},t.attempt=null,t._fn=null,t["reconnect timeout"]=a("reconnect timeout",t,e),t.retries=a("retries",t,e),t.factor=a("factor",t,e),t.max=a("max",t,e),t.min=a("min",t,e),t.timers=new s(t)}((u.prototype=new r).constructor=u)["reconnect timeout"]="30 seconds",u.max=1/0,u.min="500 ms",u.retries=10,u.factor=2,u.prototype.reconnect=function(){var n=this;return n.backoff(function(e,t){if(t.duration=new Date-t.start,e)return n.emit("reconnect failed",e,t);n.emit("reconnected",t)},n.attempt)},u.prototype.backoff=function(n,r){var o=this;return(r=r||o.attempt||{}).backoff?o:(r["reconnect timeout"]=a("reconnect timeout",o,r),r.retries=a("retries",o,r),r.factor=a("factor",o,r),r.max=a("max",o,r),r.min=a("min",o,r),r.start=+r.start||+new Date,r.duration=+r.duration||0,r.attempt=+r.attempt||0,r.attempt===r.retries?n.call(o,new Error("Unable to recover"),r):(r.backoff=!0,r.attempt++,(o.attempt=r).scheduled=1!==r.attempt?Math.min(Math.round((Math.random()+1)*r.min*Math.pow(r.factor,r.attempt-1)),r.max):r.min,o.timers.setTimeout("reconnect",function(){r.duration=new Date-r.start,r.backoff=!1,o.timers.clear("reconnect, timeout");var t=o._fn=c(function(e){if(o.reset(),e)return o.backoff(n,r);n.call(o,void 0,r)});o.emit("reconnect",r,t),o.timers.setTimeout("timeout",function(){var e=new Error("Failed to reconnect in a timely manner");r.duration=new Date-r.start,o.emit("reconnect timeout",e,r),t(e)},r["reconnect timeout"])},r.scheduled),o.emit("reconnect scheduled",r)),o)},u.prototype.reconnecting=function(){return!!this.attempt},u.prototype.reconnected=function(e){return this._fn&&this._fn(e),this},u.prototype.reset=function(){return this._fn=this.attempt=null,this.timers.clear("reconnect, timeout"),this},u.prototype.destroy=i("timers attempt _fn"),t.exports=u},{demolish:1,eventemitter3:10,millisecond:5,"one-time":6,"tick-tock":12}],10:[function(e,t,n){"use strict";var h="function"!=typeof Object.create&&"~";function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function r(){}r.prototype._events=void 0,r.prototype.listeners=function(e,t){var n=h?h+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o<i;o++)s[o]=r[o].fn;return s},r.prototype.emit=function(e,t,n,r,o,i){var s=h?h+e:e;if(!this._events||!this._events[s])return!1;var c,a,u=this._events[s],f=arguments.length;if("function"==typeof u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),f){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,r),!0;case 5:return u.fn.call(u.context,t,n,r,o),!0;case 6:return u.fn.call(u.context,t,n,r,o,i),!0}for(a=1,c=new Array(f-1);a<f;a++)c[a-1]=arguments[a];u.fn.apply(u.context,c)}else{var l,p=u.length;for(a=0;a<p;a++)switch(u[a].once&&this.removeListener(e,u[a].fn,void 0,!0),f){case 1:u[a].fn.call(u[a].context);break;case 2:u[a].fn.call(u[a].context,t);break;case 3:u[a].fn.call(u[a].context,t,n);break;default:if(!c)for(l=1,c=new Array(f-1);l<f;l++)c[l-1]=arguments[l];u[a].fn.apply(u[a].context,c)}}return!0},r.prototype.on=function(e,t,n){var r=new i(t,n||this),o=h?h+e:e;return this._events||(this._events=h?{}:Object.create(null)),this._events[o]?this._events[o].fn?this._events[o]=[this._events[o],r]:this._events[o].push(r):this._events[o]=r,this},r.prototype.once=function(e,t,n){var r=new i(t,n||this,!0),o=h?h+e:e;return this._events||(this._events=h?{}:Object.create(null)),this._events[o]?this._events[o].fn?this._events[o]=[this._events[o],r]:this._events[o].push(r):this._events[o]=r,this},r.prototype.removeListener=function(e,t,n,r){var o=h?h+e:e;if(!this._events||!this._events[o])return this;var i=this._events[o],s=[];if(t)if(i.fn)(i.fn!==t||r&&!i.once||n&&i.context!==n)&&s.push(i);else for(var c=0,a=i.length;c<a;c++)(i[c].fn!==t||r&&!i[c].once||n&&i[c].context!==n)&&s.push(i[c]);return s.length?this._events[o]=1===s.length?s[0]:s:delete this._events[o],this},r.prototype.removeAllListeners=function(e){return this._events&&(e?delete this._events[h?h+e:e]:this._events=h?{}:Object.create(null)),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prototype.setMaxListeners=function(){return this},r.prefixed=h,void 0!==t&&(t.exports=r)},{}],11:[function(e,t,n){"use strict";t.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},{}],12:[function(e,f,t){(function(r,t){"use strict";var i=Object.prototype.hasOwnProperty,s=e("millisecond");function c(e,t,n,r){this.start=+new Date,this.duration=n,this.clear=t,this.timer=e,this.fns=[r]}function a(e){clearTimeout(e)}function u(e){clearInterval(e)}function o(e){t(e)}function n(e){if(!(this instanceof n))return new n(e);this.timers={},this.context=e||this}c.prototype.remaining=function(){return this.duration-this.taken()},c.prototype.taken=function(){return new Date-this.start},n.prototype.tock=function(r,o){var i=this;return function(){if(r in i.timers){var e=i.timers[r].fns.slice(),t=e.length,n=0;for(o?i.clear(r):i.start=+new Date;n<t;n++)e[n].call(i.context)}}},n.prototype.setTimeout=function(e,t,n){var r,o=this;return o.timers[e]?o.timers[e].fns.push(t):(r=s(n),o.timers[e]=new c(setTimeout(o.tock(e,!0),s(n)),a,r,t)),o},n.prototype.setInterval=function(e,t,n){var r,o=this;return o.timers[e]?o.timers[e].fns.push(t):(r=s(n),o.timers[e]=new c(setInterval(o.tock(e),s(n)),u,r,t)),o},n.prototype.setImmediate=function(e,t){var n=this;return"function"!=typeof r?n.setTimeout(e,t,0):(n.timers[e]?n.timers[e].fns.push(t):n.timers[e]=new c(r(n.tock(e,!0)),o,0,t),n)},n.prototype.active=function(e){return e in this.timers},n.prototype.clear=function(){var e,t,n,r=arguments.length?arguments:[],o=this;if(1===r.length&&"string"==typeof r[0]&&(r=r[0].split(/[, ]+/)),!r.length)for(e in o.timers)i.call(o.timers,e)&&r.push(e);for(t=0,n=r.length;t<n;t++)(e=o.timers[r[t]])&&(e.clear(e.timer),e.fns=e.timer=e.clear=null,delete o.timers[r[t]]);return o},n.prototype.adjust=function(e,t){var n,r=s(t),o=this.timers[e];return o&&(n=o.clear===u,o.clear(o.timer),o.start=+new Date,o.duration=r,o.timer=(n?setInterval:setTimeout)(this.tock(e,!n),r)),this},n.prototype.end=n.prototype.destroy=function(){return!!this.context&&(this.clear(),this.context=this.timers=null,!0)},n.Timer=c,f.exports=n}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{millisecond:5,timers:13}],13:[function(a,e,u){(function(e,t){var r=a("process/browser.js").nextTick,n=Function.prototype.apply,o=Array.prototype.slice,i={},s=0;function c(e,t){this._id=e,this._clearFn=t}u.setTimeout=function(){return new c(n.call(setTimeout,window,arguments),clearTimeout)},u.setInterval=function(){return new c(n.call(setInterval,window,arguments),clearInterval)},u.clearTimeout=u.clearInterval=function(e){e.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},u.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},u.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},u._unrefActive=u.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;0<=t&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},u.setImmediate="function"==typeof e?e:function(e){var t=s++,n=!(arguments.length<2)&&o.call(arguments,1);return i[t]=!0,r(function(){i[t]&&(n?e.apply(null,n):e.call(null),u.clearImmediate(t))}),t},u.clearImmediate="function"==typeof t?t:function(e){delete i[e]}}).call(this,a("timers").setImmediate,a("timers").clearImmediate)},{"process/browser.js":7,timers:13}],14:[function(e,r,t){(function(i){"use strict";var h=e("requires-port"),m=e("querystringify"),s=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,n=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,t=new RegExp("^[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]+");function d(e){return(e||"").toString().replace(t,"")}var y=[["#","hash"],["?","query"],function(e){return e.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],c={hash:1,query:1};function v(e){var t,n=("undefined"!=typeof window?window:void 0!==i?i:"undefined"!=typeof self?self:{}).location||{},r={},o=typeof(e=e||n);if("blob:"===e.protocol)r=new w(unescape(e.pathname),{});else if("string"==o)for(t in r=new w(e,{}),c)delete r[t];else if("object"==o){for(t in e)t in c||(r[t]=e[t]);void 0===r.slashes&&(r.slashes=s.test(e.href))}return r}function g(e){e=d(e);var t=n.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!t[2],rest:t[3]}}function w(e,t,n){if(e=d(e),!(this instanceof w))return new w(e,t,n);var r,o,i,s,c,a,u=y.slice(),f=typeof t,l=this,p=0;for("object"!=f&&"string"!=f&&(n=t,t=null),n&&"function"!=typeof n&&(n=m.parse),t=v(t),r=!(o=g(e||"")).protocol&&!o.slashes,l.slashes=o.slashes||r&&t.slashes,l.protocol=o.protocol||t.protocol||"",e=o.rest,o.slashes||(u[3]=[/(.*)/,"pathname"]);p<u.length;p++)"function"!=typeof(s=u[p])?(i=s[0],a=s[1],i!=i?l[a]=e:"string"==typeof i?~(c=e.indexOf(i))&&(e="number"==typeof s[2]?(l[a]=e.slice(0,c),e.slice(c+s[2])):(l[a]=e.slice(c),e.slice(0,c))):(c=i.exec(e))&&(l[a]=c[1],e=e.slice(0,c.index)),l[a]=l[a]||r&&s[3]&&t[a]||"",s[4]&&(l[a]=l[a].toLowerCase())):e=s(e);n&&(l.query=n(l.query)),r&&t.slashes&&"/"!==l.pathname.charAt(0)&&(""!==l.pathname||""!==t.pathname)&&(l.pathname=function(e,t){if(""===e)return t;for(var n=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=n.length,o=n[r-1],i=!1,s=0;r--;)"."===n[r]?n.splice(r,1):".."===n[r]?(n.splice(r,1),s++):s&&(0===r&&(i=!0),n.splice(r,1),s--);return i&&n.unshift(""),"."!==o&&".."!==o||n.push(""),n.join("/")}(l.pathname,t.pathname)),h(l.port,l.protocol)||(l.host=l.hostname,l.port=""),l.username=l.password="",l.auth&&(s=l.auth.split(":"),l.username=s[0]||"",l.password=s[1]||""),l.origin=l.protocol&&l.host&&"file:"!==l.protocol?l.protocol+"//"+l.host:"null",l.href=l.toString()}w.prototype={set:function(e,t,n){var r=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(n||m.parse)(t)),r[e]=t;break;case"port":r[e]=t,h(t,r.protocol)?t&&(r.host=r.hostname+":"+t):(r.host=r.hostname,r[e]="");break;case"hostname":r[e]=t,r.port&&(t+=":"+r.port),r.host=t;break;case"host":r[e]=t,/:\d+$/.test(t)?(t=t.split(":"),r.port=t.pop(),r.hostname=t.join(":")):(r.hostname=t,r.port="");break;case"protocol":r.protocol=t.toLowerCase(),r.slashes=!n;break;case"pathname":case"hash":if(t){var o="pathname"===e?"/":"#";r[e]=t.charAt(0)!==o?o+t:t}else r[e]=t;break;default:r[e]=t}for(var i=0;i<y.length;i++){var s=y[i];s[4]&&(r[s[1]]=r[s[1]].toLowerCase())}return r.origin=r.protocol&&r.host&&"file:"!==r.protocol?r.protocol+"//"+r.host:"null",r.href=r.toString(),r},toString:function(e){e&&"function"==typeof e||(e=m.stringify);var t,n=this,r=n.protocol;r&&":"!==r.charAt(r.length-1)&&(r+=":");var o=r+(n.slashes?"//":"");return n.username&&(o+=n.username,n.password&&(o+=":"+n.password),o+="@"),o+=n.host+n.pathname,(t="object"==typeof n.query?e(n.query):n.query)&&(o+="?"!==t.charAt(0)?"?"+t:t),n.hash&&(o+=n.hash),o}},w.extractProtocol=g,w.location=v,w.trimLeft=d,w.qs=m,r.exports=w}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{querystringify:8,"requires-port":11}],15:[function(e,t,n){"use strict";var r,o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),i=64,s={},c=0,a=0;function u(e){for(var t="";t=o[e%i]+t,0<(e=Math.floor(e/i)););return t}function f(){var e=u(+new Date);return e!==r?(c=0,r=e):e+"."+u(c++)}for(;a<i;a++)s[o[a]]=a;f.encode=u,f.decode=function(e){var t=0;for(a=0;a<e.length;a++)t=t*i+s[e.charAt(a)];return t},t.exports=f},{}],16:[function(t,e,n){"use strict";var r,o=t("eventemitter3"),i=t("tick-tock"),s=t("recovery"),c=t("querystringify"),a=t("inherits"),u=t("demolish"),f=t("yeast"),l=/\u2028/g,p=/\u2029/g;function h(e,t){if(!(e instanceof m)){var n=new Error("Primus#"+t+"'s context should called with a Primus instance");if("function"!=typeof e.listeners||!e.listeners("error").length)throw n;e.emit("error",n)}}try{r=location.origin?location.origin:location.protocol+"//"+location.host}catch(e){r="http://127.0.0.1"}function m(e,t){if(!(this instanceof m))return new m(e,t);if(m.Stream.call(this),"function"!=typeof this.client)return this.critical(new Error("The client library has not been compiled correctly, see https://github.com/primus/primus#client-library for more details"));if("object"==typeof e?e=(t=e).url||t.uri||r:t=t||{},"ping"in t||"pong"in t)return this.critical(new Error("The `ping` and `pong` options have been removed"));var n=this;t.queueSize="queueSize"in t?t.queueSize:1/0,t.timeout="timeout"in t?t.timeout:1e4,t.reconnect="reconnect"in t?t.reconnect:{},t.pingTimeout="pingTimeout"in t?t.pingTimeout:45e3,t.strategy="strategy"in t?t.strategy:[],t.transport="transport"in t?t.transport:{},n.buffer=[],n.writable=!0,n.readable=!0,n.url=n.parse(e||r),n.readyState=m.CLOSED,n.options=t,n.timers=new i(this),n.socket=null,n.disconnect=!1,n.transport=t.transport,n.transformers={outgoing:[],incoming:[]},n.recovery=new s(t.reconnect),"string"==typeof t.strategy&&(t.strategy=t.strategy.split(/\s?,\s?/g)),!1===t.strategy?t.strategy=[]:t.strategy.length||(t.strategy.push("disconnect","online"),this.authorization||t.strategy.push("timeout")),t.strategy=t.strategy.join(",").toLowerCase(),"websockets"in t&&(n.AVOID_WEBSOCKETS=!t.websockets),"network"in t&&(n.NETWORK_EVENTS=t.network),t.manual||n.timers.setTimeout("open",function(){n.timers.clear("open"),n.open()},0),n.initialise(t)}m.requires=m.require=function(e){if("function"==typeof t)return t(e)};try{m.Stream=m.requires("stream")}catch(e){}m.Stream||(m.Stream=o),a(m,m.Stream),m.OPENING=1,m.CLOSED=2,m.OPEN=3,m.prototype.AVOID_WEBSOCKETS=!1,m.prototype.NETWORK_EVENTS=!1,m.prototype.online=!0;try{(m.prototype.NETWORK_EVENTS="onLine"in navigator&&(window.addEventListener||document.body.attachEvent))&&(navigator.onLine||(m.prototype.online=!1))}catch(e){}if(m.prototype.ark={},m.prototype.emits=t("emits"),m.prototype.plugin=function(e){if(h(this,"plugin"),e)return this.ark[e];var t={};for(e in this.ark)t[e]=this.ark[e];return t},(m.prototype.reserved=function(e){return/^(incoming|outgoing)::/.test(e)||e in this.reserved.events}).events={"reconnect scheduled":1,"reconnect timeout":1,readyStateChange:1,"reconnect failed":1,reconnected:1,reconnect:1,offline:1,timeout:1,destroy:1,online:1,error:1,close:1,open:1,data:1,end:1},m.prototype.initialise=function(e){var o=this;for(var t in o.recovery.on("reconnected",o.emits("reconnected")).on("reconnect failed",o.emits("reconnect failed",function(e){o.emit("end"),e()})).on("reconnect timeout",o.emits("reconnect timeout")).on("reconnect scheduled",o.emits("reconnect scheduled")).on("reconnect",o.emits("reconnect",function(e){o.emit("outgoing::reconnect"),e()})),o.on("outgoing::open",function(){var e=o.readyState;o.readyState=m.OPENING,e!==o.readyState&&o.emit("readyStateChange","opening")}),o.on("incoming::open",function(){var e=o.readyState;if(o.recovery.reconnecting()&&o.recovery.reconnected(),o.writable=!0,o.readable=!0,o.online||(o.online=!0,o.emit("online")),o.readyState=m.OPEN,e!==o.readyState&&o.emit("readyStateChange","open"),o.heartbeat(),o.buffer.length){var t=o.buffer.slice(),n=t.length,r=0;for(o.buffer.length=0;r<n;r++)o._write(t[r])}o.emit("open")}),o.on("incoming::ping",function(e){o.online=!0,o.heartbeat(),o.emit("outgoing::pong",e),o._write("primus::pong::"+e)}),o.on("incoming::error",function(e){var t=o.timers.active("connect"),n=e;if("string"==typeof e)n=new Error(e);else if(!(e instanceof Error)&&"object"==typeof e)for(var r in n=new Error(e.message||e.reason),e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);if(o.recovery.reconnecting())return o.recovery.reconnected(n);o.listeners("error").length&&o.emit("error",n),t&&(~o.options.strategy.indexOf("timeout")?o.recovery.reconnect():o.end())}),o.on("incoming::data",function(n){o.decoder(n,function(e,t){if(e)return o.listeners("error").length&&o.emit("error",e);o.protocol(t)||o.transforms(o,o,"incoming",t,n)})}),o.on("incoming::end",function(){var e=o.readyState;return o.disconnect?(o.disconnect=!1,o.end()):(o.readyState=m.CLOSED,e!==o.readyState&&o.emit("readyStateChange","end"),o.timers.active("connect")&&o.end(),e!==m.OPEN?!!o.recovery.reconnecting()&&o.recovery.reconnect():(this.writable=!1,this.readable=!1,this.timers.clear(),o.emit("close"),~o.options.strategy.indexOf("disconnect")?o.recovery.reconnect():(o.emit("outgoing::end"),void o.emit("end"))))}),o.client(),o.ark)o.ark[t].call(o,o,e);return o.NETWORK_EVENTS&&(o.offlineHandler=function(){o.online&&(o.online=!1,o.emit("offline"),o.end(),o.recovery.reset())},o.onlineHandler=function(){o.online||(o.online=!0,o.emit("online"),~o.options.strategy.indexOf("online")&&o.recovery.reconnect())},window.addEventListener?(window.addEventListener("offline",o.offlineHandler,!1),window.addEventListener("online",o.onlineHandler,!1)):document.body.attachEvent&&(document.body.attachEvent("onoffline",o.offlineHandler),document.body.attachEvent("ononline",o.onlineHandler))),o},m.prototype.protocol=function(e){if("string"!=typeof e||0!==e.indexOf("primus::"))return!1;var t=e.indexOf(":",8),n=e.slice(t+2);switch(e.slice(8,t)){case"ping":this.emit("incoming::ping",+n);break;case"server":"close"===n&&(this.disconnect=!0);break;case"id":this.emit("incoming::id",n);break;default:return!1}return!0},m.prototype.transforms=function(e,i,t,n,r){var s={data:n},c=e.transformers[t];return function n(r,o){var e=c[r++];if(!e)return o();if(1===e.length){if(!1===e.call(i,s))return;return n(r,o)}e.call(i,s,function(e,t){if(e)return i.emit("error",e);!1!==t&&n(r,o)})}(0,function(){if("incoming"===t)return i.emit("data",s.data,r);i._write(s.data)}),this},m.prototype.id=function(e){return this.socket&&this.socket.id?e(this.socket.id):(this._write("primus::id::"),this.once("incoming::id",e))},m.prototype.open=function(){return h(this,"open"),!this.recovery.reconnecting()&&this.options.timeout&&this.timeout(),this.emit("outgoing::open"),this},m.prototype.write=function(e){return h(this,"write"),this.transforms(this,this,"outgoing",e),!0},m.prototype._write=function(e){var n=this;return m.OPEN!==n.readyState?(this.buffer.length===this.options.queueSize&&this.buffer.splice(0,1),this.buffer.push(e),!1):(n.encoder(e,function(e,t){if(e)return n.listeners("error").length&&n.emit("error",e);"string"==typeof t&&(~t.indexOf("\u2028")&&(t=t.replace(l,"\\u2028")),~t.indexOf("\u2029")&&(t=t.replace(p,"\\u2029"))),n.emit("outgoing::data",t)}),!0)},m.prototype.heartbeat=function(){return this.options.pingTimeout&&(this.timers.clear("heartbeat"),this.timers.setTimeout("heartbeat",function(){this.online&&(this.online=!1,this.emit("offline"),this.emit("incoming::end"))},this.options.pingTimeout)),this},m.prototype.timeout=function(){var e=this;function t(){e.removeListener("error",t).removeListener("open",t).removeListener("end",t).timers.clear("connect")}return e.timers.setTimeout("connect",function(){t(),e.readyState===m.OPEN||e.recovery.reconnecting()||(e.emit("timeout"),~e.options.strategy.indexOf("timeout")?e.recovery.reconnect():e.end())},e.options.timeout),e.on("error",t).on("open",t).on("end",t)},m.prototype.end=function(e){if(h(this,"end"),this.readyState===m.CLOSED&&!this.timers.active("connect")&&!this.timers.active("open"))return this.recovery.reconnecting()&&(this.recovery.reset(),this.emit("end")),this;void 0!==e&&this.write(e),this.writable=!1,this.readable=!1;var t=this.readyState;return this.readyState=m.CLOSED,t!==this.readyState&&this.emit("readyStateChange","end"),this.timers.clear(),this.emit("outgoing::end"),this.emit("close"),this.emit("end"),this},m.prototype.destroy=u("url timers options recovery socket transport transformers",{before:"end",after:["removeAllListeners",function(){this.NETWORK_EVENTS&&(window.addEventListener?(window.removeEventListener("offline",this.offlineHandler),window.removeEventListener("online",this.onlineHandler)):document.body.attachEvent&&(document.body.detachEvent("onoffline",this.offlineHandler),document.body.detachEvent("ononline",this.onlineHandler)))}]}),m.prototype.clone=function(e){return this.merge({},e)},m.prototype.merge=function(e){for(var t,n,r=1;r<arguments.length;r++)for(t in n=arguments[r])Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e},m.prototype.parse=t("url-parse"),m.prototype.querystring=c.parse,m.prototype.querystringify=c.stringify,m.prototype.uri=function(e){var t=this.url,n=[],r=!1;e.query&&(r=!0),(e=e||{}).protocol="protocol"in e?e.protocol:"http:",e.query=!(!t.query||!r)&&t.query.slice(1),e.secure="secure"in e?e.secure:"https:"===t.protocol||"wss:"===t.protocol,e.auth="auth"in e?e.auth:t.auth,e.pathname="pathname"in e?e.pathname:this.pathname,e.port="port"in e?+e.port:+t.port||(e.secure?443:80);var o=this.querystring(e.query||"");return o._primuscb=f(),e.query=this.querystringify(o),this.emit("outgoing::url",e),n.push(e.secure?e.protocol.replace(":","s:"):e.protocol,""),n.push(e.auth?e.auth+"@"+t.host:t.host),e.pathname&&n.push(e.pathname.slice(1)),r?n[n.length-1]+="?"+e.query:delete e.query,e.object?e:n.join("/")},m.prototype.transform=function(e,t){return h(this,"transform"),e in this.transformers?(this.transformers[e].push(t),this):this.critical(new Error("Invalid transformer type"))},m.prototype.critical=function(e){if(this.emit("error",e))return this;throw e},m.connect=function(e,t){return new m(e,t)},m.EventEmitter=o,m.prototype.client=function(){var t,n=this,r=function(){if("undefined"!=typeof WebSocket)return WebSocket;if("undefined"!=typeof MozWebSocket)return MozWebSocket;try{return m.requires("ws")}catch(e){}}();if(!r)return n.critical(new Error("Missing required `ws` module. Please run `npm install --save ws`"));n.on("outgoing::open",function(){n.emit("outgoing::end");try{var e={protocol:"ws+unix:"===n.url.protocol?"ws+unix:":"ws:",query:!0};3===r.length?("ws+unix:"===e.protocol&&(e.pathname=n.url.pathname+":"+n.pathname),n.socket=t=new r(n.uri(e),[],n.transport)):(n.socket=t=new r(n.uri(e)),t.binaryType="arraybuffer")}catch(e){return n.emit("error",e)}t.onopen=n.emits("incoming::open"),t.onerror=n.emits("incoming::error"),t.onclose=n.emits("incoming::end"),t.onmessage=n.emits("incoming::data",function(e,t){e(void 0,t.data)})}),n.on("outgoing::data",function(e){if(t&&t.readyState===r.OPEN)try{t.send(e)}catch(e){n.emit("incoming::error",e)}}),n.on("outgoing::reconnect",function(){n.emit("outgoing::open")}),n.on("outgoing::end",function(){t&&(t.onerror=t.onopen=t.onclose=t.onmessage=function(){},t.close(),t=null)})},m.prototype.authorization=!1,m.prototype.pathname="/primus",m.prototype.encoder=function(e,t){var n;try{e=JSON.stringify(e)}catch(e){n=e}t(n,e)},m.prototype.decoder=function(e,t){var n;if("string"!=typeof e)return t(n,e);try{e=JSON.parse(e)}catch(e){n=e}t(n,e)},m.prototype.version="7.3.4","undefined"!=typeof document&&"undefined"!=typeof navigator){document.addEventListener&&document.addEventListener("keydown",function(e){27===e.keyCode&&e.preventDefault&&e.preventDefault()},!1);var d=(navigator.userAgent||"").toLowerCase(),y=d.match(/.+(?:rv|it|ra|ie)[/: ](\d+)\.(\d+)(?:\.(\d+))?/)||[],v=+[y[1],y[2]].join(".");!~d.indexOf("chrome")&&~d.indexOf("safari")&&v<534.54&&(m.prototype.AVOID_WEBSOCKETS=!0)}e.exports=m},{demolish:1,emits:2,eventemitter3:3,inherits:4,querystringify:8,recovery:9,"tick-tock":12,"url-parse":14,yeast:15}]},{},[16])(16)},[]),function(e){var t=function(e,t){var n=this;for(var r in n.callbacks={},n.id=null,n.events={},n.rooms=[],n.state="disconnected",n.options=n.defaults(),e)n.options[r]=e[r];t&&(n.externalClient=!0,n.client=t)};if("undefined"==typeof Primus){var n=require("util"),r=require("events").EventEmitter;n.inherits(t,r)}else t.prototype=new Primus.EventEmitter;t.prototype.defaults=function(){return{apiPath:"/api",cookieKey:"sessionID",url:window.location.origin}},t.prototype.connect=function(t){var n=this;n.messageId=n.messageId||0,n.client&&!0!==n.externalClient?(n.client.end(),n.client.removeAllListeners(),delete n.client,n.client=Primus.connect(n.urlWithSession(),n.options)):n.client&&!0===n.externalClient?(n.client.end(),n.client.open()):n.client=Primus.connect(n.urlWithSession(),n.options),n.client.once("open",function(){n.configure(function(e){n.state="connected",n.emit("connected"),"function"==typeof t&&t(null,e)})}),n.client.on("error",function(e){n.emit("error",e)}),n.client.on("reconnect",function(){n.emit("reconnect")}),n.client.on("reconnecting",function(){n.emit("reconnecting"),n.state="reconnecting",n.emit("disconnected")}),n.client.on("timeout",function(){n.state="timeout",n.emit("timeout")}),n.client.on("close",function(){"disconnected"!==n.state&&(n.state="disconnected",n.emit("disconnected"))}),n.client.on("end",function(){"disconnected"!==n.state&&(n.state="disconnected",n.emit("disconnected"))}),n.client.on("data",function(e){n.handleMessage(e)})},t.prototype.urlWithSession=function(){var e=this,t=e.options.url;if(e.options.cookieKey&&0<e.options.cookieKey.length){var n=e.getCookie(e.options.cookieKey);n&&0<n.length&&(t+="?"+e.options.cookieKey+"="+n)}return t},t.prototype.getCookie=function(e){if("undefined"!=typeof document&&document.cookie){var t=document.cookie.match(new RegExp(e+"=([^;]+)"));return t?t[1]:void 0}},t.prototype.configure=function(t){var n=this;n.rooms.forEach(function(e){n.send({event:"roomAdd",room:e})}),n.detailsView(function(e){return n.id=e.data.id,n.fingerprint=e.data.fingerprint,n.rooms=e.data.rooms,t(e)})},t.prototype.send=function(e,t){var n=this;n.messageId++,e.messageId=e.params?e.params.messageId||e.messageId||n.messageId:e.messageId||n.messageId,"function"==typeof t&&(n.callbacks[e.messageId]=t),n.client.write(e)},t.prototype.handleMessage=function(e){var t=this;t.emit("message",e);var n=e.messageId;"response"===e.context?("function"==typeof t.callbacks[n]&&t.callbacks[n](e),delete t.callbacks[n]):"user"===e.context?t.emit("say",e):"alert"===e.context?t.emit("alert",e):e.welcome&&"api"===e.context?(t.welcomeMessage=e.welcome,t.emit("welcome",e)):"api"===e.context&&t.emit("api",e)},t.prototype.action=function(e,t,n){n||"function"!=typeof t||(n=t,t=null),(t=t||{}).action=e,"connected"!==this.state?this.actionWeb(t,n):this.actionWebSocket(t,n)},t.prototype.actionWeb=function(e,n){var r=new XMLHttpRequest;r.onreadystatechange=function(){var t;if(4===r.readyState){if(200===r.status)t=JSON.parse(r.responseText);else try{t=JSON.parse(r.responseText)}catch(e){t={error:{statusText:r.statusText,responseText:r.responseText}}}n(t)}};var t=(e.httpMethod||"POST").toUpperCase(),o=this.options.url+this.options.apiPath+"?action="+e.action;if("GET"===t)for(var i in e)~["action","httpMethod"].indexOf(i)||(o+="&"+i+"="+e[i]);r.open(t,o,!0),r.setRequestHeader("Content-Type","application/json"),r.send(JSON.stringify(e))},t.prototype.actionWebSocket=function(e,t){this.send({event:"action",params:e},t)},t.prototype.say=function(e,t,n){this.send({event:"say",room:e,message:t},n)},t.prototype.file=function(e,t){this.send({event:"file",file:e},t)},t.prototype.detailsView=function(e){this.send({event:"detailsView"},e)},t.prototype.roomView=function(e,t){this.send({event:"roomView",room:e},t)},t.prototype.roomAdd=function(e,t){var n=this;n.send({event:"roomAdd",room:e},function(e){n.configure(function(){"function"==typeof t&&t(e)})})},t.prototype.roomLeave=function(e,t){var n=this,r=n.rooms.indexOf(e);-1<r&&n.rooms.splice(r,1),this.send({event:"roomLeave",room:e},function(e){n.configure(function(){"function"==typeof t&&t(e)})})},t.prototype.documentation=function(e){this.send({event:"documentation"},e)},t.prototype.disconnect=function(){this.state="disconnected",this.client.end(),this.emit("disconnected")};t=t;e.ActionheroWebsocketClient=t,e.ActionheroWebsocketClient=t}("undefined"==typeof exports?window:exports);
\No newline at end of file