@nivaro/react 0.3.94 → 0.3.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/NotificationBell.js +1 -1
- package/dist/shared/components/chat/ChatMessageToast.js +248 -0
- package/dist/shared/components/chat/chat-core.js +415 -381
- package/dist/shared/components/item-edit/FieldAffordances.js +285 -278
- package/dist/shared/components/item-edit/FieldRow.js +53 -52
- package/dist/shared/components/item-edit/InlineTableField.js +1 -0
- package/dist/shared/components/item-edit/RuleProvenancePopover.js +61 -53
- package/dist/shared/components/item-edit/useRecordLabels.js +44 -0
- package/dist/shared/components/notifications/NotificationDetailBits.js +55 -55
- package/dist/shared/components/ops-report/SettingsPanel.js +44 -41
- package/dist/shared/components/ops-report/drill.js +263 -177
- package/dist/shared/components/panels/PipelinePanel.js +175 -178
- package/dist/shared/components/support/ReportProblem.js +10 -10
- package/dist/shared/components/support/SupportRequestDialog.js +11 -11
- package/dist/shared/components/support/TicketDetailSheet.js +114 -109
- package/dist/shared/components/support/support-context.js +14 -9
- package/package.json +1 -1
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import { readItems as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { useContext as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { announceLocalPrefs as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
1
|
+
import { readItems as ee } from "@nivaro/sdk";
|
|
2
|
+
import { useQueryClient as b, useMutation as g, useQuery as v, useInfiniteQuery as te } from "@tanstack/react-query";
|
|
3
|
+
import { useContext as ne, useState as P, useEffect as T, useMemo as D, useCallback as U, useRef as A, createContext as se } from "react";
|
|
4
|
+
import { useNivaroClient as m } from "../../context.js";
|
|
5
|
+
import { get as p, patch as S, post as M, del as B } from "../../lib/commands.js";
|
|
6
|
+
import { isDndActive as re } from "../../lib/dnd.js";
|
|
7
|
+
import { useLiveRefetchInterval as oe } from "../../lib/live-queries.js";
|
|
8
|
+
import { playNotificationSound as ae } from "../../lib/notification-sound.js";
|
|
9
|
+
import { useTabAttention as ie } from "../../lib/tab-attention.js";
|
|
10
|
+
import { announceLocalPrefs as ce } from "../../lib/user-sync.js";
|
|
11
|
+
import { showChatMessageCard as ue, dismissChatCard as le } from "./ChatMessageToast.js";
|
|
12
|
+
import { bindChatOutbox as G, enqueueChatOutbox as V } from "./chat-outbox.js";
|
|
13
|
+
import { discardOutbox as Ot, editOutbox as kt, holdOutbox as xt, nudgeChatOutbox as Qt, retryOutbox as Lt, useOutbox as Pt } from "./chat-outbox.js";
|
|
14
|
+
import { huddleHolds as de, holdNotification as me } from "./huddle/huddle-hold.js";
|
|
15
|
+
const Ae = ["👍", "✅", "👀", "🎉", "❤️", "😂"], fe = se(null);
|
|
15
16
|
function _() {
|
|
16
|
-
const e =
|
|
17
|
+
const e = ne(fe);
|
|
17
18
|
if (!e) throw new Error("Chat components must be wrapped in <ChatProvider>");
|
|
18
19
|
return e;
|
|
19
20
|
}
|
|
20
|
-
const
|
|
21
|
+
const Ne = 0, De = {
|
|
21
22
|
collections: { messages: "chat_messages", reads: "chat_last_read", presence: "user_presence" },
|
|
22
23
|
globalRoom: "global",
|
|
23
24
|
globalLabel: "General",
|
|
24
25
|
entityPattern: String.raw`\b([A-Za-z]{2,4}\d{2}(?:INV)?-\d+)\b`
|
|
25
26
|
};
|
|
26
|
-
function
|
|
27
|
+
function Ee(e, t) {
|
|
27
28
|
return `dm:${[e.toUpperCase(), t.toUpperCase()].sort().join(":")}`;
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
+
function W(e, t) {
|
|
30
31
|
if (!e.startsWith("dm:")) return null;
|
|
31
32
|
const n = e.slice(3);
|
|
32
33
|
return [n.slice(0, 36), n.slice(37)].find((o) => o.toLowerCase() !== t.toLowerCase()) ?? null;
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
-
const n = _(), s =
|
|
36
|
-
|
|
35
|
+
function k(e, t) {
|
|
36
|
+
const n = _(), s = b(), o = (t ?? []).join("|");
|
|
37
|
+
T(() => {
|
|
37
38
|
const r = () => {
|
|
38
39
|
for (const a of e) s.invalidateQueries({ queryKey: a });
|
|
39
40
|
};
|
|
@@ -41,75 +42,75 @@ function K(e, t) {
|
|
|
41
42
|
if (n.realtime) return n.realtime(n.collections.messages, r);
|
|
42
43
|
}, [n.subscribeRooms, n.realtime, o, s]);
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
-
const n = _(), s =
|
|
46
|
-
|
|
45
|
+
function he(e, t) {
|
|
46
|
+
const n = _(), s = b();
|
|
47
|
+
T(() => {
|
|
47
48
|
if (n.realtime)
|
|
48
49
|
return n.realtime(e, () => {
|
|
49
50
|
for (const o of t) s.invalidateQueries({ queryKey: o });
|
|
50
51
|
});
|
|
51
52
|
}, [n.realtime, e, s]);
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
-
var
|
|
55
|
-
const n = _(), s =
|
|
54
|
+
function je(e, t = null) {
|
|
55
|
+
var I, w, x;
|
|
56
|
+
const n = _(), s = m(), o = t ? "around" in t ? `around:${t.around}` : `date:${t.date}` : "latest", { data: r, isLoading: a } = v({
|
|
56
57
|
queryKey: ["nvr-chat", e, o],
|
|
57
58
|
queryFn: async () => {
|
|
58
|
-
const
|
|
59
|
-
return t && "around" in t && (
|
|
60
|
-
|
|
59
|
+
const q = { room: e, limit: 80 };
|
|
60
|
+
return t && "around" in t && (q.around = t.around), t && "date" in t && (q.date = t.date), await s.request(
|
|
61
|
+
p("/chat/messages", q)
|
|
61
62
|
);
|
|
62
63
|
},
|
|
63
64
|
enabled: !!e,
|
|
64
65
|
staleTime: 5e3,
|
|
65
66
|
refetchInterval: n.realtime || n.subscribeRooms ? void 0 : 1e4
|
|
66
67
|
});
|
|
67
|
-
|
|
68
|
-
const [i, c] =
|
|
69
|
-
|
|
70
|
-
c([]),
|
|
68
|
+
k([["nvr-chat"], ["nvr-chat-rooms"], ["nvr-chat-thread"]], e ? [e] : []);
|
|
69
|
+
const [i, c] = P([]), [u, d] = P(null), [l, h] = P(!1);
|
|
70
|
+
T(() => {
|
|
71
|
+
c([]), d(null);
|
|
71
72
|
}, [e, o]);
|
|
72
|
-
const
|
|
73
|
-
if (i.length === 0) return
|
|
74
|
-
const
|
|
75
|
-
return [...i.filter((
|
|
76
|
-
}, [i,
|
|
77
|
-
var
|
|
78
|
-
if (!e ||
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
|
|
73
|
+
const y = (r == null ? void 0 : r.data) ?? [], f = D(() => {
|
|
74
|
+
if (i.length === 0) return y;
|
|
75
|
+
const q = new Set(y.map((C) => C.id));
|
|
76
|
+
return [...i.filter((C) => !q.has(C.id)), ...y];
|
|
77
|
+
}, [i, y]), R = U(async () => {
|
|
78
|
+
var C;
|
|
79
|
+
if (!e || l) return;
|
|
80
|
+
const q = f[0];
|
|
81
|
+
if (q) {
|
|
82
|
+
h(!0);
|
|
82
83
|
try {
|
|
83
|
-
const
|
|
84
|
-
|
|
84
|
+
const O = await s.request(
|
|
85
|
+
p("/chat/messages", { room: e, limit: 60, before: q.id })
|
|
85
86
|
);
|
|
86
|
-
c((
|
|
87
|
+
c((Q) => [...O.data ?? [], ...Q]), d(!!((C = O.meta) != null && C.has_older));
|
|
87
88
|
} finally {
|
|
88
|
-
|
|
89
|
+
h(!1);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
|
-
}, [e,
|
|
92
|
+
}, [e, f, s, l]);
|
|
92
93
|
return {
|
|
93
|
-
messages:
|
|
94
|
+
messages: f,
|
|
94
95
|
loading: a,
|
|
95
|
-
hasOlder:
|
|
96
|
-
hasNewer: !!((
|
|
97
|
-
anchorId: ((
|
|
98
|
-
loadOlder:
|
|
99
|
-
loadingOlder:
|
|
96
|
+
hasOlder: u ?? !!((I = r == null ? void 0 : r.meta) != null && I.has_older),
|
|
97
|
+
hasNewer: !!((w = r == null ? void 0 : r.meta) != null && w.has_newer),
|
|
98
|
+
anchorId: ((x = r == null ? void 0 : r.meta) == null ? void 0 : x.anchor) ?? null,
|
|
99
|
+
loadOlder: R,
|
|
100
|
+
loadingOlder: l
|
|
100
101
|
};
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
-
const n = _(), s =
|
|
103
|
+
function ze(e, t) {
|
|
104
|
+
const n = _(), s = m(), { data: o, isLoading: r } = v({
|
|
104
105
|
queryKey: ["nvr-chat-thread", e, t],
|
|
105
106
|
queryFn: async () => (await s.request(
|
|
106
|
-
|
|
107
|
+
p("/chat/messages", { room: e, thread: t, limit: 300 })
|
|
107
108
|
)).data ?? [],
|
|
108
109
|
enabled: !!e && !!t,
|
|
109
110
|
staleTime: 5e3,
|
|
110
111
|
refetchInterval: n.realtime || n.subscribeRooms ? void 0 : 1e4
|
|
111
112
|
});
|
|
112
|
-
|
|
113
|
+
k([["nvr-chat-thread"]], e ? [e] : []);
|
|
113
114
|
const a = o ?? [];
|
|
114
115
|
return {
|
|
115
116
|
root: a.find((i) => i.id === t) ?? null,
|
|
@@ -117,47 +118,47 @@ function De(e, t) {
|
|
|
117
118
|
loading: r
|
|
118
119
|
};
|
|
119
120
|
}
|
|
120
|
-
function
|
|
121
|
+
function Be(e) {
|
|
121
122
|
var r, a, i;
|
|
122
|
-
const t =
|
|
123
|
-
return
|
|
123
|
+
const t = m(), n = b(), s = _();
|
|
124
|
+
return G(t, n, ((r = s.me) == null ? void 0 : r.id) ?? null), { mutate: U(
|
|
124
125
|
(c) => {
|
|
125
|
-
var
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
client_id:
|
|
126
|
+
var d, l;
|
|
127
|
+
const u = typeof c == "string" ? { text: c } : c;
|
|
128
|
+
V({
|
|
129
|
+
client_id: Y(),
|
|
129
130
|
room: e,
|
|
130
|
-
text:
|
|
131
|
-
mentions:
|
|
132
|
-
attachments:
|
|
133
|
-
parent_id:
|
|
134
|
-
quote_id:
|
|
135
|
-
urgent: !!
|
|
131
|
+
text: u.text,
|
|
132
|
+
mentions: u.mentions ?? [],
|
|
133
|
+
attachments: u.attachments ?? [],
|
|
134
|
+
parent_id: u.parentId ?? null,
|
|
135
|
+
quote_id: u.quoteId ?? null,
|
|
136
|
+
urgent: !!u.urgent,
|
|
136
137
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
137
|
-
sender: ((
|
|
138
|
-
sender_name: ((
|
|
138
|
+
sender: ((d = s.me) == null ? void 0 : d.id) ?? "",
|
|
139
|
+
sender_name: ((l = s.me) == null ? void 0 : l.name) ?? null
|
|
139
140
|
});
|
|
140
141
|
},
|
|
141
142
|
[e, (a = s.me) == null ? void 0 : a.id, (i = s.me) == null ? void 0 : i.name]
|
|
142
143
|
), isPending: !1 };
|
|
143
144
|
}
|
|
144
|
-
function
|
|
145
|
+
function Y() {
|
|
145
146
|
var t;
|
|
146
147
|
const e = globalThis.crypto;
|
|
147
148
|
return ((t = e == null ? void 0 : e.randomUUID) == null ? void 0 : t.call(e)) ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
148
149
|
}
|
|
149
|
-
function
|
|
150
|
+
function Z(e, t, n) {
|
|
150
151
|
const s = (t == null ? void 0 : t.toLowerCase()) ?? "";
|
|
151
152
|
return e.map((r) => {
|
|
152
|
-
var c,
|
|
153
|
+
var c, u, d, l, h;
|
|
153
154
|
const a = r.kind === "unknown" ? "entity" : r.kind, i = a === "global" ? (
|
|
154
155
|
// The server names General only when an admin renamed it.
|
|
155
156
|
r.label ?? n.globalLabel
|
|
156
157
|
) : a === "dm" ? (
|
|
157
158
|
// The server resolves the peer's name from the user table; the
|
|
158
159
|
// message sender is only a fallback for hosts that don't send one.
|
|
159
|
-
r.label ?? (((
|
|
160
|
-
) : r.label ?? ((
|
|
160
|
+
r.label ?? (((u = (c = r.last_message) == null ? void 0 : c.sender) == null ? void 0 : u.toLowerCase()) !== s ? ((d = r.last_message) == null ? void 0 : d.sender_name) ?? null : null) ?? `User ${((l = W(r.room, s)) == null ? void 0 : l.slice(0, 8)) ?? ""}`
|
|
161
|
+
) : r.label ?? ((h = n.roomLabel) == null ? void 0 : h.call(n, r.room)) ?? r.room.toUpperCase();
|
|
161
162
|
return {
|
|
162
163
|
room: r.room,
|
|
163
164
|
label: i,
|
|
@@ -180,101 +181,101 @@ function G(e, t, n) {
|
|
|
180
181
|
return (a.lastMessage ? new Date(a.lastMessage.date_created).getTime() : 0) - i;
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
|
-
function
|
|
184
|
-
const e = _(), t =
|
|
184
|
+
function He() {
|
|
185
|
+
const e = _(), t = m(), n = e.me, s = v({
|
|
185
186
|
queryKey: ["nvr-chat-rooms", n == null ? void 0 : n.id],
|
|
186
|
-
queryFn: async () => (await t.request(
|
|
187
|
+
queryFn: async () => (await t.request(p("/chat/rooms"))).data ?? [],
|
|
187
188
|
enabled: !!n,
|
|
188
189
|
refetchInterval: 45e3,
|
|
189
190
|
staleTime: 1e4
|
|
190
191
|
});
|
|
191
|
-
|
|
192
|
-
const o =
|
|
193
|
-
() =>
|
|
192
|
+
k([["nvr-chat-rooms"]]);
|
|
193
|
+
const o = D(
|
|
194
|
+
() => Z(s.data ?? [], n == null ? void 0 : n.id, e),
|
|
194
195
|
[s.data, n == null ? void 0 : n.id, e]
|
|
195
|
-
), r =
|
|
196
|
-
var
|
|
196
|
+
), r = E().chat_badge_mode, a = o.reduce((i, c) => {
|
|
197
|
+
var u;
|
|
197
198
|
if (c.muted) return i;
|
|
198
199
|
if (r === "conversations") {
|
|
199
|
-
const
|
|
200
|
-
return i + (
|
|
200
|
+
const d = c.kind === "dm" || c.kind === "channel" && !!((u = c.channel) != null && u.is_direct);
|
|
201
|
+
return i + (d ? c.unread : c.mentions ?? 0);
|
|
201
202
|
}
|
|
202
203
|
return i + c.unread;
|
|
203
204
|
}, 0);
|
|
204
205
|
return { rooms: o, totalUnread: a, loading: s.isLoading };
|
|
205
206
|
}
|
|
206
|
-
function
|
|
207
|
-
const t = _(), n =
|
|
207
|
+
function Ge(e) {
|
|
208
|
+
const t = _(), n = m(), s = t.me, o = v({
|
|
208
209
|
queryKey: ["nvr-chat-rooms", s == null ? void 0 : s.id, "archived"],
|
|
209
210
|
queryFn: async () => (await n.request(
|
|
210
|
-
|
|
211
|
+
p("/chat/rooms", { archived: "1" })
|
|
211
212
|
)).data ?? [],
|
|
212
213
|
enabled: !!s && e,
|
|
213
214
|
staleTime: 1e4
|
|
214
215
|
});
|
|
215
|
-
return { rooms:
|
|
216
|
+
return { rooms: D(() => Z(o.data ?? [], s == null ? void 0 : s.id, t), [o.data, s == null ? void 0 : s.id, t]), loading: o.isLoading };
|
|
216
217
|
}
|
|
217
|
-
function
|
|
218
|
-
const t =
|
|
218
|
+
function Ve(e) {
|
|
219
|
+
const t = m(), { data: n, isLoading: s } = v({
|
|
219
220
|
queryKey: ["nvr-chat-directory", e],
|
|
220
221
|
queryFn: async () => (await t.request(
|
|
221
|
-
|
|
222
|
+
p("/chat/directory", e ? { search: e } : void 0)
|
|
222
223
|
)).data ?? [],
|
|
223
224
|
staleTime: 15e3
|
|
224
225
|
});
|
|
225
226
|
return { channels: n ?? [], loading: s };
|
|
226
227
|
}
|
|
227
|
-
function
|
|
228
|
-
const e =
|
|
228
|
+
function We() {
|
|
229
|
+
const e = m(), t = b(), n = () => {
|
|
229
230
|
t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), t.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
|
|
230
|
-
}, s =
|
|
231
|
-
mutationFn: (
|
|
231
|
+
}, s = g({
|
|
232
|
+
mutationFn: (d) => e.request(M(`/chat/rooms/${encodeURIComponent(d)}/join`)),
|
|
232
233
|
onSuccess: n
|
|
233
|
-
}), o =
|
|
234
|
-
mutationFn: (
|
|
234
|
+
}), o = g({
|
|
235
|
+
mutationFn: (d) => e.request(B(`/chat/rooms/${encodeURIComponent(d)}/join`)),
|
|
235
236
|
onSuccess: n
|
|
236
|
-
}), r =
|
|
237
|
-
mutationFn: ({ room:
|
|
237
|
+
}), r = g({
|
|
238
|
+
mutationFn: ({ room: d, muted: l }) => e.request(S(`/chat/rooms/${encodeURIComponent(d)}`, { muted: l })),
|
|
238
239
|
onSuccess: n
|
|
239
|
-
}), a =
|
|
240
|
-
mutationFn: ({ room:
|
|
241
|
-
|
|
242
|
-
notify_mode:
|
|
240
|
+
}), a = g({
|
|
241
|
+
mutationFn: ({ room: d, mode: l }) => e.request(
|
|
242
|
+
S(`/chat/rooms/${encodeURIComponent(d)}`, {
|
|
243
|
+
notify_mode: l === "mentions" ? "mentions" : null
|
|
243
244
|
})
|
|
244
245
|
),
|
|
245
246
|
onSuccess: n
|
|
246
|
-
}), i =
|
|
247
|
-
mutationFn: ({ room:
|
|
247
|
+
}), i = g({
|
|
248
|
+
mutationFn: ({ room: d, archived: l }) => e.request(S(`/chat/rooms/${encodeURIComponent(d)}`, { archived: l })),
|
|
248
249
|
onSuccess: n
|
|
249
|
-
}), c =
|
|
250
|
-
mutationFn: ({ room:
|
|
250
|
+
}), c = g({
|
|
251
|
+
mutationFn: ({ room: d, starred: l }) => e.request(S(`/chat/rooms/${encodeURIComponent(d)}`, { starred: l })),
|
|
251
252
|
onSuccess: n
|
|
252
|
-
}),
|
|
253
|
-
mutationFn: (
|
|
253
|
+
}), u = g({
|
|
254
|
+
mutationFn: (d) => e.request(S(`/chat/rooms/${encodeURIComponent(d)}`, { welcome_seen: !0 })),
|
|
254
255
|
onSuccess: n
|
|
255
256
|
});
|
|
256
|
-
return { join: s, leave: o, setMuted: r, setNotifyMode: a, setArchived: i, setStarred: c, dismissWelcome:
|
|
257
|
+
return { join: s, leave: o, setMuted: r, setNotifyMode: a, setArchived: i, setStarred: c, dismissWelcome: u };
|
|
257
258
|
}
|
|
258
|
-
function
|
|
259
|
-
const t =
|
|
259
|
+
function Ye(e) {
|
|
260
|
+
const t = m(), { data: n, isLoading: s } = v({
|
|
260
261
|
queryKey: ["nvr-chat-members", e],
|
|
261
262
|
queryFn: async () => (await t.request(
|
|
262
|
-
|
|
263
|
+
p(`/chat/channels/${e}/members`)
|
|
263
264
|
)).data ?? [],
|
|
264
265
|
enabled: e != null,
|
|
265
266
|
staleTime: 1e4
|
|
266
267
|
});
|
|
267
268
|
return { members: n ?? [], loading: s };
|
|
268
269
|
}
|
|
269
|
-
const
|
|
270
|
-
function
|
|
271
|
-
const [n, s] =
|
|
272
|
-
return
|
|
270
|
+
const ye = 50;
|
|
271
|
+
function Ze(e, t) {
|
|
272
|
+
const [n, s] = P(e);
|
|
273
|
+
return T(() => {
|
|
273
274
|
const o = setTimeout(() => s(e), t);
|
|
274
275
|
return () => clearTimeout(o);
|
|
275
276
|
}, [e, t]), n;
|
|
276
277
|
}
|
|
277
|
-
function
|
|
278
|
+
function ge(e) {
|
|
278
279
|
const t = String(e.id ?? e.user ?? ""), n = e.first_name ?? null, s = e.last_name ?? null, o = e.email ?? null;
|
|
279
280
|
return {
|
|
280
281
|
id: t,
|
|
@@ -286,24 +287,24 @@ function he(e) {
|
|
|
286
287
|
email: o
|
|
287
288
|
};
|
|
288
289
|
}
|
|
289
|
-
function
|
|
290
|
-
var c,
|
|
291
|
-
const o =
|
|
290
|
+
function Je(e, t, n, s) {
|
|
291
|
+
var c, u, d;
|
|
292
|
+
const o = m(), r = te({
|
|
292
293
|
queryKey: ["nvr-chat-members-page", e, t, n],
|
|
293
294
|
initialPageParam: 0,
|
|
294
|
-
queryFn: async ({ pageParam:
|
|
295
|
-
const
|
|
296
|
-
return n.trim() &&
|
|
297
|
-
|
|
295
|
+
queryFn: async ({ pageParam: l }) => {
|
|
296
|
+
const h = new URLSearchParams({ limit: String(ye), offset: String(l) });
|
|
297
|
+
return n.trim() && h.set("q", n.trim()), await o.request(
|
|
298
|
+
p(`${t}?${h.toString()}`)
|
|
298
299
|
);
|
|
299
300
|
},
|
|
300
|
-
getNextPageParam: (
|
|
301
|
-
var
|
|
302
|
-
return
|
|
301
|
+
getNextPageParam: (l, h) => l.has_more ? h.reduce((y, f) => {
|
|
302
|
+
var R;
|
|
303
|
+
return y + (((R = f.data) == null ? void 0 : R.length) ?? 0);
|
|
303
304
|
}, 0) : void 0,
|
|
304
305
|
enabled: s && !!t,
|
|
305
306
|
staleTime: 1e4
|
|
306
|
-
}), a = (((c = r.data) == null ? void 0 : c.pages) ?? []).flatMap((
|
|
307
|
+
}), a = (((c = r.data) == null ? void 0 : c.pages) ?? []).flatMap((l) => (l.data ?? []).map(ge)), i = ((d = (u = r.data) == null ? void 0 : u.pages[0]) == null ? void 0 : d.total) ?? a.length;
|
|
307
308
|
return {
|
|
308
309
|
members: a,
|
|
309
310
|
total: i,
|
|
@@ -315,81 +316,81 @@ function We(e, t, n, s) {
|
|
|
315
316
|
}
|
|
316
317
|
};
|
|
317
318
|
}
|
|
318
|
-
function
|
|
319
|
-
const t =
|
|
319
|
+
function Xe(e) {
|
|
320
|
+
const t = m(), n = b(), s = () => {
|
|
320
321
|
n.invalidateQueries({ queryKey: ["nvr-chat-members", e] }), n.invalidateQueries({ queryKey: ["nvr-chat-members-page"] }), n.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), n.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
|
|
321
|
-
}, o =
|
|
322
|
-
mutationFn: (i) => t.request(
|
|
322
|
+
}, o = g({
|
|
323
|
+
mutationFn: (i) => t.request(S(`/chat/channels/${e}`, i)),
|
|
323
324
|
onSuccess: s
|
|
324
|
-
}), r =
|
|
325
|
-
mutationFn: (i) => t.request(
|
|
325
|
+
}), r = g({
|
|
326
|
+
mutationFn: (i) => t.request(M(`/chat/channels/${e}/members`, { user_id: i })),
|
|
326
327
|
onSuccess: s
|
|
327
|
-
}), a =
|
|
328
|
-
mutationFn: (i) => t.request(
|
|
328
|
+
}), a = g({
|
|
329
|
+
mutationFn: (i) => t.request(B(`/chat/channels/${e}/members/${i}`)),
|
|
329
330
|
onSuccess: s
|
|
330
331
|
});
|
|
331
332
|
return { update: o, addMember: r, removeMember: a };
|
|
332
333
|
}
|
|
333
|
-
function
|
|
334
|
-
const e =
|
|
334
|
+
function et() {
|
|
335
|
+
const e = m(), { data: t } = v({
|
|
335
336
|
queryKey: ["nvr-chat-roles"],
|
|
336
337
|
queryFn: async () => (await e.request(
|
|
337
|
-
|
|
338
|
+
p("/chat/roles")
|
|
338
339
|
)).data ?? [],
|
|
339
340
|
staleTime: 5 * 6e4
|
|
340
341
|
});
|
|
341
342
|
return t ?? [];
|
|
342
343
|
}
|
|
343
|
-
function
|
|
344
|
-
const n =
|
|
344
|
+
function tt(e, t) {
|
|
345
|
+
const n = m(), { data: s, isLoading: o } = v({
|
|
345
346
|
queryKey: ["nvr-chat-user-search", e],
|
|
346
347
|
queryFn: async () => (await n.request(
|
|
347
|
-
|
|
348
|
+
p("/users", { limit: 20, ...e.trim() ? { search: e.trim() } : {} })
|
|
348
349
|
)).data ?? [],
|
|
349
350
|
enabled: t,
|
|
350
351
|
staleTime: 3e4
|
|
351
352
|
});
|
|
352
353
|
return { users: s ?? [], loading: o };
|
|
353
354
|
}
|
|
354
|
-
function
|
|
355
|
-
const e =
|
|
356
|
-
return
|
|
357
|
-
mutationFn: (n) => e.request(
|
|
355
|
+
function nt() {
|
|
356
|
+
const e = m(), t = b();
|
|
357
|
+
return g({
|
|
358
|
+
mutationFn: (n) => e.request(M("/chat/channels", n)),
|
|
358
359
|
onSuccess: () => {
|
|
359
360
|
t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] }), t.invalidateQueries({ queryKey: ["nvr-chat-directory"] });
|
|
360
361
|
}
|
|
361
362
|
});
|
|
362
363
|
}
|
|
363
|
-
let
|
|
364
|
-
const
|
|
364
|
+
let H = 0;
|
|
365
|
+
const j = /* @__PURE__ */ new Map();
|
|
365
366
|
function z(e) {
|
|
366
367
|
var t;
|
|
367
368
|
return e.kind === "dm" || e.kind === "channel" && !!((t = e.channel) != null && t.is_direct);
|
|
368
369
|
}
|
|
369
|
-
const
|
|
370
|
-
function
|
|
371
|
-
|
|
370
|
+
const $ = /* @__PURE__ */ new Map();
|
|
371
|
+
function st(e) {
|
|
372
|
+
T(() => {
|
|
372
373
|
if (e)
|
|
373
|
-
return
|
|
374
|
-
const t = (
|
|
375
|
-
t <= 0 ?
|
|
374
|
+
return $.set(e, ($.get(e) ?? 0) + 1), () => {
|
|
375
|
+
const t = ($.get(e) ?? 1) - 1;
|
|
376
|
+
t <= 0 ? $.delete(e) : $.set(e, t);
|
|
376
377
|
};
|
|
377
378
|
}, [e]);
|
|
378
379
|
}
|
|
379
|
-
function
|
|
380
|
+
function pe() {
|
|
380
381
|
return typeof document > "u" || document.visibilityState === "visible";
|
|
381
382
|
}
|
|
382
|
-
function
|
|
383
|
-
return
|
|
383
|
+
function L(e) {
|
|
384
|
+
return $.has(e) && pe();
|
|
384
385
|
}
|
|
385
|
-
function
|
|
386
|
-
const e =
|
|
386
|
+
function ve() {
|
|
387
|
+
const e = E().notification_sound;
|
|
387
388
|
return typeof e == "string" ? e : "off";
|
|
388
389
|
}
|
|
389
|
-
function
|
|
390
|
-
const e =
|
|
390
|
+
function E() {
|
|
391
|
+
const e = m(), { data: t } = v({
|
|
391
392
|
queryKey: ["nvr-profile-prefs"],
|
|
392
|
-
queryFn: () => e.request(
|
|
393
|
+
queryFn: () => e.request(p("/users/me")).then((n) => {
|
|
393
394
|
var s;
|
|
394
395
|
return ((s = n.data) == null ? void 0 : s.preferences) ?? {};
|
|
395
396
|
}),
|
|
@@ -397,10 +398,10 @@ function L() {
|
|
|
397
398
|
});
|
|
398
399
|
return t ?? {};
|
|
399
400
|
}
|
|
400
|
-
function
|
|
401
|
-
const e =
|
|
402
|
-
return
|
|
403
|
-
mutationFn: (n) => e.request(
|
|
401
|
+
function qe() {
|
|
402
|
+
const e = m(), t = b();
|
|
403
|
+
return g({
|
|
404
|
+
mutationFn: (n) => e.request(S("/users/me/preferences", n)),
|
|
404
405
|
onMutate: (n) => {
|
|
405
406
|
const s = t.getQueryData(["nvr-profile-prefs"]);
|
|
406
407
|
return t.setQueryData(["nvr-profile-prefs"], { ...s ?? {}, ...n }), { prev: s };
|
|
@@ -408,15 +409,15 @@ function pe() {
|
|
|
408
409
|
onError: (n, s, o) => {
|
|
409
410
|
o != null && o.prev && t.setQueryData(["nvr-profile-prefs"], o.prev);
|
|
410
411
|
},
|
|
411
|
-
onSuccess: (n, s) =>
|
|
412
|
+
onSuccess: (n, s) => ce(Object.keys(s)),
|
|
412
413
|
onSettled: () => {
|
|
413
414
|
t.invalidateQueries({ queryKey: ["nvr-profile-prefs"] }), t.invalidateQueries({ queryKey: ["presence-online"] });
|
|
414
415
|
}
|
|
415
416
|
});
|
|
416
417
|
}
|
|
417
|
-
function
|
|
418
|
-
const e =
|
|
419
|
-
|
|
418
|
+
function rt() {
|
|
419
|
+
const e = E(), t = qe(), n = Object.keys(e).length > 0;
|
|
420
|
+
T(() => {
|
|
420
421
|
if (!n) return;
|
|
421
422
|
let s = "";
|
|
422
423
|
try {
|
|
@@ -434,82 +435,115 @@ function tt() {
|
|
|
434
435
|
}
|
|
435
436
|
}, [n, e.browser_timezone]);
|
|
436
437
|
}
|
|
437
|
-
function
|
|
438
|
-
const n = _(), s =
|
|
439
|
-
r.current = o
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
)
|
|
438
|
+
function ot(e, t) {
|
|
439
|
+
const n = _(), s = ve(), o = E(), r = A(o);
|
|
440
|
+
r.current = o;
|
|
441
|
+
const a = m(), i = b(), c = A({
|
|
442
|
+
client: a,
|
|
443
|
+
qc: i,
|
|
444
|
+
me: n.me,
|
|
445
|
+
markRead: (u) => {
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
c.current = {
|
|
449
|
+
client: a,
|
|
450
|
+
qc: i,
|
|
451
|
+
me: n.me,
|
|
452
|
+
markRead: (u) => {
|
|
453
|
+
a.request(M(`/chat/rooms/${encodeURIComponent(u)}/read`)).then(() => i.invalidateQueries({ queryKey: ["nvr-chat-rooms"] })).catch(() => {
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
}, ie(
|
|
457
|
+
t ? t.filter((u) => z(u) && !u.muted && !L(u.room)).reduce((u, d) => u + d.unread, 0) : 0
|
|
458
|
+
), T(() => {
|
|
459
|
+
const u = t ? t.filter((y) => z(y) && !L(y.room)).reduce((y, f) => y + f.unread, 0) : e, d = u > H, l = de(r.current), h = re(r.current) || l;
|
|
460
|
+
if (n.sound && d && !h && ae(s), n.sound && d && l && me({ kind: "chat", title: "New message" }), t) {
|
|
461
|
+
const y = j.size > 0;
|
|
462
|
+
for (const f of t) {
|
|
463
|
+
const R = j.get(f.room) ?? 0;
|
|
464
|
+
if (y && !h && !f.muted && z(f) && f.unread > R && !L(f.room)) {
|
|
465
|
+
const I = f.lastMessage;
|
|
466
|
+
if (I) {
|
|
467
|
+
const w = f.room;
|
|
468
|
+
ue(
|
|
469
|
+
{
|
|
470
|
+
room: w,
|
|
471
|
+
label: f.label,
|
|
472
|
+
kind: f.kind,
|
|
473
|
+
mentioned: (f.mentions ?? 0) > 0
|
|
474
|
+
},
|
|
475
|
+
I,
|
|
476
|
+
{
|
|
477
|
+
reply: (x) => {
|
|
478
|
+
var C, O, Q;
|
|
479
|
+
const q = c.current;
|
|
480
|
+
G(q.client, q.qc, ((C = q.me) == null ? void 0 : C.id) ?? null), V({
|
|
481
|
+
client_id: Y(),
|
|
482
|
+
room: w,
|
|
483
|
+
text: x,
|
|
484
|
+
mentions: [],
|
|
485
|
+
attachments: [],
|
|
486
|
+
parent_id: null,
|
|
487
|
+
quote_id: null,
|
|
488
|
+
urgent: !1,
|
|
489
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
490
|
+
sender: ((O = q.me) == null ? void 0 : O.id) ?? "",
|
|
491
|
+
sender_name: ((Q = q.me) == null ? void 0 : Q.name) ?? null
|
|
492
|
+
}), q.markRead(w);
|
|
493
|
+
},
|
|
494
|
+
markRead: () => c.current.markRead(w),
|
|
495
|
+
// Only when the host has somewhere to open it.
|
|
496
|
+
...Se() ? { open: () => X(w, f.label) } : {}
|
|
497
|
+
}
|
|
498
|
+
);
|
|
499
|
+
}
|
|
466
500
|
}
|
|
467
|
-
|
|
501
|
+
(f.unread === 0 || L(f.room)) && le(f.room), j.set(f.room, f.unread);
|
|
468
502
|
}
|
|
469
503
|
}
|
|
470
|
-
|
|
504
|
+
H = u;
|
|
471
505
|
}, [e, n.sound, t, s]);
|
|
472
506
|
}
|
|
473
|
-
function
|
|
474
|
-
const e =
|
|
475
|
-
return
|
|
476
|
-
mutationFn: (n) => e.request(
|
|
507
|
+
function at() {
|
|
508
|
+
const e = m(), t = b();
|
|
509
|
+
return g({
|
|
510
|
+
mutationFn: (n) => e.request(M(`/chat/rooms/${encodeURIComponent(n)}/read`)),
|
|
477
511
|
onSuccess: () => void t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] })
|
|
478
512
|
});
|
|
479
513
|
}
|
|
480
|
-
const
|
|
481
|
-
function
|
|
514
|
+
const be = ["nvr-chat-room-types"];
|
|
515
|
+
function J(e) {
|
|
482
516
|
return {
|
|
483
|
-
queryKey:
|
|
517
|
+
queryKey: be,
|
|
484
518
|
queryFn: async () => {
|
|
485
|
-
const t = await e.request(
|
|
519
|
+
const t = await e.request(p("/chat/room-types"));
|
|
486
520
|
return ((t == null ? void 0 : t.data) ?? []).filter((n) => n.is_active);
|
|
487
521
|
},
|
|
488
522
|
staleTime: 5 * 6e4
|
|
489
523
|
};
|
|
490
524
|
}
|
|
491
|
-
function
|
|
492
|
-
const t = _(), n =
|
|
525
|
+
function it(e) {
|
|
526
|
+
const t = _(), n = m(), s = (e == null ? void 0 : e.indexOf(":")) ?? -1, o = e && s > 0 ? e.slice(0, s) : null, r = e && s > 0 ? e.slice(s + 1) : null, a = !!e && !!o && !!r && e !== t.globalRoom && o !== "dm" && o !== "ch", { data: i } = v({ ...J(n), enabled: a }), c = a ? i == null ? void 0 : i.find((l) => l.is_active && l.prefix === o) : void 0, { data: u } = v({
|
|
493
527
|
queryKey: ["nvr-chat-entity-record", c == null ? void 0 : c.collection, c == null ? void 0 : c.match_field, r],
|
|
494
528
|
queryFn: async () => {
|
|
495
|
-
var
|
|
496
|
-
return c.match_field === "id" ? r : ((
|
|
497
|
-
|
|
529
|
+
var h, y;
|
|
530
|
+
return c.match_field === "id" ? r : ((y = (h = (await n.request(
|
|
531
|
+
p(`/items/${c.collection}`, {
|
|
498
532
|
limit: 1,
|
|
499
533
|
fields: "id",
|
|
500
534
|
filter: JSON.stringify({ [c.match_field]: { _eq: r } })
|
|
501
535
|
})
|
|
502
|
-
)).data) == null ? void 0 :
|
|
536
|
+
)).data) == null ? void 0 : h[0]) == null ? void 0 : y.id) ?? null;
|
|
503
537
|
},
|
|
504
538
|
enabled: !!c && !!r,
|
|
505
539
|
staleTime: 5 * 6e4
|
|
506
540
|
});
|
|
507
|
-
return !c ||
|
|
541
|
+
return !c || u == null ? null : (t.recordUrl ?? ((l, h) => `/collections/${l}/${h}`))(c.collection, u);
|
|
508
542
|
}
|
|
509
|
-
const
|
|
510
|
-
function
|
|
543
|
+
const _e = /@\[([^\]]+)\](?:\([^)]*\))?/g;
|
|
544
|
+
function ct(e, t) {
|
|
511
545
|
const n = new RegExp(t, "gi"), s = [];
|
|
512
|
-
for (const a of e.matchAll(
|
|
546
|
+
for (const a of e.matchAll(_e))
|
|
513
547
|
s.push({
|
|
514
548
|
start: a.index,
|
|
515
549
|
end: a.index + a[0].length,
|
|
@@ -528,32 +562,32 @@ function ot(e, t) {
|
|
|
528
562
|
a.start > r && o.push({ text: e.slice(r, a.start) }), o.push(a.token), r = a.end;
|
|
529
563
|
return r < e.length && o.push({ text: e.slice(r) }), o;
|
|
530
564
|
}
|
|
531
|
-
function
|
|
565
|
+
function ut(e, t) {
|
|
532
566
|
const s = e.slice(0, t).match(/@([^@\n\r]*)$/);
|
|
533
567
|
return s ? s[1] : null;
|
|
534
568
|
}
|
|
535
|
-
const
|
|
536
|
-
function
|
|
537
|
-
const t = _(), n =
|
|
538
|
-
|
|
539
|
-
const s =
|
|
569
|
+
const Ce = 3e3;
|
|
570
|
+
function lt(e) {
|
|
571
|
+
const t = _(), n = m();
|
|
572
|
+
b();
|
|
573
|
+
const s = A(!1), o = A(null), r = t.me, a = U(() => {
|
|
540
574
|
o.current && clearTimeout(o.current), o.current = null, s.current && r && t.setTypingRoom && (s.current = !1, t.setTypingRoom(r.id, null));
|
|
541
|
-
}, [r, t]), i =
|
|
542
|
-
!r || !e || !t.setTypingRoom || (s.current || (s.current = !0, t.setTypingRoom(r.id, e)), o.current && clearTimeout(o.current), o.current = setTimeout(a,
|
|
575
|
+
}, [r, t]), i = U(() => {
|
|
576
|
+
!r || !e || !t.setTypingRoom || (s.current || (s.current = !0, t.setTypingRoom(r.id, e)), o.current && clearTimeout(o.current), o.current = setTimeout(a, Ce));
|
|
543
577
|
}, [r, e, t, a]);
|
|
544
|
-
|
|
545
|
-
const c =
|
|
578
|
+
T(() => a, [a]);
|
|
579
|
+
const c = oe(6e3, {
|
|
546
580
|
safetyMs: 3e4,
|
|
547
581
|
enabled: !!t.realtime
|
|
548
|
-
}), { data:
|
|
582
|
+
}), { data: u } = v({
|
|
549
583
|
queryKey: ["nvr-chat-typing", e],
|
|
550
584
|
queryFn: async () => {
|
|
551
|
-
const
|
|
585
|
+
const l = new Date(Date.now() - 6e4).toISOString();
|
|
552
586
|
return (await n.request(
|
|
553
|
-
|
|
587
|
+
ee(t.collections.presence, {
|
|
554
588
|
limit: 10,
|
|
555
589
|
fields: ["user_id", "display_name", "typing_room", "last_seen"],
|
|
556
|
-
filter: { typing_room: { _eq: e }, last_seen: { _gte:
|
|
590
|
+
filter: { typing_room: { _eq: e }, last_seen: { _gte: l } }
|
|
557
591
|
})
|
|
558
592
|
)).data ?? [];
|
|
559
593
|
},
|
|
@@ -561,24 +595,24 @@ function it(e) {
|
|
|
561
595
|
refetchInterval: c,
|
|
562
596
|
staleTime: 2e3
|
|
563
597
|
});
|
|
564
|
-
|
|
565
|
-
const
|
|
566
|
-
var
|
|
567
|
-
const
|
|
568
|
-
var
|
|
569
|
-
return ((
|
|
570
|
-
}).map((
|
|
571
|
-
return
|
|
572
|
-
}, [
|
|
573
|
-
return { onType: i, clearTyping: a, typingText:
|
|
574
|
-
}
|
|
575
|
-
function
|
|
576
|
-
const t = _(), n =
|
|
598
|
+
he(t.collections.presence, [["nvr-chat-typing"]]);
|
|
599
|
+
const d = D(() => {
|
|
600
|
+
var y;
|
|
601
|
+
const l = (y = r == null ? void 0 : r.id) == null ? void 0 : y.toLowerCase(), h = (u ?? []).filter((f) => {
|
|
602
|
+
var R;
|
|
603
|
+
return ((R = f.user_id) == null ? void 0 : R.toLowerCase()) !== l;
|
|
604
|
+
}).map((f) => f.display_name ?? "Someone");
|
|
605
|
+
return h.length === 0 ? null : h.length === 1 ? `${h[0]} is typing…` : h.length === 2 ? `${h[0]} and ${h[1]} are typing…` : `${h.length} people are typing…`;
|
|
606
|
+
}, [u, r == null ? void 0 : r.id]);
|
|
607
|
+
return { onType: i, clearTyping: a, typingText: d };
|
|
608
|
+
}
|
|
609
|
+
function dt(e) {
|
|
610
|
+
const t = _(), n = m(), s = t.me, o = e && s ? W(e, s.id) : null, { data: r } = v({
|
|
577
611
|
queryKey: ["nvr-chat-peer-read", e],
|
|
578
612
|
queryFn: async () => {
|
|
579
613
|
var i;
|
|
580
614
|
return ((i = (await n.request(
|
|
581
|
-
|
|
615
|
+
p(
|
|
582
616
|
`/chat/rooms/${encodeURIComponent(e)}/peer-read`
|
|
583
617
|
)
|
|
584
618
|
)).data) == null ? void 0 : i.last_read_at) ?? null;
|
|
@@ -587,40 +621,40 @@ function ct(e) {
|
|
|
587
621
|
refetchInterval: 3e4,
|
|
588
622
|
staleTime: 5e3
|
|
589
623
|
});
|
|
590
|
-
return
|
|
624
|
+
return k([["nvr-chat-peer-read"]], e ? [e] : []), r ?? null;
|
|
591
625
|
}
|
|
592
|
-
function
|
|
593
|
-
const t =
|
|
594
|
-
return
|
|
595
|
-
mutationFn: ({ messageId: s, emoji: o }) => t.request(
|
|
626
|
+
function mt(e) {
|
|
627
|
+
const t = m(), n = b();
|
|
628
|
+
return g({
|
|
629
|
+
mutationFn: ({ messageId: s, emoji: o }) => t.request(M(`/chat/messages/${s}/reactions`, { emoji: o })),
|
|
596
630
|
onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat", e] })
|
|
597
631
|
});
|
|
598
632
|
}
|
|
599
|
-
function
|
|
600
|
-
const t =
|
|
601
|
-
return
|
|
602
|
-
mutationFn: ({ messageId: s, text: o }) => t.request(
|
|
633
|
+
function ft(e) {
|
|
634
|
+
const t = m(), n = b();
|
|
635
|
+
return g({
|
|
636
|
+
mutationFn: ({ messageId: s, text: o }) => t.request(S(`/chat/messages/${s}`, { message: o })),
|
|
603
637
|
onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat", e] })
|
|
604
638
|
});
|
|
605
639
|
}
|
|
606
|
-
function
|
|
607
|
-
const t =
|
|
608
|
-
return
|
|
609
|
-
mutationFn: (s) => t.request(
|
|
640
|
+
function ht(e) {
|
|
641
|
+
const t = m(), n = b();
|
|
642
|
+
return g({
|
|
643
|
+
mutationFn: (s) => t.request(B(`/chat/messages/${s}`)),
|
|
610
644
|
onSuccess: () => {
|
|
611
645
|
n.invalidateQueries({ queryKey: ["nvr-chat", e] }), n.invalidateQueries({ queryKey: ["nvr-chat-rooms"] });
|
|
612
646
|
}
|
|
613
647
|
});
|
|
614
648
|
}
|
|
615
|
-
function
|
|
616
|
-
const n =
|
|
649
|
+
function yt(e, t = {}) {
|
|
650
|
+
const n = m(), s = { q: e };
|
|
617
651
|
t.sender && (s.sender = t.sender), t.room && (s.room = t.room), t.from && (s.from = t.from), t.to && (s.to = t.to), t.has_attachment && (s.has_attachment = "1"), t.mentions_me && (s.mentions_me = "1");
|
|
618
|
-
const o = Object.keys(s).length > 1, { data: r, isLoading: a } =
|
|
652
|
+
const o = Object.keys(s).length > 1, { data: r, isLoading: a } = v({
|
|
619
653
|
queryKey: ["nvr-chat-search", s],
|
|
620
654
|
queryFn: async () => {
|
|
621
655
|
var c;
|
|
622
656
|
const i = await n.request(
|
|
623
|
-
|
|
657
|
+
p("/chat/search", s)
|
|
624
658
|
);
|
|
625
659
|
return { hits: i.data ?? [], meaning: ((c = i.meta) == null ? void 0 : c.meaning) ?? null };
|
|
626
660
|
},
|
|
@@ -629,43 +663,43 @@ function mt(e, t = {}) {
|
|
|
629
663
|
});
|
|
630
664
|
return { hits: (r == null ? void 0 : r.hits) ?? [], meaning: (r == null ? void 0 : r.meaning) ?? null, loading: a };
|
|
631
665
|
}
|
|
632
|
-
function
|
|
633
|
-
const e =
|
|
634
|
-
return
|
|
635
|
-
mutationFn: async (n) => (await e.request(
|
|
666
|
+
function gt() {
|
|
667
|
+
const e = m(), t = b();
|
|
668
|
+
return g({
|
|
669
|
+
mutationFn: async (n) => (await e.request(M("/chat/group-dm", n))).data,
|
|
636
670
|
onSuccess: () => void t.invalidateQueries({ queryKey: ["nvr-chat-rooms"] })
|
|
637
671
|
});
|
|
638
672
|
}
|
|
639
|
-
function
|
|
640
|
-
const e =
|
|
673
|
+
function Re() {
|
|
674
|
+
const e = m(), { data: t } = v({
|
|
641
675
|
queryKey: ["nvr-chat-config"],
|
|
642
|
-
queryFn: async () => (await e.request(
|
|
676
|
+
queryFn: async () => (await e.request(p("/chat/config"))).data ?? { bot_name: null, bot_user_id: null },
|
|
643
677
|
staleTime: 5 * 6e4
|
|
644
678
|
});
|
|
645
679
|
return t ?? { bot_name: null, bot_user_id: null };
|
|
646
680
|
}
|
|
647
|
-
function
|
|
648
|
-
return
|
|
681
|
+
function pt() {
|
|
682
|
+
return Re().bot_name;
|
|
649
683
|
}
|
|
650
|
-
function
|
|
651
|
-
const t =
|
|
684
|
+
function vt(e) {
|
|
685
|
+
const t = m(), { data: n } = v({
|
|
652
686
|
queryKey: ["nvr-chat-pins", e],
|
|
653
687
|
queryFn: async () => (await t.request(
|
|
654
|
-
|
|
688
|
+
p(`/chat/rooms/${encodeURIComponent(e)}/pins`)
|
|
655
689
|
)).data ?? [],
|
|
656
690
|
enabled: !!e,
|
|
657
691
|
staleTime: 15e3
|
|
658
692
|
});
|
|
659
|
-
return
|
|
693
|
+
return k([["nvr-chat-pins"]], e ? [e] : []), n ?? [];
|
|
660
694
|
}
|
|
661
|
-
function
|
|
662
|
-
const t =
|
|
663
|
-
return
|
|
664
|
-
mutationFn: (s) => t.request(
|
|
695
|
+
function qt(e) {
|
|
696
|
+
const t = m(), n = b();
|
|
697
|
+
return g({
|
|
698
|
+
mutationFn: (s) => t.request(M(`/chat/messages/${s}/pin`)),
|
|
665
699
|
onSuccess: () => void n.invalidateQueries({ queryKey: ["nvr-chat-pins", e] })
|
|
666
700
|
});
|
|
667
701
|
}
|
|
668
|
-
const
|
|
702
|
+
const N = [
|
|
669
703
|
"#7dd3fc",
|
|
670
704
|
"#86efac",
|
|
671
705
|
"#fcd34d",
|
|
@@ -675,130 +709,130 @@ const x = [
|
|
|
675
709
|
"#99f6e4",
|
|
676
710
|
"#00ceff"
|
|
677
711
|
];
|
|
678
|
-
function
|
|
679
|
-
return
|
|
712
|
+
function bt(e) {
|
|
713
|
+
return N[we(e)];
|
|
680
714
|
}
|
|
681
|
-
function
|
|
715
|
+
function we(e) {
|
|
682
716
|
let t = 0;
|
|
683
717
|
for (const n of e) t = t * 31 + n.charCodeAt(0) | 0;
|
|
684
|
-
return Math.abs(t) %
|
|
718
|
+
return Math.abs(t) % N.length;
|
|
685
719
|
}
|
|
686
|
-
function
|
|
687
|
-
return Number.isInteger(e) && e >= 0 && e <
|
|
720
|
+
function _t(e) {
|
|
721
|
+
return Number.isInteger(e) && e >= 0 && e < N.length ? N[e] : null;
|
|
688
722
|
}
|
|
689
|
-
function
|
|
723
|
+
function Ct(e) {
|
|
690
724
|
return [...e].sort((t, n) => {
|
|
691
725
|
const s = (t.display_name ?? "").trim(), o = (n.display_name ?? "").trim();
|
|
692
726
|
return !s != !o ? s ? -1 : 1 : s.localeCompare(o, void 0, { sensitivity: "base" }) || String(t.user_id).localeCompare(String(n.user_id));
|
|
693
727
|
});
|
|
694
728
|
}
|
|
695
|
-
function
|
|
729
|
+
function Rt(e) {
|
|
696
730
|
var n, s;
|
|
697
731
|
if (!e) return "?";
|
|
698
732
|
const t = e.trim().split(/\s+/);
|
|
699
733
|
return ((((n = t[0]) == null ? void 0 : n[0]) ?? "") + (((s = t[1]) == null ? void 0 : s[0]) ?? "")).toUpperCase() || "?";
|
|
700
734
|
}
|
|
701
|
-
let
|
|
702
|
-
function
|
|
703
|
-
return
|
|
704
|
-
|
|
735
|
+
let K = null;
|
|
736
|
+
function wt(e) {
|
|
737
|
+
return K = e, () => {
|
|
738
|
+
K === e && (K = null);
|
|
705
739
|
};
|
|
706
740
|
}
|
|
707
|
-
function
|
|
708
|
-
return
|
|
741
|
+
function St() {
|
|
742
|
+
return K !== null;
|
|
709
743
|
}
|
|
710
|
-
function
|
|
711
|
-
|
|
744
|
+
function Tt(e, t) {
|
|
745
|
+
K == null || K(e, t);
|
|
712
746
|
}
|
|
713
|
-
let
|
|
714
|
-
function
|
|
715
|
-
return
|
|
716
|
-
|
|
747
|
+
let F = null;
|
|
748
|
+
function Mt(e) {
|
|
749
|
+
return F = e, () => {
|
|
750
|
+
F === e && (F = null);
|
|
717
751
|
};
|
|
718
752
|
}
|
|
719
|
-
function
|
|
720
|
-
return
|
|
753
|
+
function Se() {
|
|
754
|
+
return F !== null;
|
|
721
755
|
}
|
|
722
|
-
function
|
|
723
|
-
|
|
756
|
+
function X(e, t) {
|
|
757
|
+
F == null || F(e, t);
|
|
724
758
|
}
|
|
725
|
-
function
|
|
726
|
-
const t =
|
|
759
|
+
function Kt(e = !0) {
|
|
760
|
+
const t = m(), { data: n } = v({ ...J(t), enabled: e });
|
|
727
761
|
return n;
|
|
728
762
|
}
|
|
729
|
-
async function
|
|
763
|
+
async function Ft(e, t, n) {
|
|
730
764
|
var r;
|
|
731
765
|
const s = await e.request(
|
|
732
|
-
|
|
766
|
+
p("/chat/record-room", { collection: t, item: n })
|
|
733
767
|
);
|
|
734
768
|
if (!((r = s.data) != null && r.room)) return !1;
|
|
735
769
|
const o = s.data.room.slice(s.data.room.indexOf(":") + 1);
|
|
736
|
-
return
|
|
770
|
+
return X(s.data.room, o), !0;
|
|
737
771
|
}
|
|
738
772
|
export {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
773
|
+
De as CHAT_DEFAULTS,
|
|
774
|
+
be as CHAT_ROOM_TYPES_KEY,
|
|
775
|
+
fe as ChatConfigContext,
|
|
776
|
+
Ne as GENERAL_CHANNEL_ID,
|
|
777
|
+
ye as MEMBER_PAGE_SIZE,
|
|
778
|
+
Ae as REACTION_EMOJI,
|
|
779
|
+
Se as canOpenChatRoom,
|
|
780
|
+
St as canOpenDm,
|
|
781
|
+
bt as chatAvatarColor,
|
|
782
|
+
_t as chatAvatarColorAt,
|
|
783
|
+
we as chatAvatarColorIndex,
|
|
784
|
+
Rt as chatInitials,
|
|
785
|
+
J as chatRoomTypesQuery,
|
|
786
|
+
Ot as discardOutbox,
|
|
787
|
+
Ft as discussRecord,
|
|
788
|
+
W as dmPeer,
|
|
789
|
+
Ee as dmRoom,
|
|
790
|
+
kt as editOutbox,
|
|
791
|
+
ut as getMentionQuery,
|
|
792
|
+
xt as holdOutbox,
|
|
793
|
+
Qt as nudgeChatOutbox,
|
|
794
|
+
X as openChatRoom,
|
|
795
|
+
Tt as openDmWith,
|
|
796
|
+
wt as registerDmOpener,
|
|
797
|
+
Mt as registerRoomOpener,
|
|
798
|
+
Lt as retryOutbox,
|
|
799
|
+
Ct as sortOnlineUsers,
|
|
800
|
+
ct as splitMessageTokens,
|
|
801
|
+
ge as toPagedMember,
|
|
802
|
+
Ge as useArchivedRooms,
|
|
803
|
+
Xe as useChannelAdmin,
|
|
804
|
+
Ve as useChannelDirectory,
|
|
805
|
+
Ye as useChannelMembers,
|
|
806
|
+
Re as useChatBotInfo,
|
|
807
|
+
pt as useChatBotName,
|
|
774
808
|
_ as useChatConfig,
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
809
|
+
je as useChatMessages,
|
|
810
|
+
et as useChatRoles,
|
|
811
|
+
He as useChatRooms,
|
|
812
|
+
yt as useChatSearch,
|
|
813
|
+
ze as useChatThread,
|
|
814
|
+
nt as useCreateChannel,
|
|
815
|
+
gt as useCreateGroupDm,
|
|
816
|
+
Ze as useDebouncedMemberQuery,
|
|
817
|
+
ht as useDeleteMessage,
|
|
818
|
+
ft as useEditMessage,
|
|
819
|
+
it as useEntityRoomLink,
|
|
820
|
+
at as useMarkRoomRead,
|
|
821
|
+
E as useMyPreferences,
|
|
822
|
+
ve as useNotificationSoundPreference,
|
|
823
|
+
st as useOpenRoomRegistration,
|
|
824
|
+
Pt as useOutbox,
|
|
825
|
+
Je as usePagedMembers,
|
|
826
|
+
dt as usePeerReadAt,
|
|
827
|
+
rt as useRecordBrowserTimezone,
|
|
828
|
+
Kt as useRecordRoomTypes,
|
|
829
|
+
We as useRoomMembership,
|
|
830
|
+
vt as useRoomPins,
|
|
831
|
+
Be as useSendChatMessage,
|
|
832
|
+
qe as useSetMyPreferences,
|
|
833
|
+
qt as useTogglePin,
|
|
834
|
+
mt as useToggleReaction,
|
|
835
|
+
lt as useTypingIndicator,
|
|
836
|
+
ot as useUnreadChirp,
|
|
837
|
+
tt as useUserSearch
|
|
804
838
|
};
|