UNPKG

pusher-js

Version:

Pusher Channels JavaScript library for browsers, React Native, NodeJS and web workers

8 lines 101 kB
/*! * Pusher JavaScript Library v7.4.0 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ module.exports=function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=14)}([function(t,n,e){"use strict";(function(t){e.d(n,"f",(function(){return i})),e.d(n,"m",(function(){return s})),e.d(n,"d",(function(){return a})),e.d(n,"k",(function(){return c})),e.d(n,"i",(function(){return u})),e.d(n,"n",(function(){return h})),e.d(n,"c",(function(){return f})),e.d(n,"j",(function(){return l})),e.d(n,"g",(function(){return p})),e.d(n,"h",(function(){return d})),e.d(n,"b",(function(){return y})),e.d(n,"a",(function(){return g})),e.d(n,"e",(function(){return b})),e.d(n,"l",(function(){return m}));var r=e(10),o=e(2);function i(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];for(var r=0;r<n.length;r++){var o=n[r];for(var s in o)o[s]&&o[s].constructor&&o[s].constructor===Object?t[s]=i(t[s]||{},o[s]):t[s]=o[s]}return t}function s(){for(var t=["Pusher"],n=0;n<arguments.length;n++)"string"==typeof arguments[n]?t.push(arguments[n]):t.push(m(arguments[n]));return t.join(" : ")}function a(t,n){var e=Array.prototype.indexOf;if(null===t)return-1;if(e&&t.indexOf===e)return t.indexOf(n);for(var r=0,o=t.length;r<o;r++)if(t[r]===n)return r;return-1}function c(t,n){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&n(t[e],e,t)}function u(t){var n=[];return c(t,(function(t,e){n.push(e)})),n}function h(t){var n=[];return c(t,(function(t){n.push(t)})),n}function f(n,e,r){for(var o=0;o<n.length;o++)e.call(r||t,n[o],o,n)}function l(t,n){for(var e=[],r=0;r<t.length;r++)e.push(n(t[r],r,t,e));return e}function p(t,n){n=n||function(t){return!!t};for(var e=[],r=0;r<t.length;r++)n(t[r],r,t,e)&&e.push(t[r]);return e}function d(t,n){var e={};return c(t,(function(r,o){(n&&n(r,o,t,e)||Boolean(r))&&(e[o]=r)})),e}function y(t,n){for(var e=0;e<t.length;e++)if(n(t[e],e,t))return!0;return!1}function g(t,n){for(var e=0;e<t.length;e++)if(!n(t[e],e,t))return!1;return!0}function v(t){return n=function(t){return"object"==typeof t&&(t=m(t)),encodeURIComponent(Object(r.a)(t.toString()))},e={},c(t,(function(t,r){e[r]=n(t)})),e;var n,e}function b(t){var n,e,r=d(t,(function(t){return void 0!==t}));return l((n=v(r),e=[],c(n,(function(t,n){e.push([n,t])})),e),o.a.method("join","=")).join("&")}function m(t){try{return JSON.stringify(t)}catch(r){return JSON.stringify((n=[],e=[],function t(r,o){var i,s,a;switch(typeof r){case"object":if(!r)return null;for(i=0;i<n.length;i+=1)if(n[i]===r)return{$ref:e[i]};if(n.push(r),e.push(o),"[object Array]"===Object.prototype.toString.apply(r))for(a=[],i=0;i<r.length;i+=1)a[i]=t(r[i],o+"["+i+"]");else for(s in a={},r)Object.prototype.hasOwnProperty.call(r,s)&&(a[s]=t(r[s],o+"["+JSON.stringify(s)+"]"));return a;case"number":case"string":case"boolean":return r}}(t,"$")))}var n,e}}).call(this,e(6))},function(t,n,e){"use strict";(function(t){var r=e(0),o=e(5),i=function(){function n(){this.globalLog=function(n){t.console&&t.console.log&&t.console.log(n)}}return n.prototype.debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this.log(this.globalLog,t)},n.prototype.warn=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this.log(this.globalLogWarn,t)},n.prototype.error=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this.log(this.globalLogError,t)},n.prototype.globalLogWarn=function(n){t.console&&t.console.warn?t.console.warn(n):this.globalLog(n)},n.prototype.globalLogError=function(n){t.console&&t.console.error?t.console.error(n):this.globalLogWarn(n)},n.prototype.log=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var i=r.m.apply(this,arguments);if(o.a.log)o.a.log(i);else if(o.a.logToConsole){var s=t.bind(this);s(i)}},n}();n.a=new i}).call(this,e(6))},function(t,n,e){"use strict";var r=e(4),o={now:function(){return Date.now?Date.now():(new Date).valueOf()},defer:function(t){return new r.a(0,t)},method:function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.prototype.slice.call(arguments,1);return function(n){return n[t].apply(n,r.concat(arguments))}}};n.a=o},function(t,n,e){"use strict";(function(t){var r=e(0),o=e(11),i=function(){function n(t){this.callbacks=new o.a,this.global_callbacks=[],this.failThrough=t}return n.prototype.bind=function(t,n,e){return this.callbacks.add(t,n,e),this},n.prototype.bind_global=function(t){return this.global_callbacks.push(t),this},n.prototype.unbind=function(t,n,e){return this.callbacks.remove(t,n,e),this},n.prototype.unbind_global=function(t){return t?(this.global_callbacks=r.g(this.global_callbacks||[],(function(n){return n!==t})),this):(this.global_callbacks=[],this)},n.prototype.unbind_all=function(){return this.unbind(),this.unbind_global(),this},n.prototype.emit=function(n,e,r){for(var o=0;o<this.global_callbacks.length;o++)this.global_callbacks[o](n,e);var i=this.callbacks.get(n),s=[];if(r?s.push(e,r):e&&s.push(e),i&&i.length>0)for(o=0;o<i.length;o++)i[o].fn.apply(i[o].context||t,s);else this.failThrough&&this.failThrough(n,e);return this},n}();n.a=i}).call(this,e(6))},function(t,n,e){"use strict";(function(t){e.d(n,"a",(function(){return c})),e.d(n,"b",(function(){return u}));var r,o=e(8),i=(r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)},function(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)});function s(n){t.clearTimeout(n)}function a(n){t.clearInterval(n)}var c=function(t){function n(n,e){return t.call(this,setTimeout,s,n,(function(t){return e(),null}))||this}return i(n,t),n}(o.a),u=function(t){function n(n,e){return t.call(this,setInterval,a,n,(function(t){return e(),t}))||this}return i(n,t),n}(o.a)}).call(this,e(6))},function(t,n,e){"use strict";var r=e(0),o={VERSION:"7.4.0",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,cluster:"mt1",userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};function i(t,n,e){return t+(n.useTLS?"s":"")+"://"+(n.useTLS?n.hostTLS:n.hostNonTLS)+e}function s(t,n){return"/app/"+t+("?protocol="+o.PROTOCOL+"&client=js&version="+o.VERSION+(n?"&"+n:""))}var a,c={getInitial:function(t,n){return i("ws",n,(n.httpPath||"")+s(t,"flash=false"))}},u={getInitial:function(t,n){return i("http",n,(n.httpPath||"/pusher")+s(t))}},h=e(2),f=e(3),l=e(1),p=(a=function(t,n){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)},function(t,n){function e(){this.constructor=t}a(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),d=function(t){function n(n,e,r,o,i){var s=t.call(this)||this;return s.initialize=It.transportConnectionInitializer,s.hooks=n,s.name=e,s.priority=r,s.key=o,s.options=i,s.state="new",s.timeline=i.timeline,s.activityTimeout=i.activityTimeout,s.id=s.timeline.generateUniqueID(),s}return p(n,t),n.prototype.handlesActivityChecks=function(){return Boolean(this.hooks.handlesActivityChecks)},n.prototype.supportsPing=function(){return Boolean(this.hooks.supportsPing)},n.prototype.connect=function(){var t=this;if(this.socket||"initialized"!==this.state)return!1;var n=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(n,this.options)}catch(n){return h.a.defer((function(){t.onError(n),t.changeState("closed")})),!1}return this.bindListeners(),l.a.debug("Connecting",{transport:this.name,url:n}),this.changeState("connecting"),!0},n.prototype.close=function(){return!!this.socket&&(this.socket.close(),!0)},n.prototype.send=function(t){var n=this;return"open"===this.state&&(h.a.defer((function(){n.socket&&n.socket.send(t)})),!0)},n.prototype.ping=function(){"open"===this.state&&this.supportsPing()&&this.socket.ping()},n.prototype.onOpen=function(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0},n.prototype.onError=function(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))},n.prototype.onClose=function(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0},n.prototype.onMessage=function(t){this.emit("message",t)},n.prototype.onActivity=function(){this.emit("activity")},n.prototype.bindListeners=function(){var t=this;this.socket.onopen=function(){t.onOpen()},this.socket.onerror=function(n){t.onError(n)},this.socket.onclose=function(n){t.onClose(n)},this.socket.onmessage=function(n){t.onMessage(n)},this.supportsPing()&&(this.socket.onactivity=function(){t.onActivity()})},n.prototype.unbindListeners=function(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))},n.prototype.changeState=function(t,n){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:n})),this.emit(t,n)},n.prototype.buildTimelineMessage=function(t){return r.f({cid:this.id},t)},n}(f.a),y=function(){function t(t){this.hooks=t}return t.prototype.isSupported=function(t){return this.hooks.isSupported(t)},t.prototype.createConnection=function(t,n,e,r){return new d(this.hooks,t,n,e,r)},t}(),g=new y({urls:c,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(It.getWebSocketAPI())},isSupported:function(){return Boolean(It.getWebSocketAPI())},getSocket:function(t){return It.createWebSocket(t)}}),v={urls:u,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},b=r.f({getSocket:function(t){return It.HTTPFactory.createStreamingSocket(t)}},v),m=r.f({getSocket:function(t){return It.HTTPFactory.createPollingSocket(t)}},v),_={isSupported:function(){return It.isXHRSupported()}},w={ws:g,xhr_streaming:new y(r.f({},b,_)),xhr_polling:new y(r.f({},m,_))},S=function(){function t(t,n,e){this.manager=t,this.transport=n,this.minPingDelay=e.minPingDelay,this.maxPingDelay=e.maxPingDelay,this.pingDelay=void 0}return t.prototype.createConnection=function(t,n,e,o){var i=this;o=r.f({},o,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,n,e,o),a=null,c=function(){s.unbind("open",c),s.bind("closed",u),a=h.a.now()},u=function(t){if(s.unbind("closed",u),1002===t.code||1003===t.code)i.manager.reportDeath();else if(!t.wasClean&&a){var n=h.a.now()-a;n<2*i.maxPingDelay&&(i.manager.reportDeath(),i.pingDelay=Math.max(n/2,i.minPingDelay))}};return s.bind("open",c),s},t.prototype.isSupported=function(t){return this.manager.isAlive()&&this.transport.isSupported(t)},t}(),k={decodeMessage:function(t){try{var n=JSON.parse(t.data),e=n.data;if("string"==typeof e)try{e=JSON.parse(n.data)}catch(t){}var r={event:n.event,channel:n.channel,data:e};return n.user_id&&(r.user_id=n.user_id),r}catch(n){throw{type:"MessageParseError",error:n,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var n=k.decodeMessage(t);if("pusher:connection_established"===n.event){if(!n.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:n.data.socket_id,activityTimeout:1e3*n.data.activity_timeout}}if("pusher:error"===n.event)return{action:this.getCloseAction(n.data),error:this.getCloseError(n.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}},C=k,T=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),P=function(t){function n(n,e){var r=t.call(this)||this;return r.id=n,r.transport=e,r.activityTimeout=e.activityTimeout,r.bindListeners(),r}return T(n,t),n.prototype.handlesActivityChecks=function(){return this.transport.handlesActivityChecks()},n.prototype.send=function(t){return this.transport.send(t)},n.prototype.send_event=function(t,n,e){var r={event:t,data:n};return e&&(r.channel=e),l.a.debug("Event sent",r),this.send(C.encodeMessage(r))},n.prototype.ping=function(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})},n.prototype.close=function(){this.transport.close()},n.prototype.bindListeners=function(){var t=this,n={message:function(n){var e;try{e=C.decodeMessage(n)}catch(e){t.emit("error",{type:"MessageParseError",error:e,data:n.data})}if(void 0!==e){switch(l.a.debug("Event recd",e),e.event){case"pusher:error":t.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":t.emit("ping");break;case"pusher:pong":t.emit("pong")}t.emit("message",e)}},activity:function(){t.emit("activity")},error:function(n){t.emit("error",n)},closed:function(n){e(),n&&n.code&&t.handleCloseEvent(n),t.transport=null,t.emit("closed")}},e=function(){r.k(n,(function(n,e){t.transport.unbind(e,n)}))};r.k(n,(function(n,e){t.transport.bind(e,n)}))},n.prototype.handleCloseEvent=function(t){var n=C.getCloseAction(t),e=C.getCloseError(t);e&&this.emit("error",e),n&&this.emit(n,{action:n,error:e})},n}(f.a),O=function(){function t(t,n){this.transport=t,this.callback=n,this.bindListeners()}return t.prototype.close=function(){this.unbindListeners(),this.transport.close()},t.prototype.bindListeners=function(){var t=this;this.onMessage=function(n){var e;t.unbindListeners();try{e=C.processHandshake(n)}catch(n){return t.finish("error",{error:n}),void t.transport.close()}"connected"===e.action?t.finish("connected",{connection:new P(e.id,t.transport),activityTimeout:e.activityTimeout}):(t.finish(e.action,{error:e.error}),t.transport.close())},this.onClosed=function(n){t.unbindListeners();var e=C.getCloseAction(n)||"backoff",r=C.getCloseError(n);t.finish(e,{error:r})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)},t.prototype.unbindListeners=function(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)},t.prototype.finish=function(t,n){this.callback(r.f({transport:this.transport,action:t},n))},t}(),A=function(){function t(t,n){this.timeline=t,this.options=n||{}}return t.prototype.send=function(t,n){this.timeline.isEmpty()||this.timeline.send(It.TimelineTransport.getAgent(this,t),n)},t}(),E=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),x=function(t){function n(n){var e=this.constructor,r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return E(n,t),n}(Error),L=function(t){function n(n){var e=this.constructor,r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return E(n,t),n}(Error),U=(function(t){function n(n){var e=this.constructor,r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}E(n,t)}(Error),function(t){function n(n){var e=this.constructor,r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return E(n,t),n}(Error)),R=function(t){function n(n){var e=this.constructor,r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return E(n,t),n}(Error),M=function(t){function n(n){var e=this.constructor,r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return E(n,t),n}(Error),j=function(t){function n(n){var e=this.constructor,r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return E(n,t),n}(Error),I=function(t){function n(n){var e=this.constructor,r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return E(n,t),n}(Error),N=function(t){function n(n,e){var r=this.constructor,o=t.call(this,e)||this;return o.status=n,Object.setPrototypeOf(o,r.prototype),o}return E(n,t),n}(Error),D={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}},H=function(t){var n,e=D.urls[t];return e?(e.fullUrl?n=e.fullUrl:e.path&&(n=D.baseUrl+e.path),n?"See: "+n:""):""},z=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),B=function(t){function n(n,e){var r=t.call(this,(function(t,e){l.a.debug("No callbacks on "+n+" for "+t)}))||this;return r.name=n,r.pusher=e,r.subscribed=!1,r.subscriptionPending=!1,r.subscriptionCancelled=!1,r}return z(n,t),n.prototype.authorize=function(t,n){return n(null,{auth:""})},n.prototype.trigger=function(t,n){if(0!==t.indexOf("client-"))throw new x("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var e=H("triggeringClientEvents");l.a.warn("Client event triggered before channel 'subscription_succeeded' event . "+e)}return this.pusher.send_event(t,n,this.name)},n.prototype.disconnect=function(){this.subscribed=!1,this.subscriptionPending=!1},n.prototype.handleEvent=function(t){var n=t.event,e=t.data;if("pusher_internal:subscription_succeeded"===n)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===n)this.handleSubscriptionCountEvent(t);else if(0!==n.indexOf("pusher_internal:")){this.emit(n,e,{})}},n.prototype.handleSubscriptionSucceededEvent=function(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)},n.prototype.handleSubscriptionCountEvent=function(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)},n.prototype.subscribe=function(){var t=this;this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(function(n,e){n?(t.subscriptionPending=!1,l.a.error(n.toString()),t.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:n.message},n instanceof N?{status:n.status}:{}))):t.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:t.name})})))},n.prototype.unsubscribe=function(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})},n.prototype.cancelSubscription=function(){this.subscriptionCancelled=!0},n.prototype.reinstateSubscription=function(){this.subscriptionCancelled=!1},n}(f.a),F=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),q=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return F(n,t),n.prototype.authorize=function(t,n){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},n)},n}(B),Y=function(){function t(){this.reset()}return t.prototype.get=function(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null},t.prototype.each=function(t){var n=this;r.k(this.members,(function(e,r){t(n.get(r))}))},t.prototype.setMyID=function(t){this.myID=t},t.prototype.onSubscription=function(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)},t.prototype.addMember=function(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)},t.prototype.removeMember=function(t){var n=this.get(t.user_id);return n&&(delete this.members[t.user_id],this.count--),n},t.prototype.reset=function(){this.members={},this.count=0,this.myID=null,this.me=null},t}(),K=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),J=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new e((function(n){n(t.value)})).then(s,a)}c((r=r.apply(t,n||[])).next())}))},X=function(t,n){var e,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;s;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=n.call(t,s)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},W=function(t){function n(n,e){var r=t.call(this,n,e)||this;return r.members=new Y,r}return K(n,t),n.prototype.authorize=function(n,e){var r=this;t.prototype.authorize.call(this,n,(function(t,n){return J(r,void 0,void 0,(function(){var r,o;return X(this,(function(i){switch(i.label){case 0:return t?[3,3]:null==(n=n).channel_data?[3,1]:(r=JSON.parse(n.channel_data),this.members.setMyID(r.user_id),[3,3]);case 1:return[4,this.pusher.user.signinDonePromise];case 2:if(i.sent(),null==this.pusher.user.user_data)return o=H("authorizationEndpoint"),l.a.error("Invalid auth response for channel '"+this.name+"', expected 'channel_data' field. "+o+", or the user should be signed in."),e("Invalid auth response"),[2];this.members.setMyID(this.pusher.user.user_data.id),i.label=3;case 3:return e(t,n),[2]}}))}))}))},n.prototype.handleEvent=function(t){var n=t.event;if(0===n.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var e=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(n,e,r)}},n.prototype.handleInternalEvent=function(t){var n=t.event,e=t.data;switch(n){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(e);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var o=this.members.removeMember(e);o&&this.emit("pusher:member_removed",o)}},n.prototype.handleSubscriptionSucceededEvent=function(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))},n.prototype.disconnect=function(){this.members.reset(),t.prototype.disconnect.call(this)},n}(q),G=e(12),V=e(7),Z=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Q=function(t){function n(n,e,r){var o=t.call(this,n,e)||this;return o.key=null,o.nacl=r,o}return Z(n,t),n.prototype.authorize=function(n,e){var r=this;t.prototype.authorize.call(this,n,(function(t,n){if(t)e(t,n);else{var o=n.shared_secret;o?(r.key=Object(V.decode)(o),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+r.name),null)}}))},n.prototype.trigger=function(t,n){throw new M("Client events are not currently supported for encrypted channels")},n.prototype.handleEvent=function(n){var e=n.event,r=n.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,r):t.prototype.handleEvent.call(this,n)},n.prototype.handleEncryptedEvent=function(t,n){var e=this;if(this.key)if(n.ciphertext&&n.nonce){var r=Object(V.decode)(n.ciphertext);if(r.length<this.nacl.secretbox.overheadLength)l.a.error("Expected encrypted event ciphertext length to be "+this.nacl.secretbox.overheadLength+", got: "+r.length);else{var o=Object(V.decode)(n.nonce);if(o.length<this.nacl.secretbox.nonceLength)l.a.error("Expected encrypted event nonce length to be "+this.nacl.secretbox.nonceLength+", got: "+o.length);else{var i=this.nacl.secretbox.open(r,o,this.key);if(null===i)return l.a.debug("Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint..."),void this.authorize(this.pusher.connection.socket_id,(function(n,s){n?l.a.error("Failed to make a request to the authEndpoint: "+s+". Unable to fetch new key, so dropping encrypted event"):null!==(i=e.nacl.secretbox.open(r,o,e.key))?e.emit(t,e.getDataToEmit(i)):l.a.error("Failed to decrypt event with new key. Dropping encrypted event")}));this.emit(t,this.getDataToEmit(i))}}}else l.a.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+n);else l.a.debug("Received encrypted event before key has been retrieved from the authEndpoint")},n.prototype.getDataToEmit=function(t){var n=Object(G.decode)(t);try{return JSON.parse(n)}catch(t){return n}},n}(q),$=e(4),tt=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),nt=function(t){function n(n,e){var r=t.call(this)||this;r.state="initialized",r.connection=null,r.key=n,r.options=e,r.timeline=r.options.timeline,r.usingTLS=r.options.useTLS,r.errorCallbacks=r.buildErrorCallbacks(),r.connectionCallbacks=r.buildConnectionCallbacks(r.errorCallbacks),r.handshakeCallbacks=r.buildHandshakeCallbacks(r.errorCallbacks);var o=It.getNetwork();return o.bind("online",(function(){r.timeline.info({netinfo:"online"}),"connecting"!==r.state&&"unavailable"!==r.state||r.retryIn(0)})),o.bind("offline",(function(){r.timeline.info({netinfo:"offline"}),r.connection&&r.sendActivityCheck()})),r.updateStrategy(),r}return tt(n,t),n.prototype.connect=function(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))},n.prototype.send=function(t){return!!this.connection&&this.connection.send(t)},n.prototype.send_event=function(t,n,e){return!!this.connection&&this.connection.send_event(t,n,e)},n.prototype.disconnect=function(){this.disconnectInternally(),this.updateState("disconnected")},n.prototype.isUsingTLS=function(){return this.usingTLS},n.prototype.startConnecting=function(){var t=this,n=function(e,r){e?t.runner=t.strategy.connect(0,n):"error"===r.action?(t.emit("error",{type:"HandshakeError",error:r.error}),t.timeline.error({handshakeError:r.error})):(t.abortConnecting(),t.handshakeCallbacks[r.action](r))};this.runner=this.strategy.connect(0,n)},n.prototype.abortConnecting=function(){this.runner&&(this.runner.abort(),this.runner=null)},n.prototype.disconnectInternally=function(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()},n.prototype.updateStrategy=function(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})},n.prototype.retryIn=function(t){var n=this;this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new $.a(t||0,(function(){n.disconnectInternally(),n.connect()}))},n.prototype.clearRetryTimer=function(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)},n.prototype.setUnavailableTimer=function(){var t=this;this.unavailableTimer=new $.a(this.options.unavailableTimeout,(function(){t.updateState("unavailable")}))},n.prototype.clearUnavailableTimer=function(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()},n.prototype.sendActivityCheck=function(){var t=this;this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new $.a(this.options.pongTimeout,(function(){t.timeline.error({pong_timed_out:t.options.pongTimeout}),t.retryIn(0)}))},n.prototype.resetActivityCheck=function(){var t=this;this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new $.a(this.activityTimeout,(function(){t.sendActivityCheck()})))},n.prototype.stopActivityCheck=function(){this.activityTimer&&this.activityTimer.ensureAborted()},n.prototype.buildConnectionCallbacks=function(t){var n=this;return r.f({},t,{message:function(t){n.resetActivityCheck(),n.emit("message",t)},ping:function(){n.send_event("pusher:pong",{})},activity:function(){n.resetActivityCheck()},error:function(t){n.emit("error",t)},closed:function(){n.abandonConnection(),n.shouldRetry()&&n.retryIn(1e3)}})},n.prototype.buildHandshakeCallbacks=function(t){var n=this;return r.f({},t,{connected:function(t){n.activityTimeout=Math.min(n.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),n.clearUnavailableTimer(),n.setConnection(t.connection),n.socket_id=n.connection.id,n.updateState("connected",{socket_id:n.socket_id})}})},n.prototype.buildErrorCallbacks=function(){var t=this,n=function(n){return function(e){e.error&&t.emit("error",{type:"WebSocketError",error:e.error}),n(e)}};return{tls_only:n((function(){t.usingTLS=!0,t.updateStrategy(),t.retryIn(0)})),refused:n((function(){t.disconnect()})),backoff:n((function(){t.retryIn(1e3)})),retry:n((function(){t.retryIn(0)}))}},n.prototype.setConnection=function(t){for(var n in this.connection=t,this.connectionCallbacks)this.connection.bind(n,this.connectionCallbacks[n]);this.resetActivityCheck()},n.prototype.abandonConnection=function(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var n=this.connection;return this.connection=null,n}},n.prototype.updateState=function(t,n){var e=this.state;if(this.state=t,e!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+n.socket_id),l.a.debug("State changed",e+" -> "+r),this.timeline.info({state:t,params:n}),this.emit("state_change",{previous:e,current:t}),this.emit(t,n)}},n.prototype.shouldRetry=function(){return"connecting"===this.state||"connected"===this.state},n}(f.a),et=function(){function t(){this.channels={}}return t.prototype.add=function(t,n){return this.channels[t]||(this.channels[t]=function(t,n){if(0===t.indexOf("private-encrypted-")){if(n.config.nacl)return rt.createEncryptedChannel(t,n,n.config.nacl);var e=H("encryptedChannelSupport");throw new M("Tried to subscribe to a private-encrypted- channel but no nacl implementation available. "+e)}if(0===t.indexOf("private-"))return rt.createPrivateChannel(t,n);if(0===t.indexOf("presence-"))return rt.createPresenceChannel(t,n);if(0===t.indexOf("#"))throw new L('Cannot create a channel with name "'+t+'".');return rt.createChannel(t,n)}(t,n)),this.channels[t]},t.prototype.all=function(){return r.n(this.channels)},t.prototype.find=function(t){return this.channels[t]},t.prototype.remove=function(t){var n=this.channels[t];return delete this.channels[t],n},t.prototype.disconnect=function(){r.k(this.channels,(function(t){t.disconnect()}))},t}();var rt={createChannels:function(){return new et},createConnectionManager:function(t,n){return new nt(t,n)},createChannel:function(t,n){return new B(t,n)},createPrivateChannel:function(t,n){return new q(t,n)},createPresenceChannel:function(t,n){return new W(t,n)},createEncryptedChannel:function(t,n,e){return new Q(t,n,e)},createTimelineSender:function(t,n){return new A(t,n)},createHandshake:function(t,n){return new O(t,n)},createAssistantToTheTransportManager:function(t,n,e){return new S(t,n,e)}},ot=function(){function t(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}return t.prototype.getAssistant=function(t){return rt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})},t.prototype.isAlive=function(){return this.livesLeft>0},t.prototype.reportDeath=function(){this.livesLeft-=1},t}(),it=function(){function t(t,n){this.strategies=t,this.loop=Boolean(n.loop),this.failFast=Boolean(n.failFast),this.timeout=n.timeout,this.timeoutLimit=n.timeoutLimit}return t.prototype.isSupported=function(){return r.b(this.strategies,h.a.method("isSupported"))},t.prototype.connect=function(t,n){var e=this,r=this.strategies,o=0,i=this.timeout,s=null,a=function(c,u){u?n(null,u):(o+=1,e.loop&&(o%=r.length),o<r.length?(i&&(i*=2,e.timeoutLimit&&(i=Math.min(i,e.timeoutLimit))),s=e.tryStrategy(r[o],t,{timeout:i,failFast:e.failFast},a)):n(!0))};return s=this.tryStrategy(r[o],t,{timeout:i,failFast:this.failFast},a),{abort:function(){s.abort()},forceMinPriority:function(n){t=n,s&&s.forceMinPriority(n)}}},t.prototype.tryStrategy=function(t,n,e,r){var o=null,i=null;return e.timeout>0&&(o=new $.a(e.timeout,(function(){i.abort(),r(!0)}))),i=t.connect(n,(function(t,n){t&&o&&o.isRunning()&&!e.failFast||(o&&o.ensureAborted(),r(t,n))})),{abort:function(){o&&o.ensureAborted(),i.abort()},forceMinPriority:function(t){i.forceMinPriority(t)}}},t}(),st=function(){function t(t){this.strategies=t}return t.prototype.isSupported=function(){return r.b(this.strategies,h.a.method("isSupported"))},t.prototype.connect=function(t,n){return function(t,n,e){var o=r.j(t,(function(t,r,o,i){return t.connect(n,e(r,i))}));return{abort:function(){r.c(o,at)},forceMinPriority:function(t){r.c(o,(function(n){n.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,e){return function(o,i){e[t].error=o,o?function(t){return r.a(t,(function(t){return Boolean(t.error)}))}(e)&&n(!0):(r.c(e,(function(t){t.forceMinPriority(i.transport.priority)})),n(null,i))}}))},t}();function at(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}var ct=function(){function t(t,n,e){this.strategy=t,this.transports=n,this.ttl=e.ttl||18e5,this.usingTLS=e.useTLS,this.timeline=e.timeline}return t.prototype.isSupported=function(){return this.strategy.isSupported()},t.prototype.connect=function(t,n){var e=this.usingTLS,o=function(t){var n=It.getLocalStorage();if(n)try{var e=n[ut(t)];if(e)return JSON.parse(e)}catch(n){ht(t)}return null}(e),i=[this.strategy];if(o&&o.timestamp+this.ttl>=h.a.now()){var s=this.transports[o.transport];s&&(this.timeline.info({cached:!0,transport:o.transport,latency:o.latency}),i.push(new it([s],{timeout:2*o.latency+1e3,failFast:!0})))}var a=h.a.now(),c=i.pop().connect(t,(function o(s,u){s?(ht(e),i.length>0?(a=h.a.now(),c=i.pop().connect(t,o)):n(s)):(!function(t,n,e){var o=It.getLocalStorage();if(o)try{o[ut(t)]=r.l({timestamp:h.a.now(),transport:n,latency:e})}catch(t){}}(e,u.transport.name,h.a.now()-a),n(null,u))}));return{abort:function(){c.abort()},forceMinPriority:function(n){t=n,c&&c.forceMinPriority(n)}}},t}();function ut(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function ht(t){var n=It.getLocalStorage();if(n)try{delete n[ut(t)]}catch(t){}}var ft=function(){function t(t,n){var e=n.delay;this.strategy=t,this.options={delay:e}}return t.prototype.isSupported=function(){return this.strategy.isSupported()},t.prototype.connect=function(t,n){var e,r=this.strategy,o=new $.a(this.options.delay,(function(){e=r.connect(t,n)}));return{abort:function(){o.ensureAborted(),e&&e.abort()},forceMinPriority:function(n){t=n,e&&e.forceMinPriority(n)}}},t}(),lt=function(){function t(t,n,e){this.test=t,this.trueBranch=n,this.falseBranch=e}return t.prototype.isSupported=function(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()},t.prototype.connect=function(t,n){return(this.test()?this.trueBranch:this.falseBranch).connect(t,n)},t}(),pt=function(){function t(t){this.strategy=t}return t.prototype.isSupported=function(){return this.strategy.isSupported()},t.prototype.connect=function(t,n){var e=this.strategy.connect(t,(function(t,r){r&&e.abort(),n(t,r)}));return e},t}();function dt(t){return function(){return t.isSupported()}}var yt,gt=function(t,n,e){var o={};function i(n,r,i,s,a){var c=e(t,n,r,i,s,a);return o[n]=c,c}var s,a=Object.assign({},n,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),c=r.f({},a,{useTLS:!0}),u=Object.assign({},n,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},f=new ot({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new ot({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),p=i("ws","ws",3,a,f),d=i("wss","ws",3,c,f),y=i("xhr_streaming","xhr_streaming",1,u,l),g=i("xhr_polling","xhr_polling",1,u),v=new it([p],h),b=new it([d],h),m=new it([y],h),_=new it([g],h),w=new it([new lt(dt(m),new st([m,new ft(_,{delay:4e3})]),_)],h);return s=n.useTLS?new st([v,new ft(w,{delay:2e3})]):new st([v,new ft(b,{delay:2e3}),new ft(w,{delay:5e3})]),new ct(new pt(new lt(dt(p),s,w)),o,{ttl:18e5,timeline:n.timeline,useTLS:n.useTLS})},vt=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),bt=function(t){function n(n,e,r){var o=t.call(this)||this;return o.hooks=n,o.method=e,o.url=r,o}return vt(n,t),n.prototype.start=function(t){var n=this;this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=function(){n.close()},It.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)},n.prototype.close=function(){this.unloader&&(It.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)},n.prototype.onChunk=function(t,n){for(;;){var e=this.advanceBuffer(n);if(!e)break;this.emit("chunk",{status:t,data:e})}this.isBufferTooLong(n)&&this.emit("buffer_too_long")},n.prototype.advanceBuffer=function(t){var n=t.slice(this.position),e=n.indexOf("\n");return-1!==e?(this.position+=e+1,n.slice(0,e)):null},n.prototype.isBufferTooLong=function(t){return this.position===t.length&&t.length>262144},n}(f.a);!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(yt||(yt={}));var mt=yt,_t=1;function wt(t){var n=-1===t.indexOf("?")?"?":"&";return t+n+"t="+ +new Date+"&n="+_t++}function St(t){return Math.floor(Math.random()*t)}var kt=function(){function t(t,n){this.hooks=t,this.session=St(1e3)+"/"+function(t){for(var n=[],e=0;e<t;e++)n.push(St(32).toString(32));return n.join("")}(8),this.location=function(t){var n=/([^\?]*)\/*(\??.*)/.exec(t);return{base:n[1],queryString:n[2]}}(n),this.readyState=mt.CONNECTING,this.openStream()}return t.prototype.send=function(t){return this.sendRaw(JSON.stringify([t]))},t.prototype.ping=function(){this.hooks.sendHeartbeat(this)},t.prototype.close=function(t,n){this.onClose(t,n,!0)},t.prototype.sendRaw=function(t){if(this.readyState!==mt.OPEN)return!1;try{return It.createSocketRequest("POST",wt((n=this.location,e=this.session,n.base+"/"+e+"/xhr_send"))).start(t),!0}catch(t){return!1}var n,e},t.prototype.reconnect=function(){this.closeStream(),this.openStream()},t.prototype.onClose=function(t,n,e){this.closeStream(),this.readyState=mt.CLOSED,this.onclose&&this.onclose({code:t,reason:n,wasClean:e})},t.prototype.onChunk=function(t){var n;if(200===t.status)switch(this.readyState===mt.OPEN&&this.onActivity(),t.data.slice(0,1)){case"o":n=JSON.parse(t.data.slice(1)||"{}"),this.onOpen(n);break;case"a":n=JSON.parse(t.data.slice(1)||"[]");for(var e=0;e<n.length;e++)this.onEvent(n[e]);break;case"m":n=JSON.parse(t.data.slice(1)||"null"),this.onEvent(n);break;case"h":this.hooks.onHeartbeat(this);break;case"c":n=JSON.parse(t.data.slice(1)||"[]"),this.onClose(n[0],n[1],!0)}},t.prototype.onOpen=function(t){var n,e,r;this.readyState===mt.CONNECTING?(t&&t.hostname&&(this.location.base=(n=this.location.base,e=t.hostname,(r=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(n))[1]+e+r[3])),this.readyState=mt.OPEN,this.onopen&&this.onopen()):this.onClose(1006,"Server lost session",!0)},t.prototype.onEvent=function(t){this.readyState===mt.OPEN&&this.onmessage&&this.onmessage({data:t})},t.prototype.onActivity=function(){this.onactivity&&this.onactivity()},t.prototype.onError=function(t){this.onerror&&this.onerror(t)},t.prototype.openStream=function(){var t=this;this.stream=It.createSocketRequest("POST",wt(this.hooks.getReceiveURL(this.location,this.session))),this.stream.bind("chunk",(function(n){t.onChunk(n)})),this.stream.bind("finished",(function(n){t.hooks.onFinished(t,n)})),this.stream.bind("buffer_too_long",(function(){t.reconnect()}));try{this.stream.start()}catch(n){h.a.defer((function(){t.onError(n),t.onClose(1006,"Could not start streaming",!1)}))}},t.prototype.closeStream=function(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)},t}(),Ct={getReceiveURL:function(t,n){return t.base+"/"+n+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,n){t.onClose(1006,"Connection interrupted ("+n+")",!1)}},Tt={getReceiveURL:function(t,n){return t.base+"/"+n+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,n){200===n?t.reconnect():t.onClose(1006,"Connection interrupted ("+n+")",!1)}},Pt={getRequest:function(t){var n=new(It.getXHRAPI());return n.onreadystatechange=n.onprogress=function(){switch(n.readyState){case 3:n.responseText&&n.responseText.length>0&&t.onChunk(n.status,n.responseText);break;case 4:n.responseText&&n.responseText.length>0&&t.onChunk(n.status,n.responseText),t.emit("finished",n.status),t.close()}},n},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},Ot={getDefaultStrategy:gt,Transports:w,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket:function(t){return this.createSocket(Ct,t)},createPollingSocket:function(t){return this.createSocket(Tt,t)},createSocket:function(t,n){return new kt(t,n)},createXHR:function(t,n){return this.createRequest(Pt,t,n)},createRequest:function(t,n,e){return new bt(t,n,e)}},setup:function(t){t.ready()},getLocalStorage:function(){},getClientFeatures:function(){return r.i(r.h({ws:w.ws},(function(t){return t.isSupported({})})))},getProtocol:function(){return"http:"},isXHRSupported:function(){return!0},createSocketRequest:function(t,n){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,n);throw"Cross-origin HTTP requests are not supported"},createXHR:function(){return new(this.getXHRAPI())},createWebSocket:function(t){return new(this.getWebSocketAPI())(t)},addUnloadListener:function(t){},removeUnloadListener:function(t){}},At=e(9),Et=e.n(At),xt=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(n,e)};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}();function Lt(t){return"none"!==t.type.toLowerCase()}var Ut,Rt=new(function(t){function n(){var n=t.call(this)||this;return n.online=!0,Et.a.fetch().then((function(t){n.online=Lt(t)})),Et.a.addEventListener((function(t){var e=Lt(t);n.online!==e&&(n.online=e,n.online?n.emit("online"):n.emit("offline"))})),n}return xt(n,t),n.prototype.isOnline=function(){return this.online},n}(f.a));!function(t){t.UserAuthentication="user-authentication",t.ChannelAuthorization="channel-authorization"}(Ut||(Ut={}));var Mt,jt=function(t,n,e,r,o){var i=It.createXHR();for(var s in i.open("POST",e.endpoint,!0),i.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.headers)i.setRequestHeader(s,e.headers[s]);return i.onreadystatechange=function(){if(4===i.readyState)if(200===i.status){var t=void 0,n=!1;try{t=JSON.parse(i.responseText),n=!0}catch(t){o(new N(200,"JSON returned from "+r.toString()+" endpoint was invalid, yet status code was 200. Data was: "+i.responseText),null)}n&&o(null,t)}else{var s="";switch(r){case Ut.UserAuthentication:s=H("authenticationEndpoint");break;case Ut.ChannelAuthorization:s="Clients must be authenticated to join private or presence channels. "+H("authorizationEndpoint")}o(new N(i.status,"Unable to retrieve auth string from "+r.toString()+" endpoint - received status: "+i.status+" from "+e.endpoint+". "+s),null)}},i.send(n),i},It={getDefaultStrategy:Ot.getDefaultStrategy,Transports:Ot.Transports,setup:Ot.setup,getProtocol:Ot.getProtocol,isXHRSupported:Ot.isXHRSupported,getLocalStorage:Ot.getLocalStorage,createXHR:Ot.createXHR,createWebSocket:Ot.createWebSocket,addUnloadListener:Ot.addUnloadListener,removeUnloadListener:Ot.removeUnloadListener,transportConnectionInitializer:Ot.transportConnectionInitializer,createSocketRequest:Ot.createSocketRequest,HTTPFactory:Ot.HTTPFactory,TimelineTransport:{name:"xhr",getAgent:function(t,n){return function(e,o){var i="http"+(n?"s":"")+"://"+(t.host||t.options.host)+t.options.path;i+="/2?"+r.e(e);var s=It.createXHR();s.open("GET",i,!0),s.onreadystatechange=function(){if(4===s.readyState){var n=s.status,e=s.responseText;if(200!==n)return void l.a.debug("TimelineSender Error: received "+n+" from stats.pusher.com");try{var r=JSON.parse(e).host}catch(t){l.a.debug("TimelineSenderError: invalid response "+e)}r&&(t.host=r)}},s.send()}}},getAuthorizers:function(){return{ajax:jt}},getWebSocketAPI:function(){return WebSocket},getXHRAPI:function(){return XMLHttpRequest},getNetwork:function(){return Rt}};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(Mt||(Mt={}));var Nt=Mt,Dt=function(){function t(t,n,e){this.key=t,this.session=n,this.events=[],this.options=e||{},this.sent=0,this.uniqueID=0}return t.prototype.log=function(t,n){t<=this.options.level&&(this.events.push(r.f({},n,{timestamp:h.a.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())},t.prototype.error=function(t){this.log(Nt.ERROR,t)},t.prototype.info=function(t){this.log(Nt.INFO,t)},t.prototype.debug=function(t){this.log(Nt.DEBUG,t)},t.prototype.isEmpty=function(){return 0===this.events.length},t.prototype.send=function(t,n){var e=this,o=r.f({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(o,(function(t,r){t||e.sent++,n&&n(t,r)})),!0},t.prototype.generateUniqueID=function(){return this.uniqueID++,this.uniqueID},t}(),Ht=function(){function t(t,n,e,r){this.name=t,this.priority=n,this.transport=e,this.options=r||{}}return t.prototype.isSupported=function(){return this.transport.isSupp