@linktr.ee/messaging-react 2.1.0 → 2.2.0-rc-1778753733

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