@dcodegroup-au/dcode-chat-vue
Version:
Frontend vue components for the dcode-laravel-chat package
7 lines • 150 kB
JavaScript
(function(G,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(G=typeof globalThis<"u"?globalThis:G||self,d(G["@dcodegroup-au/dcode-chat-vue"]={},G.Vue))})(this,function(G,d){"use strict";class tt{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 Mt{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 nt extends tt{constructor(e,n,s){super(),this.name=n,this.pusher=e,this.options=s,this.eventFormatter=new Mt(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,s)=>{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,s)}),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 $t extends nt{whisper(e,n){return this.pusher.channels.channels[this.name].trigger(`client-${e}`,n),this}}class yr extends nt{whisper(e,n){return this.pusher.channels.channels[this.name].trigger(`client-${e}`,n),this}}class vr extends $t{here(e){return this.on("pusher:subscription_succeeded",n=>{e(Object.keys(n.members).map(s=>n.members[s]))}),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 qt extends tt{constructor(e,n,s){super(),this.events={},this.listeners={},this.name=n,this.socket=e,this.options=s,this.eventFormatter=new Mt(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]=(s,a)=>{this.name===s&&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(s=>s!==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 Ht extends qt{whisper(e,n){return this.socket.emit("client event",{channel:this.name,event:`client-${e}`,data:n}),this}}class wr extends Ht{here(e){return this.on("presence:subscribed",n=>{e(n.map(s=>s.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 Pe extends tt{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 zt extends Pe{whisper(e,n){return this}}class _r extends Pe{whisper(e,n){return this}}class Cr extends zt{here(e){return this}joining(e){return this}whisper(e,n){return this}leaving(e){return this}}const Vt=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 typeof window<"u"&&(e=window.Laravel)!=null&&e.csrfToken?window.Laravel.csrfToken:this.options.csrfToken?this.options.csrfToken:typeof document<"u"&&typeof document.querySelector=="function"?((n=document.querySelector('meta[name="csrf-token"]'))==null?void 0:n.getAttribute("content"))??null:null}};Vt._defaultOptions={auth:{headers:{}},authEndpoint:"/broadcasting/auth",userAuthentication:{endpoint:"/broadcasting/user-auth",headers:{}},csrfToken:null,bearerToken:null,host:null,key:null,namespace:"App.Events"};let rt=Vt;class Ae extends rt{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,s){return this.channel(e).listen(n,s)}channel(e){return this.channels[e]||(this.channels[e]=new nt(this.pusher,e,this.options)),this.channels[e]}privateChannel(e){return this.channels["private-"+e]||(this.channels["private-"+e]=new $t(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 Sr extends rt{constructor(){super(...arguments),this.channels={}}connect(){let e=this.getSocketIO();this.socket=e(this.options.host??void 0,this.options),this.socket.io.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,s){return this.channel(e).listen(n,s)}channel(e){return this.channels[e]||(this.channels[e]=new qt(this.socket,e,this.options)),this.channels[e]}privateChannel(e){return this.channels["private-"+e]||(this.channels["private-"+e]=new Ht(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 Jt extends rt{constructor(){super(...arguments),this.channels={}}connect(){}listen(e,n,s){return new Pe}channel(e){return new Pe}privateChannel(e){return new zt}encryptedPrivateChannel(e){return new _r}presenceChannel(e){return new Cr}leave(e){}leaveChannel(e){}socketId(){return"fake-socket-id"}disconnect(){}}class Xt{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 Ae({...this.options,cluster:""});else if(this.options.broadcaster==="pusher")this.connector=new Ae(this.options);else if(this.options.broadcaster==="ably")this.connector=new Ae({...this.options,cluster:"",broadcaster:"pusher"});else if(this.options.broadcaster==="socket.io")this.connector=new Sr(this.options);else if(this.options.broadcaster==="null")this.connector=new Jt(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,s){return this.connector.listen(e,n,s)}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 Ae||e instanceof Jt}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,s)=>{this.socketId()&&s.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 st={exports:{}};/*!
* Pusher JavaScript Library v8.4.0
* https://pusher.com/
*
* Copyright 2020, Pusher
* Released under the MIT licence.
*/var Wt;function kr(){return Wt||(Wt=1,function(r,e){(function(s,a){r.exports=a()})(window,function(){return function(n){var s={};function a(u){if(s[u])return s[u].exports;var l=s[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=s,a.d=function(u,l,g){a.o(u,l)||Object.defineProperty(u,l,{enumerable:!0,get:g})},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 g=Object.create(null);if(a.r(g),Object.defineProperty(g,"default",{enumerable:!0,value:u}),l&2&&typeof u!="string")for(var S in u)a.d(g,S,(function(x){return u[x]}).bind(null,S));return g},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,s,a){var u=this&&this.__extends||function(){var p=function(h,m){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,E){b.__proto__=E}||function(b,E){for(var O in E)E.hasOwnProperty(O)&&(b[O]=E[O])},p(h,m)};return function(h,m){p(h,m);function b(){this.constructor=h}h.prototype=m===null?Object.create(m):(b.prototype=m.prototype,new b)}}();Object.defineProperty(s,"__esModule",{value:!0});var l=256,g=function(){function p(h){h===void 0&&(h="="),this._paddingCharacter=h}return p.prototype.encodedLength=function(h){return this._paddingCharacter?(h+2)/3*4|0:(h*8+5)/6|0},p.prototype.encode=function(h){for(var m="",b=0;b<h.length-2;b+=3){var E=h[b]<<16|h[b+1]<<8|h[b+2];m+=this._encodeByte(E>>>3*6&63),m+=this._encodeByte(E>>>2*6&63),m+=this._encodeByte(E>>>1*6&63),m+=this._encodeByte(E>>>0*6&63)}var O=h.length-b;if(O>0){var E=h[b]<<16|(O===2?h[b+1]<<8:0);m+=this._encodeByte(E>>>3*6&63),m+=this._encodeByte(E>>>2*6&63),O===2?m+=this._encodeByte(E>>>1*6&63):m+=this._paddingCharacter||"",m+=this._paddingCharacter||""}return m},p.prototype.maxDecodedLength=function(h){return this._paddingCharacter?h/4*3|0:(h*6+7)/8|0},p.prototype.decodedLength=function(h){return this.maxDecodedLength(h.length-this._getPaddingLength(h))},p.prototype.decode=function(h){if(h.length===0)return new Uint8Array(0);for(var m=this._getPaddingLength(h),b=h.length-m,E=new Uint8Array(this.maxDecodedLength(b)),O=0,R=0,P=0,D=0,N=0,j=0,F=0;R<b-4;R+=4)D=this._decodeChar(h.charCodeAt(R+0)),N=this._decodeChar(h.charCodeAt(R+1)),j=this._decodeChar(h.charCodeAt(R+2)),F=this._decodeChar(h.charCodeAt(R+3)),E[O++]=D<<2|N>>>4,E[O++]=N<<4|j>>>2,E[O++]=j<<6|F,P|=D&l,P|=N&l,P|=j&l,P|=F&l;if(R<b-1&&(D=this._decodeChar(h.charCodeAt(R)),N=this._decodeChar(h.charCodeAt(R+1)),E[O++]=D<<2|N>>>4,P|=D&l,P|=N&l),R<b-2&&(j=this._decodeChar(h.charCodeAt(R+2)),E[O++]=N<<4|j>>>2,P|=j&l),R<b-3&&(F=this._decodeChar(h.charCodeAt(R+3)),E[O++]=j<<6|F,P|=F&l),P!==0)throw new Error("Base64Coder: incorrect characters for decoding");return E},p.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)},p.prototype._decodeChar=function(h){var m=l;return m+=(42-h&h-44)>>>8&-l+h-43+62,m+=(46-h&h-48)>>>8&-l+h-47+63,m+=(47-h&h-58)>>>8&-l+h-48+52,m+=(64-h&h-91)>>>8&-l+h-65+0,m+=(96-h&h-123)>>>8&-l+h-97+26,m},p.prototype._getPaddingLength=function(h){var m=0;if(this._paddingCharacter){for(var b=h.length-1;b>=0&&h[b]===this._paddingCharacter;b--)m++;if(h.length<4||m>2)throw new Error("Base64Coder: incorrect padding")}return m},p}();s.Coder=g;var S=new g;function x(p){return S.encode(p)}s.encode=x;function v(p){return S.decode(p)}s.decode=v;var w=function(p){u(h,p);function h(){return p!==null&&p.apply(this,arguments)||this}return h.prototype._encodeByte=function(m){var b=m;return b+=65,b+=25-m>>>8&6,b+=51-m>>>8&-75,b+=61-m>>>8&-13,b+=62-m>>>8&49,String.fromCharCode(b)},h.prototype._decodeChar=function(m){var b=l;return b+=(44-m&m-46)>>>8&-l+m-45+62,b+=(94-m&m-96)>>>8&-l+m-95+63,b+=(47-m&m-58)>>>8&-l+m-48+52,b+=(64-m&m-91)>>>8&-l+m-65+0,b+=(96-m&m-123)>>>8&-l+m-97+26,b},h}(g);s.URLSafeCoder=w;var k=new w;function _(p){return k.encode(p)}s.encodeURLSafe=_;function y(p){return k.decode(p)}s.decodeURLSafe=y,s.encodedLength=function(p){return S.encodedLength(p)},s.maxDecodedLength=function(p){return S.maxDecodedLength(p)},s.decodedLength=function(p){return S.decodedLength(p)}},function(n,s,a){Object.defineProperty(s,"__esModule",{value:!0});var u="utf8: invalid string",l="utf8: invalid source encoding";function g(v){for(var w=new Uint8Array(S(v)),k=0,_=0;_<v.length;_++){var y=v.charCodeAt(_);y<128?w[k++]=y:y<2048?(w[k++]=192|y>>6,w[k++]=128|y&63):y<55296?(w[k++]=224|y>>12,w[k++]=128|y>>6&63,w[k++]=128|y&63):(_++,y=(y&1023)<<10,y|=v.charCodeAt(_)&1023,y+=65536,w[k++]=240|y>>18,w[k++]=128|y>>12&63,w[k++]=128|y>>6&63,w[k++]=128|y&63)}return w}s.encode=g;function S(v){for(var w=0,k=0;k<v.length;k++){var _=v.charCodeAt(k);if(_<128)w+=1;else if(_<2048)w+=2;else if(_<55296)w+=3;else if(_<=57343){if(k>=v.length-1)throw new Error(u);k++,w+=4}else throw new Error(u)}return w}s.encodedLength=S;function x(v){for(var w=[],k=0;k<v.length;k++){var _=v[k];if(_&128){var y=void 0;if(_<224){if(k>=v.length)throw new Error(l);var p=v[++k];if((p&192)!==128)throw new Error(l);_=(_&31)<<6|p&63,y=128}else if(_<240){if(k>=v.length-1)throw new Error(l);var p=v[++k],h=v[++k];if((p&192)!==128||(h&192)!==128)throw new Error(l);_=(_&15)<<12|(p&63)<<6|h&63,y=2048}else if(_<248){if(k>=v.length-2)throw new Error(l);var p=v[++k],h=v[++k],m=v[++k];if((p&192)!==128||(h&192)!==128||(m&192)!==128)throw new Error(l);_=(_&15)<<18|(p&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,w.push(String.fromCharCode(55296|_>>10)),_=56320|_&1023}}w.push(String.fromCharCode(_))}return w.join("")}s.decode=x},function(n,s,a){n.exports=a(3).default},function(n,s,a){a.r(s);class u{constructor(t,i){this.lastId=0,this.prefix=t,this.name=i}create(t){this.lastId++;var i=this.lastId,c=this.prefix+i,f=this.name+"["+i+"]",T=!1,A=function(){T||(t.apply(null,arguments),T=!0)};return this[i]=A,{number:i,id:c,name:f,callback:A}}remove(t){delete this[t.number]}}var l=new u("_pusher_script_","Pusher.ScriptReceivers"),g={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:""},S=g;class x{constructor(t){this.options=t,this.receivers=t.receivers||l,this.loading={}}load(t,i,c){var f=this;if(f.loading[t]&&f.loading[t].length>0)f.loading[t].push(c);else{f.loading[t]=[c];var T=I.createScriptRequest(f.getPath(t,i)),A=f.receivers.create(function(L){if(f.receivers.remove(A),f.loading[t]){var B=f.loading[t];delete f.loading[t];for(var M=function(J){J||T.cleanup()},$=0;$<B.length;$++)B[$](L,M)}});T.send(A)}}getRoot(t){var i,c=I.getDocument().location.protocol;return t&&t.useTLS||c==="https:"?i=this.options.cdn_https:i=this.options.cdn_http,i.replace(/\/*$/,"")+"/"+this.options.version}getPath(t,i){return this.getRoot(i)+"/"+t+this.options.suffix+".js"}}var v=new u("_pusher_dependencies","Pusher.DependenciesReceivers"),w=new x({cdn_http:S.cdn_http,cdn_https:S.cdn_https,version:S.VERSION,suffix:S.dependency_suffix,receivers:v});const k={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:",i=k.urls[o];if(!i)return"";let c;return i.fullUrl?c=i.fullUrl:i.path&&(c=k.baseUrl+i.path),c?`${t} ${c}`:""}},p;(function(o){o.UserAuthentication="user-authentication",o.ChannelAuthorization="channel-authorization"})(p||(p={}));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 b extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class E 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 R extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class P extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class D extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class N extends Error{constructor(t,i){super(i),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}var F=function(o,t,i,c,f){const T=I.createXHR();T.open("POST",i.endpoint,!0),T.setRequestHeader("Content-Type","application/x-www-form-urlencoded");for(var A in i.headers)T.setRequestHeader(A,i.headers[A]);if(i.headersProvider!=null){let L=i.headersProvider();for(var A in L)T.setRequestHeader(A,L[A])}return T.onreadystatechange=function(){if(T.readyState===4)if(T.status===200){let L,B=!1;try{L=JSON.parse(T.responseText),B=!0}catch{f(new N(200,`JSON returned from ${c.toString()} endpoint was invalid, yet status code was 200. Data was: ${T.responseText}`),null)}B&&f(null,L)}else{let L="";switch(c){case p.UserAuthentication:L=y.buildLogSuffix("authenticationEndpoint");break;case p.ChannelAuthorization:L=`Clients must be authorized to join private or presence channels. ${y.buildLogSuffix("authorizationEndpoint")}`;break}f(new N(T.status,`Unable to retrieve auth string from ${c.toString()} endpoint - received status: ${T.status} from ${i.endpoint}. ${L}`),null)}},T.send(t),T};function X(o){return ye(Je(o))}var ne=String.fromCharCode,q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ve=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)},Je=function(o){return o.replace(/[^\x00-\x7F]/g,Ve)},Xe=function(o){var t=[0,2,1][o.length%3],i=o.charCodeAt(0)<<16|(o.length>1?o.charCodeAt(1):0)<<8|(o.length>2?o.charCodeAt(2):0),c=[q.charAt(i>>>18),q.charAt(i>>>12&63),t>=2?"=":q.charAt(i>>>6&63),t>=1?"=":q.charAt(i&63)];return c.join("")},ye=window.btoa||function(o){return o.replace(/[\s\S]{1,3}/g,Xe)};class ke{constructor(t,i,c,f){this.clear=i,this.timer=t(()=>{this.timer&&(this.timer=f(this.timer))},c)}isRunning(){return this.timer!==null}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}var ce=ke;function We(o){window.clearTimeout(o)}function Ee(o){window.clearInterval(o)}class Q extends ce{constructor(t,i){super(setTimeout,We,t,function(c){return i(),null})}}class Ke extends ce{constructor(t,i){super(setInterval,Ee,t,function(c){return i(),c})}}var Et={now(){return Date.now?Date.now():new Date().valueOf()},defer(o){return new Q(0,o)},method(o,...t){var i=Array.prototype.slice.call(arguments,1);return function(c){return c[o].apply(c,i.concat(arguments))}}},V=Et;function ee(o,...t){for(var i=0;i<t.length;i++){var c=t[i];for(var f in c)c[f]&&c[f].constructor&&c[f].constructor===Object?o[f]=ee(o[f]||{},c[f]):o[f]=c[f]}return o}function zi(){for(var o=["Pusher"],t=0;t<arguments.length;t++)typeof arguments[t]=="string"?o.push(arguments[t]):o.push(Qe(arguments[t]));return o.join(" : ")}function Hn(o,t){var i=Array.prototype.indexOf;if(o===null)return-1;if(i&&o.indexOf===i)return o.indexOf(t);for(var c=0,f=o.length;c<f;c++)if(o[c]===t)return c;return-1}function ie(o,t){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&t(o[i],i,o)}function zn(o){var t=[];return ie(o,function(i,c){t.push(c)}),t}function Vi(o){var t=[];return ie(o,function(i){t.push(i)}),t}function Te(o,t,i){for(var c=0;c<o.length;c++)t.call(i||window,o[c],c,o)}function Vn(o,t){for(var i=[],c=0;c<o.length;c++)i.push(t(o[c],c,o,i));return i}function Ji(o,t){var i={};return ie(o,function(c,f){i[f]=t(c)}),i}function Jn(o,t){t=t||function(f){return!!f};for(var i=[],c=0;c<o.length;c++)t(o[c],c,o,i)&&i.push(o[c]);return i}function Xn(o,t){var i={};return ie(o,function(c,f){(t&&t(c,f,o,i)||c)&&(i[f]=c)}),i}function Xi(o){var t=[];return ie(o,function(i,c){t.push([c,i])}),t}function Wn(o,t){for(var i=0;i<o.length;i++)if(t(o[i],i,o))return!0;return!1}function Wi(o,t){for(var i=0;i<o.length;i++)if(!t(o[i],i,o))return!1;return!0}function Ki(o){return Ji(o,function(t){return typeof t=="object"&&(t=Qe(t)),encodeURIComponent(X(t.toString()))})}function Qi(o){var t=Xn(o,function(c){return c!==void 0}),i=Vn(Xi(Ki(t)),V.method("join","=")).join("&");return i}function Gi(o){var t=[],i=[];return function c(f,T){var A,L,B;switch(typeof f){case"object":if(!f)return null;for(A=0;A<t.length;A+=1)if(t[A]===f)return{$ref:i[A]};if(t.push(f),i.push(T),Object.prototype.toString.apply(f)==="[object Array]")for(B=[],A=0;A<f.length;A+=1)B[A]=c(f[A],T+"["+A+"]");else{B={};for(L in f)Object.prototype.hasOwnProperty.call(f,L)&&(B[L]=c(f[L],T+"["+JSON.stringify(L)+"]"))}return B;case"number":case"string":case"boolean":return f}}(o,"$")}function Qe(o){try{return JSON.stringify(o)}catch{return JSON.stringify(Gi(o))}}class Zi{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,...i){var c=zi.apply(this,arguments);Ut.log?Ut.log(c):Ut.logToConsole&&t.bind(this)(c)}}var z=new Zi,Yi=function(o,t,i,c,f){(i.headers!==void 0||i.headersProvider!=null)&&z.warn(`To send headers with the ${c.toString()} request, you must use AJAX, rather than JSONP.`);var T=o.nextAuthCallbackID.toString();o.nextAuthCallbackID++;var A=o.getDocument(),L=A.createElement("script");o.auth_callbacks[T]=function($){f(null,$)};var B="Pusher.auth_callbacks['"+T+"']";L.src=i.endpoint+"?callback="+encodeURIComponent(B)+"&"+t;var M=A.getElementsByTagName("head")[0]||A.documentElement;M.insertBefore(L,M.firstChild)},eo=Yi;class to{constructor(t){this.src=t}send(t){var i=this,c="Error loading "+i.src;i.script=document.createElement("script"),i.script.id=t.id,i.script.src=i.src,i.script.type="text/javascript",i.script.charset="UTF-8",i.script.addEventListener?(i.script.onerror=function(){t.callback(c)},i.script.onload=function(){t.callback(null)}):i.script.onreadystatechange=function(){(i.script.readyState==="loaded"||i.script.readyState==="complete")&&t.callback(null)},i.script.async===void 0&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(i.errorScript=document.createElement("script"),i.errorScript.id=t.id+"_error",i.errorScript.text=t.name+"('"+c+"');",i.script.async=i.errorScript.async=!1):i.script.async=!0;var f=document.getElementsByTagName("head")[0];f.insertBefore(i.script,f.firstChild),i.errorScript&&f.insertBefore(i.errorScript,i.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 no{constructor(t,i){this.url=t,this.data=i}send(t){if(!this.request){var i=Qi(this.data),c=this.url+"/"+t.number+"?"+i;this.request=I.createScriptRequest(c),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var ro=function(o,t){return function(i,c){var f="http"+(t?"s":"")+"://",T=f+(o.host||o.options.host)+o.options.path,A=I.createJSONPRequest(T,i),L=I.ScriptReceivers.create(function(B,M){l.remove(L),A.cleanup(),M&&M.host&&(o.host=M.host),c&&c(B,M)});A.send(L)}},so={name:"jsonp",getAgent:ro},io=so;function Tt(o,t,i){var c=o+(t.useTLS?"s":""),f=t.useTLS?t.hostTLS:t.hostNonTLS;return c+"://"+f+i}function Rt(o,t){var i="/app/"+o,c="?protocol="+S.PROTOCOL+"&client=js&version="+S.VERSION+(t?"&"+t:"");return i+c}var oo={getInitial:function(o,t){var i=(t.httpPath||"")+Rt(o,"flash=false");return Tt("ws",t,i)}},ao={getInitial:function(o,t){var i=(t.httpPath||"/pusher")+Rt(o);return Tt("http",t,i)}},co={getInitial:function(o,t){return Tt("http",t,t.httpPath||"/pusher")},getPath:function(o,t){return Rt(o)}};class lo{constructor(){this._callbacks={}}get(t){return this._callbacks[Ot(t)]}add(t,i,c){var f=Ot(t);this._callbacks[f]=this._callbacks[f]||[],this._callbacks[f].push({fn:i,context:c})}remove(t,i,c){if(!t&&!i&&!c){this._callbacks={};return}var f=t?[Ot(t)]:zn(this._callbacks);i||c?this.removeCallback(f,i,c):this.removeAllCallbacks(f)}removeCallback(t,i,c){Te(t,function(f){this._callbacks[f]=Jn(this._callbacks[f]||[],function(T){return i&&i!==T.fn||c&&c!==T.context}),this._callbacks[f].length===0&&delete this._callbacks[f]},this)}removeAllCallbacks(t){Te(t,function(i){delete this._callbacks[i]},this)}}function Ot(o){return"_"+o}class oe{constructor(t){this.callbacks=new lo,this.global_callbacks=[],this.failThrough=t}bind(t,i,c){return this.callbacks.add(t,i,c),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,i,c){return this.callbacks.remove(t,i,c),this}unbind_global(t){return t?(this.global_callbacks=Jn(this.global_callbacks||[],i=>i!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,i,c){for(var f=0;f<this.global_callbacks.length;f++)this.global_callbacks[f](t,i);var T=this.callbacks.get(t),A=[];if(c?A.push(i,c):i&&A.push(i),T&&T.length>0)for(var f=0;f<T.length;f++)T[f].fn.apply(T[f].context||window,A);else this.failThrough&&this.failThrough(t,i);return this}}class uo extends oe{constructor(t,i,c,f,T){super(),this.initialize=I.transportConnectionInitializer,this.hooks=t,this.name=i,this.priority=c,this.key=f,this.options=T,this.state="new",this.timeline=T.timeline,this.activityTimeout=T.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(i){return V.defer(()=>{this.onError(i),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,i){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:i})),this.emit(t,i)}buildTimelineMessage(t){return ee({cid:this.id},t)}}class ve{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,i,c,f){return new uo(this.hooks,t,i,c,f)}}var ho=new ve({urls:oo,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return!!I.getWebSocketAPI()},isSupported:function(){return!!I.getWebSocketAPI()},getSocket:function(o){return I.createWebSocket(o)}}),Kn={urls:ao,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},Qn=ee({getSocket:function(o){return I.HTTPFactory.createStreamingSocket(o)}},Kn),Gn=ee({getSocket:function(o){return I.HTTPFactory.createPollingSocket(o)}},Kn),Zn={isSupported:function(){return I.isXHRSupported()}},fo=new ve(ee({},Qn,Zn)),po=new ve(ee({},Gn,Zn)),mo={ws:ho,xhr_streaming:fo,xhr_polling:po},Ge=mo,go=new ve({file:"sockjs",urls:co,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:w.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}},bo=new ve(ee({},Qn,Yn)),yo=new ve(ee({},Gn,Yn));Ge.xdr_streaming=bo,Ge.xdr_polling=yo,Ge.sockjs=go;var vo=Ge;class wo extends oe{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 _o=new wo;class Co{constructor(t,i,c){this.manager=t,this.transport=i,this.minPingDelay=c.minPingDelay,this.maxPingDelay=c.maxPingDelay,this.pingDelay=void 0}createConnection(t,i,c,f){f=ee({},f,{activityTimeout:this.pingDelay});var T=this.transport.createConnection(t,i,c,f),A=null,L=function(){T.unbind("open",L),T.bind("closed",B),A=V.now()},B=M=>{if(T.unbind("closed",B),M.code===1002||M.code===1003)this.manager.reportDeath();else if(!M.wasClean&&A){var $=V.now()-A;$<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max($/2,this.minPingDelay))}};return T.bind("open",L),T}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const er={decodeMessage:function(o){try{var t=JSON.parse(o.data),i=t.data;if(typeof i=="string")try{i=JSON.parse(t.data)}catch{}var c={event:t.event,channel:t.channel,data:i};return t.user_id&&(c.user_id=t.user_id),c}catch(f){throw{type:"MessageParseError",error:f,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 fe=er;class So extends oe{constructor(t,i){super(),this.id=t,this.transport=i,this.activityTimeout=i.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,i,c){var f={event:t,data:i};return c&&(f.channel=c),z.debug("Event sent",f),this.send(fe.encodeMessage(f))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:c=>{var f;try{f=fe.decodeMessage(c)}catch(T){this.emit("error",{type:"MessageParseError",error:T,data:c.data})}if(f!==void 0){switch(z.debug("Event recd",f),f.event){case"pusher:error":this.emit("error",{type:"PusherError",data:f.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong");break}this.emit("message",f)}},activity:()=>{this.emit("activity")},error:c=>{this.emit("error",c)},closed:c=>{i(),c&&c.code&&this.handleCloseEvent(c),this.transport=null,this.emit("closed")}},i=()=>{ie(t,(c,f)=>{this.transport.unbind(f,c)})};ie(t,(c,f)=>{this.transport.bind(f,c)})}handleCloseEvent(t){var i=fe.getCloseAction(t),c=fe.getCloseError(t);c&&this.emit("error",c),i&&this.emit(i,{action:i,error:c})}}class xo{constructor(t,i){this.transport=t,this.callback=i,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{this.unbindListeners();var i;try{i=fe.processHandshake(t)}catch(c){this.finish("error",{error:c}),this.transport.close();return}i.action==="connected"?this.finish("connected",{connection:new So(i.id,this.transport),activityTimeout:i.activityTimeout}):(this.finish(i.action,{error:i.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var i=fe.getCloseAction(t)||"backoff",c=fe.getCloseError(t);this.finish(i,{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,i){this.callback(ee({transport:this.transport,action:t},i))}}class ko{constructor(t,i){this.timeline=t,this.options=i||{}}send(t,i){this.timeline.isEmpty()||this.timeline.send(I.TimelineTransport.getAgent(this,t),i)}}class Pt extends oe{constructor(t,i){super(function(c,f){z.debug("No callbacks on "+t+" for "+c)}),this.name=t,this.pusher=i,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,i){return i(null,{auth:""})}trigger(t,i){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,i,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var i=t.event,c=t.data;if(i==="pusher_internal:subscription_succeeded")this.handleSubscriptionSucceededEvent(t);else if(i==="pusher_internal:subscription_count")this.handleSubscriptionCountEvent(t);else if(i.indexOf("pusher_internal:")!==0){var f={};this.emit(i,c,f)}}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,i)=>{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:i.auth,channel_data:i.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 At extends Pt{authorize(t,i){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},i)}}class Eo{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){ie(this.members,(i,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 i=this.get(t.user_id);return i&&(delete this.members[t.user_id],this.count--),i}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var To=function(o,t,i,c){function f(T){return T instanceof i?T:new i(function(A){A(T)})}return new(i||(i=Promise))(function(T,A){function L($){try{M(c.next($))}catch(J){A(J)}}function B($){try{M(c.throw($))}catch(J){A(J)}}function M($){$.done?T($.value):f($.value).then(L,B)}M((c=c.apply(o,t||[])).next())})};class Ro extends At{constructor(t,i){super(t,i),this.members=new Eo}authorize(t,i){super.authorize(t,(c,f)=>To(this,void 0,void 0,function*(){if(!c)if(f=f,f.channel_data!=null){var T=JSON.parse(f.channel_data);this.members.setMyID(T.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 A=y.buildLogSuffix("authorizationEndpoint");z.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${A}, or the user should be signed in.`),i("Invalid auth response");return}i(c,f)}))}handleEvent(t){var i=t.event;if(i.indexOf("pusher_internal:")===0)this.handleInternalEvent(t);else{var c=t.data,f={};t.user_id&&(f.user_id=t.user_id),this.emit(i,c,f)}}handleInternalEvent(t){var i=t.event,c=t.data;switch(i){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var f=this.members.addMember(c);this.emit("pusher:member_added",f);break;case"pusher_internal:member_removed":var T=this.members.removeMember(c);T&&this.emit("pusher:member_removed",T);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 Oo=a(1),Nt=a(0);class Po extends At{constructor(t,i,c){super(t,i),this.key=null,this.nacl=c}authorize(t,i){super.authorize(t,(c,f)=>{if(c){i(c,f);return}let T=f.shared_secret;if(!T){i(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`),null);return}this.key=Object(Nt.decode)(T),delete f.shared_secret,i(null,f)})}trigger(t,i){throw new R("Client events are not currently supported for encrypted channels")}handleEvent(t){var i=t.event,c=t.data;if(i.indexOf("pusher_internal:")===0||i.indexOf("pusher:")===0){super.handleEvent(t);return}this.handleEncryptedEvent(i,c)}handleEncryptedEvent(t,i){if(!this.key){z.debug("Received encrypted event before key has been retrieved from the authEndpoint");return}if(!i.ciphertext||!i.nonce){z.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+i);return}let c=Object(Nt.decode)(i.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 f=Object(Nt.decode)(i.nonce);if(f.length<this.nacl.secretbox.nonceLength){z.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${f.length}`);return}let T=this.nacl.secretbox.open(c,f,this.key);if(T===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,(A,L)=>{if(A){z.error(`Failed to make a request to the authEndpoint: ${L}. Unable to fetch new key, so dropping encrypted event`);return}if(T=this.nacl.secretbox.open(c,f,this.key),T===null){z.error("Failed to decrypt event with new key. Dropping encrypted event");return}this.emit(t,this.getDataToEmit(T))});return}this.emit(t,this.getDataToEmit(T))}getDataToEmit(t){let i=Object(Oo.decode)(t);try{return JSON.parse(i)}catch{return i}}}class Ao extends oe{constructor(t,i){super(),this.state="initialized",this.connection=null,this.key=t,this.options=i,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,i,c){return this.connection?this.connection.send_event(t,i,c):!1}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(i,c)=>{i?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 Q(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new Q(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new Q(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 Q(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return ee({},t,{message:i=>{this.resetActivityCheck(),this.emit("message",i)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:i=>{this.emit("error",i)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return ee({},t,{connected:i=>{this.activityTimeout=Math.min(this.options.activityTimeout,i.activityTimeout,i.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(i.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=i=>c=>{c.error&&this.emit("error",{type:"WebSocketError",error:c.error}),i(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 i in this.connectionCallbacks)this.connection.bind(i,this.connectionCallbacks[i]);this.resetActivityCheck()}abandonConnection(){if(this.connection){this.stopActivityCheck();for(var t in this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var i=this.connection;return this.connection=null,i}}updateState(t,i){var c=this.state;if(this.state=t,c!==t){var f=t;f==="connected"&&(f+=" with new socket ID "+i.socket_id),z.debug("State changed",c+" -> "+f),this.timeline.info({state:t,params:i}),this.emit("state_change",{previous:c,current:t}),this.emit(t,i)}}shouldRetry(){return this.state==="connecting"||this.state==="connected"}}class No{constructor(){this.channels={}}add(t,i){return this.channels[t]||(this.channels[t]=Lo(t,i)),this.channels[t]}all(){return Vi(this.channels)}find(t){return this.channels[t]}remove(t){var i=this.channels[t];return delete this.channels[t],i}disconnect(){ie(this.channels,function(t){t.disconnect()})}}function Lo(o,t){if(o.indexOf("private-encrypted-")===0){if(t.config.nacl)return ae.createEncryptedChannel(o,t,t.config.nacl);let i="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",c=y.buildLogSuffix("encryptedChannelSupport");throw new R(`${i}. ${c}`)}else{if(o.indexOf("private-")===0)return ae.createPrivateChannel(o,t);if(o.indexOf("presence-")===0)return ae.createPresenceChannel(o,t);if(o.indexOf("#")===0)throw new m('Cannot create a channel with name "'+o+'".');return ae.createChannel(o,t)}}var Do={createChannels(){return new No},createConnectionManager(o,t){return new Ao(o,t)},createChannel(o,t){return new Pt(o,t)},createPrivateChannel(o,t){return new At(o,t)},createPresenceChannel(o,t){return new Ro(o,t)},createEncryptedChannel(o,t,i){return new Po(o,t,i)},createTimelineSender(o,t){return new ko(o,t)},createHandshake(o,t){return new xo(o,t)},createAssistantToTheTransportManager(o,t,i){return new Co(o,t,i)}},ae=Do;class tr{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return ae.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class pe{constructor(t,i){this.strategies=t,this.loop=!!i.loop,this.failFast=!!i.failFast,this.timeout=i.timeout,this.timeoutLimit=i.timeoutLimit}isSupported(){return Wn(this.strategies,V.method("isSupported"))}connect(t,i){var c=this.strategies,f=0,T=this.timeout,A=null,L=(B,M)=>{M?i(null,M):(f=f+1,this.loop&&(f=f%c.length),