@dcodegroup-au/dcode-chat-vue
Version:
Frontend vue components for the dcode-laravel-chat package
1,557 lines • 227 kB
JavaScript
import { defineComponent as me, ref as J, watch as de, createElementBlock as K, openBlock as V, createElementVNode as M, withDirectives as qn, withKeys as Bn, vModelText as Mn, createCommentVNode as ae, normalizeClass as se, toDisplayString as Le, createVNode as Ne, Fragment as $n, renderList as Hn, withModifiers as Ri, computed as Oi, unref as he, createTextVNode as Pi, inject as Ai, onMounted as Ft, onBeforeUnmount as Li, createBlock as zn, provide as Ni } from "vue";
class qt {
/**
* Listen for a whisper event on the channel instance.
*/
listenForWhisper(e, n) {
return this.listen(".client-" + e, n);
}
/**
* Listen for an event on the channel instance.
*/
notification(e) {
return this.listen(
".Illuminate\\Notifications\\Events\\BroadcastNotificationCreated",
e
);
}
/**
* Stop listening for a whisper event on the channel instance.
*/
stopListeningForWhisper(e, n) {
return this.stopListening(".client-" + e, n);
}
}
class Jn {
/**
* Create a new class instance.
*/
constructor(e) {
this.namespace = e;
}
/**
* Format the given event name.
*/
format(e) {
return [".", "\\"].includes(e.charAt(0)) ? e.substring(1) : (this.namespace && (e = this.namespace + "." + e), e.replace(/\./g, "\\"));
}
/**
* Set the event namespace.
*/
setNamespace(e) {
this.namespace = e;
}
}
function ji(r) {
try {
new r();
} catch (e) {
if (e instanceof Error && e.message.includes("is not a constructor"))
return !1;
}
return !0;
}
class Bt extends qt {
/**
* Create a new class instance.
*/
constructor(e, n, i) {
super(), this.name = n, this.pusher = e, this.options = i, this.eventFormatter = new Jn(this.options.namespace), this.subscribe();
}
/**
* Subscribe to a Pusher channel.
*/
subscribe() {
this.subscription = this.pusher.subscribe(this.name);
}
/**
* Unsubscribe from a Pusher channel.
*/
unsubscribe() {
this.pusher.unsubscribe(this.name);
}
/**
* Listen for an event on the channel instance.
*/
listen(e, n) {
return this.on(this.eventFormatter.format(e), n), this;
}
/**
* Listen for all events on the channel instance.
*/
listenToAll(e) {
return this.subscription.bind_global((n, i) => {
if (n.startsWith("pusher:"))
return;
let a = String(this.options.namespace ?? "").replace(
/\./g,
"\\"
), l = n.startsWith(a) ? n.substring(a.length + 1) : "." + n;
e(l, i);
}), this;
}
/**
* Stop listening for an event on the channel instance.
*/
stopListening(e, n) {
return n ? this.subscription.unbind(
this.eventFormatter.format(e),
n
) : this.subscription.unbind(this.eventFormatter.format(e)), this;
}
/**
* Stop listening for all events on the channel instance.
*/
stopListeningToAll(e) {
return e ? this.subscription.unbind_global(e) : this.subscription.unbind_global(), this;
}
/**
* Register a callback to be called anytime a subscription succeeds.
*/
subscribed(e) {
return this.on("pusher:subscription_succeeded", () => {
e();
}), this;
}
/**
* Register a callback to be called anytime a subscription error occurs.
*/
error(e) {
return this.on("pusher:subscription_error", (n) => {
e(n);
}), this;
}
/**
* Bind a channel to an event.
*/
on(e, n) {
return this.subscription.bind(e, n), this;
}
}
class Vn extends Bt {
/**
* Send a whisper event to other clients in the channel.
*/
whisper(e, n) {
return this.pusher.channels.channels[this.name].trigger(
`client-${e}`,
n
), this;
}
}
class Ui extends Bt {
/**
* Send a whisper event to other clients in the channel.
*/
whisper(e, n) {
return this.pusher.channels.channels[this.name].trigger(
`client-${e}`,
n
), this;
}
}
class Di extends Vn {
/**
* Register a callback to be called anytime the member list changes.
*/
here(e) {
return this.on("pusher:subscription_succeeded", (n) => {
e(Object.keys(n.members).map((i) => n.members[i]));
}), this;
}
/**
* Listen for someone joining the channel.
*/
joining(e) {
return this.on("pusher:member_added", (n) => {
e(n.info);
}), this;
}
/**
* Send a whisper event to other clients in the channel.
*/
whisper(e, n) {
return this.pusher.channels.channels[this.name].trigger(
`client-${e}`,
n
), this;
}
/**
* Listen for someone leaving the channel.
*/
leaving(e) {
return this.on("pusher:member_removed", (n) => {
e(n.info);
}), this;
}
}
class Xn extends qt {
/**
* Create a new class instance.
*/
constructor(e, n, i) {
super(), this.events = {}, this.listeners = {}, this.name = n, this.socket = e, this.options = i, this.eventFormatter = new Jn(this.options.namespace), this.subscribe();
}
/**
* Subscribe to a Socket.io channel.
*/
subscribe() {
this.socket.emit("subscribe", {
channel: this.name,
auth: this.options.auth || {}
});
}
/**
* Unsubscribe from channel and ubind event callbacks.
*/
unsubscribe() {
this.unbind(), this.socket.emit("unsubscribe", {
channel: this.name,
auth: this.options.auth || {}
});
}
/**
* Listen for an event on the channel instance.
*/
listen(e, n) {
return this.on(this.eventFormatter.format(e), n), this;
}
/**
* Stop listening for an event on the channel instance.
*/
stopListening(e, n) {
return this.unbindEvent(this.eventFormatter.format(e), n), this;
}
/**
* Register a callback to be called anytime a subscription succeeds.
*/
subscribed(e) {
return this.on("connect", (n) => {
e(n);
}), this;
}
/**
* Register a callback to be called anytime an error occurs.
*/
error(e) {
return this;
}
/**
* Bind the channel's socket to an event and store the callback.
*/
on(e, n) {
return this.listeners[e] = this.listeners[e] || [], this.events[e] || (this.events[e] = (i, a) => {
this.name === i && this.listeners[e] && this.listeners[e].forEach((l) => l(a));
}, this.socket.on(e, this.events[e])), this.listeners[e].push(n), this;
}
/**
* Unbind the channel's socket from all stored event callbacks.
*/
unbind() {
Object.keys(this.events).forEach((e) => {
this.unbindEvent(e);
});
}
/**
* Unbind the listeners for the given event.
*/
unbindEvent(e, n) {
this.listeners[e] = this.listeners[e] || [], n && (this.listeners[e] = this.listeners[e].filter(
(i) => i !== n
)), (!n || this.listeners[e].length === 0) && (this.events[e] && (this.socket.removeListener(e, this.events[e]), delete this.events[e]), delete this.listeners[e]);
}
}
class Wn extends Xn {
/**
* Send a whisper event to other clients in the channel.
*/
whisper(e, n) {
return this.socket.emit("client event", {
channel: this.name,
event: `client-${e}`,
data: n
}), this;
}
}
class Ii extends Wn {
/**
* Register a callback to be called anytime the member list changes.
*/
here(e) {
return this.on("presence:subscribed", (n) => {
e(n.map((i) => i.user_info));
}), this;
}
/**
* Listen for someone joining the channel.
*/
joining(e) {
return this.on(
"presence:joining",
(n) => e(n.user_info)
), this;
}
/**
* Send a whisper event to other clients in the channel.
*/
whisper(e, n) {
return this.socket.emit("client event", {
channel: this.name,
event: `client-${e}`,
data: n
}), this;
}
/**
* Listen for someone leaving the channel.
*/
leaving(e) {
return this.on(
"presence:leaving",
(n) => e(n.user_info)
), this;
}
}
class Ze extends qt {
/**
* Subscribe to a channel.
*/
subscribe() {
}
/**
* Unsubscribe from a channel.
*/
unsubscribe() {
}
/**
* Listen for an event on the channel instance.
*/
listen(e, n) {
return this;
}
/**
* Listen for all events on the channel instance.
*/
listenToAll(e) {
return this;
}
/**
* Stop listening for an event on the channel instance.
*/
stopListening(e, n) {
return this;
}
/**
* Register a callback to be called anytime a subscription succeeds.
*/
subscribed(e) {
return this;
}
/**
* Register a callback to be called anytime an error occurs.
*/
error(e) {
return this;
}
/**
* Bind a channel to an event.
*/
on(e, n) {
return this;
}
}
class Kn extends Ze {
/**
* Send a whisper event to other clients in the channel.
*/
whisper(e, n) {
return this;
}
}
class Fi extends Ze {
/**
* Send a whisper event to other clients in the channel.
*/
whisper(e, n) {
return this;
}
}
class qi extends Kn {
/**
* Register a callback to be called anytime the member list changes.
*/
here(e) {
return this;
}
/**
* Listen for someone joining the channel.
*/
joining(e) {
return this;
}
/**
* Send a whisper event to other clients in the channel.
*/
whisper(e, n) {
return this;
}
/**
* Listen for someone leaving the channel.
*/
leaving(e) {
return this;
}
}
const Qn = class Gn {
/**
* Create a new class instance.
*/
constructor(e) {
this.setOptions(e), this.connect();
}
/**
* Merge the custom options with the defaults.
*/
setOptions(e) {
this.options = {
...Gn._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);
}
/**
* Extract the CSRF token from the page.
*/
csrfToken() {
var e, n;
return ((e = window == null ? void 0 : window.Laravel) == null ? void 0 : e.csrfToken) ?? this.options.csrfToken ?? ((n = document == null ? void 0 : document.querySelector('meta[name="csrf-token"]')) == null ? void 0 : n.getAttribute("content")) ?? null;
}
};
Qn._defaultOptions = {
auth: {
headers: {}
},
authEndpoint: "/broadcasting/auth",
userAuthentication: {
endpoint: "/broadcasting/user-auth",
headers: {}
},
csrfToken: null,
bearerToken: null,
host: null,
key: null,
namespace: "App.Events"
};
let Mt = Qn;
class We extends Mt {
constructor() {
super(...arguments), this.channels = {};
}
/**
* Create a fresh Pusher connection.
*/
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"
);
}
/**
* Sign in the user via Pusher user authentication (https://pusher.com/docs/channels/using_channels/user-authentication/).
*/
signin() {
this.pusher.signin();
}
/**
* Listen for an event on a channel instance.
*/
listen(e, n, i) {
return this.channel(e).listen(n, i);
}
/**
* Get a channel instance by name.
*/
channel(e) {
return this.channels[e] || (this.channels[e] = new Bt(
this.pusher,
e,
this.options
)), this.channels[e];
}
/**
* Get a private channel instance by name.
*/
privateChannel(e) {
return this.channels["private-" + e] || (this.channels["private-" + e] = new Vn(
this.pusher,
"private-" + e,
this.options
)), this.channels["private-" + e];
}
/**
* Get a private encrypted channel instance by name.
*/
encryptedPrivateChannel(e) {
return this.channels["private-encrypted-" + e] || (this.channels["private-encrypted-" + e] = new Ui(
this.pusher,
"private-encrypted-" + e,
this.options
)), this.channels["private-encrypted-" + e];
}
/**
* Get a presence channel instance by name.
*/
presenceChannel(e) {
return this.channels["presence-" + e] || (this.channels["presence-" + e] = new Di(
this.pusher,
"presence-" + e,
this.options
)), this.channels["presence-" + e];
}
/**
* Leave the given channel, as well as its private and presence variants.
*/
leave(e) {
[
e,
"private-" + e,
"private-encrypted-" + e,
"presence-" + e
].forEach((n) => {
this.leaveChannel(n);
});
}
/**
* Leave the given channel.
*/
leaveChannel(e) {
this.channels[e] && (this.channels[e].unsubscribe(), delete this.channels[e]);
}
/**
* Get the socket ID for the connection.
*/
socketId() {
return this.pusher.connection.socket_id;
}
/**
* Disconnect Pusher connection.
*/
disconnect() {
this.pusher.disconnect();
}
}
class Bi extends Mt {
constructor() {
super(...arguments), this.channels = {};
}
/**
* Create a fresh Socket.io connection.
*/
connect() {
let e = this.getSocketIO();
this.socket = e(
this.options.host ?? void 0,
this.options
), this.socket.on("reconnect", () => {
Object.values(this.channels).forEach((n) => {
n.subscribe();
});
});
}
/**
* Get socket.io module from global scope or options.
*/
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 for an event on a channel instance.
*/
listen(e, n, i) {
return this.channel(e).listen(n, i);
}
/**
* Get a channel instance by name.
*/
channel(e) {
return this.channels[e] || (this.channels[e] = new Xn(
this.socket,
e,
this.options
)), this.channels[e];
}
/**
* Get a private channel instance by name.
*/
privateChannel(e) {
return this.channels["private-" + e] || (this.channels["private-" + e] = new Wn(
this.socket,
"private-" + e,
this.options
)), this.channels["private-" + e];
}
/**
* Get a presence channel instance by name.
*/
presenceChannel(e) {
return this.channels["presence-" + e] || (this.channels["presence-" + e] = new Ii(
this.socket,
"presence-" + e,
this.options
)), this.channels["presence-" + e];
}
/**
* Leave the given channel, as well as its private and presence variants.
*/
leave(e) {
[e, "private-" + e, "presence-" + e].forEach((n) => {
this.leaveChannel(n);
});
}
/**
* Leave the given channel.
*/
leaveChannel(e) {
this.channels[e] && (this.channels[e].unsubscribe(), delete this.channels[e]);
}
/**
* Get the socket ID for the connection.
*/
socketId() {
return this.socket.id;
}
/**
* Disconnect Socketio connection.
*/
disconnect() {
this.socket.disconnect();
}
}
class yn extends Mt {
constructor() {
super(...arguments), this.channels = {};
}
/**
* Create a fresh connection.
*/
connect() {
}
/**
* Listen for an event on a channel instance.
*/
listen(e, n, i) {
return new Ze();
}
/**
* Get a channel instance by name.
*/
channel(e) {
return new Ze();
}
/**
* Get a private channel instance by name.
*/
privateChannel(e) {
return new Kn();
}
/**
* Get a private encrypted channel instance by name.
*/
encryptedPrivateChannel(e) {
return new Fi();
}
/**
* Get a presence channel instance by name.
*/
presenceChannel(e) {
return new qi();
}
/**
* Leave the given channel, as well as its private and presence variants.
*/
leave(e) {
}
/**
* Leave the given channel.
*/
leaveChannel(e) {
}
/**
* Get the socket ID for the connection.
*/
socketId() {
return "fake-socket-id";
}
/**
* Disconnect the connection.
*/
disconnect() {
}
}
class Zn {
/**
* Create a new class instance.
*/
constructor(e) {
this.options = e, this.connect(), this.options.withoutInterceptors || this.registerInterceptors();
}
/**
* Get a channel instance by name.
*/
channel(e) {
return this.connector.channel(e);
}
/**
* Create a new connection.
*/
connect() {
if (this.options.broadcaster === "reverb")
this.connector = new We({
...this.options,
cluster: ""
});
else if (this.options.broadcaster === "pusher")
this.connector = new We(this.options);
else if (this.options.broadcaster === "ably")
this.connector = new We({
...this.options,
cluster: "",
broadcaster: "pusher"
});
else if (this.options.broadcaster === "socket.io")
this.connector = new Bi(this.options);
else if (this.options.broadcaster === "null")
this.connector = new yn(this.options);
else if (typeof this.options.broadcaster == "function" && ji(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 from the Echo server.
*/
disconnect() {
this.connector.disconnect();
}
/**
* Get a presence channel instance by name.
*/
join(e) {
return this.connector.presenceChannel(e);
}
/**
* Leave the given channel, as well as its private and presence variants.
*/
leave(e) {
this.connector.leave(e);
}
/**
* Leave the given channel.
*/
leaveChannel(e) {
this.connector.leaveChannel(e);
}
/**
* Leave all channels.
*/
leaveAllChannels() {
for (const e in this.connector.channels)
this.leaveChannel(e);
}
/**
* Listen for an event on a channel instance.
*/
listen(e, n, i) {
return this.connector.listen(e, n, i);
}
/**
* Get a private channel instance by name.
*/
private(e) {
return this.connector.privateChannel(e);
}
/**
* Get a private encrypted channel instance by name.
*/
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 We || e instanceof yn;
}
/**
* Get the Socket ID for the connection.
*/
socketId() {
return this.connector.socketId();
}
/**
* Register 3rd party request interceptiors. These are used to automatically
* send a connections socket id to a Laravel app with a X-Socket-Id header.
*/
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();
}
/**
* Register a Vue HTTP interceptor to add the X-Socket-ID header.
*/
registerVueRequestInterceptor() {
Vue.http.interceptors.push(
(e, n) => {
this.socketId() && e.headers.set("X-Socket-ID", this.socketId()), n();
}
);
}
/**
* Register an Axios HTTP interceptor to add the X-Socket-ID header.
*/
registerAxiosRequestInterceptor() {
axios.interceptors.request.use(
(e) => (this.socketId() && (e.headers["X-Socket-Id"] = this.socketId()), e)
);
}
/**
* Register jQuery AjaxPrefilter to add the X-Socket-ID header.
*/
registerjQueryAjaxSetup() {
typeof jQuery.ajax < "u" && jQuery.ajaxPrefilter(
(e, n, i) => {
this.socketId() && i.setRequestHeader("X-Socket-Id", this.socketId());
}
);
}
/**
* Register the Turbo Request interceptor to add the X-Socket-ID header.
*/
registerTurboRequestInterceptor() {
document.addEventListener(
"turbo:before-fetch-request",
(e) => {
e.detail.fetchOptions.headers["X-Socket-Id"] = this.socketId();
}
);
}
}
function Mi(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 wn;
function $i() {
return wn || (wn = 1, function(r, e) {
(function(i, a) {
r.exports = a();
})(window, function() {
return (
/******/
function(n) {
var i = {};
function a(l) {
if (i[l])
return i[l].exports;
var u = i[l] = {
/******/
i: l,
/******/
l: !1,
/******/
exports: {}
/******/
};
return n[l].call(u.exports, u, u.exports, a), u.l = !0, u.exports;
}
return a.m = n, a.c = i, a.d = function(l, u, g) {
a.o(l, u) || Object.defineProperty(l, u, { enumerable: !0, get: g });
}, a.r = function(l) {
typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(l, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(l, "__esModule", { value: !0 });
}, a.t = function(l, u) {
if (u & 1 && (l = a(l)), u & 8 || u & 4 && typeof l == "object" && l && l.__esModule) return l;
var g = /* @__PURE__ */ Object.create(null);
if (a.r(g), Object.defineProperty(g, "default", { enumerable: !0, value: l }), u & 2 && typeof l != "string") for (var C in l) a.d(g, C, (function(T) {
return l[T];
}).bind(null, C));
return g;
}, a.n = function(l) {
var u = l && l.__esModule ? (
/******/
function() {
return l.default;
}
) : (
/******/
function() {
return l;
}
);
return a.d(u, "a", u), u;
}, a.o = function(l, u) {
return Object.prototype.hasOwnProperty.call(l, u);
}, a.p = "", a(a.s = 2);
}([
/* 0 */
/***/
function(n, i, a) {
var l = this && this.__extends || /* @__PURE__ */ function() {
var f = function(h, m) {
return f = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(b, E) {
b.__proto__ = E;
} || function(b, E) {
for (var k in E) E.hasOwnProperty(k) && (b[k] = E[k]);
}, f(h, m);
};
return function(h, m) {
f(h, m);
function b() {
this.constructor = h;
}
h.prototype = m === null ? Object.create(m) : (b.prototype = m.prototype, new b());
};
}();
Object.defineProperty(i, "__esModule", { value: !0 });
var u = 256, g = (
/** @class */
function() {
function f(h) {
h === void 0 && (h = "="), this._paddingCharacter = h;
}
return f.prototype.encodedLength = function(h) {
return this._paddingCharacter ? (h + 2) / 3 * 4 | 0 : (h * 8 + 5) / 6 | 0;
}, f.prototype.encode = function(h) {
for (var m = "", 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 k = h.length - b;
if (k > 0) {
var E = h[b] << 16 | (k === 2 ? h[b + 1] << 8 : 0);
m += this._encodeByte(E >>> 3 * 6 & 63), m += this._encodeByte(E >>> 2 * 6 & 63), k === 2 ? m += this._encodeByte(E >>> 1 * 6 & 63) : m += this._paddingCharacter || "", m += this._paddingCharacter || "";
}
return m;
}, f.prototype.maxDecodedLength = function(h) {
return this._paddingCharacter ? h / 4 * 3 | 0 : (h * 6 + 7) / 8 | 0;
}, f.prototype.decodedLength = function(h) {
return this.maxDecodedLength(h.length - this._getPaddingLength(h));
}, f.prototype.decode = function(h) {
if (h.length === 0)
return new Uint8Array(0);
for (var m = this._getPaddingLength(h), b = h.length - m, E = new Uint8Array(this.maxDecodedLength(b)), k = 0, R = 0, P = 0, N = 0, A = 0, I = 0, F = 0; R < b - 4; R += 4)
N = this._decodeChar(h.charCodeAt(R + 0)), A = this._decodeChar(h.charCodeAt(R + 1)), I = this._decodeChar(h.charCodeAt(R + 2)), F = this._decodeChar(h.charCodeAt(R + 3)), E[k++] = N << 2 | A >>> 4, E[k++] = A << 4 | I >>> 2, E[k++] = I << 6 | F, P |= N & u, P |= A & u, P |= I & u, P |= F & u;
if (R < b - 1 && (N = this._decodeChar(h.charCodeAt(R)), A = this._decodeChar(h.charCodeAt(R + 1)), E[k++] = N << 2 | A >>> 4, P |= N & u, P |= A & u), R < b - 2 && (I = this._decodeChar(h.charCodeAt(R + 2)), E[k++] = A << 4 | I >>> 2, P |= I & u), R < b - 3 && (F = this._decodeChar(h.charCodeAt(R + 3)), E[k++] = I << 6 | F, P |= F & u), P !== 0)
throw new Error("Base64Coder: incorrect characters for decoding");
return E;
}, f.prototype._encodeByte = function(h) {
var m = h;
return m += 65, m += 25 - h >>> 8 & 6, m += 51 - h >>> 8 & -75, m += 61 - h >>> 8 & -15, m += 62 - h >>> 8 & 3, String.fromCharCode(m);
}, f.prototype._decodeChar = function(h) {
var m = u;
return m += (42 - h & h - 44) >>> 8 & -256 + h - 43 + 62, m += (46 - h & h - 48) >>> 8 & -256 + h - 47 + 63, m += (47 - h & h - 58) >>> 8 & -256 + h - 48 + 52, m += (64 - h & h - 91) >>> 8 & -256 + h - 65 + 0, m += (96 - h & h - 123) >>> 8 & -256 + h - 97 + 26, m;
}, f.prototype._getPaddingLength = function(h) {
var m = 0;
if (this._paddingCharacter) {
for (var 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;
}, f;
}()
);
i.Coder = g;
var C = new g();
function T(f) {
return C.encode(f);
}
i.encode = T;
function p(f) {
return C.decode(f);
}
i.decode = p;
var _ = (
/** @class */
function(f) {
l(h, f);
function h() {
return f !== null && f.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 = u;
return b += (44 - m & m - 46) >>> 8 & -256 + m - 45 + 62, b += (94 - m & m - 96) >>> 8 & -256 + m - 95 + 63, b += (47 - m & m - 58) >>> 8 & -256 + m - 48 + 52, b += (64 - m & m - 91) >>> 8 & -256 + m - 65 + 0, b += (96 - m & m - 123) >>> 8 & -256 + m - 97 + 26, b;
}, h;
}(g)
);
i.URLSafeCoder = _;
var S = new _();
function w(f) {
return S.encode(f);
}
i.encodeURLSafe = w;
function v(f) {
return S.decode(f);
}
i.decodeURLSafe = v, i.encodedLength = function(f) {
return C.encodedLength(f);
}, i.maxDecodedLength = function(f) {
return C.maxDecodedLength(f);
}, i.decodedLength = function(f) {
return C.decodedLength(f);
};
},
/* 1 */
/***/
function(n, i, a) {
Object.defineProperty(i, "__esModule", { value: !0 });
var l = "utf8: invalid string", u = "utf8: invalid source encoding";
function g(p) {
for (var _ = new Uint8Array(C(p)), S = 0, w = 0; w < p.length; w++) {
var v = p.charCodeAt(w);
v < 128 ? _[S++] = v : v < 2048 ? (_[S++] = 192 | v >> 6, _[S++] = 128 | v & 63) : v < 55296 ? (_[S++] = 224 | v >> 12, _[S++] = 128 | v >> 6 & 63, _[S++] = 128 | v & 63) : (w++, v = (v & 1023) << 10, v |= p.charCodeAt(w) & 1023, v += 65536, _[S++] = 240 | v >> 18, _[S++] = 128 | v >> 12 & 63, _[S++] = 128 | v >> 6 & 63, _[S++] = 128 | v & 63);
}
return _;
}
i.encode = g;
function C(p) {
for (var _ = 0, S = 0; S < p.length; S++) {
var w = p.charCodeAt(S);
if (w < 128)
_ += 1;
else if (w < 2048)
_ += 2;
else if (w < 55296)
_ += 3;
else if (w <= 57343) {
if (S >= p.length - 1)
throw new Error(l);
S++, _ += 4;
} else
throw new Error(l);
}
return _;
}
i.encodedLength = C;
function T(p) {
for (var _ = [], S = 0; S < p.length; S++) {
var w = p[S];
if (w & 128) {
var v = void 0;
if (w < 224) {
if (S >= p.length)
throw new Error(u);
var f = p[++S];
if ((f & 192) !== 128)
throw new Error(u);
w = (w & 31) << 6 | f & 63, v = 128;
} else if (w < 240) {
if (S >= p.length - 1)
throw new Error(u);
var f = p[++S], h = p[++S];
if ((f & 192) !== 128 || (h & 192) !== 128)
throw new Error(u);
w = (w & 15) << 12 | (f & 63) << 6 | h & 63, v = 2048;
} else if (w < 248) {
if (S >= p.length - 2)
throw new Error(u);
var f = p[++S], h = p[++S], m = p[++S];
if ((f & 192) !== 128 || (h & 192) !== 128 || (m & 192) !== 128)
throw new Error(u);
w = (w & 15) << 18 | (f & 63) << 12 | (h & 63) << 6 | m & 63, v = 65536;
} else
throw new Error(u);
if (w < v || w >= 55296 && w <= 57343)
throw new Error(u);
if (w >= 65536) {
if (w > 1114111)
throw new Error(u);
w -= 65536, _.push(String.fromCharCode(55296 | w >> 10)), w = 56320 | w & 1023;
}
}
_.push(String.fromCharCode(w));
}
return _.join("");
}
i.decode = T;
},
/* 2 */
/***/
function(n, i, a) {
n.exports = a(3).default;
},
/* 3 */
/***/
function(n, i, a) {
a.r(i);
class l {
constructor(t, s) {
this.lastId = 0, this.prefix = t, this.name = s;
}
create(t) {
this.lastId++;
var s = this.lastId, c = this.prefix + s, d = this.name + "[" + s + "]", x = !1, O = function() {
x || (t.apply(null, arguments), x = !0);
};
return this[s] = O, { number: s, id: c, name: d, callback: O };
}
remove(t) {
delete this[t.number];
}
}
var u = new l("_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: ""
}, C = g;
class T {
constructor(t) {
this.options = t, this.receivers = t.receivers || u, this.loading = {};
}
load(t, s, c) {
var d = this;
if (d.loading[t] && d.loading[t].length > 0)
d.loading[t].push(c);
else {
d.loading[t] = [c];
var x = U.createScriptRequest(d.getPath(t, s)), O = d.receivers.create(function(L) {
if (d.receivers.remove(O), d.loading[t]) {
var j = d.loading[t];
delete d.loading[t];
for (var q = function(W) {
W || x.cleanup();
}, B = 0; B < j.length; B++)
j[B](L, q);
}
});
x.send(O);
}
}
getRoot(t) {
var s, c = U.getDocument().location.protocol;
return t && t.useTLS || c === "https:" ? s = this.options.cdn_https : s = this.options.cdn_http, s.replace(/\/*$/, "") + "/" + this.options.version;
}
getPath(t, s) {
return this.getRoot(s) + "/" + t + this.options.suffix + ".js";
}
}
var p = new l("_pusher_dependencies", "Pusher.DependenciesReceivers"), _ = new T({
cdn_http: C.cdn_http,
cdn_https: C.cdn_https,
version: C.VERSION,
suffix: C.dependency_suffix,
receivers: p
});
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 v = { buildLogSuffix: function(o) {
const t = "See:", s = S.urls[o];
if (!s)
return "";
let c;
return s.fullUrl ? c = s.fullUrl : s.path && (c = S.baseUrl + s.path), c ? `${t} ${c}` : "";
} }, f;
(function(o) {
o.UserAuthentication = "user-authentication", o.ChannelAuthorization = "channel-authorization";
})(f || (f = {}));
class h extends Error {
constructor(t) {
super(t), Object.setPrototypeOf(this, new.target.prototype);
}
}
class m extends Error {
constructor(t) {
super(t), Object.setPrototypeOf(this, new.target.prototype);
}
}
class 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 k extends Error {
constructor(t) {
super(t), Object.setPrototypeOf(this, new.target.prototype);
}
}
class R extends Error {
constructor(t) {
super(t), Object.setPrototypeOf(this, new.target.prototype);
}
}
class P extends Error {
constructor(t) {
super(t), Object.setPrototypeOf(this, new.target.prototype);
}
}
class N extends Error {
constructor(t) {
super(t), Object.setPrototypeOf(this, new.target.prototype);
}
}
class A extends Error {
constructor(t, s) {
super(s), this.status = t, Object.setPrototypeOf(this, new.target.prototype);
}
}
var F = function(o, t, s, c, d) {
const x = U.createXHR();
x.open("POST", s.endpoint, !0), x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
for (var O in s.headers)
x.setRequestHeader(O, s.headers[O]);
if (s.headersProvider != null) {
let L = s.headersProvider();
for (var O in L)
x.setRequestHeader(O, L[O]);
}
return x.onreadystatechange = function() {
if (x.readyState === 4)
if (x.status === 200) {
let L, j = !1;
try {
L = JSON.parse(x.responseText), j = !0;
} catch {
d(new A(200, `JSON returned from ${c.toString()} endpoint was invalid, yet status code was 200. Data was: ${x.responseText}`), null);
}
j && d(null, L);
} else {
let L = "";
switch (c) {
case f.UserAuthentication:
L = v.buildLogSuffix("authenticationEndpoint");
break;
case f.ChannelAuthorization:
L = `Clients must be authorized to join private or presence channels. ${v.buildLogSuffix("authorizationEndpoint")}`;
break;
}
d(new A(x.status, `Unable to retrieve auth string from ${c.toString()} endpoint - received status: ${x.status} from ${s.endpoint}. ${L}`), null);
}
}, x.send(t), x;
};
function fe(o) {
return Se(qe(o));
}
var re = String.fromCharCode, $ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Fe = function(o) {
var t = o.charCodeAt(0);
return t < 128 ? o : t < 2048 ? re(192 | t >>> 6) + re(128 | t & 63) : re(224 | t >>> 12 & 15) + re(128 | t >>> 6 & 63) + re(128 | t & 63);
}, qe = function(o) {
return o.replace(/[^\x00-\x7F]/g, Fe);
}, Be = function(o) {
var t = [0, 2, 1][o.length % 3], s = o.charCodeAt(0) << 16 | (o.length > 1 ? o.charCodeAt(1) : 0) << 8 | (o.length > 2 ? o.charCodeAt(2) : 0), c = [
$.charAt(s >>> 18),
$.charAt(s >>> 12 & 63),
t >= 2 ? "=" : $.charAt(s >>> 6 & 63),
t >= 1 ? "=" : $.charAt(s & 63)
];
return c.join("");
}, Se = window.btoa || function(o) {
return o.replace(/[\s\S]{1,3}/g, Be);
};
class Ee {
constructor(t, s, c, d) {
this.clear = s, this.timer = t(() => {
this.timer && (this.timer = d(this.timer));
}, c);
}
isRunning() {
return this.timer !== null;
}
ensureAborted() {
this.timer && (this.clear(this.timer), this.timer = null);
}
}
var pe = Ee;
function Me(o) {
window.clearTimeout(o);
}
function ke(o) {
window.clearInterval(o);
}
class Z extends pe {
constructor(t, s) {
super(setTimeout, Me, t, function(c) {
return s(), null;
});
}
}
class $e extends pe {
constructor(t, s) {
super(setInterval, ke, t, function(c) {
return s(), c;
});
}
}
var ct = {
now() {
return Date.now ? Date.now() : (/* @__PURE__ */ new Date()).valueOf();
},
defer(o) {
return new Z(0, o);
},
method(o, ...t) {
var s = Array.prototype.slice.call(arguments, 1);
return function(c) {
return c[o].apply(c, s.concat(arguments));
};
}
}, X = ct;
function Y(o, ...t) {
for (var s = 0; s < t.length; s++) {
var c = t[s];
for (var d in c)
c[d] && c[d].constructor && c[d].constructor === Object ? o[d] = Y(o[d] || {}, c[d]) : o[d] = c[d];
}
return o;
}
function Rr() {
for (var o = ["Pusher"], t = 0; t < arguments.length; t++)
typeof arguments[t] == "string" ? o.push(arguments[t]) : o.push(He(arguments[t]));
return o.join(" : ");
}
function Vt(o, t) {
var s = Array.prototype.indexOf;
if (o === null)
return -1;
if (s && o.indexOf === s)
return o.indexOf(t);
for (var c = 0, d = o.length; c < d; c++)
if (o[c] === t)
return c;
return -1;
}
function ce(o, t) {
for (var s in o)
Object.prototype.hasOwnProperty.call(o, s) && t(o[s], s, o);
}
function Xt(o) {
var t = [];
return ce(o, function(s, c) {
t.push(c);
}), t;
}
function Or(o) {
var t = [];
return ce(o, function(s) {
t.push(s);
}), t;
}
function Re(o, t, s) {
for (var c = 0; c < o.length; c++)
t.call(s || window, o[c], c, o);
}
function Wt(o, t) {
for (var s = [], c = 0; c < o.length; c++)
s.push(t(o[c], c, o, s));
return s;
}
function Pr(o, t) {
var s = {};
return ce(o, function(c, d) {
s[d] = t(c);
}), s;
}
function Kt(o, t) {
t = t || function(d) {
return !!d;
};
for (var s = [], c = 0; c < o.length; c++)
t(o[c], c, o, s) && s.push(o[c]);
return s;
}
function Qt(o, t) {
var s = {};
return ce(o, function(c, d) {
(t && t(c, d, o, s) || c) && (s[d] = c);
}), s;
}
function Ar(o) {
var t = [];
return ce(o, function(s, c) {
t.push([c, s]);
}), t;
}
function Gt(o, t) {
for (var s = 0; s < o.length; s++)
if (t(o[s], s, o))
return !0;
return !1;
}
function Lr(o, t) {
for (var s = 0; s < o.length; s++)
if (!t(o[s], s, o))
return !1;
return !0;
}
function Nr(o) {
return Pr(o, function(t) {
return typeof t == "object" && (t = He(t)), encodeURIComponent(fe(t.toString()));
});
}
function jr(o) {
var t = Qt(o, function(c) {
return c !== void 0;
}), s = Wt(Ar(Nr(t)), X.method("join", "=")).join("&");
return s;
}
function Ur(o) {
var t = [], s = [];
return function c(d, x) {
var O, L, j;
switch (typeof d) {
case "object":
if (!d)
return null;
for (O = 0; O < t.length; O += 1)
if (t[O] === d)
return { $ref: s[O] };
if (t.push(d), s.push(x), Object.prototype.toString.apply(d) === "[object Array]")
for (j = [], O = 0; O < d.length; O += 1)
j[O] = c(d[O], x + "[" + O + "]");
else {
j = {};
for (L in d)
Object.prototype.hasOwnProperty.call(d, L) && (j[L] = c(d[L], x + "[" + JSON.stringify(L) + "]"));
}
return j;
case "number":
case "string":
case "boolean":
return d;
}
}(o, "$");
}
function He(o) {
try {
return JSON.stringify(o);
} catch {
return JSON.stringify(Ur(o));
}
}
class Dr {
constructor() {
this.globalLog = (t) => {
window.console && window.console.log && window.console.log(t);
};
}
debug(...t) {
this.log(this.globalLog, t);
}
warn(...t) {
this.log(this.globalLogWarn, t);
}
error(...t) {
this.log(this.globalLogError, t);
}
globalLogWarn(t) {
window.console && window.console.warn ? window.console.warn(t) : this.globalLog(t);
}
globalLogError(t) {
window.console && window.console.error ? window.console.error(t) : this.globalLogWarn(t);
}
log(t, ...s) {
var c = Rr.apply(this, arguments);
yt.log ? yt.log(c) : yt.logToConsole && t.bind(this)(c);
}
}
var z = new Dr(), Ir = function(o, t, s, c, d) {
(s.headers !== void 0 || s.headersProvider != null) && z.warn(`To send headers with the ${c.toString()} request, you must use AJAX, rather than JSONP.`);
var x = o.nextAuthCallbackID.toString();
o.nextAuthCallbackID++;
var O = o.getDocument(), L = O.createElement("script");
o.auth_callbacks[x] = function(B) {
d(null, B);
};
var j = "Pusher.auth_callbacks['" + x + "']";
L.src = s.endpoint + "?callback=" + encodeURIComponent(j) + "&" + t;
var q = O.getElementsByTagName("head")[0] || O.documentElement;
q.insertBefore(L, q.firstChild);
}, Fr = Ir;
class qr {
constructor(t) {
this.src = t;
}
send(t) {
var s = this, c = "Error loading " + s.src;
s.script = document.createElement("script"), s.script.id = t.id, s.script.src = s.src, s.script.type = "text/javascript", s.script.charset = "UTF-8", s.script.addEventListener ? (s.script.onerror = function() {
t.callback(c);
}, s.script.onload = function() {
t.callback(null);
}) : s.script.onreadystatechange = function() {
(s.script.readyState === "loaded" || s.script.readyState === "complete") && t.callback(null);
}, s.sc