@linktr.ee/messaging-react 2.3.0-rc-1779427772 → 2.3.0

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