| Current Path : /home/users/unlimited/www/whatsapp-crm/public/build/assets/ |
| Current File : /home/users/unlimited/www/whatsapp-crm/public/build/assets/App-26099fac.js |
import{A as Ar,r as Ee,m as re,K as $,G as Er,q as Lr,c as Rr,e as lt,a as Le,J as Ir,n as jr,F as Nr,o as zr}from"./app-43851608.js";import Ur from"./Sidebar-13bbdf6e.js";import{l as Dr}from"./index-99011d5f.js";import qr from"./MobileSidebar-64958b6d.js";/* empty css */function Ie(p){"@babel/helpers - typeof";return Ie=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},Ie(p)}function N(p,l){if(!(p instanceof l))throw new TypeError("Cannot call a class as a function")}function dt(p,l){for(var a=0;a<l.length;a++){var o=l[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(p,o.key,o)}}function z(p,l,a){return l&&dt(p.prototype,l),a&&dt(p,a),Object.defineProperty(p,"prototype",{writable:!1}),p}function je(){return je=Object.assign||function(p){for(var l=1;l<arguments.length;l++){var a=arguments[l];for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(p[o]=a[o])}return p},je.apply(this,arguments)}function M(p,l){if(typeof l!="function"&&l!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(l&&l.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),Object.defineProperty(p,"prototype",{writable:!1}),l&&Ne(p,l)}function pe(p){return pe=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},pe(p)}function Ne(p,l){return Ne=Object.setPrototypeOf||function(o,s){return o.__proto__=s,o},Ne(p,l)}function Hr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Mr(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function Br(p,l){if(l&&(typeof l=="object"||typeof l=="function"))return l;if(l!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Mr(p)}function B(p){var l=Hr();return function(){var o=pe(p),s;if(l){var u=pe(this).constructor;s=Reflect.construct(o,arguments,u)}else s=o.apply(this,arguments);return Br(this,s)}}var ze=function(){function p(){N(this,p)}return z(p,[{key:"listenForWhisper",value:function(a,o){return this.listen(".client-"+a,o)}},{key:"notification",value:function(a){return this.listen(".Illuminate\\Notifications\\Events\\BroadcastNotificationCreated",a)}},{key:"stopListeningForWhisper",value:function(a,o){return this.stopListening(".client-"+a,o)}}]),p}(),pt=function(){function p(l){N(this,p),this.namespace=l}return z(p,[{key:"format",value:function(a){return a.charAt(0)==="."||a.charAt(0)==="\\"?a.substr(1):(this.namespace&&(a=this.namespace+"."+a),a.replace(/\./g,"\\"))}},{key:"setNamespace",value:function(a){this.namespace=a}}]),p}(),ge=function(p){M(a,p);var l=B(a);function a(o,s,u){var h;return N(this,a),h=l.call(this),h.name=s,h.pusher=o,h.options=u,h.eventFormatter=new pt(h.options.namespace),h.subscribe(),h}return z(a,[{key:"subscribe",value:function(){this.subscription=this.pusher.subscribe(this.name)}},{key:"unsubscribe",value:function(){this.pusher.unsubscribe(this.name)}},{key:"listen",value:function(s,u){return this.on(this.eventFormatter.format(s),u),this}},{key:"listenToAll",value:function(s){var u=this;return this.subscription.bind_global(function(h,A){if(!h.startsWith("pusher:")){var m=u.options.namespace.replace(/\./g,"\\"),I=h.startsWith(m)?h.substring(m.length+1):"."+h;s(I,A)}}),this}},{key:"stopListening",value:function(s,u){return u?this.subscription.unbind(this.eventFormatter.format(s),u):this.subscription.unbind(this.eventFormatter.format(s)),this}},{key:"stopListeningToAll",value:function(s){return s?this.subscription.unbind_global(s):this.subscription.unbind_global(),this}},{key:"subscribed",value:function(s){return this.on("pusher:subscription_succeeded",function(){s()}),this}},{key:"error",value:function(s){return this.on("pusher:subscription_error",function(u){s(u)}),this}},{key:"on",value:function(s,u){return this.subscription.bind(s,u),this}}]),a}(ze),Fr=function(p){M(a,p);var l=B(a);function a(){return N(this,a),l.apply(this,arguments)}return z(a,[{key:"whisper",value:function(s,u){return this.pusher.channels.channels[this.name].trigger("client-".concat(s),u),this}}]),a}(ge),Xr=function(p){M(a,p);var l=B(a);function a(){return N(this,a),l.apply(this,arguments)}return z(a,[{key:"whisper",value:function(s,u){return this.pusher.channels.channels[this.name].trigger("client-".concat(s),u),this}}]),a}(ge),$r=function(p){M(a,p);var l=B(a);function a(){return N(this,a),l.apply(this,arguments)}return z(a,[{key:"here",value:function(s){return this.on("pusher:subscription_succeeded",function(u){s(Object.keys(u.members).map(function(h){return u.members[h]}))}),this}},{key:"joining",value:function(s){return this.on("pusher:member_added",function(u){s(u.info)}),this}},{key:"whisper",value:function(s,u){return this.pusher.channels.channels[this.name].trigger("client-".concat(s),u),this}},{key:"leaving",value:function(s){return this.on("pusher:member_removed",function(u){s(u.info)}),this}}]),a}(ge),vt=function(p){M(a,p);var l=B(a);function a(o,s,u){var h;return N(this,a),h=l.call(this),h.events={},h.listeners={},h.name=s,h.socket=o,h.options=u,h.eventFormatter=new pt(h.options.namespace),h.subscribe(),h}return z(a,[{key:"subscribe",value:function(){this.socket.emit("subscribe",{channel:this.name,auth:this.options.auth||{}})}},{key:"unsubscribe",value:function(){this.unbind(),this.socket.emit("unsubscribe",{channel:this.name,auth:this.options.auth||{}})}},{key:"listen",value:function(s,u){return this.on(this.eventFormatter.format(s),u),this}},{key:"stopListening",value:function(s,u){return this.unbindEvent(this.eventFormatter.format(s),u),this}},{key:"subscribed",value:function(s){return this.on("connect",function(u){s(u)}),this}},{key:"error",value:function(s){return this}},{key:"on",value:function(s,u){var h=this;return this.listeners[s]=this.listeners[s]||[],this.events[s]||(this.events[s]=function(A,m){h.name===A&&h.listeners[s]&&h.listeners[s].forEach(function(I){return I(m)})},this.socket.on(s,this.events[s])),this.listeners[s].push(u),this}},{key:"unbind",value:function(){var s=this;Object.keys(this.events).forEach(function(u){s.unbindEvent(u)})}},{key:"unbindEvent",value:function(s,u){this.listeners[s]=this.listeners[s]||[],u&&(this.listeners[s]=this.listeners[s].filter(function(h){return h!==u})),(!u||this.listeners[s].length===0)&&(this.events[s]&&(this.socket.removeListener(s,this.events[s]),delete this.events[s]),delete this.listeners[s])}}]),a}(ze),gt=function(p){M(a,p);var l=B(a);function a(){return N(this,a),l.apply(this,arguments)}return z(a,[{key:"whisper",value:function(s,u){return this.socket.emit("client event",{channel:this.name,event:"client-".concat(s),data:u}),this}}]),a}(vt),Jr=function(p){M(a,p);var l=B(a);function a(){return N(this,a),l.apply(this,arguments)}return z(a,[{key:"here",value:function(s){return this.on("presence:subscribed",function(u){s(u.map(function(h){return h.user_info}))}),this}},{key:"joining",value:function(s){return this.on("presence:joining",function(u){return s(u.user_info)}),this}},{key:"whisper",value:function(s,u){return this.socket.emit("client event",{channel:this.name,event:"client-".concat(s),data:u}),this}},{key:"leaving",value:function(s){return this.on("presence:leaving",function(u){return s(u.user_info)}),this}}]),a}(gt),ve=function(p){M(a,p);var l=B(a);function a(){return N(this,a),l.apply(this,arguments)}return z(a,[{key:"subscribe",value:function(){}},{key:"unsubscribe",value:function(){}},{key:"listen",value:function(s,u){return this}},{key:"listenToAll",value:function(s){return this}},{key:"stopListening",value:function(s,u){return this}},{key:"subscribed",value:function(s){return this}},{key:"error",value:function(s){return this}},{key:"on",value:function(s,u){return this}}]),a}(ze),ft=function(p){M(a,p);var l=B(a);function a(){return N(this,a),l.apply(this,arguments)}return z(a,[{key:"whisper",value:function(s,u){return this}}]),a}(ve),Wr=function(p){M(a,p);var l=B(a);function a(){return N(this,a),l.apply(this,arguments)}return z(a,[{key:"here",value:function(s){return this}},{key:"joining",value:function(s){return this}},{key:"whisper",value:function(s,u){return this}},{key:"leaving",value:function(s){return this}}]),a}(ve),Ue=function(){function p(l){N(this,p),this._defaultOptions={auth:{headers:{}},authEndpoint:"/broadcasting/auth",userAuthentication:{endpoint:"/broadcasting/user-auth",headers:{}},broadcaster:"pusher",csrfToken:null,bearerToken:null,host:null,key:null,namespace:"App.Events"},this.setOptions(l),this.connect()}return z(p,[{key:"setOptions",value:function(a){this.options=je(this._defaultOptions,a);var o=this.csrfToken();return o&&(this.options.auth.headers["X-CSRF-TOKEN"]=o,this.options.userAuthentication.headers["X-CSRF-TOKEN"]=o),o=this.options.bearerToken,o&&(this.options.auth.headers.Authorization="Bearer "+o,this.options.userAuthentication.headers.Authorization="Bearer "+o),a}},{key:"csrfToken",value:function(){var a;return typeof window<"u"&&window.Laravel&&window.Laravel.csrfToken?window.Laravel.csrfToken:this.options.csrfToken?this.options.csrfToken:typeof document<"u"&&typeof document.querySelector=="function"&&(a=document.querySelector('meta[name="csrf-token"]'))?a.getAttribute("content"):null}}]),p}(),Vr=function(p){M(a,p);var l=B(a);function a(){var o;return N(this,a),o=l.apply(this,arguments),o.channels={},o}return z(a,[{key:"connect",value:function(){typeof this.options.client<"u"?this.pusher=this.options.client:this.options.Pusher?this.pusher=new this.options.Pusher(this.options.key,this.options):this.pusher=new Pusher(this.options.key,this.options)}},{key:"signin",value:function(){this.pusher.signin()}},{key:"listen",value:function(s,u,h){return this.channel(s).listen(u,h)}},{key:"channel",value:function(s){return this.channels[s]||(this.channels[s]=new ge(this.pusher,s,this.options)),this.channels[s]}},{key:"privateChannel",value:function(s){return this.channels["private-"+s]||(this.channels["private-"+s]=new Fr(this.pusher,"private-"+s,this.options)),this.channels["private-"+s]}},{key:"encryptedPrivateChannel",value:function(s){return this.channels["private-encrypted-"+s]||(this.channels["private-encrypted-"+s]=new Xr(this.pusher,"private-encrypted-"+s,this.options)),this.channels["private-encrypted-"+s]}},{key:"presenceChannel",value:function(s){return this.channels["presence-"+s]||(this.channels["presence-"+s]=new $r(this.pusher,"presence-"+s,this.options)),this.channels["presence-"+s]}},{key:"leave",value:function(s){var u=this,h=[s,"private-"+s,"private-encrypted-"+s,"presence-"+s];h.forEach(function(A,m){u.leaveChannel(A)})}},{key:"leaveChannel",value:function(s){this.channels[s]&&(this.channels[s].unsubscribe(),delete this.channels[s])}},{key:"socketId",value:function(){return this.pusher.connection.socket_id}},{key:"disconnect",value:function(){this.pusher.disconnect()}}]),a}(Ue),Gr=function(p){M(a,p);var l=B(a);function a(){var o;return N(this,a),o=l.apply(this,arguments),o.channels={},o}return z(a,[{key:"connect",value:function(){var s=this,u=this.getSocketIO();return this.socket=u(this.options.host,this.options),this.socket.on("reconnect",function(){Object.values(s.channels).forEach(function(h){h.subscribe()})}),this.socket}},{key:"getSocketIO",value:function(){if(typeof this.options.client<"u")return this.options.client;if(typeof io<"u")return io;throw new Error("Socket.io client not found. Should be globally available or passed via options.client")}},{key:"listen",value:function(s,u,h){return this.channel(s).listen(u,h)}},{key:"channel",value:function(s){return this.channels[s]||(this.channels[s]=new vt(this.socket,s,this.options)),this.channels[s]}},{key:"privateChannel",value:function(s){return this.channels["private-"+s]||(this.channels["private-"+s]=new gt(this.socket,"private-"+s,this.options)),this.channels["private-"+s]}},{key:"presenceChannel",value:function(s){return this.channels["presence-"+s]||(this.channels["presence-"+s]=new Jr(this.socket,"presence-"+s,this.options)),this.channels["presence-"+s]}},{key:"leave",value:function(s){var u=this,h=[s,"private-"+s,"presence-"+s];h.forEach(function(A){u.leaveChannel(A)})}},{key:"leaveChannel",value:function(s){this.channels[s]&&(this.channels[s].unsubscribe(),delete this.channels[s])}},{key:"socketId",value:function(){return this.socket.id}},{key:"disconnect",value:function(){this.socket.disconnect()}}]),a}(Ue),Qr=function(p){M(a,p);var l=B(a);function a(){var o;return N(this,a),o=l.apply(this,arguments),o.channels={},o}return z(a,[{key:"connect",value:function(){}},{key:"listen",value:function(s,u,h){return new ve}},{key:"channel",value:function(s){return new ve}},{key:"privateChannel",value:function(s){return new ft}},{key:"encryptedPrivateChannel",value:function(s){return new ft}},{key:"presenceChannel",value:function(s){return new Wr}},{key:"leave",value:function(s){}},{key:"leaveChannel",value:function(s){}},{key:"socketId",value:function(){return"fake-socket-id"}},{key:"disconnect",value:function(){}}]),a}(Ue),Kr=function(){function p(l){N(this,p),this.options=l,this.connect(),this.options.withoutInterceptors||this.registerInterceptors()}return z(p,[{key:"channel",value:function(a){return this.connector.channel(a)}},{key:"connect",value:function(){this.options.broadcaster=="pusher"?this.connector=new Vr(this.options):this.options.broadcaster=="socket.io"?this.connector=new Gr(this.options):this.options.broadcaster=="null"?this.connector=new Qr(this.options):typeof this.options.broadcaster=="function"&&(this.connector=new this.options.broadcaster(this.options))}},{key:"disconnect",value:function(){this.connector.disconnect()}},{key:"join",value:function(a){return this.connector.presenceChannel(a)}},{key:"leave",value:function(a){this.connector.leave(a)}},{key:"leaveChannel",value:function(a){this.connector.leaveChannel(a)}},{key:"leaveAllChannels",value:function(){for(var a in this.connector.channels)this.leaveChannel(a)}},{key:"listen",value:function(a,o,s){return this.connector.listen(a,o,s)}},{key:"private",value:function(a){return this.connector.privateChannel(a)}},{key:"encryptedPrivate",value:function(a){return this.connector.encryptedPrivateChannel(a)}},{key:"socketId",value:function(){return this.connector.socketId()}},{key:"registerInterceptors",value:function(){typeof Vue=="function"&&Vue.http&&this.registerVueRequestInterceptor(),typeof axios=="function"&&this.registerAxiosRequestInterceptor(),typeof jQuery=="function"&&this.registerjQueryAjaxSetup(),(typeof Turbo>"u"?"undefined":Ie(Turbo))==="object"&&this.registerTurboRequestInterceptor()}},{key:"registerVueRequestInterceptor",value:function(){var a=this;Vue.http.interceptors.push(function(o,s){a.socketId()&&o.headers.set("X-Socket-ID",a.socketId()),s()})}},{key:"registerAxiosRequestInterceptor",value:function(){var a=this;axios.interceptors.request.use(function(o){return a.socketId()&&(o.headers["X-Socket-Id"]=a.socketId()),o})}},{key:"registerjQueryAjaxSetup",value:function(){var a=this;typeof jQuery.ajax<"u"&&jQuery.ajaxPrefilter(function(o,s,u){a.socketId()&&u.setRequestHeader("X-Socket-Id",a.socketId())})}},{key:"registerTurboRequestInterceptor",value:function(){var a=this;document.addEventListener("turbo:before-fetch-request",function(o){o.detail.fetchOptions.headers["X-Socket-Id"]=a.socketId()})}}]),p}(),bt={exports:{}};/*!
* Pusher JavaScript Library v8.3.0
* https://pusher.com/
*
* Copyright 2020, Pusher
* Released under the MIT licence.
*/(function(p,l){(function(o,s){p.exports=s()})(window,function(){return function(a){var o={};function s(u){if(o[u])return o[u].exports;var h=o[u]={i:u,l:!1,exports:{}};return a[u].call(h.exports,h,h.exports,s),h.l=!0,h.exports}return s.m=a,s.c=o,s.d=function(u,h,A){s.o(u,h)||Object.defineProperty(u,h,{enumerable:!0,get:A})},s.r=function(u){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})},s.t=function(u,h){if(h&1&&(u=s(u)),h&8||h&4&&typeof u=="object"&&u&&u.__esModule)return u;var A=Object.create(null);if(s.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:u}),h&2&&typeof u!="string")for(var m in u)s.d(A,m,(function(I){return u[I]}).bind(null,m));return A},s.n=function(u){var h=u&&u.__esModule?function(){return u.default}:function(){return u};return s.d(h,"a",h),h},s.o=function(u,h){return Object.prototype.hasOwnProperty.call(u,h)},s.p="",s(s.s=2)}([function(a,o,s){var u=this&&this.__extends||function(){var v=function(d,g){return v=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(k,E){k.__proto__=E}||function(k,E){for(var U in E)E.hasOwnProperty(U)&&(k[U]=E[U])},v(d,g)};return function(d,g){v(d,g);function k(){this.constructor=d}d.prototype=g===null?Object.create(g):(k.prototype=g.prototype,new k)}}();Object.defineProperty(o,"__esModule",{value:!0});var h=256,A=function(){function v(d){d===void 0&&(d="="),this._paddingCharacter=d}return v.prototype.encodedLength=function(d){return this._paddingCharacter?(d+2)/3*4|0:(d*8+5)/6|0},v.prototype.encode=function(d){for(var g="",k=0;k<d.length-2;k+=3){var E=d[k]<<16|d[k+1]<<8|d[k+2];g+=this._encodeByte(E>>>3*6&63),g+=this._encodeByte(E>>>2*6&63),g+=this._encodeByte(E>>>1*6&63),g+=this._encodeByte(E>>>0*6&63)}var U=d.length-k;if(U>0){var E=d[k]<<16|(U===2?d[k+1]<<8:0);g+=this._encodeByte(E>>>3*6&63),g+=this._encodeByte(E>>>2*6&63),U===2?g+=this._encodeByte(E>>>1*6&63):g+=this._paddingCharacter||"",g+=this._paddingCharacter||""}return g},v.prototype.maxDecodedLength=function(d){return this._paddingCharacter?d/4*3|0:(d*6+7)/8|0},v.prototype.decodedLength=function(d){return this.maxDecodedLength(d.length-this._getPaddingLength(d))},v.prototype.decode=function(d){if(d.length===0)return new Uint8Array(0);for(var g=this._getPaddingLength(d),k=d.length-g,E=new Uint8Array(this.maxDecodedLength(k)),U=0,D=0,X=0,J=0,F=0,W=0,K=0;D<k-4;D+=4)J=this._decodeChar(d.charCodeAt(D+0)),F=this._decodeChar(d.charCodeAt(D+1)),W=this._decodeChar(d.charCodeAt(D+2)),K=this._decodeChar(d.charCodeAt(D+3)),E[U++]=J<<2|F>>>4,E[U++]=F<<4|W>>>2,E[U++]=W<<6|K,X|=J&h,X|=F&h,X|=W&h,X|=K&h;if(D<k-1&&(J=this._decodeChar(d.charCodeAt(D)),F=this._decodeChar(d.charCodeAt(D+1)),E[U++]=J<<2|F>>>4,X|=J&h,X|=F&h),D<k-2&&(W=this._decodeChar(d.charCodeAt(D+2)),E[U++]=F<<4|W>>>2,X|=W&h),D<k-3&&(K=this._decodeChar(d.charCodeAt(D+3)),E[U++]=W<<6|K,X|=K&h),X!==0)throw new Error("Base64Coder: incorrect characters for decoding");return E},v.prototype._encodeByte=function(d){var g=d;return g+=65,g+=25-d>>>8&0-65-26+97,g+=51-d>>>8&26-97-52+48,g+=61-d>>>8&52-48-62+43,g+=62-d>>>8&62-43-63+47,String.fromCharCode(g)},v.prototype._decodeChar=function(d){var g=h;return g+=(42-d&d-44)>>>8&-h+d-43+62,g+=(46-d&d-48)>>>8&-h+d-47+63,g+=(47-d&d-58)>>>8&-h+d-48+52,g+=(64-d&d-91)>>>8&-h+d-65+0,g+=(96-d&d-123)>>>8&-h+d-97+26,g},v.prototype._getPaddingLength=function(d){var g=0;if(this._paddingCharacter){for(var k=d.length-1;k>=0&&d[k]===this._paddingCharacter;k--)g++;if(d.length<4||g>2)throw new Error("Base64Coder: incorrect padding")}return g},v}();o.Coder=A;var m=new A;function I(v){return m.encode(v)}o.encode=I;function O(v){return m.decode(v)}o.decode=O;var P=function(v){u(d,v);function d(){return v!==null&&v.apply(this,arguments)||this}return d.prototype._encodeByte=function(g){var k=g;return k+=65,k+=25-g>>>8&0-65-26+97,k+=51-g>>>8&26-97-52+48,k+=61-g>>>8&52-48-62+45,k+=62-g>>>8&62-45-63+95,String.fromCharCode(k)},d.prototype._decodeChar=function(g){var k=h;return k+=(44-g&g-46)>>>8&-h+g-45+62,k+=(94-g&g-96)>>>8&-h+g-95+63,k+=(47-g&g-58)>>>8&-h+g-48+52,k+=(64-g&g-91)>>>8&-h+g-65+0,k+=(96-g&g-123)>>>8&-h+g-97+26,k},d}(A);o.URLSafeCoder=P;var S=new P;function C(v){return S.encode(v)}o.encodeURLSafe=C;function w(v){return S.decode(v)}o.decodeURLSafe=w,o.encodedLength=function(v){return m.encodedLength(v)},o.maxDecodedLength=function(v){return m.maxDecodedLength(v)},o.decodedLength=function(v){return m.decodedLength(v)}},function(a,o,s){Object.defineProperty(o,"__esModule",{value:!0});var u="utf8: invalid string",h="utf8: invalid source encoding";function A(O){for(var P=new Uint8Array(m(O)),S=0,C=0;C<O.length;C++){var w=O.charCodeAt(C);w<128?P[S++]=w:w<2048?(P[S++]=192|w>>6,P[S++]=128|w&63):w<55296?(P[S++]=224|w>>12,P[S++]=128|w>>6&63,P[S++]=128|w&63):(C++,w=(w&1023)<<10,w|=O.charCodeAt(C)&1023,w+=65536,P[S++]=240|w>>18,P[S++]=128|w>>12&63,P[S++]=128|w>>6&63,P[S++]=128|w&63)}return P}o.encode=A;function m(O){for(var P=0,S=0;S<O.length;S++){var C=O.charCodeAt(S);if(C<128)P+=1;else if(C<2048)P+=2;else if(C<55296)P+=3;else if(C<=57343){if(S>=O.length-1)throw new Error(u);S++,P+=4}else throw new Error(u)}return P}o.encodedLength=m;function I(O){for(var P=[],S=0;S<O.length;S++){var C=O[S];if(C&128){var w=void 0;if(C<224){if(S>=O.length)throw new Error(h);var v=O[++S];if((v&192)!==128)throw new Error(h);C=(C&31)<<6|v&63,w=128}else if(C<240){if(S>=O.length-1)throw new Error(h);var v=O[++S],d=O[++S];if((v&192)!==128||(d&192)!==128)throw new Error(h);C=(C&15)<<12|(v&63)<<6|d&63,w=2048}else if(C<248){if(S>=O.length-2)throw new Error(h);var v=O[++S],d=O[++S],g=O[++S];if((v&192)!==128||(d&192)!==128||(g&192)!==128)throw new Error(h);C=(C&15)<<18|(v&63)<<12|(d&63)<<6|g&63,w=65536}else throw new Error(h);if(C<w||C>=55296&&C<=57343)throw new Error(h);if(C>=65536){if(C>1114111)throw new Error(h);C-=65536,P.push(String.fromCharCode(55296|C>>10)),C=56320|C&1023}}P.push(String.fromCharCode(C))}return P.join("")}o.decode=I},function(a,o,s){a.exports=s(3).default},function(a,o,s){s.r(o);class u{constructor(e,t){this.lastId=0,this.prefix=e,this.name=t}create(e){this.lastId++;var t=this.lastId,r=this.prefix+t,i=this.name+"["+t+"]",c=!1,f=function(){c||(e.apply(null,arguments),c=!0)};return this[t]=f,{number:t,id:r,name:i,callback:f}}remove(e){delete this[e.number]}}var h=new u("_pusher_script_","Pusher.ScriptReceivers"),A={VERSION:"8.3.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:""},m=A;class I{constructor(e){this.options=e,this.receivers=e.receivers||h,this.loading={}}load(e,t,r){var i=this;if(i.loading[e]&&i.loading[e].length>0)i.loading[e].push(r);else{i.loading[e]=[r];var c=_.createScriptRequest(i.getPath(e,t)),f=i.receivers.create(function(b){if(i.receivers.remove(f),i.loading[e]){var y=i.loading[e];delete i.loading[e];for(var T=function(R){R||c.cleanup()},x=0;x<y.length;x++)y[x](b,T)}});c.send(f)}}getRoot(e){var t,r=_.getDocument().location.protocol;return e&&e.useTLS||r==="https:"?t=this.options.cdn_https:t=this.options.cdn_http,t.replace(/\/*$/,"")+"/"+this.options.version}getPath(e,t){return this.getRoot(t)+"/"+e+this.options.suffix+".js"}}var O=new u("_pusher_dependencies","Pusher.DependenciesReceivers"),P=new I({cdn_http:m.cdn_http,cdn_https:m.cdn_https,version:m.VERSION,suffix:m.dependency_suffix,receivers:O});const S={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 w={buildLogSuffix:function(n){const e="See:",t=S.urls[n];if(!t)return"";let r;return t.fullUrl?r=t.fullUrl:t.path&&(r=S.baseUrl+t.path),r?`${e} ${r}`:""}},v;(function(n){n.UserAuthentication="user-authentication",n.ChannelAuthorization="channel-authorization"})(v||(v={}));class d extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class g extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class k extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class E extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class U extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class D extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class X extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class J extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class F extends Error{constructor(e,t){super(t),this.status=e,Object.setPrototypeOf(this,new.target.prototype)}}var K=function(n,e,t,r,i){const c=_.createXHR();c.open("POST",t.endpoint,!0),c.setRequestHeader("Content-Type","application/x-www-form-urlencoded");for(var f in t.headers)c.setRequestHeader(f,t.headers[f]);if(t.headersProvider!=null){let b=t.headersProvider();for(var f in b)c.setRequestHeader(f,b[f])}return c.onreadystatechange=function(){if(c.readyState===4)if(c.status===200){let b,y=!1;try{b=JSON.parse(c.responseText),y=!0}catch{i(new F(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${c.responseText}`),null)}y&&i(null,b)}else{let b="";switch(r){case v.UserAuthentication:b=w.buildLogSuffix("authenticationEndpoint");break;case v.ChannelAuthorization:b=`Clients must be authorized to join private or presence channels. ${w.buildLogSuffix("authorizationEndpoint")}`;break}i(new F(c.status,`Unable to retrieve auth string from ${r.toString()} endpoint - received status: ${c.status} from ${t.endpoint}. ${b}`),null)}},c.send(e),c};function mt(n){return wt(_t(n))}var ie=String.fromCharCode,ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",yt=function(n){var e=n.charCodeAt(0);return e<128?n:e<2048?ie(192|e>>>6)+ie(128|e&63):ie(224|e>>>12&15)+ie(128|e>>>6&63)+ie(128|e&63)},_t=function(n){return n.replace(/[^\x00-\x7F]/g,yt)},kt=function(n){var e=[0,2,1][n.length%3],t=n.charCodeAt(0)<<16|(n.length>1?n.charCodeAt(1):0)<<8|(n.length>2?n.charCodeAt(2):0),r=[ce.charAt(t>>>18),ce.charAt(t>>>12&63),e>=2?"=":ce.charAt(t>>>6&63),e>=1?"=":ce.charAt(t&63)];return r.join("")},wt=window.btoa||function(n){return n.replace(/[\s\S]{1,3}/g,kt)};class St{constructor(e,t,r,i){this.clear=t,this.timer=e(()=>{this.timer&&(this.timer=i(this.timer))},r)}isRunning(){return this.timer!==null}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}var De=St;function Ct(n){window.clearTimeout(n)}function Tt(n){window.clearInterval(n)}class Y extends De{constructor(e,t){super(setTimeout,Ct,e,function(r){return t(),null})}}class Pt extends De{constructor(e,t){super(setInterval,Tt,e,function(r){return t(),r})}}var xt={now(){return Date.now?Date.now():new Date().valueOf()},defer(n){return new Y(0,n)},method(n,...e){var t=Array.prototype.slice.call(arguments,1);return function(r){return r[n].apply(r,t.concat(arguments))}}},q=xt;function H(n,...e){for(var t=0;t<e.length;t++){var r=e[t];for(var i in r)r[i]&&r[i].constructor&&r[i].constructor===Object?n[i]=H(n[i]||{},r[i]):n[i]=r[i]}return n}function Ot(){for(var n=["Pusher"],e=0;e<arguments.length;e++)typeof arguments[e]=="string"?n.push(arguments[e]):n.push(ue(arguments[e]));return n.join(" : ")}function qe(n,e){var t=Array.prototype.indexOf;if(n===null)return-1;if(t&&n.indexOf===t)return n.indexOf(e);for(var r=0,i=n.length;r<i;r++)if(n[r]===e)return r;return-1}function V(n,e){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(n[t],t,n)}function He(n){var e=[];return V(n,function(t,r){e.push(r)}),e}function At(n){var e=[];return V(n,function(t){e.push(t)}),e}function se(n,e,t){for(var r=0;r<n.length;r++)e.call(t||window,n[r],r,n)}function Me(n,e){for(var t=[],r=0;r<n.length;r++)t.push(e(n[r],r,n,t));return t}function Et(n,e){var t={};return V(n,function(r,i){t[i]=e(r)}),t}function Be(n,e){e=e||function(i){return!!i};for(var t=[],r=0;r<n.length;r++)e(n[r],r,n,t)&&t.push(n[r]);return t}function Fe(n,e){var t={};return V(n,function(r,i){(e&&e(r,i,n,t)||r)&&(t[i]=r)}),t}function Lt(n){var e=[];return V(n,function(t,r){e.push([r,t])}),e}function Xe(n,e){for(var t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1}function Rt(n,e){for(var t=0;t<n.length;t++)if(!e(n[t],t,n))return!1;return!0}function It(n){return Et(n,function(e){return typeof e=="object"&&(e=ue(e)),encodeURIComponent(mt(e.toString()))})}function jt(n){var e=Fe(n,function(r){return r!==void 0}),t=Me(Lt(It(e)),q.method("join","=")).join("&");return t}function Nt(n){var e=[],t=[];return function r(i,c){var f,b,y;switch(typeof i){case"object":if(!i)return null;for(f=0;f<e.length;f+=1)if(e[f]===i)return{$ref:t[f]};if(e.push(i),t.push(c),Object.prototype.toString.apply(i)==="[object Array]")for(y=[],f=0;f<i.length;f+=1)y[f]=r(i[f],c+"["+f+"]");else{y={};for(b in i)Object.prototype.hasOwnProperty.call(i,b)&&(y[b]=r(i[b],c+"["+JSON.stringify(b)+"]"))}return y;case"number":case"string":case"boolean":return i}}(n,"$")}function ue(n){try{return JSON.stringify(n)}catch{return JSON.stringify(Nt(n))}}class zt{constructor(){this.globalLog=e=>{window.console&&window.console.log&&window.console.log(e)}}debug(...e){this.log(this.globalLog,e)}warn(...e){this.log(this.globalLogWarn,e)}error(...e){this.log(this.globalLogError,e)}globalLogWarn(e){window.console&&window.console.warn?window.console.warn(e):this.globalLog(e)}globalLogError(e){window.console&&window.console.error?window.console.error(e):this.globalLogWarn(e)}log(e,...t){var r=Ot.apply(this,arguments);xe.log?xe.log(r):xe.logToConsole&&e.bind(this)(r)}}var L=new zt,Ut=function(n,e,t,r,i){(t.headers!==void 0||t.headersProvider!=null)&&L.warn(`To send headers with the ${r.toString()} request, you must use AJAX, rather than JSONP.`);var c=n.nextAuthCallbackID.toString();n.nextAuthCallbackID++;var f=n.getDocument(),b=f.createElement("script");n.auth_callbacks[c]=function(x){i(null,x)};var y="Pusher.auth_callbacks['"+c+"']";b.src=t.endpoint+"?callback="+encodeURIComponent(y)+"&"+e;var T=f.getElementsByTagName("head")[0]||f.documentElement;T.insertBefore(b,T.firstChild)},Dt=Ut;class qt{constructor(e){this.src=e}send(e){var t=this,r="Error loading "+t.src;t.script=document.createElement("script"),t.script.id=e.id,t.script.src=t.src,t.script.type="text/javascript",t.script.charset="UTF-8",t.script.addEventListener?(t.script.onerror=function(){e.callback(r)},t.script.onload=function(){e.callback(null)}):t.script.onreadystatechange=function(){(t.script.readyState==="loaded"||t.script.readyState==="complete")&&e.callback(null)},t.script.async===void 0&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(t.errorScript=document.createElement("script"),t.errorScript.id=e.id+"_error",t.errorScript.text=e.name+"('"+r+"');",t.script.async=t.errorScript.async=!1):t.script.async=!0;var i=document.getElementsByTagName("head")[0];i.insertBefore(t.script,i.firstChild),t.errorScript&&i.insertBefore(t.errorScript,t.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 Ht{constructor(e,t){this.url=e,this.data=t}send(e){if(!this.request){var t=jt(this.data),r=this.url+"/"+e.number+"?"+t;this.request=_.createScriptRequest(r),this.request.send(e)}}cleanup(){this.request&&this.request.cleanup()}}var Mt=function(n,e){return function(t,r){var i="http"+(e?"s":"")+"://",c=i+(n.host||n.options.host)+n.options.path,f=_.createJSONPRequest(c,t),b=_.ScriptReceivers.create(function(y,T){h.remove(b),f.cleanup(),T&&T.host&&(n.host=T.host),r&&r(y,T)});f.send(b)}},Bt={name:"jsonp",getAgent:Mt},Ft=Bt;function be(n,e,t){var r=n+(e.useTLS?"s":""),i=e.useTLS?e.hostTLS:e.hostNonTLS;return r+"://"+i+t}function me(n,e){var t="/app/"+n,r="?protocol="+m.PROTOCOL+"&client=js&version="+m.VERSION+(e?"&"+e:"");return t+r}var Xt={getInitial:function(n,e){var t=(e.httpPath||"")+me(n,"flash=false");return be("ws",e,t)}},$t={getInitial:function(n,e){var t=(e.httpPath||"/pusher")+me(n);return be("http",e,t)}},Jt={getInitial:function(n,e){return be("http",e,e.httpPath||"/pusher")},getPath:function(n,e){return me(n)}};class Wt{constructor(){this._callbacks={}}get(e){return this._callbacks[ye(e)]}add(e,t,r){var i=ye(e);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:t,context:r})}remove(e,t,r){if(!e&&!t&&!r){this._callbacks={};return}var i=e?[ye(e)]:He(this._callbacks);t||r?this.removeCallback(i,t,r):this.removeAllCallbacks(i)}removeCallback(e,t,r){se(e,function(i){this._callbacks[i]=Be(this._callbacks[i]||[],function(c){return t&&t!==c.fn||r&&r!==c.context}),this._callbacks[i].length===0&&delete this._callbacks[i]},this)}removeAllCallbacks(e){se(e,function(t){delete this._callbacks[t]},this)}}function ye(n){return"_"+n}class G{constructor(e){this.callbacks=new Wt,this.global_callbacks=[],this.failThrough=e}bind(e,t,r){return this.callbacks.add(e,t,r),this}bind_global(e){return this.global_callbacks.push(e),this}unbind(e,t,r){return this.callbacks.remove(e,t,r),this}unbind_global(e){return e?(this.global_callbacks=Be(this.global_callbacks||[],t=>t!==e),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(e,t,r){for(var i=0;i<this.global_callbacks.length;i++)this.global_callbacks[i](e,t);var c=this.callbacks.get(e),f=[];if(r?f.push(t,r):t&&f.push(t),c&&c.length>0)for(var i=0;i<c.length;i++)c[i].fn.apply(c[i].context||window,f);else this.failThrough&&this.failThrough(e,t);return this}}class Vt extends G{constructor(e,t,r,i,c){super(),this.initialize=_.transportConnectionInitializer,this.hooks=e,this.name=t,this.priority=r,this.key=i,this.options=c,this.state="new",this.timeline=c.timeline,this.activityTimeout=c.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 e=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(e,this.options)}catch(t){return q.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),L.debug("Connecting",{transport:this.name,url:e}),this.changeState("connecting"),!0}close(){return this.socket?(this.socket.close(),!0):!1}send(e){return this.state==="open"?(q.defer(()=>{this.socket&&this.socket.send(e)}),!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(e){this.emit("error",{type:"WebSocketError",error:e}),this.timeline.error(this.buildTimelineMessage({error:e.toString()}))}onClose(e){e?this.changeState("closed",{code:e.code,reason:e.reason,wasClean:e.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(e){this.emit("message",e)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=e=>{this.onError(e)},this.socket.onclose=e=>{this.onClose(e)},this.socket.onmessage=e=>{this.onMessage(e)},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(e,t){this.state=e,this.timeline.info(this.buildTimelineMessage({state:e,params:t})),this.emit(e,t)}buildTimelineMessage(e){return H({cid:this.id},e)}}class ne{constructor(e){this.hooks=e}isSupported(e){return this.hooks.isSupported(e)}createConnection(e,t,r,i){return new Vt(this.hooks,e,t,r,i)}}var Gt=new ne({urls:Xt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return!!_.getWebSocketAPI()},isSupported:function(){return!!_.getWebSocketAPI()},getSocket:function(n){return _.createWebSocket(n)}}),$e={urls:$t,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},Je=H({getSocket:function(n){return _.HTTPFactory.createStreamingSocket(n)}},$e),We=H({getSocket:function(n){return _.HTTPFactory.createPollingSocket(n)}},$e),Ve={isSupported:function(){return _.isXHRSupported()}},Qt=new ne(H({},Je,Ve)),Kt=new ne(H({},We,Ve)),Yt={ws:Gt,xhr_streaming:Qt,xhr_polling:Kt},he=Yt,Zt=new ne({file:"sockjs",urls:Jt,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return window.SockJS!==void 0},getSocket:function(n,e){return new window.SockJS(n,null,{js_path:P.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(n,e){n.send(JSON.stringify({path:e}))}}),Ge={isSupported:function(n){var e=_.isXDRSupported(n.useTLS);return e}},en=new ne(H({},Je,Ge)),tn=new ne(H({},We,Ge));he.xdr_streaming=en,he.xdr_polling=tn,he.sockjs=Zt;var nn=he;class rn extends G{constructor(){super();var e=this;window.addEventListener!==void 0&&(window.addEventListener("online",function(){e.emit("online")},!1),window.addEventListener("offline",function(){e.emit("offline")},!1))}isOnline(){return window.navigator.onLine===void 0?!0:window.navigator.onLine}}var sn=new rn;class on{constructor(e,t,r){this.manager=e,this.transport=t,this.minPingDelay=r.minPingDelay,this.maxPingDelay=r.maxPingDelay,this.pingDelay=void 0}createConnection(e,t,r,i){i=H({},i,{activityTimeout:this.pingDelay});var c=this.transport.createConnection(e,t,r,i),f=null,b=function(){c.unbind("open",b),c.bind("closed",y),f=q.now()},y=T=>{if(c.unbind("closed",y),T.code===1002||T.code===1003)this.manager.reportDeath();else if(!T.wasClean&&f){var x=q.now()-f;x<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(x/2,this.minPingDelay))}};return c.bind("open",b),c}isSupported(e){return this.manager.isAlive()&&this.transport.isSupported(e)}}const Qe={decodeMessage:function(n){try{var e=JSON.parse(n.data),t=e.data;if(typeof t=="string")try{t=JSON.parse(e.data)}catch{}var r={event:e.event,channel:e.channel,data:t};return e.user_id&&(r.user_id=e.user_id),r}catch(i){throw{type:"MessageParseError",error:i,data:n.data}}},encodeMessage:function(n){return JSON.stringify(n)},processHandshake:function(n){var e=Qe.decodeMessage(n);if(e.event==="pusher:connection_established"){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:e.data.activity_timeout*1e3}}else{if(e.event==="pusher:error")return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"}},getCloseAction:function(n){return n.code<4e3?n.code>=1002&&n.code<=1004?"backoff":null:n.code===4e3?"tls_only":n.code<4100?"refused":n.code<4200?"backoff":n.code<4300?"retry":"refused"},getCloseError:function(n){return n.code!==1e3&&n.code!==1001?{type:"PusherError",data:{code:n.code,message:n.reason||n.message}}:null}};var Z=Qe;class an extends G{constructor(e,t){super(),this.id=e,this.transport=t,this.activityTimeout=t.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(e){return this.transport.send(e)}send_event(e,t,r){var i={event:e,data:t};return r&&(i.channel=r),L.debug("Event sent",i),this.send(Z.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var e={message:r=>{var i;try{i=Z.decodeMessage(r)}catch(c){this.emit("error",{type:"MessageParseError",error:c,data:r.data})}if(i!==void 0){switch(L.debug("Event recd",i),i.event){case"pusher:error":this.emit("error",{type:"PusherError",data:i.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong");break}this.emit("message",i)}},activity:()=>{this.emit("activity")},error:r=>{this.emit("error",r)},closed:r=>{t(),r&&r.code&&this.handleCloseEvent(r),this.transport=null,this.emit("closed")}},t=()=>{V(e,(r,i)=>{this.transport.unbind(i,r)})};V(e,(r,i)=>{this.transport.bind(i,r)})}handleCloseEvent(e){var t=Z.getCloseAction(e),r=Z.getCloseError(e);r&&this.emit("error",r),t&&this.emit(t,{action:t,error:r})}}class cn{constructor(e,t){this.transport=e,this.callback=t,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=e=>{this.unbindListeners();var t;try{t=Z.processHandshake(e)}catch(r){this.finish("error",{error:r}),this.transport.close();return}t.action==="connected"?this.finish("connected",{connection:new an(t.id,this.transport),activityTimeout:t.activityTimeout}):(this.finish(t.action,{error:t.error}),this.transport.close())},this.onClosed=e=>{this.unbindListeners();var t=Z.getCloseAction(e)||"backoff",r=Z.getCloseError(e);this.finish(t,{error:r})},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(e,t){this.callback(H({transport:this.transport,action:e},t))}}class un{constructor(e,t){this.timeline=e,this.options=t||{}}send(e,t){this.timeline.isEmpty()||this.timeline.send(_.TimelineTransport.getAgent(this,e),t)}}class _e extends G{constructor(e,t){super(function(r,i){L.debug("No callbacks on "+e+" for "+r)}),this.name=e,this.pusher=t,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(e,t){return t(null,{auth:""})}trigger(e,t){if(e.indexOf("client-")!==0)throw new d("Event '"+e+"' does not start with 'client-'");if(!this.subscribed){var r=w.buildLogSuffix("triggeringClientEvents");L.warn(`Client event triggered before channel 'subscription_succeeded' event . ${r}`)}return this.pusher.send_event(e,t,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(e){var t=e.event,r=e.data;if(t==="pusher_internal:subscription_succeeded")this.handleSubscriptionSucceededEvent(e);else if(t==="pusher_internal:subscription_count")this.handleSubscriptionCountEvent(e);else if(t.indexOf("pusher_internal:")!==0){var i={};this.emit(t,r,i)}}handleSubscriptionSucceededEvent(e){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",e.data)}handleSubscriptionCountEvent(e){e.data.subscription_count&&(this.subscriptionCount=e.data.subscription_count),this.emit("pusher:subscription_count",e.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(e,t)=>{e?(this.subscriptionPending=!1,L.error(e.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:e.message},e instanceof F?{status:e.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:t.auth,channel_data:t.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 ke extends _e{authorize(e,t){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:e},t)}}class hn{constructor(){this.reset()}get(e){return Object.prototype.hasOwnProperty.call(this.members,e)?{id:e,info:this.members[e]}:null}each(e){V(this.members,(t,r)=>{e(this.get(r))})}setMyID(e){this.myID=e}onSubscription(e){this.members=e.presence.hash,this.count=e.presence.count,this.me=this.get(this.myID)}addMember(e){return this.get(e.user_id)===null&&this.count++,this.members[e.user_id]=e.user_info,this.get(e.user_id)}removeMember(e){var t=this.get(e.user_id);return t&&(delete this.members[e.user_id],this.count--),t}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var ln=function(n,e,t,r){function i(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function b(x){try{T(r.next(x))}catch(R){f(R)}}function y(x){try{T(r.throw(x))}catch(R){f(R)}}function T(x){x.done?c(x.value):i(x.value).then(b,y)}T((r=r.apply(n,e||[])).next())})};class dn extends ke{constructor(e,t){super(e,t),this.members=new hn}authorize(e,t){super.authorize(e,(r,i)=>ln(this,void 0,void 0,function*(){if(!r)if(i=i,i.channel_data!=null){var c=JSON.parse(i.channel_data);this.members.setMyID(c.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 f=w.buildLogSuffix("authorizationEndpoint");L.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${f}, or the user should be signed in.`),t("Invalid auth response");return}t(r,i)}))}handleEvent(e){var t=e.event;if(t.indexOf("pusher_internal:")===0)this.handleInternalEvent(e);else{var r=e.data,i={};e.user_id&&(i.user_id=e.user_id),this.emit(t,r,i)}}handleInternalEvent(e){var t=e.event,r=e.data;switch(t){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(e);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(e);break;case"pusher_internal:member_added":var i=this.members.addMember(r);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var c=this.members.removeMember(r);c&&this.emit("pusher:member_removed",c);break}}handleSubscriptionSucceededEvent(e){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(e.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var fn=s(1),we=s(0);class pn extends ke{constructor(e,t,r){super(e,t),this.key=null,this.nacl=r}authorize(e,t){super.authorize(e,(r,i)=>{if(r){t(r,i);return}let c=i.shared_secret;if(!c){t(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`),null);return}this.key=Object(we.decode)(c),delete i.shared_secret,t(null,i)})}trigger(e,t){throw new D("Client events are not currently supported for encrypted channels")}handleEvent(e){var t=e.event,r=e.data;if(t.indexOf("pusher_internal:")===0||t.indexOf("pusher:")===0){super.handleEvent(e);return}this.handleEncryptedEvent(t,r)}handleEncryptedEvent(e,t){if(!this.key){L.debug("Received encrypted event before key has been retrieved from the authEndpoint");return}if(!t.ciphertext||!t.nonce){L.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+t);return}let r=Object(we.decode)(t.ciphertext);if(r.length<this.nacl.secretbox.overheadLength){L.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${r.length}`);return}let i=Object(we.decode)(t.nonce);if(i.length<this.nacl.secretbox.nonceLength){L.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${i.length}`);return}let c=this.nacl.secretbox.open(r,i,this.key);if(c===null){L.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,(f,b)=>{if(f){L.error(`Failed to make a request to the authEndpoint: ${b}. Unable to fetch new key, so dropping encrypted event`);return}if(c=this.nacl.secretbox.open(r,i,this.key),c===null){L.error("Failed to decrypt event with new key. Dropping encrypted event");return}this.emit(e,this.getDataToEmit(c))});return}this.emit(e,this.getDataToEmit(c))}getDataToEmit(e){let t=Object(fn.decode)(e);try{return JSON.parse(t)}catch{return t}}}class vn extends G{constructor(e,t){super(),this.state="initialized",this.connection=null,this.key=e,this.options=t,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 r=_.getNetwork();r.bind("online",()=>{this.timeline.info({netinfo:"online"}),(this.state==="connecting"||this.state==="unavailable")&&this.retryIn(0)}),r.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(e){return this.connection?this.connection.send(e):!1}send_event(e,t,r){return this.connection?this.connection.send_event(e,t,r):!1}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var e=(t,r)=>{t?this.runner=this.strategy.connect(0,e):r.action==="error"?(this.emit("error",{type:"HandshakeError",error:r.error}),this.timeline.error({handshakeError:r.error})):(this.abortConnecting(),this.handshakeCallbacks[r.action](r))};this.runner=this.strategy.connect(0,e)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){if(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection){var e=this.abandonConnection();e.close()}}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(e){this.timeline.info({action:"retry",delay:e}),e>0&&this.emit("connecting_in",Math.round(e/1e3)),this.retryTimer=new Y(e||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new Y(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new Y(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 Y(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(e){return H({},e,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(e){return H({},e,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let e=t=>r=>{r.error&&this.emit("error",{type:"WebSocketError",error:r.error}),t(r)};return{tls_only:e(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:e(()=>{this.disconnect()}),backoff:e(()=>{this.retryIn(1e3)}),retry:e(()=>{this.retryIn(0)})}}setConnection(e){this.connection=e;for(var t in this.connectionCallbacks)this.connection.bind(t,this.connectionCallbacks[t]);this.resetActivityCheck()}abandonConnection(){if(this.connection){this.stopActivityCheck();for(var e in this.connectionCallbacks)this.connection.unbind(e,this.connectionCallbacks[e]);var t=this.connection;return this.connection=null,t}}updateState(e,t){var r=this.state;if(this.state=e,r!==e){var i=e;i==="connected"&&(i+=" with new socket ID "+t.socket_id),L.debug("State changed",r+" -> "+i),this.timeline.info({state:e,params:t}),this.emit("state_change",{previous:r,current:e}),this.emit(e,t)}}shouldRetry(){return this.state==="connecting"||this.state==="connected"}}class gn{constructor(){this.channels={}}add(e,t){return this.channels[e]||(this.channels[e]=bn(e,t)),this.channels[e]}all(){return At(this.channels)}find(e){return this.channels[e]}remove(e){var t=this.channels[e];return delete this.channels[e],t}disconnect(){V(this.channels,function(e){e.disconnect()})}}function bn(n,e){if(n.indexOf("private-encrypted-")===0){if(e.config.nacl)return Q.createEncryptedChannel(n,e,e.config.nacl);let t="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=w.buildLogSuffix("encryptedChannelSupport");throw new D(`${t}. ${r}`)}else{if(n.indexOf("private-")===0)return Q.createPrivateChannel(n,e);if(n.indexOf("presence-")===0)return Q.createPresenceChannel(n,e);if(n.indexOf("#")===0)throw new g('Cannot create a channel with name "'+n+'".');return Q.createChannel(n,e)}}var mn={createChannels(){return new gn},createConnectionManager(n,e){return new vn(n,e)},createChannel(n,e){return new _e(n,e)},createPrivateChannel(n,e){return new ke(n,e)},createPresenceChannel(n,e){return new dn(n,e)},createEncryptedChannel(n,e,t){return new pn(n,e,t)},createTimelineSender(n,e){return new un(n,e)},createHandshake(n,e){return new cn(n,e)},createAssistantToTheTransportManager(n,e,t){return new on(n,e,t)}},Q=mn;class Ke{constructor(e){this.options=e||{},this.livesLeft=this.options.lives||1/0}getAssistant(e){return Q.createAssistantToTheTransportManager(this,e,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class ee{constructor(e,t){this.strategies=e,this.loop=!!t.loop,this.failFast=!!t.failFast,this.timeout=t.timeout,this.timeoutLimit=t.timeoutLimit}isSupported(){return Xe(this.strategies,q.method("isSupported"))}connect(e,t){var r=this.strategies,i=0,c=this.timeout,f=null,b=(y,T)=>{T?t(null,T):(i=i+1,this.loop&&(i=i%r.length),i<r.length?(c&&(c=c*2,this.timeoutLimit&&(c=Math.min(c,this.timeoutLimit))),f=this.tryStrategy(r[i],e,{timeout:c,failFast:this.failFast},b)):t(!0))};return f=this.tryStrategy(r[i],e,{timeout:c,failFast:this.failFast},b),{abort:function(){f.abort()},forceMinPriority:function(y){e=y,f&&f.forceMinPriority(y)}}}tryStrategy(e,t,r,i){var c=null,f=null;return r.timeout>0&&(c=new Y(r.timeout,function(){f.abort(),i(!0)})),f=e.connect(t,function(b,y){b&&c&&c.isRunning()&&!r.failFast||(c&&c.ensureAborted(),i(b,y))}),{abort:function(){c&&c.ensureAborted(),f.abort()},forceMinPriority:function(b){f.forceMinPriority(b)}}}}class Se{constructor(e){this.strategies=e}isSupported(){return Xe(this.strategies,q.method("isSupported"))}connect(e,t){return yn(this.strategies,e,function(r,i){return function(c,f){if(i[r].error=c,c){_n(i)&&t(!0);return}se(i,function(b){b.forceMinPriority(f.transport.priority)}),t(null,f)}})}}function yn(n,e,t){var r=Me(n,function(i,c,f,b){return i.connect(e,t(c,b))});return{abort:function(){se(r,kn)},forceMinPriority:function(i){se(r,function(c){c.forceMinPriority(i)})}}}function _n(n){return Rt(n,function(e){return!!e.error})}function kn(n){!n.error&&!n.aborted&&(n.abort(),n.aborted=!0)}class wn{constructor(e,t,r){this.strategy=e,this.transports=t,this.ttl=r.ttl||1800*1e3,this.usingTLS=r.useTLS,this.timeline=r.timeline}isSupported(){return this.strategy.isSupported()}connect(e,t){var r=this.usingTLS,i=Sn(r),c=i&&i.cacheSkipCount?i.cacheSkipCount:0,f=[this.strategy];if(i&&i.timestamp+this.ttl>=q.now()){var b=this.transports[i.transport];b&&(["ws","wss"].includes(i.transport)||c>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),f.push(new ee([b],{timeout:i.latency*2+1e3,failFast:!0}))):c++)}var y=q.now(),T=f.pop().connect(e,function x(R,fe){R?(Ye(r),f.length>0?(y=q.now(),T=f.pop().connect(e,x)):t(R)):(Cn(r,fe.transport.name,q.now()-y,c),t(null,fe))});return{abort:function(){T.abort()},forceMinPriority:function(x){e=x,T&&T.forceMinPriority(x)}}}}function Ce(n){return"pusherTransport"+(n?"TLS":"NonTLS")}function Sn(n){var e=_.getLocalStorage();if(e)try{var t=e[Ce(n)];if(t)return JSON.parse(t)}catch{Ye(n)}return null}function Cn(n,e,t,r){var i=_.getLocalStorage();if(i)try{i[Ce(n)]=ue({timestamp:q.now(),transport:e,latency:t,cacheSkipCount:r})}catch{}}function Ye(n){var e=_.getLocalStorage();if(e)try{delete e[Ce(n)]}catch{}}class le{constructor(e,{delay:t}){this.strategy=e,this.options={delay:t}}isSupported(){return this.strategy.isSupported()}connect(e,t){var r=this.strategy,i,c=new Y(this.options.delay,function(){i=r.connect(e,t)});return{abort:function(){c.ensureAborted(),i&&i.abort()},forceMinPriority:function(f){e=f,i&&i.forceMinPriority(f)}}}}class oe{constructor(e,t,r){this.test=e,this.trueBranch=t,this.falseBranch=r}isSupported(){var e=this.test()?this.trueBranch:this.falseBranch;return e.isSupported()}connect(e,t){var r=this.test()?this.trueBranch:this.falseBranch;return r.connect(e,t)}}class Tn{constructor(e){this.strategy=e}isSupported(){return this.strategy.isSupported()}connect(e,t){var r=this.strategy.connect(e,function(i,c){c&&r.abort(),t(i,c)});return r}}function ae(n){return function(){return n.isSupported()}}var Pn=function(n,e,t){var r={};function i(ut,Tr,Pr,xr,Or){var ht=t(n,ut,Tr,Pr,xr,Or);return r[ut]=ht,ht}var c=Object.assign({},e,{hostNonTLS:n.wsHost+":"+n.wsPort,hostTLS:n.wsHost+":"+n.wssPort,httpPath:n.wsPath}),f=Object.assign({},c,{useTLS:!0}),b=Object.assign({},e,{hostNonTLS:n.httpHost+":"+n.httpPort,hostTLS:n.httpHost+":"+n.httpsPort,httpPath:n.httpPath}),y={loop:!0,timeout:15e3,timeoutLimit:6e4},T=new Ke({minPingDelay:1e4,maxPingDelay:n.activityTimeout}),x=new Ke({lives:2,minPingDelay:1e4,maxPingDelay:n.activityTimeout}),R=i("ws","ws",3,c,T),fe=i("wss","ws",3,f,T),_r=i("sockjs","sockjs",1,b),rt=i("xhr_streaming","xhr_streaming",1,b,x),kr=i("xdr_streaming","xdr_streaming",1,b,x),it=i("xhr_polling","xhr_polling",1,b),wr=i("xdr_polling","xdr_polling",1,b),st=new ee([R],y),Sr=new ee([fe],y),Cr=new ee([_r],y),ot=new ee([new oe(ae(rt),rt,kr)],y),at=new ee([new oe(ae(it),it,wr)],y),ct=new ee([new oe(ae(ot),new Se([ot,new le(at,{delay:4e3})]),at)],y),Oe=new oe(ae(ct),ct,Cr),Ae;return e.useTLS?Ae=new Se([st,new le(Oe,{delay:2e3})]):Ae=new Se([st,new le(Sr,{delay:2e3}),new le(Oe,{delay:5e3})]),new wn(new Tn(new oe(ae(R),Ae,Oe)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},xn=Pn,On=function(){var n=this;n.timeline.info(n.buildTimelineMessage({transport:n.name+(n.options.useTLS?"s":"")})),n.hooks.isInitialized()?n.changeState("initialized"):n.hooks.file?(n.changeState("initializing"),P.load(n.hooks.file,{useTLS:n.options.useTLS},function(e,t){n.hooks.isInitialized()?(n.changeState("initialized"),t(!0)):(e&&n.onError(e),n.onClose(),t(!1))})):n.onClose()},An={getRequest:function(n){var e=new window.XDomainRequest;return e.ontimeout=function(){n.emit("error",new k),n.close()},e.onerror=function(t){n.emit("error",t),n.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&n.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&n.onChunk(200,e.responseText),n.emit("finished",200),n.close()},e},abortRequest:function(n){n.ontimeout=n.onerror=n.onprogress=n.onload=null,n.abort()}},En=An;const Ln=256*1024;class Rn extends G{constructor(e,t,r){super(),this.hooks=e,this.method=t,this.url=r}start(e){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},_.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(e)}close(){this.unloader&&(_.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(e,t){for(;;){var r=this.advanceBuffer(t);if(r)this.emit("chunk",{status:e,data:r});else break}this.isBufferTooLong(t)&&this.emit("buffer_too_long")}advanceBuffer(e){var t=e.slice(this.position),r=t.indexOf(`
`);return r!==-1?(this.position+=r+1,t.slice(0,r)):null}isBufferTooLong(e){return this.position===e.length&&e.length>Ln}}var Te;(function(n){n[n.CONNECTING=0]="CONNECTING",n[n.OPEN=1]="OPEN",n[n.CLOSED=3]="CLOSED"})(Te||(Te={}));var te=Te,In=1;class jn{constructor(e,t){this.hooks=e,this.session=et(1e3)+"/"+Dn(8),this.location=Nn(t),this.readyState=te.CONNECTING,this.openStream()}send(e){return this.sendRaw(JSON.stringify([e]))}ping(){this.hooks.sendHeartbeat(this)}close(e,t){this.onClose(e,t,!0)}sendRaw(e){if(this.readyState===te.OPEN)try{return _.createSocketRequest("POST",Ze(zn(this.location,this.session))).start(e),!0}catch{return!1}else return!1}reconnect(){this.closeStream(),this.openStream()}onClose(e,t,r){this.closeStream(),this.readyState=te.CLOSED,this.onclose&&this.onclose({code:e,reason:t,wasClean:r})}onChunk(e){if(e.status===200){this.readyState===te.OPEN&&this.onActivity();var t,r=e.data.slice(0,1);switch(r){case"o":t=JSON.parse(e.data.slice(1)||"{}"),this.onOpen(t);break;case"a":t=JSON.parse(e.data.slice(1)||"[]");for(var i=0;i<t.length;i++)this.onEvent(t[i]);break;case"m":t=JSON.parse(e.data.slice(1)||"null"),this.onEvent(t);break;case"h":this.hooks.onHeartbeat(this);break;case"c":t=JSON.parse(e.data.slice(1)||"[]"),this.onClose(t[0],t[1],!0);break}}}onOpen(e){this.readyState===te.CONNECTING?(e&&e.hostname&&(this.location.base=Un(this.location.base,e.hostname)),this.readyState=te.OPEN,this.onopen&&this.onopen()):this.onClose(1006,"Server lost session",!0)}onEvent(e){this.readyState===te.OPEN&&this.onmessage&&this.onmessage({data:e})}onActivity(){this.onactivity&&this.onactivity()}onError(e){this.onerror&&this.onerror(e)}openStream(){this.stream=_.createSocketRequest("POST",Ze(this.hooks.getReceiveURL(this.location,this.session))),this.stream.bind("chunk",e=>{this.onChunk(e)}),this.stream.bind("finished",e=>{this.hooks.onFinished(this,e)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(e){q.defer(()=>{this.onError(e),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}}function Nn(n){var e=/([^\?]*)\/*(\??.*)/.exec(n);return{base:e[1],queryString:e[2]}}function zn(n,e){return n.base+"/"+e+"/xhr_send"}function Ze(n){var e=n.indexOf("?")===-1?"?":"&";return n+e+"t="+ +new Date+"&n="+In++}function Un(n,e){var t=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(n);return t[1]+e+t[3]}function et(n){return _.randomInt(n)}function Dn(n){for(var e=[],t=0;t<n;t++)e.push(et(32).toString(32));return e.join("")}var qn=jn,Hn={getReceiveURL:function(n,e){return n.base+"/"+e+"/xhr_streaming"+n.queryString},onHeartbeat:function(n){n.sendRaw("[]")},sendHeartbeat:function(n){n.sendRaw("[]")},onFinished:function(n,e){n.onClose(1006,"Connection interrupted ("+e+")",!1)}},Mn=Hn,Bn={getReceiveURL:function(n,e){return n.base+"/"+e+"/xhr"+n.queryString},onHeartbeat:function(){},sendHeartbeat:function(n){n.sendRaw("[]")},onFinished:function(n,e){e===200?n.reconnect():n.onClose(1006,"Connection interrupted ("+e+")",!1)}},Fn=Bn,Xn={getRequest:function(n){var e=_.getXHRAPI(),t=new e;return t.onreadystatechange=t.onprogress=function(){switch(t.readyState){case 3:t.responseText&&t.responseText.length>0&&n.onChunk(t.status,t.responseText);break;case 4:t.responseText&&t.responseText.length>0&&n.onChunk(t.status,t.responseText),n.emit("finished",t.status),n.close();break}},t},abortRequest:function(n){n.onreadystatechange=null,n.abort()}},$n=Xn,Jn={createStreamingSocket(n){return this.createSocket(Mn,n)},createPollingSocket(n){return this.createSocket(Fn,n)},createSocket(n,e){return new qn(n,e)},createXHR(n,e){return this.createRequest($n,n,e)},createRequest(n,e,t){return new Rn(n,e,t)}},tt=Jn;tt.createXDR=function(n,e){return this.createRequest(En,n,e)};var Wn=tt,Vn={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:h,DependenciesReceivers:O,getDefaultStrategy:xn,Transports:nn,transportConnectionInitializer:On,HTTPFactory:Wn,TimelineTransport:Ft,getXHRAPI(){return window.XMLHttpRequest},getWebSocketAPI(){return window.WebSocket||window.MozWebSocket},setup(n){window.Pusher=n;var e=()=>{this.onDocumentBody(n.ready)};window.JSON?e():P.load("json2",{},e)},getDocument(){return document},getProtocol(){return this.getDocument().location.protocol},getAuthorizers(){return{ajax:K,jsonp:Dt}},onDocumentBody(n){document.body?n():setTimeout(()=>{this.onDocumentBody(n)},0)},createJSONPRequest(n,e){return new Ht(n,e)},createScriptRequest(n){return new qt(n)},getLocalStorage(){try{return window.localStorage}catch{return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){var n=this.getXHRAPI();return new n},createMicrosoftXHR(){return new ActiveXObject("Microsoft.XMLHTTP")},getNetwork(){return sn},createWebSocket(n){var e=this.getWebSocketAPI();return new e(n)},createSocketRequest(n,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(n,e);if(this.isXDRSupported(e.indexOf("https:")===0))return this.HTTPFactory.createXDR(n,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var n=this.getXHRAPI();return!!n&&new n().withCredentials!==void 0},isXDRSupported(n){var e=n?"https:":"http:",t=this.getProtocol();return!!window.XDomainRequest&&t===e},addUnloadListener(n){window.addEventListener!==void 0?window.addEventListener("unload",n,!1):window.attachEvent!==void 0&&window.attachEvent("onunload",n)},removeUnloadListener(n){window.addEventListener!==void 0?window.removeEventListener("unload",n,!1):window.detachEvent!==void 0&&window.detachEvent("onunload",n)},randomInt(n){return Math.floor(function(){return(window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}()*n)}},_=Vn,Pe;(function(n){n[n.ERROR=3]="ERROR",n[n.INFO=6]="INFO",n[n.DEBUG=7]="DEBUG"})(Pe||(Pe={}));var de=Pe;class Gn{constructor(e,t,r){this.key=e,this.session=t,this.events=[],this.options=r||{},this.sent=0,this.uniqueID=0}log(e,t){e<=this.options.level&&(this.events.push(H({},t,{timestamp:q.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(e){this.log(de.ERROR,e)}info(e){this.log(de.INFO,e)}debug(e){this.log(de.DEBUG,e)}isEmpty(){return this.events.length===0}send(e,t){var r=H({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],e(r,(i,c)=>{i||this.sent++,t&&t(i,c)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class Qn{constructor(e,t,r,i){this.name=e,this.priority=t,this.transport=r,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(e,t){if(this.isSupported()){if(this.priority<e)return nt(new E,t)}else return nt(new J,t);var r=!1,i=this.transport.createConnection(this.name,this.priority,this.options.key,this.options),c=null,f=function(){i.unbind("initialized",f),i.connect()},b=function(){c=Q.createHandshake(i,function(R){r=!0,x(),t(null,R)})},y=function(R){x(),t(R)},T=function(){x();var R;R=ue(i),t(new U(R))},x=function(){i.unbind("initialized",f),i.unbind("open",b),i.unbind("error",y),i.unbind("closed",T)};return i.bind("initialized",f),i.bind("open",b),i.bind("error",y),i.bind("closed",T),i.initialize(),{abort:()=>{r||(x(),c?c.close():i.close())},forceMinPriority:R=>{r||this.priority<R&&(c?c.close():i.close())}}}}function nt(n,e){return q.defer(function(){e(n)}),{abort:function(){},forceMinPriority:function(){}}}const{Transports:Kn}=_;var Yn=function(n,e,t,r,i,c){var f=Kn[t];if(!f)throw new X(t);var b=(!n.enabledTransports||qe(n.enabledTransports,e)!==-1)&&(!n.disabledTransports||qe(n.disabledTransports,e)===-1),y;return b?(i=Object.assign({ignoreNullOrigin:n.ignoreNullOrigin},i),y=new Qn(e,r,c?c.getAssistant(f):f,i)):y=Zn,y},Zn={isSupported:function(){return!1},connect:function(n,e){var t=q.defer(function(){e(new J)});return{abort:function(){t.ensureAborted()},forceMinPriority:function(){}}}};function er(n){if(n==null)throw"You must pass an options object";if(n.cluster==null)throw"Options object must provide a cluster";"disableStats"in n&&L.warn("The disableStats option is deprecated in favor of enableStats")}const tr=(n,e)=>{var t="socket_id="+encodeURIComponent(n.socketId);for(var r in e.params)t+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(e.paramsProvider!=null){let i=e.paramsProvider();for(var r in i)t+="&"+encodeURIComponent(r)+"="+encodeURIComponent(i[r])}return t};var nr=n=>{if(typeof _.getAuthorizers()[n.transport]>"u")throw`'${n.transport}' is not a recognized auth transport`;return(e,t)=>{const r=tr(e,n);_.getAuthorizers()[n.transport](_,r,n,v.UserAuthentication,t)}};const rr=(n,e)=>{var t="socket_id="+encodeURIComponent(n.socketId);t+="&channel_name="+encodeURIComponent(n.channelName);for(var r in e.params)t+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(e.paramsProvider!=null){let i=e.paramsProvider();for(var r in i)t+="&"+encodeURIComponent(r)+"="+encodeURIComponent(i[r])}return t};var ir=n=>{if(typeof _.getAuthorizers()[n.transport]>"u")throw`'${n.transport}' is not a recognized auth transport`;return(e,t)=>{const r=rr(e,n);_.getAuthorizers()[n.transport](_,r,n,v.ChannelAuthorization,t)}};const sr=(n,e,t)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(i,c)=>{const f=n.channel(i.channelName);t(f,r).authorize(i.socketId,c)}};function or(n,e){let t={activityTimeout:n.activityTimeout||m.activityTimeout,cluster:n.cluster,httpPath:n.httpPath||m.httpPath,httpPort:n.httpPort||m.httpPort,httpsPort:n.httpsPort||m.httpsPort,pongTimeout:n.pongTimeout||m.pongTimeout,statsHost:n.statsHost||m.stats_host,unavailableTimeout:n.unavailableTimeout||m.unavailableTimeout,wsPath:n.wsPath||m.wsPath,wsPort:n.wsPort||m.wsPort,wssPort:n.wssPort||m.wssPort,enableStats:lr(n),httpHost:ar(n),useTLS:hr(n),wsHost:cr(n),userAuthenticator:dr(n),channelAuthorizer:pr(n,e)};return"disabledTransports"in n&&(t.disabledTransports=n.disabledTransports),"enabledTransports"in n&&(t.enabledTransports=n.enabledTransports),"ignoreNullOrigin"in n&&(t.ignoreNullOrigin=n.ignoreNullOrigin),"timelineParams"in n&&(t.timelineParams=n.timelineParams),"nacl"in n&&(t.nacl=n.nacl),t}function ar(n){return n.httpHost?n.httpHost:n.cluster?`sockjs-${n.cluster}.pusher.com`:m.httpHost}function cr(n){return n.wsHost?n.wsHost:ur(n.cluster)}function ur(n){return`ws-${n}.pusher.com`}function hr(n){return _.getProtocol()==="https:"?!0:n.forceTLS!==!1}function lr(n){return"enableStats"in n?n.enableStats:"disableStats"in n?!n.disableStats:!1}function dr(n){const e=Object.assign(Object.assign({},m.userAuthentication),n.userAuthentication);return"customHandler"in e&&e.customHandler!=null?e.customHandler:nr(e)}function fr(n,e){let t;return"channelAuthorization"in n?t=Object.assign(Object.assign({},m.channelAuthorization),n.channelAuthorization):(t={transport:n.authTransport||m.authTransport,endpoint:n.authEndpoint||m.authEndpoint},"auth"in n&&("params"in n.auth&&(t.params=n.auth.params),"headers"in n.auth&&(t.headers=n.auth.headers)),"authorizer"in n&&(t.customHandler=sr(e,t,n.authorizer))),t}function pr(n,e){const t=fr(n,e);return"customHandler"in t&&t.customHandler!=null?t.customHandler:ir(t)}class vr extends G{constructor(e){super(function(t,r){L.debug(`No callbacks on watchlist events for ${t}`)}),this.pusher=e,this.bindWatchlistInternalEvent()}handleEvent(e){e.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",e=>{var t=e.event;t==="pusher_internal:watchlist_events"&&this.handleEvent(e)})}}function gr(){let n,e;return{promise:new Promise((r,i)=>{n=r,e=i}),resolve:n,reject:e}}var br=gr;class mr extends G{constructor(e){super(function(t,r){L.debug("No callbacks on user for "+t)}),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,r)=>{if(t){L.warn(`Error during signin: ${t}`),this._cleanup();return}this.pusher.send_event("pusher:signin",{auth:r.auth,user_data:r.user_data})},this.pusher=e,this.pusher.connection.bind("state_change",({previous:t,current:r})=>{t!=="connected"&&r==="connected"&&this._signin(),t==="connected"&&r!=="connected"&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new vr(e),this.pusher.connection.bind("message",t=>{var r=t.event;r==="pusher:signin_success"&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),this.pusher.connection.state==="connected"&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(e){try{this.user_data=JSON.parse(e.user_data)}catch{L.error(`Failed parsing user data after signin: ${e.user_data}`),this._cleanup();return}if(typeof this.user_data.id!="string"||this.user_data.id===""){L.error(`user_data doesn't contain an id. user_data: ${this.user_data}`),this._cleanup();return}this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){const e=t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():!t.subscriptionPending&&this.pusher.connection.state==="connected"&&t.subscribe()};this.serverToUserChannel=new _e(`#server-to-user-${this.user_data.id}`,this.pusher),this.serverToUserChannel.bind_global((t,r)=>{t.indexOf("pusher_internal:")===0||t.indexOf("pusher:")===0||this.emit(t,r)}),e(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested||this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:e,resolve:t,reject:r}=br();e.done=!1;const i=()=>{e.done=!0};e.then(i).catch(i),this.signinDonePromise=e,this._signinDoneResolve=t}}class j{static ready(){j.isReady=!0;for(var e=0,t=j.instances.length;e<t;e++)j.instances[e].connect()}static getClientFeatures(){return He(Fe({ws:_.Transports.ws},function(e){return e.isSupported({})}))}constructor(e,t){yr(e),er(t),this.key=e,this.config=or(t,this),this.channels=Q.createChannels(),this.global_emitter=new G,this.sessionID=_.randomInt(1e9),this.timeline=new Gn(this.key,this.sessionID,{cluster:this.config.cluster,features:j.getClientFeatures(),params:this.config.timelineParams||{},limit:50,level:de.INFO,version:m.VERSION}),this.config.enableStats&&(this.timelineSender=Q.createTimelineSender(this.timeline,{host:this.config.statsHost,path:"/timeline/v2/"+_.TimelineTransport.name}));var r=i=>_.getDefaultStrategy(this.config,i,Yn);this.connection=Q.createConnectionManager(this.key,{getStrategy:r,timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:!!this.config.useTLS}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",i=>{var c=i.event,f=c.indexOf("pusher_internal:")===0;if(i.channel){var b=this.channel(i.channel);b&&b.handleEvent(i)}f||this.global_emitter.emit(i.event,i.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",i=>{L.warn(i)}),j.instances.push(this),this.timeline.info({instances:j.instances.length}),this.user=new mr(this),j.isReady&&this.connect()}channel(e){return this.channels.find(e)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var e=this.connection.isUsingTLS(),t=this.timelineSender;this.timelineSenderTimer=new Pt(6e4,function(){t.send(e)})}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(e,t,r){return this.global_emitter.bind(e,t,r),this}unbind(e,t,r){return this.global_emitter.unbind(e,t,r),this}bind_global(e){return this.global_emitter.bind_global(e),this}unbind_global(e){return this.global_emitter.unbind_global(e),this}unbind_all(e){return this.global_emitter.unbind_all(),this}subscribeAll(){var e;for(e in this.channels.channels)this.channels.channels.hasOwnProperty(e)&&this.subscribe(e)}subscribe(e){var t=this.channels.add(e,this);return t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():!t.subscriptionPending&&this.connection.state==="connected"&&t.subscribe(),t}unsubscribe(e){var t=this.channels.find(e);t&&t.subscriptionPending?t.cancelSubscription():(t=this.channels.remove(e),t&&t.subscribed&&t.unsubscribe())}send_event(e,t,r){return this.connection.send_event(e,t,r)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}j.instances=[],j.isReady=!1,j.logToConsole=!1,j.Runtime=_,j.ScriptReceivers=_.ScriptReceivers,j.DependenciesReceivers=_.DependenciesReceivers,j.auth_callbacks=_.auth_callbacks;var xe=o.default=j;function yr(n){if(n==null)throw"You must pass your app key when you instantiate Pusher."}_.setup(j)}])})})(bt);var Yr=bt.exports;const Zr=Ar(Yr);let Re=null;function ei(p,l){return Re||(window.Pusher=Zr,Re=new Kr({broadcaster:"pusher",key:p,cluster:l,encrypted:!0})),Re}const ti={class:"md:min-h-screen flex flex-col w-full min-w-0"},ni={__name:"App",setup(p){const l=Ee(!0),a=re(()=>$().props.auth.user),o=re(()=>$().props.config),s=re(()=>$().props.organization),u=re(()=>$().props.organizations),h=re(()=>$().props.title),A=re(()=>$().props.allowCreate),m=Ee($().props.unreadMessages),I=Ee(null);Er(()=>[$().props.flash,{deep:!0}],()=>{$().props.flash.status!=null&&Dr($().props.flash.status.message,{autoClose:3e3})});const O=()=>{l.value=!l.value},P=w=>{const v=o.value.find(d=>d.key===w);return v?v.value:""},S=()=>{const v=(s.value.metadata?JSON.parse(s.value.metadata):{}).notifications||{};v!=null&&v.enable_sound&&I.value&&(I.value.src=v==null?void 0:v.tone,I.value.volume=(v==null?void 0:v.volume)||1)},C=()=>{I.value&&I.value.play().catch(w=>{console.warn("Audio playback failed:",w)})};return Lr(()=>{S(),ei(P("pusher_app_key"),P("pusher_app_cluster")).channel("chats.ch"+s.value.id).listen("NewChatEvent",v=>{const d=v.chat;d[0].value.deleted_at==null&&d[0].value.type==="inbound"&&(C(),m.value+=1)})}),(w,v)=>(zr(),Rr(Nr,null,[lt(qr,{user:a.value,config:o.value,organization:s.value,organizations:u.value,title:h.value,displayCreateBtn:A.value,displayTopBar:l.value},null,8,["user","config","organization","organizations","title","displayCreateBtn","displayTopBar"]),Le("div",{class:jr(["md:mt-0 md:pt-0 flex md:h-screen w-full tracking-[0.3px] bg-gray-300/10",l.value===!1?"mt-0 pt-0":""])},[lt(Ur,{user:a.value,config:o.value,organization:s.value,organizations:u.value,unreadMessages:m.value},null,8,["user","config","organization","organizations","unreadMessages"]),Le("div",ti,[Ir(w.$slots,"default",{user:a.value,toggleNavBar:O,onTestEmit:v[0]||(v[0]=(...d)=>w.doSomething&&w.doSomething(...d))})])],2),Le("audio",{ref_key:"audioPlayer",ref:I,allow:"autoplay"},null,512)],64))}},hi=Object.freeze(Object.defineProperty({__proto__:null,default:ni},Symbol.toStringTag,{value:"Module"}));export{hi as A,Kr as E,Zr as P,ni as _,ei as g};