@dcodegroup-au/dcode-chat-vue
Version:
Frontend vue components for the dcode-laravel-chat package
7 lines • 141 kB
JavaScript
(function(Q,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],g):(Q=typeof globalThis<"u"?globalThis:Q||self,g(Q["@dcodegroup-au/dcode-chat-vue"]={},Q.Vue))})(this,function(Q,g){"use strict";class Ye{listenForWhisper(e,n){return this.listen(".client-"+e,n)}notification(e){return this.listen(".Illuminate\\Notifications\\Events\\BroadcastNotificationCreated",e)}stopListeningForWhisper(e,n){return this.stopListening(".client-"+e,n)}}class It{constructor(e){this.namespace=e}format(e){return[".","\\"].includes(e.charAt(0))?e.substring(1):(this.namespace&&(e=this.namespace+"."+e),e.replace(/\./g,"\\"))}setNamespace(e){this.namespace=e}}function br(r){try{new r}catch(e){if(e instanceof Error&&e.message.includes("is not a constructor"))return!1}return!0}class et extends Ye{constructor(e,n,i){super(),this.name=n,this.pusher=e,this.options=i,this.eventFormatter=new It(this.options.namespace),this.subscribe()}subscribe(){this.subscription=this.pusher.subscribe(this.name)}unsubscribe(){this.pusher.unsubscribe(this.name)}listen(e,n){return this.on(this.eventFormatter.format(e),n),this}listenToAll(e){return this.subscription.bind_global((n,i)=>{if(n.startsWith("pusher:"))return;let a=String(this.options.namespace??"").replace(/\./g,"\\"),u=n.startsWith(a)?n.substring(a.length+1):"."+n;e(u,i)}),this}stopListening(e,n){return n?this.subscription.unbind(this.eventFormatter.format(e),n):this.subscription.unbind(this.eventFormatter.format(e)),this}stopListeningToAll(e){return e?this.subscription.unbind_global(e):this.subscription.unbind_global(),this}subscribed(e){return this.on("pusher:subscription_succeeded",()=>{e()}),this}error(e){return this.on("pusher:subscription_error",n=>{e(n)}),this}on(e,n){return this.subscription.bind(e,n),this}}class Bt extends et{whisper(e,n){return this.pusher.channels.channels[this.name].trigger(`client-${e}`,n),this}}class yr extends et{whisper(e,n){return this.pusher.channels.channels[this.name].trigger(`client-${e}`,n),this}}class vr extends Bt{here(e){return this.on("pusher:subscription_succeeded",n=>{e(Object.keys(n.members).map(i=>n.members[i]))}),this}joining(e){return this.on("pusher:member_added",n=>{e(n.info)}),this}whisper(e,n){return this.pusher.channels.channels[this.name].trigger(`client-${e}`,n),this}leaving(e){return this.on("pusher:member_removed",n=>{e(n.info)}),this}}class Ft extends Ye{constructor(e,n,i){super(),this.events={},this.listeners={},this.name=n,this.socket=e,this.options=i,this.eventFormatter=new It(this.options.namespace),this.subscribe()}subscribe(){this.socket.emit("subscribe",{channel:this.name,auth:this.options.auth||{}})}unsubscribe(){this.unbind(),this.socket.emit("unsubscribe",{channel:this.name,auth:this.options.auth||{}})}listen(e,n){return this.on(this.eventFormatter.format(e),n),this}stopListening(e,n){return this.unbindEvent(this.eventFormatter.format(e),n),this}subscribed(e){return this.on("connect",n=>{e(n)}),this}error(e){return this}on(e,n){return this.listeners[e]=this.listeners[e]||[],this.events[e]||(this.events[e]=(i,a)=>{this.name===i&&this.listeners[e]&&this.listeners[e].forEach(u=>u(a))},this.socket.on(e,this.events[e])),this.listeners[e].push(n),this}unbind(){Object.keys(this.events).forEach(e=>{this.unbindEvent(e)})}unbindEvent(e,n){this.listeners[e]=this.listeners[e]||[],n&&(this.listeners[e]=this.listeners[e].filter(i=>i!==n)),(!n||this.listeners[e].length===0)&&(this.events[e]&&(this.socket.removeListener(e,this.events[e]),delete this.events[e]),delete this.listeners[e])}}class qt extends Ft{whisper(e,n){return this.socket.emit("client event",{channel:this.name,event:`client-${e}`,data:n}),this}}class wr extends qt{here(e){return this.on("presence:subscribed",n=>{e(n.map(i=>i.user_info))}),this}joining(e){return this.on("presence:joining",n=>e(n.user_info)),this}whisper(e,n){return this.socket.emit("client event",{channel:this.name,event:`client-${e}`,data:n}),this}leaving(e){return this.on("presence:leaving",n=>e(n.user_info)),this}}class Oe extends Ye{subscribe(){}unsubscribe(){}listen(e,n){return this}listenToAll(e){return this}stopListening(e,n){return this}subscribed(e){return this}error(e){return this}on(e,n){return this}}class Mt extends Oe{whisper(e,n){return this}}class _r extends Oe{whisper(e,n){return this}}class Sr extends Mt{here(e){return this}joining(e){return this}whisper(e,n){return this}leaving(e){return this}}const $t=class mr{constructor(e){this.setOptions(e),this.connect()}setOptions(e){this.options={...mr._defaultOptions,...e,broadcaster:e.broadcaster};let n=this.csrfToken();n&&(this.options.auth.headers["X-CSRF-TOKEN"]=n,this.options.userAuthentication.headers["X-CSRF-TOKEN"]=n),n=this.options.bearerToken,n&&(this.options.auth.headers.Authorization="Bearer "+n,this.options.userAuthentication.headers.Authorization="Bearer "+n)}csrfToken(){var e,n;return((e=window==null?void 0:window.Laravel)==null?void 0:e.csrfToken)??this.options.csrfToken??((n=document==null?void 0:document.querySelector('meta[name="csrf-token"]'))==null?void 0:n.getAttribute("content"))??null}};$t._defaultOptions={auth:{headers:{}},authEndpoint:"/broadcasting/auth",userAuthentication:{endpoint:"/broadcasting/user-auth",headers:{}},csrfToken:null,bearerToken:null,host:null,key:null,namespace:"App.Events"};let tt=$t;class Pe extends tt{constructor(){super(...arguments),this.channels={}}connect(){if(typeof this.options.client<"u")this.pusher=this.options.client;else if(this.options.Pusher)this.pusher=new this.options.Pusher(this.options.key,this.options);else if(typeof window<"u"&&typeof window.Pusher<"u")this.pusher=new window.Pusher(this.options.key,this.options);else throw new Error("Pusher client not found. Should be globally available or passed via options.client")}signin(){this.pusher.signin()}listen(e,n,i){return this.channel(e).listen(n,i)}channel(e){return this.channels[e]||(this.channels[e]=new et(this.pusher,e,this.options)),this.channels[e]}privateChannel(e){return this.channels["private-"+e]||(this.channels["private-"+e]=new Bt(this.pusher,"private-"+e,this.options)),this.channels["private-"+e]}encryptedPrivateChannel(e){return this.channels["private-encrypted-"+e]||(this.channels["private-encrypted-"+e]=new yr(this.pusher,"private-encrypted-"+e,this.options)),this.channels["private-encrypted-"+e]}presenceChannel(e){return this.channels["presence-"+e]||(this.channels["presence-"+e]=new vr(this.pusher,"presence-"+e,this.options)),this.channels["presence-"+e]}leave(e){[e,"private-"+e,"private-encrypted-"+e,"presence-"+e].forEach(n=>{this.leaveChannel(n)})}leaveChannel(e){this.channels[e]&&(this.channels[e].unsubscribe(),delete this.channels[e])}socketId(){return this.pusher.connection.socket_id}disconnect(){this.pusher.disconnect()}}class Cr extends tt{constructor(){super(...arguments),this.channels={}}connect(){let e=this.getSocketIO();this.socket=e(this.options.host??void 0,this.options),this.socket.on("reconnect",()=>{Object.values(this.channels).forEach(n=>{n.subscribe()})})}getSocketIO(){if(typeof this.options.client<"u")return this.options.client;if(typeof window<"u"&&typeof window.io<"u")return window.io;throw new Error("Socket.io client not found. Should be globally available or passed via options.client")}listen(e,n,i){return this.channel(e).listen(n,i)}channel(e){return this.channels[e]||(this.channels[e]=new Ft(this.socket,e,this.options)),this.channels[e]}privateChannel(e){return this.channels["private-"+e]||(this.channels["private-"+e]=new qt(this.socket,"private-"+e,this.options)),this.channels["private-"+e]}presenceChannel(e){return this.channels["presence-"+e]||(this.channels["presence-"+e]=new wr(this.socket,"presence-"+e,this.options)),this.channels["presence-"+e]}leave(e){[e,"private-"+e,"presence-"+e].forEach(n=>{this.leaveChannel(n)})}leaveChannel(e){this.channels[e]&&(this.channels[e].unsubscribe(),delete this.channels[e])}socketId(){return this.socket.id}disconnect(){this.socket.disconnect()}}class Ht extends tt{constructor(){super(...arguments),this.channels={}}connect(){}listen(e,n,i){return new Oe}channel(e){return new Oe}privateChannel(e){return new Mt}encryptedPrivateChannel(e){return new _r}presenceChannel(e){return new Sr}leave(e){}leaveChannel(e){}socketId(){return"fake-socket-id"}disconnect(){}}class zt{constructor(e){this.options=e,this.connect(),this.options.withoutInterceptors||this.registerInterceptors()}channel(e){return this.connector.channel(e)}connect(){if(this.options.broadcaster==="reverb")this.connector=new Pe({...this.options,cluster:""});else if(this.options.broadcaster==="pusher")this.connector=new Pe(this.options);else if(this.options.broadcaster==="ably")this.connector=new Pe({...this.options,cluster:"",broadcaster:"pusher"});else if(this.options.broadcaster==="socket.io")this.connector=new Cr(this.options);else if(this.options.broadcaster==="null")this.connector=new Ht(this.options);else if(typeof this.options.broadcaster=="function"&&br(this.options.broadcaster))this.connector=new this.options.broadcaster(this.options);else throw new Error(`Broadcaster ${typeof this.options.broadcaster} ${String(this.options.broadcaster)} is not supported.`)}disconnect(){this.connector.disconnect()}join(e){return this.connector.presenceChannel(e)}leave(e){this.connector.leave(e)}leaveChannel(e){this.connector.leaveChannel(e)}leaveAllChannels(){for(const e in this.connector.channels)this.leaveChannel(e)}listen(e,n,i){return this.connector.listen(e,n,i)}private(e){return this.connector.privateChannel(e)}encryptedPrivate(e){if(this.connectorSupportsEncryptedPrivateChannels(this.connector))return this.connector.encryptedPrivateChannel(e);throw new Error(`Broadcaster ${typeof this.options.broadcaster} ${String(this.options.broadcaster)} does not support encrypted private channels.`)}connectorSupportsEncryptedPrivateChannels(e){return e instanceof Pe||e instanceof Ht}socketId(){return this.connector.socketId()}registerInterceptors(){typeof Vue<"u"&&Vue!=null&&Vue.http&&this.registerVueRequestInterceptor(),typeof axios=="function"&&this.registerAxiosRequestInterceptor(),typeof jQuery=="function"&&this.registerjQueryAjaxSetup(),typeof Turbo=="object"&&this.registerTurboRequestInterceptor()}registerVueRequestInterceptor(){Vue.http.interceptors.push((e,n)=>{this.socketId()&&e.headers.set("X-Socket-ID",this.socketId()),n()})}registerAxiosRequestInterceptor(){axios.interceptors.request.use(e=>(this.socketId()&&(e.headers["X-Socket-Id"]=this.socketId()),e))}registerjQueryAjaxSetup(){typeof jQuery.ajax<"u"&&jQuery.ajaxPrefilter((e,n,i)=>{this.socketId()&&i.setRequestHeader("X-Socket-Id",this.socketId())})}registerTurboRequestInterceptor(){document.addEventListener("turbo:before-fetch-request",e=>{e.detail.fetchOptions.headers["X-Socket-Id"]=this.socketId()})}}function xr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var nt={exports:{}};/*!
* Pusher JavaScript Library v8.4.0
* https://pusher.com/
*
* Copyright 2020, Pusher
* Released under the MIT licence.
*/var Vt;function Er(){return Vt||(Vt=1,function(r,e){(function(i,a){r.exports=a()})(window,function(){return function(n){var i={};function a(u){if(i[u])return i[u].exports;var l=i[u]={i:u,l:!1,exports:{}};return n[u].call(l.exports,l,l.exports,a),l.l=!0,l.exports}return a.m=n,a.c=i,a.d=function(u,l,b){a.o(u,l)||Object.defineProperty(u,l,{enumerable:!0,get:b})},a.r=function(u){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})},a.t=function(u,l){if(l&1&&(u=a(u)),l&8||l&4&&typeof u=="object"&&u&&u.__esModule)return u;var b=Object.create(null);if(a.r(b),Object.defineProperty(b,"default",{enumerable:!0,value:u}),l&2&&typeof u!="string")for(var x in u)a.d(b,x,(function(T){return u[T]}).bind(null,x));return b},a.n=function(u){var l=u&&u.__esModule?function(){return u.default}:function(){return u};return a.d(l,"a",l),l},a.o=function(u,l){return Object.prototype.hasOwnProperty.call(u,l)},a.p="",a(a.s=2)}([function(n,i,a){var u=this&&this.__extends||function(){var f=function(h,m){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(w,k){w.__proto__=k}||function(w,k){for(var R in k)k.hasOwnProperty(R)&&(w[R]=k[R])},f(h,m)};return function(h,m){f(h,m);function w(){this.constructor=h}h.prototype=m===null?Object.create(m):(w.prototype=m.prototype,new w)}}();Object.defineProperty(i,"__esModule",{value:!0});var l=256,b=function(){function f(h){h===void 0&&(h="="),this._paddingCharacter=h}return f.prototype.encodedLength=function(h){return this._paddingCharacter?(h+2)/3*4|0:(h*8+5)/6|0},f.prototype.encode=function(h){for(var m="",w=0;w<h.length-2;w+=3){var k=h[w]<<16|h[w+1]<<8|h[w+2];m+=this._encodeByte(k>>>3*6&63),m+=this._encodeByte(k>>>2*6&63),m+=this._encodeByte(k>>>1*6&63),m+=this._encodeByte(k>>>0*6&63)}var R=h.length-w;if(R>0){var k=h[w]<<16|(R===2?h[w+1]<<8:0);m+=this._encodeByte(k>>>3*6&63),m+=this._encodeByte(k>>>2*6&63),R===2?m+=this._encodeByte(k>>>1*6&63):m+=this._paddingCharacter||"",m+=this._paddingCharacter||""}return m},f.prototype.maxDecodedLength=function(h){return this._paddingCharacter?h/4*3|0:(h*6+7)/8|0},f.prototype.decodedLength=function(h){return this.maxDecodedLength(h.length-this._getPaddingLength(h))},f.prototype.decode=function(h){if(h.length===0)return new Uint8Array(0);for(var m=this._getPaddingLength(h),w=h.length-m,k=new Uint8Array(this.maxDecodedLength(w)),R=0,O=0,A=0,j=0,N=0,B=0,F=0;O<w-4;O+=4)j=this._decodeChar(h.charCodeAt(O+0)),N=this._decodeChar(h.charCodeAt(O+1)),B=this._decodeChar(h.charCodeAt(O+2)),F=this._decodeChar(h.charCodeAt(O+3)),k[R++]=j<<2|N>>>4,k[R++]=N<<4|B>>>2,k[R++]=B<<6|F,A|=j&l,A|=N&l,A|=B&l,A|=F&l;if(O<w-1&&(j=this._decodeChar(h.charCodeAt(O)),N=this._decodeChar(h.charCodeAt(O+1)),k[R++]=j<<2|N>>>4,A|=j&l,A|=N&l),O<w-2&&(B=this._decodeChar(h.charCodeAt(O+2)),k[R++]=N<<4|B>>>2,A|=B&l),O<w-3&&(F=this._decodeChar(h.charCodeAt(O+3)),k[R++]=B<<6|F,A|=F&l),A!==0)throw new Error("Base64Coder: incorrect characters for decoding");return k},f.prototype._encodeByte=function(h){var m=h;return m+=65,m+=25-h>>>8&6,m+=51-h>>>8&-75,m+=61-h>>>8&-15,m+=62-h>>>8&3,String.fromCharCode(m)},f.prototype._decodeChar=function(h){var m=l;return m+=(42-h&h-44)>>>8&-256+h-43+62,m+=(46-h&h-48)>>>8&-256+h-47+63,m+=(47-h&h-58)>>>8&-256+h-48+52,m+=(64-h&h-91)>>>8&-256+h-65+0,m+=(96-h&h-123)>>>8&-256+h-97+26,m},f.prototype._getPaddingLength=function(h){var m=0;if(this._paddingCharacter){for(var w=h.length-1;w>=0&&h[w]===this._paddingCharacter;w--)m++;if(h.length<4||m>2)throw new Error("Base64Coder: incorrect padding")}return m},f}();i.Coder=b;var x=new b;function T(f){return x.encode(f)}i.encode=T;function p(f){return x.decode(f)}i.decode=p;var S=function(f){u(h,f);function h(){return f!==null&&f.apply(this,arguments)||this}return h.prototype._encodeByte=function(m){var w=m;return w+=65,w+=25-m>>>8&6,w+=51-m>>>8&-75,w+=61-m>>>8&-13,w+=62-m>>>8&49,String.fromCharCode(w)},h.prototype._decodeChar=function(m){var w=l;return w+=(44-m&m-46)>>>8&-256+m-45+62,w+=(94-m&m-96)>>>8&-256+m-95+63,w+=(47-m&m-58)>>>8&-256+m-48+52,w+=(64-m&m-91)>>>8&-256+m-65+0,w+=(96-m&m-123)>>>8&-256+m-97+26,w},h}(b);i.URLSafeCoder=S;var C=new S;function _(f){return C.encode(f)}i.encodeURLSafe=_;function y(f){return C.decode(f)}i.decodeURLSafe=y,i.encodedLength=function(f){return x.encodedLength(f)},i.maxDecodedLength=function(f){return x.maxDecodedLength(f)},i.decodedLength=function(f){return x.decodedLength(f)}},function(n,i,a){Object.defineProperty(i,"__esModule",{value:!0});var u="utf8: invalid string",l="utf8: invalid source encoding";function b(p){for(var S=new Uint8Array(x(p)),C=0,_=0;_<p.length;_++){var y=p.charCodeAt(_);y<128?S[C++]=y:y<2048?(S[C++]=192|y>>6,S[C++]=128|y&63):y<55296?(S[C++]=224|y>>12,S[C++]=128|y>>6&63,S[C++]=128|y&63):(_++,y=(y&1023)<<10,y|=p.charCodeAt(_)&1023,y+=65536,S[C++]=240|y>>18,S[C++]=128|y>>12&63,S[C++]=128|y>>6&63,S[C++]=128|y&63)}return S}i.encode=b;function x(p){for(var S=0,C=0;C<p.length;C++){var _=p.charCodeAt(C);if(_<128)S+=1;else if(_<2048)S+=2;else if(_<55296)S+=3;else if(_<=57343){if(C>=p.length-1)throw new Error(u);C++,S+=4}else throw new Error(u)}return S}i.encodedLength=x;function T(p){for(var S=[],C=0;C<p.length;C++){var _=p[C];if(_&128){var y=void 0;if(_<224){if(C>=p.length)throw new Error(l);var f=p[++C];if((f&192)!==128)throw new Error(l);_=(_&31)<<6|f&63,y=128}else if(_<240){if(C>=p.length-1)throw new Error(l);var f=p[++C],h=p[++C];if((f&192)!==128||(h&192)!==128)throw new Error(l);_=(_&15)<<12|(f&63)<<6|h&63,y=2048}else if(_<248){if(C>=p.length-2)throw new Error(l);var f=p[++C],h=p[++C],m=p[++C];if((f&192)!==128||(h&192)!==128||(m&192)!==128)throw new Error(l);_=(_&15)<<18|(f&63)<<12|(h&63)<<6|m&63,y=65536}else throw new Error(l);if(_<y||_>=55296&&_<=57343)throw new Error(l);if(_>=65536){if(_>1114111)throw new Error(l);_-=65536,S.push(String.fromCharCode(55296|_>>10)),_=56320|_&1023}}S.push(String.fromCharCode(_))}return S.join("")}i.decode=T},function(n,i,a){n.exports=a(3).default},function(n,i,a){a.r(i);class u{constructor(t,s){this.lastId=0,this.prefix=t,this.name=s}create(t){this.lastId++;var s=this.lastId,c=this.prefix+s,d=this.name+"["+s+"]",E=!1,P=function(){E||(t.apply(null,arguments),E=!0)};return this[s]=P,{number:s,id:c,name:d,callback:P}}remove(t){delete this[t.number]}}var l=new u("_pusher_script_","Pusher.ScriptReceivers"),b={VERSION:"8.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,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:""},x=b;class T{constructor(t){this.options=t,this.receivers=t.receivers||l,this.loading={}}load(t,s,c){var d=this;if(d.loading[t]&&d.loading[t].length>0)d.loading[t].push(c);else{d.loading[t]=[c];var E=I.createScriptRequest(d.getPath(t,s)),P=d.receivers.create(function(L){if(d.receivers.remove(P),d.loading[t]){var D=d.loading[t];delete d.loading[t];for(var q=function(J){J||E.cleanup()},M=0;M<D.length;M++)D[M](L,q)}});E.send(P)}}getRoot(t){var s,c=I.getDocument().location.protocol;return t&&t.useTLS||c==="https:"?s=this.options.cdn_https:s=this.options.cdn_http,s.replace(/\/*$/,"")+"/"+this.options.version}getPath(t,s){return this.getRoot(s)+"/"+t+this.options.suffix+".js"}}var p=new u("_pusher_dependencies","Pusher.DependenciesReceivers"),S=new T({cdn_http:x.cdn_http,cdn_https:x.cdn_https,version:x.VERSION,suffix:x.dependency_suffix,receivers:p});const C={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"}}};var y={buildLogSuffix:function(o){const t="See:",s=C.urls[o];if(!s)return"";let c;return s.fullUrl?c=s.fullUrl:s.path&&(c=C.baseUrl+s.path),c?`${t} ${c}`:""}},f;(function(o){o.UserAuthentication="user-authentication",o.ChannelAuthorization="channel-authorization"})(f||(f={}));class h extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class m extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class w extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class k extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class R extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class O extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class A extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class j extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class N extends Error{constructor(t,s){super(s),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}var F=function(o,t,s,c,d){const E=I.createXHR();E.open("POST",s.endpoint,!0),E.setRequestHeader("Content-Type","application/x-www-form-urlencoded");for(var P in s.headers)E.setRequestHeader(P,s.headers[P]);if(s.headersProvider!=null){let L=s.headersProvider();for(var P in L)E.setRequestHeader(P,L[P])}return E.onreadystatechange=function(){if(E.readyState===4)if(E.status===200){let L,D=!1;try{L=JSON.parse(E.responseText),D=!0}catch{d(new N(200,`JSON returned from ${c.toString()} endpoint was invalid, yet status code was 200. Data was: ${E.responseText}`),null)}D&&d(null,L)}else{let L="";switch(c){case f.UserAuthentication:L=y.buildLogSuffix("authenticationEndpoint");break;case f.ChannelAuthorization:L=`Clients must be authorized to join private or presence channels. ${y.buildLogSuffix("authorizationEndpoint")}`;break}d(new N(E.status,`Unable to retrieve auth string from ${c.toString()} endpoint - received status: ${E.status} from ${s.endpoint}. ${L}`),null)}},E.send(t),E};function ae(o){return be(ze(o))}var ne=String.fromCharCode,$="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",He=function(o){var t=o.charCodeAt(0);return t<128?o:t<2048?ne(192|t>>>6)+ne(128|t&63):ne(224|t>>>12&15)+ne(128|t>>>6&63)+ne(128|t&63)},ze=function(o){return o.replace(/[^\x00-\x7F]/g,He)},Ve=function(o){var t=[0,2,1][o.length%3],s=o.charCodeAt(0)<<16|(o.length>1?o.charCodeAt(1):0)<<8|(o.length>2?o.charCodeAt(2):0),c=[$.charAt(s>>>18),$.charAt(s>>>12&63),t>=2?"=":$.charAt(s>>>6&63),t>=1?"=":$.charAt(s&63)];return c.join("")},be=window.btoa||function(o){return o.replace(/[\s\S]{1,3}/g,Ve)};class xe{constructor(t,s,c,d){this.clear=s,this.timer=t(()=>{this.timer&&(this.timer=d(this.timer))},c)}isRunning(){return this.timer!==null}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}var ce=xe;function Je(o){window.clearTimeout(o)}function Ee(o){window.clearInterval(o)}class K extends ce{constructor(t,s){super(setTimeout,Je,t,function(c){return s(),null})}}class Xe extends ce{constructor(t,s){super(setInterval,Ee,t,function(c){return s(),c})}}var Ct={now(){return Date.now?Date.now():new Date().valueOf()},defer(o){return new K(0,o)},method(o,...t){var s=Array.prototype.slice.call(arguments,1);return function(c){return c[o].apply(c,s.concat(arguments))}}},V=Ct;function Y(o,...t){for(var s=0;s<t.length;s++){var c=t[s];for(var d in c)c[d]&&c[d].constructor&&c[d].constructor===Object?o[d]=Y(o[d]||{},c[d]):o[d]=c[d]}return o}function Ti(){for(var o=["Pusher"],t=0;t<arguments.length;t++)typeof arguments[t]=="string"?o.push(arguments[t]):o.push(We(arguments[t]));return o.join(" : ")}function Hn(o,t){var s=Array.prototype.indexOf;if(o===null)return-1;if(s&&o.indexOf===s)return o.indexOf(t);for(var c=0,d=o.length;c<d;c++)if(o[c]===t)return c;return-1}function se(o,t){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&t(o[s],s,o)}function zn(o){var t=[];return se(o,function(s,c){t.push(c)}),t}function ki(o){var t=[];return se(o,function(s){t.push(s)}),t}function Te(o,t,s){for(var c=0;c<o.length;c++)t.call(s||window,o[c],c,o)}function Vn(o,t){for(var s=[],c=0;c<o.length;c++)s.push(t(o[c],c,o,s));return s}function Ri(o,t){var s={};return se(o,function(c,d){s[d]=t(c)}),s}function Jn(o,t){t=t||function(d){return!!d};for(var s=[],c=0;c<o.length;c++)t(o[c],c,o,s)&&s.push(o[c]);return s}function Xn(o,t){var s={};return se(o,function(c,d){(t&&t(c,d,o,s)||c)&&(s[d]=c)}),s}function Oi(o){var t=[];return se(o,function(s,c){t.push([c,s])}),t}function Wn(o,t){for(var s=0;s<o.length;s++)if(t(o[s],s,o))return!0;return!1}function Pi(o,t){for(var s=0;s<o.length;s++)if(!t(o[s],s,o))return!1;return!0}function Ai(o){return Ri(o,function(t){return typeof t=="object"&&(t=We(t)),encodeURIComponent(ae(t.toString()))})}function Ni(o){var t=Xn(o,function(c){return c!==void 0}),s=Vn(Oi(Ai(t)),V.method("join","=")).join("&");return s}function Li(o){var t=[],s=[];return function c(d,E){var P,L,D;switch(typeof d){case"object":if(!d)return null;for(P=0;P<t.length;P+=1)if(t[P]===d)return{$ref:s[P]};if(t.push(d),s.push(E),Object.prototype.toString.apply(d)==="[object Array]")for(D=[],P=0;P<d.length;P+=1)D[P]=c(d[P],E+"["+P+"]");else{D={};for(L in d)Object.prototype.hasOwnProperty.call(d,L)&&(D[L]=c(d[L],E+"["+JSON.stringify(L)+"]"))}return D;case"number":case"string":case"boolean":return d}}(o,"$")}function We(o){try{return JSON.stringify(o)}catch{return JSON.stringify(Li(o))}}class ji{constructor(){this.globalLog=t=>{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...s){var c=Ti.apply(this,arguments);jt.log?jt.log(c):jt.logToConsole&&t.bind(this)(c)}}var z=new ji,Di=function(o,t,s,c,d){(s.headers!==void 0||s.headersProvider!=null)&&z.warn(`To send headers with the ${c.toString()} request, you must use AJAX, rather than JSONP.`);var E=o.nextAuthCallbackID.toString();o.nextAuthCallbackID++;var P=o.getDocument(),L=P.createElement("script");o.auth_callbacks[E]=function(M){d(null,M)};var D="Pusher.auth_callbacks['"+E+"']";L.src=s.endpoint+"?callback="+encodeURIComponent(D)+"&"+t;var q=P.getElementsByTagName("head")[0]||P.documentElement;q.insertBefore(L,q.firstChild)},Ui=Di;class Ii{constructor(t){this.src=t}send(t){var s=this,c="Error loading "+s.src;s.script=document.createElement("script"),s.script.id=t.id,s.script.src=s.src,s.script.type="text/javascript",s.script.charset="UTF-8",s.script.addEventListener?(s.script.onerror=function(){t.callback(c)},s.script.onload=function(){t.callback(null)}):s.script.onreadystatechange=function(){(s.script.readyState==="loaded"||s.script.readyState==="complete")&&t.callback(null)},s.script.async===void 0&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(s.errorScript=document.createElement("script"),s.errorScript.id=t.id+"_error",s.errorScript.text=t.name+"('"+c+"');",s.script.async=s.errorScript.async=!1):s.script.async=!0;var d=document.getElementsByTagName("head")[0];d.insertBefore(s.script,d.firstChild),s.errorScript&&d.insertBefore(s.errorScript,s.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Bi{constructor(t,s){this.url=t,this.data=s}send(t){if(!this.request){var s=Ni(this.data),c=this.url+"/"+t.number+"?"+s;this.request=I.createScriptRequest(c),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Fi=function(o,t){return function(s,c){var d="http"+(t?"s":"")+"://",E=d+(o.host||o.options.host)+o.options.path,P=I.createJSONPRequest(E,s),L=I.ScriptReceivers.create(function(D,q){l.remove(L),P.cleanup(),q&&q.host&&(o.host=q.host),c&&c(D,q)});P.send(L)}},qi={name:"jsonp",getAgent:Fi},Mi=qi;function xt(o,t,s){var c=o+(t.useTLS?"s":""),d=t.useTLS?t.hostTLS:t.hostNonTLS;return c+"://"+d+s}function Et(o,t){var s="/app/"+o,c="?protocol="+x.PROTOCOL+"&client=js&version="+x.VERSION+(t?"&"+t:"");return s+c}var $i={getInitial:function(o,t){var s=(t.httpPath||"")+Et(o,"flash=false");return xt("ws",t,s)}},Hi={getInitial:function(o,t){var s=(t.httpPath||"/pusher")+Et(o);return xt("http",t,s)}},zi={getInitial:function(o,t){return xt("http",t,t.httpPath||"/pusher")},getPath:function(o,t){return Et(o)}};class Vi{constructor(){this._callbacks={}}get(t){return this._callbacks[Tt(t)]}add(t,s,c){var d=Tt(t);this._callbacks[d]=this._callbacks[d]||[],this._callbacks[d].push({fn:s,context:c})}remove(t,s,c){if(!t&&!s&&!c){this._callbacks={};return}var d=t?[Tt(t)]:zn(this._callbacks);s||c?this.removeCallback(d,s,c):this.removeAllCallbacks(d)}removeCallback(t,s,c){Te(t,function(d){this._callbacks[d]=Jn(this._callbacks[d]||[],function(E){return s&&s!==E.fn||c&&c!==E.context}),this._callbacks[d].length===0&&delete this._callbacks[d]},this)}removeAllCallbacks(t){Te(t,function(s){delete this._callbacks[s]},this)}}function Tt(o){return"_"+o}class ie{constructor(t){this.callbacks=new Vi,this.global_callbacks=[],this.failThrough=t}bind(t,s,c){return this.callbacks.add(t,s,c),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,s,c){return this.callbacks.remove(t,s,c),this}unbind_global(t){return t?(this.global_callbacks=Jn(this.global_callbacks||[],s=>s!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,s,c){for(var d=0;d<this.global_callbacks.length;d++)this.global_callbacks[d](t,s);var E=this.callbacks.get(t),P=[];if(c?P.push(s,c):s&&P.push(s),E&&E.length>0)for(var d=0;d<E.length;d++)E[d].fn.apply(E[d].context||window,P);else this.failThrough&&this.failThrough(t,s);return this}}class Ji extends ie{constructor(t,s,c,d,E){super(),this.initialize=I.transportConnectionInitializer,this.hooks=t,this.name=s,this.priority=c,this.key=d,this.options=E,this.state="new",this.timeline=E.timeline,this.activityTimeout=E.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return!!this.hooks.handlesActivityChecks}supportsPing(){return!!this.hooks.supportsPing}connect(){if(this.socket||this.state!=="initialized")return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(s){return V.defer(()=>{this.onError(s),this.changeState("closed")}),!1}return this.bindListeners(),z.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return this.socket?(this.socket.close(),!0):!1}send(t){return this.state==="open"?(V.defer(()=>{this.socket&&this.socket.send(t)}),!0):!1}ping(){this.state==="open"&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){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))}changeState(t,s){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:s})),this.emit(t,s)}buildTimelineMessage(t){return Y({cid:this.id},t)}}class ye{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,s,c,d){return new Ji(this.hooks,t,s,c,d)}}var Xi=new ye({urls:$i,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return!!I.getWebSocketAPI()},isSupported:function(){return!!I.getWebSocketAPI()},getSocket:function(o){return I.createWebSocket(o)}}),Kn={urls:Hi,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},Qn=Y({getSocket:function(o){return I.HTTPFactory.createStreamingSocket(o)}},Kn),Gn=Y({getSocket:function(o){return I.HTTPFactory.createPollingSocket(o)}},Kn),Zn={isSupported:function(){return I.isXHRSupported()}},Wi=new ye(Y({},Qn,Zn)),Ki=new ye(Y({},Gn,Zn)),Qi={ws:Xi,xhr_streaming:Wi,xhr_polling:Ki},Ke=Qi,Gi=new ye({file:"sockjs",urls:zi,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return window.SockJS!==void 0},getSocket:function(o,t){return new window.SockJS(o,null,{js_path:S.getPath("sockjs",{useTLS:t.useTLS}),ignore_null_origin:t.ignoreNullOrigin})},beforeOpen:function(o,t){o.send(JSON.stringify({path:t}))}}),Yn={isSupported:function(o){var t=I.isXDRSupported(o.useTLS);return t}},Zi=new ye(Y({},Qn,Yn)),Yi=new ye(Y({},Gn,Yn));Ke.xdr_streaming=Zi,Ke.xdr_polling=Yi,Ke.sockjs=Gi;var eo=Ke;class to extends ie{constructor(){super();var t=this;window.addEventListener!==void 0&&(window.addEventListener("online",function(){t.emit("online")},!1),window.addEventListener("offline",function(){t.emit("offline")},!1))}isOnline(){return window.navigator.onLine===void 0?!0:window.navigator.onLine}}var no=new to;class ro{constructor(t,s,c){this.manager=t,this.transport=s,this.minPingDelay=c.minPingDelay,this.maxPingDelay=c.maxPingDelay,this.pingDelay=void 0}createConnection(t,s,c,d){d=Y({},d,{activityTimeout:this.pingDelay});var E=this.transport.createConnection(t,s,c,d),P=null,L=function(){E.unbind("open",L),E.bind("closed",D),P=V.now()},D=q=>{if(E.unbind("closed",D),q.code===1002||q.code===1003)this.manager.reportDeath();else if(!q.wasClean&&P){var M=V.now()-P;M<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(M/2,this.minPingDelay))}};return E.bind("open",L),E}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const er={decodeMessage:function(o){try{var t=JSON.parse(o.data),s=t.data;if(typeof s=="string")try{s=JSON.parse(t.data)}catch{}var c={event:t.event,channel:t.channel,data:s};return t.user_id&&(c.user_id=t.user_id),c}catch(d){throw{type:"MessageParseError",error:d,data:o.data}}},encodeMessage:function(o){return JSON.stringify(o)},processHandshake:function(o){var t=er.decodeMessage(o);if(t.event==="pusher:connection_established"){if(!t.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:t.data.socket_id,activityTimeout:t.data.activity_timeout*1e3}}else{if(t.event==="pusher:error")return{action:this.getCloseAction(t.data),error:this.getCloseError(t.data)};throw"Invalid handshake"}},getCloseAction:function(o){return o.code<4e3?o.code>=1002&&o.code<=1004?"backoff":null:o.code===4e3?"tls_only":o.code<4100?"refused":o.code<4200?"backoff":o.code<4300?"retry":"refused"},getCloseError:function(o){return o.code!==1e3&&o.code!==1001?{type:"PusherError",data:{code:o.code,message:o.reason||o.message}}:null}};var de=er;class so extends ie{constructor(t,s){super(),this.id=t,this.transport=s,this.activityTimeout=s.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,s,c){var d={event:t,data:s};return c&&(d.channel=c),z.debug("Event sent",d),this.send(de.encodeMessage(d))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:c=>{var d;try{d=de.decodeMessage(c)}catch(E){this.emit("error",{type:"MessageParseError",error:E,data:c.data})}if(d!==void 0){switch(z.debug("Event recd",d),d.event){case"pusher:error":this.emit("error",{type:"PusherError",data:d.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong");break}this.emit("message",d)}},activity:()=>{this.emit("activity")},error:c=>{this.emit("error",c)},closed:c=>{s(),c&&c.code&&this.handleCloseEvent(c),this.transport=null,this.emit("closed")}},s=()=>{se(t,(c,d)=>{this.transport.unbind(d,c)})};se(t,(c,d)=>{this.transport.bind(d,c)})}handleCloseEvent(t){var s=de.getCloseAction(t),c=de.getCloseError(t);c&&this.emit("error",c),s&&this.emit(s,{action:s,error:c})}}class io{constructor(t,s){this.transport=t,this.callback=s,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{this.unbindListeners();var s;try{s=de.processHandshake(t)}catch(c){this.finish("error",{error:c}),this.transport.close();return}s.action==="connected"?this.finish("connected",{connection:new so(s.id,this.transport),activityTimeout:s.activityTimeout}):(this.finish(s.action,{error:s.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var s=de.getCloseAction(t)||"backoff",c=de.getCloseError(t);this.finish(s,{error:c})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,s){this.callback(Y({transport:this.transport,action:t},s))}}class oo{constructor(t,s){this.timeline=t,this.options=s||{}}send(t,s){this.timeline.isEmpty()||this.timeline.send(I.TimelineTransport.getAgent(this,t),s)}}class kt extends ie{constructor(t,s){super(function(c,d){z.debug("No callbacks on "+t+" for "+c)}),this.name=t,this.pusher=s,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,s){return s(null,{auth:""})}trigger(t,s){if(t.indexOf("client-")!==0)throw new h("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var c=y.buildLogSuffix("triggeringClientEvents");z.warn(`Client event triggered before channel 'subscription_succeeded' event . ${c}`)}return this.pusher.send_event(t,s,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var s=t.event,c=t.data;if(s==="pusher_internal:subscription_succeeded")this.handleSubscriptionSucceededEvent(t);else if(s==="pusher_internal:subscription_count")this.handleSubscriptionCountEvent(t);else if(s.indexOf("pusher_internal:")!==0){var d={};this.emit(s,c,d)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,s)=>{t?(this.subscriptionPending=!1,z.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof N?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:s.auth,channel_data:s.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class Rt extends kt{authorize(t,s){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},s)}}class ao{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){se(this.members,(s,c)=>{t(this.get(c))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return this.get(t.user_id)===null&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var s=this.get(t.user_id);return s&&(delete this.members[t.user_id],this.count--),s}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var co=function(o,t,s,c){function d(E){return E instanceof s?E:new s(function(P){P(E)})}return new(s||(s=Promise))(function(E,P){function L(M){try{q(c.next(M))}catch(J){P(J)}}function D(M){try{q(c.throw(M))}catch(J){P(J)}}function q(M){M.done?E(M.value):d(M.value).then(L,D)}q((c=c.apply(o,t||[])).next())})};class lo extends Rt{constructor(t,s){super(t,s),this.members=new ao}authorize(t,s){super.authorize(t,(c,d)=>co(this,void 0,void 0,function*(){if(!c)if(d=d,d.channel_data!=null){var E=JSON.parse(d.channel_data);this.members.setMyID(E.user_id)}else if(yield this.pusher.user.signinDonePromise,this.pusher.user.user_data!=null)this.members.setMyID(this.pusher.user.user_data.id);else{let P=y.buildLogSuffix("authorizationEndpoint");z.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${P}, or the user should be signed in.`),s("Invalid auth response");return}s(c,d)}))}handleEvent(t){var s=t.event;if(s.indexOf("pusher_internal:")===0)this.handleInternalEvent(t);else{var c=t.data,d={};t.user_id&&(d.user_id=t.user_id),this.emit(s,c,d)}}handleInternalEvent(t){var s=t.event,c=t.data;switch(s){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var d=this.members.addMember(c);this.emit("pusher:member_added",d);break;case"pusher_internal:member_removed":var E=this.members.removeMember(c);E&&this.emit("pusher:member_removed",E);break}}handleSubscriptionSucceededEvent(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))}disconnect(){this.members.reset(),super.disconnect()}}var uo=a(1),Ot=a(0);class ho extends Rt{constructor(t,s,c){super(t,s),this.key=null,this.nacl=c}authorize(t,s){super.authorize(t,(c,d)=>{if(c){s(c,d);return}let E=d.shared_secret;if(!E){s(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`),null);return}this.key=Object(Ot.decode)(E),delete d.shared_secret,s(null,d)})}trigger(t,s){throw new O("Client events are not currently supported for encrypted channels")}handleEvent(t){var s=t.event,c=t.data;if(s.indexOf("pusher_internal:")===0||s.indexOf("pusher:")===0){super.handleEvent(t);return}this.handleEncryptedEvent(s,c)}handleEncryptedEvent(t,s){if(!this.key){z.debug("Received encrypted event before key has been retrieved from the authEndpoint");return}if(!s.ciphertext||!s.nonce){z.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+s);return}let c=Object(Ot.decode)(s.ciphertext);if(c.length<this.nacl.secretbox.overheadLength){z.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${c.length}`);return}let d=Object(Ot.decode)(s.nonce);if(d.length<this.nacl.secretbox.nonceLength){z.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${d.length}`);return}let E=this.nacl.secretbox.open(c,d,this.key);if(E===null){z.debug("Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint..."),this.authorize(this.pusher.connection.socket_id,(P,L)=>{if(P){z.error(`Failed to make a request to the authEndpoint: ${L}. Unable to fetch new key, so dropping encrypted event`);return}if(E=this.nacl.secretbox.open(c,d,this.key),E===null){z.error("Failed to decrypt event with new key. Dropping encrypted event");return}this.emit(t,this.getDataToEmit(E))});return}this.emit(t,this.getDataToEmit(E))}getDataToEmit(t){let s=Object(uo.decode)(t);try{return JSON.parse(s)}catch{return s}}}class fo extends ie{constructor(t,s){super(),this.state="initialized",this.connection=null,this.key=t,this.options=s,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var c=I.getNetwork();c.bind("online",()=>{this.timeline.info({netinfo:"online"}),(this.state==="connecting"||this.state==="unavailable")&&this.retryIn(0)}),c.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}connect(){if(!(this.connection||this.runner)){if(!this.strategy.isSupported()){this.updateState("failed");return}this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()}}send(t){return this.connection?this.connection.send(t):!1}send_event(t,s,c){return this.connection?this.connection.send_event(t,s,c):!1}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(s,c)=>{s?this.runner=this.strategy.connect(0,t):c.action==="error"?(this.emit("error",{type:"HandshakeError",error:c.error}),this.timeline.error({handshakeError:c.error})):(this.abortConnecting(),this.handshakeCallbacks[c.action](c))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){if(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection){var t=this.abandonConnection();t.close()}}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new K(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new K(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new K(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new K(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return Y({},t,{message:s=>{this.resetActivityCheck(),this.emit("message",s)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:s=>{this.emit("error",s)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return Y({},t,{connected:s=>{this.activityTimeout=Math.min(this.options.activityTimeout,s.activityTimeout,s.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(s.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=s=>c=>{c.error&&this.emit("error",{type:"WebSocketError",error:c.error}),s(c)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){this.connection=t;for(var s in this.connectionCallbacks)this.connection.bind(s,this.connectionCallbacks[s]);this.resetActivityCheck()}abandonConnection(){if(this.connection){this.stopActivityCheck();for(var t in this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var s=this.connection;return this.connection=null,s}}updateState(t,s){var c=this.state;if(this.state=t,c!==t){var d=t;d==="connected"&&(d+=" with new socket ID "+s.socket_id),z.debug("State changed",c+" -> "+d),this.timeline.info({state:t,params:s}),this.emit("state_change",{previous:c,current:t}),this.emit(t,s)}}shouldRetry(){return this.state==="connecting"||this.state==="connected"}}class po{constructor(){this.channels={}}add(t,s){return this.channels[t]||(this.channels[t]=mo(t,s)),this.channels[t]}all(){return ki(this.channels)}find(t){return this.channels[t]}remove(t){var s=this.channels[t];return delete this.channels[t],s}disconnect(){se(this.channels,function(t){t.disconnect()})}}function mo(o,t){if(o.indexOf("private-encrypted-")===0){if(t.config.nacl)return oe.createEncryptedChannel(o,t,t.config.nacl);let s="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",c=y.buildLogSuffix("encryptedChannelSupport");throw new O(`${s}. ${c}`)}else{if(o.indexOf("private-")===0)return oe.createPrivateChannel(o,t);if(o.indexOf("presence-")===0)return oe.createPresenceChannel(o,t);if(o.indexOf("#")===0)throw new m('Cannot create a channel with name "'+o+'".');return oe.createChannel(o,t)}}var go={createChannels(){return new po},createConnectionManager(o,t){return new fo(o,t)},createChannel(o,t){return new kt(o,t)},createPrivateChannel(o,t){return new Rt(o,t)},createPresenceChannel(o,t){return new lo(o,t)},createEncryptedChannel(o,t,s){return new ho(o,t,s)},createTimelineSender(o,t){return new oo(o,t)},createHandshake(o,t){return new io(o,t)},createAssistantToTheTransportManager(o,t,s){return new ro(o,t,s)}},oe=go;class tr{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return oe.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class fe{constructor(t,s){this.strategies=t,this.loop=!!s.loop,this.failFast=!!s.failFast,this.timeout=s.timeout,this.timeoutLimit=s.timeoutLimit}isSupported(){return Wn(this.strategies,V.method("isSupported"))}connect(t,s){var c=this.strategies,d=0,E=this.timeout,P=null,L=(D,q)=>{q?s(null,q):(d=d+1,this.loop&&(d=d%c.length),d<c.length?(E&&(E=E*2,this.timeoutLimit&&(E=Math.min(E,this.timeoutLimit))),P=