@linktr.ee/messaging-react 2.3.4 → 2.4.1

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.
Files changed (33) hide show
  1. package/dist/{Card-9X9RSzWd.cjs → Card-C3jo2jEu.cjs} +2 -2
  2. package/dist/{Card-9X9RSzWd.cjs.map → Card-C3jo2jEu.cjs.map} +1 -1
  3. package/dist/{Card-Cmfkr70L.js → Card-Ct_Vj2M-.js} +16 -16
  4. package/dist/{Card-Cmfkr70L.js.map → Card-Ct_Vj2M-.js.map} +1 -1
  5. package/dist/{Card-C-dmAFJG.js → Card-CwnMzWRr.js} +6 -6
  6. package/dist/{Card-C-dmAFJG.js.map → Card-CwnMzWRr.js.map} +1 -1
  7. package/dist/{Card-W7jCeHUe.cjs → Card-D0hMivle.cjs} +2 -2
  8. package/dist/{Card-W7jCeHUe.cjs.map → Card-D0hMivle.cjs.map} +1 -1
  9. package/dist/{Card-a6NQp99K.js → Card-DNlAktyj.js} +19 -19
  10. package/dist/{Card-a6NQp99K.js.map → Card-DNlAktyj.js.map} +1 -1
  11. package/dist/{Card-B0y7S-V2.cjs → Card-d7-NkNG3.cjs} +2 -2
  12. package/dist/{Card-B0y7S-V2.cjs.map → Card-d7-NkNG3.cjs.map} +1 -1
  13. package/dist/{LockedThumbnail-CtZQCl64.cjs → LockedThumbnail-B11obbIY.cjs} +2 -2
  14. package/dist/{LockedThumbnail-CtZQCl64.cjs.map → LockedThumbnail-B11obbIY.cjs.map} +1 -1
  15. package/dist/{LockedThumbnail-DPVq7iJu.js → LockedThumbnail-CY115EyU.js} +8 -8
  16. package/dist/{LockedThumbnail-DPVq7iJu.js.map → LockedThumbnail-CY115EyU.js.map} +1 -1
  17. package/dist/index-CBceLyrt.cjs +2 -0
  18. package/dist/index-CBceLyrt.cjs.map +1 -0
  19. package/dist/index-CeHWbIiy.js +4733 -0
  20. package/dist/index-CeHWbIiy.js.map +1 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.ts +17 -1
  23. package/dist/index.js +1 -1
  24. package/package.json +1 -1
  25. package/src/components/ChannelView.test.tsx +32 -0
  26. package/src/components/ChannelView.tsx +17 -1
  27. package/src/components/MessagingShell/index.tsx +2 -0
  28. package/src/index.ts +1 -0
  29. package/src/types.ts +18 -0
  30. package/dist/index-BfCt0dJa.js +0 -8128
  31. package/dist/index-BfCt0dJa.js.map +0 -1
  32. package/dist/index-C0RXJhLE.cjs +0 -18
  33. package/dist/index-C0RXJhLE.cjs.map +0 -1
