@linktr.ee/messaging-react 1.40.2 → 2.0.0

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.
@@ -1,2994 +0,0 @@
1
- import { jsx as e, jsxs as d, Fragment as ce } from "react/jsx-runtime";
2
- import D from "classnames";
3
- import O, { createContext as ut, useContext as mt, useCallback as G, useState as A, useRef as K, useEffect as J, useMemo as Se, Suspense as ht } from "react";
4
- import { StreamChatService as Ft } from "@linktr.ee/messaging-core";
5
- import { Chat as Ot, ChannelList as Pt, DateSeparator as Ut, useChannelStateContext as oe, useChatContext as De, areMessageUIPropsEqual as zt, useMessageReminder as Bt, useComponentContext as ft, Attachment as $t, EditMessageModal as jt, MessageBlocked as Gt, MessageBouncePrompt as Vt, MessageDeleted as Ht, MessageIsThreadReplyInChannelButtonIndicator as Yt, MessageRepliesCountButton as Wt, ReminderNotification as qt, StreamedMessageText as Xt, messageHasAttachments as Zt, messageHasReactions as Jt, isDateSeparatorMessage as Kt, isMessageBlocked as Qt, isMessageBounced as es, MessageBounceModal as ts, MessageText as Qe, Poll as ss, MessageErrorIcon as ns, useMessageContext as gt, useMessageComposer as as, useStateStore as rs, MessageInput as is, useMessageInputContext as os, useMessageComposerHasSendableData as ls, SimpleAttachmentSelector as cs, QuotedMessagePreview as ds, AttachmentPreviewList as us, TextareaComposer as ms, MessageTimestamp as _e, useTypingContext as hs, Channel as fs, WithComponents as gs, Window as bs, MessageList as ps } from "stream-chat-react";
6
- import { StarIcon as Ie, GiftIcon as xs, XIcon as bt, SpinnerGapIcon as ye, SignOutIcon as vs, ProhibitInsetIcon as et, FlagIcon as ws, FileIcon as pt, ImageIcon as _s, SpeakerHighIcon as ys, VideoCameraIcon as Ns, FileMdIcon as Cs, FileTextIcon as Es, FileZipIcon as Ss, FilePptIcon as Is, FileCsvIcon as ks, FileXlsIcon as Ms, FileDocIcon as Ts, FilePdfIcon as Ds, CircleNotchIcon as xt, PlayIcon as tt, PauseIcon as Rs, LinkIcon as Ls, DownloadSimpleIcon as As, ThumbsUpIcon as Fs, ThumbsDownIcon as Os, ArrowUpIcon as Ps, SparkleIcon as ke, ProhibitIcon as Us, ArrowLeftIcon as st, CaretRightIcon as nt, DotsThreeIcon as at } from "@phosphor-icons/react";
7
- import { LinkPreviewsManager as rt } from "stream-chat";
8
- const vt = ut({
9
- service: null,
10
- client: null,
11
- isConnected: !1,
12
- isLoading: !1,
13
- error: null,
14
- capabilities: {},
15
- refreshConnection: async () => {
16
- },
17
- debug: !1
18
- }), Re = () => mt(vt), da = ({
19
- children: t,
20
- user: s,
21
- serviceConfig: n,
22
- apiKey: r,
23
- capabilities: o = {},
24
- debug: l = !1
25
- }) => {
26
- const i = G(
27
- (k, ...T) => {
28
- l && console.log(`🔥 [MessagingProvider] ${k}`, ...T);
29
- },
30
- [l]
31
- );
32
- i("🔄 RENDER START", {
33
- userId: s == null ? void 0 : s.id,
34
- apiKey: (r == null ? void 0 : r.substring(0, 8)) + "...",
35
- serviceConfig: !!n,
36
- capabilities: Object.keys(o)
37
- });
38
- const [c, m] = A(null), [u, h] = A(null), [f, v] = A(!1), [a, N] = A(!1), [b, C] = A(null), x = K(!1), I = K({
39
- userId: s == null ? void 0 : s.id,
40
- apiKey: r,
41
- serviceConfig: n,
42
- capabilities: o
43
- }), w = K(0);
44
- w.current++, i("📊 RENDER INFO", {
45
- renderCount: w.current,
46
- currentProps: { userId: s == null ? void 0 : s.id, apiKey: (r == null ? void 0 : r.substring(0, 8)) + "..." },
47
- propChanges: {
48
- userChanged: I.current.userId !== (s == null ? void 0 : s.id),
49
- apiKeyChanged: I.current.apiKey !== r,
50
- serviceConfigChanged: I.current.serviceConfig !== n,
51
- capabilitiesChanged: I.current.capabilities !== o
52
- }
53
- }), I.current = {
54
- userId: s == null ? void 0 : s.id,
55
- apiKey: r,
56
- serviceConfig: n,
57
- capabilities: o
58
- }, J(() => {
59
- const k = w.current;
60
- if (i("🔧 SERVICE INIT EFFECT TRIGGERED", {
61
- renderCount: k,
62
- apiKey: !!r,
63
- serviceConfig: !!n,
64
- dependencies: {
65
- apiKey: (r == null ? void 0 : r.substring(0, 8)) + "...",
66
- serviceConfigRef: n,
67
- serviceConfigStable: I.current.serviceConfig === n,
68
- apiKeyStable: I.current.apiKey === r
69
- }
70
- }), !r || !n) {
71
- i("⚠️ SERVICE INIT SKIPPED", {
72
- renderCount: k,
73
- reason: "Missing apiKey or serviceConfig"
74
- });
75
- return;
76
- }
77
- i("🚀 CREATING NEW SERVICE", {
78
- renderCount: k,
79
- apiKey: (r == null ? void 0 : r.substring(0, 8)) + "...",
80
- serviceConfigChanged: I.current.serviceConfig !== n
81
- });
82
- const T = new Ft({
83
- ...n,
84
- apiKey: r,
85
- debug: l
86
- });
87
- return m(T), i("✅ SERVICE SET", {
88
- renderCount: k,
89
- serviceInstance: !!T
90
- }), () => {
91
- i("🧹 SERVICE CLEANUP", {
92
- renderCount: k,
93
- reason: "Effect cleanup"
94
- }), T.disconnectUser().catch(console.error);
95
- };
96
- }, [r, n, l, i]);
97
- const E = K(null);
98
- J(() => {
99
- var T, M;
100
- if (i("🔗 USER CONNECTION EFFECT TRIGGERED", {
101
- hasService: !!c,
102
- hasUser: !!s,
103
- userId: s == null ? void 0 : s.id,
104
- isConnecting: x.current,
105
- isConnected: f,
106
- dependencies: { service: !!c, userId: s == null ? void 0 : s.id }
107
- }), !c || !s) {
108
- i("⚠️ USER CONNECTION SKIPPED", "Missing service or user");
109
- return;
110
- }
111
- if (x.current) {
112
- i("⚠️ USER CONNECTION SKIPPED", "Already connecting");
113
- return;
114
- }
115
- if (((T = E.current) == null ? void 0 : T.serviceId) === c && ((M = E.current) == null ? void 0 : M.userId) === s.id) {
116
- i(
117
- "⚠️ USER CONNECTION SKIPPED",
118
- "Already connected this user with this service"
119
- );
120
- return;
121
- }
122
- (async () => {
123
- i("🚀 STARTING USER CONNECTION", { userId: s.id }), x.current = !0, N(!0), C(null);
124
- try {
125
- i("📞 CALLING SERVICE.CONNECTUSER", { userId: s.id });
126
- const y = await c.connectUser(s);
127
- h(y), v(!0), E.current = { serviceId: c, userId: s.id }, i("✅ USER CONNECTION SUCCESS", {
128
- userId: s.id,
129
- clientId: y.userID
130
- });
131
- } catch (y) {
132
- const _ = y instanceof Error ? y.message : "Connection failed";
133
- C(_), i("❌ USER CONNECTION ERROR", {
134
- userId: s.id,
135
- error: _
136
- });
137
- } finally {
138
- N(!1), x.current = !1, i("🔄 USER CONNECTION FINISHED", {
139
- userId: s.id,
140
- isConnected: f
141
- });
142
- }
143
- })();
144
- }, [c, s, i, f]), J(() => (i("🔌 CLEANUP EFFECT REGISTERED", {
145
- hasService: !!c,
146
- isConnected: f
147
- }), () => {
148
- c && f ? (i(
149
- "🧹 CLEANUP EFFECT TRIGGERED",
150
- "Cleaning up connection on unmount"
151
- ), E.current = null, c.disconnectUser().catch(console.error)) : i("🔇 CLEANUP EFFECT SKIPPED", {
152
- hasService: !!c,
153
- isConnected: f
154
- });
155
- }), [c, f, i]);
156
- const P = G(async () => {
157
- if (i("🔄 REFRESH CONNECTION CALLED", {
158
- hasService: !!c,
159
- hasUser: !!s
160
- }), !c || !s) {
161
- i("⚠️ REFRESH CONNECTION SKIPPED", "Missing service or user");
162
- return;
163
- }
164
- i("🚀 STARTING CONNECTION REFRESH", { userId: s.id }), N(!0);
165
- try {
166
- i("🔌 DISCONNECTING FOR REFRESH"), await c.disconnectUser(), i("📞 RECONNECTING FOR REFRESH");
167
- const k = await c.connectUser(s);
168
- h(k), v(!0), C(null), i("✅ CONNECTION REFRESH SUCCESS", { userId: s.id });
169
- } catch (k) {
170
- const T = k instanceof Error ? k.message : "Refresh failed";
171
- C(T), i("❌ CONNECTION REFRESH ERROR", {
172
- userId: s.id,
173
- error: T
174
- });
175
- } finally {
176
- N(!1), i("🔄 CONNECTION REFRESH FINISHED", { userId: s.id });
177
- }
178
- }, [c, s, i]), U = O.useMemo(() => (i("💫 CONTEXT VALUE MEMOIZATION", {
179
- hasService: !!c,
180
- hasClient: !!u,
181
- isConnected: f,
182
- isLoading: a,
183
- hasError: !!b,
184
- capabilitiesKeys: Object.keys(o)
185
- }), {
186
- service: c,
187
- client: u,
188
- isConnected: f,
189
- isLoading: a,
190
- error: b,
191
- capabilities: o,
192
- refreshConnection: P,
193
- debug: l
194
- }), [
195
- c,
196
- u,
197
- f,
198
- a,
199
- b,
200
- o,
201
- P,
202
- l,
203
- i
204
- ]);
205
- return i("🔄 RENDER END", {
206
- renderCount: w.current,
207
- willRenderChat: !!(u && f),
208
- contextValueReady: !!U
209
- }), /* @__PURE__ */ e(vt.Provider, { value: U, children: u && f ? /* @__PURE__ */ e(
210
- Ot,
211
- {
212
- client: u,
213
- customClasses: {
214
- channelList: "str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"
215
- },
216
- children: t
217
- }
218
- ) : t });
219
- }, zs = () => Re();
220
- function Bs(t) {
221
- const s = t.state.pending_messages;
222
- if (s != null && s.length)
223
- for (const n of s)
224
- t.state.addMessageSorted(n.message);
225
- }
226
- const wt = O.createContext({
227
- selectedChannel: void 0,
228
- onChannelSelect: () => {
229
- },
230
- debug: !1,
231
- renderMessagePreview: void 0
232
- }), $s = wt.Provider, js = () => O.useContext(wt), _t = (t) => {
233
- var r, o;
234
- const [s, n] = A(
235
- !!((o = (r = t == null ? void 0 : t.state) == null ? void 0 : r.membership) != null && o.pinned_at)
236
- );
237
- return J(() => {
238
- var i;
239
- if (!t) {
240
- n(!1);
241
- return;
242
- }
243
- n(!!((i = t.state.membership) != null && i.pinned_at));
244
- const l = (c) => {
245
- var m;
246
- n(
247
- c != null && c.member ? !!c.member.pinned_at : !!((m = t.state.membership) != null && m.pinned_at)
248
- );
249
- };
250
- return t.on("member.updated", l), () => {
251
- t.off("member.updated", l);
252
- };
253
- }, [t]), s;
254
- }, Gs = (t, s) => {
255
- const n = new Date(
256
- Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate())
257
- ), o = new Date(
258
- Date.UTC(s.getUTCFullYear(), s.getUTCMonth(), s.getUTCDate())
259
- ).getTime() - n.getTime();
260
- return Math.floor(o / (1e3 * 60 * 60 * 24));
261
- }, Vs = (t) => {
262
- const s = /* @__PURE__ */ new Date();
263
- if (Math.floor((s.getTime() - t.getTime()) / 1e3) < 60)
264
- return "Just now";
265
- const r = Gs(t, s);
266
- return r === 0 ? t.toLocaleTimeString([], {
267
- hour: "numeric",
268
- minute: "2-digit",
269
- hour12: !0
270
- }) : r === 1 ? "Yesterday" : r < 7 ? `${r}d` : r < 28 ? `${Math.floor(r / 7)}w` : t.toLocaleDateString("en-US", {
271
- month: "numeric",
272
- day: "numeric",
273
- year: "2-digit"
274
- });
275
- }, it = [
276
- "🍎",
277
- // Apple
278
- "🍌",
279
- // Banana
280
- "🍇",
281
- // Grape
282
- "🍊",
283
- // Orange
284
- "🍓",
285
- // Strawberry
286
- "🥥",
287
- // Coconut
288
- "🍒",
289
- // Cherry
290
- "🥭",
291
- // Mango
292
- "🍉",
293
- // Watermelon
294
- "🍋",
295
- // Lemon
296
- "🥝",
297
- // Kiwi
298
- "🫒",
299
- // Olive
300
- "🍈"
301
- // Melon
302
- ];
303
- function Hs(t) {
304
- let s = 0;
305
- for (let n = 0; n < t.length; n++) {
306
- const r = t.charCodeAt(n);
307
- s = (s << 5) - s + r, s = s & s;
308
- }
309
- return Math.abs(s);
310
- }
311
- function Ys(t) {
312
- const n = Hs(t) % it.length;
313
- return it[n];
314
- }
315
- const ne = ({
316
- id: t,
317
- image: s,
318
- size: n = 40,
319
- className: r,
320
- starred: o = !1,
321
- shape: l = "squircle",
322
- dmAgentEnabled: i = !1
323
- }) => {
324
- const c = Ys(t), u = n < 32 ? "text-xs" : n < 56 ? "text-sm" : n < 120 ? "text-lg" : "text-4xl", h = n >= 40 ? 2 : 1, f = l === "circle" ? { borderRadius: "50%" } : {
325
- borderRadius: "33%",
326
- cornerShape: "superellipse(1.3)"
327
- }, v = /* @__PURE__ */ e("div", { className: "h-full w-full overflow-hidden", style: f, children: s ? /* @__PURE__ */ e(
328
- "img",
329
- {
330
- src: s,
331
- alt: "",
332
- className: "h-full w-full object-cover"
333
- }
334
- ) : /* @__PURE__ */ e(
335
- "div",
336
- {
337
- "aria-hidden": "true",
338
- className: D(
339
- "avatar-fallback flex h-full w-full items-center justify-center bg-[#E6E5E3] font-semibold select-none transition-colors",
340
- u
341
- ),
342
- children: c
343
- }
344
- ) });
345
- return /* @__PURE__ */ d(
346
- "div",
347
- {
348
- className: D(
349
- "relative flex-shrink-0 !bg-transparent",
350
- r
351
- ),
352
- style: {
353
- "--str-chat__avatar-size": `${n}px`,
354
- width: `${n}px`,
355
- height: `${n}px`
356
- },
357
- children: [
358
- o && /* @__PURE__ */ e(
359
- "div",
360
- {
361
- "aria-hidden": "true",
362
- className: "absolute -left-1.5 -top-1.5 z-10 flex size-5 items-center justify-center rounded-full bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",
363
- children: /* @__PURE__ */ e(Ie, { className: "size-3 text-yellow-600", weight: "duotone" })
364
- }
365
- ),
366
- /* @__PURE__ */ e(
367
- "div",
368
- {
369
- "data-testid": "avatar-ring",
370
- className: D(
371
- "h-full w-full",
372
- "bg-transparent"
373
- ),
374
- style: {
375
- ...f,
376
- ...i && {
377
- borderWidth: `${h}px`,
378
- borderStyle: "solid",
379
- borderColor: "var(--AI-Gradient, #7F22FE)",
380
- boxShadow: "inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"
381
- }
382
- },
383
- children: v
384
- }
385
- )
386
- ]
387
- }
388
- );
389
- }, Ws = ({ size: t = 15 }) => /* @__PURE__ */ e(
390
- "svg",
391
- {
392
- width: t,
393
- height: t,
394
- viewBox: "0 0 15 15",
395
- fill: "none",
396
- "aria-hidden": "true",
397
- children: /* @__PURE__ */ e(
398
- "path",
399
- {
400
- d: "M12.003 9a.985.985 0 0 1-.652.934l-3.223 1.191-1.188 3.226a.995.995 0 0 1-1.867 0l-1.195-3.226L.65 9.937a.995.995 0 0 1 0-1.867l3.227-1.195 1.187-3.226a.995.995 0 0 1 1.868 0l1.195 3.226 3.226 1.187a.99.99 0 0 1 .649.938m3-5.83a.52.52 0 0 1-.344.492l-1.702.63-.627 1.703a.525.525 0 0 1-.986 0l-.63-1.704-1.704-.627a.525.525 0 0 1 0-.986l1.703-.63.627-1.704a.526.526 0 0 1 .986 0l.631 1.703 1.704.627a.52.52 0 0 1 .342.495",
401
- fill: "currentColor",
402
- fillOpacity: 0.55
403
- }
404
- )
405
- }
406
- ), qs = (t) => {
407
- var s;
408
- return ((s = t.metadata) == null ? void 0 : s.custom_type) === "MESSAGE_TIP";
409
- }, Xs = (t) => {
410
- var s;
411
- return ((s = t.metadata) == null ? void 0 : s.custom_type) === "MESSAGE_PAID";
412
- }, ge = (t) => {
413
- var s;
414
- return ((s = t.metadata) == null ? void 0 : s.custom_type) === "MESSAGE_CHATBOT";
415
- }, Zs = (t) => {
416
- var s;
417
- return ((s = t.metadata) == null ? void 0 : s.custom_type) === "MESSAGE_ATTACHMENT";
418
- }, yt = (t) => qs(t) || Xs(t), Js = (t) => {
419
- var s;
420
- return yt(t) && !((s = t.text) != null && s.trim());
421
- }, Ne = ({
422
- message: t,
423
- standalone: s = !1,
424
- isMyMessage: n = !1,
425
- hasAttachment: r = !1
426
- }) => {
427
- var f;
428
- const o = yt(t), l = ge(t);
429
- if (!o && !l)
430
- return null;
431
- if (o) {
432
- const v = (f = t.metadata) == null ? void 0 : f.amount_text;
433
- if (!v) return null;
434
- const a = s ? "message-tip-standalone" : "message-tag message-tag--tip", N = s ? `${v} tip` : `Delivered with ${v} tip`;
435
- return /* @__PURE__ */ d("div", { className: a, children: [
436
- /* @__PURE__ */ e(xs, { size: s ? 14 : 12 }),
437
- /* @__PURE__ */ e("span", { children: N })
438
- ] });
439
- }
440
- const i = n && r, c = i ? "Sent with AI" : "Sent with DM Agent", m = [
441
- "message-chatbot-indicator",
442
- n ? "message-chatbot-indicator--sender" : "message-chatbot-indicator--receiver",
443
- i ? "message-chatbot-indicator--attachment" : "message-chatbot-indicator--text"
444
- ].join(" "), u = /* @__PURE__ */ e("span", { className: "message-chatbot-indicator__label", children: c }), h = /* @__PURE__ */ e("span", { className: "message-chatbot-indicator__icon", children: /* @__PURE__ */ e(Ws, { size: i ? 12 : 15 }) });
445
- return /* @__PURE__ */ e("div", { className: m, "data-testid": "message-chatbot-indicator", children: n && !i ? /* @__PURE__ */ d(ce, { children: [
446
- u,
447
- h
448
- ] }) : /* @__PURE__ */ d(ce, { children: [
449
- h,
450
- u
451
- ] }) });
452
- }, Nt = O.memo(
453
- ({ channel: t, unread: s }) => {
454
- var P, U, k, T;
455
- const { selectedChannel: n, onChannelSelect: r, debug: o, renderMessagePreview: l } = js(), i = (n == null ? void 0 : n.id) === (t == null ? void 0 : t.id), c = () => {
456
- t && r(t);
457
- }, m = (M) => {
458
- const y = M.key === "Enter" || M.key === " ", _ = M.repeat;
459
- !y || _ || (M.preventDefault(), c());
460
- }, h = Object.values(((P = t == null ? void 0 : t.state) == null ? void 0 : P.members) || {}).find(
461
- (M) => {
462
- var y, _;
463
- return ((y = M.user) == null ? void 0 : y.id) && M.user.id !== ((_ = t == null ? void 0 : t._client) == null ? void 0 : _.userID);
464
- }
465
- ), f = ((U = h == null ? void 0 : h.user) == null ? void 0 : U.name) || "Conversation", v = (k = h == null ? void 0 : h.user) == null ? void 0 : k.image, a = (() => {
466
- var y;
467
- const M = (y = t == null ? void 0 : t.state) == null ? void 0 : y.messages;
468
- if (M != null && M.length) {
469
- for (let _ = M.length - 1; _ >= 0; _--)
470
- if (M[_].type !== "system") return M[_];
471
- }
472
- })(), b = (() => {
473
- var _, F;
474
- if (a != null && a.text) return a.text;
475
- if (((_ = a == null ? void 0 : a.metadata) == null ? void 0 : _.custom_type) === "MESSAGE_TIP") return "💵 Sent a tip";
476
- const y = (F = a == null ? void 0 : a.attachments) == null ? void 0 : F[0];
477
- return y ? y.og_scrape_url ? y.og_scrape_url : y.type === "image" ? "📷 Sent an image" : y.type === "video" ? "🎥 Sent a video" : y.type === "audio" ? "🎵 Sent audio" : y.type === "file" ? "📎 Sent a file" : "📎 Sent an attachment" : "No messages yet";
478
- })(), C = a != null && a.created_at ? Vs(new Date(a.created_at)) : "", x = a ? ge(a) : !1, I = l ? l(a, b) : `${x ? "✨ " : ""}${b}`, w = _t(t), E = s ?? 0;
479
- return o && console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER", {
480
- channelId: t == null ? void 0 : t.id,
481
- isSelected: i,
482
- participantName: f,
483
- unreadCount: E,
484
- hasTimestamp: !!C
485
- }), /* @__PURE__ */ e(
486
- "div",
487
- {
488
- role: "button",
489
- tabIndex: 0,
490
- onClick: c,
491
- onKeyDown: m,
492
- className: D(
493
- "group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring",
494
- {
495
- "bg-primary-alt/10 border-l-4 border-l-primary": i,
496
- "hover:bg-sand": !i
497
- }
498
- ),
499
- children: /* @__PURE__ */ d("div", { className: "flex items-start gap-3", children: [
500
- /* @__PURE__ */ e(
501
- ne,
502
- {
503
- id: ((T = h == null ? void 0 : h.user) == null ? void 0 : T.id) || t.id || "unknown",
504
- name: f,
505
- image: v,
506
- size: 44,
507
- starred: w,
508
- className: "[&_.avatar-fallback]:group-hover:bg-[#eeeeee]"
509
- }
510
- ),
511
- /* @__PURE__ */ d("div", { className: "flex-1 min-w-0 flex flex-col gap-1", children: [
512
- /* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-2", children: [
513
- /* @__PURE__ */ d(
514
- "h3",
515
- {
516
- className: D(
517
- "text-sm font-medium truncate",
518
- i ? "text-primary" : "text-charcoal"
519
- ),
520
- children: [
521
- w && /* @__PURE__ */ e("span", { className: "sr-only", children: "Starred conversation. " }),
522
- f
523
- ]
524
- }
525
- ),
526
- C && /* @__PURE__ */ e("span", { className: "text-xs text-stone flex-shrink-0", children: C })
527
- ] }),
528
- /* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-2 min-w-0", children: [
529
- /* @__PURE__ */ e("p", { className: "text-xs text-stone flex-1 line-clamp-1", children: I }),
530
- E > 0 && /* @__PURE__ */ e("span", { className: "bg-[#7f22fe] text-white text-xs px-2 py-0.5 rounded-full min-w-[20px] text-center flex-shrink-0", children: E > 99 ? "99+" : E })
531
- ] })
532
- ] })
533
- ] })
534
- }
535
- );
536
- }
537
- );
538
- Nt.displayName = "CustomChannelPreview";
539
- const Ks = { last_message_at: -1 }, Ct = O.memo(
540
- ({
541
- onChannelSelect: t,
542
- selectedChannel: s,
543
- filters: n,
544
- allowNewMessagesFromUnfilteredChannels: r = !1,
545
- onMessageNew: o,
546
- onAddedToChannel: l,
547
- channelRenderFilterFn: i,
548
- sort: c = Ks,
549
- className: m,
550
- customEmptyStateIndicator: u,
551
- renderMessagePreview: h
552
- }) => {
553
- const f = O.useRef(0);
554
- f.current++;
555
- const { debug: v = !1 } = Re(), a = O.useCallback(
556
- (b) => {
557
- for (const C of b)
558
- Bs(C);
559
- return i ? i(b) : b;
560
- },
561
- [i]
562
- );
563
- v && console.log("📺 [ChannelList] 🔄 RENDER START", {
564
- renderCount: f.current,
565
- selectedChannelId: s == null ? void 0 : s.id,
566
- filters: n
567
- });
568
- const N = O.useMemo(
569
- () => ({
570
- selectedChannel: s,
571
- onChannelSelect: t,
572
- debug: v,
573
- renderMessagePreview: h
574
- }),
575
- [s, t, v, h]
576
- );
577
- return /* @__PURE__ */ e(
578
- "div",
579
- {
580
- className: D(
581
- "messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",
582
- m
583
- ),
584
- children: /* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden min-w-0", children: /* @__PURE__ */ e($s, { value: N, children: /* @__PURE__ */ e(
585
- Pt,
586
- {
587
- filters: n,
588
- sort: c,
589
- options: { limit: 30 },
590
- allowNewMessagesFromUnfilteredChannels: r,
591
- onMessageNew: o,
592
- onAddedToChannel: l,
593
- channelRenderFilterFn: a,
594
- Preview: Nt,
595
- EmptyStateIndicator: u
596
- },
597
- `${JSON.stringify(n)}:${JSON.stringify(c)}`
598
- ) }) })
599
- }
600
- );
601
- }
602
- );
603
- Ct.displayName = "ChannelList";
604
- const he = ({
605
- variant: t = "default",
606
- className: s,
607
- children: n,
608
- ...r
609
- }) => /* @__PURE__ */ e(
610
- "button",
611
- {
612
- type: "button",
613
- className: D(
614
- "flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",
615
- t === "danger" ? "text-danger hover:bg-danger/50" : "text-charcoal hover:bg-sand",
616
- s
617
- ),
618
- ...r,
619
- children: n
620
- }
621
- );
622
- function Qs({ label: t, className: s, children: n, ...r }) {
623
- return /* @__PURE__ */ d(
624
- "button",
625
- {
626
- type: "button",
627
- className: D(
628
- "inline-flex items-center justify-center rounded-full transition-colors focus-ring p-2",
629
- {
630
- "cursor-not-allowed opacity-50": r.disabled,
631
- "hover:bg-sand": !r.disabled
632
- },
633
- s
634
- ),
635
- ...r,
636
- children: [
637
- /* @__PURE__ */ e("span", { className: "sr-only", children: t }),
638
- n
639
- ]
640
- }
641
- );
642
- }
643
- function en({ onClick: t }) {
644
- return /* @__PURE__ */ e(Qs, { label: "Close", onClick: t, className: "p-1", children: /* @__PURE__ */ e(bt, { className: "h-5 w-5 text-stone", weight: "bold" }) });
645
- }
646
- const tn = ({
647
- dialogRef: t,
648
- onClose: s,
649
- participant: n,
650
- channel: r,
651
- followerStatusLabel: o,
652
- onLeaveConversation: l,
653
- onBlockParticipant: i,
654
- showDeleteConversation: c = !0,
655
- onDeleteConversationClick: m,
656
- onBlockParticipantClick: u,
657
- onReportParticipantClick: h,
658
- customProfileContent: f,
659
- customChannelActions: v
660
- }) => {
661
- var S, $, V, ee, te, W, g;
662
- const { service: a, debug: N } = Re(), [b, C] = A(!1), [x, I] = A(!1), [w, E] = A(!1), P = G(async () => {
663
- var p;
664
- if (!(!a || !((p = n == null ? void 0 : n.user) != null && p.id)))
665
- try {
666
- const j = (await a.getBlockedUsers()).some(
667
- (Y) => {
668
- var ae;
669
- return Y.blocked_user_id === ((ae = n == null ? void 0 : n.user) == null ? void 0 : ae.id);
670
- }
671
- );
672
- C(j);
673
- } catch (L) {
674
- console.error(
675
- "[ChannelInfoDialog] Failed to check blocked status:",
676
- L
677
- );
678
- }
679
- }, [a, (S = n == null ? void 0 : n.user) == null ? void 0 : S.id]);
680
- J(() => {
681
- P();
682
- }, [P]);
683
- const U = async () => {
684
- var p;
685
- if (!x) {
686
- m == null || m(), N && console.log("[ChannelInfoDialog] Leave conversation", r.cid), I(!0);
687
- try {
688
- const L = ((p = r._client) == null ? void 0 : p.userID) ?? null;
689
- await r.hide(L, !1), l && await l(r), s();
690
- } catch (L) {
691
- console.error("[ChannelInfoDialog] Failed to leave conversation", L);
692
- } finally {
693
- I(!1);
694
- }
695
- }
696
- }, k = async () => {
697
- var p, L, j;
698
- if (!(w || !a)) {
699
- u == null || u(), N && console.log("[ChannelInfoDialog] Block member", (p = n == null ? void 0 : n.user) == null ? void 0 : p.id), E(!0);
700
- try {
701
- await a.blockUser((L = n == null ? void 0 : n.user) == null ? void 0 : L.id), i && await i((j = n == null ? void 0 : n.user) == null ? void 0 : j.id), s();
702
- } catch (Y) {
703
- console.error("[ChannelInfoDialog] Failed to block member", Y);
704
- } finally {
705
- E(!1);
706
- }
707
- }
708
- }, T = async () => {
709
- var p, L, j;
710
- if (!(w || !a)) {
711
- u == null || u(), N && console.log("[ChannelInfoDialog] Unblock member", (p = n == null ? void 0 : n.user) == null ? void 0 : p.id), E(!0);
712
- try {
713
- await a.unBlockUser((L = n == null ? void 0 : n.user) == null ? void 0 : L.id), i && await i((j = n == null ? void 0 : n.user) == null ? void 0 : j.id), s();
714
- } catch (Y) {
715
- console.error("[ChannelInfoDialog] Failed to unblock member", Y);
716
- } finally {
717
- E(!1);
718
- }
719
- }
720
- }, M = () => {
721
- h == null || h(), s(), window.open(
722
- "https://linktr.ee/s/about/trust-center/report",
723
- "_blank",
724
- "noopener,noreferrer"
725
- );
726
- };
727
- if (!n) return null;
728
- const y = (($ = n.user) == null ? void 0 : $.name) || ((V = n.user) == null ? void 0 : V.id) || "Unknown member", _ = (ee = n.user) == null ? void 0 : ee.image, F = (te = n.user) == null ? void 0 : te.email, H = (W = n.user) == null ? void 0 : W.username, R = F || (H ? `linktr.ee/${H}` : void 0), z = ((g = n.user) == null ? void 0 : g.id) || "unknown";
729
- return (
730
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
731
- /* @__PURE__ */ e(
732
- "dialog",
733
- {
734
- ref: t,
735
- className: "mes-dialog group",
736
- onClose: s,
737
- onClick: (p) => {
738
- p.target === t.current && s();
739
- },
740
- children: /* @__PURE__ */ d("div", { className: "ml-auto flex h-full w-full flex-col bg-white shadow-none transition-shadow duration-200 group-open:shadow-max-elevation-light", children: [
741
- /* @__PURE__ */ d("div", { className: "flex items-center justify-between border-b border-sand px-4 py-3", children: [
742
- /* @__PURE__ */ e("h2", { className: "text-base font-semibold text-charcoal", children: "Chat info" }),
743
- /* @__PURE__ */ e(en, { onClick: s })
744
- ] }),
745
- /* @__PURE__ */ d("div", { className: "flex-1 px-2 overflow-y-auto w-full", children: [
746
- /* @__PURE__ */ d(
747
- "div",
748
- {
749
- className: "flex flex-col items-center gap-3 self-stretch px-4 py-2 mt-6 rounded-lg border border-black/[0.04]",
750
- style: { backgroundColor: "#FBFAF9" },
751
- children: [
752
- /* @__PURE__ */ d("div", { className: "flex items-center gap-3 w-full", children: [
753
- /* @__PURE__ */ e(
754
- ne,
755
- {
756
- id: z,
757
- name: y,
758
- image: _,
759
- size: 88,
760
- shape: "circle"
761
- }
762
- ),
763
- /* @__PURE__ */ d("div", { className: "flex flex-col min-w-0 flex-1", children: [
764
- /* @__PURE__ */ e("p", { className: "truncate text-base font-semibold text-charcoal", children: y }),
765
- R && /* @__PURE__ */ e("p", { className: "truncate text-sm text-[#00000055]", children: R }),
766
- o && !f && /* @__PURE__ */ e(
767
- "span",
768
- {
769
- className: "mt-1 rounded-full text-xs font-normal w-fit",
770
- style: {
771
- padding: "4px 8px",
772
- backgroundColor: o === "Subscribed to you" ? "#DCFCE7" : "#F5F5F4",
773
- color: o === "Subscribed to you" ? "#008236" : "#78716C",
774
- lineHeight: "133.333%",
775
- letterSpacing: "0.21px"
776
- },
777
- children: o
778
- }
779
- )
780
- ] })
781
- ] }),
782
- f && /* @__PURE__ */ e("div", { className: "w-full", children: f })
783
- ]
784
- }
785
- ),
786
- /* @__PURE__ */ d("ul", { className: "flex flex-col gap-2 mt-2", children: [
787
- c && /* @__PURE__ */ e("li", { children: /* @__PURE__ */ d(
788
- he,
789
- {
790
- onClick: U,
791
- disabled: x,
792
- "aria-busy": x,
793
- children: [
794
- x ? /* @__PURE__ */ e(ye, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(vs, { className: "h-5 w-5" }),
795
- /* @__PURE__ */ e("span", { children: "Delete Conversation" })
796
- ]
797
- }
798
- ) }),
799
- /* @__PURE__ */ e("li", { children: b ? /* @__PURE__ */ d(
800
- he,
801
- {
802
- onClick: T,
803
- disabled: w,
804
- "aria-busy": w,
805
- children: [
806
- w ? /* @__PURE__ */ e(ye, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(et, { className: "h-5 w-5" }),
807
- /* @__PURE__ */ e("span", { children: "Unblock" })
808
- ]
809
- }
810
- ) : /* @__PURE__ */ d(
811
- he,
812
- {
813
- onClick: k,
814
- disabled: w,
815
- "aria-busy": w,
816
- children: [
817
- w ? /* @__PURE__ */ e(ye, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(et, { className: "h-5 w-5" }),
818
- /* @__PURE__ */ e("span", { children: "Block" })
819
- ]
820
- }
821
- ) }),
822
- /* @__PURE__ */ e("li", { children: /* @__PURE__ */ d(he, { variant: "danger", onClick: M, children: [
823
- /* @__PURE__ */ e(ws, { className: "h-5 w-5" }),
824
- /* @__PURE__ */ e("span", { children: "Report" })
825
- ] }) }),
826
- v
827
- ] })
828
- ] })
829
- ] })
830
- }
831
- )
832
- );
833
- }, sn = (t) => /* @__PURE__ */ e(Ut, { ...t, position: "center" }), Me = "vote_up", Te = "vote_down";
834
- function nn(t) {
835
- return t != null && t.length ? t.some((s) => s.type === Te) ? "down" : t.some((s) => s.type === Me) ? "up" : null : null;
836
- }
837
- function an(t) {
838
- const { channel: s } = oe(), { client: n } = De("useMessageVote"), r = Se(
839
- () => nn(t.own_reactions),
840
- [t.own_reactions]
841
- ), o = G(async () => {
842
- if (n != null && n.userID)
843
- try {
844
- r === "up" ? await s.deleteReaction(t.id, Me) : await s.sendReaction(
845
- t.id,
846
- { type: Me },
847
- { enforce_unique: !0, skip_push: !0 }
848
- );
849
- } catch {
850
- }
851
- }, [s, n == null ? void 0 : n.userID, t.id, r]), l = G(async () => {
852
- if (n != null && n.userID)
853
- try {
854
- r === "down" ? await s.deleteReaction(t.id, Te) : await s.sendReaction(
855
- t.id,
856
- { type: Te },
857
- { enforce_unique: !0, skip_push: !0 }
858
- );
859
- } catch {
860
- }
861
- }, [s, n == null ? void 0 : n.userID, t.id, r]);
862
- return { selected: r, voteUp: o, voteDown: l };
863
- }
864
- const rn = O.lazy(() => import("./Card-A0lkei-S.js")), on = O.lazy(() => import("./Card-DXoAKkv0.js")), Et = () => /* @__PURE__ */ e(
865
- "div",
866
- {
867
- className: "w-[280px] min-h-[200px] animate-pulse rounded-[24px] bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",
868
- "aria-hidden": !0
869
- }
870
- ), ln = (t) => /* @__PURE__ */ e(ht, { fallback: /* @__PURE__ */ e(Et, {}), children: /* @__PURE__ */ e(rn, { ...t }) }), cn = (t) => /* @__PURE__ */ e(ht, { fallback: /* @__PURE__ */ e(Et, {}), children: /* @__PURE__ */ e(on, { ...t }) }), ot = { Creator: ln, Visitor: cn }, dn = [
871
- [/pdf/, "pdf"],
872
- [/wordprocessingml|msword|\.doc/, "doc"],
873
- [/spreadsheetml|ms-excel|\.xls/, "xls"],
874
- [/csv/, "csv"],
875
- [/presentationml|ms-powerpoint|\.ppt/, "ppt"],
876
- [/zip|x-rar|x-7z|x-tar|x-gzip/, "zip"],
877
- [/plain|rtf/, "text"],
878
- [/markdown/, "markdown"]
879
- ];
880
- function xe(t) {
881
- return t.startsWith("video/") ? "video" : t.startsWith("audio/") ? "audio" : t.startsWith("image/") ? "image" : "document";
882
- }
883
- function un(t) {
884
- const s = dn.find(
885
- ([n]) => n.test(t)
886
- );
887
- return s ? s[1] : "generic";
888
- }
889
- const mn = {
890
- video: Ns,
891
- audio: ys,
892
- image: _s,
893
- document: pt
894
- }, hn = {
895
- pdf: Ds,
896
- doc: Ts,
897
- xls: Ms,
898
- csv: ks,
899
- ppt: Is,
900
- zip: Ss,
901
- text: Es,
902
- markdown: Cs,
903
- generic: pt
904
- };
905
- function fn(t) {
906
- const s = xe(t);
907
- return s !== "document" ? mn[s] : hn[un(t)];
908
- }
909
- function be(t, s) {
910
- return O.createElement(fn(t), s);
911
- }
912
- const gn = (t) => {
913
- var s, n;
914
- return "touches" in t ? ((s = t.touches[0]) == null ? void 0 : s.clientX) ?? ((n = t.changedTouches[0]) == null ? void 0 : n.clientX) ?? 0 : t.clientX;
915
- }, bn = ({
916
- source: t,
917
- mimeType: s,
918
- poster: n,
919
- autoPlay: r = !1,
920
- playing: o,
921
- loop: l = !1,
922
- controls: i = !0,
923
- showProgress: c = !1,
924
- muted: m = !1,
925
- onContainerClick: u
926
- }) => {
927
- const h = xe(s), f = K(null), v = K(null), a = K(null), N = K(o), [b, C] = A(r), [x, I] = A(0), [w, E] = A(!1), [P, U] = A(!1), [k, T] = A(!1), [M, y] = A(!1), [_, F] = A(!0), [H, R] = A(null), z = G(() => {
928
- T(!1), C(!0);
929
- }, []), S = G((g) => {
930
- const p = v.current;
931
- if (!p) return 0;
932
- const L = p.getBoundingClientRect();
933
- return Math.max(
934
- 0,
935
- Math.min(1, (gn(g) - L.left) / L.width)
936
- );
937
- }, []), $ = G((g) => {
938
- const p = f.current;
939
- p && p.duration && (p.currentTime = g * p.duration);
940
- }, []), V = (g) => {
941
- g.stopPropagation(), E(!0);
942
- const p = S(g);
943
- I(p), $(p);
944
- };
945
- J(() => {
946
- o !== void 0 && o !== N.current && (N.current = o, C(o));
947
- }, [o]), J(() => {
948
- if (!b) {
949
- a.current !== null && (cancelAnimationFrame(a.current), a.current = null);
950
- return;
951
- }
952
- const g = () => {
953
- const p = f.current;
954
- p && p.duration && !w && I(p.currentTime / p.duration), a.current = requestAnimationFrame(g);
955
- };
956
- return a.current = requestAnimationFrame(g), () => {
957
- a.current !== null && cancelAnimationFrame(a.current);
958
- };
959
- }, [b, w]), J(() => {
960
- const g = f.current;
961
- g && (b ? g.play().catch((p) => {
962
- C(!1), T(!0);
963
- }) : g.pause());
964
- }, [b]), J(() => {
965
- if (!w) return;
966
- const g = (L) => I(S(L)), p = (L) => {
967
- E(!1), $(S(L));
968
- };
969
- return window.addEventListener("mousemove", g), window.addEventListener("mouseup", p), window.addEventListener("touchmove", g, { passive: !0 }), window.addEventListener("touchend", p), () => {
970
- window.removeEventListener("mousemove", g), window.removeEventListener("mouseup", p), window.removeEventListener("touchmove", g), window.removeEventListener("touchend", p);
971
- };
972
- }, [w, S, $]);
973
- const ee = H ? { aspectRatio: String(H) } : void 0, te = H ? "" : " aspect-video", W = Math.round(x * 100);
974
- return /* @__PURE__ */ d(
975
- "div",
976
- {
977
- role: "button",
978
- tabIndex: 0,
979
- className: `relative cursor-pointer overflow-hidden bg-black ${te}`,
980
- style: ee,
981
- onClick: (g) => {
982
- if (u) {
983
- u(g);
984
- return;
985
- }
986
- k || i && C((p) => !p);
987
- },
988
- onKeyDown: (g) => {
989
- if (!(g.key !== "Enter" && g.key !== " ")) {
990
- if (g.preventDefault(), u) {
991
- u(g);
992
- return;
993
- }
994
- k || i && C((p) => !p);
995
- }
996
- },
997
- children: [
998
- n && (h === "audio" || _) && /* @__PURE__ */ e(
999
- "img",
1000
- {
1001
- src: n,
1002
- alt: "",
1003
- className: "absolute inset-0 h-full w-full object-cover"
1004
- }
1005
- ),
1006
- !n && (h === "audio" || _) && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: be(s, {
1007
- className: "size-12 text-black/20",
1008
- weight: "regular"
1009
- }) }),
1010
- /* @__PURE__ */ e("div", { className: "absolute inset-0", children: h === "audio" ? /* @__PURE__ */ e(
1011
- "audio",
1012
- {
1013
- ref: f,
1014
- src: t,
1015
- loop: l,
1016
- muted: m,
1017
- style: { width: "100%", height: "100%" },
1018
- onLoadStart: () => y(!0),
1019
- onCanPlay: () => {
1020
- y(!1), F(!1);
1021
- },
1022
- onWaiting: () => y(!0),
1023
- onPlay: () => T(!1),
1024
- onEnded: () => {
1025
- l || (C(!1), I(0));
1026
- },
1027
- children: /* @__PURE__ */ e("track", { kind: "captions" })
1028
- }
1029
- ) : /* @__PURE__ */ e(
1030
- "video",
1031
- {
1032
- ref: f,
1033
- src: t,
1034
- loop: l,
1035
- muted: m,
1036
- playsInline: !0,
1037
- style: { width: "100%", height: "100%" },
1038
- onLoadStart: () => y(!0),
1039
- onCanPlay: () => {
1040
- y(!1), F(!1);
1041
- },
1042
- onWaiting: () => y(!0),
1043
- onPlay: () => T(!1),
1044
- onLoadedMetadata: () => {
1045
- const g = f.current;
1046
- g instanceof HTMLVideoElement && g.videoWidth && g.videoHeight && R(g.videoWidth / g.videoHeight);
1047
- },
1048
- onEnded: () => {
1049
- l || (C(!1), I(0));
1050
- },
1051
- children: /* @__PURE__ */ e("track", { kind: "captions" })
1052
- }
1053
- ) }),
1054
- M && !k && /* @__PURE__ */ e("div", { className: "absolute inset-0 z-10 flex items-center justify-center", children: /* @__PURE__ */ e(
1055
- xt,
1056
- {
1057
- className: "size-8 animate-spin text-white/80",
1058
- weight: "bold"
1059
- }
1060
- ) }),
1061
- k && !i && /* @__PURE__ */ e(
1062
- "div",
1063
- {
1064
- className: "absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",
1065
- role: "button",
1066
- tabIndex: 0,
1067
- "aria-label": "Play preview",
1068
- onClick: (g) => {
1069
- g.stopPropagation(), z();
1070
- },
1071
- onKeyDown: (g) => {
1072
- g.key !== "Enter" && g.key !== " " || (g.preventDefault(), g.stopPropagation(), z());
1073
- },
1074
- children: /* @__PURE__ */ e("span", { className: "flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm", children: /* @__PURE__ */ e(tt, { className: "size-9 translate-x-0.5", weight: "fill" }) })
1075
- }
1076
- ),
1077
- c && !i && /* @__PURE__ */ e("div", { className: "absolute inset-x-0 bottom-0 px-3 pb-2.5 pt-6 bg-gradient-to-t from-black/40 to-transparent", children: /* @__PURE__ */ e(
1078
- "div",
1079
- {
1080
- role: "slider",
1081
- "aria-label": "Playback position",
1082
- "aria-valuenow": W,
1083
- "aria-valuemin": 0,
1084
- "aria-valuemax": 100,
1085
- tabIndex: 0,
1086
- ref: v,
1087
- className: "relative flex h-4 w-full cursor-pointer items-center",
1088
- onMouseDown: V,
1089
- onTouchStart: V,
1090
- onClick: (g) => g.stopPropagation(),
1091
- onKeyDown: (g) => {
1092
- g.key === "ArrowRight" && $(Math.min(1, x + 0.05)), g.key === "ArrowLeft" && $(Math.max(0, x - 0.05));
1093
- },
1094
- children: /* @__PURE__ */ e("div", { className: "w-full overflow-hidden rounded-full bg-white/30 h-1", children: /* @__PURE__ */ e(
1095
- "div",
1096
- {
1097
- className: "h-full rounded-full bg-white",
1098
- style: { width: `${W}%` }
1099
- }
1100
- ) })
1101
- }
1102
- ) }),
1103
- i && /* @__PURE__ */ d("div", { className: "absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/60 to-transparent px-3 pb-2.5 pt-6 transition-all duration-200", children: [
1104
- /* @__PURE__ */ e(
1105
- "button",
1106
- {
1107
- type: "button",
1108
- onClick: (g) => {
1109
- g.stopPropagation(), C((p) => !p);
1110
- },
1111
- className: "shrink-0 text-white",
1112
- "aria-label": b ? "Pause" : "Play",
1113
- children: b ? /* @__PURE__ */ e(Rs, { className: "size-5", weight: "fill" }) : /* @__PURE__ */ e(tt, { className: "size-5 translate-x-px", weight: "fill" })
1114
- }
1115
- ),
1116
- /* @__PURE__ */ d(
1117
- "div",
1118
- {
1119
- role: "slider",
1120
- "aria-label": "Playback position",
1121
- "aria-valuenow": W,
1122
- "aria-valuemin": 0,
1123
- "aria-valuemax": 100,
1124
- tabIndex: 0,
1125
- ref: v,
1126
- className: "relative flex h-4 w-full cursor-pointer items-center",
1127
- onMouseDown: V,
1128
- onTouchStart: V,
1129
- onClick: (g) => g.stopPropagation(),
1130
- onMouseEnter: () => U(!0),
1131
- onMouseLeave: () => U(!1),
1132
- onKeyDown: (g) => {
1133
- g.key === "ArrowRight" && $(Math.min(1, x + 0.05)), g.key === "ArrowLeft" && $(Math.max(0, x - 0.05));
1134
- },
1135
- children: [
1136
- /* @__PURE__ */ e(
1137
- "div",
1138
- {
1139
- className: `w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${P || w ? "h-1.5" : "h-1"}`,
1140
- children: /* @__PURE__ */ e(
1141
- "div",
1142
- {
1143
- className: "h-full rounded-full bg-white",
1144
- style: { width: `${W}%` }
1145
- }
1146
- )
1147
- }
1148
- ),
1149
- /* @__PURE__ */ e(
1150
- "div",
1151
- {
1152
- className: `absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${P || w ? "scale-100 opacity-100" : "scale-0 opacity-0"}`,
1153
- style: { left: `${W}%` }
1154
- }
1155
- )
1156
- ]
1157
- }
1158
- )
1159
- ] })
1160
- ]
1161
- }
1162
- );
1163
- }, lt = (t) => t === "dark" ? "size-12 text-white/20" : "size-12 text-black/20", pn = (t) => t === "dark" ? "aspect-video overflow-hidden bg-white/10" : "aspect-video overflow-hidden bg-black/5", St = ({
1164
- mimeType: t,
1165
- sourceUrl: s,
1166
- thumbnailUrl: n,
1167
- title: r,
1168
- variant: o,
1169
- mediaPlayerProps: l,
1170
- containedImage: i = !1
1171
- }) => {
1172
- const c = xe(t), [m, u] = A(!1);
1173
- return s && (c === "video" || c === "audio") ? /* @__PURE__ */ e(
1174
- bn,
1175
- {
1176
- source: s,
1177
- mimeType: t,
1178
- poster: n,
1179
- controls: !0,
1180
- ...l
1181
- }
1182
- ) : s && c === "image" ? i ? /* @__PURE__ */ e("div", { className: "relative aspect-video overflow-hidden bg-black/5", children: /* @__PURE__ */ e(
1183
- "img",
1184
- {
1185
- src: s,
1186
- alt: r ?? "",
1187
- className: `absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${m ? "opacity-100" : "opacity-0"}`,
1188
- draggable: !1,
1189
- onLoad: () => u(!0)
1190
- }
1191
- ) }) : /* @__PURE__ */ e(
1192
- "img",
1193
- {
1194
- src: s,
1195
- alt: r ?? "",
1196
- className: "block w-full",
1197
- draggable: !1
1198
- }
1199
- ) : s && c === "document" ? n ? i ? /* @__PURE__ */ e("div", { className: "relative aspect-video overflow-hidden bg-black/5", children: /* @__PURE__ */ e(
1200
- "img",
1201
- {
1202
- src: n,
1203
- alt: r ?? "",
1204
- className: `absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${m ? "opacity-100" : "opacity-0"}`,
1205
- draggable: !1,
1206
- onLoad: () => u(!0)
1207
- }
1208
- ) }) : /* @__PURE__ */ e(
1209
- "img",
1210
- {
1211
- src: n,
1212
- alt: "",
1213
- className: "block w-full",
1214
- draggable: !1
1215
- }
1216
- ) : /* @__PURE__ */ e(
1217
- "div",
1218
- {
1219
- className: `flex aspect-video w-full items-center justify-center ${o === "dark" ? "bg-white/10" : "bg-black/5"}`,
1220
- children: be(t, {
1221
- className: lt(o),
1222
- weight: "regular"
1223
- })
1224
- }
1225
- ) : n ? /* @__PURE__ */ e("div", { className: `relative ${pn(o)}`, children: /* @__PURE__ */ e(
1226
- "img",
1227
- {
1228
- src: n,
1229
- alt: r ?? "",
1230
- draggable: !1,
1231
- className: "absolute inset-0 h-full w-full object-cover"
1232
- }
1233
- ) }) : /* @__PURE__ */ e(
1234
- "div",
1235
- {
1236
- className: `flex aspect-video w-full items-center justify-center ${o === "dark" ? "bg-white/10" : "bg-black/5"}`,
1237
- children: be(t, {
1238
- className: lt(o),
1239
- weight: "regular"
1240
- })
1241
- }
1242
- );
1243
- }, It = ({
1244
- variant: t,
1245
- thumbnail: s,
1246
- title: n,
1247
- placeholderTitle: r = "Attachment title",
1248
- mimeType: o,
1249
- detail: l,
1250
- statusBadge: i,
1251
- action: c,
1252
- topLeft: m,
1253
- topRight: u,
1254
- rootRef: h,
1255
- "data-testid": f
1256
- }) => {
1257
- const v = t === "dark", a = v ? n ?? r : n ?? "", N = v && !n;
1258
- return /* @__PURE__ */ d(
1259
- "div",
1260
- {
1261
- ref: h,
1262
- "data-testid": f,
1263
- className: D(
1264
- "relative w-[280px] select-none overflow-hidden rounded-[24px] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",
1265
- v ? "bg-[#121110]" : "bg-white"
1266
- ),
1267
- children: [
1268
- m ? /* @__PURE__ */ e("div", { className: "pointer-events-auto absolute left-3 top-3 z-50", children: m }) : null,
1269
- u ? /* @__PURE__ */ e("div", { className: "pointer-events-auto absolute right-3 top-3 z-50", children: u }) : null,
1270
- s,
1271
- /* @__PURE__ */ d("div", { className: "px-4 pb-3 pt-3", children: [
1272
- a.trim() !== "" && /* @__PURE__ */ e(
1273
- "p",
1274
- {
1275
- className: D("mb-0.5 truncate text-base font-medium", {
1276
- "text-black": !v,
1277
- "text-white/30": v && N,
1278
- "text-white": v && !N
1279
- }),
1280
- children: a
1281
- }
1282
- ),
1283
- /* @__PURE__ */ d("div", { className: "flex flex-wrap items-center gap-1", children: [
1284
- be(o, {
1285
- className: D(
1286
- "size-5 shrink-0",
1287
- v ? "text-white/55" : "text-black/55"
1288
- ),
1289
- weight: "regular"
1290
- }),
1291
- l != null && l !== "" && /* @__PURE__ */ e(
1292
- "span",
1293
- {
1294
- className: D(
1295
- "text-xs font-medium",
1296
- v ? "text-white/55" : "text-black/55"
1297
- ),
1298
- children: l
1299
- }
1300
- ),
1301
- i
1302
- ] }),
1303
- c
1304
- ] })
1305
- ]
1306
- }
1307
- );
1308
- };
1309
- function kt(t) {
1310
- return t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
1311
- }
1312
- function Le(t) {
1313
- return `w-[280px] select-none overflow-hidden rounded-[24px] ${t ? "bg-[#121110]" : "bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`;
1314
- }
1315
- function xn(t) {
1316
- return t ? "bg-white/10" : "bg-black/5";
1317
- }
1318
- function vn(t) {
1319
- return t ? "text-white" : "text-black";
1320
- }
1321
- function wn(t) {
1322
- return t ? "text-white/55" : "text-black/55";
1323
- }
1324
- function _n(t) {
1325
- return t ? "text-white/40" : "text-black/40";
1326
- }
1327
- function yn(t) {
1328
- return t ? "text-white/20" : "text-black/20";
1329
- }
1330
- const Ae = ({ attachment: t, isMyMessage: s }) => {
1331
- const { title: n, text: r, image_url: o, og_scrape_url: l, title_link: i } = t, c = l ?? i, m = typeof c == "string" && c.trim() !== "" ? c : void 0, u = /* @__PURE__ */ d(O.Fragment, { children: [
1332
- /* @__PURE__ */ e("div", { className: "p-2", children: o ? /* @__PURE__ */ e(
1333
- "img",
1334
- {
1335
- src: o,
1336
- alt: n ?? "",
1337
- className: "aspect-video w-full rounded-[20px] object-cover"
1338
- }
1339
- ) : /* @__PURE__ */ e(
1340
- "div",
1341
- {
1342
- className: `aspect-video w-full rounded-[20px] ${xn(s)} flex items-center justify-center`,
1343
- children: /* @__PURE__ */ e(Ls, { className: `size-12 ${yn(s)}` })
1344
- }
1345
- ) }),
1346
- /* @__PURE__ */ d("div", { className: "px-3 pb-3", children: [
1347
- n && /* @__PURE__ */ e("p", { className: `truncate text-[14px] font-medium leading-5 ${vn(s)}`, children: n }),
1348
- r && /* @__PURE__ */ e("p", { className: `truncate text-[12px] leading-4 ${wn(s)}`, children: r }),
1349
- m && /* @__PURE__ */ e("p", { className: `mt-1 truncate text-[12px] leading-4 ${_n(s)}`, children: m })
1350
- ] })
1351
- ] });
1352
- return m ? /* @__PURE__ */ e("a", { href: m, target: "_blank", rel: "noopener noreferrer", className: "block no-underline", children: u }) : /* @__PURE__ */ e("div", { className: "block", children: u });
1353
- };
1354
- function Mt(t) {
1355
- return t.type === "link" || !!t.og_scrape_url && !t.asset_url;
1356
- }
1357
- function Fe(t) {
1358
- var s;
1359
- return (s = t.attachments) == null ? void 0 : s.find(Mt);
1360
- }
1361
- async function Nn(t, s) {
1362
- let n;
1363
- try {
1364
- n = s ?? new URL(t).pathname.split("/").pop() ?? "download";
1365
- } catch {
1366
- n = s ?? "download";
1367
- }
1368
- const r = await fetch(t, { mode: "cors" });
1369
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
1370
- const o = await r.blob(), l = URL.createObjectURL(o), i = document.createElement("a");
1371
- i.href = l, i.download = n, i.style.display = "none", document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(l);
1372
- }
1373
- const Cn = ({
1374
- url: t,
1375
- filename: s
1376
- }) => {
1377
- const [n, r] = A(!1);
1378
- return /* @__PURE__ */ e(
1379
- "button",
1380
- {
1381
- type: "button",
1382
- onClick: (l) => {
1383
- l.stopPropagation();
1384
- const i = window.open("", "_blank", "noopener,noreferrer");
1385
- r(!0), Nn(t, s).then(() => {
1386
- i == null || i.close();
1387
- }).catch(() => {
1388
- i && (i.location.href = t);
1389
- }).finally(() => r(!1));
1390
- },
1391
- disabled: n,
1392
- className: "mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full bg-[#121110] px-4 text-sm font-medium leading-none text-white hover:bg-[#2a2928] disabled:opacity-70",
1393
- children: n ? /* @__PURE__ */ e(xt, { className: "size-4 animate-spin text-white", weight: "bold" }) : /* @__PURE__ */ d(O.Fragment, { children: [
1394
- /* @__PURE__ */ e(As, { className: "size-4 text-white", weight: "bold" }),
1395
- "Download"
1396
- ] })
1397
- }
1398
- );
1399
- };
1400
- function Oe(t) {
1401
- var f, v, a, N;
1402
- const s = (f = t.attachments) == null ? void 0 : f.find(
1403
- (b) => b.type === "video" && b.asset_url
1404
- ), n = (v = t.attachments) == null ? void 0 : v.find(
1405
- (b) => b.type === "image" && b.image_url
1406
- ), r = (a = t.attachments) == null ? void 0 : a.find(
1407
- (b) => b.type === "audio" && b.asset_url
1408
- ), o = (N = t.attachments) == null ? void 0 : N.find(
1409
- (b) => b.type === "file" && b.asset_url
1410
- ), l = s ?? n ?? r ?? o, i = (s == null ? void 0 : s.asset_url) ?? (n == null ? void 0 : n.image_url) ?? (r == null ? void 0 : r.asset_url) ?? (o == null ? void 0 : o.asset_url);
1411
- if (!i) return null;
1412
- const c = (l == null ? void 0 : l.mime_type) ?? ((l == null ? void 0 : l.type) === "image" ? "image/jpeg" : (l == null ? void 0 : l.type) === "video" ? "video/mp4" : (l == null ? void 0 : l.type) === "audio" ? "audio/mpeg" : "application/octet-stream"), m = l == null ? void 0 : l.title, u = l == null ? void 0 : l.file_size, h = s == null ? void 0 : s.thumb_url;
1413
- return {
1414
- resolvedUrl: i,
1415
- resolvedType: c,
1416
- title: m,
1417
- fileSize: u,
1418
- thumbnailUrl: h
1419
- };
1420
- }
1421
- const Tt = ({
1422
- resolvedUrl: t,
1423
- resolvedType: s,
1424
- title: n,
1425
- fileSize: r,
1426
- thumbnailUrl: o
1427
- }) => {
1428
- const l = r !== void 0 ? kt(r) : void 0;
1429
- return /* @__PURE__ */ e(
1430
- It,
1431
- {
1432
- variant: "dark",
1433
- title: n,
1434
- placeholderTitle: "",
1435
- mimeType: s,
1436
- detail: l,
1437
- thumbnail: /* @__PURE__ */ e(
1438
- St,
1439
- {
1440
- mimeType: s,
1441
- sourceUrl: t,
1442
- thumbnailUrl: o,
1443
- title: n,
1444
- variant: "dark"
1445
- }
1446
- )
1447
- }
1448
- );
1449
- }, Dt = ({
1450
- resolvedUrl: t,
1451
- resolvedType: s,
1452
- title: n,
1453
- fileSize: r,
1454
- thumbnailUrl: o
1455
- }) => {
1456
- const l = xe(s), i = r !== void 0 ? kt(r) : void 0;
1457
- return /* @__PURE__ */ e(
1458
- It,
1459
- {
1460
- variant: "light",
1461
- title: n,
1462
- mimeType: s,
1463
- detail: i,
1464
- thumbnail: /* @__PURE__ */ e(
1465
- St,
1466
- {
1467
- mimeType: s,
1468
- sourceUrl: t,
1469
- thumbnailUrl: o,
1470
- title: n,
1471
- variant: "light",
1472
- containedImage: l === "image" || l === "document"
1473
- }
1474
- ),
1475
- action: /* @__PURE__ */ e(Cn, { url: t, filename: n })
1476
- }
1477
- );
1478
- }, En = ({
1479
- message: t,
1480
- isMyMessage: s = !1
1481
- }) => {
1482
- const n = Fe(t), r = Oe(t);
1483
- return !n && !r ? null : /* @__PURE__ */ d("div", { className: s ? "str-chat__message str-chat__message-simple str-chat__message--me str-chat__message-simple--me" : "str-chat__message str-chat__message-simple str-chat__message--other", children: [
1484
- !s && t.user && /* @__PURE__ */ e(
1485
- ne,
1486
- {
1487
- className: "str-chat__avatar str-chat__message-sender-avatar",
1488
- id: t.user.id,
1489
- image: t.user.image,
1490
- name: t.user.name ?? t.user.id
1491
- }
1492
- ),
1493
- /* @__PURE__ */ e(
1494
- "div",
1495
- {
1496
- className: "str-chat__message-inner",
1497
- style: { marginInlineEnd: 0, marginInlineStart: 0 },
1498
- children: /* @__PURE__ */ e("div", { className: "str-chat__message-bubble-wrapper", children: /* @__PURE__ */ e(
1499
- "div",
1500
- {
1501
- className: "str-chat__message-bubble",
1502
- style: { padding: 0, borderRadius: 0, overflow: "visible", background: "transparent" },
1503
- children: n ? /* @__PURE__ */ e("div", { className: Le(s), children: /* @__PURE__ */ e(Ae, { attachment: n, isMyMessage: s }) }) : s ? /* @__PURE__ */ e(Tt, { ...r }) : /* @__PURE__ */ e(Dt, { ...r })
1504
- }
1505
- ) })
1506
- }
1507
- )
1508
- ] });
1509
- }, Sn = ({
1510
- message: t
1511
- }) => {
1512
- const s = Fe(t);
1513
- if (s)
1514
- return /* @__PURE__ */ e("div", { className: Le(!0), children: /* @__PURE__ */ e(Ae, { attachment: s, isMyMessage: !0 }) });
1515
- const n = Oe(t);
1516
- return n ? /* @__PURE__ */ e(Tt, { ...n }) : null;
1517
- }, In = ({
1518
- message: t
1519
- }) => {
1520
- const s = Fe(t);
1521
- if (s)
1522
- return /* @__PURE__ */ e("div", { className: Le(!1), children: /* @__PURE__ */ e(Ae, { attachment: s, isMyMessage: !1 }) });
1523
- const n = Oe(t);
1524
- return n ? /* @__PURE__ */ e(Dt, { ...n }) : null;
1525
- }, ua = Object.assign(En, {
1526
- Creator: Sn,
1527
- Visitor: In
1528
- }), kn = {
1529
- isUnlocking: () => !1
1530
- }, Mn = {
1531
- LockedAttachment: kn
1532
- }, Rt = ut({}), ma = Rt.Provider;
1533
- function Tn(t) {
1534
- return mt(Rt)[t] ?? Mn[t];
1535
- }
1536
- const Dn = ({
1537
- selected: t,
1538
- onVoteUp: s,
1539
- onVoteDown: n
1540
- }) => /* @__PURE__ */ d("div", { className: "message-vote-buttons", children: [
1541
- /* @__PURE__ */ e(
1542
- "button",
1543
- {
1544
- type: "button",
1545
- className: D("message-vote-button focus-ring", {
1546
- "message-vote-button--selected": t === "up"
1547
- }),
1548
- onClick: s,
1549
- "aria-label": "Good response",
1550
- "aria-pressed": t === "up",
1551
- "data-tooltip": "Good response",
1552
- children: /* @__PURE__ */ e(Fs, { size: 16, weight: t === "up" ? "fill" : "regular" })
1553
- }
1554
- ),
1555
- /* @__PURE__ */ e(
1556
- "button",
1557
- {
1558
- type: "button",
1559
- className: D("message-vote-button focus-ring", {
1560
- "message-vote-button--selected": t === "down"
1561
- }),
1562
- onClick: n,
1563
- "aria-label": "Bad response",
1564
- "aria-pressed": t === "down",
1565
- "data-tooltip": "Bad response",
1566
- children: /* @__PURE__ */ e(Os, { size: 16, weight: t === "down" ? "fill" : "regular" })
1567
- }
1568
- )
1569
- ] }), Rn = (t) => {
1570
- var se, Pe, Ue, ze, Be, $e, je, Ge, Ve, He, Ye, We, qe, Xe;
1571
- const {
1572
- additionalMessageInputProps: s,
1573
- chatbotVotingEnabled: n,
1574
- editing: r,
1575
- endOfGroup: o,
1576
- firstOfGroup: l,
1577
- groupedByUser: i,
1578
- handleAction: c,
1579
- handleOpenThread: m,
1580
- handleRetry: u,
1581
- highlighted: h,
1582
- isMessageAIGenerated: f,
1583
- isMyMessage: v,
1584
- message: a,
1585
- renderText: N,
1586
- threadList: b
1587
- } = t, { client: C } = De("CustomMessage"), { channel: x } = oe("CustomMessage"), { isUnlocking: I, onUnlockClick: w, onFetchSource: E, onDownloadClick: P } = Tn("LockedAttachment"), [U, k] = A(!1), T = Bt(a.id), { selected: M, voteUp: y, voteDown: _ } = an(a), {
1588
- Attachment: F = $t,
1589
- EditMessageModal: H = jt,
1590
- MessageBlocked: R = Gt,
1591
- MessageBouncePrompt: z = Vt,
1592
- MessageDeleted: S = Ht,
1593
- MessageIsThreadReplyInChannelButtonIndicator: $ = Yt,
1594
- MessageRepliesCountButton: V = Wt,
1595
- ReminderNotification: ee = qt,
1596
- StreamedMessageText: te = Xt,
1597
- PinIndicator: W
1598
- } = ft("CustomMessage"), g = Zt(a), p = Jt(a), L = Se(
1599
- () => f == null ? void 0 : f(a),
1600
- [f, a]
1601
- ), j = Se(() => {
1602
- const Ze = a.attachments ?? [], me = a.shared_location ? [a.shared_location, ...Ze] : Ze;
1603
- if (!ge(a)) return me;
1604
- const Je = me.filter((Ke) => !("type" in Ke) || !Mt(Ke));
1605
- return Je.length === me.length ? me : Je;
1606
- }, [a]);
1607
- if (Kt(a))
1608
- return null;
1609
- if (a.deleted_at || a.type === "deleted")
1610
- return /* @__PURE__ */ e(S, { message: a });
1611
- if (Qt(a))
1612
- return /* @__PURE__ */ e(R, {});
1613
- const Y = !b && !!a.reply_count, ae = !b && a.show_in_channel && a.parent_id, de = a.status === "failed" && ((se = a.error) == null ? void 0 : se.status) !== 403, re = es(a);
1614
- let q;
1615
- de ? q = () => u(a) : re && (q = () => k(!0));
1616
- const ie = v(), ve = D(
1617
- "str-chat__message str-chat__message-simple",
1618
- `str-chat__message--${a.type}`,
1619
- `str-chat__message--${a.status}`,
1620
- ie ? "str-chat__message--me str-chat__message-simple--me" : "str-chat__message--other",
1621
- a.text ? "str-chat__message--has-text" : "has-no-text",
1622
- {
1623
- "str-chat__message--has-attachment": g,
1624
- "str-chat__message--highlighted": h,
1625
- "str-chat__message--pinned pinned-message": a.pinned,
1626
- "str-chat__message--with-reactions": p,
1627
- "str-chat__message-send-can-be-retried": (a == null ? void 0 : a.status) === "failed" && ((Pe = a == null ? void 0 : a.error) == null ? void 0 : Pe.status) !== 403,
1628
- "str-chat__message-with-thread-link": Y || ae,
1629
- "str-chat__virtual-message__wrapper--end": o,
1630
- "str-chat__virtual-message__wrapper--first": l,
1631
- "str-chat__virtual-message__wrapper--group": i
1632
- }
1633
- ), ue = a.poll_id && C.polls.fromState(a.poll_id), we = Js(a), Z = ge(a), B = Zs(a), X = !!(j != null && j.length && !a.quoted_message), Q = Z && ie && X;
1634
- return /* @__PURE__ */ d(ce, { children: [
1635
- r && /* @__PURE__ */ e(
1636
- H,
1637
- {
1638
- additionalMessageInputProps: s
1639
- }
1640
- ),
1641
- U && /* @__PURE__ */ e(
1642
- ts,
1643
- {
1644
- MessageBouncePrompt: z,
1645
- onClose: () => k(!1),
1646
- open: U
1647
- }
1648
- ),
1649
- /* @__PURE__ */ d("div", { className: ve, children: [
1650
- W && /* @__PURE__ */ e(W, {}),
1651
- !!T && /* @__PURE__ */ e(ee, { reminder: T }),
1652
- a.user && /* @__PURE__ */ e(
1653
- ne,
1654
- {
1655
- className: "str-chat__avatar str-chat__message-sender-avatar",
1656
- id: a.user.id,
1657
- image: a.user.image,
1658
- name: a.user.name || a.user.id,
1659
- size: Z ? 24 : 28,
1660
- shape: "circle",
1661
- dmAgentEnabled: Z
1662
- }
1663
- ),
1664
- /* @__PURE__ */ e(
1665
- "div",
1666
- {
1667
- className: D("str-chat__message-inner", {
1668
- "str-chat__simple-message--error-failed": de || re
1669
- }),
1670
- "data-testid": "message-inner",
1671
- onClick: q,
1672
- onKeyDown: q,
1673
- role: q ? "button" : void 0,
1674
- tabIndex: q ? 0 : void 0,
1675
- style: {
1676
- // Force margins to 0 to prevent hover layout shift
1677
- // Stream Chat CSS sets margin-inline-end/start to 78px, then 0 on hover
1678
- marginInlineEnd: 0,
1679
- marginInlineStart: 0
1680
- },
1681
- children: B ? /* @__PURE__ */ d("div", { className: "str-chat__message-bubble-wrapper", children: [
1682
- ie ? /* @__PURE__ */ e(
1683
- ot.Creator,
1684
- {
1685
- title: (Ue = a.metadata) == null ? void 0 : Ue.attachment_title,
1686
- mimeType: (ze = a.metadata) == null ? void 0 : ze.attachment_mime_type,
1687
- thumbnailUrl: (Be = a.metadata) == null ? void 0 : Be.attachment_thumbnail,
1688
- amountText: ($e = a.metadata) == null ? void 0 : $e.amount_text,
1689
- detail: (je = a.metadata) == null ? void 0 : je.attachment_detail,
1690
- paymentStatus: (Ge = a.metadata) == null ? void 0 : Ge.payment_status,
1691
- isUnlocking: I(a.id),
1692
- onPreviewClick: () => w == null ? void 0 : w(a, x),
1693
- onFetchSource: async () => await (E == null ? void 0 : E(a, x))
1694
- }
1695
- ) : /* @__PURE__ */ e(
1696
- ot.Visitor,
1697
- {
1698
- title: (Ve = a.metadata) == null ? void 0 : Ve.attachment_title,
1699
- mimeType: (He = a.metadata) == null ? void 0 : He.attachment_mime_type,
1700
- thumbnailUrl: (Ye = a.metadata) == null ? void 0 : Ye.attachment_thumbnail,
1701
- amountText: (We = a.metadata) == null ? void 0 : We.amount_text,
1702
- detail: (qe = a.metadata) == null ? void 0 : qe.attachment_detail,
1703
- paymentStatus: (Xe = a.metadata) == null ? void 0 : Xe.payment_status,
1704
- isUnlocking: I(a.id),
1705
- onUnlockClick: () => w == null ? void 0 : w(a, x),
1706
- onFetchSource: async () => await (E == null ? void 0 : E(a, x)),
1707
- onDownloadClick: () => P == null ? void 0 : P(a, x)
1708
- }
1709
- ),
1710
- a.text && /* @__PURE__ */ e("div", { className: "str-chat__message-bubble", children: /* @__PURE__ */ e(Qe, { message: a, renderText: N }) })
1711
- ] }) : we ? (
1712
- /* Tip-only messages render as a standalone bubble */
1713
- /* @__PURE__ */ e(Ne, { message: a, standalone: !0 })
1714
- ) : /* @__PURE__ */ d("div", { className: "str-chat__message-bubble-wrapper", children: [
1715
- /* @__PURE__ */ d("div", { className: "str-chat__message-bubble", children: [
1716
- Z && !Q && /* @__PURE__ */ e(
1717
- Ne,
1718
- {
1719
- message: a,
1720
- hasAttachment: X,
1721
- isMyMessage: ie
1722
- }
1723
- ),
1724
- ue && /* @__PURE__ */ e(ss, { poll: ue }),
1725
- j != null && j.length && !a.quoted_message ? /* @__PURE__ */ e(
1726
- F,
1727
- {
1728
- actionHandler: c,
1729
- attachments: j
1730
- }
1731
- ) : null,
1732
- L ? /* @__PURE__ */ e(
1733
- te,
1734
- {
1735
- message: a,
1736
- renderText: N
1737
- }
1738
- ) : /* @__PURE__ */ e(Qe, { message: a, renderText: N }),
1739
- /* @__PURE__ */ e(ns, {})
1740
- ] }),
1741
- (!Z || Q) && /* @__PURE__ */ e(
1742
- Ne,
1743
- {
1744
- message: a,
1745
- hasAttachment: X,
1746
- isMyMessage: ie
1747
- }
1748
- ),
1749
- n && Z && /* @__PURE__ */ e(
1750
- Dn,
1751
- {
1752
- selected: M,
1753
- onVoteUp: y,
1754
- onVoteDown: _
1755
- }
1756
- )
1757
- ] })
1758
- }
1759
- ),
1760
- Y && /* @__PURE__ */ e(
1761
- V,
1762
- {
1763
- onClick: m,
1764
- reply_count: a.reply_count
1765
- }
1766
- ),
1767
- ae && /* @__PURE__ */ e($, {})
1768
- ] }, a.id)
1769
- ] });
1770
- }, Ln = O.memo(
1771
- Rn,
1772
- (t, s) => t.chatbotVotingEnabled !== s.chatbotVotingEnabled ? !1 : zt(t, s)
1773
- ), An = (t) => {
1774
- const s = gt("CustomMessage");
1775
- return /* @__PURE__ */ e(Ln, { ...s, ...t });
1776
- }, Fn = (t) => ({
1777
- linkPreviews: Array.from(t.previews.values()).filter(
1778
- (s) => rt.previewIsLoaded(s) || rt.previewIsLoading(s)
1779
- )
1780
- }), On = ({
1781
- link: t,
1782
- onDismiss: s
1783
- }) => {
1784
- const { og_scrape_url: n, title: r, image_url: o } = t;
1785
- return /* @__PURE__ */ d(
1786
- "a",
1787
- {
1788
- href: n,
1789
- target: "_blank",
1790
- rel: "noopener noreferrer",
1791
- className: "relative w-full block rounded-[24px] bg-[#121110] p-2 no-underline transition-opacity hover:opacity-90",
1792
- children: [
1793
- o && /* @__PURE__ */ e(
1794
- "img",
1795
- {
1796
- src: o,
1797
- alt: r || "",
1798
- className: "h-[148px] w-full rounded-[20px] object-cover"
1799
- }
1800
- ),
1801
- /* @__PURE__ */ e(
1802
- "button",
1803
- {
1804
- type: "button",
1805
- onClick: (i) => {
1806
- i.preventDefault(), s(n);
1807
- },
1808
- className: "absolute right-4 top-4 flex size-6 items-center justify-center rounded-full border border-white/40 bg-white/70 backdrop-blur-2xl focus-ring",
1809
- "aria-label": "Close link preview",
1810
- children: /* @__PURE__ */ e(bt, { className: "size-4 text-black/90" })
1811
- }
1812
- ),
1813
- /* @__PURE__ */ d("div", { className: "p-2", children: [
1814
- r && /* @__PURE__ */ e("div", { className: "text-[14px] font-medium leading-5 text-white", children: r }),
1815
- /* @__PURE__ */ e("div", { className: "text-[12px] leading-4 text-white/55", children: n })
1816
- ] })
1817
- ]
1818
- }
1819
- );
1820
- }, Pn = () => {
1821
- const { linkPreviewsManager: t } = as(), { linkPreviews: s } = rs(
1822
- t.state,
1823
- Fn
1824
- ), n = (o) => {
1825
- t.dismissPreview(o);
1826
- };
1827
- return s.length > 0 ? /* @__PURE__ */ e("div", { className: "flex flex-col items-center w-full gap-2 mb-4", children: s.map((o) => /* @__PURE__ */ e(
1828
- On,
1829
- {
1830
- link: o,
1831
- onDismiss: n
1832
- },
1833
- o.og_scrape_url
1834
- )) }) : null;
1835
- }, Un = ({ sendMessage: t, disabled: s, ...n }) => /* @__PURE__ */ e(
1836
- "button",
1837
- {
1838
- ...n,
1839
- type: "button",
1840
- "aria-label": "Send",
1841
- disabled: s,
1842
- onClick: t,
1843
- children: /* @__PURE__ */ e(Ps, { weight: "bold", className: "size-4" })
1844
- }
1845
- ), zn = () => {
1846
- var c;
1847
- const { channel: t } = oe(), s = ((c = t == null ? void 0 : t.data) == null ? void 0 : c.frozen) === !0, { handleSubmit: n } = os(), { SendButton: r } = ft(
1848
- "CustomMessageInput"
1849
- ), o = r ?? Un, l = ls();
1850
- return /* @__PURE__ */ d(ce, { children: [
1851
- /* @__PURE__ */ e("div", { className: "left-container", children: /* @__PURE__ */ e(cs, {}) }),
1852
- /* @__PURE__ */ d("div", { className: "central-container min-w-0 w-full p-2 bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)]", children: [
1853
- /* @__PURE__ */ e(ds, {}),
1854
- /* @__PURE__ */ e(Pn, {}),
1855
- /* @__PURE__ */ e(us, {}),
1856
- /* @__PURE__ */ d("div", { className: "flex", children: [
1857
- /* @__PURE__ */ e("div", { className: "w-full ml-2 mr-4 self-center leading-[0]", children: /* @__PURE__ */ e(
1858
- ms,
1859
- {
1860
- "aria-disabled": s || void 0,
1861
- className: "w-full resize-none outline-none leading-6",
1862
- autoFocus: !s,
1863
- maxRows: 4,
1864
- readOnly: s,
1865
- tabIndex: s ? -1 : void 0
1866
- }
1867
- ) }),
1868
- /* @__PURE__ */ e(
1869
- o,
1870
- {
1871
- sendMessage: n,
1872
- "aria-label": "Send",
1873
- className: "str-chat__send-button mt-auto flex justify-center items-center flex-shrink-0 rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring",
1874
- "data-testid": "send-button",
1875
- disabled: s || !l,
1876
- type: "button"
1877
- }
1878
- )
1879
- ] })
1880
- ] })
1881
- ] });
1882
- }, Bn = ({
1883
- renderActions: t
1884
- }) => {
1885
- var r;
1886
- const { channel: s } = oe(), n = ((r = s == null ? void 0 : s.data) == null ? void 0 : r.frozen) === !0;
1887
- return /* @__PURE__ */ d(
1888
- "div",
1889
- {
1890
- inert: n ? "" : void 0,
1891
- "aria-disabled": n || void 0,
1892
- className: "message-input flex items-center gap-2 p-4 aria-disabled:opacity-40",
1893
- children: [
1894
- t == null ? void 0 : t(),
1895
- /* @__PURE__ */ e(is, { Input: zn })
1896
- ]
1897
- }
1898
- );
1899
- }, $n = [
1900
- "SYSTEM_DM_AGENT_PAUSED",
1901
- "SYSTEM_DM_AGENT_RESUMED"
1902
- ], jn = {
1903
- SYSTEM_DM_AGENT_PAUSED: "DM Agent has left the conversation",
1904
- SYSTEM_DM_AGENT_RESUMED: "DM Agent has rejoined the conversation"
1905
- }, Gn = [
1906
- "SYSTEM_AGE_SAFETY_BLOCKED"
1907
- ], Vn = {
1908
- SYSTEM_AGE_SAFETY_BLOCKED: "This user isn’t able to reply because they don’t meet our age safety guidelines."
1909
- }, Ce = "age safety guidelines.", Hn = "https://linktr.ee/s/about/contact", ct = (t) => $n.includes(t), Yn = (t) => Gn.includes(t), Wn = (t) => {
1910
- var r;
1911
- const s = (r = t.metadata) == null ? void 0 : r.custom_type;
1912
- if (ct(s))
1913
- return {
1914
- kind: "dm-agent",
1915
- type: s
1916
- };
1917
- if (Yn(s))
1918
- return {
1919
- kind: "age-safety",
1920
- type: s
1921
- };
1922
- const n = t.dm_agent_system_type;
1923
- if (ct(n))
1924
- return {
1925
- kind: "dm-agent",
1926
- type: n
1927
- };
1928
- }, qn = (t) => {
1929
- const s = t.indexOf(Ce);
1930
- if (s === -1)
1931
- return t;
1932
- const n = s + Ce.length;
1933
- return /* @__PURE__ */ d(ce, { children: [
1934
- t.slice(0, s),
1935
- /* @__PURE__ */ e(
1936
- "a",
1937
- {
1938
- href: Hn,
1939
- target: "_blank",
1940
- rel: "noopener noreferrer",
1941
- className: "mes-age-safety-system-message__emphasis font-medium text-inherit underline",
1942
- children: Ce
1943
- }
1944
- ),
1945
- t.slice(n)
1946
- ] });
1947
- }, Xn = (t) => {
1948
- var r, o;
1949
- const s = t.message.hide_date === !0, n = Wn(
1950
- t.message
1951
- );
1952
- if ((n == null ? void 0 : n.kind) === "dm-agent") {
1953
- const l = ((r = t.message.text) == null ? void 0 : r.trim()) || jn[n.type];
1954
- return /* @__PURE__ */ d("div", { className: "str-chat__message--system", "data-testid": "message-system", children: [
1955
- /* @__PURE__ */ d(
1956
- "div",
1957
- {
1958
- className: "mes-dm-agent-system-message mx-auto mb-2 inline-flex w-fit max-w-[min(100%,480px)] items-center justify-center gap-[10px] rounded-[12px] border border-[rgba(0,0,0,0.08)] p-3 text-[rgba(0,0,0,0.55)]",
1959
- "data-testid": "dm-agent-system-message",
1960
- "data-dm-agent-system-type": n.type,
1961
- children: [
1962
- /* @__PURE__ */ e(
1963
- ke,
1964
- {
1965
- size: 16,
1966
- weight: "regular",
1967
- "aria-hidden": !0,
1968
- className: "mes-dm-agent-system-message__sparkle shrink-0"
1969
- }
1970
- ),
1971
- /* @__PURE__ */ e("p", { className: "mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]", children: l })
1972
- ]
1973
- }
1974
- ),
1975
- !s && /* @__PURE__ */ e(_e, { message: t.message })
1976
- ] });
1977
- }
1978
- if ((n == null ? void 0 : n.kind) === "age-safety") {
1979
- const l = ((o = t.message.text) == null ? void 0 : o.trim()) || Vn[n.type];
1980
- return /* @__PURE__ */ d("div", { className: "str-chat__message--system", "data-testid": "message-system", children: [
1981
- /* @__PURE__ */ d(
1982
- "div",
1983
- {
1984
- className: "mes-age-safety-system-message box-border mx-auto mb-2 flex w-full max-w-[329px] items-start justify-center gap-3 rounded-[12px] border border-[var(--border-secondary,rgba(0,0,0,0.08))] bg-[var(--bg-warning-subtle,#fef3c6)] px-2 py-4 pl-5 text-[color:var(--text-warning-on-warning,#894b00)]",
1985
- "data-testid": "age-safety-system-message",
1986
- "data-age-safety-system-type": n.type,
1987
- children: [
1988
- /* @__PURE__ */ e(
1989
- Us,
1990
- {
1991
- size: 24,
1992
- weight: "duotone",
1993
- "aria-hidden": !0,
1994
- className: "mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]",
1995
- "data-testid": "age-safety-system-message-icon"
1996
- }
1997
- ),
1998
- /* @__PURE__ */ e("div", { className: "mes-age-safety-system-message__content min-w-0 flex-[1_0_0]", children: /* @__PURE__ */ e("p", { className: "m-0 text-balance text-left text-[12px] font-normal leading-4 tracking-[0.21px] text-[color:var(--text-warning-on-warning,#894b00)]", children: qn(l) }) })
1999
- ]
2000
- }
2001
- ),
2002
- !s && /* @__PURE__ */ e(_e, { message: t.message })
2003
- ] });
2004
- }
2005
- return /* @__PURE__ */ d("div", { className: "str-chat__message--system", "data-testid": "message-system", children: [
2006
- /* @__PURE__ */ d("div", { className: "str-chat__message--system__text", children: [
2007
- /* @__PURE__ */ e("div", { className: "str-chat__message--system__line" }),
2008
- /* @__PURE__ */ e("p", { children: t.message.text }),
2009
- /* @__PURE__ */ e("div", { className: "str-chat__message--system__line" })
2010
- ] }),
2011
- !s && /* @__PURE__ */ e(_e, { message: t.message })
2012
- ] });
2013
- }, Ee = ({ cx: t, index: s }) => /* @__PURE__ */ e("circle", { cx: t, cy: "4", r: "3.9", fill: "#A0A0A0", children: /* @__PURE__ */ e(
2014
- "animateTransform",
2015
- {
2016
- attributeName: "transform",
2017
- type: "translate",
2018
- values: "0 0; 0 -2.25; 0 0;",
2019
- dur: "900ms",
2020
- begin: `${120 * s}ms`,
2021
- repeatCount: "indefinite"
2022
- }
2023
- ) }), Zn = ({ threadList: t }) => {
2024
- var N;
2025
- const { channel: s, channelConfig: n, thread: r } = oe(), { client: o } = De(), { typing: l = {} } = hs();
2026
- if ((n == null ? void 0 : n.typing_events) === !1)
2027
- return null;
2028
- const i = t ? [] : Object.values(l).filter(
2029
- ({ parent_id: b, user: C }) => {
2030
- var x;
2031
- return (C == null ? void 0 : C.id) !== ((x = o.user) == null ? void 0 : x.id) && !b;
2032
- }
2033
- ), c = t ? Object.values(l).filter(
2034
- ({ parent_id: b, user: C }) => {
2035
- var x;
2036
- return (C == null ? void 0 : C.id) !== ((x = o.user) == null ? void 0 : x.id) && b === (r == null ? void 0 : r.id);
2037
- }
2038
- ) : [], m = t ? c : i;
2039
- if (!m.length)
2040
- return null;
2041
- const u = (N = m[0]) == null ? void 0 : N.user, h = u != null && u.id && s.state.members[u.id] ? s.state.members[u.id].user : void 0, f = (u == null ? void 0 : u.id) ?? (h == null ? void 0 : h.id) ?? "typing-user", v = (u == null ? void 0 : u.name) ?? (h == null ? void 0 : h.name) ?? (u == null ? void 0 : u.id) ?? "Typing user", a = (u == null ? void 0 : u.image) ?? (h == null ? void 0 : h.image);
2042
- return /* @__PURE__ */ d(
2043
- "div",
2044
- {
2045
- className: "str-chat__typing-indicator !items-end !bg-transparent",
2046
- "data-testid": "typing-indicator",
2047
- style: { insetInlineStart: 0, insetInlineEnd: "auto" },
2048
- children: [
2049
- /* @__PURE__ */ e("div", { className: "shrink-0", "aria-hidden": "true", children: /* @__PURE__ */ e(
2050
- ne,
2051
- {
2052
- id: f,
2053
- name: v,
2054
- image: a,
2055
- size: 24,
2056
- shape: "circle"
2057
- }
2058
- ) }),
2059
- /* @__PURE__ */ e("div", { className: "px-4 py-3 rounded-lg bg-[#E9EAED] h-12 flex flex-col justify-end", children: /* @__PURE__ */ d(
2060
- "svg",
2061
- {
2062
- "aria-hidden": "true",
2063
- className: "block overflow-visible mb-[0.2rem]",
2064
- viewBox: "0 0 32 8",
2065
- width: "32",
2066
- height: "8",
2067
- overflow: "visible",
2068
- children: [
2069
- /* @__PURE__ */ e(Ee, { cx: "4", index: 0 }),
2070
- /* @__PURE__ */ e(Ee, { cx: "16", index: 1 }),
2071
- /* @__PURE__ */ e(Ee, { cx: "28", index: 2 })
2072
- ]
2073
- }
2074
- ) })
2075
- ]
2076
- }
2077
- );
2078
- }, Jn = () => null, Kn = ({ className: t, message: s }) => /* @__PURE__ */ d(
2079
- "div",
2080
- {
2081
- className: D("flex items-center justify-center h-full", t),
2082
- children: [
2083
- /* @__PURE__ */ d("svg", { viewBox: "0 0 100 100", className: "size-8 fill-pebble", stroke: "none", children: [
2084
- /* @__PURE__ */ e("circle", { cx: "6", cy: "50", r: "6", children: /* @__PURE__ */ e(
2085
- "animateTransform",
2086
- {
2087
- attributeName: "transform",
2088
- dur: "1s",
2089
- type: "translate",
2090
- values: "0 15 ; 0 -15; 0 15",
2091
- repeatCount: "indefinite",
2092
- begin: "0.1"
2093
- }
2094
- ) }),
2095
- /* @__PURE__ */ e("circle", { cx: "30", cy: "50", r: "6", children: /* @__PURE__ */ e(
2096
- "animateTransform",
2097
- {
2098
- attributeName: "transform",
2099
- dur: "1s",
2100
- type: "translate",
2101
- values: "0 10 ; 0 -10; 0 10",
2102
- repeatCount: "indefinite",
2103
- begin: "0.2"
2104
- }
2105
- ) }),
2106
- /* @__PURE__ */ e("circle", { cx: "54", cy: "50", r: "6", children: /* @__PURE__ */ e(
2107
- "animateTransform",
2108
- {
2109
- attributeName: "transform",
2110
- dur: "1s",
2111
- type: "translate",
2112
- values: "0 5 ; 0 -5; 0 5",
2113
- repeatCount: "indefinite",
2114
- begin: "0.3"
2115
- }
2116
- ) })
2117
- ] }),
2118
- s && /* @__PURE__ */ e("span", { className: "text-stone", children: s })
2119
- ]
2120
- }
2121
- ), pe = O.memo(() => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */ d("div", { className: "flex items-center", children: [
2122
- /* @__PURE__ */ e(Kn, { className: "w-6 h-6" }),
2123
- /* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading messages" })
2124
- ] }) }));
2125
- pe.displayName = "LoadingState";
2126
- const le = "size-10 rounded-full bg-[#F1F0EE] hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring", dt = "Replies instantly with AI assistant", Qn = ({
2127
- onBack: t,
2128
- showBackButton: s,
2129
- onShowInfo: n,
2130
- canShowInfo: r,
2131
- showStarButton: o = !1,
2132
- dmAgentEnabled: l = !1
2133
- }) => {
2134
- var v, a, N, b, C;
2135
- const { channel: i } = oe(), c = O.useMemo(() => Object.values(i.state.members || {}).find(
2136
- (I) => {
2137
- var w;
2138
- return ((w = I.user) == null ? void 0 : w.id) && I.user.id !== i._client.userID;
2139
- }
2140
- ), [i._client.userID, i.state.members]), m = ((v = c == null ? void 0 : c.user) == null ? void 0 : v.name) || ((a = c == null ? void 0 : c.user) == null ? void 0 : a.id) || "Unknown member", u = (N = c == null ? void 0 : c.user) == null ? void 0 : N.image, h = _t(i), f = async () => {
2141
- try {
2142
- h ? await i.unpin() : await i.pin();
2143
- } catch (x) {
2144
- console.error(
2145
- "[CustomChannelHeader] Failed to update pinned status:",
2146
- x
2147
- );
2148
- }
2149
- };
2150
- return /* @__PURE__ */ d("div", { className: "@container", children: [
2151
- /* @__PURE__ */ d("div", { className: "grid grid-cols-[1fr_auto_1fr] w-full items-center @lg:hidden", children: [
2152
- /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: s && /* @__PURE__ */ e(
2153
- "button",
2154
- {
2155
- className: le,
2156
- onClick: t || (() => {
2157
- }),
2158
- type: "button",
2159
- "aria-label": "Back to conversations",
2160
- children: /* @__PURE__ */ e(st, { className: "size-5 text-black/90" })
2161
- }
2162
- ) }),
2163
- /* @__PURE__ */ d("div", { className: "flex flex-col gap-1 items-center", children: [
2164
- /* @__PURE__ */ e(
2165
- ne,
2166
- {
2167
- id: ((b = c == null ? void 0 : c.user) == null ? void 0 : b.id) || i.id || "unknown",
2168
- name: m,
2169
- image: u,
2170
- starred: o && h,
2171
- dmAgentEnabled: l,
2172
- size: 40
2173
- }
2174
- ),
2175
- /* @__PURE__ */ d(
2176
- "button",
2177
- {
2178
- type: "button",
2179
- onClick: n,
2180
- className: "flex items-center gap-0.5 rounded-full bg-black/[0.05] px-3 py-1 text-xs font-medium text-black/90 hover:bg-black/[0.08] transition-colors",
2181
- "aria-label": `View info for ${m}`,
2182
- children: [
2183
- m,
2184
- /* @__PURE__ */ e(nt, { className: "size-3 shrink-0" })
2185
- ]
2186
- }
2187
- ),
2188
- l && /* @__PURE__ */ d("div", { className: "flex items-center gap-1 text-[10px] leading-3 text-black/55", children: [
2189
- /* @__PURE__ */ e(ke, { className: "size-3 shrink-0 text-black/55" }),
2190
- /* @__PURE__ */ e("span", { children: dt })
2191
- ] })
2192
- ] }),
2193
- /* @__PURE__ */ d("div", { className: "flex justify-end items-center gap-2", children: [
2194
- o && /* @__PURE__ */ e(
2195
- "button",
2196
- {
2197
- className: le,
2198
- onClick: f,
2199
- type: "button",
2200
- "aria-label": h ? "Unstar conversation" : "Star conversation",
2201
- children: /* @__PURE__ */ e(
2202
- Ie,
2203
- {
2204
- className: D("size-5", {
2205
- "text-yellow-600": h,
2206
- "text-black/90": !h
2207
- }),
2208
- weight: h ? "duotone" : "regular"
2209
- }
2210
- )
2211
- }
2212
- ),
2213
- /* @__PURE__ */ e(
2214
- "button",
2215
- {
2216
- className: le,
2217
- onClick: n,
2218
- type: "button",
2219
- "aria-label": "Show info",
2220
- children: /* @__PURE__ */ e(at, { className: "size-5 text-black/90" })
2221
- }
2222
- )
2223
- ] })
2224
- ] }),
2225
- /* @__PURE__ */ d("div", { className: "hidden @lg:flex items-center justify-between gap-3 min-h-12", children: [
2226
- /* @__PURE__ */ d("div", { className: "flex items-center gap-4 min-w-0", children: [
2227
- s && t && /* @__PURE__ */ e(
2228
- "button",
2229
- {
2230
- type: "button",
2231
- onClick: t,
2232
- className: le,
2233
- "aria-label": "Back to conversations",
2234
- children: /* @__PURE__ */ e(st, { className: "size-5 text-black/90" })
2235
- }
2236
- ),
2237
- /* @__PURE__ */ e(
2238
- ne,
2239
- {
2240
- id: ((C = c == null ? void 0 : c.user) == null ? void 0 : C.id) || i.id || "unknown",
2241
- name: m,
2242
- image: u,
2243
- starred: o && h,
2244
- dmAgentEnabled: l,
2245
- size: 40
2246
- }
2247
- ),
2248
- /* @__PURE__ */ d("div", { className: "min-w-0", children: [
2249
- r ? /* @__PURE__ */ d(
2250
- "button",
2251
- {
2252
- type: "button",
2253
- onClick: n,
2254
- className: "flex items-center gap-1 font-medium text-black/90 truncate hover:text-black/70 transition-colors",
2255
- "aria-label": `View info for ${m}`,
2256
- children: [
2257
- /* @__PURE__ */ e("span", { className: "truncate", children: m }),
2258
- /* @__PURE__ */ e(nt, { className: "size-4 shrink-0" })
2259
- ]
2260
- }
2261
- ) : /* @__PURE__ */ e("h1", { className: "font-medium text-black/90 truncate", children: m }),
2262
- l && /* @__PURE__ */ d("div", { className: "mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55", children: [
2263
- /* @__PURE__ */ e(ke, { className: "size-3 shrink-0 text-black/55" }),
2264
- /* @__PURE__ */ e("span", { className: "truncate", children: dt })
2265
- ] })
2266
- ] })
2267
- ] }),
2268
- /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
2269
- o && /* @__PURE__ */ e(
2270
- "button",
2271
- {
2272
- className: le,
2273
- onClick: f,
2274
- type: "button",
2275
- "aria-label": h ? "Unstar conversation" : "Star conversation",
2276
- children: /* @__PURE__ */ e(
2277
- Ie,
2278
- {
2279
- className: D("size-5", {
2280
- "text-yellow-600": h,
2281
- "text-black/90": !h
2282
- }),
2283
- weight: h ? "duotone" : "regular"
2284
- }
2285
- )
2286
- }
2287
- ),
2288
- r && n && /* @__PURE__ */ e(
2289
- "button",
2290
- {
2291
- className: le,
2292
- onClick: n,
2293
- type: "button",
2294
- "aria-label": "Show info",
2295
- children: /* @__PURE__ */ e(at, { className: "size-5 text-black/90" })
2296
- }
2297
- )
2298
- ] })
2299
- ] })
2300
- ] });
2301
- }, ea = ({
2302
- onBack: t,
2303
- showBackButton: s,
2304
- renderMessageInputActions: n,
2305
- renderConversationFooter: r,
2306
- onLeaveConversation: o,
2307
- onBlockParticipant: l,
2308
- showDeleteConversation: i = !0,
2309
- onDeleteConversationClick: c,
2310
- onBlockParticipantClick: m,
2311
- onReportParticipantClick: u,
2312
- showStarButton: h = !1,
2313
- chatbotVotingEnabled: f = !1,
2314
- renderChannelBanner: v,
2315
- customProfileContent: a,
2316
- customChannelActions: N,
2317
- renderMessage: b,
2318
- dmAgentEnabled: C = !1
2319
- }) => {
2320
- var F, H;
2321
- const { channel: x } = oe(), I = K(null), w = O.useMemo(() => Object.values(x.state.members || {}).find(
2322
- (z) => {
2323
- var S;
2324
- return ((S = z.user) == null ? void 0 : S.id) && z.user.id !== x._client.userID;
2325
- }
2326
- ), [x._client.userID, x.state.members]), E = O.useMemo(() => Object.values(x.state.members || {}).find((z) => {
2327
- var S;
2328
- return ((S = z.user) == null ? void 0 : S.id) === x._client.userID;
2329
- }), [x._client.userID, x.state.members]), P = ((F = E == null ? void 0 : E.user) == null ? void 0 : F.is_account) ?? (E == null ? void 0 : E.is_account), U = ((H = w == null ? void 0 : w.user) == null ? void 0 : H.is_account) ?? (w == null ? void 0 : w.is_account), k = C && P === !1 && U === !0, T = O.useMemo(() => {
2330
- const R = x.data ?? {};
2331
- if (R.followerStatus)
2332
- return String(R.followerStatus);
2333
- if (R.isFollower !== void 0)
2334
- return R.isFollower ? "Subscribed to you" : "Not subscribed";
2335
- }, [x.data]), M = G(() => {
2336
- var R;
2337
- (R = I.current) == null || R.showModal();
2338
- }, []), y = G(() => {
2339
- var R;
2340
- (R = I.current) == null || R.close();
2341
- }, []), _ = G(
2342
- (R) => {
2343
- const { message: z } = gt("ChannelView"), S = /* @__PURE__ */ e(An, { ...R, chatbotVotingEnabled: f });
2344
- return !b || !z ? S : b(S, z);
2345
- },
2346
- [f, b]
2347
- );
2348
- return /* @__PURE__ */ d(ce, { children: [
2349
- /* @__PURE__ */ e(gs, { overrides: { Message: _ }, children: /* @__PURE__ */ d(bs, { children: [
2350
- /* @__PURE__ */ e("div", { className: "p-4", children: /* @__PURE__ */ e(
2351
- Qn,
2352
- {
2353
- onBack: t,
2354
- showBackButton: s,
2355
- onShowInfo: M,
2356
- canShowInfo: !!w,
2357
- showStarButton: h,
2358
- dmAgentEnabled: k
2359
- }
2360
- ) }),
2361
- v == null ? void 0 : v(),
2362
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e(
2363
- ps,
2364
- {
2365
- hideDeletedMessages: !0,
2366
- hideNewMessageSeparator: !1,
2367
- messageActions: void 0
2368
- }
2369
- ) }),
2370
- r == null ? void 0 : r(x),
2371
- /* @__PURE__ */ e(
2372
- Bn,
2373
- {
2374
- renderActions: () => n == null ? void 0 : n(x)
2375
- }
2376
- )
2377
- ] }) }),
2378
- /* @__PURE__ */ e(
2379
- tn,
2380
- {
2381
- dialogRef: I,
2382
- onClose: y,
2383
- participant: w,
2384
- channel: x,
2385
- followerStatusLabel: T,
2386
- onLeaveConversation: o,
2387
- onBlockParticipant: l,
2388
- showDeleteConversation: i,
2389
- onDeleteConversationClick: c,
2390
- onBlockParticipantClick: m,
2391
- onReportParticipantClick: u,
2392
- customProfileContent: a,
2393
- customChannelActions: N
2394
- }
2395
- )
2396
- ] });
2397
- }, Lt = O.memo(
2398
- ({
2399
- channel: t,
2400
- onBack: s,
2401
- showBackButton: n = !1,
2402
- renderMessageInputActions: r,
2403
- renderConversationFooter: o,
2404
- onLeaveConversation: l,
2405
- onBlockParticipant: i,
2406
- className: c,
2407
- CustomChannelEmptyState: m = Jn,
2408
- showDeleteConversation: u = !0,
2409
- onDeleteConversationClick: h,
2410
- onBlockParticipantClick: f,
2411
- onReportParticipantClick: v,
2412
- dmAgentEnabled: a,
2413
- messageMetadata: N,
2414
- onMessageSent: b,
2415
- showStarButton: C = !1,
2416
- chatbotVotingEnabled: x = !1,
2417
- renderChannelBanner: I,
2418
- customProfileContent: w,
2419
- customChannelActions: E,
2420
- renderMessage: P,
2421
- sendButton: U
2422
- }) => {
2423
- const k = G(
2424
- async (T, M, y) => {
2425
- var S;
2426
- const _ = ((S = t.data) == null ? void 0 : S.chatbot_paused) === !0, F = a && !_, H = {
2427
- ...M,
2428
- ...F && { silent: !0 },
2429
- ...N && {
2430
- metadata: {
2431
- ...M.metadata ?? {},
2432
- ...N
2433
- }
2434
- }
2435
- }, R = {
2436
- ...y,
2437
- ...F && { skip_push: !0 }
2438
- }, z = await t.sendMessage(H, R);
2439
- return b == null || b(z), z;
2440
- },
2441
- [t, a, N, b]
2442
- );
2443
- return /* @__PURE__ */ e(
2444
- "div",
2445
- {
2446
- className: D(
2447
- "messaging-channel-view h-full flex flex-col",
2448
- c
2449
- ),
2450
- children: /* @__PURE__ */ e(
2451
- fs,
2452
- {
2453
- channel: t,
2454
- MessageSystem: Xn,
2455
- EmptyStateIndicator: m,
2456
- LoadingIndicator: pe,
2457
- DateSeparator: sn,
2458
- TypingIndicator: Zn,
2459
- doSendMessageRequest: k,
2460
- ...U ? { SendButton: U } : {},
2461
- children: /* @__PURE__ */ e(
2462
- ea,
2463
- {
2464
- onBack: s,
2465
- showBackButton: n,
2466
- renderMessageInputActions: r,
2467
- renderConversationFooter: o,
2468
- onLeaveConversation: l,
2469
- onBlockParticipant: i,
2470
- CustomChannelEmptyState: m,
2471
- showDeleteConversation: u,
2472
- onDeleteConversationClick: h,
2473
- onBlockParticipantClick: f,
2474
- onReportParticipantClick: v,
2475
- showStarButton: C,
2476
- dmAgentEnabled: a,
2477
- chatbotVotingEnabled: x,
2478
- renderChannelBanner: I,
2479
- customProfileContent: w,
2480
- customChannelActions: E,
2481
- renderMessage: P
2482
- }
2483
- )
2484
- }
2485
- )
2486
- }
2487
- );
2488
- }
2489
- );
2490
- Lt.displayName = "ChannelView";
2491
- const ta = ({ className: t }) => /* @__PURE__ */ d(
2492
- "svg",
2493
- {
2494
- width: "140",
2495
- height: "120",
2496
- viewBox: "44 -2 144 126",
2497
- fill: "none",
2498
- xmlns: "http://www.w3.org/2000/svg",
2499
- className: t,
2500
- children: [
2501
- /* @__PURE__ */ d("g", { clipPath: "url(#clip0_empty_state)", children: [
2502
- /* @__PURE__ */ e(
2503
- "path",
2504
- {
2505
- d: "M123.68 82.1932C123.383 103.675 105.839 121 84.2417 121C77.4724 121 71.0986 119.297 65.5327 116.299L52.5873 119.687L53.8036 106.673C48.1776 99.8701 44.7994 91.1453 44.7994 81.6356C44.7994 59.8965 62.4554 42.2754 84.2374 42.2754C89.1328 42.2754 93.8175 43.1633 98.1413 44.789",
2506
- fill: "#D7D4CE"
2507
- }
2508
- ),
2509
- /* @__PURE__ */ e(
2510
- "path",
2511
- {
2512
- d: "M84.2458 86.0364C82.2851 86.0364 80.6957 84.4501 80.6957 82.4933C80.6957 80.5365 82.2851 78.9502 84.2458 78.9502C86.2065 78.9502 87.7959 80.5365 87.7959 82.4933C87.7959 84.4501 86.2065 86.0364 84.2458 86.0364Z",
2513
- fill: "white"
2514
- }
2515
- ),
2516
- /* @__PURE__ */ e(
2517
- "path",
2518
- {
2519
- d: "M68.3044 86.0364C66.3437 86.0364 64.7543 84.4501 64.7543 82.4933C64.7543 80.5365 66.3437 78.9502 68.3044 78.9502C70.2651 78.9502 71.8545 80.5365 71.8545 82.4933C71.8545 84.4501 70.2651 86.0364 68.3044 86.0364Z",
2520
- fill: "white"
2521
- }
2522
- ),
2523
- /* @__PURE__ */ e(
2524
- "path",
2525
- {
2526
- d: "M100.183 86.0364C98.2226 86.0364 96.6332 84.4501 96.6332 82.4933C96.6332 80.5365 98.2226 78.9502 100.183 78.9502C102.144 78.9502 103.733 80.5365 103.733 82.4933C103.733 84.4501 102.144 86.0364 100.183 86.0364Z",
2527
- fill: "white"
2528
- }
2529
- ),
2530
- /* @__PURE__ */ d("g", { filter: "url(#filter0_empty_state)", children: [
2531
- /* @__PURE__ */ e(
2532
- "path",
2533
- {
2534
- d: "M171.522 68.7154C177.443 61.4539 181 52.1488 181 42C181 18.8027 162.421 0 139.5 0C116.579 0 98 18.8027 98 42C98 65.1973 116.579 84 139.5 84C146.622 84 153.328 82.1857 159.184 78.9829L172.801 82.5993L171.522 68.7154Z",
2535
- fill: "white"
2536
- }
2537
- ),
2538
- /* @__PURE__ */ e(
2539
- "path",
2540
- {
2541
- d: "M171.522 68.7154C177.443 61.4539 181 52.1488 181 42C181 18.8027 162.421 0 139.5 0C116.579 0 98 18.8027 98 42C98 65.1973 116.579 84 139.5 84C146.622 84 153.328 82.1857 159.184 78.9829L172.801 82.5993L171.522 68.7154Z",
2542
- stroke: "#D7D4CE",
2543
- strokeWidth: "2",
2544
- strokeMiterlimit: "10"
2545
- }
2546
- )
2547
- ] }),
2548
- /* @__PURE__ */ e(
2549
- "path",
2550
- {
2551
- d: "M139.502 45.5431C137.541 45.5431 135.952 43.9568 135.952 42C135.952 40.0432 137.541 38.4569 139.502 38.4569C141.462 38.4569 143.052 40.0432 143.052 42C143.052 43.9568 141.462 45.5431 139.502 45.5431Z",
2552
- fill: "#D7D4CE"
2553
- }
2554
- ),
2555
- /* @__PURE__ */ e(
2556
- "path",
2557
- {
2558
- d: "M123.561 45.5431C121.601 45.5431 120.011 43.9568 120.011 42C120.011 40.0432 121.601 38.4569 123.561 38.4569C125.522 38.4569 127.111 40.0432 127.111 42C127.111 43.9568 125.522 45.5431 123.561 45.5431Z",
2559
- fill: "#D7D4CE"
2560
- }
2561
- ),
2562
- /* @__PURE__ */ e(
2563
- "path",
2564
- {
2565
- d: "M155.439 45.5431C153.478 45.5431 151.889 43.9568 151.889 42C151.889 40.0432 153.478 38.4569 155.439 38.4569C157.4 38.4569 158.989 40.0432 158.989 42C158.989 43.9568 157.4 45.5431 155.439 45.5431Z",
2566
- fill: "#D7D4CE"
2567
- }
2568
- )
2569
- ] }),
2570
- /* @__PURE__ */ d("defs", { children: [
2571
- /* @__PURE__ */ d(
2572
- "filter",
2573
- {
2574
- id: "filter0_empty_state",
2575
- x: "97",
2576
- y: "-1",
2577
- width: "89",
2578
- height: "90",
2579
- filterUnits: "userSpaceOnUse",
2580
- colorInterpolationFilters: "sRGB",
2581
- children: [
2582
- /* @__PURE__ */ e("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }),
2583
- /* @__PURE__ */ e(
2584
- "feColorMatrix",
2585
- {
2586
- in: "SourceAlpha",
2587
- type: "matrix",
2588
- values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",
2589
- result: "hardAlpha"
2590
- }
2591
- ),
2592
- /* @__PURE__ */ e("feOffset", { dx: "4", dy: "4" }),
2593
- /* @__PURE__ */ e("feComposite", { in2: "hardAlpha", operator: "out" }),
2594
- /* @__PURE__ */ e(
2595
- "feColorMatrix",
2596
- {
2597
- type: "matrix",
2598
- values: "0 0 0 0 0.8428 0 0 0 0 0.830064 0 0 0 0 0.8095 0 0 0 1 0"
2599
- }
2600
- ),
2601
- /* @__PURE__ */ e(
2602
- "feBlend",
2603
- {
2604
- mode: "normal",
2605
- in2: "BackgroundImageFix",
2606
- result: "effect1_dropShadow"
2607
- }
2608
- ),
2609
- /* @__PURE__ */ e(
2610
- "feBlend",
2611
- {
2612
- mode: "normal",
2613
- in: "SourceGraphic",
2614
- in2: "effect1_dropShadow",
2615
- result: "shape"
2616
- }
2617
- )
2618
- ]
2619
- }
2620
- ),
2621
- /* @__PURE__ */ e("clipPath", { id: "clip0_empty_state", children: /* @__PURE__ */ e("rect", { width: "233", height: "233", fill: "white" }) })
2622
- ] })
2623
- ]
2624
- }
2625
- ), At = O.memo(
2626
- ({ hasChannels: t, channelsLoaded: s }) => /* @__PURE__ */ e("div", { className: "messaging-empty-state flex items-center justify-center h-full p-8 text-balance", children: /* @__PURE__ */ d("div", { className: "flex flex-col items-center max-w-sm text-center", children: [
2627
- /* @__PURE__ */ e(ta, {}),
2628
- s && !t && /* @__PURE__ */ d("div", { className: "mt-8", children: [
2629
- /* @__PURE__ */ e("h2", { className: "font-medium text-black text-[18px] mb-2", children: "Your inbox is empty" }),
2630
- /* @__PURE__ */ e("p", { className: "text-[#676B5F] text-sm mb-6", children: "Share with your followers to start receiving messages" })
2631
- ] })
2632
- ] }) })
2633
- );
2634
- At.displayName = "EmptyState";
2635
- const fe = O.memo(({ message: t, onBack: s }) => /* @__PURE__ */ e("div", { className: "messaging-error-state flex items-center justify-center h-full p-8", children: /* @__PURE__ */ d("div", { className: "text-center max-w-sm", children: [
2636
- /* @__PURE__ */ e("div", { className: "w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6", children: /* @__PURE__ */ e("span", { className: "text-4xl", children: "⚠️" }) }),
2637
- /* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal mb-2", children: "Oops!" }),
2638
- /* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t }),
2639
- s && /* @__PURE__ */ e(
2640
- "button",
2641
- {
2642
- type: "button",
2643
- onClick: s,
2644
- className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",
2645
- children: "Go Back"
2646
- }
2647
- )
2648
- ] }) }));
2649
- fe.displayName = "ErrorState";
2650
- const ha = ({
2651
- capabilities: t = {},
2652
- className: s,
2653
- renderMessageInputActions: n,
2654
- renderConversationFooter: r,
2655
- onChannelSelect: o,
2656
- initialParticipantFilter: l,
2657
- initialParticipantData: i,
2658
- CustomChannelEmptyState: c,
2659
- showChannelList: m = !0,
2660
- filters: u,
2661
- channelRenderFilterFn: h,
2662
- channelListCustomEmptyStateIndicator: f,
2663
- onDeleteConversationClick: v,
2664
- onBlockParticipantClick: a,
2665
- onReportParticipantClick: N,
2666
- dmAgentEnabled: b,
2667
- messageMetadata: C,
2668
- onMessageSent: x,
2669
- showStarButton: I = !1,
2670
- chatbotVotingEnabled: w = !1,
2671
- renderMessagePreview: E,
2672
- renderChannelBanner: P,
2673
- customProfileContent: U,
2674
- customChannelActions: k,
2675
- renderMessage: T,
2676
- sendButton: M
2677
- }) => {
2678
- const {
2679
- service: y,
2680
- client: _,
2681
- isConnected: F,
2682
- isLoading: H,
2683
- error: R,
2684
- refreshConnection: z,
2685
- debug: S
2686
- } = zs(), [$, V] = A(null), [ee, te] = A(!1), [W, g] = A(!1), [p, L] = A(!1), [j, Y] = A(null), {
2687
- showDeleteConversation: ae = !0
2688
- } = t, de = O.useMemo(() => {
2689
- const B = _ == null ? void 0 : _.userID;
2690
- return {
2691
- ...{
2692
- type: "messaging",
2693
- last_message_at: { $exists: !0 },
2694
- ...B && {
2695
- members: { $in: [B] },
2696
- hidden: !1
2697
- }
2698
- },
2699
- ...u
2700
- };
2701
- }, [u, _ == null ? void 0 : _.userID]), re = K(null), q = G(async () => {
2702
- if (!_ || !F) return;
2703
- const B = _.userID;
2704
- if (B)
2705
- try {
2706
- S && console.log("[MessagingShell] Syncing channels for user:", B);
2707
- const X = await _.queryChannels(
2708
- {
2709
- type: "messaging",
2710
- members: { $in: [B] }
2711
- },
2712
- {},
2713
- { limit: 100 }
2714
- );
2715
- te(X.length > 0), g(!0), re.current = B, S && console.log("[MessagingShell] Channels synced successfully:", {
2716
- channelCount: X.length
2717
- });
2718
- } catch (X) {
2719
- console.error("[MessagingShell] Failed to sync channels:", X);
2720
- }
2721
- }, [_, F, S]);
2722
- J(() => {
2723
- if (!_ || !F) return;
2724
- const B = _.userID;
2725
- B && re.current !== B && q();
2726
- }, [_, F, q]), J(() => {
2727
- if (!l || !_ || !F) return;
2728
- (async () => {
2729
- const X = _.userID;
2730
- if (X)
2731
- try {
2732
- S && console.log(
2733
- "[MessagingShell] Loading initial conversation with:",
2734
- l
2735
- );
2736
- const Q = await _.queryChannels(
2737
- {
2738
- type: "messaging",
2739
- members: { $eq: [X, l] }
2740
- },
2741
- {},
2742
- { limit: 1 }
2743
- );
2744
- if (Q.length > 0)
2745
- V(Q[0]), L(!0), Y(null), o && o(Q[0]), S && console.log(
2746
- "[MessagingShell] Initial conversation loaded:",
2747
- Q[0].id
2748
- );
2749
- else if (i && y) {
2750
- S && console.log(
2751
- "[MessagingShell] No conversation found, creating one for:",
2752
- i
2753
- );
2754
- try {
2755
- const se = await y.startChannelWithParticipant({
2756
- id: i.id,
2757
- name: i.name,
2758
- email: i.email,
2759
- phone: i.phone
2760
- });
2761
- V(se), L(!0), Y(null), o && o(se), S && console.log(
2762
- "[MessagingShell] Channel created and loaded:",
2763
- se.id
2764
- );
2765
- } catch (se) {
2766
- console.error(
2767
- "[MessagingShell] Failed to create conversation:",
2768
- se
2769
- ), Y("Failed to create conversation");
2770
- }
2771
- } else
2772
- Y(
2773
- "No conversation found with this account"
2774
- ), S && console.log(
2775
- "[MessagingShell] No conversation found for:",
2776
- l
2777
- );
2778
- } catch (Q) {
2779
- console.error(
2780
- "[MessagingShell] Failed to load initial conversation:",
2781
- Q
2782
- ), Y("Failed to load conversation");
2783
- }
2784
- })();
2785
- }, [
2786
- l,
2787
- i,
2788
- _,
2789
- F,
2790
- y,
2791
- S,
2792
- o
2793
- ]);
2794
- const ie = G(
2795
- (B) => {
2796
- V(B), o == null || o(B);
2797
- },
2798
- [o]
2799
- ), ve = G(() => {
2800
- p || V(null);
2801
- }, [p]), ue = G(
2802
- async (B) => {
2803
- S && console.log("[MessagingShell] Leaving conversation:", B.id), V(null), L(!1), re.current = null, await q();
2804
- },
2805
- [q, S]
2806
- ), we = G(
2807
- async (B) => {
2808
- S && console.log("[MessagingShell] Blocking participant:", B), V(null), L(!1), re.current = null, await q();
2809
- },
2810
- [q, S]
2811
- ), Z = !!$;
2812
- return H ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(pe, {}) }) : R ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(fe, { message: R, onBack: z }) }) : !F || !_ ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(
2813
- fe,
2814
- {
2815
- message: "Not connected to messaging service",
2816
- onBack: z
2817
- }
2818
- ) }) : j ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(fe, { message: j }) }) : /* @__PURE__ */ e(
2819
- "div",
2820
- {
2821
- className: D(
2822
- "messaging-shell h-full bg-background-primary overflow-hidden",
2823
- s
2824
- ),
2825
- children: /* @__PURE__ */ d("div", { className: "flex h-full min-h-0", children: [
2826
- /* @__PURE__ */ e(
2827
- "div",
2828
- {
2829
- className: D(
2830
- "messaging-channel-list-sidebar min-h-0 min-w-0 lg:flex lg:flex-col",
2831
- {
2832
- "!hidden": m === !1 || p,
2833
- // Hide on mobile when channel selected, show on desktop with consistent wide width
2834
- "hidden lg:flex lg:flex-1 lg:max-w-2xl": m !== !1 && !p && Z,
2835
- // Show on mobile when no channel selected, use same wide width on desktop
2836
- "flex flex-col w-full lg:flex-1 lg:max-w-2xl": m !== !1 && !p && !Z
2837
- }
2838
- ),
2839
- children: /* @__PURE__ */ e(
2840
- Ct,
2841
- {
2842
- onChannelSelect: ie,
2843
- selectedChannel: $ || void 0,
2844
- filters: de,
2845
- channelRenderFilterFn: h,
2846
- customEmptyStateIndicator: f,
2847
- renderMessagePreview: E
2848
- }
2849
- )
2850
- }
2851
- ),
2852
- /* @__PURE__ */ e(
2853
- "div",
2854
- {
2855
- className: D(
2856
- "messaging-conversation-view flex-1 flex-col min-w-0 min-h-0",
2857
- {
2858
- // In direct conversation mode (or waiting for it), always show (full width)
2859
- flex: p || Z || l,
2860
- // Normal mode: hide on mobile when no channel selected
2861
- "hidden lg:flex": !p && !Z && !l
2862
- }
2863
- ),
2864
- children: $ ? /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 flex flex-col", children: /* @__PURE__ */ e(
2865
- Lt,
2866
- {
2867
- channel: $,
2868
- onBack: ve,
2869
- showBackButton: !p,
2870
- renderMessageInputActions: n,
2871
- renderConversationFooter: r,
2872
- renderChannelBanner: P,
2873
- onLeaveConversation: ue,
2874
- onBlockParticipant: we,
2875
- CustomChannelEmptyState: c,
2876
- showDeleteConversation: ae,
2877
- onDeleteConversationClick: v,
2878
- onBlockParticipantClick: a,
2879
- onReportParticipantClick: N,
2880
- dmAgentEnabled: b,
2881
- messageMetadata: C,
2882
- onMessageSent: x,
2883
- showStarButton: I,
2884
- chatbotVotingEnabled: w,
2885
- customProfileContent: U,
2886
- customChannelActions: k,
2887
- renderMessage: T,
2888
- sendButton: M
2889
- },
2890
- $.id
2891
- ) }) : l ? (
2892
- // Show loading while creating/loading direct conversation channel
2893
- /* @__PURE__ */ e(pe, {})
2894
- ) : /* @__PURE__ */ e(
2895
- At,
2896
- {
2897
- hasChannels: ee,
2898
- channelsLoaded: W
2899
- }
2900
- )
2901
- }
2902
- )
2903
- ] })
2904
- }
2905
- );
2906
- }, sa = ({
2907
- question: t,
2908
- onClick: s,
2909
- loading: n = !1,
2910
- className: r
2911
- }) => /* @__PURE__ */ e(
2912
- "button",
2913
- {
2914
- type: "button",
2915
- onClick: s,
2916
- disabled: n,
2917
- style: { backgroundColor: "#E6E5E3" },
2918
- className: D(
2919
- "w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",
2920
- {
2921
- "hover:brightness-95 active:brightness-90": !n,
2922
- "opacity-50 cursor-not-allowed": n
2923
- },
2924
- r
2925
- ),
2926
- children: t
2927
- }
2928
- ), fa = ({
2929
- faqs: t,
2930
- onFaqClick: s,
2931
- loadingFaqId: n,
2932
- headerText: r,
2933
- className: o,
2934
- avatarImage: l,
2935
- avatarName: i
2936
- }) => {
2937
- const c = t.filter((m) => m.enabled).sort((m, u) => (m.order ?? 0) - (u.order ?? 0));
2938
- return c.length === 0 ? null : /* @__PURE__ */ e("div", { className: o, children: /* @__PURE__ */ d("div", { className: "flex gap-3 items-end", children: [
2939
- (l || i) && /* @__PURE__ */ e("div", { className: "flex-none", children: /* @__PURE__ */ e(
2940
- ne,
2941
- {
2942
- id: i || "account",
2943
- name: i || "Account",
2944
- image: l,
2945
- size: 24,
2946
- shape: "circle"
2947
- }
2948
- ) }),
2949
- /* @__PURE__ */ d(
2950
- "div",
2951
- {
2952
- className: "flex-1 flex flex-col gap-3 rounded-lg p-4",
2953
- style: { backgroundColor: "#F1F0EE" },
2954
- children: [
2955
- r && /* @__PURE__ */ e("p", { className: "text-md text-charcoal mb-4", children: r }),
2956
- c.map((m) => /* @__PURE__ */ e(
2957
- sa,
2958
- {
2959
- question: m.question,
2960
- onClick: () => s(m.id),
2961
- loading: n === m.id
2962
- },
2963
- m.id
2964
- ))
2965
- ]
2966
- }
2967
- )
2968
- ] }) });
2969
- };
2970
- export {
2971
- It as A,
2972
- Jn as C,
2973
- fa as F,
2974
- ot as L,
2975
- ua as M,
2976
- St as a,
2977
- he as b,
2978
- ne as c,
2979
- Ct as d,
2980
- Lt as e,
2981
- ma as f,
2982
- sa as g,
2983
- Dn as h,
2984
- da as i,
2985
- ha as j,
2986
- Vs as k,
2987
- Mt as l,
2988
- Oe as m,
2989
- an as n,
2990
- zs as o,
2991
- Fe as r,
2992
- Tn as u
2993
- };
2994
- //# sourceMappingURL=index-B_PLgcDi.js.map