@@ -0,0 +1,4733 @@
1
+ import { jsx as n, jsxs as m, Fragment as ie } from "react/jsx-runtime";
2
+ import y from "classnames";
3
+ import P, { createContext as Ze, useContext as Ke, useCallback as U, useState as z, useRef as Z, useEffect as X, useMemo as re, Suspense as Je } from "react";
4
+ import { StreamChatService as En } from "@linktr.ee/messaging-core";
5
+ import { Chat as In, ChannelList as Sn, DateSeparator as Tn, useChannelStateContext as me, useChatContext as Qe, areMessageUIPropsEqual as Mn, useMessageReminder as An, useComponentContext as Vt, Attachment as Dn, EditMessageModal as Rn, MessageBlocked as Ln, MessageBouncePrompt as Fn, MessageDeleted as On, MessageIsThreadReplyInChannelButtonIndicator as zn, MessageRepliesCountButton as Pn, ReminderNotification as Bn, StreamedMessageText as $n, messageHasAttachments as jn, messageHasReactions as Un, isDateSeparatorMessage as Vn, isMessageBlocked as Gn, isMessageBounced as Hn, MessageBounceModal as Yn, MessageText as At, Poll as Wn, MessageErrorIcon as qn, useMessageContext as Le, useTranslationContext as Xn, useMessageComposer as Zn, useStateStore as Kn, MessageInput as Jn, useMessageInputContext as Qn, useMessageComposerHasSendableData as es, SimpleAttachmentSelector as ts, QuotedMessagePreview as ns, AttachmentPreviewList as ss, TextareaComposer as as, MessageTimestamp as ze, AIStates as Pe, useTypingContext as rs, useAIState as is, Channel as os, WithComponents as ls, Window as cs, MessageList as ds } from "stream-chat-react";
6
+ import { StarIcon as Ge, GiftIcon as us, XIcon as xe, SpinnerGapIcon as Be, SignOutIcon as ms, ProhibitInsetIcon as Dt, FlagIcon as hs, FileIcon as Gt, ImageIcon as fs, SpeakerHighIcon as gs, VideoCameraIcon as Ht, FileMdIcon as bs, FileTextIcon as ps, FileZipIcon as vs, FilePptIcon as xs, FileCsvIcon as ws, FileXlsIcon as Ns, FileDocIcon as ys, FilePdfIcon as _s, CircleNotchIcon as pe, PlayIcon as He, PauseIcon as Cs, LinkIcon as ks, DownloadSimpleIcon as ve, ThumbsUpIcon as Es, ThumbsDownIcon as Is, ArrowUpIcon as Ss, SparkleIcon as Ye, ProhibitIcon as Ts, ArrowLeftIcon as Rt, CaretRightIcon as We, DotsThreeIcon as Lt, PencilSimpleIcon as Ms, CaretLeftIcon as As } from "@phosphor-icons/react";
7
+ import { MessageActions as Ds, DefaultDropdownActionButton as Yt } from "stream-chat-react/experimental";
8
+ import { LinkPreviewsManager as Ft } from "stream-chat";
9
+ const Wt = Ze({
10
+ service: null,
11
+ client: null,
12
+ isConnected: !1,
13
+ isLoading: !1,
14
+ error: null,
15
+ capabilities: {},
16
+ refreshConnection: async () => {
17
+ },
18
+ debug: !1
19
+ }), et = () => Ke(Wt), yi = ({
20
+ children: e,
21
+ user: t,
22
+ serviceConfig: s,
23
+ apiKey: a,
24
+ capabilities: r = {},
25
+ debug: i = !1
26
+ }) => {
27
+ const l = U(
28
+ (T, ...F) => {
29
+ i && console.log(`🔥 [MessagingProvider] ${T}`, ...F);
30
+ },
31
+ [i]
32
+ );
33
+ l("🔄 RENDER START", {
34
+ userId: t == null ? void 0 : t.id,
35
+ apiKey: (a == null ? void 0 : a.substring(0, 8)) + "...",
36
+ serviceConfig: !!s,
37
+ capabilities: Object.keys(r)
38
+ });
39
+ const [o, d] = z(null), [h, g] = z(null), [u, f] = z(!1), [c, b] = z(!1), [x, v] = z(null), N = Z(!1), w = Z({
40
+ userId: t == null ? void 0 : t.id,
41
+ apiKey: a,
42
+ serviceConfig: s,
43
+ capabilities: r
44
+ }), E = Z(0);
45
+ E.current++, l("📊 RENDER INFO", {
46
+ renderCount: E.current,
47
+ currentProps: { userId: t == null ? void 0 : t.id, apiKey: (a == null ? void 0 : a.substring(0, 8)) + "..." },
48
+ propChanges: {
49
+ userChanged: w.current.userId !== (t == null ? void 0 : t.id),
50
+ apiKeyChanged: w.current.apiKey !== a,
51
+ serviceConfigChanged: w.current.serviceConfig !== s,
52
+ capabilitiesChanged: w.current.capabilities !== r
53
+ }
54
+ }), w.current = {
55
+ userId: t == null ? void 0 : t.id,
56
+ apiKey: a,
57
+ serviceConfig: s,
58
+ capabilities: r
59
+ }, X(() => {
60
+ const T = E.current;
61
+ if (l("🔧 SERVICE INIT EFFECT TRIGGERED", {
62
+ renderCount: T,
63
+ apiKey: !!a,
64
+ serviceConfig: !!s,
65
+ dependencies: {
66
+ apiKey: (a == null ? void 0 : a.substring(0, 8)) + "...",
67
+ serviceConfigRef: s,
68
+ serviceConfigStable: w.current.serviceConfig === s,
69
+ apiKeyStable: w.current.apiKey === a
70
+ }
71
+ }), !a || !s) {
72
+ l("⚠️ SERVICE INIT SKIPPED", {
73
+ renderCount: T,
74
+ reason: "Missing apiKey or serviceConfig"
75
+ });
76
+ return;
77
+ }
78
+ l("🚀 CREATING NEW SERVICE", {
79
+ renderCount: T,
80
+ apiKey: (a == null ? void 0 : a.substring(0, 8)) + "...",
81
+ serviceConfigChanged: w.current.serviceConfig !== s
82
+ });
83
+ const F = new En({
84
+ ...s,
85
+ apiKey: a,
86
+ debug: i
87
+ });
88
+ return d(F), l("✅ SERVICE SET", {
89
+ renderCount: T,
90
+ serviceInstance: !!F
91
+ }), () => {
92
+ l("🧹 SERVICE CLEANUP", {
93
+ renderCount: T,
94
+ reason: "Effect cleanup"
95
+ }), F.disconnectUser().catch(console.error);
96
+ };
97
+ }, [a, s, i, l]);
98
+ const I = Z(null);
99
+ X(() => {
100
+ var F, M;
101
+ if (l("🔗 USER CONNECTION EFFECT TRIGGERED", {
102
+ hasService: !!o,
103
+ hasUser: !!t,
104
+ userId: t == null ? void 0 : t.id,
105
+ isConnecting: N.current,
106
+ isConnected: u,
107
+ dependencies: { service: !!o, userId: t == null ? void 0 : t.id }
108
+ }), !o || !t) {
109
+ l("⚠️ USER CONNECTION SKIPPED", "Missing service or user");
110
+ return;
111
+ }
112
+ if (N.current) {
113
+ l("⚠️ USER CONNECTION SKIPPED", "Already connecting");
114
+ return;
115
+ }
116
+ if (((F = I.current) == null ? void 0 : F.serviceId) === o && ((M = I.current) == null ? void 0 : M.userId) === t.id) {
117
+ l(
118
+ "⚠️ USER CONNECTION SKIPPED",
119
+ "Already connected this user with this service"
120
+ );
121
+ return;
122
+ }
123
+ (async () => {
124
+ l("🚀 STARTING USER CONNECTION", { userId: t.id }), N.current = !0, b(!0), v(null);
125
+ try {
126
+ l("📞 CALLING SERVICE.CONNECTUSER", { userId: t.id });
127
+ const R = await o.connectUser(t);
128
+ g(R), f(!0), I.current = { serviceId: o, userId: t.id }, l("✅ USER CONNECTION SUCCESS", {
129
+ userId: t.id,
130
+ clientId: R.userID
131
+ });
132
+ } catch (R) {
133
+ const A = R instanceof Error ? R.message : "Connection failed";
134
+ v(A), l("❌ USER CONNECTION ERROR", {
135
+ userId: t.id,
136
+ error: A
137
+ });
138
+ } finally {
139
+ b(!1), N.current = !1, l("🔄 USER CONNECTION FINISHED", {
140
+ userId: t.id,
141
+ isConnected: u
142
+ });
143
+ }
144
+ })();
145
+ }, [o, t, l, u]), X(() => (l("🔌 CLEANUP EFFECT REGISTERED", {
146
+ hasService: !!o,
147
+ isConnected: u
148
+ }), () => {
149
+ o && u ? (l(
150
+ "🧹 CLEANUP EFFECT TRIGGERED",
151
+ "Cleaning up connection on unmount"
152
+ ), I.current = null, o.disconnectUser().catch(console.error)) : l("🔇 CLEANUP EFFECT SKIPPED", {
153
+ hasService: !!o,
154
+ isConnected: u
155
+ });
156
+ }), [o, u, l]);
157
+ const S = U(async () => {
158
+ if (l("🔄 REFRESH CONNECTION CALLED", {
159
+ hasService: !!o,
160
+ hasUser: !!t
161
+ }), !o || !t) {
162
+ l("⚠️ REFRESH CONNECTION SKIPPED", "Missing service or user");
163
+ return;
164
+ }
165
+ l("🚀 STARTING CONNECTION REFRESH", { userId: t.id }), b(!0);
166
+ try {
167
+ l("🔌 DISCONNECTING FOR REFRESH"), await o.disconnectUser(), l("📞 RECONNECTING FOR REFRESH");
168
+ const T = await o.connectUser(t);
169
+ g(T), f(!0), v(null), l("✅ CONNECTION REFRESH SUCCESS", { userId: t.id });
170
+ } catch (T) {
171
+ const F = T instanceof Error ? T.message : "Refresh failed";
172
+ v(F), l("❌ CONNECTION REFRESH ERROR", {
173
+ userId: t.id,
174
+ error: F
175
+ });
176
+ } finally {
177
+ b(!1), l("🔄 CONNECTION REFRESH FINISHED", { userId: t.id });
178
+ }
179
+ }, [o, t, l]), D = P.useMemo(() => (l("💫 CONTEXT VALUE MEMOIZATION", {
180
+ hasService: !!o,
181
+ hasClient: !!h,
182
+ isConnected: u,
183
+ isLoading: c,
184
+ hasError: !!x,
185
+ capabilitiesKeys: Object.keys(r)
186
+ }), {
187
+ service: o,
188
+ client: h,
189
+ isConnected: u,
190
+ isLoading: c,
191
+ error: x,
192
+ capabilities: r,
193
+ refreshConnection: S,
194
+ debug: i
195
+ }), [
196
+ o,
197
+ h,
198
+ u,
199
+ c,
200
+ x,
201
+ r,
202
+ S,
203
+ i,
204
+ l
205
+ ]);
206
+ return l("🔄 RENDER END", {
207
+ renderCount: E.current,
208
+ willRenderChat: !!(h && u),
209
+ contextValueReady: !!D
210
+ }), /* @__PURE__ */ n(Wt.Provider, { value: D, children: h && u ? /* @__PURE__ */ n(
211
+ In,
212
+ {
213
+ client: h,
214
+ customClasses: {
215
+ channelList: "str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"
216
+ },
217
+ children: e
218
+ }
219
+ ) : e });
220
+ }, Rs = () => et();
221
+ function Ls(e) {
222
+ const t = e.state.pending_messages;
223
+ if (t != null && t.length)
224
+ for (const s of t)
225
+ e.state.addMessageSorted(s.message);
226
+ }
227
+ const qt = P.createContext({
228
+ selectedChannel: void 0,
229
+ onChannelSelect: () => {
230
+ },
231
+ debug: !1,
232
+ renderMessagePreview: void 0,
233
+ viewerLanguage: void 0
234
+ }), Fs = qt.Provider, Os = () => P.useContext(qt), Xt = (e) => {
235
+ var a, r;
236
+ const [t, s] = z(
237
+ !!((r = (a = e == null ? void 0 : e.state) == null ? void 0 : a.membership) != null && r.pinned_at)
238
+ );
239
+ return X(() => {
240
+ var l;
241
+ if (!e) {
242
+ s(!1);
243
+ return;
244
+ }
245
+ s(!!((l = e.state.membership) != null && l.pinned_at));
246
+ const i = (o) => {
247
+ var d;
248
+ s(
249
+ o != null && o.member ? !!o.member.pinned_at : !!((d = e.state.membership) != null && d.pinned_at)
250
+ );
251
+ };
252
+ return e.on("member.updated", i), () => {
253
+ e.off("member.updated", i);
254
+ };
255
+ }, [e]), t;
256
+ }, zs = (e, t) => {
257
+ const s = new Date(
258
+ Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate())
259
+ ), r = new Date(
260
+ Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate())
261
+ ).getTime() - s.getTime();
262
+ return Math.floor(r / (1e3 * 60 * 60 * 24));
263
+ }, Ps = (e) => {
264
+ const t = /* @__PURE__ */ new Date();
265
+ if (Math.floor((t.getTime() - e.getTime()) / 1e3) < 60)
266
+ return "Just now";
267
+ const a = zs(e, t);
268
+ return a === 0 ? e.toLocaleTimeString([], {
269
+ hour: "numeric",
270
+ minute: "2-digit",
271
+ hour12: !0
272
+ }) : a === 1 ? "Yesterday" : a < 7 ? `${a}d` : a < 28 ? `${Math.floor(a / 7)}w` : e.toLocaleDateString("en-US", {
273
+ month: "numeric",
274
+ day: "numeric",
275
+ year: "2-digit"
276
+ });
277
+ };
278
+ function Bs(e) {
279
+ return (e == null ? void 0 : e.trim().toLowerCase().split(/[-_]/)[0]) || void 0;
280
+ }
281
+ function Zt({
282
+ message: e,
283
+ viewerLanguage: t
284
+ }) {
285
+ var r;
286
+ const s = e == null ? void 0 : e.text, a = Bs(t);
287
+ return a ? ((r = e == null ? void 0 : e.i18n) == null ? void 0 : r[`${a}_text`]) ?? s : s;
288
+ }
289
+ const $s = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
290
+ function js(e) {
291
+ return $s.test(e.trim());
292
+ }
293
+ function Ot(e, t) {
294
+ const s = e == null ? void 0 : e.trim();
295
+ return !s || t && s === t ? !1 : !js(s);
296
+ }
297
+ function tt(e) {
298
+ return Ot(e == null ? void 0 : e.name, e == null ? void 0 : e.id) ? e.name.trim() : Ot(e == null ? void 0 : e.username, e == null ? void 0 : e.id) ? e.username.trim() : "Unknown member";
299
+ }
300
+ const zt = [
301
+ "🍎",
302
+ // Apple
303
+ "🍌",
304
+ // Banana
305
+ "🍇",
306
+ // Grape
307
+ "🍊",
308
+ // Orange
309
+ "🍓",
310
+ // Strawberry
311
+ "🥥",
312
+ // Coconut
313
+ "🍒",
314
+ // Cherry
315
+ "🥭",
316
+ // Mango
317
+ "🍉",
318
+ // Watermelon
319
+ "🍋",
320
+ // Lemon
321
+ "🥝",
322
+ // Kiwi
323
+ "🫒",
324
+ // Olive
325
+ "🍈"
326
+ // Melon
327
+ ];
328
+ function Us(e) {
329
+ let t = 0;
330
+ for (let s = 0; s < e.length; s++) {
331
+ const a = e.charCodeAt(s);
332
+ t = (t << 5) - t + a, t = t & t;
333
+ }
334
+ return Math.abs(t);
335
+ }
336
+ function Vs(e) {
337
+ const s = Us(e) % zt.length;
338
+ return zt[s];
339
+ }
340
+ const oe = ({
341
+ id: e,
342
+ image: t,
343
+ size: s = 40,
344
+ className: a,
345
+ starred: r = !1,
346
+ shape: i = "squircle",
347
+ dmAgentEnabled: l = !1
348
+ }) => {
349
+ const o = Vs(e), h = s < 32 ? "text-xs" : s < 56 ? "text-sm" : s < 120 ? "text-lg" : "text-4xl", g = s >= 40 ? 2 : 1, u = i === "circle" ? { borderRadius: "50%" } : {
350
+ borderRadius: "33%",
351
+ cornerShape: "superellipse(1.3)"
352
+ }, f = /* @__PURE__ */ n("div", { className: "h-full w-full overflow-hidden", style: u, children: t ? /* @__PURE__ */ n(
353
+ "img",
354
+ {
355
+ src: t,
356
+ alt: "",
357
+ className: "h-full w-full object-cover"
358
+ }
359
+ ) : /* @__PURE__ */ n(
360
+ "div",
361
+ {
362
+ "aria-hidden": "true",
363
+ className: y(
364
+ "avatar-fallback flex h-full w-full items-center justify-center bg-[#E6E5E3] font-semibold select-none transition-colors",
365
+ h
366
+ ),
367
+ children: o
368
+ }
369
+ ) });
370
+ return /* @__PURE__ */ m(
371
+ "div",
372
+ {
373
+ className: y(
374
+ "relative flex-shrink-0 !bg-transparent",
375
+ a
376
+ ),
377
+ style: {
378
+ "--str-chat__avatar-size": `${s}px`,
379
+ width: `${s}px`,
380
+ height: `${s}px`
381
+ },
382
+ children: [
383
+ r && /* @__PURE__ */ n(
384
+ "div",
385
+ {
386
+ "aria-hidden": "true",
387
+ 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)]",
388
+ children: /* @__PURE__ */ n(Ge, { className: "size-3 text-yellow-600", weight: "duotone" })
389
+ }
390
+ ),
391
+ /* @__PURE__ */ n(
392
+ "div",
393
+ {
394
+ "data-testid": "avatar-ring",
395
+ className: y(
396
+ "h-full w-full",
397
+ "bg-transparent"
398
+ ),
399
+ style: {
400
+ ...u,
401
+ ...l && {
402
+ borderWidth: `${g}px`,
403
+ borderStyle: "solid",
404
+ borderColor: "var(--AI-Gradient, #7F22FE)",
405
+ boxShadow: "inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"
406
+ }
407
+ },
408
+ children: f
409
+ }
410
+ )
411
+ ]
412
+ }
413
+ );
414
+ }, Gs = ({ size: e = 15 }) => /* @__PURE__ */ n(
415
+ "svg",
416
+ {
417
+ width: e,
418
+ height: e,
419
+ viewBox: "0 0 15 15",
420
+ fill: "none",
421
+ "aria-hidden": "true",
422
+ children: /* @__PURE__ */ n(
423
+ "path",
424
+ {
425
+ 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",
426
+ fill: "currentColor",
427
+ fillOpacity: 0.55
428
+ }
429
+ )
430
+ }
431
+ ), Hs = (e) => {
432
+ var t;
433
+ return ((t = e.metadata) == null ? void 0 : t.custom_type) === "MESSAGE_TIP";
434
+ }, Ys = (e) => {
435
+ var t;
436
+ return ((t = e.metadata) == null ? void 0 : t.custom_type) === "MESSAGE_PAID";
437
+ }, Me = (e) => {
438
+ var t;
439
+ return ((t = e.metadata) == null ? void 0 : t.custom_type) === "MESSAGE_CHATBOT";
440
+ }, Ws = (e) => {
441
+ var t;
442
+ return ((t = e.metadata) == null ? void 0 : t.custom_type) === "MESSAGE_ATTACHMENT";
443
+ }, Kt = (e) => Hs(e) || Ys(e), qs = (e) => {
444
+ var t;
445
+ return Kt(e) && !((t = e.text) != null && t.trim());
446
+ }, $e = ({
447
+ message: e,
448
+ standalone: t = !1,
449
+ isMyMessage: s = !1,
450
+ hasAttachment: a = !1
451
+ }) => {
452
+ var u;
453
+ const r = Kt(e), i = Me(e);
454
+ if (!r && !i)
455
+ return null;
456
+ if (r) {
457
+ const f = (u = e.metadata) == null ? void 0 : u.amount_text;
458
+ if (!f) return null;
459
+ const c = t ? "message-tip-standalone" : "message-tag message-tag--tip", b = t ? `${f} tip` : `Delivered with ${f} tip`;
460
+ return /* @__PURE__ */ m("div", { className: c, children: [
461
+ /* @__PURE__ */ n(us, { size: t ? 14 : 12 }),
462
+ /* @__PURE__ */ n("span", { children: b })
463
+ ] });
464
+ }
465
+ const l = s && a, o = l ? "Sent with AI" : "Sent with DM Agent", d = [
466
+ "message-chatbot-indicator",
467
+ s ? "message-chatbot-indicator--sender" : "message-chatbot-indicator--receiver",
468
+ l ? "message-chatbot-indicator--attachment" : "message-chatbot-indicator--text"
469
+ ].join(" "), h = /* @__PURE__ */ n("span", { className: "message-chatbot-indicator__label", children: o }), g = /* @__PURE__ */ n("span", { className: "message-chatbot-indicator__icon", children: /* @__PURE__ */ n(Gs, { size: l ? 12 : 15 }) });
470
+ return /* @__PURE__ */ n("div", { className: d, "data-testid": "message-chatbot-indicator", children: s && !l ? /* @__PURE__ */ m(ie, { children: [
471
+ h,
472
+ g
473
+ ] }) : /* @__PURE__ */ m(ie, { children: [
474
+ g,
475
+ h
476
+ ] }) });
477
+ }, Jt = P.memo(
478
+ ({ channel: e, unread: t }) => {
479
+ var D, T, F;
480
+ const {
481
+ selectedChannel: s,
482
+ onChannelSelect: a,
483
+ debug: r,
484
+ renderMessagePreview: i,
485
+ viewerLanguage: l
486
+ } = Os(), o = (s == null ? void 0 : s.id) === (e == null ? void 0 : e.id), d = () => {
487
+ e && a(e);
488
+ }, h = (M) => {
489
+ const R = M.key === "Enter" || M.key === " ", A = M.repeat;
490
+ !R || A || (M.preventDefault(), d());
491
+ }, u = Object.values(((D = e == null ? void 0 : e.state) == null ? void 0 : D.members) || {}).find(
492
+ (M) => {
493
+ var R, A;
494
+ return ((R = M.user) == null ? void 0 : R.id) && M.user.id !== ((A = e == null ? void 0 : e._client) == null ? void 0 : A.userID);
495
+ }
496
+ ), f = tt(u == null ? void 0 : u.user), c = (T = u == null ? void 0 : u.user) == null ? void 0 : T.image, b = (() => {
497
+ var R;
498
+ const M = (R = e == null ? void 0 : e.state) == null ? void 0 : R.messages;
499
+ if (M != null && M.length) {
500
+ for (let A = M.length - 1; A >= 0; A--)
501
+ if (M[A].type !== "system") return M[A];
502
+ }
503
+ })(), v = (() => {
504
+ var G, k;
505
+ const M = Zt({
506
+ message: b,
507
+ viewerLanguage: l
508
+ });
509
+ if (M) return M;
510
+ if (((G = b == null ? void 0 : b.metadata) == null ? void 0 : G.custom_type) === "MESSAGE_TIP") return "💵 Sent a tip";
511
+ const A = (k = b == null ? void 0 : b.attachments) == null ? void 0 : k[0];
512
+ return A ? A.og_scrape_url ? A.og_scrape_url : A.type === "image" ? "📷 Sent an image" : A.type === "video" ? "🎥 Sent a video" : A.type === "audio" ? "🎵 Sent audio" : A.type === "file" ? "📎 Sent a file" : "📎 Sent an attachment" : "No messages yet";
513
+ })(), N = b != null && b.created_at ? Ps(new Date(b.created_at)) : "", w = b ? Me(b) : !1, E = i ? i(b, v) : `${w ? "✨ " : ""}${v}`, I = Xt(e), S = t ?? 0;
514
+ return r && console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER", {
515
+ channelId: e == null ? void 0 : e.id,
516
+ isSelected: o,
517
+ participantName: f,
518
+ unreadCount: S,
519
+ hasTimestamp: !!N
520
+ }), /* @__PURE__ */ n(
521
+ "div",
522
+ {
523
+ role: "button",
524
+ tabIndex: 0,
525
+ onClick: d,
526
+ onKeyDown: h,
527
+ className: y(
528
+ "group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring",
529
+ {
530
+ "bg-primary-alt/10 border-l-4 border-l-primary": o,
531
+ "hover:bg-sand": !o
532
+ }
533
+ ),
534
+ children: /* @__PURE__ */ m("div", { className: "flex items-start gap-3", children: [
535
+ /* @__PURE__ */ n(
536
+ oe,
537
+ {
538
+ id: ((F = u == null ? void 0 : u.user) == null ? void 0 : F.id) || e.id || "unknown",
539
+ name: f,
540
+ image: c,
541
+ size: 44,
542
+ starred: I,
543
+ className: "[&_.avatar-fallback]:group-hover:bg-[#eeeeee]"
544
+ }
545
+ ),
546
+ /* @__PURE__ */ m("div", { className: "flex-1 min-w-0 flex flex-col gap-1", children: [
547
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between gap-2", children: [
548
+ /* @__PURE__ */ m(
549
+ "h3",
550
+ {
551
+ className: y(
552
+ "text-sm font-medium truncate",
553
+ o ? "text-primary" : "text-charcoal"
554
+ ),
555
+ children: [
556
+ I && /* @__PURE__ */ n("span", { className: "sr-only", children: "Starred conversation. " }),
557
+ f
558
+ ]
559
+ }
560
+ ),
561
+ N && /* @__PURE__ */ n("span", { className: "text-xs text-stone flex-shrink-0", children: N })
562
+ ] }),
563
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between gap-2 min-w-0", children: [
564
+ /* @__PURE__ */ n("p", { className: "text-xs text-stone flex-1 line-clamp-1", children: E }),
565
+ S > 0 && /* @__PURE__ */ n("span", { className: "bg-[#7f22fe] text-white text-xs px-2 py-0.5 rounded-full min-w-[20px] text-center flex-shrink-0", children: S > 99 ? "99+" : S })
566
+ ] })
567
+ ] })
568
+ ] })
569
+ }
570
+ );
571
+ }
572
+ );
573
+ Jt.displayName = "CustomChannelPreview";
574
+ const Xs = { last_message_at: -1 }, Qt = P.memo(
575
+ ({
576
+ onChannelSelect: e,
577
+ selectedChannel: t,
578
+ filters: s,
579
+ allowNewMessagesFromUnfilteredChannels: a = !1,
580
+ onMessageNew: r,
581
+ onAddedToChannel: i,
582
+ channelRenderFilterFn: l,
583
+ sort: o = Xs,
584
+ className: d,
585
+ customEmptyStateIndicator: h,
586
+ renderMessagePreview: g,
587
+ viewerLanguage: u
588
+ }) => {
589
+ const f = P.useRef(0);
590
+ f.current++;
591
+ const { debug: c = !1 } = et(), b = P.useCallback(
592
+ (v) => {
593
+ for (const N of v)
594
+ Ls(N);
595
+ return l ? l(v) : v;
596
+ },
597
+ [l]
598
+ );
599
+ c && console.log("📺 [ChannelList] 🔄 RENDER START", {
600
+ renderCount: f.current,
601
+ selectedChannelId: t == null ? void 0 : t.id,
602
+ filters: s
603
+ });
604
+ const x = P.useMemo(
605
+ () => ({
606
+ selectedChannel: t,
607
+ onChannelSelect: e,
608
+ debug: c,
609
+ renderMessagePreview: g,
610
+ viewerLanguage: u
611
+ }),
612
+ [
613
+ t,
614
+ e,
615
+ c,
616
+ g,
617
+ u
618
+ ]
619
+ );
620
+ return /* @__PURE__ */ n(
621
+ "div",
622
+ {
623
+ className: y(
624
+ "messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",
625
+ d
626
+ ),
627
+ children: /* @__PURE__ */ n("div", { className: "flex-1 overflow-hidden min-w-0", children: /* @__PURE__ */ n(Fs, { value: x, children: /* @__PURE__ */ n(
628
+ Sn,
629
+ {
630
+ filters: s,
631
+ sort: o,
632
+ options: { limit: 30 },
633
+ allowNewMessagesFromUnfilteredChannels: a,
634
+ onMessageNew: r,
635
+ onAddedToChannel: i,
636
+ channelRenderFilterFn: b,
637
+ Preview: Jt,
638
+ EmptyStateIndicator: h
639
+ },
640
+ `${JSON.stringify(s)}:${JSON.stringify(o)}`
641
+ ) }) })
642
+ }
643
+ );
644
+ }
645
+ );
646
+ Qt.displayName = "ChannelList";
647
+ const Se = ({
648
+ variant: e = "default",
649
+ className: t,
650
+ children: s,
651
+ ...a
652
+ }) => /* @__PURE__ */ n(
653
+ "button",
654
+ {
655
+ type: "button",
656
+ className: y(
657
+ "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",
658
+ e === "danger" ? "text-danger hover:bg-danger/50" : "text-charcoal hover:bg-sand",
659
+ t
660
+ ),
661
+ ...a,
662
+ children: s
663
+ }
664
+ );
665
+ function Zs({ label: e, className: t, children: s, ...a }) {
666
+ return /* @__PURE__ */ m(
667
+ "button",
668
+ {
669
+ type: "button",
670
+ className: y(
671
+ "inline-flex items-center justify-center rounded-full transition-colors focus-ring p-2",
672
+ {
673
+ "cursor-not-allowed opacity-50": a.disabled,
674
+ "hover:bg-sand": !a.disabled
675
+ },
676
+ t
677
+ ),
678
+ ...a,
679
+ children: [
680
+ /* @__PURE__ */ n("span", { className: "sr-only", children: e }),
681
+ s
682
+ ]
683
+ }
684
+ );
685
+ }
686
+ function Ks({ onClick: e }) {
687
+ return /* @__PURE__ */ n(Zs, { label: "Close", onClick: e, className: "p-1", children: /* @__PURE__ */ n(xe, { className: "h-5 w-5 text-stone", weight: "bold" }) });
688
+ }
689
+ const Js = ({
690
+ dialogRef: e,
691
+ onClose: t,
692
+ participant: s,
693
+ participantDisplayName: a,
694
+ channel: r,
695
+ followerStatusLabel: i,
696
+ onLeaveConversation: l,
697
+ onBlockParticipant: o,
698
+ showDeleteConversation: d = !0,
699
+ onDeleteConversationClick: h,
700
+ onBlockParticipantClick: g,
701
+ onReportParticipantClick: u,
702
+ customProfileContent: f,
703
+ customChannelActions: c
704
+ }) => {
705
+ var V, $, L, Y;
706
+ const { service: b, debug: x } = et(), [v, N] = z(!1), [w, E] = z(!1), [I, S] = z(!1), D = U(async () => {
707
+ var _;
708
+ if (!(!b || !((_ = s == null ? void 0 : s.user) != null && _.id)))
709
+ try {
710
+ const p = (await b.getBlockedUsers()).some(
711
+ (C) => {
712
+ var H;
713
+ return C.blocked_user_id === ((H = s == null ? void 0 : s.user) == null ? void 0 : H.id);
714
+ }
715
+ );
716
+ N(p);
717
+ } catch (O) {
718
+ console.error(
719
+ "[ChannelInfoDialog] Failed to check blocked status:",
720
+ O
721
+ );
722
+ }
723
+ }, [b, (V = s == null ? void 0 : s.user) == null ? void 0 : V.id]);
724
+ X(() => {
725
+ D();
726
+ }, [D]);
727
+ const T = async () => {
728
+ var _;
729
+ if (!w) {
730
+ h == null || h(), x && console.log("[ChannelInfoDialog] Leave conversation", r.cid), E(!0);
731
+ try {
732
+ const O = ((_ = r._client) == null ? void 0 : _.userID) ?? null;
733
+ await r.hide(O, !1), l && await l(r), t();
734
+ } catch (O) {
735
+ console.error("[ChannelInfoDialog] Failed to leave conversation", O);
736
+ } finally {
737
+ E(!1);
738
+ }
739
+ }
740
+ }, F = async () => {
741
+ var _, O, p;
742
+ if (!(I || !b)) {
743
+ g == null || g(), x && console.log("[ChannelInfoDialog] Block member", (_ = s == null ? void 0 : s.user) == null ? void 0 : _.id), S(!0);
744
+ try {
745
+ await b.blockUser((O = s == null ? void 0 : s.user) == null ? void 0 : O.id), o && await o((p = s == null ? void 0 : s.user) == null ? void 0 : p.id), t();
746
+ } catch (C) {
747
+ console.error("[ChannelInfoDialog] Failed to block member", C);
748
+ } finally {
749
+ S(!1);
750
+ }
751
+ }
752
+ }, M = async () => {
753
+ var _, O, p;
754
+ if (!(I || !b)) {
755
+ g == null || g(), x && console.log("[ChannelInfoDialog] Unblock member", (_ = s == null ? void 0 : s.user) == null ? void 0 : _.id), S(!0);
756
+ try {
757
+ await b.unBlockUser((O = s == null ? void 0 : s.user) == null ? void 0 : O.id), o && await o((p = s == null ? void 0 : s.user) == null ? void 0 : p.id), t();
758
+ } catch (C) {
759
+ console.error("[ChannelInfoDialog] Failed to unblock member", C);
760
+ } finally {
761
+ S(!1);
762
+ }
763
+ }
764
+ }, R = () => {
765
+ u == null || u(), t(), window.open(
766
+ "https://linktr.ee/s/about/trust-center/report",
767
+ "_blank",
768
+ "noopener,noreferrer"
769
+ );
770
+ };
771
+ if (!s) return null;
772
+ const A = a ?? tt(s.user), G = ($ = s.user) == null ? void 0 : $.image, k = (L = s.user) == null ? void 0 : L.username, j = k ? `linktr.ee/${k}` : void 0, W = ((Y = s.user) == null ? void 0 : Y.id) || "unknown";
773
+ return (
774
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
775
+ /* @__PURE__ */ n(
776
+ "dialog",
777
+ {
778
+ ref: e,
779
+ className: "mes-dialog group",
780
+ onClose: t,
781
+ onClick: (_) => {
782
+ _.target === e.current && t();
783
+ },
784
+ children: /* @__PURE__ */ m("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: [
785
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between border-b border-sand px-4 py-3", children: [
786
+ /* @__PURE__ */ n("h2", { className: "text-base font-semibold text-charcoal", children: "Chat info" }),
787
+ /* @__PURE__ */ n(Ks, { onClick: t })
788
+ ] }),
789
+ /* @__PURE__ */ m("div", { className: "flex-1 px-2 overflow-y-auto w-full", children: [
790
+ /* @__PURE__ */ m(
791
+ "div",
792
+ {
793
+ className: "flex flex-col items-center gap-3 self-stretch px-4 py-2 mt-6 rounded-lg border border-black/[0.04]",
794
+ style: { backgroundColor: "#FBFAF9" },
795
+ children: [
796
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-3 w-full", children: [
797
+ /* @__PURE__ */ n(
798
+ oe,
799
+ {
800
+ id: W,
801
+ name: A,
802
+ image: G,
803
+ size: 88,
804
+ shape: "circle"
805
+ }
806
+ ),
807
+ /* @__PURE__ */ m("div", { className: "flex flex-col min-w-0 flex-1", children: [
808
+ /* @__PURE__ */ n("p", { className: "truncate text-base font-semibold text-charcoal", children: A }),
809
+ j && /* @__PURE__ */ n("p", { className: "truncate text-sm text-[#00000055]", children: j }),
810
+ i && !f && /* @__PURE__ */ n(
811
+ "span",
812
+ {
813
+ className: "mt-1 rounded-full text-xs font-normal w-fit",
814
+ style: {
815
+ padding: "4px 8px",
816
+ backgroundColor: i === "Subscribed to you" ? "#DCFCE7" : "#F5F5F4",
817
+ color: i === "Subscribed to you" ? "#008236" : "#78716C",
818
+ lineHeight: "133.333%",
819
+ letterSpacing: "0.21px"
820
+ },
821
+ children: i
822
+ }
823
+ )
824
+ ] })
825
+ ] }),
826
+ f && /* @__PURE__ */ n("div", { className: "w-full", children: f })
827
+ ]
828
+ }
829
+ ),
830
+ /* @__PURE__ */ m("ul", { className: "flex flex-col gap-2 mt-2", children: [
831
+ d && /* @__PURE__ */ n("li", { children: /* @__PURE__ */ m(
832
+ Se,
833
+ {
834
+ onClick: T,
835
+ disabled: w,
836
+ "aria-busy": w,
837
+ children: [
838
+ w ? /* @__PURE__ */ n(Be, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ n(ms, { className: "h-5 w-5" }),
839
+ /* @__PURE__ */ n("span", { children: "Delete Conversation" })
840
+ ]
841
+ }
842
+ ) }),
843
+ /* @__PURE__ */ n("li", { children: v ? /* @__PURE__ */ m(
844
+ Se,
845
+ {
846
+ onClick: M,
847
+ disabled: I,
848
+ "aria-busy": I,
849
+ children: [
850
+ I ? /* @__PURE__ */ n(Be, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ n(Dt, { className: "h-5 w-5" }),
851
+ /* @__PURE__ */ n("span", { children: "Unblock" })
852
+ ]
853
+ }
854
+ ) : /* @__PURE__ */ m(
855
+ Se,
856
+ {
857
+ onClick: F,
858
+ disabled: I,
859
+ "aria-busy": I,
860
+ children: [
861
+ I ? /* @__PURE__ */ n(Be, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ n(Dt, { className: "h-5 w-5" }),
862
+ /* @__PURE__ */ n("span", { children: "Block" })
863
+ ]
864
+ }
865
+ ) }),
866
+ /* @__PURE__ */ n("li", { children: /* @__PURE__ */ m(Se, { variant: "danger", onClick: R, children: [
867
+ /* @__PURE__ */ n(hs, { className: "h-5 w-5" }),
868
+ /* @__PURE__ */ n("span", { children: "Report" })
869
+ ] }) }),
870
+ c
871
+ ] })
872
+ ] })
873
+ ] })
874
+ }
875
+ )
876
+ );
877
+ }, Qs = (e) => /* @__PURE__ */ n(Tn, { ...e, position: "center" }), qe = "vote_up", Xe = "vote_down";
878
+ function ea(e) {
879
+ return e != null && e.length ? e.some((t) => t.type === Xe) ? "down" : e.some((t) => t.type === qe) ? "up" : null : null;
880
+ }
881
+ function ta(e) {
882
+ const { channel: t } = me(), { client: s } = Qe("useMessageVote"), a = re(
883
+ () => ea(e.own_reactions),
884
+ [e.own_reactions]
885
+ ), r = U(async () => {
886
+ if (s != null && s.userID)
887
+ try {
888
+ a === "up" ? await t.deleteReaction(e.id, qe) : await t.sendReaction(
889
+ e.id,
890
+ { type: qe },
891
+ { enforce_unique: !0, skip_push: !0 }
892
+ );
893
+ } catch {
894
+ }
895
+ }, [t, s == null ? void 0 : s.userID, e.id, a]), i = U(async () => {
896
+ if (s != null && s.userID)
897
+ try {
898
+ a === "down" ? await t.deleteReaction(e.id, Xe) : await t.sendReaction(
899
+ e.id,
900
+ { type: Xe },
901
+ { enforce_unique: !0, skip_push: !0 }
902
+ );
903
+ } catch {
904
+ }
905
+ }, [t, s == null ? void 0 : s.userID, e.id, a]);
906
+ return { selected: a, voteUp: r, voteDown: i };
907
+ }
908
+ const na = P.lazy(() => import("./Card-DNlAktyj.js")), sa = P.lazy(() => import("./Card-CwnMzWRr.js")), aa = P.lazy(() => import("./Card-Ct_Vj2M-.js")), nt = () => /* @__PURE__ */ n(
909
+ "div",
910
+ {
911
+ className: "w-[280px] min-h-[200px] animate-pulse rounded-md bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]",
912
+ "aria-hidden": !0
913
+ }
914
+ ), ra = (e) => /* @__PURE__ */ n(Je, { fallback: /* @__PURE__ */ n(nt, {}), children: /* @__PURE__ */ n(na, { ...e }) }), en = (e) => /* @__PURE__ */ n(Je, { fallback: /* @__PURE__ */ n(nt, {}), children: /* @__PURE__ */ n(sa, { ...e }) }), tn = (e) => /* @__PURE__ */ n(Je, { fallback: /* @__PURE__ */ n(nt, {}), children: /* @__PURE__ */ n(aa, { ...e }) }), ia = en, oa = tn, Pt = { Composer: ra, Sent: en, Received: tn, Creator: ia, Visitor: oa }, la = [
915
+ [/pdf/, "pdf"],
916
+ [/wordprocessingml|msword|\.doc/, "doc"],
917
+ [/spreadsheetml|ms-excel|\.xls/, "xls"],
918
+ [/csv/, "csv"],
919
+ [/presentationml|ms-powerpoint|\.ppt/, "ppt"],
920
+ [/zip|x-rar|x-7z|x-tar|x-gzip/, "zip"],
921
+ [/plain|rtf/, "text"],
922
+ [/markdown/, "markdown"]
923
+ ];
924
+ function le(e) {
925
+ return e.startsWith("video/") ? "video" : e.startsWith("audio/") ? "audio" : e.startsWith("image/") ? "image" : "document";
926
+ }
927
+ function nn(e) {
928
+ const t = la.find(
929
+ ([s]) => s.test(e)
930
+ );
931
+ return t ? t[1] : "generic";
932
+ }
933
+ const ca = {
934
+ video: Ht,
935
+ audio: gs,
936
+ image: fs,
937
+ document: Gt
938
+ }, da = {
939
+ pdf: _s,
940
+ doc: ys,
941
+ xls: Ns,
942
+ csv: ws,
943
+ ppt: xs,
944
+ zip: vs,
945
+ text: ps,
946
+ markdown: bs,
947
+ generic: Gt
948
+ };
949
+ function ua(e) {
950
+ const t = le(e);
951
+ return t !== "document" ? ca[t] : da[nn(e)];
952
+ }
953
+ function ge(e, t) {
954
+ return P.createElement(ua(e), t);
955
+ }
956
+ const ma = (e) => {
957
+ var t, s;
958
+ return "touches" in e ? ((t = e.touches[0]) == null ? void 0 : t.clientX) ?? ((s = e.changedTouches[0]) == null ? void 0 : s.clientX) ?? 0 : e.clientX;
959
+ }, ha = ({
960
+ source: e,
961
+ mimeType: t,
962
+ poster: s,
963
+ autoPlay: a = !1,
964
+ playing: r,
965
+ loop: i = !1,
966
+ controls: l = !0,
967
+ showProgress: o = !1,
968
+ muted: d = !1,
969
+ onContainerClick: h
970
+ }) => {
971
+ const g = le(t), u = Z(null), f = Z(null), c = Z(null), b = Z(r), [x, v] = z(a), [N, w] = z(0), [E, I] = z(!1), [S, D] = z(!1), [T, F] = z(!1), [M, R] = z(!1), [A, G] = z(!0), [k, j] = z(null), W = U(() => {
972
+ F(!1), v(!0);
973
+ }, []), V = U((p) => {
974
+ const C = f.current;
975
+ if (!C) return 0;
976
+ const H = C.getBoundingClientRect();
977
+ return Math.max(
978
+ 0,
979
+ Math.min(1, (ma(p) - H.left) / H.width)
980
+ );
981
+ }, []), $ = U((p) => {
982
+ const C = u.current;
983
+ C && C.duration && (C.currentTime = p * C.duration);
984
+ }, []), L = (p) => {
985
+ p.stopPropagation(), I(!0);
986
+ const C = V(p);
987
+ w(C), $(C);
988
+ };
989
+ X(() => {
990
+ r !== void 0 && r !== b.current && (b.current = r, v(r));
991
+ }, [r]), X(() => {
992
+ if (!x) {
993
+ c.current !== null && (cancelAnimationFrame(c.current), c.current = null);
994
+ return;
995
+ }
996
+ const p = () => {
997
+ const C = u.current;
998
+ C && C.duration && !E && w(C.currentTime / C.duration), c.current = requestAnimationFrame(p);
999
+ };
1000
+ return c.current = requestAnimationFrame(p), () => {
1001
+ c.current !== null && cancelAnimationFrame(c.current);
1002
+ };
1003
+ }, [x, E]), X(() => {
1004
+ const p = u.current;
1005
+ p && (x ? p.play().catch((C) => {
1006
+ v(!1), F(!0);
1007
+ }) : p.pause());
1008
+ }, [x]), X(() => {
1009
+ if (!E) return;
1010
+ const p = (H) => w(V(H)), C = (H) => {
1011
+ I(!1), $(V(H));
1012
+ };
1013
+ return window.addEventListener("mousemove", p), window.addEventListener("mouseup", C), window.addEventListener("touchmove", p, { passive: !0 }), window.addEventListener("touchend", C), () => {
1014
+ window.removeEventListener("mousemove", p), window.removeEventListener("mouseup", C), window.removeEventListener("touchmove", p), window.removeEventListener("touchend", C);
1015
+ };
1016
+ }, [E, V, $]);
1017
+ const Y = k ? { aspectRatio: String(k) } : void 0, _ = k ? "" : " aspect-video", O = Math.round(N * 100);
1018
+ return /* @__PURE__ */ m(
1019
+ "div",
1020
+ {
1021
+ role: "button",
1022
+ tabIndex: 0,
1023
+ className: `relative cursor-pointer overflow-hidden bg-black ${_}`,
1024
+ style: Y,
1025
+ onClick: (p) => {
1026
+ if (h) {
1027
+ h(p);
1028
+ return;
1029
+ }
1030
+ T || l && v((C) => !C);
1031
+ },
1032
+ onKeyDown: (p) => {
1033
+ if (!(p.key !== "Enter" && p.key !== " ")) {
1034
+ if (p.preventDefault(), h) {
1035
+ h(p);
1036
+ return;
1037
+ }
1038
+ T || l && v((C) => !C);
1039
+ }
1040
+ },
1041
+ children: [
1042
+ s && (g === "audio" || A) && /* @__PURE__ */ n(
1043
+ "img",
1044
+ {
1045
+ src: s,
1046
+ alt: "",
1047
+ className: "absolute inset-0 h-full w-full object-cover"
1048
+ }
1049
+ ),
1050
+ !s && (g === "audio" || A) && /* @__PURE__ */ n("div", { className: "absolute inset-0 flex items-center justify-center", children: ge(t, {
1051
+ className: "size-12 text-black/20",
1052
+ weight: "regular"
1053
+ }) }),
1054
+ /* @__PURE__ */ n("div", { className: "absolute inset-0", children: g === "audio" ? /* @__PURE__ */ n(
1055
+ "audio",
1056
+ {
1057
+ ref: u,
1058
+ src: e,
1059
+ loop: i,
1060
+ muted: d,
1061
+ style: { width: "100%", height: "100%" },
1062
+ onLoadStart: () => R(!0),
1063
+ onCanPlay: () => {
1064
+ R(!1), G(!1);
1065
+ },
1066
+ onWaiting: () => R(!0),
1067
+ onPlay: () => F(!1),
1068
+ onEnded: () => {
1069
+ i || (v(!1), w(0));
1070
+ },
1071
+ children: /* @__PURE__ */ n("track", { kind: "captions" })
1072
+ }
1073
+ ) : /* @__PURE__ */ n(
1074
+ "video",
1075
+ {
1076
+ ref: u,
1077
+ src: e,
1078
+ loop: i,
1079
+ muted: d,
1080
+ playsInline: !0,
1081
+ style: { width: "100%", height: "100%" },
1082
+ onLoadStart: () => R(!0),
1083
+ onCanPlay: () => {
1084
+ R(!1), G(!1);
1085
+ },
1086
+ onWaiting: () => R(!0),
1087
+ onPlay: () => F(!1),
1088
+ onLoadedMetadata: () => {
1089
+ const p = u.current;
1090
+ p instanceof HTMLVideoElement && p.videoWidth && p.videoHeight && j(p.videoWidth / p.videoHeight);
1091
+ },
1092
+ onEnded: () => {
1093
+ i || (v(!1), w(0));
1094
+ },
1095
+ children: /* @__PURE__ */ n("track", { kind: "captions" })
1096
+ }
1097
+ ) }),
1098
+ M && !T && /* @__PURE__ */ n("div", { className: "absolute inset-0 z-10 flex items-center justify-center", children: /* @__PURE__ */ n(
1099
+ pe,
1100
+ {
1101
+ className: "size-8 animate-spin text-white/80",
1102
+ weight: "bold"
1103
+ }
1104
+ ) }),
1105
+ T && !l && /* @__PURE__ */ n(
1106
+ "div",
1107
+ {
1108
+ className: "absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",
1109
+ role: "button",
1110
+ tabIndex: 0,
1111
+ "aria-label": "Play preview",
1112
+ onClick: (p) => {
1113
+ p.stopPropagation(), W();
1114
+ },
1115
+ onKeyDown: (p) => {
1116
+ p.key !== "Enter" && p.key !== " " || (p.preventDefault(), p.stopPropagation(), W());
1117
+ },
1118
+ children: /* @__PURE__ */ n("span", { className: "flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm", children: /* @__PURE__ */ n(He, { className: "size-9 translate-x-0.5", weight: "fill" }) })
1119
+ }
1120
+ ),
1121
+ o && !l && /* @__PURE__ */ n("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__ */ n(
1122
+ "div",
1123
+ {
1124
+ role: "slider",
1125
+ "aria-label": "Playback position",
1126
+ "aria-valuenow": O,
1127
+ "aria-valuemin": 0,
1128
+ "aria-valuemax": 100,
1129
+ tabIndex: 0,
1130
+ ref: f,
1131
+ className: "relative flex h-4 w-full cursor-pointer items-center",
1132
+ onMouseDown: L,
1133
+ onTouchStart: L,
1134
+ onClick: (p) => p.stopPropagation(),
1135
+ onKeyDown: (p) => {
1136
+ p.key === "ArrowRight" && $(Math.min(1, N + 0.05)), p.key === "ArrowLeft" && $(Math.max(0, N - 0.05));
1137
+ },
1138
+ children: /* @__PURE__ */ n("div", { className: "w-full overflow-hidden rounded-full bg-white/30 h-1", children: /* @__PURE__ */ n(
1139
+ "div",
1140
+ {
1141
+ className: "h-full rounded-full bg-white",
1142
+ style: { width: `${O}%` }
1143
+ }
1144
+ ) })
1145
+ }
1146
+ ) }),
1147
+ l && /* @__PURE__ */ m("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: [
1148
+ /* @__PURE__ */ n(
1149
+ "button",
1150
+ {
1151
+ type: "button",
1152
+ onClick: (p) => {
1153
+ p.stopPropagation(), v((C) => !C);
1154
+ },
1155
+ className: "shrink-0 text-white",
1156
+ "aria-label": x ? "Pause" : "Play",
1157
+ children: x ? /* @__PURE__ */ n(Cs, { className: "size-5", weight: "fill" }) : /* @__PURE__ */ n(He, { className: "size-5 translate-x-px", weight: "fill" })
1158
+ }
1159
+ ),
1160
+ /* @__PURE__ */ m(
1161
+ "div",
1162
+ {
1163
+ role: "slider",
1164
+ "aria-label": "Playback position",
1165
+ "aria-valuenow": O,
1166
+ "aria-valuemin": 0,
1167
+ "aria-valuemax": 100,
1168
+ tabIndex: 0,
1169
+ ref: f,
1170
+ className: "relative flex h-4 w-full cursor-pointer items-center",
1171
+ onMouseDown: L,
1172
+ onTouchStart: L,
1173
+ onClick: (p) => p.stopPropagation(),
1174
+ onMouseEnter: () => D(!0),
1175
+ onMouseLeave: () => D(!1),
1176
+ onKeyDown: (p) => {
1177
+ p.key === "ArrowRight" && $(Math.min(1, N + 0.05)), p.key === "ArrowLeft" && $(Math.max(0, N - 0.05));
1178
+ },
1179
+ children: [
1180
+ /* @__PURE__ */ n(
1181
+ "div",
1182
+ {
1183
+ className: `w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${S || E ? "h-1.5" : "h-1"}`,
1184
+ children: /* @__PURE__ */ n(
1185
+ "div",
1186
+ {
1187
+ className: "h-full rounded-full bg-white",
1188
+ style: { width: `${O}%` }
1189
+ }
1190
+ )
1191
+ }
1192
+ ),
1193
+ /* @__PURE__ */ n(
1194
+ "div",
1195
+ {
1196
+ className: `absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${S || E ? "scale-100 opacity-100" : "scale-0 opacity-0"}`,
1197
+ style: { left: `${O}%` }
1198
+ }
1199
+ )
1200
+ ]
1201
+ }
1202
+ )
1203
+ ] })
1204
+ ]
1205
+ }
1206
+ );
1207
+ }, Bt = (e) => e === "dark" ? "size-12 text-white/20" : "size-12 text-black/20", fa = (e) => e === "dark" ? "aspect-video overflow-hidden bg-white/10" : "aspect-video overflow-hidden bg-black/5", sn = ({
1208
+ mimeType: e,
1209
+ sourceUrl: t,
1210
+ thumbnailUrl: s,
1211
+ title: a,
1212
+ variant: r,
1213
+ mediaPlayerProps: i,
1214
+ containedImage: l = !1
1215
+ }) => {
1216
+ const o = le(e), [d, h] = z(!1);
1217
+ return t && (o === "video" || o === "audio") ? /* @__PURE__ */ n(
1218
+ ha,
1219
+ {
1220
+ source: t,
1221
+ mimeType: e,
1222
+ poster: s,
1223
+ controls: !0,
1224
+ ...i
1225
+ }
1226
+ ) : t && o === "image" ? l ? /* @__PURE__ */ n("div", { className: "relative aspect-video overflow-hidden bg-black/5", children: /* @__PURE__ */ n(
1227
+ "img",
1228
+ {
1229
+ src: t,
1230
+ alt: a ?? "",
1231
+ className: `absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d ? "opacity-100" : "opacity-0"}`,
1232
+ draggable: !1,
1233
+ onLoad: () => h(!0)
1234
+ }
1235
+ ) }) : /* @__PURE__ */ n(
1236
+ "img",
1237
+ {
1238
+ src: t,
1239
+ alt: a ?? "",
1240
+ className: "block w-full",
1241
+ draggable: !1
1242
+ }
1243
+ ) : t && o === "document" ? s ? l ? /* @__PURE__ */ n("div", { className: "relative aspect-video overflow-hidden bg-black/5", children: /* @__PURE__ */ n(
1244
+ "img",
1245
+ {
1246
+ src: s,
1247
+ alt: a ?? "",
1248
+ className: `absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d ? "opacity-100" : "opacity-0"}`,
1249
+ draggable: !1,
1250
+ onLoad: () => h(!0)
1251
+ }
1252
+ ) }) : /* @__PURE__ */ n(
1253
+ "img",
1254
+ {
1255
+ src: s,
1256
+ alt: "",
1257
+ className: "block w-full",
1258
+ draggable: !1
1259
+ }
1260
+ ) : /* @__PURE__ */ n(
1261
+ "div",
1262
+ {
1263
+ className: `flex aspect-video w-full items-center justify-center ${r === "dark" ? "bg-white/10" : "bg-black/5"}`,
1264
+ children: ge(e, {
1265
+ className: Bt(r),
1266
+ weight: "regular"
1267
+ })
1268
+ }
1269
+ ) : s ? /* @__PURE__ */ n("div", { className: `relative ${fa(r)}`, children: /* @__PURE__ */ n(
1270
+ "img",
1271
+ {
1272
+ src: s,
1273
+ alt: a ?? "",
1274
+ draggable: !1,
1275
+ className: "absolute inset-0 h-full w-full object-cover"
1276
+ }
1277
+ ) }) : /* @__PURE__ */ n(
1278
+ "div",
1279
+ {
1280
+ className: `flex aspect-video w-full items-center justify-center ${r === "dark" ? "bg-white/10" : "bg-black/5"}`,
1281
+ children: ge(e, {
1282
+ className: Bt(r),
1283
+ weight: "regular"
1284
+ })
1285
+ }
1286
+ );
1287
+ }, an = ({
1288
+ variant: e,
1289
+ thumbnail: t,
1290
+ title: s,
1291
+ placeholderTitle: a = "Attachment title",
1292
+ mimeType: r,
1293
+ detail: i,
1294
+ statusBadge: l,
1295
+ action: o,
1296
+ topLeft: d,
1297
+ topRight: h,
1298
+ rootRef: g,
1299
+ "data-testid": u
1300
+ }) => {
1301
+ const f = e === "dark", c = f ? s ?? a : s ?? "", b = f && !s;
1302
+ return /* @__PURE__ */ m(
1303
+ "div",
1304
+ {
1305
+ ref: g,
1306
+ "data-testid": u,
1307
+ className: y(
1308
+ "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)]",
1309
+ f ? "bg-[#121110]" : "bg-white"
1310
+ ),
1311
+ children: [
1312
+ d ? /* @__PURE__ */ n("div", { className: "pointer-events-auto absolute left-3 top-3 z-50", children: d }) : null,
1313
+ h ? /* @__PURE__ */ n("div", { className: "pointer-events-auto absolute right-3 top-3 z-50", children: h }) : null,
1314
+ t,
1315
+ /* @__PURE__ */ m("div", { className: "px-4 pb-3 pt-3", children: [
1316
+ c.trim() !== "" && /* @__PURE__ */ n(
1317
+ "p",
1318
+ {
1319
+ className: y("mb-0.5 truncate text-base font-medium", {
1320
+ "text-black": !f,
1321
+ "text-white/30": f && b,
1322
+ "text-white": f && !b
1323
+ }),
1324
+ children: c
1325
+ }
1326
+ ),
1327
+ /* @__PURE__ */ m("div", { className: "flex flex-wrap items-center gap-1", children: [
1328
+ ge(r, {
1329
+ className: y(
1330
+ "size-5 shrink-0",
1331
+ f ? "text-white/55" : "text-black/55"
1332
+ ),
1333
+ weight: "regular"
1334
+ }),
1335
+ i != null && i !== "" && /* @__PURE__ */ n(
1336
+ "span",
1337
+ {
1338
+ className: y(
1339
+ "text-xs font-medium",
1340
+ f ? "text-white/55" : "text-black/55"
1341
+ ),
1342
+ children: i
1343
+ }
1344
+ ),
1345
+ l
1346
+ ] }),
1347
+ o
1348
+ ] })
1349
+ ]
1350
+ }
1351
+ );
1352
+ };
1353
+ function rn(e) {
1354
+ return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`;
1355
+ }
1356
+ function st(e) {
1357
+ return `w-[280px] select-none overflow-hidden rounded-[24px] ${e ? "bg-[#121110]" : "bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`;
1358
+ }
1359
+ function ga(e) {
1360
+ return e ? "bg-white/10" : "bg-black/5";
1361
+ }
1362
+ function ba(e) {
1363
+ return e ? "text-white" : "text-black";
1364
+ }
1365
+ function pa(e) {
1366
+ return e ? "text-white/55" : "text-black/55";
1367
+ }
1368
+ function va(e) {
1369
+ return e ? "text-white/40" : "text-black/40";
1370
+ }
1371
+ function xa(e) {
1372
+ return e ? "text-white/20" : "text-black/20";
1373
+ }
1374
+ const at = ({ attachment: e, isMyMessage: t }) => {
1375
+ const { title: s, text: a, image_url: r, og_scrape_url: i, title_link: l } = e, o = i ?? l, d = typeof o == "string" && o.trim() !== "" ? o : void 0, h = /* @__PURE__ */ m(P.Fragment, { children: [
1376
+ /* @__PURE__ */ n("div", { className: "p-2", children: r ? /* @__PURE__ */ n(
1377
+ "img",
1378
+ {
1379
+ src: r,
1380
+ alt: s ?? "",
1381
+ className: "aspect-video w-full rounded-[20px] object-cover"
1382
+ }
1383
+ ) : /* @__PURE__ */ n(
1384
+ "div",
1385
+ {
1386
+ className: `aspect-video w-full rounded-[20px] ${ga(t)} flex items-center justify-center`,
1387
+ children: /* @__PURE__ */ n(ks, { className: `size-12 ${xa(t)}` })
1388
+ }
1389
+ ) }),
1390
+ /* @__PURE__ */ m("div", { className: "px-3 pb-3", children: [
1391
+ s && /* @__PURE__ */ n("p", { className: `truncate text-[14px] font-medium leading-5 ${ba(t)}`, children: s }),
1392
+ a && /* @__PURE__ */ n("p", { className: `truncate text-[12px] leading-4 ${pa(t)}`, children: a }),
1393
+ d && /* @__PURE__ */ n("p", { className: `mt-1 truncate text-[12px] leading-4 ${va(t)}`, children: d })
1394
+ ] })
1395
+ ] });
1396
+ return d ? /* @__PURE__ */ n("a", { href: d, target: "_blank", rel: "noopener noreferrer", className: "block no-underline", children: h }) : /* @__PURE__ */ n("div", { className: "block", children: h });
1397
+ };
1398
+ function on(e) {
1399
+ return e.type === "link" || !!e.og_scrape_url && !e.asset_url;
1400
+ }
1401
+ function rt(e) {
1402
+ var t;
1403
+ return (t = e.attachments) == null ? void 0 : t.find(on);
1404
+ }
1405
+ async function wa(e, t) {
1406
+ let s;
1407
+ try {
1408
+ s = t ?? new URL(e).pathname.split("/").pop() ?? "download";
1409
+ } catch {
1410
+ s = t ?? "download";
1411
+ }
1412
+ const a = await fetch(e, { mode: "cors" });
1413
+ if (!a.ok) throw new Error(`HTTP ${a.status}`);
1414
+ const r = await a.blob(), i = URL.createObjectURL(r), l = document.createElement("a");
1415
+ l.href = i, l.download = s, l.style.display = "none", document.body.appendChild(l), l.click(), document.body.removeChild(l), URL.revokeObjectURL(i);
1416
+ }
1417
+ const Na = ({
1418
+ url: e,
1419
+ filename: t
1420
+ }) => {
1421
+ const [s, a] = z(!1);
1422
+ return /* @__PURE__ */ n(
1423
+ "button",
1424
+ {
1425
+ type: "button",
1426
+ onClick: (i) => {
1427
+ i.stopPropagation();
1428
+ const l = window.open("", "_blank", "noopener,noreferrer");
1429
+ a(!0), wa(e, t).then(() => {
1430
+ l == null || l.close();
1431
+ }).catch(() => {
1432
+ l && (l.location.href = e);
1433
+ }).finally(() => a(!1));
1434
+ },
1435
+ disabled: s,
1436
+ 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",
1437
+ children: s ? /* @__PURE__ */ n(pe, { className: "size-4 animate-spin text-white", weight: "bold" }) : /* @__PURE__ */ m(P.Fragment, { children: [
1438
+ /* @__PURE__ */ n(ve, { className: "size-4 text-white", weight: "bold" }),
1439
+ "Download"
1440
+ ] })
1441
+ }
1442
+ );
1443
+ };
1444
+ function it(e) {
1445
+ var u, f, c, b;
1446
+ const t = (u = e.attachments) == null ? void 0 : u.find(
1447
+ (x) => x.type === "video" && x.asset_url
1448
+ ), s = (f = e.attachments) == null ? void 0 : f.find(
1449
+ (x) => x.type === "image" && x.image_url
1450
+ ), a = (c = e.attachments) == null ? void 0 : c.find(
1451
+ (x) => x.type === "audio" && x.asset_url
1452
+ ), r = (b = e.attachments) == null ? void 0 : b.find(
1453
+ (x) => x.type === "file" && x.asset_url
1454
+ ), i = t ?? s ?? a ?? r, l = (t == null ? void 0 : t.asset_url) ?? (s == null ? void 0 : s.image_url) ?? (a == null ? void 0 : a.asset_url) ?? (r == null ? void 0 : r.asset_url);
1455
+ if (!l) return null;
1456
+ const o = (i == null ? void 0 : i.mime_type) ?? ((i == null ? void 0 : i.type) === "image" ? "image/jpeg" : (i == null ? void 0 : i.type) === "video" ? "video/mp4" : (i == null ? void 0 : i.type) === "audio" ? "audio/mpeg" : "application/octet-stream"), d = i == null ? void 0 : i.title, h = i == null ? void 0 : i.file_size, g = t == null ? void 0 : t.thumb_url;
1457
+ return {
1458
+ resolvedUrl: l,
1459
+ resolvedType: o,
1460
+ title: d,
1461
+ fileSize: h,
1462
+ thumbnailUrl: g
1463
+ };
1464
+ }
1465
+ const ln = ({
1466
+ resolvedUrl: e,
1467
+ resolvedType: t,
1468
+ title: s,
1469
+ fileSize: a,
1470
+ thumbnailUrl: r
1471
+ }) => {
1472
+ const i = a !== void 0 ? rn(a) : void 0;
1473
+ return /* @__PURE__ */ n(
1474
+ an,
1475
+ {
1476
+ variant: "dark",
1477
+ title: s,
1478
+ placeholderTitle: "",
1479
+ mimeType: t,
1480
+ detail: i,
1481
+ thumbnail: /* @__PURE__ */ n(
1482
+ sn,
1483
+ {
1484
+ mimeType: t,
1485
+ sourceUrl: e,
1486
+ thumbnailUrl: r,
1487
+ title: s,
1488
+ variant: "dark"
1489
+ }
1490
+ )
1491
+ }
1492
+ );
1493
+ }, cn = ({
1494
+ resolvedUrl: e,
1495
+ resolvedType: t,
1496
+ title: s,
1497
+ fileSize: a,
1498
+ thumbnailUrl: r
1499
+ }) => {
1500
+ const i = le(t), l = a !== void 0 ? rn(a) : void 0;
1501
+ return /* @__PURE__ */ n(
1502
+ an,
1503
+ {
1504
+ variant: "light",
1505
+ title: s,
1506
+ mimeType: t,
1507
+ detail: l,
1508
+ thumbnail: /* @__PURE__ */ n(
1509
+ sn,
1510
+ {
1511
+ mimeType: t,
1512
+ sourceUrl: e,
1513
+ thumbnailUrl: r,
1514
+ title: s,
1515
+ variant: "light",
1516
+ containedImage: i === "image" || i === "document"
1517
+ }
1518
+ ),
1519
+ action: /* @__PURE__ */ n(Na, { url: e, filename: s })
1520
+ }
1521
+ );
1522
+ }, ya = ({
1523
+ message: e,
1524
+ isMyMessage: t = !1
1525
+ }) => {
1526
+ const s = rt(e), a = it(e);
1527
+ return !s && !a ? null : /* @__PURE__ */ m("div", { className: t ? "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: [
1528
+ !t && e.user && /* @__PURE__ */ n(
1529
+ oe,
1530
+ {
1531
+ className: "str-chat__avatar str-chat__message-sender-avatar",
1532
+ id: e.user.id,
1533
+ image: e.user.image,
1534
+ name: e.user.name ?? e.user.id
1535
+ }
1536
+ ),
1537
+ /* @__PURE__ */ n(
1538
+ "div",
1539
+ {
1540
+ className: "str-chat__message-inner",
1541
+ style: { marginInlineEnd: 0, marginInlineStart: 0 },
1542
+ children: /* @__PURE__ */ n("div", { className: "str-chat__message-bubble-wrapper", children: /* @__PURE__ */ n(
1543
+ "div",
1544
+ {
1545
+ className: "str-chat__message-bubble",
1546
+ style: { padding: 0, borderRadius: 0, overflow: "visible", background: "transparent" },
1547
+ children: s ? /* @__PURE__ */ n("div", { className: st(t), children: /* @__PURE__ */ n(at, { attachment: s, isMyMessage: t }) }) : t ? /* @__PURE__ */ n(ln, { ...a }) : /* @__PURE__ */ n(cn, { ...a })
1548
+ }
1549
+ ) })
1550
+ }
1551
+ )
1552
+ ] });
1553
+ }, _a = ({
1554
+ message: e
1555
+ }) => {
1556
+ const t = rt(e);
1557
+ if (t)
1558
+ return /* @__PURE__ */ n("div", { className: st(!0), children: /* @__PURE__ */ n(at, { attachment: t, isMyMessage: !0 }) });
1559
+ const s = it(e);
1560
+ return s ? /* @__PURE__ */ n(ln, { ...s }) : null;
1561
+ }, Ca = ({
1562
+ message: e
1563
+ }) => {
1564
+ const t = rt(e);
1565
+ if (t)
1566
+ return /* @__PURE__ */ n("div", { className: st(!1), children: /* @__PURE__ */ n(at, { attachment: t, isMyMessage: !1 }) });
1567
+ const s = it(e);
1568
+ return s ? /* @__PURE__ */ n(cn, { ...s }) : null;
1569
+ }, _i = Object.assign(ya, {
1570
+ Creator: _a,
1571
+ Visitor: Ca
1572
+ }), ka = {
1573
+ isUnlocking: () => !1
1574
+ }, Ea = {
1575
+ LockedAttachment: ka
1576
+ }, dn = Ze({}), Ci = dn.Provider;
1577
+ function Ia(e) {
1578
+ return Ke(dn)[e] ?? Ea[e];
1579
+ }
1580
+ const Sa = ({
1581
+ selected: e,
1582
+ onVoteUp: t,
1583
+ onVoteDown: s
1584
+ }) => /* @__PURE__ */ m("div", { className: "message-vote-buttons", children: [
1585
+ /* @__PURE__ */ n(
1586
+ "button",
1587
+ {
1588
+ type: "button",
1589
+ className: y("message-vote-button focus-ring", {
1590
+ "message-vote-button--selected": e === "up"
1591
+ }),
1592
+ onClick: t,
1593
+ "aria-label": "Good response",
1594
+ "aria-pressed": e === "up",
1595
+ "data-tooltip": "Good response",
1596
+ children: /* @__PURE__ */ n(Es, { size: 16, weight: e === "up" ? "fill" : "regular" })
1597
+ }
1598
+ ),
1599
+ /* @__PURE__ */ n(
1600
+ "button",
1601
+ {
1602
+ type: "button",
1603
+ className: y("message-vote-button focus-ring", {
1604
+ "message-vote-button--selected": e === "down"
1605
+ }),
1606
+ onClick: s,
1607
+ "aria-label": "Bad response",
1608
+ "aria-pressed": e === "down",
1609
+ "data-tooltip": "Bad response",
1610
+ children: /* @__PURE__ */ n(Is, { size: 16, weight: e === "down" ? "fill" : "regular" })
1611
+ }
1612
+ )
1613
+ ] }), Ta = (e) => {
1614
+ var gt, bt, pt, vt, xt, wt, Nt, yt, _t, Ct, kt, Et, It, St;
1615
+ const {
1616
+ additionalMessageInputProps: t,
1617
+ chatbotVotingEnabled: s,
1618
+ editing: a,
1619
+ endOfGroup: r,
1620
+ firstOfGroup: i,
1621
+ groupedByUser: l,
1622
+ handleAction: o,
1623
+ handleOpenThread: d,
1624
+ handleRetry: h,
1625
+ highlighted: g,
1626
+ isMessageAIGenerated: u,
1627
+ isMyMessage: f,
1628
+ message: c,
1629
+ renderText: b,
1630
+ threadList: x,
1631
+ viewerLanguage: v
1632
+ } = e, { client: N } = Qe("CustomMessage"), { channel: w } = me("CustomMessage"), { isUnlocking: E, onUnlockClick: I, onFetchSource: S, onDownloadClick: D } = Ia("LockedAttachment"), [T, F] = z(!1), M = An(c.id), { selected: R, voteUp: A, voteDown: G } = ta(c), {
1633
+ Attachment: k = Dn,
1634
+ EditMessageModal: j = Rn,
1635
+ MessageActions: W,
1636
+ MessageBlocked: V = Ln,
1637
+ MessageBouncePrompt: $ = Fn,
1638
+ MessageDeleted: L = On,
1639
+ MessageIsThreadReplyInChannelButtonIndicator: Y = zn,
1640
+ MessageRepliesCountButton: _ = Pn,
1641
+ ReminderNotification: O = Bn,
1642
+ StreamedMessageText: p = $n,
1643
+ PinIndicator: C
1644
+ } = Vt("CustomMessage"), H = jn(c), q = Un(c), he = re(
1645
+ () => u == null ? void 0 : u(c),
1646
+ [u, c]
1647
+ ), J = re(() => {
1648
+ const be = c.attachments ?? [], Ie = c.shared_location ? [c.shared_location, ...be] : be;
1649
+ if (!Me(c)) return Ie;
1650
+ const Tt = Ie.filter((Mt) => !("type" in Mt) || !on(Mt));
1651
+ return Tt.length === Ie.length ? Ie : Tt;
1652
+ }, [c]), ee = re(() => {
1653
+ const be = Zt({ message: c, viewerLanguage: v });
1654
+ return be === c.text ? c : { ...c, text: be };
1655
+ }, [c, v]);
1656
+ if (Vn(c))
1657
+ return null;
1658
+ if (c.deleted_at || c.type === "deleted")
1659
+ return /* @__PURE__ */ n(L, { message: c });
1660
+ if (Gn(c))
1661
+ return /* @__PURE__ */ n(V, {});
1662
+ const Ce = !x && !!c.reply_count, ke = !x && c.show_in_channel && c.parent_id, ce = c.status === "failed" && ((gt = c.error) == null ? void 0 : gt.status) !== 403, te = Hn(c);
1663
+ let se;
1664
+ ce ? se = () => h(c) : te && (se = () => F(!0));
1665
+ const de = f(), Oe = y(
1666
+ "str-chat__message str-chat__message-simple",
1667
+ `str-chat__message--${c.type}`,
1668
+ `str-chat__message--${c.status}`,
1669
+ de ? "str-chat__message--me str-chat__message-simple--me" : "str-chat__message--other",
1670
+ c.text ? "str-chat__message--has-text" : "has-no-text",
1671
+ {
1672
+ "str-chat__message--has-attachment": H,
1673
+ "str-chat__message--highlighted": g,
1674
+ "str-chat__message--pinned pinned-message": c.pinned,
1675
+ "str-chat__message--with-reactions": q,
1676
+ "str-chat__message-send-can-be-retried": (c == null ? void 0 : c.status) === "failed" && ((bt = c == null ? void 0 : c.error) == null ? void 0 : bt.status) !== 403,
1677
+ "str-chat__message-with-thread-link": Ce || ke,
1678
+ "str-chat__virtual-message__wrapper--end": r,
1679
+ "str-chat__virtual-message__wrapper--first": i,
1680
+ "str-chat__virtual-message__wrapper--group": l
1681
+ }
1682
+ ), Ee = c.poll_id && N.polls.fromState(c.poll_id), ue = qs(c), B = Me(c), K = Ws(c), Q = !!(J != null && J.length && !c.quoted_message), ae = B && de && Q;
1683
+ return /* @__PURE__ */ m(ie, { children: [
1684
+ a && /* @__PURE__ */ n(
1685
+ j,
1686
+ {
1687
+ additionalMessageInputProps: t
1688
+ }
1689
+ ),
1690
+ T && /* @__PURE__ */ n(
1691
+ Yn,
1692
+ {
1693
+ MessageBouncePrompt: $,
1694
+ onClose: () => F(!1),
1695
+ open: T
1696
+ }
1697
+ ),
1698
+ /* @__PURE__ */ m("div", { className: Oe, children: [
1699
+ C && /* @__PURE__ */ n(C, {}),
1700
+ !!M && /* @__PURE__ */ n(O, { reminder: M }),
1701
+ c.user && /* @__PURE__ */ n(
1702
+ oe,
1703
+ {
1704
+ className: "str-chat__avatar str-chat__message-sender-avatar",
1705
+ id: c.user.id,
1706
+ image: c.user.image,
1707
+ name: c.user.name || c.user.id,
1708
+ size: B ? 24 : 28,
1709
+ shape: "circle",
1710
+ dmAgentEnabled: B
1711
+ }
1712
+ ),
1713
+ /* @__PURE__ */ m(
1714
+ "div",
1715
+ {
1716
+ className: y("str-chat__message-inner", {
1717
+ "str-chat__simple-message--error-failed": ce || te
1718
+ }),
1719
+ "data-testid": "message-inner",
1720
+ onClick: se,
1721
+ onKeyDown: se,
1722
+ role: se ? "button" : void 0,
1723
+ tabIndex: se ? 0 : void 0,
1724
+ style: {
1725
+ // Force margins to 0 to prevent hover layout shift
1726
+ // Stream Chat CSS sets margin-inline-end/start to 78px, then 0 on hover
1727
+ marginInlineEnd: 0,
1728
+ marginInlineStart: 0
1729
+ },
1730
+ children: [
1731
+ K ? /* @__PURE__ */ m("div", { className: "str-chat__message-bubble-wrapper", children: [
1732
+ de ? /* @__PURE__ */ n(
1733
+ Pt.Sent,
1734
+ {
1735
+ title: (pt = c.metadata) == null ? void 0 : pt.attachment_title,
1736
+ mimeType: (vt = c.metadata) == null ? void 0 : vt.attachment_mime_type,
1737
+ thumbnailUrl: (xt = c.metadata) == null ? void 0 : xt.attachment_thumbnail,
1738
+ amountText: (wt = c.metadata) == null ? void 0 : wt.amount_text,
1739
+ detail: (Nt = c.metadata) == null ? void 0 : Nt.attachment_detail,
1740
+ paymentStatus: (yt = c.metadata) == null ? void 0 : yt.payment_status,
1741
+ onPreviewClick: () => I == null ? void 0 : I(c, w),
1742
+ onFetchSource: async () => await (S == null ? void 0 : S(c, w))
1743
+ }
1744
+ ) : /* @__PURE__ */ n(
1745
+ Pt.Received,
1746
+ {
1747
+ title: (_t = c.metadata) == null ? void 0 : _t.attachment_title,
1748
+ mimeType: (Ct = c.metadata) == null ? void 0 : Ct.attachment_mime_type,
1749
+ thumbnailUrl: (kt = c.metadata) == null ? void 0 : kt.attachment_thumbnail,
1750
+ amountText: (Et = c.metadata) == null ? void 0 : Et.amount_text,
1751
+ detail: (It = c.metadata) == null ? void 0 : It.attachment_detail,
1752
+ paymentStatus: (St = c.metadata) == null ? void 0 : St.payment_status,
1753
+ isUnlocking: E(c.id),
1754
+ onUnlockClick: () => I == null ? void 0 : I(c, w),
1755
+ onFetchSource: async () => await (S == null ? void 0 : S(c, w)),
1756
+ onDownloadClick: () => D == null ? void 0 : D(c, w)
1757
+ }
1758
+ ),
1759
+ c.text && /* @__PURE__ */ n("div", { className: "str-chat__message-bubble", children: /* @__PURE__ */ n(
1760
+ At,
1761
+ {
1762
+ message: ee,
1763
+ renderText: b
1764
+ }
1765
+ ) })
1766
+ ] }) : ue ? (
1767
+ /* Tip-only messages render as a standalone bubble */
1768
+ /* @__PURE__ */ n($e, { message: c, standalone: !0 })
1769
+ ) : /* @__PURE__ */ n("div", { className: "str-chat__message-bubble-wrapper", children: /* @__PURE__ */ m("div", { className: "str-chat__message-bubble", children: [
1770
+ B && !ae && /* @__PURE__ */ n(
1771
+ $e,
1772
+ {
1773
+ message: c,
1774
+ hasAttachment: Q,
1775
+ isMyMessage: de
1776
+ }
1777
+ ),
1778
+ Ee && /* @__PURE__ */ n(Wn, { poll: Ee }),
1779
+ J != null && J.length && !c.quoted_message ? /* @__PURE__ */ n(
1780
+ k,
1781
+ {
1782
+ actionHandler: o,
1783
+ attachments: J
1784
+ }
1785
+ ) : null,
1786
+ he ? /* @__PURE__ */ n(
1787
+ p,
1788
+ {
1789
+ message: ee,
1790
+ renderText: b
1791
+ }
1792
+ ) : /* @__PURE__ */ n(
1793
+ At,
1794
+ {
1795
+ message: ee,
1796
+ renderText: b
1797
+ }
1798
+ ),
1799
+ /* @__PURE__ */ n(qn, {})
1800
+ ] }) }),
1801
+ W && /* @__PURE__ */ n(W, {})
1802
+ ]
1803
+ }
1804
+ ),
1805
+ !K && !ue && /* @__PURE__ */ m("div", { className: "str-chat__message-footer", children: [
1806
+ (!B || ae) && /* @__PURE__ */ n(
1807
+ $e,
1808
+ {
1809
+ message: c,
1810
+ hasAttachment: Q,
1811
+ isMyMessage: de
1812
+ }
1813
+ ),
1814
+ s && B && /* @__PURE__ */ n(
1815
+ Sa,
1816
+ {
1817
+ selected: R,
1818
+ onVoteUp: A,
1819
+ onVoteDown: G
1820
+ }
1821
+ )
1822
+ ] }),
1823
+ Ce && /* @__PURE__ */ n(
1824
+ _,
1825
+ {
1826
+ onClick: d,
1827
+ reply_count: c.reply_count
1828
+ }
1829
+ ),
1830
+ ke && /* @__PURE__ */ n(Y, {})
1831
+ ] }, c.id)
1832
+ ] });
1833
+ }, Ma = P.memo(
1834
+ Ta,
1835
+ (e, t) => e.chatbotVotingEnabled !== t.chatbotVotingEnabled || e.viewerLanguage !== t.viewerLanguage ? !1 : Mn(e, t)
1836
+ ), Aa = (e) => {
1837
+ const t = Le("CustomMessage");
1838
+ return /* @__PURE__ */ n(Ma, { ...t, ...e });
1839
+ }, Da = () => {
1840
+ const { handleDelete: e } = Le("CustomMessageActions"), { t } = Xn("CustomMessageActions");
1841
+ return /* @__PURE__ */ n(Yt, { onClick: e, children: t("Delete") });
1842
+ }, Ra = () => {
1843
+ const { handleFlag: e } = Le("CustomMessageActions");
1844
+ return /* @__PURE__ */ n(Yt, { onClick: e, children: "Report" });
1845
+ }, La = [
1846
+ { Component: Da, placement: "dropdown", type: "delete" },
1847
+ { Component: Ra, placement: "dropdown", type: "flag" }
1848
+ ], Fa = () => /* @__PURE__ */ n(Ds, { messageActionSet: La }), Oa = (e) => ({
1849
+ linkPreviews: Array.from(e.previews.values()).filter(
1850
+ (t) => Ft.previewIsLoaded(t) || Ft.previewIsLoading(t)
1851
+ )
1852
+ }), za = ({
1853
+ link: e,
1854
+ onDismiss: t
1855
+ }) => {
1856
+ const { og_scrape_url: s, title: a, image_url: r } = e;
1857
+ return /* @__PURE__ */ m(
1858
+ "a",
1859
+ {
1860
+ href: s,
1861
+ target: "_blank",
1862
+ rel: "noopener noreferrer",
1863
+ className: "relative w-full block rounded-[24px] bg-[#121110] p-2 no-underline transition-opacity hover:opacity-90",
1864
+ children: [
1865
+ r && /* @__PURE__ */ n(
1866
+ "img",
1867
+ {
1868
+ src: r,
1869
+ alt: a || "",
1870
+ className: "h-[148px] w-full rounded-[20px] object-cover"
1871
+ }
1872
+ ),
1873
+ /* @__PURE__ */ n(
1874
+ "button",
1875
+ {
1876
+ type: "button",
1877
+ onClick: (l) => {
1878
+ l.preventDefault(), t(s);
1879
+ },
1880
+ 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",
1881
+ "aria-label": "Close link preview",
1882
+ children: /* @__PURE__ */ n(xe, { className: "size-4 text-black/90" })
1883
+ }
1884
+ ),
1885
+ /* @__PURE__ */ m("div", { className: "p-2", children: [
1886
+ a && /* @__PURE__ */ n("div", { className: "text-[14px] font-medium leading-5 text-white", children: a }),
1887
+ /* @__PURE__ */ n("div", { className: "text-[12px] leading-4 text-white/55", children: s })
1888
+ ] })
1889
+ ]
1890
+ }
1891
+ );
1892
+ }, Pa = () => {
1893
+ const { linkPreviewsManager: e } = Zn(), { linkPreviews: t } = Kn(
1894
+ e.state,
1895
+ Oa
1896
+ ), s = (r) => {
1897
+ e.dismissPreview(r);
1898
+ };
1899
+ return t.length > 0 ? /* @__PURE__ */ n("div", { className: "flex flex-col items-center w-full gap-2 mb-4", children: t.map((r) => /* @__PURE__ */ n(
1900
+ za,
1901
+ {
1902
+ link: r,
1903
+ onDismiss: s
1904
+ },
1905
+ r.og_scrape_url
1906
+ )) }) : null;
1907
+ }, Ba = ({ sendMessage: e, disabled: t, ...s }) => /* @__PURE__ */ n(
1908
+ "button",
1909
+ {
1910
+ ...s,
1911
+ type: "button",
1912
+ "aria-label": "Send",
1913
+ disabled: t,
1914
+ onClick: e,
1915
+ children: /* @__PURE__ */ n(Ss, { weight: "bold", className: "size-4" })
1916
+ }
1917
+ ), $a = () => {
1918
+ var o;
1919
+ const { channel: e } = me(), t = ((o = e == null ? void 0 : e.data) == null ? void 0 : o.frozen) === !0, { handleSubmit: s } = Qn(), { SendButton: a } = Vt("CustomMessageInput"), r = a ?? Ba, i = es();
1920
+ return /* @__PURE__ */ m(ie, { children: [
1921
+ /* @__PURE__ */ n("div", { className: "left-container", children: /* @__PURE__ */ n(ts, {}) }),
1922
+ /* @__PURE__ */ m("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: [
1923
+ /* @__PURE__ */ n(ns, {}),
1924
+ /* @__PURE__ */ n(Pa, {}),
1925
+ /* @__PURE__ */ n(ss, {}),
1926
+ /* @__PURE__ */ m("div", { className: "flex", children: [
1927
+ /* @__PURE__ */ n("div", { className: "w-full ml-2 mr-4 self-center leading-[0]", children: /* @__PURE__ */ n(
1928
+ as,
1929
+ {
1930
+ "aria-disabled": t || void 0,
1931
+ className: "w-full resize-none outline-none leading-6",
1932
+ autoFocus: !t,
1933
+ maxRows: 4,
1934
+ readOnly: t,
1935
+ tabIndex: t ? -1 : void 0
1936
+ }
1937
+ ) }),
1938
+ /* @__PURE__ */ n(
1939
+ r,
1940
+ {
1941
+ sendMessage: s,
1942
+ "aria-label": "Send",
1943
+ 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",
1944
+ "data-testid": "send-button",
1945
+ disabled: t || !i,
1946
+ type: "button"
1947
+ }
1948
+ )
1949
+ ] })
1950
+ ] })
1951
+ ] });
1952
+ }, ja = ({
1953
+ renderActions: e
1954
+ }) => {
1955
+ var a;
1956
+ const { channel: t } = me(), s = ((a = t == null ? void 0 : t.data) == null ? void 0 : a.frozen) === !0;
1957
+ return /* @__PURE__ */ m(
1958
+ "div",
1959
+ {
1960
+ inert: s ? "" : void 0,
1961
+ "aria-disabled": s || void 0,
1962
+ className: "message-input flex items-center gap-2 p-4 aria-disabled:opacity-40",
1963
+ children: [
1964
+ e == null ? void 0 : e(),
1965
+ /* @__PURE__ */ n(Jn, { Input: $a })
1966
+ ]
1967
+ }
1968
+ );
1969
+ }, Ua = [
1970
+ "SYSTEM_DM_AGENT_PAUSED",
1971
+ "SYSTEM_DM_AGENT_RESUMED"
1972
+ ], Va = {
1973
+ SYSTEM_DM_AGENT_PAUSED: "DM Agent has left the conversation",
1974
+ SYSTEM_DM_AGENT_RESUMED: "DM Agent has rejoined the conversation"
1975
+ }, Ga = [
1976
+ "SYSTEM_AGE_SAFETY_BLOCKED"
1977
+ ], Ha = {
1978
+ SYSTEM_AGE_SAFETY_BLOCKED: "This user isn’t able to reply because they don’t meet our age safety guidelines."
1979
+ }, je = "age safety guidelines.", Ya = "https://linktr.ee/s/about/contact", $t = (e) => Ua.includes(e), Wa = (e) => Ga.includes(e), qa = (e) => {
1980
+ var a;
1981
+ const t = (a = e.metadata) == null ? void 0 : a.custom_type;
1982
+ if ($t(t))
1983
+ return {
1984
+ kind: "dm-agent",
1985
+ type: t
1986
+ };
1987
+ if (Wa(t))
1988
+ return {
1989
+ kind: "age-safety",
1990
+ type: t
1991
+ };
1992
+ const s = e.dm_agent_system_type;
1993
+ if ($t(s))
1994
+ return {
1995
+ kind: "dm-agent",
1996
+ type: s
1997
+ };
1998
+ }, Xa = (e) => {
1999
+ const t = e.indexOf(je);
2000
+ if (t === -1)
2001
+ return e;
2002
+ const s = t + je.length;
2003
+ return /* @__PURE__ */ m(ie, { children: [
2004
+ e.slice(0, t),
2005
+ /* @__PURE__ */ n(
2006
+ "a",
2007
+ {
2008
+ href: Ya,
2009
+ target: "_blank",
2010
+ rel: "noopener noreferrer",
2011
+ className: "mes-age-safety-system-message__emphasis font-medium text-inherit underline",
2012
+ children: je
2013
+ }
2014
+ ),
2015
+ e.slice(s)
2016
+ ] });
2017
+ }, Za = (e) => {
2018
+ var a, r;
2019
+ const t = e.message.hide_date === !0, s = qa(
2020
+ e.message
2021
+ );
2022
+ if ((s == null ? void 0 : s.kind) === "dm-agent") {
2023
+ const i = ((a = e.message.text) == null ? void 0 : a.trim()) || Va[s.type];
2024
+ return /* @__PURE__ */ m("div", { className: "str-chat__message--system", "data-testid": "message-system", children: [
2025
+ /* @__PURE__ */ m(
2026
+ "div",
2027
+ {
2028
+ 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)]",
2029
+ "data-testid": "dm-agent-system-message",
2030
+ "data-dm-agent-system-type": s.type,
2031
+ children: [
2032
+ /* @__PURE__ */ n(
2033
+ Ye,
2034
+ {
2035
+ size: 16,
2036
+ weight: "regular",
2037
+ "aria-hidden": !0,
2038
+ className: "mes-dm-agent-system-message__sparkle shrink-0"
2039
+ }
2040
+ ),
2041
+ /* @__PURE__ */ n("p", { className: "mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]", children: i })
2042
+ ]
2043
+ }
2044
+ ),
2045
+ !t && /* @__PURE__ */ n(ze, { message: e.message })
2046
+ ] });
2047
+ }
2048
+ if ((s == null ? void 0 : s.kind) === "age-safety") {
2049
+ const i = ((r = e.message.text) == null ? void 0 : r.trim()) || Ha[s.type];
2050
+ return /* @__PURE__ */ m("div", { className: "str-chat__message--system", "data-testid": "message-system", children: [
2051
+ /* @__PURE__ */ m(
2052
+ "div",
2053
+ {
2054
+ 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)]",
2055
+ "data-testid": "age-safety-system-message",
2056
+ "data-age-safety-system-type": s.type,
2057
+ children: [
2058
+ /* @__PURE__ */ n(
2059
+ Ts,
2060
+ {
2061
+ size: 24,
2062
+ weight: "duotone",
2063
+ "aria-hidden": !0,
2064
+ className: "mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]",
2065
+ "data-testid": "age-safety-system-message-icon"
2066
+ }
2067
+ ),
2068
+ /* @__PURE__ */ n("div", { className: "mes-age-safety-system-message__content min-w-0 flex-[1_0_0]", children: /* @__PURE__ */ n("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: Xa(i) }) })
2069
+ ]
2070
+ }
2071
+ ),
2072
+ !t && /* @__PURE__ */ n(ze, { message: e.message })
2073
+ ] });
2074
+ }
2075
+ return /* @__PURE__ */ m("div", { className: "str-chat__message--system", "data-testid": "message-system", children: [
2076
+ /* @__PURE__ */ m("div", { className: "str-chat__message--system__text", children: [
2077
+ /* @__PURE__ */ n("div", { className: "str-chat__message--system__line" }),
2078
+ /* @__PURE__ */ n("p", { children: e.message.text }),
2079
+ /* @__PURE__ */ n("div", { className: "str-chat__message--system__line" })
2080
+ ] }),
2081
+ !t && /* @__PURE__ */ n(ze, { message: e.message })
2082
+ ] });
2083
+ }, un = Ze(!1), Ue = ({ cx: e, index: t }) => /* @__PURE__ */ n("circle", { cx: e, cy: "4", r: "3.9", fill: "#A0A0A0", children: /* @__PURE__ */ n(
2084
+ "animateTransform",
2085
+ {
2086
+ attributeName: "transform",
2087
+ type: "translate",
2088
+ values: "0 0; 0 -2.25; 0 0;",
2089
+ dur: "900ms",
2090
+ begin: `${120 * t}ms`,
2091
+ repeatCount: "indefinite"
2092
+ }
2093
+ ) }), Ka = /* @__PURE__ */ new Set([
2094
+ Pe.Thinking,
2095
+ Pe.Generating,
2096
+ Pe.ExternalSources
2097
+ ]), Ja = ({ threadList: e }) => {
2098
+ var b, x;
2099
+ const { channel: t, channelConfig: s, thread: a } = me(), { client: r } = Qe(), { typing: i = {} } = rs(), { aiState: l } = is(t), o = Ke(un);
2100
+ if (!e && o && Ka.has(l)) {
2101
+ const v = Qa(t, (b = r.user) == null ? void 0 : b.id);
2102
+ return /* @__PURE__ */ n(
2103
+ jt,
2104
+ {
2105
+ avatarId: (v == null ? void 0 : v.id) ?? "ai-agent",
2106
+ avatarName: (v == null ? void 0 : v.name) ?? (v == null ? void 0 : v.id) ?? "Agent",
2107
+ avatarImage: v == null ? void 0 : v.image,
2108
+ testId: "typing-indicator-ai"
2109
+ }
2110
+ );
2111
+ }
2112
+ if ((s == null ? void 0 : s.typing_events) === !1)
2113
+ return null;
2114
+ const h = e ? [] : Object.values(i).filter(
2115
+ ({ parent_id: v, user: N }) => {
2116
+ var w;
2117
+ return (N == null ? void 0 : N.id) !== ((w = r.user) == null ? void 0 : w.id) && !v;
2118
+ }
2119
+ ), g = e ? Object.values(i).filter(
2120
+ ({ parent_id: v, user: N }) => {
2121
+ var w;
2122
+ return (N == null ? void 0 : N.id) !== ((w = r.user) == null ? void 0 : w.id) && v === (a == null ? void 0 : a.id);
2123
+ }
2124
+ ) : [], u = e ? g : h;
2125
+ if (!u.length)
2126
+ return null;
2127
+ const f = (x = u[0]) == null ? void 0 : x.user, c = f != null && f.id && t.state.members[f.id] ? t.state.members[f.id].user : void 0;
2128
+ return /* @__PURE__ */ n(
2129
+ jt,
2130
+ {
2131
+ avatarId: (f == null ? void 0 : f.id) ?? (c == null ? void 0 : c.id) ?? "typing-user",
2132
+ avatarName: (f == null ? void 0 : f.name) ?? (c == null ? void 0 : c.name) ?? (f == null ? void 0 : f.id) ?? "Typing user",
2133
+ avatarImage: (f == null ? void 0 : f.image) ?? (c == null ? void 0 : c.image),
2134
+ testId: "typing-indicator"
2135
+ }
2136
+ );
2137
+ }, jt = ({
2138
+ avatarId: e,
2139
+ avatarName: t,
2140
+ avatarImage: s,
2141
+ testId: a
2142
+ }) => /* @__PURE__ */ m(
2143
+ "div",
2144
+ {
2145
+ className: "str-chat__typing-indicator !items-end !bg-transparent",
2146
+ "data-testid": a,
2147
+ style: { insetInlineStart: 0, insetInlineEnd: "auto" },
2148
+ children: [
2149
+ /* @__PURE__ */ n("div", { className: "shrink-0", "aria-hidden": "true", children: /* @__PURE__ */ n(
2150
+ oe,
2151
+ {
2152
+ id: e,
2153
+ name: t,
2154
+ image: s ?? void 0,
2155
+ size: 24,
2156
+ shape: "circle"
2157
+ }
2158
+ ) }),
2159
+ /* @__PURE__ */ n("div", { className: "px-4 py-3 rounded-lg bg-[#E9EAED] h-12 flex flex-col justify-end", children: /* @__PURE__ */ m(
2160
+ "svg",
2161
+ {
2162
+ "aria-hidden": "true",
2163
+ className: "block overflow-visible mb-[0.2rem]",
2164
+ viewBox: "0 0 32 8",
2165
+ width: "32",
2166
+ height: "8",
2167
+ overflow: "visible",
2168
+ children: [
2169
+ /* @__PURE__ */ n(Ue, { cx: "4", index: 0 }),
2170
+ /* @__PURE__ */ n(Ue, { cx: "16", index: 1 }),
2171
+ /* @__PURE__ */ n(Ue, { cx: "28", index: 2 })
2172
+ ]
2173
+ }
2174
+ ) })
2175
+ ]
2176
+ }
2177
+ );
2178
+ function Qa(e, t) {
2179
+ var a;
2180
+ const s = ((a = e == null ? void 0 : e.state) == null ? void 0 : a.members) ?? {};
2181
+ for (const r of Object.values(s)) {
2182
+ const i = r == null ? void 0 : r.user;
2183
+ if (i && i.id !== t)
2184
+ return i;
2185
+ }
2186
+ }
2187
+ const er = () => null, tr = ({ className: e, message: t }) => /* @__PURE__ */ m(
2188
+ "div",
2189
+ {
2190
+ className: y("flex items-center justify-center h-full", e),
2191
+ children: [
2192
+ /* @__PURE__ */ m("svg", { viewBox: "0 0 100 100", className: "size-8 fill-pebble", stroke: "none", children: [
2193
+ /* @__PURE__ */ n("circle", { cx: "6", cy: "50", r: "6", children: /* @__PURE__ */ n(
2194
+ "animateTransform",
2195
+ {
2196
+ attributeName: "transform",
2197
+ dur: "1s",
2198
+ type: "translate",
2199
+ values: "0 15 ; 0 -15; 0 15",
2200
+ repeatCount: "indefinite",
2201
+ begin: "0.1"
2202
+ }
2203
+ ) }),
2204
+ /* @__PURE__ */ n("circle", { cx: "30", cy: "50", r: "6", children: /* @__PURE__ */ n(
2205
+ "animateTransform",
2206
+ {
2207
+ attributeName: "transform",
2208
+ dur: "1s",
2209
+ type: "translate",
2210
+ values: "0 10 ; 0 -10; 0 10",
2211
+ repeatCount: "indefinite",
2212
+ begin: "0.2"
2213
+ }
2214
+ ) }),
2215
+ /* @__PURE__ */ n("circle", { cx: "54", cy: "50", r: "6", children: /* @__PURE__ */ n(
2216
+ "animateTransform",
2217
+ {
2218
+ attributeName: "transform",
2219
+ dur: "1s",
2220
+ type: "translate",
2221
+ values: "0 5 ; 0 -5; 0 5",
2222
+ repeatCount: "indefinite",
2223
+ begin: "0.3"
2224
+ }
2225
+ ) })
2226
+ ] }),
2227
+ t && /* @__PURE__ */ n("span", { className: "text-stone", children: t })
2228
+ ]
2229
+ }
2230
+ ), Ae = P.memo(() => /* @__PURE__ */ n("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */ m("div", { className: "flex items-center", children: [
2231
+ /* @__PURE__ */ n(tr, { className: "w-6 h-6" }),
2232
+ /* @__PURE__ */ n("span", { className: "text-sm text-stone", children: "Loading messages" })
2233
+ ] }) }));
2234
+ Ae.displayName = "LoadingState";
2235
+ const fe = "size-10 rounded-full bg-[#F1F0EE] hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring", Ut = "Replies instantly with AI assistant", nr = ({
2236
+ onBack: e,
2237
+ showBackButton: t,
2238
+ onShowInfo: s,
2239
+ canShowInfo: a,
2240
+ showStarButton: r = !1,
2241
+ dmAgentEnabled: i = !1,
2242
+ getParticipantDisplayName: l
2243
+ }) => {
2244
+ var c, b, x, v, N;
2245
+ const { channel: o } = me(), d = P.useMemo(() => {
2246
+ var I, S;
2247
+ const w = (I = o._client) == null ? void 0 : I.userID;
2248
+ return w ? Object.values(((S = o.state) == null ? void 0 : S.members) || {}).find(
2249
+ (D) => {
2250
+ var T;
2251
+ return ((T = D.user) == null ? void 0 : T.id) && D.user.id !== w;
2252
+ }
2253
+ ) : void 0;
2254
+ }, [(c = o._client) == null ? void 0 : c.userID, (b = o.state) == null ? void 0 : b.members]), h = l(d), g = (x = d == null ? void 0 : d.user) == null ? void 0 : x.image, u = Xt(o), f = async () => {
2255
+ try {
2256
+ u ? await o.unpin() : await o.pin();
2257
+ } catch (w) {
2258
+ console.error(
2259
+ "[CustomChannelHeader] Failed to update pinned status:",
2260
+ w
2261
+ );
2262
+ }
2263
+ };
2264
+ return /* @__PURE__ */ m("div", { className: "@container", children: [
2265
+ /* @__PURE__ */ m("div", { className: "grid grid-cols-[1fr_auto_1fr] w-full items-center @lg:hidden", children: [
2266
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: t && /* @__PURE__ */ n(
2267
+ "button",
2268
+ {
2269
+ className: fe,
2270
+ onClick: e || (() => {
2271
+ }),
2272
+ type: "button",
2273
+ "aria-label": "Back to conversations",
2274
+ children: /* @__PURE__ */ n(Rt, { className: "size-5 text-black/90" })
2275
+ }
2276
+ ) }),
2277
+ /* @__PURE__ */ m("div", { className: "flex flex-col gap-1 items-center", children: [
2278
+ /* @__PURE__ */ n(
2279
+ oe,
2280
+ {
2281
+ id: ((v = d == null ? void 0 : d.user) == null ? void 0 : v.id) || o.id || "unknown",
2282
+ name: h,
2283
+ image: g,
2284
+ starred: r && u,
2285
+ dmAgentEnabled: i,
2286
+ size: 40
2287
+ }
2288
+ ),
2289
+ /* @__PURE__ */ m(
2290
+ "button",
2291
+ {
2292
+ type: "button",
2293
+ onClick: s,
2294
+ 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",
2295
+ "aria-label": `View info for ${h}`,
2296
+ children: [
2297
+ h,
2298
+ /* @__PURE__ */ n(We, { className: "size-3 shrink-0" })
2299
+ ]
2300
+ }
2301
+ ),
2302
+ i && /* @__PURE__ */ m("div", { className: "flex items-center gap-1 text-[10px] leading-3 text-black/55", children: [
2303
+ /* @__PURE__ */ n(Ye, { className: "size-3 shrink-0 text-black/55" }),
2304
+ /* @__PURE__ */ n("span", { children: Ut })
2305
+ ] })
2306
+ ] }),
2307
+ /* @__PURE__ */ m("div", { className: "flex justify-end items-center gap-2", children: [
2308
+ r && /* @__PURE__ */ n(
2309
+ "button",
2310
+ {
2311
+ className: fe,
2312
+ onClick: f,
2313
+ type: "button",
2314
+ "aria-label": u ? "Unstar conversation" : "Star conversation",
2315
+ children: /* @__PURE__ */ n(
2316
+ Ge,
2317
+ {
2318
+ className: y("size-5", {
2319
+ "text-yellow-600": u,
2320
+ "text-black/90": !u
2321
+ }),
2322
+ weight: u ? "duotone" : "regular"
2323
+ }
2324
+ )
2325
+ }
2326
+ ),
2327
+ /* @__PURE__ */ n(
2328
+ "button",
2329
+ {
2330
+ className: fe,
2331
+ onClick: s,
2332
+ type: "button",
2333
+ "aria-label": "Show info",
2334
+ children: /* @__PURE__ */ n(Lt, { className: "size-5 text-black/90" })
2335
+ }
2336
+ )
2337
+ ] })
2338
+ ] }),
2339
+ /* @__PURE__ */ m("div", { className: "hidden @lg:flex items-center justify-between gap-3 min-h-12", children: [
2340
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-4 min-w-0", children: [
2341
+ t && e && /* @__PURE__ */ n(
2342
+ "button",
2343
+ {
2344
+ type: "button",
2345
+ onClick: e,
2346
+ className: fe,
2347
+ "aria-label": "Back to conversations",
2348
+ children: /* @__PURE__ */ n(Rt, { className: "size-5 text-black/90" })
2349
+ }
2350
+ ),
2351
+ /* @__PURE__ */ n(
2352
+ oe,
2353
+ {
2354
+ id: ((N = d == null ? void 0 : d.user) == null ? void 0 : N.id) || o.id || "unknown",
2355
+ name: h,
2356
+ image: g,
2357
+ starred: r && u,
2358
+ dmAgentEnabled: i,
2359
+ size: 40
2360
+ }
2361
+ ),
2362
+ /* @__PURE__ */ m("div", { className: "min-w-0", children: [
2363
+ a ? /* @__PURE__ */ m(
2364
+ "button",
2365
+ {
2366
+ type: "button",
2367
+ onClick: s,
2368
+ className: "flex items-center gap-1 font-medium text-black/90 truncate hover:text-black/70 transition-colors",
2369
+ "aria-label": `View info for ${h}`,
2370
+ children: [
2371
+ /* @__PURE__ */ n("span", { className: "truncate", children: h }),
2372
+ /* @__PURE__ */ n(We, { className: "size-4 shrink-0" })
2373
+ ]
2374
+ }
2375
+ ) : /* @__PURE__ */ n("h1", { className: "font-medium text-black/90 truncate", children: h }),
2376
+ i && /* @__PURE__ */ m("div", { className: "mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55", children: [
2377
+ /* @__PURE__ */ n(Ye, { className: "size-3 shrink-0 text-black/55" }),
2378
+ /* @__PURE__ */ n("span", { className: "truncate", children: Ut })
2379
+ ] })
2380
+ ] })
2381
+ ] }),
2382
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-2", children: [
2383
+ r && /* @__PURE__ */ n(
2384
+ "button",
2385
+ {
2386
+ className: fe,
2387
+ onClick: f,
2388
+ type: "button",
2389
+ "aria-label": u ? "Unstar conversation" : "Star conversation",
2390
+ children: /* @__PURE__ */ n(
2391
+ Ge,
2392
+ {
2393
+ className: y("size-5", {
2394
+ "text-yellow-600": u,
2395
+ "text-black/90": !u
2396
+ }),
2397
+ weight: u ? "duotone" : "regular"
2398
+ }
2399
+ )
2400
+ }
2401
+ ),
2402
+ a && s && /* @__PURE__ */ n(
2403
+ "button",
2404
+ {
2405
+ className: fe,
2406
+ onClick: s,
2407
+ type: "button",
2408
+ "aria-label": "Show info",
2409
+ children: /* @__PURE__ */ n(Lt, { className: "size-5 text-black/90" })
2410
+ }
2411
+ )
2412
+ ] })
2413
+ ] })
2414
+ ] });
2415
+ }, sr = ({
2416
+ onBack: e,
2417
+ showBackButton: t,
2418
+ renderMessageInputActions: s,
2419
+ renderConversationFooter: a,
2420
+ onLeaveConversation: r,
2421
+ onBlockParticipant: i,
2422
+ showDeleteConversation: l = !0,
2423
+ onDeleteConversationClick: o,
2424
+ onBlockParticipantClick: d,
2425
+ onReportParticipantClick: h,
2426
+ showStarButton: g = !1,
2427
+ chatbotVotingEnabled: u = !1,
2428
+ renderChannelBanner: f,
2429
+ customProfileContent: c,
2430
+ customChannelActions: b,
2431
+ renderMessage: x,
2432
+ dmAgentEnabled: v = !1,
2433
+ viewerLanguage: N,
2434
+ getParticipantDisplayName: w
2435
+ }) => {
2436
+ var j, W, V, $, L, Y;
2437
+ const { channel: E } = me(), I = Z(null), S = P.useMemo(() => {
2438
+ var p, C;
2439
+ const _ = (p = E._client) == null ? void 0 : p.userID;
2440
+ return _ ? Object.values(((C = E.state) == null ? void 0 : C.members) || {}).find(
2441
+ (H) => {
2442
+ var q;
2443
+ return ((q = H.user) == null ? void 0 : q.id) && H.user.id !== _;
2444
+ }
2445
+ ) : void 0;
2446
+ }, [(j = E._client) == null ? void 0 : j.userID, (W = E.state) == null ? void 0 : W.members]), D = P.useMemo(() => {
2447
+ var p, C;
2448
+ const _ = (p = E._client) == null ? void 0 : p.userID;
2449
+ return _ ? Object.values(((C = E.state) == null ? void 0 : C.members) || {}).find((H) => {
2450
+ var q;
2451
+ return ((q = H.user) == null ? void 0 : q.id) === _;
2452
+ }) : void 0;
2453
+ }, [(V = E._client) == null ? void 0 : V.userID, ($ = E.state) == null ? void 0 : $.members]), T = ((L = D == null ? void 0 : D.user) == null ? void 0 : L.is_account) ?? (D == null ? void 0 : D.is_account), F = ((Y = S == null ? void 0 : S.user) == null ? void 0 : Y.is_account) ?? (S == null ? void 0 : S.is_account), M = v && T === !1 && F === !0, R = P.useMemo(() => {
2454
+ const _ = E.data ?? {};
2455
+ if (_.followerStatus)
2456
+ return String(_.followerStatus);
2457
+ if (_.isFollower !== void 0)
2458
+ return _.isFollower ? "Subscribed to you" : "Not subscribed";
2459
+ }, [E.data]), A = U(() => {
2460
+ var _;
2461
+ (_ = I.current) == null || _.showModal();
2462
+ }, []), G = U(() => {
2463
+ var _;
2464
+ (_ = I.current) == null || _.close();
2465
+ }, []), k = U(
2466
+ (_) => {
2467
+ const { message: O } = Le("ChannelView"), p = /* @__PURE__ */ n(
2468
+ Aa,
2469
+ {
2470
+ ..._,
2471
+ chatbotVotingEnabled: u,
2472
+ viewerLanguage: N
2473
+ }
2474
+ );
2475
+ return !x || !O ? p : x(p, O);
2476
+ },
2477
+ [u, x, N]
2478
+ );
2479
+ return /* @__PURE__ */ m(ie, { children: [
2480
+ /* @__PURE__ */ n(
2481
+ ls,
2482
+ {
2483
+ overrides: {
2484
+ Message: k,
2485
+ MessageActions: Fa
2486
+ },
2487
+ children: /* @__PURE__ */ m(cs, { children: [
2488
+ /* @__PURE__ */ n("div", { className: "p-4", children: /* @__PURE__ */ n(
2489
+ nr,
2490
+ {
2491
+ onBack: e,
2492
+ showBackButton: t,
2493
+ onShowInfo: A,
2494
+ canShowInfo: !!S,
2495
+ showStarButton: g,
2496
+ dmAgentEnabled: M,
2497
+ getParticipantDisplayName: w
2498
+ }
2499
+ ) }, "lt-channel-header"),
2500
+ f ? /* @__PURE__ */ n(P.Fragment, { children: f() }, "lt-channel-banner") : null,
2501
+ /* @__PURE__ */ n(
2502
+ "div",
2503
+ {
2504
+ className: "flex-1 overflow-hidden relative",
2505
+ children: /* @__PURE__ */ n(
2506
+ ds,
2507
+ {
2508
+ hideDeletedMessages: !0,
2509
+ hideNewMessageSeparator: !1
2510
+ }
2511
+ )
2512
+ },
2513
+ "lt-channel-message-list"
2514
+ ),
2515
+ a ? /* @__PURE__ */ n(P.Fragment, { children: a(E) }, "lt-channel-conversation-footer") : null,
2516
+ /* @__PURE__ */ n(
2517
+ ja,
2518
+ {
2519
+ renderActions: () => s == null ? void 0 : s(E)
2520
+ },
2521
+ "lt-channel-message-input"
2522
+ )
2523
+ ] })
2524
+ }
2525
+ ),
2526
+ /* @__PURE__ */ n(
2527
+ Js,
2528
+ {
2529
+ dialogRef: I,
2530
+ onClose: G,
2531
+ participant: S,
2532
+ participantDisplayName: w(S),
2533
+ channel: E,
2534
+ followerStatusLabel: R,
2535
+ onLeaveConversation: r,
2536
+ onBlockParticipant: i,
2537
+ showDeleteConversation: l,
2538
+ onDeleteConversationClick: o,
2539
+ onBlockParticipantClick: d,
2540
+ onReportParticipantClick: h,
2541
+ customProfileContent: c,
2542
+ customChannelActions: b
2543
+ }
2544
+ )
2545
+ ] });
2546
+ }, mn = P.memo(
2547
+ ({
2548
+ channel: e,
2549
+ onBack: t,
2550
+ showBackButton: s = !1,
2551
+ renderMessageInputActions: a,
2552
+ renderConversationFooter: r,
2553
+ onLeaveConversation: i,
2554
+ onBlockParticipant: l,
2555
+ className: o,
2556
+ CustomChannelEmptyState: d = er,
2557
+ showDeleteConversation: h = !0,
2558
+ onDeleteConversationClick: g,
2559
+ onBlockParticipantClick: u,
2560
+ onReportParticipantClick: f,
2561
+ dmAgentEnabled: c,
2562
+ messageMetadata: b,
2563
+ onMessageSent: x,
2564
+ showStarButton: v = !1,
2565
+ chatbotVotingEnabled: N = !1,
2566
+ renderChannelBanner: w,
2567
+ customProfileContent: E,
2568
+ customChannelActions: I,
2569
+ renderMessage: S,
2570
+ onMessageLinkClick: D,
2571
+ sendButton: T,
2572
+ viewerLanguage: F,
2573
+ getParticipantDisplayName: M
2574
+ }) => {
2575
+ const R = U(
2576
+ (k) => (M == null ? void 0 : M(k)) ?? tt(k == null ? void 0 : k.user),
2577
+ [M]
2578
+ ), A = U(
2579
+ async (k, j, W) => {
2580
+ var O;
2581
+ const V = ((O = e.data) == null ? void 0 : O.chatbot_paused) === !0, $ = c && !V, L = {
2582
+ ...j,
2583
+ ...$ && { silent: !0 },
2584
+ ...b && {
2585
+ metadata: {
2586
+ ...j.metadata ?? {},
2587
+ ...b
2588
+ }
2589
+ }
2590
+ }, Y = {
2591
+ ...W,
2592
+ ...$ && { skip_push: !0 }
2593
+ }, _ = await e.sendMessage(L, Y);
2594
+ return x == null || x(_), _;
2595
+ },
2596
+ [e, c, b, x]
2597
+ ), G = Z(null);
2598
+ return X(() => {
2599
+ if (!D) return;
2600
+ const k = G.current;
2601
+ if (!k) return;
2602
+ const j = (W) => {
2603
+ var L;
2604
+ const V = (L = W.target) == null ? void 0 : L.closest("a[href]"), $ = V == null ? void 0 : V.getAttribute("href");
2605
+ $ && D($);
2606
+ };
2607
+ return k.addEventListener("click", j), () => k.removeEventListener("click", j);
2608
+ }, [D]), /* @__PURE__ */ n(
2609
+ "div",
2610
+ {
2611
+ ref: G,
2612
+ className: y(
2613
+ "messaging-channel-view h-full flex flex-col",
2614
+ o
2615
+ ),
2616
+ children: /* @__PURE__ */ n(un.Provider, { value: c ?? !1, children: /* @__PURE__ */ n(
2617
+ os,
2618
+ {
2619
+ channel: e,
2620
+ MessageSystem: Za,
2621
+ EmptyStateIndicator: d,
2622
+ LoadingIndicator: Ae,
2623
+ DateSeparator: Qs,
2624
+ TypingIndicator: Ja,
2625
+ doSendMessageRequest: A,
2626
+ ...T ? { SendButton: T } : {},
2627
+ children: /* @__PURE__ */ n(
2628
+ sr,
2629
+ {
2630
+ onBack: t,
2631
+ showBackButton: s,
2632
+ renderMessageInputActions: a,
2633
+ renderConversationFooter: r,
2634
+ onLeaveConversation: i,
2635
+ onBlockParticipant: l,
2636
+ CustomChannelEmptyState: d,
2637
+ showDeleteConversation: h,
2638
+ onDeleteConversationClick: g,
2639
+ onBlockParticipantClick: u,
2640
+ onReportParticipantClick: f,
2641
+ showStarButton: v,
2642
+ dmAgentEnabled: c,
2643
+ chatbotVotingEnabled: N,
2644
+ renderChannelBanner: w,
2645
+ customProfileContent: E,
2646
+ customChannelActions: I,
2647
+ renderMessage: S,
2648
+ viewerLanguage: F,
2649
+ getParticipantDisplayName: R
2650
+ }
2651
+ )
2652
+ }
2653
+ ) })
2654
+ }
2655
+ );
2656
+ }
2657
+ );
2658
+ mn.displayName = "ChannelView";
2659
+ const ar = ({ className: e }) => /* @__PURE__ */ m(
2660
+ "svg",
2661
+ {
2662
+ width: "140",
2663
+ height: "120",
2664
+ viewBox: "44 -2 144 126",
2665
+ fill: "none",
2666
+ xmlns: "http://www.w3.org/2000/svg",
2667
+ className: e,
2668
+ children: [
2669
+ /* @__PURE__ */ m("g", { clipPath: "url(#clip0_empty_state)", children: [
2670
+ /* @__PURE__ */ n(
2671
+ "path",
2672
+ {
2673
+ 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",
2674
+ fill: "#D7D4CE"
2675
+ }
2676
+ ),
2677
+ /* @__PURE__ */ n(
2678
+ "path",
2679
+ {
2680
+ 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",
2681
+ fill: "white"
2682
+ }
2683
+ ),
2684
+ /* @__PURE__ */ n(
2685
+ "path",
2686
+ {
2687
+ 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",
2688
+ fill: "white"
2689
+ }
2690
+ ),
2691
+ /* @__PURE__ */ n(
2692
+ "path",
2693
+ {
2694
+ 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",
2695
+ fill: "white"
2696
+ }
2697
+ ),
2698
+ /* @__PURE__ */ m("g", { filter: "url(#filter0_empty_state)", children: [
2699
+ /* @__PURE__ */ n(
2700
+ "path",
2701
+ {
2702
+ 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",
2703
+ fill: "white"
2704
+ }
2705
+ ),
2706
+ /* @__PURE__ */ n(
2707
+ "path",
2708
+ {
2709
+ 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",
2710
+ stroke: "#D7D4CE",
2711
+ strokeWidth: "2",
2712
+ strokeMiterlimit: "10"
2713
+ }
2714
+ )
2715
+ ] }),
2716
+ /* @__PURE__ */ n(
2717
+ "path",
2718
+ {
2719
+ 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",
2720
+ fill: "#D7D4CE"
2721
+ }
2722
+ ),
2723
+ /* @__PURE__ */ n(
2724
+ "path",
2725
+ {
2726
+ 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",
2727
+ fill: "#D7D4CE"
2728
+ }
2729
+ ),
2730
+ /* @__PURE__ */ n(
2731
+ "path",
2732
+ {
2733
+ 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",
2734
+ fill: "#D7D4CE"
2735
+ }
2736
+ )
2737
+ ] }),
2738
+ /* @__PURE__ */ m("defs", { children: [
2739
+ /* @__PURE__ */ m(
2740
+ "filter",
2741
+ {
2742
+ id: "filter0_empty_state",
2743
+ x: "97",
2744
+ y: "-1",
2745
+ width: "89",
2746
+ height: "90",
2747
+ filterUnits: "userSpaceOnUse",
2748
+ colorInterpolationFilters: "sRGB",
2749
+ children: [
2750
+ /* @__PURE__ */ n("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }),
2751
+ /* @__PURE__ */ n(
2752
+ "feColorMatrix",
2753
+ {
2754
+ in: "SourceAlpha",
2755
+ type: "matrix",
2756
+ values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",
2757
+ result: "hardAlpha"
2758
+ }
2759
+ ),
2760
+ /* @__PURE__ */ n("feOffset", { dx: "4", dy: "4" }),
2761
+ /* @__PURE__ */ n("feComposite", { in2: "hardAlpha", operator: "out" }),
2762
+ /* @__PURE__ */ n(
2763
+ "feColorMatrix",
2764
+ {
2765
+ type: "matrix",
2766
+ values: "0 0 0 0 0.8428 0 0 0 0 0.830064 0 0 0 0 0.8095 0 0 0 1 0"
2767
+ }
2768
+ ),
2769
+ /* @__PURE__ */ n(
2770
+ "feBlend",
2771
+ {
2772
+ mode: "normal",
2773
+ in2: "BackgroundImageFix",
2774
+ result: "effect1_dropShadow"
2775
+ }
2776
+ ),
2777
+ /* @__PURE__ */ n(
2778
+ "feBlend",
2779
+ {
2780
+ mode: "normal",
2781
+ in: "SourceGraphic",
2782
+ in2: "effect1_dropShadow",
2783
+ result: "shape"
2784
+ }
2785
+ )
2786
+ ]
2787
+ }
2788
+ ),
2789
+ /* @__PURE__ */ n("clipPath", { id: "clip0_empty_state", children: /* @__PURE__ */ n("rect", { width: "233", height: "233", fill: "white" }) })
2790
+ ] })
2791
+ ]
2792
+ }
2793
+ ), hn = P.memo(
2794
+ ({ hasChannels: e, channelsLoaded: t }) => /* @__PURE__ */ n("div", { className: "messaging-empty-state flex items-center justify-center h-full p-8 text-balance", children: /* @__PURE__ */ m("div", { className: "flex flex-col items-center max-w-sm text-center", children: [
2795
+ /* @__PURE__ */ n(ar, {}),
2796
+ t && !e && /* @__PURE__ */ m("div", { className: "mt-8", children: [
2797
+ /* @__PURE__ */ n("h2", { className: "font-medium text-black text-[18px] mb-2", children: "Your inbox is empty" }),
2798
+ /* @__PURE__ */ n("p", { className: "text-[#676B5F] text-sm mb-6", children: "Share with your followers to start receiving messages" })
2799
+ ] })
2800
+ ] }) })
2801
+ );
2802
+ hn.displayName = "EmptyState";
2803
+ const Te = P.memo(({ message: e, onBack: t }) => /* @__PURE__ */ n("div", { className: "messaging-error-state flex items-center justify-center h-full p-8", children: /* @__PURE__ */ m("div", { className: "text-center max-w-sm", children: [
2804
+ /* @__PURE__ */ n("div", { className: "w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6", children: /* @__PURE__ */ n("span", { className: "text-4xl", children: "⚠️" }) }),
2805
+ /* @__PURE__ */ n("h2", { className: "font-semibold text-charcoal mb-2", children: "Oops!" }),
2806
+ /* @__PURE__ */ n("p", { className: "text-stone text-sm mb-6", children: e }),
2807
+ t && /* @__PURE__ */ n(
2808
+ "button",
2809
+ {
2810
+ type: "button",
2811
+ onClick: t,
2812
+ 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",
2813
+ children: "Go Back"
2814
+ }
2815
+ )
2816
+ ] }) }));
2817
+ Te.displayName = "ErrorState";
2818
+ const ki = ({
2819
+ capabilities: e = {},
2820
+ className: t,
2821
+ renderMessageInputActions: s,
2822
+ renderConversationFooter: a,
2823
+ onChannelSelect: r,
2824
+ initialParticipantFilter: i,
2825
+ initialParticipantData: l,
2826
+ CustomChannelEmptyState: o,
2827
+ showChannelList: d = !0,
2828
+ filters: h,
2829
+ channelRenderFilterFn: g,
2830
+ channelListCustomEmptyStateIndicator: u,
2831
+ onDeleteConversationClick: f,
2832
+ onBlockParticipantClick: c,
2833
+ onReportParticipantClick: b,
2834
+ dmAgentEnabled: x,
2835
+ messageMetadata: v,
2836
+ onMessageSent: N,
2837
+ showStarButton: w = !1,
2838
+ chatbotVotingEnabled: E = !1,
2839
+ viewerLanguage: I,
2840
+ renderMessagePreview: S,
2841
+ renderChannelBanner: D,
2842
+ customProfileContent: T,
2843
+ customChannelActions: F,
2844
+ renderMessage: M,
2845
+ onMessageLinkClick: R,
2846
+ sendButton: A
2847
+ }) => {
2848
+ const {
2849
+ service: G,
2850
+ client: k,
2851
+ isConnected: j,
2852
+ isLoading: W,
2853
+ error: V,
2854
+ refreshConnection: $,
2855
+ debug: L
2856
+ } = Rs(), [Y, _] = z(null), [O, p] = z(!1), [C, H] = z(!1), [q, he] = z(!1), [J, ee] = z(null), { showDeleteConversation: Ce = !0 } = e, ke = P.useMemo(() => {
2857
+ const B = k == null ? void 0 : k.userID;
2858
+ return {
2859
+ ...{
2860
+ type: "messaging",
2861
+ last_message_at: { $exists: !0 },
2862
+ ...B && {
2863
+ members: { $in: [B] },
2864
+ hidden: !1
2865
+ }
2866
+ },
2867
+ ...h
2868
+ };
2869
+ }, [h, k == null ? void 0 : k.userID]), ce = Z(null), te = U(async () => {
2870
+ if (!k || !j) return;
2871
+ const B = k.userID;
2872
+ if (B)
2873
+ try {
2874
+ L && console.log("[MessagingShell] Syncing channels for user:", B);
2875
+ const K = await k.queryChannels(
2876
+ {
2877
+ type: "messaging",
2878
+ members: { $in: [B] }
2879
+ },
2880
+ {},
2881
+ { limit: 100 }
2882
+ );
2883
+ p(K.length > 0), H(!0), ce.current = B, L && console.log("[MessagingShell] Channels synced successfully:", {
2884
+ channelCount: K.length
2885
+ });
2886
+ } catch (K) {
2887
+ console.error("[MessagingShell] Failed to sync channels:", K);
2888
+ }
2889
+ }, [k, j, L]);
2890
+ X(() => {
2891
+ if (!k || !j) return;
2892
+ const B = k.userID;
2893
+ B && ce.current !== B && te();
2894
+ }, [k, j, te]), X(() => {
2895
+ if (!i || !k || !j) return;
2896
+ (async () => {
2897
+ const K = k.userID;
2898
+ if (K)
2899
+ try {
2900
+ L && console.log(
2901
+ "[MessagingShell] Loading initial conversation with:",
2902
+ i
2903
+ );
2904
+ const Q = await k.queryChannels(
2905
+ {
2906
+ type: "messaging",
2907
+ members: { $eq: [K, i] }
2908
+ },
2909
+ {},
2910
+ { limit: 1 }
2911
+ );
2912
+ if (Q.length > 0)
2913
+ _(Q[0]), he(!0), ee(null), r && r(Q[0]), L && console.log(
2914
+ "[MessagingShell] Initial conversation loaded:",
2915
+ Q[0].id
2916
+ );
2917
+ else if (l && G) {
2918
+ L && console.log(
2919
+ "[MessagingShell] No conversation found, creating one for:",
2920
+ l
2921
+ );
2922
+ try {
2923
+ const ae = await G.startChannelWithParticipant({
2924
+ id: l.id,
2925
+ name: l.name,
2926
+ phone: l.phone
2927
+ });
2928
+ _(ae), he(!0), ee(null), r && r(ae), L && console.log(
2929
+ "[MessagingShell] Channel created and loaded:",
2930
+ ae.id
2931
+ );
2932
+ } catch (ae) {
2933
+ console.error(
2934
+ "[MessagingShell] Failed to create conversation:",
2935
+ ae
2936
+ ), ee("Failed to create conversation");
2937
+ }
2938
+ } else
2939
+ ee(
2940
+ "No conversation found with this account"
2941
+ ), L && console.log(
2942
+ "[MessagingShell] No conversation found for:",
2943
+ i
2944
+ );
2945
+ } catch (Q) {
2946
+ console.error(
2947
+ "[MessagingShell] Failed to load initial conversation:",
2948
+ Q
2949
+ ), ee("Failed to load conversation");
2950
+ }
2951
+ })();
2952
+ }, [
2953
+ i,
2954
+ l,
2955
+ k,
2956
+ j,
2957
+ G,
2958
+ L,
2959
+ r
2960
+ ]);
2961
+ const se = U(
2962
+ (B) => {
2963
+ _(B), r == null || r(B);
2964
+ },
2965
+ [r]
2966
+ ), de = U(() => {
2967
+ q || _(null);
2968
+ }, [q]), Oe = U(
2969
+ async (B) => {
2970
+ L && console.log("[MessagingShell] Leaving conversation:", B.id), _(null), he(!1), ce.current = null, await te();
2971
+ },
2972
+ [te, L]
2973
+ ), Ee = U(
2974
+ async (B) => {
2975
+ L && console.log("[MessagingShell] Blocking participant:", B), _(null), he(!1), ce.current = null, await te();
2976
+ },
2977
+ [te, L]
2978
+ ), ue = !!Y;
2979
+ return W ? /* @__PURE__ */ n("div", { className: y("h-full", t), children: /* @__PURE__ */ n(Ae, {}) }) : V ? /* @__PURE__ */ n("div", { className: y("h-full", t), children: /* @__PURE__ */ n(Te, { message: V, onBack: $ }) }) : !j || !k ? /* @__PURE__ */ n("div", { className: y("h-full", t), children: /* @__PURE__ */ n(
2980
+ Te,
2981
+ {
2982
+ message: "Not connected to messaging service",
2983
+ onBack: $
2984
+ }
2985
+ ) }) : J ? /* @__PURE__ */ n("div", { className: y("h-full", t), children: /* @__PURE__ */ n(Te, { message: J }) }) : /* @__PURE__ */ n(
2986
+ "div",
2987
+ {
2988
+ className: y(
2989
+ "messaging-shell h-full bg-background-primary overflow-hidden",
2990
+ t
2991
+ ),
2992
+ children: /* @__PURE__ */ m("div", { className: "flex h-full min-h-0", children: [
2993
+ /* @__PURE__ */ n(
2994
+ "div",
2995
+ {
2996
+ className: y(
2997
+ "messaging-channel-list-sidebar min-h-0 min-w-0 lg:flex lg:flex-col",
2998
+ {
2999
+ "!hidden": d === !1 || q,
3000
+ // Hide on mobile when channel selected, show on desktop with consistent wide width
3001
+ "hidden lg:flex lg:flex-1 lg:max-w-2xl": d !== !1 && !q && ue,
3002
+ // Show on mobile when no channel selected, use same wide width on desktop
3003
+ "flex flex-col w-full lg:flex-1 lg:max-w-2xl": d !== !1 && !q && !ue
3004
+ }
3005
+ ),
3006
+ children: /* @__PURE__ */ n(
3007
+ Qt,
3008
+ {
3009
+ onChannelSelect: se,
3010
+ selectedChannel: Y || void 0,
3011
+ filters: ke,
3012
+ channelRenderFilterFn: g,
3013
+ customEmptyStateIndicator: u,
3014
+ renderMessagePreview: S,
3015
+ viewerLanguage: I
3016
+ }
3017
+ )
3018
+ }
3019
+ ),
3020
+ /* @__PURE__ */ n(
3021
+ "div",
3022
+ {
3023
+ className: y(
3024
+ "messaging-conversation-view flex-1 flex-col min-w-0 min-h-0",
3025
+ {
3026
+ // In direct conversation mode (or waiting for it), always show (full width)
3027
+ flex: q || ue || i,
3028
+ // Normal mode: hide on mobile when no channel selected
3029
+ "hidden lg:flex": !q && !ue && !i
3030
+ }
3031
+ ),
3032
+ children: Y ? /* @__PURE__ */ n("div", { className: "flex-1 min-h-0 flex flex-col", children: /* @__PURE__ */ n(
3033
+ mn,
3034
+ {
3035
+ channel: Y,
3036
+ onBack: de,
3037
+ showBackButton: !q,
3038
+ renderMessageInputActions: s,
3039
+ renderConversationFooter: a,
3040
+ renderChannelBanner: D,
3041
+ onLeaveConversation: Oe,
3042
+ onBlockParticipant: Ee,
3043
+ CustomChannelEmptyState: o,
3044
+ showDeleteConversation: Ce,
3045
+ onDeleteConversationClick: f,
3046
+ onBlockParticipantClick: c,
3047
+ onReportParticipantClick: b,
3048
+ dmAgentEnabled: x,
3049
+ messageMetadata: v,
3050
+ onMessageSent: N,
3051
+ showStarButton: w,
3052
+ chatbotVotingEnabled: E,
3053
+ viewerLanguage: I,
3054
+ customProfileContent: T,
3055
+ customChannelActions: F,
3056
+ renderMessage: M,
3057
+ onMessageLinkClick: R,
3058
+ sendButton: A
3059
+ },
3060
+ Y.id
3061
+ ) }) : i ? (
3062
+ // Show loading while creating/loading direct conversation channel
3063
+ /* @__PURE__ */ n(Ae, {})
3064
+ ) : /* @__PURE__ */ n(
3065
+ hn,
3066
+ {
3067
+ hasChannels: O,
3068
+ channelsLoaded: C
3069
+ }
3070
+ )
3071
+ }
3072
+ )
3073
+ ] })
3074
+ }
3075
+ );
3076
+ }, rr = /^([a-z][a-z0-9+.-]*):/i, ir = /* @__PURE__ */ new Set(["http", "https", "mailto", "tel", "sms"]);
3077
+ function fn(e) {
3078
+ if (typeof e != "string") return;
3079
+ const t = e.trim();
3080
+ if (t === "") return;
3081
+ const s = rr.exec(t);
3082
+ if (s) {
3083
+ const a = s[1].toLowerCase();
3084
+ return ir.has(a) ? t : void 0;
3085
+ }
3086
+ return t.startsWith("//") || t.startsWith("/") ? t : `https://${t}`;
3087
+ }
3088
+ const or = {
3089
+ dark: "bg-white text-[#121110] hover:bg-white/90",
3090
+ light: "bg-[#121110] text-white hover:bg-[#2a2928]"
3091
+ }, lr = ({ variant: e, cta: t }) => {
3092
+ const s = y(
3093
+ "mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",
3094
+ or[e]
3095
+ ), a = fn(t.href);
3096
+ return a ? /* @__PURE__ */ n(
3097
+ "a",
3098
+ {
3099
+ href: a,
3100
+ target: "_blank",
3101
+ rel: "noopener noreferrer",
3102
+ onClick: (r) => {
3103
+ var i;
3104
+ r.stopPropagation(), (i = t.onClick) == null || i.call(t);
3105
+ },
3106
+ className: `${s} no-underline`,
3107
+ children: t.label
3108
+ }
3109
+ ) : /* @__PURE__ */ n(
3110
+ "button",
3111
+ {
3112
+ type: "button",
3113
+ onClick: (r) => {
3114
+ var i;
3115
+ r.stopPropagation(), (i = t.onClick) == null || i.call(t);
3116
+ },
3117
+ className: s,
3118
+ children: t.label
3119
+ }
3120
+ );
3121
+ }, cr = {
3122
+ dark: "text-white",
3123
+ light: "text-black/90"
3124
+ }, dr = "text-white/30", ur = {
3125
+ dark: "text-white/55",
3126
+ light: "text-black/55"
3127
+ }, ot = ({
3128
+ variant: e,
3129
+ title: t,
3130
+ placeholderTitle: s,
3131
+ description: a,
3132
+ url: r,
3133
+ appIcon: i,
3134
+ cta: l,
3135
+ trailingAction: o
3136
+ }) => {
3137
+ const d = e === "dark", h = t ?? (d ? s : void 0) ?? "", g = h.trim() !== "", u = a != null && a.trim() !== "", f = typeof r == "string" ? r.trim() : "", c = f !== "", b = l != null;
3138
+ if (!g && !u && !c && !b) return null;
3139
+ const v = y(
3140
+ "truncate text-base font-medium leading-6",
3141
+ d && !t ? dr : cr[e]
3142
+ ), N = y(
3143
+ "truncate text-xs leading-4",
3144
+ ur[e]
3145
+ );
3146
+ return /* @__PURE__ */ m("div", { className: "px-4 py-3", children: [
3147
+ /* @__PURE__ */ m("div", { className: "flex items-end gap-3", children: [
3148
+ /* @__PURE__ */ m("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [
3149
+ /* @__PURE__ */ m("div", { className: "flex min-w-0 flex-col gap-1", children: [
3150
+ g && /* @__PURE__ */ m("div", { className: "flex min-w-0 items-center gap-2", children: [
3151
+ i ? /* @__PURE__ */ n("span", { className: "shrink-0", children: i }) : null,
3152
+ /* @__PURE__ */ n("p", { className: y("min-w-0", v), children: h })
3153
+ ] }),
3154
+ u && /* @__PURE__ */ n("p", { className: N, children: a })
3155
+ ] }),
3156
+ !b && c && /* @__PURE__ */ n("p", { className: N, children: f })
3157
+ ] }),
3158
+ o && /* @__PURE__ */ n("div", { className: "shrink-0", children: o })
3159
+ ] }),
3160
+ l && /* @__PURE__ */ n(lr, { variant: e, cta: l })
3161
+ ] });
3162
+ }, mr = y(
3163
+ "relative block w-[280px] select-none overflow-hidden rounded-md",
3164
+ // 1px hairline border that sits flush with the card chrome — matches
3165
+ // the messaging design system's "small border around link attachments"
3166
+ // treatment from the mobile spec. The drop shadow remains for depth.
3167
+ "border border-black/[0.08]",
3168
+ "shadow-[0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]"
3169
+ ), De = ({
3170
+ variant: e,
3171
+ children: t,
3172
+ href: s,
3173
+ onClick: a,
3174
+ ariaLabel: r,
3175
+ rootRef: i,
3176
+ topRight: l,
3177
+ bgClassName: o,
3178
+ "data-testid": d
3179
+ }) => {
3180
+ const h = s != null || a != null, g = y(
3181
+ mr,
3182
+ o ?? (e === "dark" ? "bg-[#121110]" : "bg-white"),
3183
+ // `focus-ring` is a design-system utility from the component-library
3184
+ // tailwind preset — outline-none + a black 2px focus-visible ring
3185
+ // with offset, so keyboard users can see the focused card.
3186
+ h ? "cursor-pointer no-underline focus-ring" : null
3187
+ ), u = l ? /* @__PURE__ */ n("div", { className: "pointer-events-auto absolute right-3 top-3 z-10", children: l }) : null;
3188
+ return s ? /* @__PURE__ */ m(
3189
+ "a",
3190
+ {
3191
+ ref: i,
3192
+ href: s,
3193
+ target: "_blank",
3194
+ rel: "noopener noreferrer",
3195
+ onClick: a,
3196
+ "data-testid": d,
3197
+ className: g,
3198
+ children: [
3199
+ t,
3200
+ u
3201
+ ]
3202
+ }
3203
+ ) : a ? /* @__PURE__ */ m(
3204
+ "button",
3205
+ {
3206
+ ref: i,
3207
+ type: "button",
3208
+ onClick: a,
3209
+ "aria-label": r,
3210
+ "data-testid": d,
3211
+ className: y(g, "text-left"),
3212
+ children: [
3213
+ t,
3214
+ u
3215
+ ]
3216
+ }
3217
+ ) : /* @__PURE__ */ m(
3218
+ "div",
3219
+ {
3220
+ ref: i,
3221
+ "data-testid": d,
3222
+ className: g,
3223
+ children: [
3224
+ t,
3225
+ u
3226
+ ]
3227
+ }
3228
+ );
3229
+ }, hr = {
3230
+ dark: "bg-white/10",
3231
+ light: "bg-black/5"
3232
+ }, fr = {
3233
+ dark: "size-16 text-white/25",
3234
+ light: "size-16 text-black/25"
3235
+ }, Fe = (e, t) => !!t && !!e && le(e) === "audio", gr = (e, t) => {
3236
+ if (!t || !e) return !1;
3237
+ const s = le(e);
3238
+ return s === "video" || s === "audio";
3239
+ }, lt = "bg-[#F2F3F4]", Re = ({
3240
+ variant: e,
3241
+ thumbnailUrl: t,
3242
+ sourceUrl: s,
3243
+ title: a,
3244
+ mimeType: r = "image/*",
3245
+ topLeft: i,
3246
+ topRight: l
3247
+ }) => {
3248
+ const o = le(r), d = !!s && o === "video";
3249
+ return Fe(r, s) ? /* @__PURE__ */ n("div", { className: "p-3", children: /* @__PURE__ */ n(
3250
+ "audio",
3251
+ {
3252
+ src: s,
3253
+ controls: !0,
3254
+ preload: "metadata",
3255
+ className: "block w-full",
3256
+ children: /* @__PURE__ */ n("track", { kind: "captions" })
3257
+ }
3258
+ ) }) : /* @__PURE__ */ m(
3259
+ "div",
3260
+ {
3261
+ className: y(
3262
+ "relative h-[180px] w-full overflow-hidden",
3263
+ d && "bg-black"
3264
+ ),
3265
+ children: [
3266
+ d ? /* @__PURE__ */ n(
3267
+ "video",
3268
+ {
3269
+ src: s,
3270
+ poster: t,
3271
+ controls: !0,
3272
+ playsInline: !0,
3273
+ preload: "metadata",
3274
+ className: "absolute inset-0 h-full w-full object-contain",
3275
+ children: /* @__PURE__ */ n("track", { kind: "captions" })
3276
+ }
3277
+ ) : t ? /* @__PURE__ */ n(
3278
+ "img",
3279
+ {
3280
+ src: t,
3281
+ alt: a ?? "",
3282
+ draggable: !1,
3283
+ className: "absolute inset-0 h-full w-full object-cover"
3284
+ }
3285
+ ) : /* @__PURE__ */ n(
3286
+ "div",
3287
+ {
3288
+ className: y(
3289
+ "flex h-full w-full items-center justify-center",
3290
+ hr[e]
3291
+ ),
3292
+ children: ge(r, {
3293
+ className: fr[e],
3294
+ weight: "regular"
3295
+ })
3296
+ }
3297
+ ),
3298
+ i ? /* @__PURE__ */ n("div", { className: "pointer-events-auto absolute left-3 top-3 z-10", children: i }) : null,
3299
+ l ? /* @__PURE__ */ n("div", { className: "pointer-events-auto absolute right-3 top-3 z-10", children: l }) : null
3300
+ ]
3301
+ }
3302
+ );
3303
+ }, br = ({
3304
+ title: e,
3305
+ placeholderTitle: t,
3306
+ description: s,
3307
+ url: a,
3308
+ mimeType: r,
3309
+ thumbnailUrl: i,
3310
+ sourceUrl: l,
3311
+ layout: o = "featured",
3312
+ appIcon: d,
3313
+ cta: h,
3314
+ onDismiss: g,
3315
+ onEditClick: u
3316
+ }) => {
3317
+ const f = o === "classic", c = Fe(r, l), b = g ? /* @__PURE__ */ n(
3318
+ "button",
3319
+ {
3320
+ type: "button",
3321
+ onClick: g,
3322
+ "aria-label": "Dismiss attachment",
3323
+ className: "flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",
3324
+ children: /* @__PURE__ */ n(xe, { className: "size-3", weight: "bold" })
3325
+ }
3326
+ ) : void 0, x = u ? /* @__PURE__ */ n(
3327
+ "button",
3328
+ {
3329
+ type: "button",
3330
+ onClick: u,
3331
+ "aria-label": "Edit attachment",
3332
+ className: "flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",
3333
+ children: /* @__PURE__ */ n(Ms, { className: "size-5", weight: "regular" })
3334
+ }
3335
+ ) : void 0;
3336
+ return c ? /* @__PURE__ */ n(De, { variant: "dark", bgClassName: lt, children: /* @__PURE__ */ m("div", { className: "flex items-center gap-2 pr-3", children: [
3337
+ /* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ n(
3338
+ Re,
3339
+ {
3340
+ variant: "dark",
3341
+ sourceUrl: l,
3342
+ title: e,
3343
+ mimeType: r
3344
+ }
3345
+ ) }),
3346
+ b && /* @__PURE__ */ n("div", { className: "shrink-0", children: b })
3347
+ ] }) }) : /* @__PURE__ */ m(
3348
+ De,
3349
+ {
3350
+ variant: "dark",
3351
+ topRight: f ? b : void 0,
3352
+ children: [
3353
+ !f && /* @__PURE__ */ n(
3354
+ Re,
3355
+ {
3356
+ variant: "dark",
3357
+ thumbnailUrl: i,
3358
+ sourceUrl: l,
3359
+ title: e,
3360
+ mimeType: r,
3361
+ topRight: b
3362
+ }
3363
+ ),
3364
+ /* @__PURE__ */ n(
3365
+ ot,
3366
+ {
3367
+ variant: "dark",
3368
+ title: e,
3369
+ placeholderTitle: t,
3370
+ description: s,
3371
+ url: a,
3372
+ appIcon: d,
3373
+ cta: h,
3374
+ trailingAction: x
3375
+ }
3376
+ )
3377
+ ]
3378
+ }
3379
+ );
3380
+ }, pr = ({
3381
+ title: e,
3382
+ description: t,
3383
+ url: s,
3384
+ mimeType: a,
3385
+ thumbnailUrl: r,
3386
+ sourceUrl: i,
3387
+ layout: l = "featured",
3388
+ appIcon: o,
3389
+ cta: d,
3390
+ onClick: h
3391
+ }) => {
3392
+ const g = gr(a, i), u = fn(s), f = d == null && u != null && !g ? u : void 0, c = d == null && !g ? h : void 0, b = Fe(a, i) ? lt : void 0, x = d && h ? {
3393
+ ...d,
3394
+ onClick: () => {
3395
+ var v;
3396
+ h(), (v = d.onClick) == null || v.call(d);
3397
+ }
3398
+ } : d;
3399
+ return /* @__PURE__ */ m(
3400
+ De,
3401
+ {
3402
+ variant: "light",
3403
+ href: f,
3404
+ onClick: c,
3405
+ ariaLabel: e ?? "Open attachment preview",
3406
+ bgClassName: b,
3407
+ "data-testid": "link-attachment",
3408
+ children: [
3409
+ l === "featured" && /* @__PURE__ */ n(
3410
+ Re,
3411
+ {
3412
+ variant: "light",
3413
+ thumbnailUrl: r,
3414
+ sourceUrl: i,
3415
+ title: e,
3416
+ mimeType: a
3417
+ }
3418
+ ),
3419
+ /* @__PURE__ */ n(
3420
+ ot,
3421
+ {
3422
+ variant: "light",
3423
+ title: e,
3424
+ description: t,
3425
+ url: s,
3426
+ appIcon: o,
3427
+ cta: x
3428
+ }
3429
+ )
3430
+ ]
3431
+ }
3432
+ );
3433
+ }, vr = ({
3434
+ title: e,
3435
+ placeholderTitle: t,
3436
+ description: s,
3437
+ url: a,
3438
+ mimeType: r,
3439
+ thumbnailUrl: i,
3440
+ sourceUrl: l,
3441
+ layout: o = "featured",
3442
+ appIcon: d,
3443
+ cta: h
3444
+ }) => /* @__PURE__ */ m(
3445
+ De,
3446
+ {
3447
+ variant: "dark",
3448
+ bgClassName: Fe(r, l) ? lt : void 0,
3449
+ children: [
3450
+ o === "featured" && /* @__PURE__ */ n(
3451
+ Re,
3452
+ {
3453
+ variant: "dark",
3454
+ thumbnailUrl: i,
3455
+ sourceUrl: l,
3456
+ title: e,
3457
+ mimeType: r
3458
+ }
3459
+ ),
3460
+ /* @__PURE__ */ n(
3461
+ ot,
3462
+ {
3463
+ variant: "dark",
3464
+ title: e,
3465
+ placeholderTitle: t,
3466
+ description: s,
3467
+ url: a,
3468
+ appIcon: d,
3469
+ cta: h
3470
+ }
3471
+ )
3472
+ ]
3473
+ }
3474
+ ), Ei = {
3475
+ Composer: br,
3476
+ Sent: vr,
3477
+ Received: pr
3478
+ }, xr = {
3479
+ dark: "bg-[#121110]",
3480
+ light: "bg-[#e9eaed]"
3481
+ }, wr = {
3482
+ dark: "text-white",
3483
+ light: "text-[#080707]"
3484
+ }, Nr = {
3485
+ dark: "border-white/[0.08]",
3486
+ light: "border-black/[0.08]"
3487
+ }, yr = (e) => e === "dark" ? "sender" : "receiver", _r = {
3488
+ sender: {
3489
+ single: "rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",
3490
+ first: "rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[4px]",
3491
+ middle: "rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[4px]",
3492
+ end: "rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[18px]"
3493
+ },
3494
+ receiver: {
3495
+ single: "rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",
3496
+ first: "rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",
3497
+ middle: "rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",
3498
+ end: "rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]"
3499
+ }
3500
+ }, we = ({
3501
+ variant: e,
3502
+ text: t,
3503
+ bordered: s = !0,
3504
+ groupPosition: a = "single",
3505
+ className: r,
3506
+ children: i,
3507
+ "data-testid": l
3508
+ }) => {
3509
+ const o = t != null && t !== "", d = _r[yr(e)][a];
3510
+ return /* @__PURE__ */ m(
3511
+ "div",
3512
+ {
3513
+ "data-testid": l,
3514
+ "data-group-position": a,
3515
+ className: y(
3516
+ // 280px-wide bubble — matches the mobile chat attachment width
3517
+ // and keeps the document / image / audio bubbles visually
3518
+ // consistent inside the conversation timeline. The 8px / 16px
3519
+ // inset matches `--str-chat__spacing-2 --str-chat__spacing-4`
3520
+ // so attachments share the same hit / negative-space rhythm
3521
+ // as the surrounding `CustomMessage` text bubbles.
3522
+ "relative w-[280px] overflow-hidden px-2 py-2",
3523
+ d,
3524
+ xr[e],
3525
+ wr[e],
3526
+ s && "border",
3527
+ s && Nr[e],
3528
+ r
3529
+ ),
3530
+ children: [
3531
+ i,
3532
+ o ? /* @__PURE__ */ n(
3533
+ "p",
3534
+ {
3535
+ className: y(
3536
+ // No `text-*` / `font-*` overrides here — caption inherits
3537
+ // the same font family + size as `.str-chat__message-text`
3538
+ // so it matches the surrounding `CustomMessage` bubbles.
3539
+ "whitespace-pre-wrap break-words leading-snug",
3540
+ // Top gutter only — bubble's `py-2` already supplies the
3541
+ // bottom inset, and the children above already render
3542
+ // flush against their own bottom edge.
3543
+ "pt-2",
3544
+ "px-2"
3545
+ ),
3546
+ children: t
3547
+ }
3548
+ ) : null
3549
+ ]
3550
+ }
3551
+ );
3552
+ }, Ne = ({
3553
+ onClick: e,
3554
+ variant: t = "overlay",
3555
+ ariaLabel: s = "Dismiss attachment"
3556
+ }) => /* @__PURE__ */ n(
3557
+ "button",
3558
+ {
3559
+ type: "button",
3560
+ onClick: (a) => {
3561
+ a.stopPropagation(), e();
3562
+ },
3563
+ "aria-label": s,
3564
+ className: y(
3565
+ "flex size-6 items-center justify-center rounded-full text-white",
3566
+ t === "overlay" ? "bg-[#121110]/85 backdrop-blur" : "bg-white/15 hover:bg-white/25"
3567
+ ),
3568
+ children: /* @__PURE__ */ n(xe, { className: "size-3", weight: "bold" })
3569
+ }
3570
+ ), ye = (e) => e === "received" ? "light" : "dark", Ii = ({
3571
+ firstOfGroup: e,
3572
+ endOfGroup: t,
3573
+ groupedByUser: s
3574
+ }) => !s || e && t ? "single" : e ? "first" : t ? "end" : "middle", Cr = ({
3575
+ src: e,
3576
+ mimeType: t,
3577
+ filename: s,
3578
+ items: a
3579
+ }) => a && a.length > 0 ? a : e ? [{ src: e, mimeType: t, filename: s }] : [], kr = ({ item: e, preload: t, trailingAction: s }) => /* @__PURE__ */ m("div", { className: "flex items-center gap-2", children: [
3580
+ /* @__PURE__ */ n(
3581
+ "audio",
3582
+ {
3583
+ src: e.src,
3584
+ controls: !0,
3585
+ preload: e.preload ?? t,
3586
+ className: "block min-w-0 flex-1",
3587
+ children: e.mimeType ? /* @__PURE__ */ n("source", { src: e.src, type: e.mimeType }) : null
3588
+ }
3589
+ ),
3590
+ s ?? null
3591
+ ] }), ct = ({
3592
+ state: e,
3593
+ src: t,
3594
+ mimeType: s,
3595
+ filename: a,
3596
+ items: r,
3597
+ text: i,
3598
+ groupPosition: l,
3599
+ preload: o,
3600
+ onDismiss: d
3601
+ }) => {
3602
+ const h = ye(e), g = e === "composer" && !!d, u = Cr({ src: t, mimeType: s, filename: a, items: r });
3603
+ if (u.length === 0)
3604
+ return null;
3605
+ const f = o ?? (u.length > 1 ? "none" : "metadata");
3606
+ return /* @__PURE__ */ n(
3607
+ we,
3608
+ {
3609
+ variant: h,
3610
+ text: i,
3611
+ groupPosition: l,
3612
+ "data-testid": "audio-attachment",
3613
+ children: /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: u.map((c, b) => /* @__PURE__ */ n(
3614
+ kr,
3615
+ {
3616
+ item: c,
3617
+ preload: f,
3618
+ trailingAction: (
3619
+ // Composer only supports a single attachment, so the
3620
+ // dismiss control sits on the only player.
3621
+ g && b === 0 ? /* @__PURE__ */ n(Ne, { onClick: d, variant: "inline" }) : void 0
3622
+ )
3623
+ },
3624
+ `${c.src}-${b}`
3625
+ )) })
3626
+ }
3627
+ );
3628
+ }, Er = (e) => /* @__PURE__ */ n(ct, { ...e, state: "composer" }), Ir = (e) => /* @__PURE__ */ n(ct, { ...e, state: "sent" }), Sr = (e) => /* @__PURE__ */ n(ct, { ...e, state: "received" }), Tr = {
3629
+ Composer: Er,
3630
+ Sent: Ir,
3631
+ Received: Sr
3632
+ };
3633
+ function Mr(e) {
3634
+ return !Number.isFinite(e) || e < 0 ? "" : e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : e < 1024 * 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(2)} MB` : `${(e / (1024 * 1024 * 1024)).toFixed(2)} GB`;
3635
+ }
3636
+ const Ar = {
3637
+ pdf: "PDF",
3638
+ doc: "DOC",
3639
+ xls: "XLS",
3640
+ csv: "CSV",
3641
+ ppt: "PPT",
3642
+ zip: "ZIP",
3643
+ text: "TXT",
3644
+ markdown: "MD"
3645
+ };
3646
+ function Dr(e, t) {
3647
+ if (t) {
3648
+ const r = t.lastIndexOf(".");
3649
+ if (r > 0 && r < t.length - 1) {
3650
+ const i = t.slice(r + 1);
3651
+ if (i && i.length <= 5) return i.toUpperCase();
3652
+ }
3653
+ }
3654
+ if (!e) return;
3655
+ if (le(e) === "document") {
3656
+ const r = nn(e), i = Ar[r];
3657
+ if (i) return i;
3658
+ if (e === "application/octet-stream") return;
3659
+ }
3660
+ const a = e.split("/")[1];
3661
+ if (!(!a || a === "*"))
3662
+ return a.toUpperCase();
3663
+ }
3664
+ function Rr(e, t, s) {
3665
+ const a = Dr(e, t), r = typeof s == "number" && s > 0 ? Mr(s) : void 0;
3666
+ return [a, r].filter(Boolean).join(" · ") || void 0;
3667
+ }
3668
+ function ne(e) {
3669
+ try {
3670
+ const s = new URL(e).pathname.split("/").pop();
3671
+ return s && s.length > 0 ? decodeURIComponent(s) : "download";
3672
+ } catch {
3673
+ return "download";
3674
+ }
3675
+ }
3676
+ const Lr = {
3677
+ dark: "text-white/55",
3678
+ light: "text-black/65"
3679
+ }, Fr = {
3680
+ dark: "bg-white/10",
3681
+ light: "bg-black/5"
3682
+ }, Or = {
3683
+ dark: "text-white/85",
3684
+ light: "text-black/85"
3685
+ }, gn = ({
3686
+ variant: e,
3687
+ filename: t,
3688
+ title: s,
3689
+ mimeType: a = "application/octet-stream",
3690
+ fileSize: r,
3691
+ onActivate: i,
3692
+ activateLabel: l,
3693
+ trailingAction: o
3694
+ }) => {
3695
+ const d = s ?? t ?? "File", h = Rr(a, t, r), g = /* @__PURE__ */ n(
3696
+ "div",
3697
+ {
3698
+ className: y(
3699
+ "flex size-10 shrink-0 items-center justify-center rounded-sm",
3700
+ Fr[e]
3701
+ ),
3702
+ "aria-hidden": !0,
3703
+ children: ge(a, {
3704
+ className: y("size-6", Or[e]),
3705
+ weight: "regular"
3706
+ })
3707
+ }
3708
+ ), u = /* @__PURE__ */ m("div", { className: "flex min-w-0 flex-1 flex-col text-left", children: [
3709
+ /* @__PURE__ */ n("p", { className: "truncate font-medium leading-snug", children: d }),
3710
+ h ? /* @__PURE__ */ n(
3711
+ "p",
3712
+ {
3713
+ className: y(
3714
+ "truncate text-xs leading-4",
3715
+ Lr[e]
3716
+ ),
3717
+ children: h
3718
+ }
3719
+ ) : null
3720
+ ] }), f = i ? /* @__PURE__ */ m(
3721
+ "button",
3722
+ {
3723
+ type: "button",
3724
+ onClick: i,
3725
+ "aria-label": l,
3726
+ className: y(
3727
+ "flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",
3728
+ e === "dark" ? "hover:bg-white/[0.04]" : "hover:bg-black/[0.04]"
3729
+ ),
3730
+ children: [
3731
+ g,
3732
+ u
3733
+ ]
3734
+ }
3735
+ ) : /* @__PURE__ */ m(ie, { children: [
3736
+ g,
3737
+ u
3738
+ ] });
3739
+ return /* @__PURE__ */ m("div", { className: "flex items-center gap-3 px-3 py-2", children: [
3740
+ f,
3741
+ o ? /* @__PURE__ */ n("div", { className: "shrink-0", children: o }) : null
3742
+ ] });
3743
+ };
3744
+ async function bn(e, t) {
3745
+ const s = t ?? ne(e);
3746
+ try {
3747
+ const a = await fetch(e, { mode: "cors" });
3748
+ if (!a.ok) throw new Error(`HTTP ${a.status}`);
3749
+ const r = await a.blob(), i = URL.createObjectURL(r), l = document.createElement("a");
3750
+ l.href = i, l.download = s, l.style.display = "none", document.body.appendChild(l), l.click(), document.body.removeChild(l), URL.revokeObjectURL(i);
3751
+ } catch {
3752
+ if (!window.open(e, "_blank", "noopener,noreferrer")) {
3753
+ const r = document.createElement("a");
3754
+ r.href = e, r.download = s, r.target = "_blank", r.rel = "noopener noreferrer", r.style.display = "none", document.body.appendChild(r), r.click(), document.body.removeChild(r);
3755
+ }
3756
+ }
3757
+ }
3758
+ const zr = ({
3759
+ src: e,
3760
+ filename: t,
3761
+ fileSize: s,
3762
+ mimeType: a,
3763
+ title: r,
3764
+ items: i
3765
+ }) => i && i.length > 0 ? i : e ? [{ src: e, filename: t, fileSize: s, mimeType: a, title: r }] : [], Pr = ({
3766
+ variant: e,
3767
+ item: t,
3768
+ index: s,
3769
+ onActivate: a,
3770
+ trailingAction: r
3771
+ }) => {
3772
+ const i = t.filename ?? ne(t.src);
3773
+ return /* @__PURE__ */ n(
3774
+ gn,
3775
+ {
3776
+ variant: e,
3777
+ filename: i,
3778
+ title: t.title,
3779
+ mimeType: t.mimeType ?? "application/octet-stream",
3780
+ fileSize: t.fileSize,
3781
+ onActivate: () => a(s),
3782
+ activateLabel: `Download ${i}`,
3783
+ trailingAction: r
3784
+ }
3785
+ );
3786
+ }, dt = ({
3787
+ state: e,
3788
+ src: t,
3789
+ filename: s,
3790
+ fileSize: a,
3791
+ mimeType: r,
3792
+ title: i,
3793
+ items: l,
3794
+ text: o,
3795
+ groupPosition: d,
3796
+ onClick: h,
3797
+ onDismiss: g
3798
+ }) => {
3799
+ const u = ye(e), f = e === "composer" && !!g, c = zr({
3800
+ src: t,
3801
+ filename: s,
3802
+ fileSize: a,
3803
+ mimeType: r,
3804
+ title: i,
3805
+ items: l
3806
+ }), b = (v) => {
3807
+ if ((h == null ? void 0 : h(v)) === !1) return;
3808
+ const N = c[v];
3809
+ if (!N) return;
3810
+ const w = N.filename ?? ne(N.src);
3811
+ bn(N.src, w);
3812
+ };
3813
+ if (c.length === 0)
3814
+ return null;
3815
+ const x = /* @__PURE__ */ n(
3816
+ "span",
3817
+ {
3818
+ className: y(
3819
+ "flex size-8 items-center justify-center rounded-full",
3820
+ u === "dark" ? "text-white/70" : "text-black/70"
3821
+ ),
3822
+ "aria-hidden": !0,
3823
+ children: /* @__PURE__ */ n(ve, { className: "size-5", weight: "bold" })
3824
+ }
3825
+ );
3826
+ return /* @__PURE__ */ n(
3827
+ we,
3828
+ {
3829
+ variant: u,
3830
+ text: o,
3831
+ groupPosition: d,
3832
+ "data-testid": "file-attachment",
3833
+ children: /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: c.map((v, N) => /* @__PURE__ */ n(
3834
+ Pr,
3835
+ {
3836
+ variant: u,
3837
+ item: v,
3838
+ index: N,
3839
+ onActivate: b,
3840
+ trailingAction: f && N === 0 ? /* @__PURE__ */ n(Ne, { onClick: g, variant: "inline" }) : x
3841
+ },
3842
+ `${v.src}-${N}`
3843
+ )) })
3844
+ }
3845
+ );
3846
+ }, Br = (e) => /* @__PURE__ */ n(dt, { ...e, state: "composer" }), $r = (e) => /* @__PURE__ */ n(dt, { ...e, state: "sent" }), jr = (e) => /* @__PURE__ */ n(dt, { ...e, state: "received" }), Ur = {
3847
+ Composer: Br,
3848
+ Sent: $r,
3849
+ Received: jr
3850
+ }, ut = ({
3851
+ onPrev: e,
3852
+ onNext: t,
3853
+ prevLabel: s = "Previous",
3854
+ nextLabel: a = "Next"
3855
+ }) => /* @__PURE__ */ m(ie, { children: [
3856
+ /* @__PURE__ */ n(
3857
+ "button",
3858
+ {
3859
+ type: "button",
3860
+ onClick: e,
3861
+ "aria-label": s,
3862
+ className: "mes-media-viewer__nav mes-media-viewer__nav--prev",
3863
+ children: /* @__PURE__ */ n(As, { size: 20, weight: "bold", "aria-hidden": !0 })
3864
+ }
3865
+ ),
3866
+ /* @__PURE__ */ n(
3867
+ "button",
3868
+ {
3869
+ type: "button",
3870
+ onClick: t,
3871
+ "aria-label": a,
3872
+ className: "mes-media-viewer__nav mes-media-viewer__nav--next",
3873
+ children: /* @__PURE__ */ n(We, { size: 20, weight: "bold", "aria-hidden": !0 })
3874
+ }
3875
+ )
3876
+ ] }), pn = ({
3877
+ url: e,
3878
+ filename: t,
3879
+ variant: s = "pill",
3880
+ label: a = "Download",
3881
+ iconOnly: r,
3882
+ tone: i = "dark",
3883
+ onTriggered: l
3884
+ }) => {
3885
+ const [o, d] = z(!1), h = U(
3886
+ (c) => {
3887
+ c.stopPropagation(), !o && (d(!0), bn(e, t).catch(() => {
3888
+ }).finally(() => {
3889
+ d(!1), l == null || l();
3890
+ }));
3891
+ },
3892
+ [o, e, t, l]
3893
+ ), g = r ?? s !== "pill", f = { className: y(
3894
+ s === "pill" ? "size-4" : "size-5",
3895
+ "shrink-0"
3896
+ ), weight: "bold" };
3897
+ return s === "inline" ? /* @__PURE__ */ n(
3898
+ "button",
3899
+ {
3900
+ type: "button",
3901
+ onClick: h,
3902
+ disabled: o,
3903
+ "aria-label": a,
3904
+ className: y(
3905
+ "flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",
3906
+ {
3907
+ dark: "text-white/70 hover:bg-white/[0.08] hover:text-white",
3908
+ light: "text-black/70 hover:bg-black/[0.08] hover:text-black"
3909
+ }[i]
3910
+ ),
3911
+ children: o ? /* @__PURE__ */ n(
3912
+ pe,
3913
+ {
3914
+ className: "size-4 animate-spin",
3915
+ weight: "bold",
3916
+ "aria-hidden": !0
3917
+ }
3918
+ ) : /* @__PURE__ */ n(
3919
+ ve,
3920
+ {
3921
+ className: "size-5 shrink-0",
3922
+ weight: "bold",
3923
+ "aria-hidden": !0
3924
+ }
3925
+ )
3926
+ }
3927
+ ) : s === "viewer" ? /* @__PURE__ */ n(
3928
+ "button",
3929
+ {
3930
+ type: "button",
3931
+ onClick: h,
3932
+ disabled: o,
3933
+ "aria-label": a,
3934
+ className: "mes-media-viewer__action",
3935
+ children: o ? /* @__PURE__ */ n(pe, { size: 20, weight: "bold", "aria-hidden": !0 }) : /* @__PURE__ */ n(ve, { size: 20, weight: "bold", "aria-hidden": !0 })
3936
+ }
3937
+ ) : /* @__PURE__ */ m(
3938
+ "button",
3939
+ {
3940
+ type: "button",
3941
+ onClick: h,
3942
+ disabled: o,
3943
+ "aria-label": g ? a : void 0,
3944
+ className: y(
3945
+ "mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full px-4 text-sm font-medium leading-none transition-colors disabled:opacity-70",
3946
+ i === "dark" ? "bg-[#121110] text-white hover:bg-[#2a2928]" : "bg-white text-[#121110] hover:bg-white/90"
3947
+ ),
3948
+ children: [
3949
+ o ? /* @__PURE__ */ n(
3950
+ pe,
3951
+ {
3952
+ className: "size-4 animate-spin",
3953
+ weight: "bold",
3954
+ "aria-hidden": !0
3955
+ }
3956
+ ) : /* @__PURE__ */ n(ve, { ...f, "aria-hidden": !0 }),
3957
+ g ? null : a
3958
+ ]
3959
+ }
3960
+ );
3961
+ }, Ve = (e, t, s) => Math.min(Math.max(e, t), s), mt = ({
3962
+ length: e,
3963
+ initialIndex: t,
3964
+ open: s
3965
+ }) => {
3966
+ const a = Ve(t, 0, Math.max(e - 1, 0)), [r, i] = z(a);
3967
+ X(() => {
3968
+ s && i(Ve(t, 0, Math.max(e - 1, 0)));
3969
+ }, [s, t, e]), X(() => {
3970
+ i((d) => Ve(d, 0, Math.max(e - 1, 0)));
3971
+ }, [e]);
3972
+ const l = U(() => {
3973
+ e <= 1 || i((d) => d <= 0 ? e - 1 : d - 1);
3974
+ }, [e]), o = U(() => {
3975
+ e <= 1 || i((d) => d >= e - 1 ? 0 : d + 1);
3976
+ }, [e]);
3977
+ return X(() => {
3978
+ if (!s || e <= 1) return;
3979
+ const d = (h) => {
3980
+ if (h.key !== "ArrowLeft" && h.key !== "ArrowRight") return;
3981
+ const g = document.activeElement;
3982
+ g && (g.tagName === "VIDEO" || g.tagName === "AUDIO") || (h.preventDefault(), h.key === "ArrowLeft" ? l() : o());
3983
+ };
3984
+ return window.addEventListener("keydown", d), () => window.removeEventListener("keydown", d);
3985
+ }, [s, e, l, o]), { index: r, prev: l, next: o };
3986
+ }, ht = ({
3987
+ open: e,
3988
+ onClose: t,
3989
+ ariaLabel: s,
3990
+ counter: a,
3991
+ actions: r,
3992
+ children: i,
3993
+ "data-testid": l
3994
+ }) => {
3995
+ const o = Z(null), d = Z(null);
3996
+ return X(() => {
3997
+ var f;
3998
+ const u = o.current;
3999
+ if (u) {
4000
+ if (e) {
4001
+ if (!u.open)
4002
+ if (typeof u.showModal == "function")
4003
+ try {
4004
+ u.showModal();
4005
+ } catch {
4006
+ u.setAttribute("open", "");
4007
+ }
4008
+ else
4009
+ u.setAttribute("open", "");
4010
+ const c = typeof document < "u" ? document.activeElement : null;
4011
+ return (f = d.current) == null || f.focus(), () => {
4012
+ if (u.open)
4013
+ if (typeof u.close == "function")
4014
+ try {
4015
+ u.close();
4016
+ } catch {
4017
+ u.removeAttribute("open");
4018
+ }
4019
+ else
4020
+ u.removeAttribute("open");
4021
+ c && document.body.contains(c) && c.focus();
4022
+ };
4023
+ }
4024
+ if (u.open)
4025
+ if (typeof u.close == "function")
4026
+ try {
4027
+ u.close();
4028
+ } catch {
4029
+ u.removeAttribute("open");
4030
+ }
4031
+ else
4032
+ u.removeAttribute("open");
4033
+ }
4034
+ }, [e]), // The native `<dialog>` element ships its own keyboard dismissal
4035
+ // (Escape, handled by the platform and surfaced through `onClose`),
4036
+ // so the `onClick` on the backdrop doesn't need a paired keyboard
4037
+ // listener — that's the whole point of using `<dialog>`. The
4038
+ // `jsx-a11y` rules below don't model `<dialog>` as interactive, so
4039
+ // we silence them locally with the rationale captured here.
4040
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
4041
+ /* @__PURE__ */ m(
4042
+ "dialog",
4043
+ {
4044
+ ref: o,
4045
+ className: "mes-media-viewer",
4046
+ "aria-label": s ?? "Attachment viewer",
4047
+ "data-testid": l,
4048
+ onClose: () => {
4049
+ t();
4050
+ },
4051
+ onClick: (u) => {
4052
+ u.target === o.current && t();
4053
+ },
4054
+ children: [
4055
+ /* @__PURE__ */ m("div", { className: "mes-media-viewer__chrome", children: [
4056
+ a ? /* @__PURE__ */ n("span", { className: "mes-media-viewer__counter", children: a }) : null,
4057
+ /* @__PURE__ */ m("div", { className: "mes-media-viewer__actions", children: [
4058
+ r,
4059
+ /* @__PURE__ */ n(
4060
+ "button",
4061
+ {
4062
+ ref: d,
4063
+ type: "button",
4064
+ onClick: t,
4065
+ "aria-label": "Close viewer",
4066
+ className: "mes-media-viewer__action",
4067
+ children: /* @__PURE__ */ n(xe, { size: 20, weight: "bold", "aria-hidden": !0 })
4068
+ }
4069
+ )
4070
+ ] })
4071
+ ] }),
4072
+ /* @__PURE__ */ n("div", { className: "mes-media-viewer__body", children: i })
4073
+ ]
4074
+ }
4075
+ );
4076
+ }, vn = ({
4077
+ open: e,
4078
+ items: t,
4079
+ initialIndex: s = 0,
4080
+ onClose: a
4081
+ }) => {
4082
+ const { index: r, prev: i, next: l } = mt({
4083
+ length: t.length,
4084
+ initialIndex: s,
4085
+ open: e
4086
+ }), o = t[r], d = re(
4087
+ () => (o == null ? void 0 : o.filename) ?? (o ? ne(o.src) : "image"),
4088
+ [o]
4089
+ );
4090
+ return o ? /* @__PURE__ */ m(
4091
+ ht,
4092
+ {
4093
+ open: e,
4094
+ onClose: a,
4095
+ ariaLabel: d,
4096
+ counter: t.length > 1 ? `${r + 1} / ${t.length}` : void 0,
4097
+ actions: /* @__PURE__ */ n(
4098
+ pn,
4099
+ {
4100
+ url: o.src,
4101
+ filename: d,
4102
+ variant: "viewer",
4103
+ label: `Download ${d}`
4104
+ }
4105
+ ),
4106
+ "data-testid": "image-viewer",
4107
+ children: [
4108
+ /* @__PURE__ */ n(
4109
+ "img",
4110
+ {
4111
+ src: o.src,
4112
+ alt: o.alt ?? d,
4113
+ draggable: !1,
4114
+ loading: "eager",
4115
+ decoding: "async",
4116
+ className: "mes-media-viewer__image"
4117
+ },
4118
+ `${r}:${o.src}`
4119
+ ),
4120
+ t.length > 1 ? /* @__PURE__ */ n(
4121
+ ut,
4122
+ {
4123
+ onPrev: i,
4124
+ onNext: l,
4125
+ prevLabel: "Previous image",
4126
+ nextLabel: "Next image"
4127
+ }
4128
+ ) : null
4129
+ ]
4130
+ }
4131
+ ) : null;
4132
+ }, Vr = "relative block size-full overflow-hidden bg-black/5 outline-none focus-visible:ring-2 focus-visible:ring-white/80 focus-visible:ring-offset-2 focus-visible:ring-offset-black", xn = ({
4133
+ tiles: e,
4134
+ onTileActivate: t,
4135
+ maxVisible: s = 4,
4136
+ className: a
4137
+ }) => {
4138
+ const r = e.length;
4139
+ if (r === 0) return null;
4140
+ const i = e.slice(0, Math.min(r, s)), l = r - i.length, o = (d, h, g) => {
4141
+ const u = y(Vr, "h-full w-full");
4142
+ return t ? /* @__PURE__ */ m(
4143
+ "button",
4144
+ {
4145
+ type: "button",
4146
+ onClick: () => t(h),
4147
+ "aria-label": d.ariaLabel ?? `Open media ${h + 1}`,
4148
+ className: y(u, "cursor-zoom-in"),
4149
+ children: [
4150
+ d.content,
4151
+ g
4152
+ ]
4153
+ },
4154
+ h
4155
+ ) : /* @__PURE__ */ m("div", { className: u, children: [
4156
+ d.content,
4157
+ g
4158
+ ] }, h);
4159
+ };
4160
+ return i.length === 1 ? /* @__PURE__ */ n("div", { className: y("aspect-square w-full", a), children: o(i[0], 0) }) : i.length === 2 ? /* @__PURE__ */ n(
4161
+ "div",
4162
+ {
4163
+ className: y(
4164
+ "grid aspect-[16/9] w-full grid-cols-2 gap-0.5",
4165
+ a
4166
+ ),
4167
+ children: i.map((d, h) => o(d, h))
4168
+ }
4169
+ ) : i.length === 3 ? /* @__PURE__ */ m(
4170
+ "div",
4171
+ {
4172
+ className: y(
4173
+ "grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",
4174
+ a
4175
+ ),
4176
+ children: [
4177
+ /* @__PURE__ */ n("div", { className: "row-span-2", children: o(i[0], 0) }),
4178
+ o(i[1], 1),
4179
+ o(i[2], 2)
4180
+ ]
4181
+ }
4182
+ ) : /* @__PURE__ */ n(
4183
+ "div",
4184
+ {
4185
+ className: y(
4186
+ "grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",
4187
+ a
4188
+ ),
4189
+ children: i.map((d, h) => {
4190
+ const g = l > 0 && h === i.length - 1;
4191
+ return o(
4192
+ d,
4193
+ h,
4194
+ g ? /* @__PURE__ */ m("div", { className: "absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white", children: [
4195
+ "+",
4196
+ l
4197
+ ] }) : null
4198
+ );
4199
+ })
4200
+ }
4201
+ );
4202
+ }, _e = (e) => {
4203
+ const [t, s] = z(!1), [a, r] = z(0), i = U(
4204
+ (o) => {
4205
+ (e == null ? void 0 : e(o)) !== !1 && (r(o), s(!0));
4206
+ },
4207
+ [e]
4208
+ ), l = U(() => s(!1), []);
4209
+ return { viewerOpen: t, viewerIndex: a, handleActivate: i, closeViewer: l };
4210
+ }, Gr = (e, t, s, a) => ({
4211
+ ariaLabel: `Open image ${t + 1} of ${s}`,
4212
+ content: /* @__PURE__ */ n(
4213
+ "img",
4214
+ {
4215
+ src: e.src,
4216
+ alt: e.alt ?? "",
4217
+ width: e.width,
4218
+ height: e.height,
4219
+ draggable: !1,
4220
+ loading: e.loading ?? a,
4221
+ decoding: "async",
4222
+ className: "absolute inset-0 size-full rounded-md object-cover"
4223
+ }
4224
+ )
4225
+ }), Hr = ({
4226
+ src: e,
4227
+ alt: t,
4228
+ items: s
4229
+ }) => s && s.length > 0 ? s : e ? [{ src: e, alt: t }] : [], wn = (e, t) => e.map((s, a) => ({
4230
+ src: s.src,
4231
+ alt: s.alt,
4232
+ filename: t && e.length === 1 ? t : t ? `${t} (${a + 1})` : void 0
4233
+ })), Yr = ({ src: e, alt: t, filename: s, loading: a = "lazy", onClick: r, onDismiss: i }) => {
4234
+ const { viewerOpen: l, viewerIndex: o, handleActivate: d, closeViewer: h } = _e(
4235
+ r
4236
+ );
4237
+ return /* @__PURE__ */ m("div", { className: "relative w-fit", children: [
4238
+ /* @__PURE__ */ n(
4239
+ "button",
4240
+ {
4241
+ type: "button",
4242
+ onClick: () => d(0),
4243
+ "aria-label": "Open image",
4244
+ className: "block size-[280px] cursor-zoom-in overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",
4245
+ children: /* @__PURE__ */ n(
4246
+ "img",
4247
+ {
4248
+ src: e,
4249
+ alt: t ?? "",
4250
+ draggable: !1,
4251
+ loading: a,
4252
+ decoding: "async",
4253
+ className: "size-full object-cover"
4254
+ }
4255
+ )
4256
+ }
4257
+ ),
4258
+ i ? /* @__PURE__ */ n("div", { className: "absolute right-2 top-2 z-10", children: /* @__PURE__ */ n(Ne, { onClick: i }) }) : null,
4259
+ /* @__PURE__ */ n(
4260
+ vn,
4261
+ {
4262
+ open: l,
4263
+ items: wn([{ src: e, alt: t }], s),
4264
+ initialIndex: o,
4265
+ onClose: h
4266
+ }
4267
+ )
4268
+ ] });
4269
+ }, Nn = ({
4270
+ state: e,
4271
+ src: t,
4272
+ alt: s,
4273
+ filename: a,
4274
+ items: r,
4275
+ text: i,
4276
+ groupPosition: l,
4277
+ loading: o = "lazy",
4278
+ onClick: d
4279
+ }) => {
4280
+ const h = Hr({ src: t, alt: s, items: r }), g = ye(e), { viewerOpen: u, viewerIndex: f, handleActivate: c, closeViewer: b } = _e(
4281
+ d
4282
+ );
4283
+ if (h.length === 0)
4284
+ return null;
4285
+ const x = h.map(
4286
+ (v, N) => Gr(v, N, h.length, o)
4287
+ );
4288
+ return /* @__PURE__ */ m(
4289
+ we,
4290
+ {
4291
+ variant: g,
4292
+ text: i,
4293
+ groupPosition: l,
4294
+ "data-testid": "image-attachment",
4295
+ children: [
4296
+ /* @__PURE__ */ n("div", { className: "relative", children: /* @__PURE__ */ n(xn, { tiles: x, onTileActivate: c }) }),
4297
+ /* @__PURE__ */ n(
4298
+ vn,
4299
+ {
4300
+ open: u,
4301
+ items: wn(h, a),
4302
+ initialIndex: f,
4303
+ onClose: b
4304
+ }
4305
+ )
4306
+ ]
4307
+ }
4308
+ );
4309
+ }, Wr = (e) => /* @__PURE__ */ n(Yr, { ...e }), qr = (e) => /* @__PURE__ */ n(Nn, { ...e, state: "sent" }), Xr = (e) => /* @__PURE__ */ n(Nn, { ...e, state: "received" }), Zr = {
4310
+ Composer: Wr,
4311
+ Sent: qr,
4312
+ Received: Xr
4313
+ }, Kr = ({
4314
+ open: e,
4315
+ items: t,
4316
+ initialIndex: s = 0,
4317
+ onClose: a
4318
+ }) => {
4319
+ const { index: r, prev: i, next: l } = mt({
4320
+ length: t.length,
4321
+ initialIndex: s,
4322
+ open: e
4323
+ }), o = t[r], d = re(
4324
+ () => (o == null ? void 0 : o.filename) ?? (o ? ne(o.src) : "document"),
4325
+ [o]
4326
+ ), h = re(
4327
+ () => o ? Jr(o.src) : void 0,
4328
+ [o]
4329
+ );
4330
+ return !o || !h ? null : /* @__PURE__ */ m(
4331
+ ht,
4332
+ {
4333
+ open: e,
4334
+ onClose: a,
4335
+ ariaLabel: d,
4336
+ counter: t.length > 1 ? `${r + 1} / ${t.length}` : void 0,
4337
+ "data-testid": "pdf-viewer",
4338
+ children: [
4339
+ /* @__PURE__ */ n(
4340
+ "iframe",
4341
+ {
4342
+ src: h,
4343
+ title: d,
4344
+ className: "mes-media-viewer__iframe",
4345
+ sandbox: "allow-scripts allow-forms allow-popups allow-downloads"
4346
+ },
4347
+ `${r}:${o.src}`
4348
+ ),
4349
+ t.length > 1 ? /* @__PURE__ */ n(
4350
+ ut,
4351
+ {
4352
+ onPrev: i,
4353
+ onNext: l,
4354
+ prevLabel: "Previous document",
4355
+ nextLabel: "Next document"
4356
+ }
4357
+ ) : null
4358
+ ]
4359
+ }
4360
+ );
4361
+ }, Jr = (e) => {
4362
+ const t = e.indexOf("#"), s = t === -1 ? e : e.slice(0, t), a = t === -1 ? "" : e.slice(t + 1), r = new URLSearchParams(a);
4363
+ return r.has("toolbar") || r.set("toolbar", "0"), r.has("navpanes") || r.set("navpanes", "0"), `${s}#${r.toString()}`;
4364
+ }, Qr = ({
4365
+ src: e,
4366
+ filename: t,
4367
+ fileSize: s,
4368
+ title: a,
4369
+ items: r
4370
+ }) => r && r.length > 0 ? r : e ? [{ src: e, filename: t, fileSize: s, title: a }] : [], ei = ({
4371
+ variant: e,
4372
+ item: t,
4373
+ index: s,
4374
+ onActivate: a,
4375
+ trailingAction: r
4376
+ }) => {
4377
+ const i = t.filename ?? ne(t.src);
4378
+ return /* @__PURE__ */ n(
4379
+ gn,
4380
+ {
4381
+ variant: e,
4382
+ filename: i,
4383
+ title: t.title,
4384
+ mimeType: "application/pdf",
4385
+ fileSize: t.fileSize,
4386
+ onActivate: () => a(s),
4387
+ activateLabel: `Open ${i}`,
4388
+ trailingAction: r
4389
+ }
4390
+ );
4391
+ }, ft = ({
4392
+ state: e,
4393
+ src: t,
4394
+ filename: s,
4395
+ fileSize: a,
4396
+ title: r,
4397
+ items: i,
4398
+ text: l,
4399
+ groupPosition: o,
4400
+ onClick: d,
4401
+ onDismiss: h
4402
+ }) => {
4403
+ const g = ye(e), u = Qr({ src: t, filename: s, fileSize: a, title: r, items: i }), { viewerOpen: f, viewerIndex: c, handleActivate: b, closeViewer: x } = _e(
4404
+ d
4405
+ ), v = e === "composer" && !!h;
4406
+ if (u.length === 0)
4407
+ return null;
4408
+ const N = u.map((w) => ({
4409
+ src: w.src,
4410
+ filename: w.filename ?? ne(w.src)
4411
+ }));
4412
+ return /* @__PURE__ */ m(
4413
+ we,
4414
+ {
4415
+ variant: g,
4416
+ text: l,
4417
+ groupPosition: o,
4418
+ "data-testid": "pdf-attachment",
4419
+ children: [
4420
+ /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: u.map((w, E) => {
4421
+ const I = w.filename ?? ne(w.src), S = v && E === 0 ? /* @__PURE__ */ n(Ne, { onClick: h, variant: "inline" }) : e === "composer" ? void 0 : /* @__PURE__ */ n(
4422
+ pn,
4423
+ {
4424
+ url: w.src,
4425
+ filename: I,
4426
+ variant: "inline",
4427
+ label: `Download ${I}`,
4428
+ tone: g
4429
+ }
4430
+ );
4431
+ return /* @__PURE__ */ n(
4432
+ ei,
4433
+ {
4434
+ variant: g,
4435
+ item: w,
4436
+ index: E,
4437
+ onActivate: b,
4438
+ trailingAction: S
4439
+ },
4440
+ `${w.src}-${E}`
4441
+ );
4442
+ }) }),
4443
+ /* @__PURE__ */ n(
4444
+ Kr,
4445
+ {
4446
+ open: f,
4447
+ items: N,
4448
+ initialIndex: c,
4449
+ onClose: x
4450
+ }
4451
+ )
4452
+ ]
4453
+ }
4454
+ );
4455
+ }, ti = (e) => /* @__PURE__ */ n(ft, { ...e, state: "composer" }), ni = (e) => /* @__PURE__ */ n(ft, { ...e, state: "sent" }), si = (e) => /* @__PURE__ */ n(ft, { ...e, state: "received" }), ai = {
4456
+ Composer: ti,
4457
+ Sent: ni,
4458
+ Received: si
4459
+ }, yn = ({
4460
+ open: e,
4461
+ items: t,
4462
+ initialIndex: s = 0,
4463
+ onClose: a
4464
+ }) => {
4465
+ const { index: r, prev: i, next: l } = mt({
4466
+ length: t.length,
4467
+ initialIndex: s,
4468
+ open: e
4469
+ }), o = t[r], d = re(
4470
+ () => (o == null ? void 0 : o.filename) ?? (o ? ne(o.src) : "video"),
4471
+ [o]
4472
+ );
4473
+ return o ? /* @__PURE__ */ m(
4474
+ ht,
4475
+ {
4476
+ open: e,
4477
+ onClose: a,
4478
+ ariaLabel: d,
4479
+ counter: t.length > 1 ? `${r + 1} / ${t.length}` : void 0,
4480
+ "data-testid": "video-viewer",
4481
+ children: [
4482
+ /* @__PURE__ */ n(
4483
+ "video",
4484
+ {
4485
+ src: o.src,
4486
+ poster: o.poster,
4487
+ controls: !0,
4488
+ autoPlay: !0,
4489
+ muted: !0,
4490
+ playsInline: !0,
4491
+ preload: o.preload ?? "metadata",
4492
+ className: "mes-media-viewer__video",
4493
+ children: o.mimeType ? /* @__PURE__ */ n("source", { src: o.src, type: o.mimeType }) : null
4494
+ },
4495
+ `${r}:${o.src}`
4496
+ ),
4497
+ t.length > 1 ? /* @__PURE__ */ n(
4498
+ ut,
4499
+ {
4500
+ onPrev: i,
4501
+ onNext: l,
4502
+ prevLabel: "Previous video",
4503
+ nextLabel: "Next video"
4504
+ }
4505
+ ) : null
4506
+ ]
4507
+ }
4508
+ ) : null;
4509
+ }, ri = () => /* @__PURE__ */ n("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ n("span", { className: "flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur", children: /* @__PURE__ */ n(He, { className: "size-6", weight: "fill", "aria-hidden": !0 }) }) }), _n = ({
4510
+ item: e,
4511
+ index: t
4512
+ }) => /* @__PURE__ */ m("div", { className: "absolute inset-0 size-full bg-[#0d0d0d]", children: [
4513
+ e.poster ? /* @__PURE__ */ n(
4514
+ "img",
4515
+ {
4516
+ src: e.poster,
4517
+ alt: `Video ${t + 1} thumbnail`,
4518
+ draggable: !1,
4519
+ loading: "lazy",
4520
+ decoding: "async",
4521
+ className: "absolute inset-0 size-full rounded-md object-cover"
4522
+ }
4523
+ ) : /* @__PURE__ */ n("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ n(
4524
+ Ht,
4525
+ {
4526
+ className: "size-16 rounded-md text-white/30",
4527
+ weight: "regular",
4528
+ "aria-hidden": !0
4529
+ }
4530
+ ) }),
4531
+ /* @__PURE__ */ n(ri, {})
4532
+ ] }), ii = (e, t, s) => ({
4533
+ ariaLabel: `Play video ${t + 1} of ${s}`,
4534
+ content: /* @__PURE__ */ n(_n, { item: e, index: t })
4535
+ }), oi = ({
4536
+ src: e,
4537
+ poster: t,
4538
+ mimeType: s,
4539
+ preload: a,
4540
+ items: r
4541
+ }) => r && r.length > 0 ? a ? r.map((i) => ({ ...i, preload: i.preload ?? a })) : r : e ? [{ src: e, poster: t, mimeType: s, preload: a }] : [], Cn = (e, t) => e.map((s, a) => ({
4542
+ src: s.src,
4543
+ poster: s.poster,
4544
+ mimeType: s.mimeType,
4545
+ preload: s.preload,
4546
+ filename: t && e.length === 1 ? t : t ? `${t} (${a + 1})` : void 0
4547
+ })), li = ({ src: e, poster: t, mimeType: s, filename: a, preload: r, onClick: i, onDismiss: l }) => {
4548
+ const { viewerOpen: o, viewerIndex: d, handleActivate: h, closeViewer: g } = _e(
4549
+ i
4550
+ );
4551
+ return /* @__PURE__ */ m("div", { className: "relative w-fit", children: [
4552
+ /* @__PURE__ */ n(
4553
+ "button",
4554
+ {
4555
+ type: "button",
4556
+ onClick: () => h(0),
4557
+ "aria-label": "Play video",
4558
+ className: "relative block size-[280px] cursor-pointer overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",
4559
+ children: /* @__PURE__ */ n(_n, { item: { src: e, poster: t, mimeType: s }, index: 0 })
4560
+ }
4561
+ ),
4562
+ l ? /* @__PURE__ */ n("div", { className: "absolute right-2 top-2 z-10", children: /* @__PURE__ */ n(Ne, { onClick: l }) }) : null,
4563
+ /* @__PURE__ */ n(
4564
+ yn,
4565
+ {
4566
+ open: o,
4567
+ items: Cn(
4568
+ [{ src: e, poster: t, mimeType: s, preload: r }],
4569
+ a
4570
+ ),
4571
+ initialIndex: d,
4572
+ onClose: g
4573
+ }
4574
+ )
4575
+ ] });
4576
+ }, kn = ({
4577
+ state: e,
4578
+ src: t,
4579
+ poster: s,
4580
+ mimeType: a,
4581
+ filename: r,
4582
+ items: i,
4583
+ text: l,
4584
+ groupPosition: o,
4585
+ preload: d,
4586
+ onClick: h
4587
+ }) => {
4588
+ const g = oi({ src: t, poster: s, mimeType: a, preload: d, items: i }), u = ye(e), { viewerOpen: f, viewerIndex: c, handleActivate: b, closeViewer: x } = _e(
4589
+ h
4590
+ );
4591
+ if (g.length === 0)
4592
+ return null;
4593
+ const v = g.map(
4594
+ (N, w) => ii(N, w, g.length)
4595
+ );
4596
+ return /* @__PURE__ */ m(
4597
+ we,
4598
+ {
4599
+ variant: u,
4600
+ text: l,
4601
+ groupPosition: o,
4602
+ "data-testid": "video-attachment",
4603
+ children: [
4604
+ /* @__PURE__ */ n("div", { className: "relative", children: /* @__PURE__ */ n(
4605
+ xn,
4606
+ {
4607
+ tiles: v,
4608
+ onTileActivate: b,
4609
+ className: "overflow-hidden rounded-md"
4610
+ }
4611
+ ) }),
4612
+ /* @__PURE__ */ n(
4613
+ yn,
4614
+ {
4615
+ open: f,
4616
+ items: Cn(g, r),
4617
+ initialIndex: c,
4618
+ onClose: x
4619
+ }
4620
+ )
4621
+ ]
4622
+ }
4623
+ );
4624
+ }, ci = (e) => /* @__PURE__ */ n(li, { ...e }), di = (e) => /* @__PURE__ */ n(kn, { ...e, state: "sent" }), ui = (e) => /* @__PURE__ */ n(kn, { ...e, state: "received" }), mi = {
4625
+ Composer: ci,
4626
+ Sent: di,
4627
+ Received: ui
4628
+ }, Si = {
4629
+ Image: Zr,
4630
+ Video: mi,
4631
+ Audio: Tr,
4632
+ Pdf: ai,
4633
+ File: Ur
4634
+ }, hi = ({
4635
+ question: e,
4636
+ onClick: t,
4637
+ loading: s = !1,
4638
+ className: a
4639
+ }) => /* @__PURE__ */ n(
4640
+ "button",
4641
+ {
4642
+ type: "button",
4643
+ onClick: t,
4644
+ disabled: s,
4645
+ style: { backgroundColor: "#E6E5E3" },
4646
+ className: y(
4647
+ "w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",
4648
+ {
4649
+ "hover:brightness-95 active:brightness-90": !s,
4650
+ "opacity-50 cursor-not-allowed": s
4651
+ },
4652
+ a
4653
+ ),
4654
+ children: e
4655
+ }
4656
+ ), Ti = ({
4657
+ faqs: e,
4658
+ onFaqClick: t,
4659
+ loadingFaqId: s,
4660
+ headerText: a,
4661
+ className: r,
4662
+ avatarImage: i,
4663
+ avatarName: l
4664
+ }) => {
4665
+ const o = e.filter((d) => d.enabled).sort((d, h) => (d.order ?? 0) - (h.order ?? 0));
4666
+ return o.length === 0 ? null : /* @__PURE__ */ n("div", { className: r, children: /* @__PURE__ */ m("div", { className: "flex gap-3 items-end", children: [
4667
+ (i || l) && /* @__PURE__ */ n("div", { className: "flex-none", children: /* @__PURE__ */ n(
4668
+ oe,
4669
+ {
4670
+ id: l || "account",
4671
+ name: l || "Account",
4672
+ image: i,
4673
+ size: 24,
4674
+ shape: "circle"
4675
+ }
4676
+ ) }),
4677
+ /* @__PURE__ */ m(
4678
+ "div",
4679
+ {
4680
+ className: "flex-1 flex flex-col gap-3 rounded-lg p-4",
4681
+ style: { backgroundColor: "#F1F0EE" },
4682
+ children: [
4683
+ a && /* @__PURE__ */ n("p", { className: "text-md text-charcoal mb-4", children: a }),
4684
+ o.map((d) => /* @__PURE__ */ n(
4685
+ hi,
4686
+ {
4687
+ question: d.question,
4688
+ onClick: () => t(d.id),
4689
+ loading: s === d.id
4690
+ },
4691
+ d.id
4692
+ ))
4693
+ ]
4694
+ }
4695
+ )
4696
+ ] }) });
4697
+ };
4698
+ export {
4699
+ sn as A,
4700
+ ta as B,
4701
+ er as C,
4702
+ Rs as D,
4703
+ Ti as F,
4704
+ Ei as L,
4705
+ _i as M,
4706
+ Se as a,
4707
+ oe as b,
4708
+ Qt as c,
4709
+ mn as d,
4710
+ Ci as e,
4711
+ hi as f,
4712
+ le as g,
4713
+ Pt as h,
4714
+ Si as i,
4715
+ Sa as j,
4716
+ yi as k,
4717
+ ki as l,
4718
+ Rr as m,
4719
+ Mr as n,
4720
+ Ps as o,
4721
+ Dr as p,
4722
+ Zt as q,
4723
+ ge as r,
4724
+ on as s,
4725
+ js as t,
4726
+ Ii as u,
4727
+ Bs as v,
4728
+ rt as w,
4729
+ it as x,
4730
+ tt as y,
4731
+ Ia as z
4732
+ };
4733
+ //# sourceMappingURL=index-CeHWbIiy.js.map