@linktr.ee/messaging-react 4.2.0-rc-1787325521 → 4.2.0-rc-1787325710

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 (51) hide show
  1. package/dist/AttachmentCard-C-X0jLZ2.cjs +2 -0
  2. package/dist/AttachmentCard-C-X0jLZ2.cjs.map +1 -0
  3. package/dist/AttachmentCard-D2IoHdcv.js +410 -0
  4. package/dist/AttachmentCard-D2IoHdcv.js.map +1 -0
  5. package/dist/Card-C7uLQbYz.js +105 -0
  6. package/dist/Card-C7uLQbYz.js.map +1 -0
  7. package/dist/Card-DENHpLIC.cjs +2 -0
  8. package/dist/Card-DENHpLIC.cjs.map +1 -0
  9. package/dist/Card-Ds1FMcUj.cjs +2 -0
  10. package/dist/Card-Ds1FMcUj.cjs.map +1 -0
  11. package/dist/Card-EKD9NkTa.js +498 -0
  12. package/dist/Card-EKD9NkTa.js.map +1 -0
  13. package/dist/LoadingDots-BSk_UeS0.cjs +2 -0
  14. package/dist/LoadingDots-BSk_UeS0.cjs.map +1 -0
  15. package/dist/LoadingDots-B_WiXBeQ.js +73 -0
  16. package/dist/LoadingDots-B_WiXBeQ.js.map +1 -0
  17. package/dist/assets/index.css +2 -1
  18. package/dist/index.cjs +3 -2
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.ts +0 -26
  21. package/dist/index.js +4071 -41
  22. package/dist/index.js.map +1 -1
  23. package/dist/rolldown-runtime-BocRIvOZ.cjs +1 -0
  24. package/dist/testing.cjs +2 -2
  25. package/dist/testing.cjs.map +1 -1
  26. package/dist/testing.js +106 -118
  27. package/dist/testing.js.map +1 -1
  28. package/package.json +5 -5
  29. package/src/components/ChannelView.stories.tsx +0 -4
  30. package/src/index.ts +0 -3
  31. package/src/providers/MessagingProvider.test.tsx +1 -127
  32. package/src/providers/MessagingProvider.tsx +15 -26
  33. package/src/types.ts +0 -8
  34. package/dist/Card-BYJyA83X.js +0 -701
  35. package/dist/Card-BYJyA83X.js.map +0 -1
  36. package/dist/Card-Be81K6su.cjs +0 -2
  37. package/dist/Card-Be81K6su.cjs.map +0 -1
  38. package/dist/Card-BplJtZao.cjs +0 -2
  39. package/dist/Card-BplJtZao.cjs.map +0 -1
  40. package/dist/Card-BzvDr-pU.js +0 -112
  41. package/dist/Card-BzvDr-pU.js.map +0 -1
  42. package/dist/PurchaseStatusBadge-BmqAQEV9.cjs +0 -2
  43. package/dist/PurchaseStatusBadge-BmqAQEV9.cjs.map +0 -1
  44. package/dist/PurchaseStatusBadge-D1RRsubZ.js +0 -59
  45. package/dist/PurchaseStatusBadge-D1RRsubZ.js.map +0 -1
  46. package/dist/index-BUC9vqhJ.js +0 -5916
  47. package/dist/index-BUC9vqhJ.js.map +0 -1
  48. package/dist/index-BkqyKPJP.cjs +0 -3
  49. package/dist/index-BkqyKPJP.cjs.map +0 -1
  50. package/src/logging/index.test.tsx +0 -136
  51. package/src/logging/index.tsx +0 -48
package/dist/index.js CHANGED
@@ -1,41 +1,4071 @@
1
- import { a as e, b as t, C as i, c as n, d as o, e as g, F as r, f as m, L as l, h as M, M as c, i as L, j as h, k as p, l as u, m as d, R as v, T as C, n as A, p as k, q as F, s as b, t as P, u as T, v as f, w as x, x as y, y as z, o as S, z as q, B, D, E, G as R, H as w, I as G, J as I } from "./index-BUC9vqhJ.js";
2
- export {
3
- e as ActionButton,
4
- t as Avatar,
5
- i as ChannelEmptyState,
6
- n as ChannelList,
7
- o as ChannelView,
8
- g as CustomMessageProvider,
9
- r as FaqList,
10
- m as FaqListItem,
11
- l as LinkAttachment,
12
- M as LockedAttachment,
13
- c as MediaMessage,
14
- L as MessageAttachment,
15
- h as MessageBubble,
16
- p as MessagingLoggerProvider,
17
- u as MessagingProvider,
18
- d as MessagingShell,
19
- v as RichCard,
20
- C as TipMessage,
21
- A as buildCompactMetaLabel,
22
- k as formatFileSize,
23
- F as formatRelativeTime,
24
- b as getFileExtensionLabel,
25
- P as getMessageDisplayText,
26
- T as isLinkAttachment,
27
- f as isTipMessage,
28
- x as isUuidLike,
29
- y as messageAttachmentGroupPositionFromStream,
30
- z as normalizeLanguageCode,
31
- S as optimizeMessagingAttachmentUrl,
32
- q as resolveConversationParticipant,
33
- B as resolveLinkAttachment,
34
- D as resolveMediaFromMessage,
35
- E as resolveParticipantDisplayName,
36
- R as useComposerLocked,
37
- w as useCustomMessage,
38
- G as useMessaging,
39
- I as useMessagingLogger
40
- };
41
- //# sourceMappingURL=index.js.map
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./AttachmentCard-D2IoHdcv.js";
2
+ import o, { Suspense as s, createContext as c, useCallback as l, useContext as u, useEffect as d, useId as f, useMemo as p, useRef as m, useState as h } from "react";
3
+ import { StreamChatService as g } from "@linktr.ee/messaging-core";
4
+ import { LinkPreviewsManager as _, StreamChat as v } from "stream-chat";
5
+ import { AIStates as y, Attachment as b, AttachmentPreviewList as x, Channel as S, ChannelList as C, Chat as w, DateSeparator as T, EditMessageModal as E, InfiniteScroll as D, MessageBlocked as O, MessageBounceModal as k, MessageBouncePrompt as A, MessageDeleted as j, MessageErrorIcon as M, MessageInput as N, MessageIsThreadReplyInChannelButtonIndicator as P, MessageList as F, MessageRepliesCountButton as I, MessageStatus as L, MessageText as R, MessageTimestamp as z, Poll as ee, QuotedMessagePreview as te, ReminderNotification as ne, StreamedMessageText as re, TextareaComposer as ie, Window as B, WithComponents as ae, areMessageUIPropsEqual as oe, isDateSeparatorMessage as se, isMessageBlocked as ce, isMessageBounced as le, messageHasAttachments as ue, messageHasReactions as de, useAIState as fe, useChannelStateContext as pe, useChatContext as me, useComponentContext as he, useMessageComposer as ge, useMessageComposerHasSendableData as _e, useMessageContext as V, useMessageInputContext as ve, useMessageReminder as ye, useStateStore as be, useTypingContext as xe } from "stream-chat-react";
6
+ import { Fragment as H, jsx as U, jsxs as W } from "react/jsx-runtime";
7
+ import { MESSAGE_CUSTOM_TYPE as G, OFFICIAL_SENDER_USER_ID as Se, isAgeSafetySystemType as K, isDmAgentSystemType as Ce, isOfficialChannel as we, resolveRichCardImagePresentation as Te, selectEnabledFaqs as Ee } from "@linktr.ee/messaging-taxonomy";
8
+ import q from "classnames";
9
+ import { ArrowLeftIcon as De, ArrowUpIcon as Oe, CaretLeftIcon as ke, CaretRightIcon as Ae, ChecksIcon as je, CircleNotchIcon as J, CurrencyDollarIcon as Me, DotsThreeIcon as Y, DownloadSimpleIcon as X, FlagIcon as Ne, GiftIcon as Pe, LinkIcon as Fe, MegaphoneIcon as Ie, PencilSimpleIcon as Le, PlayIcon as Re, ProhibitIcon as ze, ProhibitInsetIcon as Be, SignOutIcon as Ve, SparkleIcon as He, SpinnerGapIcon as Ue, StarIcon as We, TrashSimpleIcon as Ge, VideoCameraIcon as Ke, WarningCircleIcon as qe, XIcon as Je } from "@phosphor-icons/react";
10
+ import { DefaultDropdownActionButton as Ye, MessageActions as Xe } from "stream-chat-react/experimental";
11
+ //#region src/providers/MessagingProvider.tsx
12
+ var Ze = c({
13
+ service: null,
14
+ client: null,
15
+ isConnected: !1,
16
+ isLoading: !1,
17
+ error: null,
18
+ capabilities: {},
19
+ refreshConnection: async () => {},
20
+ debug: !1
21
+ }), Qe = () => u(Ze), $e = ({ children: e, user: t, serviceConfig: n, apiKey: r, capabilities: i = {}, debug: a = !1, client: s }) => {
22
+ let c = l((e, ...t) => {
23
+ a && console.log(`🔥 [MessagingProvider] ${e}`, ...t);
24
+ }, [a]);
25
+ c("🔄 RENDER START", {
26
+ userId: t?.id,
27
+ apiKey: r?.substring(0, 8) + "...",
28
+ serviceConfig: !!n,
29
+ capabilities: Object.keys(i)
30
+ });
31
+ let [u, f] = h(null), [p, _] = h(null), [y, b] = h(!1), [x, S] = h(!1), [C, T] = h(null), E = m(!1), D = m(null), O = m(n);
32
+ O.current = n;
33
+ let k = m(a);
34
+ k.current = a;
35
+ let A = m({
36
+ userId: t?.id,
37
+ apiKey: r,
38
+ serviceConfig: n,
39
+ capabilities: i
40
+ }), j = m(0);
41
+ j.current++, c("📊 RENDER INFO", {
42
+ renderCount: j.current,
43
+ currentProps: {
44
+ userId: t?.id,
45
+ apiKey: r?.substring(0, 8) + "..."
46
+ },
47
+ propChanges: {
48
+ userChanged: A.current.userId !== t?.id,
49
+ apiKeyChanged: A.current.apiKey !== r,
50
+ serviceConfigChanged: A.current.serviceConfig !== n,
51
+ capabilitiesChanged: A.current.capabilities !== i
52
+ }
53
+ }), A.current = {
54
+ userId: t?.id,
55
+ apiKey: r,
56
+ serviceConfig: n,
57
+ capabilities: i
58
+ };
59
+ let M = m(null);
60
+ !s && r && M.current?.apiKey !== r && (M.current = {
61
+ apiKey: r,
62
+ client: new v(r)
63
+ });
64
+ let N = s || (r ? M.current?.client ?? null : null);
65
+ d(() => {
66
+ let e = j.current, t = O.current;
67
+ if (s) {
68
+ D.current = null, f(null), _(null), b(!1), T(null), S(!1);
69
+ return;
70
+ }
71
+ if (!r || !N || !t) {
72
+ c("⚠️ SERVICE INIT SKIPPED", {
73
+ renderCount: e,
74
+ reason: "Missing apiKey, client, or serviceConfig"
75
+ });
76
+ return;
77
+ }
78
+ c("🚀 CREATING SERVICE", {
79
+ renderCount: e,
80
+ apiKey: r?.substring(0, 8) + "..."
81
+ });
82
+ let n = new g({
83
+ ...t,
84
+ apiKey: r,
85
+ debug: k.current,
86
+ client: N
87
+ });
88
+ D.current = n, f(n), c("✅ SERVICE SET", {
89
+ renderCount: e,
90
+ serviceInstance: !!n
91
+ });
92
+ }, [
93
+ r,
94
+ N,
95
+ s
96
+ ]);
97
+ let P = m(null);
98
+ d(() => {
99
+ if (c("🔗 USER CONNECTION EFFECT TRIGGERED", {
100
+ hasService: !!u,
101
+ hasUser: !!t,
102
+ userId: t?.id,
103
+ isConnecting: E.current,
104
+ isConnected: y,
105
+ dependencies: {
106
+ service: !!u,
107
+ userId: t?.id
108
+ }
109
+ }), !s) {
110
+ if (!u || !t) {
111
+ c("⚠️ USER CONNECTION SKIPPED", "Missing service or user");
112
+ return;
113
+ }
114
+ if (E.current) {
115
+ c("⚠️ USER CONNECTION SKIPPED", "Already connecting");
116
+ return;
117
+ }
118
+ if (P.current?.serviceId === u && P.current?.userId === t.id) {
119
+ c("⚠️ USER CONNECTION SKIPPED", "Already connected this user with this service");
120
+ return;
121
+ }
122
+ (async () => {
123
+ c("🚀 STARTING USER CONNECTION", { userId: t.id }), E.current = !0, S(!0), T(null);
124
+ try {
125
+ c("📞 CALLING SERVICE.CONNECTUSER", { userId: t.id });
126
+ let e = await u.connectUser(t);
127
+ _(e), b(!0), P.current = {
128
+ serviceId: u,
129
+ userId: t.id
130
+ }, c("✅ USER CONNECTION SUCCESS", {
131
+ userId: t.id,
132
+ clientId: e.userID
133
+ });
134
+ } catch (e) {
135
+ let n = e instanceof Error ? e.message : "Connection failed";
136
+ T(n), c("❌ USER CONNECTION ERROR", {
137
+ userId: t.id,
138
+ error: n
139
+ });
140
+ } finally {
141
+ S(!1), E.current = !1, c("🔄 USER CONNECTION FINISHED", {
142
+ userId: t.id,
143
+ isConnected: y
144
+ });
145
+ }
146
+ })();
147
+ }
148
+ }, [
149
+ u,
150
+ t,
151
+ c,
152
+ y,
153
+ s
154
+ ]), d(() => {
155
+ let e = N;
156
+ return () => {
157
+ e && (P.current = null, D.current?.disconnectUser().catch(console.error));
158
+ };
159
+ }, [N]);
160
+ let F = l(async () => {
161
+ if (c("🔄 REFRESH CONNECTION CALLED", {
162
+ hasService: !!u,
163
+ hasUser: !!t
164
+ }), !s) {
165
+ if (!u || !t) {
166
+ c("⚠️ REFRESH CONNECTION SKIPPED", "Missing service or user");
167
+ return;
168
+ }
169
+ c("🚀 STARTING CONNECTION REFRESH", { userId: t.id }), S(!0);
170
+ try {
171
+ c("🔌 DISCONNECTING FOR REFRESH"), await u.disconnectUser(), c("📞 RECONNECTING FOR REFRESH");
172
+ let e = await u.connectUser(t);
173
+ _(e), b(!0), T(null), c("✅ CONNECTION REFRESH SUCCESS", { userId: t.id });
174
+ } catch (e) {
175
+ let n = e instanceof Error ? e.message : "Refresh failed";
176
+ T(n), c("❌ CONNECTION REFRESH ERROR", {
177
+ userId: t.id,
178
+ error: n
179
+ });
180
+ } finally {
181
+ S(!1), c("🔄 CONNECTION REFRESH FINISHED", { userId: t.id });
182
+ }
183
+ }
184
+ }, [
185
+ u,
186
+ t,
187
+ c,
188
+ s
189
+ ]), I = o.useMemo(() => (c("💫 CONTEXT VALUE MEMOIZATION", {
190
+ hasService: !!u,
191
+ hasClient: !!p,
192
+ isConnected: y,
193
+ isLoading: x,
194
+ hasError: !!C,
195
+ capabilitiesKeys: Object.keys(i)
196
+ }), {
197
+ service: s ? null : u,
198
+ client: s ?? p,
199
+ isConnected: s ? !0 : y,
200
+ isLoading: !s && x,
201
+ error: s ? null : C,
202
+ capabilities: i,
203
+ refreshConnection: F,
204
+ debug: a
205
+ }), [
206
+ u,
207
+ p,
208
+ s,
209
+ y,
210
+ x,
211
+ C,
212
+ i,
213
+ F,
214
+ a,
215
+ c
216
+ ]);
217
+ return c("🔄 RENDER END", {
218
+ renderCount: j.current,
219
+ willRenderChat: !!N,
220
+ contextValueReady: !!I
221
+ }), /* @__PURE__ */ U(Ze.Provider, {
222
+ value: I,
223
+ children: N ? /* @__PURE__ */ U(w, {
224
+ client: N,
225
+ customClasses: { channelList: "str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]" },
226
+ children: e
227
+ }) : e
228
+ });
229
+ }, et = () => Qe(), tt = (e) => {
230
+ let [t, n] = h(!!e?.state?.membership?.pinned_at);
231
+ return d(() => {
232
+ if (!e) {
233
+ n(!1);
234
+ return;
235
+ }
236
+ n(!!e.state.membership?.pinned_at);
237
+ let t = (t) => {
238
+ n(t?.member ? !!t.member.pinned_at : !!e.state.membership?.pinned_at);
239
+ };
240
+ return e.on("member.updated", t), () => {
241
+ e.off("member.updated", t);
242
+ };
243
+ }, [e]), t;
244
+ };
245
+ //#endregion
246
+ //#region src/utils/resolveConversationParticipant.ts
247
+ function nt(e, t, n) {
248
+ let r = Object.values(e || {});
249
+ if (we(n)) {
250
+ let e = r.find((e) => e.user?.id === Se);
251
+ if (e) return e;
252
+ }
253
+ return r.find((e) => e.user?.id && e.user.id !== t);
254
+ }
255
+ //#endregion
256
+ //#region src/utils/resolveParticipantDisplayName.ts
257
+ var rt = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
258
+ function it(e) {
259
+ return rt.test(e.trim());
260
+ }
261
+ function at(e, t) {
262
+ let n = e?.trim();
263
+ return !n || t && n === t || t && n === `Follower ${t}` ? !1 : !it(n);
264
+ }
265
+ function ot(e) {
266
+ return at(e?.name, e?.id) ? e.name.trim() : at(e?.username, e?.id) ? e.username.trim() : "Unknown member";
267
+ }
268
+ //#endregion
269
+ //#region src/components/Avatar/getAvatarEmoji.ts
270
+ var st = [
271
+ {
272
+ emoji: "🍎",
273
+ bgColor: "#FFD1DD"
274
+ },
275
+ {
276
+ emoji: "🍌",
277
+ bgColor: "#FFF1C9"
278
+ },
279
+ {
280
+ emoji: "🍇",
281
+ bgColor: "#E6D9FF"
282
+ },
283
+ {
284
+ emoji: "🍊",
285
+ bgColor: "#D6F4FF"
286
+ },
287
+ {
288
+ emoji: "🍓",
289
+ bgColor: "#FFE0AE"
290
+ },
291
+ {
292
+ emoji: "🥥",
293
+ bgColor: "#F7E7D8"
294
+ },
295
+ {
296
+ emoji: "🍒",
297
+ bgColor: "#DFF4D8"
298
+ },
299
+ {
300
+ emoji: "🥭",
301
+ bgColor: "#FFD8C2"
302
+ },
303
+ {
304
+ emoji: "🍉",
305
+ bgColor: "#D6EBFF"
306
+ },
307
+ {
308
+ emoji: "🍋",
309
+ bgColor: "#CAEEB5"
310
+ },
311
+ {
312
+ emoji: "🥝",
313
+ bgColor: "#FFE7C7"
314
+ },
315
+ {
316
+ emoji: "🫒",
317
+ bgColor: "#F6E3B4"
318
+ },
319
+ {
320
+ emoji: "🍈",
321
+ bgColor: "#D9F7E1"
322
+ }
323
+ ];
324
+ function ct(e) {
325
+ let t = 0;
326
+ for (let n = 0; n < e.length; n++) {
327
+ let r = e.charCodeAt(n);
328
+ t = (t << 5) - t + r, t &= t;
329
+ }
330
+ return Math.abs(t);
331
+ }
332
+ function lt(e) {
333
+ return st[ct(e) % st.length];
334
+ }
335
+ function ut(e) {
336
+ return lt(e).emoji;
337
+ }
338
+ function dt(e) {
339
+ return lt(e).bgColor;
340
+ }
341
+ //#endregion
342
+ //#region src/components/Avatar/index.tsx
343
+ var Z = ({ id: e, image: t, size: n = 40, className: r, starred: i = !1, shape: a = "squircle", dmAgentEnabled: o = !1 }) => {
344
+ let s = ut(e), c = dt(e), l = n < 32 ? Math.round(n * .45) : n < 56 ? 14 : n < 120 ? 18 : 36, u = n >= 40 ? 2 : 1, d = a === "circle" ? { borderRadius: "50%" } : { borderRadius: "1rem" }, f = /* @__PURE__ */ U("div", {
345
+ className: "h-full w-full overflow-hidden",
346
+ style: d,
347
+ children: t ? /* @__PURE__ */ U("img", {
348
+ src: t,
349
+ alt: "",
350
+ className: "h-full w-full object-cover"
351
+ }) : /* @__PURE__ */ U("div", {
352
+ "aria-hidden": "true",
353
+ className: q("avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors"),
354
+ style: {
355
+ fontSize: l,
356
+ lineHeight: 1
357
+ },
358
+ children: s
359
+ })
360
+ });
361
+ return /* @__PURE__ */ W("div", {
362
+ className: q("relative flex-shrink-0", r),
363
+ style: {
364
+ "--str-chat__avatar-size": `${n}px`,
365
+ width: `${n}px`,
366
+ height: `${n}px`,
367
+ backgroundColor: t ? void 0 : c,
368
+ ...d
369
+ },
370
+ children: [i && /* @__PURE__ */ U("div", {
371
+ "aria-hidden": "true",
372
+ 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)]",
373
+ children: /* @__PURE__ */ U(We, {
374
+ className: "size-3 text-yellow-600",
375
+ weight: "duotone"
376
+ })
377
+ }), /* @__PURE__ */ U("div", {
378
+ "data-testid": "avatar-ring",
379
+ className: q("h-full w-full", "bg-transparent"),
380
+ style: {
381
+ ...d,
382
+ ...o && {
383
+ borderWidth: `${u}px`,
384
+ borderStyle: "solid",
385
+ borderColor: "var(--AI-Gradient, #7F22FE)",
386
+ boxShadow: "inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"
387
+ }
388
+ },
389
+ children: f
390
+ })]
391
+ });
392
+ }, ft = "https://linktr.ee/s/about/trust-center/report", pt = ({ channel: e, participant: t, showBlockParticipant: n = !0, enabled: r = !0, onLeaveConversation: i, onBlockParticipant: a, onDeleteConversationClick: o, onBlockParticipantClick: s, onReportParticipantClick: c, onActionComplete: l, logLabel: u = "useChannelModerationActions" }) => {
393
+ let { service: f, debug: p } = Qe(), m = t?.user?.id, g = !!(r && n && f && m), [_, v] = h(!1), [y, b] = h(null), [x, S] = h(!1), [C, w] = h(!1), T = g && (y?.participantId !== m || y?.service !== f);
394
+ return d(() => {
395
+ if (!g || !f || !m) {
396
+ v(!1), b(null);
397
+ return;
398
+ }
399
+ let e = !1;
400
+ return (async () => {
401
+ try {
402
+ let t = await f.getBlockedUsers();
403
+ if (e) return;
404
+ v(t.some((e) => e.blocked_user_id === m));
405
+ } catch (t) {
406
+ e || console.error(`[${u}] Failed to check blocked status:`, t);
407
+ } finally {
408
+ e || b({
409
+ participantId: m,
410
+ service: f
411
+ });
412
+ }
413
+ })(), () => {
414
+ e = !0;
415
+ };
416
+ }, [
417
+ g,
418
+ f,
419
+ m,
420
+ u
421
+ ]), {
422
+ isParticipantBlocked: _,
423
+ isCheckingBlockedStatus: T,
424
+ isLeaving: x,
425
+ isUpdatingBlockStatus: C,
426
+ handleLeaveConversation: async () => {
427
+ if (!x) {
428
+ o?.(), p && console.log(`[${u}] Leave conversation`, e.cid), S(!0);
429
+ try {
430
+ let t = e._client?.userID ?? null;
431
+ await e.hide(t, !1), i && await i(e), l?.();
432
+ } catch (e) {
433
+ console.error(`[${u}] Failed to leave conversation`, e);
434
+ } finally {
435
+ S(!1);
436
+ }
437
+ }
438
+ },
439
+ handleBlockUser: async () => {
440
+ if (!(C || !f)) {
441
+ s?.(), p && console.log(`[${u}] Block member`, t?.user?.id), w(!0);
442
+ try {
443
+ await f.blockUser(t?.user?.id), a && await a(t?.user?.id), l?.();
444
+ } catch (e) {
445
+ console.error(`[${u}] Failed to block member`, e);
446
+ } finally {
447
+ w(!1);
448
+ }
449
+ }
450
+ },
451
+ handleUnblockUser: async () => {
452
+ if (!(C || !f)) {
453
+ s?.(), p && console.log(`[${u}] Unblock member`, t?.user?.id), w(!0);
454
+ try {
455
+ await f.unBlockUser(t?.user?.id), a && await a(t?.user?.id), l?.();
456
+ } catch (e) {
457
+ console.error(`[${u}] Failed to unblock member`, e);
458
+ } finally {
459
+ w(!1);
460
+ }
461
+ }
462
+ },
463
+ handleReportUser: () => {
464
+ c?.(), l?.(), window.open(ft, "_blank", "noopener,noreferrer");
465
+ }
466
+ };
467
+ }, mt = ({ variant: e = "default", className: t, children: n, ...r }) => /* @__PURE__ */ U("button", {
468
+ type: "button",
469
+ className: q("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", e === "danger" ? "text-danger hover:bg-danger/50" : "text-charcoal hover:bg-sand", t),
470
+ ...r,
471
+ children: n
472
+ }), ht = ({ channel: e, participant: t, showDeleteConversation: n = !0, showBlockParticipant: r = !0, showReportParticipant: i = !0, onLeaveConversation: a, onBlockParticipant: o, onDeleteConversationClick: s, onBlockParticipantClick: c, onReportParticipantClick: u, customChannelActions: p, triggerClassName: g }) => {
473
+ let [_, v] = h(!1), y = m(null), b = f(), { isParticipantBlocked: x, isCheckingBlockedStatus: S, isLeaving: C, isUpdatingBlockStatus: w, handleLeaveConversation: T, handleBlockUser: E, handleUnblockUser: D, handleReportUser: O } = pt({
474
+ channel: e,
475
+ participant: t,
476
+ showBlockParticipant: r,
477
+ enabled: _,
478
+ onLeaveConversation: a,
479
+ onBlockParticipant: o,
480
+ onDeleteConversationClick: s,
481
+ onBlockParticipantClick: c,
482
+ onReportParticipantClick: u,
483
+ onActionComplete: l(() => v(!1), []),
484
+ logLabel: "ChannelActionsMenu"
485
+ });
486
+ return d(() => {
487
+ if (!_) return;
488
+ let e = (e) => {
489
+ y.current && !y.current.contains(e.target) && v(!1);
490
+ }, t = (e) => {
491
+ e.key === "Escape" && v(!1);
492
+ };
493
+ return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
494
+ document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
495
+ };
496
+ }, [_]), !t || !(n || r || i || p) ? null : /* @__PURE__ */ W("div", {
497
+ ref: y,
498
+ className: "relative",
499
+ children: [/* @__PURE__ */ W("button", {
500
+ className: g,
501
+ type: "button",
502
+ "aria-haspopup": "true",
503
+ "aria-expanded": _,
504
+ "aria-controls": _ ? b : void 0,
505
+ onClick: () => v((e) => !e),
506
+ children: [/* @__PURE__ */ U(Y, { className: "size-5 text-black/90" }), /* @__PURE__ */ U("span", {
507
+ className: "sr-only",
508
+ children: "More options"
509
+ })]
510
+ }), _ && /* @__PURE__ */ U("div", {
511
+ id: b,
512
+ "aria-label": "Conversation options",
513
+ className: q("absolute right-0 top-full z-50 mt-2 w-56 overflow-hidden", "rounded-lg border border-sand bg-white p-1 shadow-max-elevation-light"),
514
+ children: /* @__PURE__ */ W("ul", {
515
+ className: "flex flex-col gap-1",
516
+ children: [
517
+ n && /* @__PURE__ */ U("li", { children: /* @__PURE__ */ W(mt, {
518
+ onClick: T,
519
+ disabled: C,
520
+ "aria-busy": C,
521
+ children: [C ? /* @__PURE__ */ U(Ue, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ U(Ve, { className: "h-5 w-5" }), /* @__PURE__ */ U("span", { children: "Delete Conversation" })]
522
+ }) }),
523
+ r && /* @__PURE__ */ U("li", { children: S ? /* @__PURE__ */ W(mt, {
524
+ disabled: !0,
525
+ "aria-busy": !0,
526
+ children: [/* @__PURE__ */ U(Ue, { className: "h-5 w-5 animate-spin" }), /* @__PURE__ */ U("span", { children: "Block" })]
527
+ }) : x ? /* @__PURE__ */ W(mt, {
528
+ onClick: D,
529
+ disabled: w,
530
+ "aria-busy": w,
531
+ children: [w ? /* @__PURE__ */ U(Ue, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ U(Be, { className: "h-5 w-5" }), /* @__PURE__ */ U("span", { children: "Unblock" })]
532
+ }) : /* @__PURE__ */ W(mt, {
533
+ onClick: E,
534
+ disabled: w,
535
+ "aria-busy": w,
536
+ children: [w ? /* @__PURE__ */ U(Ue, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ U(Be, { className: "h-5 w-5" }), /* @__PURE__ */ U("span", { children: "Block" })]
537
+ }) }),
538
+ i && /* @__PURE__ */ U("li", { children: /* @__PURE__ */ W(mt, {
539
+ variant: "danger",
540
+ onClick: O,
541
+ children: [/* @__PURE__ */ U(Ne, { className: "h-5 w-5" }), /* @__PURE__ */ U("span", { children: "Report" })]
542
+ }) }),
543
+ p
544
+ ]
545
+ })
546
+ })]
547
+ });
548
+ }, gt = "flex size-10 flex-shrink-0 items-center justify-center rounded-full bg-white/65 shadow-[0px_4px_8px_0px_rgba(0,0,0,0.06),0px_0px_0px_1px_rgba(0,0,0,0.04)] backdrop-blur-[40px] transition-filter duration-150 hover:brightness-95 aria-expanded:brightness-95 focus-ring", _t = "CUSTOMER_PAID", vt = (e) => typeof e == "string" && e.trim().replace(/[\s-]+/g, "_").toUpperCase() === _t, yt = ({ className: e, onBack: t, showBackButton: n, showStarButton: r = !1, onLeaveConversation: i, onBlockParticipant: a, showDeleteConversation: s = !0, showBlockParticipant: c = !0, showReportParticipant: l = !0, onDeleteConversationClick: u, onBlockParticipantClick: d, onReportParticipantClick: f, customChannelActions: p, renderChannelActions: m, showChannelInfo: h = !0, onParticipantNameClick: g }) => {
549
+ let { channel: _ } = pe(), { client: v } = me(), y = o.useMemo(() => nt(_.state?.members, v?.userID, _.type), [
550
+ _.state?.members,
551
+ v?.userID,
552
+ _.type
553
+ ]), b = ot(y?.user), x = y?.user?.image, S = tt(_), C = vt(_.data?.customer_tag) && y?.is_follower === !0, w = r && S, T = C || w || !!g, E = async () => {
554
+ try {
555
+ S ? await _.unpin() : await _.pin();
556
+ } catch (e) {
557
+ console.error("[ChannelHeaderRedesign] Failed to update pinned status:", e);
558
+ }
559
+ }, D = /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U(Z, {
560
+ id: y?.user?.id || _.id || "unknown",
561
+ name: b,
562
+ image: x,
563
+ shape: "circle",
564
+ size: 48,
565
+ className: "-mb-2"
566
+ }), /* @__PURE__ */ U("span", {
567
+ className: q("relative z-10 flex max-w-full flex-col items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 shadow-[0px_0px_0px_0px_rgba(0,0,0,0.04),0px_1px_2px_0px_rgba(0,0,0,0.04),0px_8px_32px_0px_rgba(0,0,0,0.1)] backdrop-blur-[2px] transition-filter duration-150 group-hover:brightness-95", T ? "pl-3 pr-2" : "px-3"),
568
+ children: /* @__PURE__ */ W("span", {
569
+ className: "flex max-w-full items-center justify-center",
570
+ children: [/* @__PURE__ */ U("span", {
571
+ className: "min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90",
572
+ children: b
573
+ }), T && /* @__PURE__ */ W("span", {
574
+ className: "ml-2 flex gap-1",
575
+ children: [
576
+ C && /* @__PURE__ */ U("span", {
577
+ "aria-label": "Paid customer",
578
+ className: "flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white",
579
+ children: /* @__PURE__ */ U(Me, {
580
+ className: "size-2.5",
581
+ weight: "bold"
582
+ })
583
+ }),
584
+ w && /* @__PURE__ */ U("span", {
585
+ className: "messaging-header-star-badge flex overflow-hidden",
586
+ children: /* @__PURE__ */ U("span", {
587
+ "aria-label": "Starred conversation",
588
+ className: "flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white",
589
+ children: /* @__PURE__ */ U(We, {
590
+ className: "size-2.5",
591
+ weight: "fill"
592
+ })
593
+ })
594
+ }),
595
+ g && /* @__PURE__ */ U(Ae, {
596
+ "aria-hidden": "true",
597
+ className: "size-4 shrink-0 text-black/65",
598
+ weight: "bold"
599
+ })
600
+ ]
601
+ })]
602
+ })
603
+ })] });
604
+ return /* @__PURE__ */ U("div", {
605
+ className: q("@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]", e),
606
+ children: /* @__PURE__ */ W("div", {
607
+ className: "grid min-h-[100px] grid-cols-[minmax(40px,1fr)_auto_minmax(40px,1fr)] items-start pb-2 pt-5 @lg:min-h-[104px] @lg:pt-6",
608
+ children: [
609
+ /* @__PURE__ */ U("div", {
610
+ className: "flex items-start",
611
+ children: n && /* @__PURE__ */ U("button", {
612
+ className: q(gt, "messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),
613
+ onClick: t || (() => {}),
614
+ type: "button",
615
+ "aria-label": "Back to conversations",
616
+ children: /* @__PURE__ */ U(De, { className: "size-5 text-black/90" })
617
+ })
618
+ }),
619
+ /* @__PURE__ */ U("div", {
620
+ className: "flex min-w-0 justify-center",
621
+ "data-dd-privacy": "mask",
622
+ children: g ? /* @__PURE__ */ U("button", {
623
+ type: "button",
624
+ onClick: g,
625
+ "aria-label": `View details for ${b}`,
626
+ className: "group flex min-w-0 max-w-full appearance-none flex-col items-center border-0 bg-transparent px-2 focus-ring focus-visible:outline-none",
627
+ children: D
628
+ }) : /* @__PURE__ */ U("div", {
629
+ className: "flex min-w-0 max-w-full flex-col items-center px-2",
630
+ children: D
631
+ })
632
+ }),
633
+ /* @__PURE__ */ W("div", {
634
+ className: "flex items-start justify-end gap-2",
635
+ children: [r && /* @__PURE__ */ U("button", {
636
+ className: gt,
637
+ onClick: E,
638
+ type: "button",
639
+ "aria-pressed": S,
640
+ "aria-label": S ? "Unstar conversation" : "Star conversation",
641
+ children: /* @__PURE__ */ U(We, {
642
+ className: q("size-5", {
643
+ "text-[#FFD60A]": S,
644
+ "text-black/90": !S
645
+ }),
646
+ weight: S ? "fill" : "regular"
647
+ })
648
+ }), h && (m === void 0 ? /* @__PURE__ */ U(ht, {
649
+ channel: _,
650
+ participant: y,
651
+ showDeleteConversation: s,
652
+ showBlockParticipant: c,
653
+ showReportParticipant: l,
654
+ onLeaveConversation: i,
655
+ onBlockParticipant: a,
656
+ onDeleteConversationClick: u,
657
+ onBlockParticipantClick: d,
658
+ onReportParticipantClick: f,
659
+ customChannelActions: p,
660
+ triggerClassName: gt
661
+ }) : m)]
662
+ })
663
+ ]
664
+ })
665
+ });
666
+ }, bt = (e) => /* @__PURE__ */ U(T, {
667
+ ...e,
668
+ position: "center"
669
+ });
670
+ //#endregion
671
+ //#region src/utils/getMessageDisplayText.ts
672
+ function xt(e) {
673
+ return e?.trim().toLowerCase().split(/[-_]/)[0] || void 0;
674
+ }
675
+ function St({ message: e, viewerLanguage: t }) {
676
+ let n = e?.text, r = xt(t);
677
+ return r ? e?.i18n?.[`${r}_text`] ?? n : n;
678
+ }
679
+ //#endregion
680
+ //#region src/components/MediaMessage/index.tsx
681
+ function Ct(e) {
682
+ return e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB`;
683
+ }
684
+ function wt(e) {
685
+ return `w-[280px] select-none overflow-hidden rounded-[24px] ${e ? "bg-[#1e2330]" : "bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`;
686
+ }
687
+ function Tt(e) {
688
+ return e ? "bg-white/10" : "bg-black/5";
689
+ }
690
+ function Et(e) {
691
+ return e ? "text-white" : "text-black";
692
+ }
693
+ function Dt(e) {
694
+ return e ? "text-white/55" : "text-black/55";
695
+ }
696
+ function Ot(e) {
697
+ return e ? "text-white/40" : "text-black/40";
698
+ }
699
+ function kt(e) {
700
+ return e ? "text-white/20" : "text-black/20";
701
+ }
702
+ var At = ({ attachment: e, isMyMessage: t }) => {
703
+ let { title: n, text: i, image_url: a, og_scrape_url: s, title_link: c } = e, l = s ?? c, u = typeof l == "string" && l.trim() !== "" ? l : void 0, d = /* @__PURE__ */ W(o.Fragment, { children: [/* @__PURE__ */ U("div", {
704
+ className: "p-2",
705
+ children: a ? /* @__PURE__ */ U("img", {
706
+ src: r(a) ?? a,
707
+ alt: n ?? "",
708
+ className: "aspect-video w-full rounded-[20px] object-cover"
709
+ }) : /* @__PURE__ */ U("div", {
710
+ className: `aspect-video w-full rounded-[20px] ${Tt(t)} flex items-center justify-center`,
711
+ children: /* @__PURE__ */ U(Fe, { className: `size-12 ${kt(t)}` })
712
+ })
713
+ }), /* @__PURE__ */ W("div", {
714
+ className: "px-3 pb-3",
715
+ children: [
716
+ n && /* @__PURE__ */ U("p", {
717
+ className: `truncate text-[14px] font-medium leading-5 ${Et(t)}`,
718
+ children: n
719
+ }),
720
+ i && /* @__PURE__ */ U("p", {
721
+ className: `truncate text-[12px] leading-4 ${Dt(t)}`,
722
+ children: i
723
+ }),
724
+ u && /* @__PURE__ */ U("p", {
725
+ className: `mt-1 truncate text-[12px] leading-4 ${Ot(t)}`,
726
+ children: u
727
+ })
728
+ ]
729
+ })] });
730
+ return u ? /* @__PURE__ */ U("a", {
731
+ href: u,
732
+ target: "_blank",
733
+ rel: "noopener noreferrer",
734
+ className: "block no-underline",
735
+ children: d
736
+ }) : /* @__PURE__ */ U("div", {
737
+ className: "block",
738
+ children: d
739
+ });
740
+ };
741
+ function jt(e) {
742
+ return e.type === "link" || !!e.og_scrape_url?.trim() && !e.asset_url;
743
+ }
744
+ function Mt(e) {
745
+ return e.attachments?.find(jt);
746
+ }
747
+ async function Nt(e, t) {
748
+ let n;
749
+ try {
750
+ n = t ?? new URL(e).pathname.split("/").pop() ?? "download";
751
+ } catch {
752
+ n = t ?? "download";
753
+ }
754
+ let r = await fetch(e, { mode: "cors" });
755
+ if (!r.ok) throw Error(`HTTP ${r.status}`);
756
+ let i = await r.blob(), a = URL.createObjectURL(i), o = document.createElement("a");
757
+ o.href = a, o.download = n, o.style.display = "none", document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(a);
758
+ }
759
+ var Pt = ({ url: e, filename: t }) => {
760
+ let [n, r] = h(!1);
761
+ return /* @__PURE__ */ U("button", {
762
+ type: "button",
763
+ onClick: (n) => {
764
+ n.stopPropagation();
765
+ let i = window.open("", "_blank", "noopener,noreferrer");
766
+ r(!0), Nt(e, t).then(() => {
767
+ i?.close();
768
+ }).catch(() => {
769
+ i && (i.location.href = e);
770
+ }).finally(() => r(!1));
771
+ },
772
+ disabled: n,
773
+ 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",
774
+ children: n ? /* @__PURE__ */ U(J, {
775
+ className: "size-4 animate-spin text-white",
776
+ weight: "bold"
777
+ }) : /* @__PURE__ */ W(o.Fragment, { children: [/* @__PURE__ */ U(X, {
778
+ className: "size-4 text-white",
779
+ weight: "bold"
780
+ }), "Download"] })
781
+ });
782
+ };
783
+ function Ft(e) {
784
+ let t = e.attachments?.find((e) => e.type === "video" && e.asset_url), n = e.attachments?.find((e) => e.type === "image" && e.image_url), r = e.attachments?.find((e) => e.type === "audio" && e.asset_url), i = e.attachments?.find((e) => e.type === "file" && e.asset_url), a = t ?? n ?? r ?? i, o = t?.asset_url ?? n?.image_url ?? r?.asset_url ?? i?.asset_url;
785
+ return o ? {
786
+ resolvedUrl: o,
787
+ resolvedType: a?.mime_type ?? (a?.type === "image" ? "image/jpeg" : a?.type === "video" ? "video/mp4" : a?.type === "audio" ? "audio/mpeg" : "application/octet-stream"),
788
+ title: a?.title,
789
+ fileSize: a?.file_size,
790
+ thumbnailUrl: t?.thumb_url
791
+ } : null;
792
+ }
793
+ var It = ({ resolvedUrl: e, resolvedType: t, title: r, fileSize: i, thumbnailUrl: o }) => {
794
+ let s = i === void 0 ? void 0 : Ct(i);
795
+ return /* @__PURE__ */ U(a, {
796
+ variant: "dark",
797
+ title: r,
798
+ placeholderTitle: "",
799
+ mimeType: t,
800
+ detail: s,
801
+ thumbnail: /* @__PURE__ */ U(n, {
802
+ mimeType: t,
803
+ sourceUrl: e,
804
+ thumbnailUrl: o,
805
+ title: r,
806
+ variant: "dark"
807
+ })
808
+ });
809
+ }, Lt = ({ resolvedUrl: t, resolvedType: r, title: i, fileSize: o, thumbnailUrl: s }) => {
810
+ let c = e(r), l = o === void 0 ? void 0 : Ct(o);
811
+ return /* @__PURE__ */ U(a, {
812
+ variant: "light",
813
+ title: i,
814
+ mimeType: r,
815
+ detail: l,
816
+ thumbnail: /* @__PURE__ */ U(n, {
817
+ mimeType: r,
818
+ sourceUrl: t,
819
+ thumbnailUrl: s,
820
+ title: i,
821
+ variant: "light",
822
+ containedImage: c === "image" || c === "document"
823
+ }),
824
+ action: /* @__PURE__ */ U(Pt, {
825
+ url: t,
826
+ filename: i
827
+ })
828
+ });
829
+ }, Rt = Object.assign(({ message: e, isMyMessage: t = !1 }) => {
830
+ let n = Mt(e), r = Ft(e);
831
+ return !n && !r ? null : /* @__PURE__ */ W("div", {
832
+ 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",
833
+ "data-dd-privacy": "mask",
834
+ children: [!t && e.user && /* @__PURE__ */ U(Z, {
835
+ className: "str-chat__avatar str-chat__message-sender-avatar",
836
+ id: e.user.id,
837
+ image: e.user.image,
838
+ name: e.user.name ?? e.user.id
839
+ }), /* @__PURE__ */ U("div", {
840
+ className: "str-chat__message-inner",
841
+ style: {
842
+ marginInlineEnd: 0,
843
+ marginInlineStart: 0
844
+ },
845
+ children: /* @__PURE__ */ U("div", {
846
+ className: "str-chat__message-bubble-wrapper",
847
+ children: /* @__PURE__ */ U("div", {
848
+ className: "str-chat__message-bubble",
849
+ "data-attachment-bubble": "true",
850
+ style: {
851
+ padding: 0,
852
+ borderRadius: 0,
853
+ overflow: "visible",
854
+ background: "transparent"
855
+ },
856
+ children: n ? /* @__PURE__ */ U("div", {
857
+ className: wt(t),
858
+ children: /* @__PURE__ */ U(At, {
859
+ attachment: n,
860
+ isMyMessage: t
861
+ })
862
+ }) : U(t ? It : Lt, { ...r })
863
+ })
864
+ })
865
+ })]
866
+ });
867
+ }, {
868
+ Creator: ({ message: e }) => {
869
+ let t = Mt(e);
870
+ if (t) return /* @__PURE__ */ U("div", {
871
+ className: wt(!0),
872
+ "data-dd-privacy": "mask",
873
+ children: /* @__PURE__ */ U(At, {
874
+ attachment: t,
875
+ isMyMessage: !0
876
+ })
877
+ });
878
+ let n = Ft(e);
879
+ return n ? /* @__PURE__ */ U("div", {
880
+ style: { display: "contents" },
881
+ "data-dd-privacy": "mask",
882
+ children: /* @__PURE__ */ U(It, { ...n })
883
+ }) : null;
884
+ },
885
+ Visitor: ({ message: e }) => {
886
+ let t = Mt(e);
887
+ if (t) return /* @__PURE__ */ U("div", {
888
+ className: wt(!1),
889
+ "data-dd-privacy": "mask",
890
+ children: /* @__PURE__ */ U(At, {
891
+ attachment: t,
892
+ isMyMessage: !1
893
+ })
894
+ });
895
+ let n = Ft(e);
896
+ return n ? /* @__PURE__ */ U("div", {
897
+ style: { display: "contents" },
898
+ "data-dd-privacy": "mask",
899
+ children: /* @__PURE__ */ U(Lt, { ...n })
900
+ }) : null;
901
+ }
902
+ }), zt = { LockedAttachment: { isUnlocking: () => !1 } }, Bt = c({}), Vt = Bt.Provider;
903
+ function Ht(e) {
904
+ return u(Bt)[e] ?? zt[e];
905
+ }
906
+ //#endregion
907
+ //#region src/components/CustomMessage/LockedAttachment/index.tsx
908
+ var Ut = o.lazy(() => import("./Card-C7uLQbYz.js")), Wt = o.lazy(() => import("./Card-EKD9NkTa.js")), Gt = () => /* @__PURE__ */ U("div", {
909
+ 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)]",
910
+ "aria-hidden": !0
911
+ }), Kt = (e) => /* @__PURE__ */ U(s, {
912
+ fallback: /* @__PURE__ */ U(Gt, {}),
913
+ children: e.contentType === "text" ? /* @__PURE__ */ U(Ut, { ...e }) : /* @__PURE__ */ U(Wt, { ...e })
914
+ }), qt = ({ size: e = 15 }) => /* @__PURE__ */ U("svg", {
915
+ width: e,
916
+ height: e,
917
+ viewBox: "0 0 15 15",
918
+ fill: "none",
919
+ "aria-hidden": "true",
920
+ children: /* @__PURE__ */ U("path", {
921
+ 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",
922
+ fill: "currentColor",
923
+ fillOpacity: .55
924
+ })
925
+ }), Jt = (e) => e.metadata?.custom_type === G.PAID, Yt = (e) => e.metadata?.custom_type === G.CHATBOT, Xt = (e) => e.metadata?.custom_type === G.ATTACHMENT, Zt = (e) => Xt(e) && e.metadata?.attachment_content_type === "text", Qt = (e) => Xt(e) && e.metadata?.attachment_content_type !== "text", $t = (e) => Jt(e) && !!e.metadata?.amount_text, en = ({ message: e, isMyMessage: t = !1, hasAttachment: n = !1 }) => {
926
+ let r = Jt(e), i = Yt(e);
927
+ if (!r && !i) return null;
928
+ if (r) {
929
+ let t = e.metadata?.amount_text;
930
+ return t ? /* @__PURE__ */ W("div", {
931
+ className: "message-tag--paid inline-flex items-center gap-1 text-[12px] font-medium leading-[2] text-[#016630]",
932
+ children: [/* @__PURE__ */ U(Pe, { size: 12 }), /* @__PURE__ */ W("span", { children: [
933
+ "Delivered with ",
934
+ t,
935
+ " message"
936
+ ] })]
937
+ }) : null;
938
+ }
939
+ let a = t && n, o = a ? "Sent with AI" : "Sent by AI Assistant", s = a ? "justify-end gap-2 text-black/30" : t ? "w-full justify-start gap-1.5 mt-3 px-4 text-white/55" : "w-full justify-start gap-1.5 mt-3 px-4 text-black/30", c = /* @__PURE__ */ U("span", {
940
+ className: "text-left",
941
+ children: o
942
+ }), l = /* @__PURE__ */ U("span", {
943
+ className: "inline-flex items-center leading-none",
944
+ children: /* @__PURE__ */ U(qt, { size: a ? 12 : 15 })
945
+ });
946
+ return /* @__PURE__ */ U("div", {
947
+ className: `inline-flex items-center text-[10px] font-normal leading-4 tracking-[0.2px] ${s}`,
948
+ "data-testid": "message-chatbot-indicator",
949
+ children: t && !a ? /* @__PURE__ */ W(H, { children: [c, l] }) : /* @__PURE__ */ W(H, { children: [l, c] })
950
+ });
951
+ }, tn = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='23' fill='none'%3E%3Cpath fill='black' d='M0 0H15C15 10.1934 15.859 15.2345 19.168 21.4893C19.527 22.168 19.039 22.9917 18.274 22.9178C5.176 21.6506 0.32 6.0737 0 0Z'/%3E%3C/svg%3E\") no-repeat center / 100% 100%", nn = {
952
+ me: "var(--str-chat__own-message-bubble-background-color, #1e2330)",
953
+ other: "var(--str-chat__message-bubble-background-color, #f1f0ee)"
954
+ }, rn = ({ side: e }) => /* @__PURE__ */ U("span", {
955
+ "aria-hidden": "true",
956
+ className: "pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",
957
+ style: {
958
+ insetInlineEnd: e === "me" ? "calc(-1 * 0.3125rem)" : void 0,
959
+ insetInlineStart: e === "other" ? "calc(-1 * 0.3125rem)" : void 0,
960
+ transform: e === "other" ? "scaleX(-1)" : void 0,
961
+ transformOrigin: "center",
962
+ backgroundColor: nn[e],
963
+ WebkitMask: tn,
964
+ mask: tn
965
+ }
966
+ }), an = c(void 0), on = (e) => {
967
+ let t = e.metadata?.outbound_id;
968
+ return typeof t == "string" ? t : void 0;
969
+ }, sn = (e, t) => {
970
+ if (!t || !e?.length) return;
971
+ let n = /* @__PURE__ */ new Set(), r;
972
+ for (let i of e) {
973
+ let e = on(i);
974
+ if (!e || n.has(e)) continue;
975
+ n.add(e);
976
+ let a = t(e);
977
+ a && (r ??= {}, r[e] = {
978
+ id: a.id,
979
+ ...a.name === void 0 ? {} : { name: a.name }
980
+ });
981
+ }
982
+ return r;
983
+ }, cn = (e, t) => {
984
+ if (e === t) return !0;
985
+ if (!e || !t) return !1;
986
+ let n = Object.keys(e), r = Object.keys(t);
987
+ return n.length === r.length && n.every((n) => e[n].id === t[n]?.id && e[n].name === t[n]?.name);
988
+ }, ln = (e, t) => {
989
+ let n = sn(e, t), [r, i] = h(n);
990
+ return cn(r, n) ? r : (i(n), n);
991
+ }, un = (e) => e.metadata?.custom_type === G.TIP, dn = ({ message: e }) => {
992
+ let t = e.metadata?.amount_text;
993
+ return t ? /* @__PURE__ */ W("div", {
994
+ className: "message-tip-pill inline-flex items-end gap-0.5 max-w-[520px] rounded-[1.5rem] bg-[#43e660] px-4 py-3 text-white",
995
+ children: [/* @__PURE__ */ U("span", {
996
+ className: "flex h-5 items-center text-[20px] leading-none",
997
+ "aria-hidden": "true",
998
+ children: "🎁"
999
+ }), /* @__PURE__ */ W("span", {
1000
+ className: "text-[14px] font-bold leading-[1.43] tracking-[0.28px] text-[rgba(4,4,3,0.9)]",
1001
+ children: [t, " tip!"]
1002
+ })]
1003
+ }) : null;
1004
+ }, fn = () => {
1005
+ let { message: e } = V("SentMessageDeliveryStatus"), { messages: t } = pe("SentMessageDeliveryStatus"), n = (() => {
1006
+ if (t) for (let e = t.length - 1; e >= 0; --e) {
1007
+ let n = t[e];
1008
+ if (n.type !== "system" && n.type !== "ephemeral" && n.type !== "deleted") return n.id;
1009
+ }
1010
+ })();
1011
+ return e.id === n;
1012
+ }, pn = () => fn() ? /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U(je, {
1013
+ weight: "bold",
1014
+ "aria-hidden": "true"
1015
+ }), /* @__PURE__ */ U("span", {
1016
+ "data-testid": "sent-message-delivery-status",
1017
+ children: "Delivered"
1018
+ })] }) : null, mn = () => fn() ? /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U(J, {
1019
+ className: "sent-message-status__spinner animate-spin",
1020
+ weight: "bold",
1021
+ "aria-hidden": "true"
1022
+ }), /* @__PURE__ */ U("span", {
1023
+ "data-testid": "sent-message-sending-status",
1024
+ children: "Sending"
1025
+ })] }) : null, hn = ({ outbound: e, onOutboundClick: t }) => {
1026
+ let n = e.name || "Broadcast", r = /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U("span", {
1027
+ className: "sent-message-outbound-badge",
1028
+ "aria-hidden": "true",
1029
+ children: /* @__PURE__ */ U(Ie, { weight: "fill" })
1030
+ }), /* @__PURE__ */ U("span", {
1031
+ className: q("sent-message-outbound-name", { "underline [text-decoration-skip-ink:auto]": !!t }),
1032
+ "data-testid": "sent-message-outbound-status",
1033
+ children: n
1034
+ })] });
1035
+ return t ? /* @__PURE__ */ U("button", {
1036
+ type: "button",
1037
+ className: "inline-flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0 text-inherit [font:inherit]",
1038
+ "aria-label": `View broadcast ${n}`,
1039
+ onClick: () => t(e),
1040
+ children: r
1041
+ }) : r;
1042
+ }, gn = () => /* @__PURE__ */ W("span", {
1043
+ className: "str-chat__message-status sent-message-status--failed",
1044
+ children: [/* @__PURE__ */ U(qe, {
1045
+ weight: "bold",
1046
+ "aria-hidden": "true"
1047
+ }), /* @__PURE__ */ U("span", {
1048
+ "data-testid": "sent-message-failed-status",
1049
+ children: "Failed to send"
1050
+ })]
1051
+ }), _n = ({ onOutboundClick: e, resolvedOutbound: t }) => {
1052
+ let { isMyMessage: n, message: r, threadList: i } = V("SentMessageDeliveryStatus"), a = n(), o = fn();
1053
+ if (i) return null;
1054
+ if (r.status === "failed" && a && r.type !== "error") return /* @__PURE__ */ U(gn, {});
1055
+ if (!a) return null;
1056
+ let s = r.metadata?.outbound_id, c = r.status !== "sending" && r.status !== "failed" && s && t ? /* @__PURE__ */ U(hn, {
1057
+ outbound: t,
1058
+ onOutboundClick: e
1059
+ }) : null, l = $t(r) ? null : /* @__PURE__ */ U(L, {
1060
+ MessageSentStatus: pn,
1061
+ MessageDeliveredStatus: pn,
1062
+ MessageReadStatus: pn,
1063
+ MessageSendingStatus: un(r) ? pn : mn
1064
+ });
1065
+ return c ? /* @__PURE__ */ W("span", {
1066
+ className: "sent-message-status-row",
1067
+ children: [
1068
+ l,
1069
+ l && o && /* @__PURE__ */ U("span", {
1070
+ className: "sent-message-outbound-separator",
1071
+ "aria-hidden": "true",
1072
+ children: "•"
1073
+ }),
1074
+ c
1075
+ ]
1076
+ }) : l;
1077
+ }, vn = /^([a-z][a-z0-9+.-]*):/i, yn = /* @__PURE__ */ new Set([
1078
+ "http",
1079
+ "https",
1080
+ "mailto",
1081
+ "tel",
1082
+ "sms"
1083
+ ]);
1084
+ function bn(e) {
1085
+ if (typeof e != "string") return;
1086
+ let t = e.trim();
1087
+ if (t === "") return;
1088
+ let n = vn.exec(t);
1089
+ if (n) {
1090
+ let e = n[1].toLowerCase();
1091
+ return yn.has(e) ? t : void 0;
1092
+ }
1093
+ return t.startsWith("//") || t.startsWith("/") ? t : `https://${t}`;
1094
+ }
1095
+ //#endregion
1096
+ //#region src/components/LinkAttachment/components/_shared/CardCta.tsx
1097
+ var xn = {
1098
+ dark: {
1099
+ primary: "bg-white text-[#121110] hover:bg-white/90",
1100
+ secondary: "bg-white/15 text-white hover:bg-white/25"
1101
+ },
1102
+ light: {
1103
+ primary: "bg-[#121110] text-white hover:bg-[#2a2928]",
1104
+ secondary: "bg-black/[0.06] text-[#121110] hover:bg-black/10"
1105
+ }
1106
+ }, Sn = ({ variant: e, cta: t, fullWidth: n = !0, standalone: r = !1 }) => {
1107
+ let i = t.variant ?? "primary", a = q("inline-flex h-10 items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors", n ? "w-full" : "min-w-0", !r && "mt-2", xn[e][i]), o = n ? t.label : /* @__PURE__ */ U("span", {
1108
+ className: "min-w-0 truncate",
1109
+ children: t.label
1110
+ }), s = bn(t.href);
1111
+ return s ? /* @__PURE__ */ U("a", {
1112
+ href: s,
1113
+ target: "_blank",
1114
+ rel: "noopener noreferrer",
1115
+ onClick: (e) => {
1116
+ e.stopPropagation(), t.onClick?.();
1117
+ },
1118
+ className: `${a} no-underline`,
1119
+ children: o
1120
+ }) : /* @__PURE__ */ U("button", {
1121
+ type: "button",
1122
+ onClick: (e) => {
1123
+ e.stopPropagation(), t.onClick?.();
1124
+ },
1125
+ className: a,
1126
+ children: o
1127
+ });
1128
+ }, Cn = {
1129
+ dark: "text-white",
1130
+ light: "text-black/90"
1131
+ }, wn = "text-white/30", Tn = {
1132
+ dark: "text-white/55",
1133
+ light: "text-black/55"
1134
+ }, En = {
1135
+ dark: "bg-white/25",
1136
+ light: "bg-black/15"
1137
+ }, Dn = ({ variant: e, ctaSurface: t, chinTextColor: n, title: r, placeholderTitle: i, description: a, descriptionLines: o = 1, url: s, appIcon: c, cta: l, trailingAction: u, isLoading: d = !1 }) => {
1138
+ let f = e === "dark", p = r ?? (f ? i : void 0) ?? "", m = p.trim() !== "", h = a != null && a.trim() !== "", g = typeof s == "string" ? s.trim() : "", _ = g !== "", v = l != null;
1139
+ if (!d && !m && !h && !_ && !v) return null;
1140
+ let y = q("line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]", n == null && (f && !r ? wn : Cn[e])), b = q("truncate text-[12px] leading-4 tracking-[0.24px]", n == null && Tn[e]), x = q("text-[12px] leading-4 tracking-[0.24px]", o <= 1 && "truncate", n == null && Tn[e]);
1141
+ if (d) {
1142
+ let t = q("animate-pulse rounded", En[e]);
1143
+ return /* @__PURE__ */ U("div", {
1144
+ className: "shrink-0 px-4 py-3",
1145
+ children: /* @__PURE__ */ W("div", {
1146
+ className: "flex min-w-0 flex-col gap-[2px]",
1147
+ children: [/* @__PURE__ */ U("div", {
1148
+ className: q("h-5 w-3/4", t),
1149
+ "aria-hidden": !0
1150
+ }), /* @__PURE__ */ U("div", {
1151
+ className: q("h-4 w-1/2", t),
1152
+ "aria-hidden": !0
1153
+ })]
1154
+ })
1155
+ });
1156
+ }
1157
+ let S = n ? { color: n } : void 0, C = o > 1 ? {
1158
+ ...S,
1159
+ display: "-webkit-box",
1160
+ WebkitBoxOrient: "vertical",
1161
+ WebkitLineClamp: o,
1162
+ overflow: "hidden"
1163
+ } : S;
1164
+ return /* @__PURE__ */ W("div", {
1165
+ className: "shrink-0 px-4 py-3",
1166
+ children: [/* @__PURE__ */ W("div", {
1167
+ className: "flex items-end gap-3",
1168
+ children: [/* @__PURE__ */ W("div", {
1169
+ className: "flex min-w-0 flex-1 flex-col gap-[2px]",
1170
+ children: [
1171
+ m && /* @__PURE__ */ W("div", {
1172
+ className: "flex min-w-0 items-center gap-2",
1173
+ children: [c ? /* @__PURE__ */ U("span", {
1174
+ className: "shrink-0",
1175
+ children: c
1176
+ }) : null, /* @__PURE__ */ U("p", {
1177
+ className: q("min-w-0", y),
1178
+ style: S,
1179
+ children: p
1180
+ })]
1181
+ }),
1182
+ h && /* @__PURE__ */ U("p", {
1183
+ className: x,
1184
+ style: C,
1185
+ children: a
1186
+ }),
1187
+ !v && _ && /* @__PURE__ */ U("p", {
1188
+ className: b,
1189
+ style: S,
1190
+ "data-testid": "link-attachment-url",
1191
+ children: g
1192
+ })
1193
+ ]
1194
+ }), u && /* @__PURE__ */ U("div", {
1195
+ className: "shrink-0",
1196
+ children: u
1197
+ })]
1198
+ }), l && /* @__PURE__ */ U(Sn, {
1199
+ variant: t ?? e,
1200
+ cta: l
1201
+ })]
1202
+ });
1203
+ }, On = "Loading link preview", kn = q("relative w-[var(--lt-msg-card-width,290px)] max-w-full select-none overflow-hidden", "rounded-[20px]"), An = "flex h-[250px] flex-col", jn = ({ variant: e, children: t, href: n, onClick: r, ariaLabel: i, rootRef: a, topRight: o, bgClassName: s, accentHex: c, fixedHeight: l = !1, busy: u = !1, "data-testid": d }) => {
1204
+ let f = q("messaging-link-card", kn, l ? An : "block", s ?? (e === "dark" ? "bg-[#1e2330]" : "bg-[#f1f0ee]"), n != null || r != null ? "cursor-pointer no-underline focus-ring" : null), p = u ? {
1205
+ role: "status",
1206
+ "aria-busy": !0,
1207
+ "aria-label": On
1208
+ } : void 0, m = c ? { "--accent": c } : void 0, h = o ? /* @__PURE__ */ U("div", {
1209
+ className: "pointer-events-auto absolute right-3 top-3 z-10",
1210
+ children: o
1211
+ }) : null;
1212
+ return n ? /* @__PURE__ */ W("a", {
1213
+ ref: a,
1214
+ href: n,
1215
+ target: "_blank",
1216
+ rel: "noopener noreferrer",
1217
+ onClick: r,
1218
+ "data-testid": d,
1219
+ "data-variant": e,
1220
+ className: f,
1221
+ style: m,
1222
+ ...p,
1223
+ children: [t, h]
1224
+ }) : r ? /* @__PURE__ */ W("button", {
1225
+ ref: a,
1226
+ type: "button",
1227
+ onClick: r,
1228
+ "aria-label": i,
1229
+ "data-testid": d,
1230
+ "data-variant": e,
1231
+ className: q(f, "text-left"),
1232
+ style: m,
1233
+ ...p,
1234
+ children: [t, h]
1235
+ }) : /* @__PURE__ */ W("div", {
1236
+ ref: a,
1237
+ "data-testid": d,
1238
+ "data-variant": e,
1239
+ className: f,
1240
+ style: m,
1241
+ ...p,
1242
+ children: [t, h]
1243
+ });
1244
+ }, Mn = {
1245
+ dark: "bg-white/10",
1246
+ light: "bg-black/5"
1247
+ }, Nn = {
1248
+ dark: "size-16 text-white/25",
1249
+ light: "size-16 text-black/25"
1250
+ }, Pn = (t, n) => !!n && !!t && e(t) === "audio", Fn = (t, n) => {
1251
+ if (!n || !t) return !1;
1252
+ let r = e(t);
1253
+ return r === "video" || r === "audio";
1254
+ }, In = "bg-[#F2F3F4]", Ln = ({ variant: t, thumbnailUrl: n, sourceUrl: a, title: o, mimeType: s = "image/*", topLeft: c, topRight: l, isLoading: u = !1, onImageError: d }) => {
1255
+ let f = e(s), p = !!a && f === "video", m = r(n);
1256
+ return !u && Pn(s, a) ? /* @__PURE__ */ U("div", {
1257
+ className: "p-3",
1258
+ children: /* @__PURE__ */ U("audio", {
1259
+ src: a,
1260
+ controls: !0,
1261
+ preload: "metadata",
1262
+ className: "block w-full",
1263
+ children: /* @__PURE__ */ U("track", { kind: "captions" })
1264
+ })
1265
+ }) : /* @__PURE__ */ W("div", {
1266
+ className: q("relative min-h-0 w-full flex-1 overflow-hidden", p && "bg-black"),
1267
+ children: [
1268
+ u ? /* @__PURE__ */ U("div", {
1269
+ className: q("h-full w-full animate-pulse", Mn[t]),
1270
+ "aria-hidden": !0
1271
+ }) : p ? /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U("video", {
1272
+ src: a,
1273
+ poster: m,
1274
+ controls: !0,
1275
+ playsInline: !0,
1276
+ preload: "metadata",
1277
+ className: "absolute inset-0 h-full w-full object-contain",
1278
+ children: /* @__PURE__ */ U("track", { kind: "captions" })
1279
+ }), m && d ? /* @__PURE__ */ U("img", {
1280
+ src: m,
1281
+ alt: "",
1282
+ "aria-hidden": !0,
1283
+ onError: d,
1284
+ className: "hidden"
1285
+ }) : null] }) : n ? /* @__PURE__ */ U("img", {
1286
+ src: m ?? n,
1287
+ alt: o ?? "",
1288
+ draggable: !1,
1289
+ loading: "lazy",
1290
+ decoding: "async",
1291
+ onError: d,
1292
+ className: "absolute inset-0 h-full w-full object-cover"
1293
+ }) : /* @__PURE__ */ U("div", {
1294
+ className: q("flex h-full w-full items-center justify-center", Mn[t]),
1295
+ children: i(s, {
1296
+ className: Nn[t],
1297
+ weight: "regular"
1298
+ })
1299
+ }),
1300
+ c ? /* @__PURE__ */ U("div", {
1301
+ className: "pointer-events-auto absolute left-3 top-3 z-10",
1302
+ children: c
1303
+ }) : null,
1304
+ l ? /* @__PURE__ */ U("div", {
1305
+ className: "pointer-events-auto absolute right-3 top-3 z-10",
1306
+ children: l
1307
+ }) : null
1308
+ ]
1309
+ });
1310
+ }, Rn = /^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
1311
+ function zn(e) {
1312
+ let t = e.trim();
1313
+ return t.startsWith("#") ? t : `#${t}`;
1314
+ }
1315
+ //#endregion
1316
+ //#region src/components/LinkAttachment/components/_shared/useChinPalette.ts
1317
+ var Bn = "#FFFFFF", Vn = "#040403", Hn = {
1318
+ dark: Bn,
1319
+ light: Vn
1320
+ };
1321
+ function Un({ variant: e, accentColor: t, status: n = "ready", layout: r = "featured", thumbnailUrl: i, mimeType: a, sourceUrl: s }) {
1322
+ let [c, l] = o.useState(!1);
1323
+ o.useEffect(() => {
1324
+ l(!1);
1325
+ }, [i]);
1326
+ let u = o.useCallback(() => {
1327
+ l(!0);
1328
+ }, []), d = Pn(a, s), f = r === "featured" && i && !d && !c && n === "ready" && t != null && Rn.test(t.trim()) ? zn(t) : void 0, p = d ? Vn : Hn[e];
1329
+ return {
1330
+ thumbnailUrl: c ? void 0 : i,
1331
+ accentHex: f,
1332
+ chinTextColor: p,
1333
+ surface: d ? "light" : e,
1334
+ isLoading: n === "loading",
1335
+ onImageError: u
1336
+ };
1337
+ }
1338
+ //#endregion
1339
+ //#region src/components/LinkAttachment/components/Composer/Card.tsx
1340
+ var Wn = "flex size-6 items-center justify-center rounded-full bg-[#121110] text-white focus-ring", Gn = "relative before:absolute before:-inset-[10px] before:content-['']", Kn = ({ title: e, placeholderTitle: t, description: n, descriptionLines: r, url: i, mimeType: a, thumbnailUrl: o, sourceUrl: s, layout: c = "featured", appIcon: l, cta: u, accentColor: d, status: f = "ready", onDismiss: p, onEditClick: m, dismissLabel: h = "Dismiss attachment" }) => {
1341
+ let g = c === "classic", _ = Pn(a, s), v = Un({
1342
+ variant: "dark",
1343
+ accentColor: d,
1344
+ status: f,
1345
+ layout: c,
1346
+ thumbnailUrl: o,
1347
+ mimeType: a,
1348
+ sourceUrl: s
1349
+ }), y = p ? /* @__PURE__ */ U("button", {
1350
+ type: "button",
1351
+ onClick: p,
1352
+ "aria-label": h,
1353
+ className: q(Wn, !_ && Gn),
1354
+ children: /* @__PURE__ */ U(Je, {
1355
+ className: "size-3",
1356
+ weight: "bold"
1357
+ })
1358
+ }) : void 0, b = m ? /* @__PURE__ */ U("button", {
1359
+ type: "button",
1360
+ onClick: m,
1361
+ "aria-label": "Edit attachment",
1362
+ className: "flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",
1363
+ children: /* @__PURE__ */ U(Le, {
1364
+ className: "size-5",
1365
+ weight: "regular"
1366
+ })
1367
+ }) : void 0;
1368
+ return _ && !v.isLoading ? /* @__PURE__ */ U(jn, {
1369
+ variant: "dark",
1370
+ bgClassName: In,
1371
+ children: /* @__PURE__ */ W("div", {
1372
+ className: "flex items-center gap-2 pr-3",
1373
+ children: [/* @__PURE__ */ U("div", {
1374
+ className: "min-w-0 flex-1",
1375
+ children: /* @__PURE__ */ U(Ln, {
1376
+ variant: "dark",
1377
+ sourceUrl: s,
1378
+ title: e,
1379
+ mimeType: a
1380
+ })
1381
+ }), y && /* @__PURE__ */ U("div", {
1382
+ className: "shrink-0",
1383
+ children: y
1384
+ })]
1385
+ })
1386
+ }) : /* @__PURE__ */ W(jn, {
1387
+ variant: "dark",
1388
+ fixedHeight: !g,
1389
+ accentHex: v.accentHex,
1390
+ busy: v.isLoading,
1391
+ topRight: g ? y : void 0,
1392
+ children: [!g && /* @__PURE__ */ U(Ln, {
1393
+ variant: "dark",
1394
+ thumbnailUrl: v.thumbnailUrl,
1395
+ sourceUrl: s,
1396
+ title: e,
1397
+ mimeType: a,
1398
+ topRight: y,
1399
+ isLoading: v.isLoading,
1400
+ onImageError: v.onImageError
1401
+ }), /* @__PURE__ */ U(Dn, {
1402
+ chinTextColor: v.chinTextColor,
1403
+ variant: "dark",
1404
+ ctaSurface: v.surface,
1405
+ title: e,
1406
+ placeholderTitle: t,
1407
+ description: n,
1408
+ descriptionLines: r,
1409
+ url: i,
1410
+ appIcon: l,
1411
+ cta: u,
1412
+ trailingAction: b,
1413
+ isLoading: v.isLoading
1414
+ })]
1415
+ });
1416
+ }, qn = ({ accentHex: e, side: t, visible: n, children: r }) => n ? /* @__PURE__ */ W("div", {
1417
+ className: "relative isolate w-fit",
1418
+ children: [r, /* @__PURE__ */ U("span", {
1419
+ "aria-hidden": !0,
1420
+ "data-testid": "link-card-tail",
1421
+ "data-variant": t === "sender" ? "dark" : "light",
1422
+ style: e ? { "--accent": e } : void 0,
1423
+ className: q("messaging-link-card-tail", t === "receiver" && "messaging-link-card-tail--received")
1424
+ })]
1425
+ }) : /* @__PURE__ */ U(H, { children: r }), Jn = {
1426
+ Composer: Kn,
1427
+ Sent: ({ title: e, placeholderTitle: t, description: n, descriptionLines: r, url: i, mimeType: a, thumbnailUrl: o, sourceUrl: s, layout: c = "featured", appIcon: l, cta: u, accentColor: d, status: f = "ready", onClick: p, groupPosition: m = "single" }) => {
1428
+ let h = Fn(a, s), g = bn(i), _ = u == null && g != null && !h ? g : void 0, v = u == null && !h && _ != null ? p : void 0, y = f !== "loading" && Pn(a, s), b = Un({
1429
+ variant: "dark",
1430
+ accentColor: d,
1431
+ status: f,
1432
+ layout: c,
1433
+ thumbnailUrl: o,
1434
+ mimeType: a,
1435
+ sourceUrl: s
1436
+ });
1437
+ return /* @__PURE__ */ U(qn, {
1438
+ accentHex: b.accentHex,
1439
+ side: "sender",
1440
+ visible: !y && (m === "single" || m === "end"),
1441
+ children: /* @__PURE__ */ W(jn, {
1442
+ variant: "dark",
1443
+ href: _,
1444
+ onClick: v,
1445
+ fixedHeight: c === "featured" && !y,
1446
+ accentHex: b.accentHex,
1447
+ busy: b.isLoading,
1448
+ bgClassName: y ? In : void 0,
1449
+ children: [c === "featured" && /* @__PURE__ */ U(Ln, {
1450
+ variant: "dark",
1451
+ thumbnailUrl: b.thumbnailUrl,
1452
+ sourceUrl: s,
1453
+ title: e,
1454
+ mimeType: a,
1455
+ isLoading: b.isLoading,
1456
+ onImageError: b.onImageError
1457
+ }), /* @__PURE__ */ U(Dn, {
1458
+ chinTextColor: b.chinTextColor,
1459
+ variant: "dark",
1460
+ ctaSurface: b.surface,
1461
+ title: e,
1462
+ placeholderTitle: t,
1463
+ description: n,
1464
+ descriptionLines: r,
1465
+ url: i,
1466
+ appIcon: l,
1467
+ cta: u,
1468
+ isLoading: b.isLoading
1469
+ })]
1470
+ })
1471
+ });
1472
+ },
1473
+ Received: ({ title: e, description: t, descriptionLines: n, url: r, mimeType: i, thumbnailUrl: a, sourceUrl: o, layout: s = "featured", appIcon: c, cta: l, accentColor: u, status: d = "ready", onClick: f, groupPosition: p = "single" }) => {
1474
+ let m = Fn(i, o), h = bn(r), g = l == null && h != null && !m ? h : void 0, _ = l == null && !m ? f : void 0, v = d !== "loading" && Pn(i, o) ? In : void 0, y = l && f ? {
1475
+ ...l,
1476
+ onClick: () => {
1477
+ f(), l.onClick?.();
1478
+ }
1479
+ } : l, b = Un({
1480
+ variant: "light",
1481
+ accentColor: u,
1482
+ status: d,
1483
+ layout: s,
1484
+ thumbnailUrl: a,
1485
+ mimeType: i,
1486
+ sourceUrl: o
1487
+ });
1488
+ return /* @__PURE__ */ U(qn, {
1489
+ accentHex: b.accentHex,
1490
+ side: "receiver",
1491
+ visible: v == null && (p === "single" || p === "end"),
1492
+ children: /* @__PURE__ */ W(jn, {
1493
+ variant: "light",
1494
+ href: g,
1495
+ onClick: _,
1496
+ ariaLabel: e ?? "Open attachment preview",
1497
+ fixedHeight: s === "featured" && v == null,
1498
+ accentHex: b.accentHex,
1499
+ busy: b.isLoading,
1500
+ bgClassName: v,
1501
+ "data-testid": "link-attachment",
1502
+ children: [s === "featured" && /* @__PURE__ */ U(Ln, {
1503
+ variant: "light",
1504
+ thumbnailUrl: b.thumbnailUrl,
1505
+ sourceUrl: o,
1506
+ title: e,
1507
+ mimeType: i,
1508
+ isLoading: b.isLoading,
1509
+ onImageError: b.onImageError
1510
+ }), /* @__PURE__ */ U(Dn, {
1511
+ chinTextColor: b.chinTextColor,
1512
+ variant: "light",
1513
+ ctaSurface: b.surface,
1514
+ title: e,
1515
+ description: t,
1516
+ descriptionLines: n,
1517
+ url: r,
1518
+ appIcon: c,
1519
+ cta: y,
1520
+ isLoading: b.isLoading
1521
+ })]
1522
+ })
1523
+ });
1524
+ }
1525
+ }, Yn = {
1526
+ dark: "bg-[#1e2330]",
1527
+ light: "bg-[#f2f1ef]"
1528
+ }, Xn = {
1529
+ dark: "text-white",
1530
+ light: "text-[#000000]"
1531
+ }, Zn = {
1532
+ dark: "border-white/[0.08]",
1533
+ light: "border-black/[0.08]"
1534
+ }, Qn = (e) => e === "dark" ? "sender" : "receiver", $n = {
1535
+ sender: {
1536
+ single: "rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",
1537
+ first: "rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[4px]",
1538
+ middle: "rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[4px]",
1539
+ end: "rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[18px]"
1540
+ },
1541
+ receiver: {
1542
+ single: "rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",
1543
+ first: "rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",
1544
+ middle: "rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",
1545
+ end: "rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]"
1546
+ }
1547
+ }, er = ({ variant: e, text: t, bordered: n = !0, groupPosition: r = "single", widthClassName: i = "w-[280px]", paddingClassName: a = "px-2 py-2", radiusClassName: o, className: s, children: c, "data-testid": l }) => {
1548
+ let u = t != null && t !== "", d = o ?? $n[Qn(e)][r];
1549
+ return /* @__PURE__ */ W("div", {
1550
+ "data-testid": l,
1551
+ "data-group-position": r,
1552
+ className: q("relative", i, "overflow-hidden", a, u && "pb-0", d, Yn[e], Xn[e], n && "border", n && Zn[e], s),
1553
+ children: [c, u ? /* @__PURE__ */ U("p", {
1554
+ className: q("whitespace-pre-wrap break-words leading-snug hyphens-manual", "pb-2 pt-2", "px-2"),
1555
+ children: t
1556
+ }) : null]
1557
+ });
1558
+ }, tr = ({ onClick: e, variant: t = "overlay", ariaLabel: n = "Dismiss attachment" }) => /* @__PURE__ */ U("button", {
1559
+ type: "button",
1560
+ onClick: (t) => {
1561
+ t.stopPropagation(), e();
1562
+ },
1563
+ "aria-label": n,
1564
+ className: q("flex size-6 items-center justify-center rounded-full text-white", t === "overlay" ? "bg-[#121110]/85 backdrop-blur" : "bg-white/15 hover:bg-white/25"),
1565
+ children: /* @__PURE__ */ U(Je, {
1566
+ className: "size-3",
1567
+ weight: "bold"
1568
+ })
1569
+ }), nr = (e) => e === "received" ? "light" : "dark", rr = ({ firstOfGroup: e, endOfGroup: t, groupedByUser: n }) => !n || e && t ? "single" : e ? "first" : t ? "end" : "middle", ir = ({ src: e, mimeType: t, filename: n, items: r }) => r && r.length > 0 ? r : e ? [{
1570
+ src: e,
1571
+ mimeType: t,
1572
+ filename: n
1573
+ }] : [], ar = ({ item: e, preload: t, trailingAction: n }) => /* @__PURE__ */ W("div", {
1574
+ className: "flex items-center gap-2",
1575
+ children: [/* @__PURE__ */ U("audio", {
1576
+ src: e.src,
1577
+ controls: !0,
1578
+ preload: e.preload ?? t,
1579
+ className: "block min-w-0 flex-1",
1580
+ children: e.mimeType ? /* @__PURE__ */ U("source", {
1581
+ src: e.src,
1582
+ type: e.mimeType
1583
+ }) : null
1584
+ }), n ?? null]
1585
+ }), or = ({ state: e, src: t, mimeType: n, filename: r, items: i, text: a, groupPosition: o, preload: s, onDismiss: c }) => {
1586
+ let l = nr(e), u = e === "composer" && !!c, d = ir({
1587
+ src: t,
1588
+ mimeType: n,
1589
+ filename: r,
1590
+ items: i
1591
+ });
1592
+ if (d.length === 0) return null;
1593
+ let f = s ?? (d.length > 1 ? "none" : "metadata");
1594
+ return /* @__PURE__ */ U(er, {
1595
+ variant: l,
1596
+ text: a,
1597
+ groupPosition: o,
1598
+ "data-testid": "audio-attachment",
1599
+ children: /* @__PURE__ */ U("div", {
1600
+ className: "flex flex-col gap-2",
1601
+ children: d.map((e, t) => /* @__PURE__ */ U(ar, {
1602
+ item: e,
1603
+ preload: f,
1604
+ trailingAction: u && t === 0 ? /* @__PURE__ */ U(tr, {
1605
+ onClick: c,
1606
+ variant: "inline"
1607
+ }) : void 0
1608
+ }, `${e.src}-${t}`))
1609
+ })
1610
+ });
1611
+ }, sr = {
1612
+ Composer: (e) => /* @__PURE__ */ U(or, {
1613
+ ...e,
1614
+ state: "composer"
1615
+ }),
1616
+ Sent: (e) => /* @__PURE__ */ U(or, {
1617
+ ...e,
1618
+ state: "sent"
1619
+ }),
1620
+ Received: (e) => /* @__PURE__ */ U(or, {
1621
+ ...e,
1622
+ state: "received"
1623
+ })
1624
+ };
1625
+ //#endregion
1626
+ //#region src/components/MessageAttachment/_shared/fileMeta.ts
1627
+ function cr(e) {
1628
+ return !Number.isFinite(e) || e < 0 ? "" : e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : e < 1073741824 ? `${(e / 1048576).toFixed(2)} MB` : `${(e / 1073741824).toFixed(2)} GB`;
1629
+ }
1630
+ var lr = {
1631
+ pdf: "PDF",
1632
+ doc: "DOC",
1633
+ xls: "XLS",
1634
+ csv: "CSV",
1635
+ ppt: "PPT",
1636
+ zip: "ZIP",
1637
+ text: "TXT",
1638
+ markdown: "MD"
1639
+ };
1640
+ function ur(n, r) {
1641
+ if (r) {
1642
+ let e = r.lastIndexOf(".");
1643
+ if (e > 0 && e < r.length - 1) {
1644
+ let t = r.slice(e + 1);
1645
+ if (t && t.length <= 5) return t.toUpperCase();
1646
+ }
1647
+ }
1648
+ if (!n) return;
1649
+ if (e(n) === "document") {
1650
+ let e = lr[t(n)];
1651
+ if (e) return e;
1652
+ if (n === "application/octet-stream") return;
1653
+ }
1654
+ let i = n.split("/")[1];
1655
+ if (!(!i || i === "*")) return i.toUpperCase();
1656
+ }
1657
+ function dr(e, t, n) {
1658
+ return [ur(e, t), typeof n == "number" && n > 0 ? cr(n) : void 0].filter(Boolean).join(" · ") || void 0;
1659
+ }
1660
+ function Q(e) {
1661
+ try {
1662
+ let t = new URL(e).pathname.split("/").pop();
1663
+ return t && t.length > 0 ? decodeURIComponent(t) : "download";
1664
+ } catch {
1665
+ return "download";
1666
+ }
1667
+ }
1668
+ //#endregion
1669
+ //#region src/components/MessageAttachment/_shared/CompactDocumentRow.tsx
1670
+ var fr = {
1671
+ dark: "text-white/55",
1672
+ light: "text-black/65"
1673
+ }, pr = {
1674
+ dark: "bg-white/10",
1675
+ light: "bg-black/5"
1676
+ }, mr = {
1677
+ dark: "text-white/85",
1678
+ light: "text-black/85"
1679
+ }, hr = ({ variant: e, filename: t, title: n, mimeType: r = "application/octet-stream", fileSize: a, onActivate: o, activateLabel: s, trailingAction: c }) => {
1680
+ let l = n ?? t ?? "File", u = dr(r, t, a), d = /* @__PURE__ */ U("div", {
1681
+ className: q("flex size-10 shrink-0 items-center justify-center rounded-sm", pr[e]),
1682
+ "aria-hidden": !0,
1683
+ children: i(r, {
1684
+ className: q("size-6", mr[e]),
1685
+ weight: "regular"
1686
+ })
1687
+ }), f = /* @__PURE__ */ W("div", {
1688
+ className: "flex min-w-0 flex-1 flex-col text-left",
1689
+ children: [/* @__PURE__ */ U("p", {
1690
+ className: "truncate font-medium leading-snug",
1691
+ children: l
1692
+ }), u ? /* @__PURE__ */ U("p", {
1693
+ className: q("truncate text-xs leading-4", fr[e]),
1694
+ children: u
1695
+ }) : null]
1696
+ }), p = o ? /* @__PURE__ */ W("button", {
1697
+ type: "button",
1698
+ onClick: o,
1699
+ "aria-label": s,
1700
+ className: q("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors", e === "dark" ? "hover:bg-white/[0.04]" : "hover:bg-black/[0.04]"),
1701
+ children: [d, f]
1702
+ }) : /* @__PURE__ */ W(H, { children: [d, f] });
1703
+ return /* @__PURE__ */ W("div", {
1704
+ className: "flex items-center gap-3 px-3 py-2",
1705
+ children: [p, c ? /* @__PURE__ */ U("div", {
1706
+ className: "shrink-0",
1707
+ children: c
1708
+ }) : null]
1709
+ });
1710
+ };
1711
+ //#endregion
1712
+ //#region src/components/MessageAttachment/_shared/triggerDownload.ts
1713
+ async function gr(e, t) {
1714
+ let n = t ?? Q(e);
1715
+ try {
1716
+ let t = await fetch(e, { mode: "cors" });
1717
+ if (!t.ok) throw Error(`HTTP ${t.status}`);
1718
+ let r = await t.blob(), i = URL.createObjectURL(r), a = document.createElement("a");
1719
+ a.href = i, a.download = n, a.style.display = "none", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
1720
+ } catch {
1721
+ if (!window.open(e, "_blank", "noopener,noreferrer")) {
1722
+ let t = document.createElement("a");
1723
+ t.href = e, t.download = n, t.target = "_blank", t.rel = "noopener noreferrer", t.style.display = "none", document.body.appendChild(t), t.click(), document.body.removeChild(t);
1724
+ }
1725
+ }
1726
+ }
1727
+ //#endregion
1728
+ //#region src/components/MessageAttachment/File/index.tsx
1729
+ var _r = ({ src: e, filename: t, fileSize: n, mimeType: r, title: i, items: a }) => a && a.length > 0 ? a : e ? [{
1730
+ src: e,
1731
+ filename: t,
1732
+ fileSize: n,
1733
+ mimeType: r,
1734
+ title: i
1735
+ }] : [], vr = ({ variant: e, item: t, index: n, onActivate: r, trailingAction: i }) => {
1736
+ let a = t.filename ?? Q(t.src);
1737
+ return /* @__PURE__ */ U(hr, {
1738
+ variant: e,
1739
+ filename: a,
1740
+ title: t.title,
1741
+ mimeType: t.mimeType ?? "application/octet-stream",
1742
+ fileSize: t.fileSize,
1743
+ onActivate: () => r(n),
1744
+ activateLabel: `Download ${a}`,
1745
+ trailingAction: i
1746
+ });
1747
+ }, yr = ({ state: e, src: t, filename: n, fileSize: r, mimeType: i, title: a, items: o, text: s, groupPosition: c, onClick: l, onDismiss: u }) => {
1748
+ let d = nr(e), f = e === "composer" && !!u, p = _r({
1749
+ src: t,
1750
+ filename: n,
1751
+ fileSize: r,
1752
+ mimeType: i,
1753
+ title: a,
1754
+ items: o
1755
+ }), m = (e) => {
1756
+ if (l?.(e) === !1) return;
1757
+ let t = p[e];
1758
+ if (!t) return;
1759
+ let n = t.filename ?? Q(t.src);
1760
+ gr(t.src, n);
1761
+ };
1762
+ if (p.length === 0) return null;
1763
+ let h = /* @__PURE__ */ U("span", {
1764
+ className: q("flex size-8 items-center justify-center rounded-full", d === "dark" ? "text-white/70" : "text-black/70"),
1765
+ "aria-hidden": !0,
1766
+ children: /* @__PURE__ */ U(X, {
1767
+ className: "size-5",
1768
+ weight: "bold"
1769
+ })
1770
+ });
1771
+ return /* @__PURE__ */ U(er, {
1772
+ variant: d,
1773
+ text: s,
1774
+ groupPosition: c,
1775
+ "data-testid": "file-attachment",
1776
+ children: /* @__PURE__ */ U("div", {
1777
+ className: "flex flex-col gap-2",
1778
+ children: p.map((e, t) => /* @__PURE__ */ U(vr, {
1779
+ variant: d,
1780
+ item: e,
1781
+ index: t,
1782
+ onActivate: m,
1783
+ trailingAction: f && t === 0 ? /* @__PURE__ */ U(tr, {
1784
+ onClick: u,
1785
+ variant: "inline"
1786
+ }) : h
1787
+ }, `${e.src}-${t}`))
1788
+ })
1789
+ });
1790
+ }, br = {
1791
+ Composer: (e) => /* @__PURE__ */ U(yr, {
1792
+ ...e,
1793
+ state: "composer"
1794
+ }),
1795
+ Sent: (e) => /* @__PURE__ */ U(yr, {
1796
+ ...e,
1797
+ state: "sent"
1798
+ }),
1799
+ Received: (e) => /* @__PURE__ */ U(yr, {
1800
+ ...e,
1801
+ state: "received"
1802
+ })
1803
+ }, xr = "inline-flex size-10 items-center justify-center rounded-full border-0 bg-white/[0.12] p-0 text-white transition-colors duration-150 ease-[ease] hover:bg-white/[0.22] focus-visible:bg-white/[0.22] focus-visible:outline-none disabled:cursor-default disabled:opacity-40", Sr = "absolute top-1/2 z-[1] inline-flex size-12 -translate-y-1/2 items-center justify-center rounded-full border-0 bg-white/[0.12] p-0 text-white transition-colors duration-150 ease-[ease] hover:bg-white/[0.22] focus-visible:bg-white/[0.22] focus-visible:outline-none", Cr = ({ onPrev: e, onNext: t, prevLabel: n = "Previous", nextLabel: r = "Next" }) => /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U("button", {
1804
+ type: "button",
1805
+ onClick: e,
1806
+ "aria-label": n,
1807
+ className: `${Sr} left-4`,
1808
+ children: /* @__PURE__ */ U(ke, {
1809
+ size: 20,
1810
+ weight: "bold",
1811
+ "aria-hidden": !0
1812
+ })
1813
+ }), /* @__PURE__ */ U("button", {
1814
+ type: "button",
1815
+ onClick: t,
1816
+ "aria-label": r,
1817
+ className: `${Sr} right-4`,
1818
+ children: /* @__PURE__ */ U(Ae, {
1819
+ size: 20,
1820
+ weight: "bold",
1821
+ "aria-hidden": !0
1822
+ })
1823
+ })] }), wr = ({ url: e, filename: t, variant: n = "pill", label: r = "Download", iconOnly: i, tone: a = "dark", onTriggered: o }) => {
1824
+ let [s, c] = h(!1), u = l((n) => {
1825
+ n.stopPropagation(), !s && (c(!0), gr(e, t).catch(() => {}).finally(() => {
1826
+ c(!1), o?.();
1827
+ }));
1828
+ }, [
1829
+ s,
1830
+ e,
1831
+ t,
1832
+ o
1833
+ ]), d = i ?? n !== "pill", f = {
1834
+ className: q(n === "pill" ? "size-4" : "size-5", "shrink-0"),
1835
+ weight: "bold"
1836
+ };
1837
+ return n === "inline" ? /* @__PURE__ */ U("button", {
1838
+ type: "button",
1839
+ onClick: u,
1840
+ disabled: s,
1841
+ "aria-label": r,
1842
+ className: q("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70", {
1843
+ dark: "text-white/70 hover:bg-white/[0.08] hover:text-white",
1844
+ light: "text-black/70 hover:bg-black/[0.08] hover:text-black"
1845
+ }[a]),
1846
+ children: s ? /* @__PURE__ */ U(J, {
1847
+ className: "size-4 animate-spin",
1848
+ weight: "bold",
1849
+ "aria-hidden": !0
1850
+ }) : /* @__PURE__ */ U(X, {
1851
+ className: "size-5 shrink-0",
1852
+ weight: "bold",
1853
+ "aria-hidden": !0
1854
+ })
1855
+ }) : n === "viewer" ? /* @__PURE__ */ U("button", {
1856
+ type: "button",
1857
+ onClick: u,
1858
+ disabled: s,
1859
+ "aria-label": r,
1860
+ className: xr,
1861
+ children: U(s ? J : X, {
1862
+ size: 20,
1863
+ weight: "bold",
1864
+ "aria-hidden": !0
1865
+ })
1866
+ }) : /* @__PURE__ */ W("button", {
1867
+ type: "button",
1868
+ onClick: u,
1869
+ disabled: s,
1870
+ "aria-label": d ? r : void 0,
1871
+ className: q("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", a === "dark" ? "bg-[#121110] text-white hover:bg-[#2a2928]" : "bg-white text-[#121110] hover:bg-white/90"),
1872
+ children: [s ? /* @__PURE__ */ U(J, {
1873
+ className: "size-4 animate-spin",
1874
+ weight: "bold",
1875
+ "aria-hidden": !0
1876
+ }) : /* @__PURE__ */ U(X, {
1877
+ ...f,
1878
+ "aria-hidden": !0
1879
+ }), d ? null : r]
1880
+ });
1881
+ }, Tr = (e, t, n) => Math.min(Math.max(e, t), n), Er = ({ length: e, initialIndex: t, open: n }) => {
1882
+ let r = Tr(t, 0, Math.max(e - 1, 0)), [i, a] = h(r);
1883
+ d(() => {
1884
+ n && a(Tr(t, 0, Math.max(e - 1, 0)));
1885
+ }, [
1886
+ n,
1887
+ t,
1888
+ e
1889
+ ]), d(() => {
1890
+ a((t) => Tr(t, 0, Math.max(e - 1, 0)));
1891
+ }, [e]);
1892
+ let o = l(() => {
1893
+ e <= 1 || a((t) => t <= 0 ? e - 1 : t - 1);
1894
+ }, [e]), s = l(() => {
1895
+ e <= 1 || a((t) => t >= e - 1 ? 0 : t + 1);
1896
+ }, [e]);
1897
+ return d(() => {
1898
+ if (!n || e <= 1) return;
1899
+ let t = (e) => {
1900
+ if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
1901
+ let t = document.activeElement;
1902
+ t && (t.tagName === "VIDEO" || t.tagName === "AUDIO") || (e.preventDefault(), e.key === "ArrowLeft" ? o() : s());
1903
+ };
1904
+ return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
1905
+ }, [
1906
+ n,
1907
+ e,
1908
+ o,
1909
+ s
1910
+ ]), {
1911
+ index: i,
1912
+ prev: o,
1913
+ next: s
1914
+ };
1915
+ }, Dr = ({ open: e, onClose: t, ariaLabel: n, counter: r, actions: i, children: a, "data-testid": o }) => {
1916
+ let s = m(null), c = m(null);
1917
+ return d(() => {
1918
+ let t = s.current;
1919
+ if (t) {
1920
+ if (e) {
1921
+ if (!t.open) {
1922
+ if (typeof t.showModal == "function") try {
1923
+ t.showModal();
1924
+ } catch {
1925
+ t.setAttribute("open", "");
1926
+ }
1927
+ else t.setAttribute("open", "");
1928
+ }
1929
+ let e = typeof document < "u" ? document.activeElement : null;
1930
+ return c.current?.focus(), () => {
1931
+ if (t.open) {
1932
+ if (typeof t.close == "function") try {
1933
+ t.close();
1934
+ } catch {
1935
+ t.removeAttribute("open");
1936
+ }
1937
+ else t.removeAttribute("open");
1938
+ }
1939
+ e && document.body.contains(e) && e.focus();
1940
+ };
1941
+ }
1942
+ if (t.open) {
1943
+ if (typeof t.close == "function") try {
1944
+ t.close();
1945
+ } catch {
1946
+ t.removeAttribute("open");
1947
+ }
1948
+ else t.removeAttribute("open");
1949
+ }
1950
+ }
1951
+ }, [e]), /* @__PURE__ */ W("dialog", {
1952
+ ref: s,
1953
+ className: "mes-media-viewer",
1954
+ "aria-label": n ?? "Attachment viewer",
1955
+ "data-testid": o,
1956
+ onClose: () => {
1957
+ t();
1958
+ },
1959
+ onClick: (e) => {
1960
+ e.target === s.current && t();
1961
+ },
1962
+ children: [/* @__PURE__ */ W("div", {
1963
+ className: "pointer-events-none absolute inset-x-3 top-3 z-[1] flex items-center justify-between gap-3",
1964
+ children: [r ? /* @__PURE__ */ U("span", {
1965
+ className: "pointer-events-auto inline-flex items-center rounded-full bg-white/[0.12] px-3 py-1.5 text-[13px] font-medium leading-none tabular-nums text-white",
1966
+ children: r
1967
+ }) : null, /* @__PURE__ */ W("div", {
1968
+ className: "pointer-events-auto ml-auto inline-flex items-center gap-2",
1969
+ children: [i, /* @__PURE__ */ U("button", {
1970
+ ref: c,
1971
+ type: "button",
1972
+ onClick: t,
1973
+ "aria-label": "Close viewer",
1974
+ className: xr,
1975
+ children: /* @__PURE__ */ U(Je, {
1976
+ size: 20,
1977
+ weight: "bold",
1978
+ "aria-hidden": !0
1979
+ })
1980
+ })]
1981
+ })]
1982
+ }), /* @__PURE__ */ U("div", {
1983
+ className: "box-border flex h-full w-full items-center justify-center px-6 py-16",
1984
+ children: a
1985
+ })]
1986
+ });
1987
+ }, Or = ({ open: e, items: t, initialIndex: n = 0, onClose: r }) => {
1988
+ let { index: i, prev: a, next: o } = Er({
1989
+ length: t.length,
1990
+ initialIndex: n,
1991
+ open: e
1992
+ }), s = t[i], c = p(() => s?.filename ?? (s ? Q(s.src) : "image"), [s]);
1993
+ return s ? /* @__PURE__ */ W(Dr, {
1994
+ open: e,
1995
+ onClose: r,
1996
+ ariaLabel: c,
1997
+ counter: t.length > 1 ? `${i + 1} / ${t.length}` : void 0,
1998
+ actions: /* @__PURE__ */ U(wr, {
1999
+ url: s.src,
2000
+ filename: c,
2001
+ variant: "viewer",
2002
+ label: `Download ${c}`
2003
+ }),
2004
+ "data-testid": "image-viewer",
2005
+ children: [e ? /* @__PURE__ */ U("img", {
2006
+ src: s.src,
2007
+ alt: s.alt ?? c,
2008
+ draggable: !1,
2009
+ decoding: "async",
2010
+ className: "block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] select-none object-contain"
2011
+ }, `${i}:${s.src}`) : null, t.length > 1 ? /* @__PURE__ */ U(Cr, {
2012
+ onPrev: a,
2013
+ onNext: o,
2014
+ prevLabel: "Previous image",
2015
+ nextLabel: "Next image"
2016
+ }) : null]
2017
+ }) : null;
2018
+ }, kr = "relative block size-full overflow-hidden bg-black/5 outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-white/80 focus-visible:after:ring-offset-2 focus-visible:after:ring-offset-black", Ar = {
2019
+ 1: ["rounded-[18px]"],
2020
+ 2: ["rounded-l-[18px]", "rounded-r-[18px]"],
2021
+ 3: [
2022
+ "rounded-l-[18px]",
2023
+ "rounded-tr-[18px]",
2024
+ "rounded-br-[18px]"
2025
+ ],
2026
+ 4: [
2027
+ "rounded-tl-[18px]",
2028
+ "rounded-tr-[18px]",
2029
+ "rounded-bl-[18px]",
2030
+ "rounded-br-[18px]"
2031
+ ]
2032
+ }, jr = "--mes-single-width-cap", Mr = "[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]", Nr = 436, Pr = ({ tiles: e, onTileActivate: t, maxVisible: n = 4, singleAspectRatio: r, className: i }) => {
2033
+ let a = e.length;
2034
+ if (a === 0) return null;
2035
+ let o = e.slice(0, Math.min(a, n)), s = a - o.length, c = (e, n, r) => {
2036
+ let i = q(kr, "h-full w-full", Ar[o.length]?.[n]);
2037
+ return t ? /* @__PURE__ */ W("button", {
2038
+ type: "button",
2039
+ onClick: () => t(n),
2040
+ "aria-label": e.ariaLabel ?? `Open media ${n + 1}`,
2041
+ className: q(i, "cursor-zoom-in"),
2042
+ children: [e.content, r]
2043
+ }, n) : /* @__PURE__ */ W("div", {
2044
+ className: i,
2045
+ children: [e.content, r]
2046
+ }, n);
2047
+ }, l;
2048
+ return r && (l = {
2049
+ aspectRatio: r,
2050
+ width: `min(var(${jr}), ${Math.round(Nr * r * 100) / 100}px)`,
2051
+ maxWidth: "100%"
2052
+ }), o.length === 1 ? /* @__PURE__ */ U("div", {
2053
+ className: q(r ? Mr : "aspect-square w-full", i),
2054
+ style: l,
2055
+ children: c(o[0], 0)
2056
+ }) : o.length === 2 ? /* @__PURE__ */ U("div", {
2057
+ className: q("grid aspect-[16/9] w-full grid-cols-2 gap-0.5", i),
2058
+ children: o.map((e, t) => c(e, t))
2059
+ }) : o.length === 3 ? /* @__PURE__ */ W("div", {
2060
+ className: q("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5", i),
2061
+ children: [
2062
+ /* @__PURE__ */ U("div", {
2063
+ className: "row-span-2",
2064
+ children: c(o[0], 0)
2065
+ }),
2066
+ c(o[1], 1),
2067
+ c(o[2], 2)
2068
+ ]
2069
+ }) : /* @__PURE__ */ U("div", {
2070
+ className: q("grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5", i),
2071
+ children: o.map((e, t) => {
2072
+ let n = s > 0 && t === o.length - 1;
2073
+ return c(e, t, n ? /* @__PURE__ */ W("div", {
2074
+ className: "absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",
2075
+ children: ["+", s]
2076
+ }) : null);
2077
+ })
2078
+ });
2079
+ }, Fr = (e) => {
2080
+ let [t, n] = h(!1), [r, i] = h(0);
2081
+ return {
2082
+ viewerOpen: t,
2083
+ viewerIndex: r,
2084
+ handleActivate: l((t) => {
2085
+ e?.(t) !== !1 && (i(t), n(!0));
2086
+ }, [e]),
2087
+ closeViewer: l(() => n(!1), [])
2088
+ };
2089
+ }, Ir = ({ item: e, index: t, totalCount: n, fallbackLoading: i, imgRef: a, onLoad: o }) => ({
2090
+ ariaLabel: `Open image ${t + 1} of ${n}`,
2091
+ content: /* @__PURE__ */ U("img", {
2092
+ ref: a,
2093
+ src: r(e.src) ?? e.src,
2094
+ alt: e.alt ?? "",
2095
+ width: e.width,
2096
+ height: e.height,
2097
+ draggable: !1,
2098
+ loading: e.loading ?? i,
2099
+ decoding: "async",
2100
+ onLoad: o,
2101
+ className: "absolute inset-0 size-full object-cover"
2102
+ })
2103
+ }), Lr = ({ src: e, alt: t, items: n }) => n && n.length > 0 ? n : e ? [{
2104
+ src: e,
2105
+ alt: t
2106
+ }] : [], Rr = (e, t) => e.map((n, r) => ({
2107
+ src: n.src,
2108
+ alt: n.alt,
2109
+ filename: t && e.length === 1 ? t : t ? `${t} (${r + 1})` : void 0
2110
+ })), zr = ({ src: e, alt: t, filename: n, loading: i = "lazy", onClick: a, onDismiss: o }) => {
2111
+ let { viewerOpen: s, viewerIndex: c, handleActivate: l, closeViewer: u } = Fr(a);
2112
+ return /* @__PURE__ */ W("div", {
2113
+ className: "relative w-fit",
2114
+ children: [
2115
+ /* @__PURE__ */ U("button", {
2116
+ type: "button",
2117
+ onClick: () => l(0),
2118
+ "aria-label": "Open image",
2119
+ className: "block size-[280px] cursor-zoom-in overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",
2120
+ children: /* @__PURE__ */ U("img", {
2121
+ src: r(e) ?? e,
2122
+ alt: t ?? "",
2123
+ draggable: !1,
2124
+ loading: i,
2125
+ decoding: "async",
2126
+ className: "size-full object-cover"
2127
+ })
2128
+ }),
2129
+ o ? /* @__PURE__ */ U("div", {
2130
+ className: "absolute right-2 top-2 z-10",
2131
+ children: /* @__PURE__ */ U(tr, { onClick: o })
2132
+ }) : null,
2133
+ /* @__PURE__ */ U(Or, {
2134
+ open: s,
2135
+ items: Rr([{
2136
+ src: e,
2137
+ alt: t
2138
+ }], n),
2139
+ initialIndex: c,
2140
+ onClose: u
2141
+ })
2142
+ ]
2143
+ });
2144
+ }, Br = 326 / 246, Vr = (e) => {
2145
+ let t = e?.src, [n, r] = o.useState(), i = o.useCallback((e) => {
2146
+ if (!e || e.naturalWidth <= 0 || e.naturalHeight <= 0 || t === void 0) return;
2147
+ let n = e.naturalWidth / e.naturalHeight;
2148
+ r((e) => e && e.src === t && e.ratio === n ? e : {
2149
+ src: t,
2150
+ ratio: n
2151
+ });
2152
+ }, [t]), a = o.useCallback((e) => i(e.currentTarget), [i]), s = e?.width && e?.height ? e.width / e.height : void 0, c = n && n.src === t ? n.ratio : void 0;
2153
+ return {
2154
+ ratio: s ?? c ?? Br,
2155
+ imgRef: i,
2156
+ onLoad: a
2157
+ };
2158
+ }, Hr = ({ state: e, src: t, alt: n, filename: r, items: i, text: a, groupPosition: o, loading: s = "lazy", onClick: c }) => {
2159
+ let l = Lr({
2160
+ src: t,
2161
+ alt: n,
2162
+ items: i
2163
+ }), u = nr(e), { viewerOpen: d, viewerIndex: f, handleActivate: p, closeViewer: m } = Fr(c), h = l.length === 1, g = Vr(h ? l[0] : void 0);
2164
+ if (l.length === 0) return null;
2165
+ let _ = l.map((e, t) => Ir({
2166
+ item: e,
2167
+ index: t,
2168
+ totalCount: l.length,
2169
+ fallbackLoading: s,
2170
+ imgRef: h ? g.imgRef : void 0,
2171
+ onLoad: h ? g.onLoad : void 0
2172
+ }));
2173
+ return /* @__PURE__ */ W(er, {
2174
+ variant: u,
2175
+ text: a,
2176
+ groupPosition: o,
2177
+ bordered: !1,
2178
+ widthClassName: h ? "w-fit max-w-[min(100%,313px)] sm:max-w-[min(100%,330px)]" : "w-[383px] max-w-full",
2179
+ paddingClassName: "p-0.5",
2180
+ radiusClassName: "rounded-[20px]",
2181
+ "data-testid": "image-attachment",
2182
+ children: [/* @__PURE__ */ U("div", {
2183
+ className: "relative",
2184
+ children: /* @__PURE__ */ U(Pr, {
2185
+ tiles: _,
2186
+ onTileActivate: p,
2187
+ singleAspectRatio: h ? g.ratio : void 0
2188
+ })
2189
+ }), /* @__PURE__ */ U(Or, {
2190
+ open: d,
2191
+ items: Rr(l, r),
2192
+ initialIndex: f,
2193
+ onClose: m
2194
+ })]
2195
+ });
2196
+ }, Ur = {
2197
+ Composer: (e) => /* @__PURE__ */ U(zr, { ...e }),
2198
+ Sent: (e) => /* @__PURE__ */ U(Hr, {
2199
+ ...e,
2200
+ state: "sent"
2201
+ }),
2202
+ Received: (e) => /* @__PURE__ */ U(Hr, {
2203
+ ...e,
2204
+ state: "received"
2205
+ })
2206
+ }, Wr = ({ open: e, items: t, initialIndex: n = 0, onClose: r }) => {
2207
+ let { index: i, prev: a, next: o } = Er({
2208
+ length: t.length,
2209
+ initialIndex: n,
2210
+ open: e
2211
+ }), s = t[i], c = p(() => s?.filename ?? (s ? Q(s.src) : "document"), [s]), l = p(() => s ? Gr(s.src) : void 0, [s]);
2212
+ return !s || !l ? null : /* @__PURE__ */ W(Dr, {
2213
+ open: e,
2214
+ onClose: r,
2215
+ ariaLabel: c,
2216
+ counter: t.length > 1 ? `${i + 1} / ${t.length}` : void 0,
2217
+ "data-testid": "pdf-viewer",
2218
+ children: [/* @__PURE__ */ U("iframe", {
2219
+ src: l,
2220
+ title: c,
2221
+ className: "block h-[calc(100dvh-128px)] w-[min(96vw,1400px)] border-0 bg-white",
2222
+ sandbox: "allow-scripts allow-forms allow-popups allow-downloads"
2223
+ }, `${i}:${s.src}`), t.length > 1 ? /* @__PURE__ */ U(Cr, {
2224
+ onPrev: a,
2225
+ onNext: o,
2226
+ prevLabel: "Previous document",
2227
+ nextLabel: "Next document"
2228
+ }) : null]
2229
+ });
2230
+ }, Gr = (e) => {
2231
+ let t = e.indexOf("#"), n = t === -1 ? e : e.slice(0, t), r = t === -1 ? "" : e.slice(t + 1), i = new URLSearchParams(r);
2232
+ return i.has("toolbar") || i.set("toolbar", "0"), i.has("navpanes") || i.set("navpanes", "0"), `${n}#${i.toString()}`;
2233
+ }, Kr = ({ src: e, filename: t, fileSize: n, title: r, items: i }) => i && i.length > 0 ? i : e ? [{
2234
+ src: e,
2235
+ filename: t,
2236
+ fileSize: n,
2237
+ title: r
2238
+ }] : [], qr = ({ variant: e, item: t, index: n, onActivate: r, trailingAction: i }) => {
2239
+ let a = t.filename ?? Q(t.src);
2240
+ return /* @__PURE__ */ U(hr, {
2241
+ variant: e,
2242
+ filename: a,
2243
+ title: t.title,
2244
+ mimeType: "application/pdf",
2245
+ fileSize: t.fileSize,
2246
+ onActivate: () => r(n),
2247
+ activateLabel: `Open ${a}`,
2248
+ trailingAction: i
2249
+ });
2250
+ }, Jr = ({ state: e, src: t, filename: n, fileSize: r, title: i, items: a, text: o, groupPosition: s, onClick: c, onDismiss: l }) => {
2251
+ let u = nr(e), d = Kr({
2252
+ src: t,
2253
+ filename: n,
2254
+ fileSize: r,
2255
+ title: i,
2256
+ items: a
2257
+ }), { viewerOpen: f, viewerIndex: p, handleActivate: m, closeViewer: h } = Fr(c), g = e === "composer" && !!l;
2258
+ if (d.length === 0) return null;
2259
+ let _ = d.map((e) => ({
2260
+ src: e.src,
2261
+ filename: e.filename ?? Q(e.src)
2262
+ }));
2263
+ return /* @__PURE__ */ W(er, {
2264
+ variant: u,
2265
+ text: o,
2266
+ groupPosition: s,
2267
+ "data-testid": "pdf-attachment",
2268
+ children: [/* @__PURE__ */ U("div", {
2269
+ className: "flex flex-col gap-2",
2270
+ children: d.map((t, n) => {
2271
+ let r = t.filename ?? Q(t.src), i = g && n === 0 ? /* @__PURE__ */ U(tr, {
2272
+ onClick: l,
2273
+ variant: "inline"
2274
+ }) : e === "composer" ? void 0 : /* @__PURE__ */ U(wr, {
2275
+ url: t.src,
2276
+ filename: r,
2277
+ variant: "inline",
2278
+ label: `Download ${r}`,
2279
+ tone: u
2280
+ });
2281
+ return /* @__PURE__ */ U(qr, {
2282
+ variant: u,
2283
+ item: t,
2284
+ index: n,
2285
+ onActivate: m,
2286
+ trailingAction: i
2287
+ }, `${t.src}-${n}`);
2288
+ })
2289
+ }), /* @__PURE__ */ U(Wr, {
2290
+ open: f,
2291
+ items: _,
2292
+ initialIndex: p,
2293
+ onClose: h
2294
+ })]
2295
+ });
2296
+ }, Yr = {
2297
+ Composer: (e) => /* @__PURE__ */ U(Jr, {
2298
+ ...e,
2299
+ state: "composer"
2300
+ }),
2301
+ Sent: (e) => /* @__PURE__ */ U(Jr, {
2302
+ ...e,
2303
+ state: "sent"
2304
+ }),
2305
+ Received: (e) => /* @__PURE__ */ U(Jr, {
2306
+ ...e,
2307
+ state: "received"
2308
+ })
2309
+ }, Xr = ({ open: e, items: t, initialIndex: n = 0, onClose: r }) => {
2310
+ let { index: i, prev: a, next: o } = Er({
2311
+ length: t.length,
2312
+ initialIndex: n,
2313
+ open: e
2314
+ }), s = t[i], c = p(() => s?.filename ?? (s ? Q(s.src) : "video"), [s]);
2315
+ return s ? /* @__PURE__ */ W(Dr, {
2316
+ open: e,
2317
+ onClose: r,
2318
+ ariaLabel: c,
2319
+ counter: t.length > 1 ? `${i + 1} / ${t.length}` : void 0,
2320
+ "data-testid": "video-viewer",
2321
+ children: [/* @__PURE__ */ U("video", {
2322
+ src: s.src,
2323
+ poster: s.poster,
2324
+ controls: !0,
2325
+ autoPlay: !0,
2326
+ muted: !0,
2327
+ playsInline: !0,
2328
+ preload: s.preload ?? "metadata",
2329
+ className: "block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] bg-black",
2330
+ children: s.mimeType ? /* @__PURE__ */ U("source", {
2331
+ src: s.src,
2332
+ type: s.mimeType
2333
+ }) : null
2334
+ }, `${i}:${s.src}`), t.length > 1 ? /* @__PURE__ */ U(Cr, {
2335
+ onPrev: a,
2336
+ onNext: o,
2337
+ prevLabel: "Previous video",
2338
+ nextLabel: "Next video"
2339
+ }) : null]
2340
+ }) : null;
2341
+ }, Zr = () => /* @__PURE__ */ U("div", {
2342
+ className: "pointer-events-none absolute inset-0 flex items-center justify-center",
2343
+ children: /* @__PURE__ */ U("span", {
2344
+ className: "flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",
2345
+ children: /* @__PURE__ */ U(Re, {
2346
+ className: "size-6",
2347
+ weight: "fill",
2348
+ "aria-hidden": !0
2349
+ })
2350
+ })
2351
+ }), Qr = ({ item: e, index: t }) => /* @__PURE__ */ W("div", {
2352
+ className: "absolute inset-0 size-full bg-[#0d0d0d]",
2353
+ children: [e.poster ? /* @__PURE__ */ U("img", {
2354
+ src: e.poster,
2355
+ alt: `Video ${t + 1} thumbnail`,
2356
+ draggable: !1,
2357
+ loading: "lazy",
2358
+ decoding: "async",
2359
+ className: "absolute inset-0 size-full object-cover"
2360
+ }) : /* @__PURE__ */ U("div", {
2361
+ className: "absolute inset-0 flex items-center justify-center",
2362
+ children: /* @__PURE__ */ U(Ke, {
2363
+ className: "size-16 text-white/30",
2364
+ weight: "regular",
2365
+ "aria-hidden": !0
2366
+ })
2367
+ }), /* @__PURE__ */ U(Zr, {})]
2368
+ }), $r = (e, t, n) => ({
2369
+ ariaLabel: `Play video ${t + 1} of ${n}`,
2370
+ content: /* @__PURE__ */ U(Qr, {
2371
+ item: e,
2372
+ index: t
2373
+ })
2374
+ }), ei = ({ src: e, poster: t, mimeType: n, preload: r, items: i }) => i && i.length > 0 ? r ? i.map((e) => ({
2375
+ ...e,
2376
+ preload: e.preload ?? r
2377
+ })) : i : e ? [{
2378
+ src: e,
2379
+ poster: t,
2380
+ mimeType: n,
2381
+ preload: r
2382
+ }] : [], ti = (e, t) => e.map((n, r) => ({
2383
+ src: n.src,
2384
+ poster: n.poster,
2385
+ mimeType: n.mimeType,
2386
+ preload: n.preload,
2387
+ filename: t && e.length === 1 ? t : t ? `${t} (${r + 1})` : void 0
2388
+ })), ni = ({ src: e, poster: t, mimeType: n, filename: r, preload: i, onClick: a, onDismiss: o }) => {
2389
+ let { viewerOpen: s, viewerIndex: c, handleActivate: l, closeViewer: u } = Fr(a);
2390
+ return /* @__PURE__ */ W("div", {
2391
+ className: "relative w-fit",
2392
+ children: [
2393
+ /* @__PURE__ */ U("button", {
2394
+ type: "button",
2395
+ onClick: () => l(0),
2396
+ "aria-label": "Play video",
2397
+ className: "relative block size-[280px] cursor-pointer overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",
2398
+ children: /* @__PURE__ */ U(Qr, {
2399
+ item: {
2400
+ src: e,
2401
+ poster: t,
2402
+ mimeType: n
2403
+ },
2404
+ index: 0
2405
+ })
2406
+ }),
2407
+ o ? /* @__PURE__ */ U("div", {
2408
+ className: "absolute right-2 top-2 z-10",
2409
+ children: /* @__PURE__ */ U(tr, { onClick: o })
2410
+ }) : null,
2411
+ /* @__PURE__ */ U(Xr, {
2412
+ open: s,
2413
+ items: ti([{
2414
+ src: e,
2415
+ poster: t,
2416
+ mimeType: n,
2417
+ preload: i
2418
+ }], r),
2419
+ initialIndex: c,
2420
+ onClose: u
2421
+ })
2422
+ ]
2423
+ });
2424
+ }, ri = ({ state: e, src: t, poster: n, mimeType: r, filename: i, items: a, text: o, groupPosition: s, preload: c, onClick: l }) => {
2425
+ let u = ei({
2426
+ src: t,
2427
+ poster: n,
2428
+ mimeType: r,
2429
+ preload: c,
2430
+ items: a
2431
+ }), d = nr(e), { viewerOpen: f, viewerIndex: p, handleActivate: m, closeViewer: h } = Fr(l);
2432
+ if (u.length === 0) return null;
2433
+ let g = u.map((e, t) => $r(e, t, u.length));
2434
+ return /* @__PURE__ */ W(er, {
2435
+ variant: d,
2436
+ text: o,
2437
+ groupPosition: s,
2438
+ "data-testid": "video-attachment",
2439
+ children: [/* @__PURE__ */ U("div", {
2440
+ className: "relative",
2441
+ children: /* @__PURE__ */ U(Pr, {
2442
+ tiles: g,
2443
+ onTileActivate: m
2444
+ })
2445
+ }), /* @__PURE__ */ U(Xr, {
2446
+ open: f,
2447
+ items: ti(u, i),
2448
+ initialIndex: p,
2449
+ onClose: h
2450
+ })]
2451
+ });
2452
+ }, ii = {
2453
+ Image: Ur,
2454
+ Video: {
2455
+ Composer: (e) => /* @__PURE__ */ U(ni, { ...e }),
2456
+ Sent: (e) => /* @__PURE__ */ U(ri, {
2457
+ ...e,
2458
+ state: "sent"
2459
+ }),
2460
+ Received: (e) => /* @__PURE__ */ U(ri, {
2461
+ ...e,
2462
+ state: "received"
2463
+ })
2464
+ },
2465
+ Audio: sr,
2466
+ Pdf: Yr,
2467
+ File: br
2468
+ };
2469
+ //#endregion
2470
+ //#region src/components/CustomMessage/StreamAttachmentMessage.tsx
2471
+ function $(e) {
2472
+ return e?.trim() || void 0;
2473
+ }
2474
+ function ai(e) {
2475
+ return e.trim().replace(/^https?:\/\//i, "").replace(/\/+$/, "").toLowerCase();
2476
+ }
2477
+ function oi(e, t) {
2478
+ if (!e?.trim() || !t?.trim()) return !1;
2479
+ let n = ai(e), r = ai(t);
2480
+ if (n === r) return !0;
2481
+ if (!n.includes(r)) return !1;
2482
+ let i = n.split(r).join("");
2483
+ return !/[^\p{P}\p{Z}\p{C}]/u.test(i);
2484
+ }
2485
+ function si(e) {
2486
+ let t = $(e.og_scrape_url) ?? $(e.title_link), n = $(e.image_url) ?? $(e.thumb_url), i = $(e.asset_url), a = $(e.mime_type);
2487
+ return {
2488
+ title: $(e.title),
2489
+ description: $(e.text),
2490
+ url: t,
2491
+ thumbnailUrl: r(n),
2492
+ sourceUrl: i,
2493
+ layout: n || Fn(a, i) ? "featured" : "classic",
2494
+ mimeType: a,
2495
+ accentColor: $(e.accent_color),
2496
+ status: "ready"
2497
+ };
2498
+ }
2499
+ function ci(e) {
2500
+ return jt(e) ? null : e.type === "image" ? e.image_url || e.asset_url ? "image" : null : e.type === "video" && e.asset_url ? "video" : e.type === "audio" && e.asset_url ? "audio" : e.type === "file" && e.asset_url ? e.mime_type === "application/pdf" ? "pdf" : e.mime_type?.startsWith("audio/") ? "audio" : "file" : null;
2501
+ }
2502
+ function li(e) {
2503
+ if (!e?.length) return [];
2504
+ let t = [], n = (e, n) => {
2505
+ let r = t[t.length - 1];
2506
+ if (r?.type === "media" && r.kind === e) {
2507
+ r.attachments.push(n);
2508
+ return;
2509
+ }
2510
+ t.push({
2511
+ type: "media",
2512
+ kind: e,
2513
+ attachments: [n]
2514
+ });
2515
+ }, r = (e) => {
2516
+ let n = t[t.length - 1];
2517
+ if (n?.type === "link") {
2518
+ n.attachments.push(e);
2519
+ return;
2520
+ }
2521
+ t.push({
2522
+ type: "link",
2523
+ attachments: [e]
2524
+ });
2525
+ };
2526
+ for (let t of e) {
2527
+ if (jt(t)) {
2528
+ r(t);
2529
+ continue;
2530
+ }
2531
+ let e = ci(t);
2532
+ e && n(e, t);
2533
+ }
2534
+ return t;
2535
+ }
2536
+ function ui(e) {
2537
+ return e.filter((e) => e.type === "media").length;
2538
+ }
2539
+ function di(e, t, n) {
2540
+ return t <= 1 ? n : e === 0 ? "first" : e === t - 1 ? "end" : "middle";
2541
+ }
2542
+ function fi(e) {
2543
+ return $(e.image_url) ?? $(e.asset_url) ?? "";
2544
+ }
2545
+ function pi(e) {
2546
+ switch (e) {
2547
+ case "image": return ii.Image;
2548
+ case "video": return ii.Video;
2549
+ case "audio": return ii.Audio;
2550
+ case "pdf": return ii.Pdf;
2551
+ default: return ii.File;
2552
+ }
2553
+ }
2554
+ function mi(e, t) {
2555
+ switch (e) {
2556
+ case "image": return {
2557
+ src: fi(t),
2558
+ alt: $(t.title)
2559
+ };
2560
+ case "video": return {
2561
+ src: $(t.asset_url) ?? "",
2562
+ poster: $(t.thumb_url),
2563
+ mimeType: $(t.mime_type)
2564
+ };
2565
+ case "audio": return {
2566
+ src: $(t.asset_url) ?? "",
2567
+ mimeType: $(t.mime_type) ?? "audio/mpeg",
2568
+ filename: $(t.title)
2569
+ };
2570
+ case "pdf": return {
2571
+ src: $(t.asset_url) ?? "",
2572
+ filename: $(t.title),
2573
+ fileSize: t.file_size
2574
+ };
2575
+ case "file": return {
2576
+ src: $(t.asset_url) ?? "",
2577
+ filename: $(t.title),
2578
+ fileSize: t.file_size,
2579
+ mimeType: $(t.mime_type) ?? "application/octet-stream"
2580
+ };
2581
+ }
2582
+ }
2583
+ function hi(e, t) {
2584
+ if (t.length > 1) return { items: t.map((t) => mi(e, t)) };
2585
+ let n = t[0];
2586
+ return n ? mi(e, n) : {};
2587
+ }
2588
+ function gi({ groupPosition: e, isMyMessage: t, segment: n }) {
2589
+ let r = pi(n.kind), i = {
2590
+ ...hi(n.kind, n.attachments),
2591
+ groupPosition: e
2592
+ };
2593
+ return U(t ? r.Sent : r.Received, { ...i });
2594
+ }
2595
+ var _i = ({ groupPosition: e, isMyMessage: t, message: n, renderText: r }) => {
2596
+ let i = li(n.attachments);
2597
+ if (i.length === 0) return null;
2598
+ let a = ui(i), o = n.text?.trim(), s = i.find((e) => e.type === "link"), c = s?.type === "link" ? si(s.attachments[0] ?? {}).url : void 0, l = o && oi(o, c) ? void 0 : o, u = 0, d = [], f = l ? "middle" : e, p = e === "single" || e === "end", m = (e, n, r) => {
2599
+ let i = t ? Jn.Sent : Jn.Received;
2600
+ d.push(/* @__PURE__ */ U(i, {
2601
+ ...si(e),
2602
+ groupPosition: r ? f : "middle"
2603
+ }, n));
2604
+ }, h = (n, r) => {
2605
+ let i = di(u, a, e);
2606
+ u += 1, d.push(/* @__PURE__ */ U(gi, {
2607
+ groupPosition: i,
2608
+ isMyMessage: t,
2609
+ segment: n
2610
+ }, r));
2611
+ };
2612
+ return i.forEach((e, t) => {
2613
+ let n = t === i.length - 1;
2614
+ if (e.type === "link") {
2615
+ e.attachments.forEach((r, i) => {
2616
+ m(r, `link-${t}-${i}`, n && i === e.attachments.length - 1);
2617
+ });
2618
+ return;
2619
+ }
2620
+ h(e, `media-${t}`);
2621
+ }), /* @__PURE__ */ W("div", {
2622
+ className: "str-chat__message-bubble-wrapper",
2623
+ children: [/* @__PURE__ */ W("div", {
2624
+ className: "str-chat__message-bubble",
2625
+ "data-attachment-bubble": "true",
2626
+ style: {
2627
+ background: "transparent",
2628
+ borderRadius: 0,
2629
+ overflow: "visible",
2630
+ padding: 0
2631
+ },
2632
+ children: [d, !l && /* @__PURE__ */ U(M, {})]
2633
+ }), l ? /* @__PURE__ */ W("div", {
2634
+ className: q("str-chat__message-bubble", { "relative isolate": p }),
2635
+ children: [
2636
+ /* @__PURE__ */ U(R, {
2637
+ message: n,
2638
+ renderText: r
2639
+ }),
2640
+ /* @__PURE__ */ U(M, {}),
2641
+ p && /* @__PURE__ */ U(rn, { side: t ? "me" : "other" })
2642
+ ]
2643
+ }) : null]
2644
+ });
2645
+ }, vi = o.memo((e) => {
2646
+ let { additionalMessageInputProps: t, editing: n, endOfGroup: r, firstOfGroup: i, groupStyles: a, groupedByUser: o, handleAction: s, handleOpenThread: c, handleRetry: l, highlighted: u, isMessageAIGenerated: d, isMyMessage: f, message: m, renderText: g, threadList: _, viewerLanguage: v, onOutboundClick: y, resolvedOutbound: x } = e, { client: S } = me("CustomMessage"), { channel: C } = pe("CustomMessage"), { isUnlocking: w, onUnlockClick: T, onFetchSource: D, onDownloadClick: N } = Ht("LockedAttachment"), [F, L] = h(!1), z = ye(m.id), { Attachment: te = b, EditMessageModal: ie = E, MessageActions: B, MessageBlocked: ae = O, MessageBouncePrompt: oe = A, MessageDeleted: fe = j, MessageIsThreadReplyInChannelButtonIndicator: ge = P, MessageRepliesCountButton: _e = I, ReminderNotification: V = ne, StreamedMessageText: ve = re, PinIndicator: be } = he("CustomMessage"), xe = ue(m), G = de(m), Se = p(() => d?.(m), [d, m]), K = p(() => {
2647
+ let e = m.attachments ?? [], t = m.shared_location ? [m.shared_location, ...e] : e;
2648
+ if (!Yt(m)) return t;
2649
+ let n = t.filter((e) => !("type" in e) || !jt(e));
2650
+ return n.length === t.length ? t : n;
2651
+ }, [m]), Ce = p(() => li(K), [K]), we = p(() => {
2652
+ let e = St({
2653
+ message: m,
2654
+ viewerLanguage: v
2655
+ });
2656
+ return e === m.text ? m : {
2657
+ ...m,
2658
+ text: e
2659
+ };
2660
+ }, [m, v]), Te = Ce.length > 0, Ee = Ce.reduce((e, t) => e + t.attachments.length, 0) === (K?.length ?? 0), De = a?.[0] ?? "", Oe = De === "top" ? "first" : De === "middle" ? "middle" : De === "bottom" ? "end" : "single", ke = De === "single" || De === "bottom";
2661
+ if (se(m)) return null;
2662
+ if (m.deleted_at || m.type === "deleted") return /* @__PURE__ */ U(fe, { message: m });
2663
+ if (ce(m)) return /* @__PURE__ */ U(ae, {});
2664
+ let Ae = !_ && !!m.reply_count, je = !_ && m.show_in_channel && m.parent_id, J = m.status === "failed" && m.error?.status !== 403, Me = le(m), Y;
2665
+ J ? Y = () => l(m) : Me && (Y = () => L(!0));
2666
+ let X = f(), Ne = q("str-chat__message str-chat__message-simple", `str-chat__message--${m.type}`, `str-chat__message--${m.status}`, X ? "str-chat__message--me str-chat__message-simple--me" : "str-chat__message--other", m.text ? "str-chat__message--has-text" : "has-no-text", {
2667
+ "str-chat__message--has-attachment": xe,
2668
+ "str-chat__message--highlighted": u,
2669
+ "str-chat__message--pinned pinned-message": m.pinned,
2670
+ "str-chat__message--with-reactions": G,
2671
+ "str-chat__message-send-can-be-retried": m?.status === "failed" && m?.error?.status !== 403,
2672
+ "str-chat__message-with-thread-link": Ae || je,
2673
+ "str-chat__virtual-message__wrapper--end": r,
2674
+ "str-chat__virtual-message__wrapper--first": i,
2675
+ "str-chat__virtual-message__wrapper--group": o
2676
+ }), Pe = m.poll_id && S.polls.fromState(m.poll_id), Fe = un(m), Ie = Yt(m), Le = Xt(m), Re = !!(K?.length && !m.quoted_message), ze = Ie && X && Re, Be = Te && Ee && !m.quoted_message && !Pe && !Se && !Ie, Ve = {
2677
+ contentType: "text",
2678
+ amountText: m.metadata?.amount_text,
2679
+ paymentStatus: m.metadata?.payment_status,
2680
+ renderedText: m.text && /* @__PURE__ */ U(R, {
2681
+ message: we,
2682
+ renderText: g
2683
+ })
2684
+ }, He = {
2685
+ contentType: "media",
2686
+ title: m.metadata?.attachment_title,
2687
+ mimeType: m.metadata?.attachment_mime_type,
2688
+ thumbnailUrl: m.metadata?.attachment_thumbnail,
2689
+ amountText: m.metadata?.amount_text,
2690
+ detail: m.metadata?.attachment_detail,
2691
+ paymentStatus: m.metadata?.payment_status,
2692
+ onFetchSource: D ? () => D(m, C) : void 0
2693
+ }, Ue = /* @__PURE__ */ W("div", {
2694
+ className: q("str-chat__message-bubble", { "relative isolate": ke }),
2695
+ children: [/* @__PURE__ */ U(R, {
2696
+ message: we,
2697
+ renderText: g
2698
+ }), ke && /* @__PURE__ */ U(rn, { side: X ? "me" : "other" })]
2699
+ });
2700
+ return /* @__PURE__ */ W(H, { children: [
2701
+ n && /* @__PURE__ */ U(ie, { additionalMessageInputProps: t }),
2702
+ F && /* @__PURE__ */ U(k, {
2703
+ MessageBouncePrompt: oe,
2704
+ onClose: () => L(!1),
2705
+ open: F
2706
+ }),
2707
+ /* @__PURE__ */ W("div", {
2708
+ className: Ne,
2709
+ "data-message-id": m.id,
2710
+ "data-dd-privacy": "mask",
2711
+ children: [
2712
+ be && /* @__PURE__ */ U(be, {}),
2713
+ !!z && /* @__PURE__ */ U(V, { reminder: z }),
2714
+ m.user && /* @__PURE__ */ U(Z, {
2715
+ className: "str-chat__avatar str-chat__message-sender-avatar",
2716
+ id: m.user.id,
2717
+ image: m.user.image,
2718
+ name: m.user.name || m.user.id,
2719
+ size: 24,
2720
+ shape: "circle",
2721
+ dmAgentEnabled: Ie
2722
+ }),
2723
+ /* @__PURE__ */ U("div", {
2724
+ className: q("str-chat__message-inner", { "str-chat__simple-message--error-failed": J || Me }),
2725
+ "data-testid": "message-inner",
2726
+ onClick: Y,
2727
+ onKeyDown: Y,
2728
+ role: Y ? "button" : void 0,
2729
+ tabIndex: Y ? 0 : void 0,
2730
+ style: {
2731
+ marginInlineEnd: 0,
2732
+ marginInlineStart: 0
2733
+ },
2734
+ children: Fe ? /* @__PURE__ */ W("div", {
2735
+ className: "str-chat__message-bubble-wrapper message-tip-wrapper",
2736
+ children: [/* @__PURE__ */ U(dn, { message: m }), m.text?.trim() && Ue]
2737
+ }) : Zt(m) ? /* @__PURE__ */ U("div", {
2738
+ className: "str-chat__message-bubble-wrapper",
2739
+ children: /* @__PURE__ */ W("div", {
2740
+ className: "flex items-center gap-2",
2741
+ children: [
2742
+ X && B && /* @__PURE__ */ U(B, {}),
2743
+ X ? /* @__PURE__ */ U(Kt, {
2744
+ ...Ve,
2745
+ isMine: !0
2746
+ }) : /* @__PURE__ */ U(Kt, {
2747
+ ...Ve,
2748
+ isMine: !1,
2749
+ isUnlocking: w(m.id),
2750
+ onUnlockClick: () => T?.(m, C)
2751
+ }),
2752
+ !X && B && /* @__PURE__ */ U(B, {})
2753
+ ]
2754
+ })
2755
+ }) : Qt(m) ? /* @__PURE__ */ W("div", {
2756
+ className: "str-chat__message-bubble-wrapper message-locked-attachment-wrapper",
2757
+ children: [/* @__PURE__ */ W("div", {
2758
+ className: "flex items-center gap-2",
2759
+ children: [
2760
+ X && B && /* @__PURE__ */ U(B, {}),
2761
+ X ? /* @__PURE__ */ U(Kt, {
2762
+ ...He,
2763
+ isMine: !0,
2764
+ onPreviewClick: () => T ? T(m, C) : void 0
2765
+ }) : /* @__PURE__ */ U(Kt, {
2766
+ ...He,
2767
+ isMine: !1,
2768
+ isUnlocking: w(m.id),
2769
+ onUnlockClick: () => T ? T(m, C) : void 0,
2770
+ onDownloadClick: () => N ? N(m, C) : void 0
2771
+ }),
2772
+ !X && B && /* @__PURE__ */ U(B, {})
2773
+ ]
2774
+ }), m.text && Ue]
2775
+ }) : Be ? /* @__PURE__ */ U(_i, {
2776
+ groupPosition: Oe,
2777
+ isMyMessage: X,
2778
+ message: {
2779
+ ...we,
2780
+ attachments: K,
2781
+ i18n: void 0
2782
+ },
2783
+ renderText: g
2784
+ }) : /* @__PURE__ */ U("div", {
2785
+ className: "str-chat__message-bubble-wrapper",
2786
+ children: /* @__PURE__ */ W("div", {
2787
+ className: q("str-chat__message-bubble", { "relative isolate": ke }),
2788
+ children: [
2789
+ Ie && !ze && /* @__PURE__ */ U(en, {
2790
+ message: m,
2791
+ hasAttachment: Re,
2792
+ isMyMessage: X
2793
+ }),
2794
+ Pe && /* @__PURE__ */ U(ee, { poll: Pe }),
2795
+ K?.length && !m.quoted_message ? /* @__PURE__ */ U(te, {
2796
+ actionHandler: s,
2797
+ attachments: K
2798
+ }) : null,
2799
+ U(Se ? ve : R, {
2800
+ message: we,
2801
+ renderText: g
2802
+ }),
2803
+ /* @__PURE__ */ U(M, {}),
2804
+ ke && /* @__PURE__ */ U(rn, { side: X ? "me" : "other" })
2805
+ ]
2806
+ })
2807
+ })
2808
+ }),
2809
+ !Le && !Fe && /* @__PURE__ */ U("div", {
2810
+ className: "str-chat__message-footer",
2811
+ children: (!Ie || ze) && /* @__PURE__ */ U(en, {
2812
+ message: m,
2813
+ hasAttachment: Re,
2814
+ isMyMessage: X
2815
+ })
2816
+ }),
2817
+ /* @__PURE__ */ U(_n, {
2818
+ onOutboundClick: y,
2819
+ resolvedOutbound: x
2820
+ }),
2821
+ Ae && /* @__PURE__ */ U(_e, {
2822
+ onClick: c,
2823
+ reply_count: m.reply_count
2824
+ }),
2825
+ je && /* @__PURE__ */ U(ge, {})
2826
+ ]
2827
+ }, m.id)
2828
+ ] });
2829
+ }, (e, t) => e.viewerLanguage !== t.viewerLanguage || e.onOutboundClick !== t.onOutboundClick || e.resolvedOutbound?.id !== t.resolvedOutbound?.id || e.resolvedOutbound?.name !== t.resolvedOutbound?.name ? !1 : oe(e, t)), yi = (e) => {
2830
+ let t = V("CustomMessage"), n = u(an), r = t.message.metadata?.outbound_id, i = typeof r == "string" ? n?.[r] : void 0;
2831
+ return /* @__PURE__ */ U(vi, {
2832
+ ...t,
2833
+ ...e,
2834
+ resolvedOutbound: i
2835
+ });
2836
+ }, bi = () => {
2837
+ let { handleDelete: e, message: t } = V("CustomMessageActions");
2838
+ return t.metadata?.payment_status === "paid" ? null : /* @__PURE__ */ U(Ye, {
2839
+ onClick: e,
2840
+ "aria-label": "Delete",
2841
+ title: "Delete",
2842
+ className: "bg-marble rounded-full p-2 hover:bg-sand transition-all",
2843
+ children: /* @__PURE__ */ U(Ge, {
2844
+ size: 16,
2845
+ weight: "light",
2846
+ "aria-hidden": !0
2847
+ })
2848
+ });
2849
+ }, xi = () => {
2850
+ let { handleFlag: e } = V("CustomMessageActions");
2851
+ return /* @__PURE__ */ U(Ye, {
2852
+ onClick: e,
2853
+ "aria-label": "Report",
2854
+ title: "Report",
2855
+ className: "bg-marble rounded-full p-2 hover:bg-sand transition-all",
2856
+ children: /* @__PURE__ */ U(Ne, {
2857
+ size: 16,
2858
+ weight: "light",
2859
+ "aria-hidden": !0
2860
+ })
2861
+ });
2862
+ }, Si = () => {
2863
+ let { message: e } = V("CustomMessageActions");
2864
+ return e.metadata?.custom_type === G.ATTACHMENT ? /* @__PURE__ */ U(Xe, { messageActionSet: [{
2865
+ Component: bi,
2866
+ placement: "quick",
2867
+ type: "delete"
2868
+ }, {
2869
+ Component: xi,
2870
+ placement: "quick",
2871
+ type: "flag"
2872
+ }] }) : null;
2873
+ }, Ci = (e) => ({ linkPreviews: Array.from(e.previews.values()).filter((e) => _.previewIsLoaded(e) || _.previewIsLoading(e)) }), wi = () => {
2874
+ let { linkPreviewsManager: e } = ge(), { linkPreviews: t } = be(e.state, Ci), n = (t) => {
2875
+ e.dismissPreview(t);
2876
+ };
2877
+ return t.length > 0 ? /* @__PURE__ */ U("div", {
2878
+ className: "messaging-link-preview-list flex flex-col items-stretch w-full gap-2",
2879
+ children: t.map((e) => {
2880
+ let t = _.previewIsLoading(e);
2881
+ return /* @__PURE__ */ U(Jn.Composer, {
2882
+ title: e.title,
2883
+ url: e.og_scrape_url,
2884
+ thumbnailUrl: e.image_url,
2885
+ layout: t || e.image_url ? "featured" : "classic",
2886
+ status: t ? "loading" : "ready",
2887
+ onDismiss: () => n(e.og_scrape_url)
2888
+ }, e.og_scrape_url);
2889
+ })
2890
+ }) : null;
2891
+ }, Ti = o.createContext(!1), Ei = 200, Di = () => u(Ti), Oi = ({ sendMessage: e, disabled: t, ...n }) => /* @__PURE__ */ U("button", {
2892
+ ...n,
2893
+ type: "button",
2894
+ "aria-label": "Send",
2895
+ disabled: t,
2896
+ onPointerDown: (e) => e.preventDefault(),
2897
+ onClick: e,
2898
+ children: /* @__PURE__ */ U(Oe, {
2899
+ weight: "bold",
2900
+ className: "size-4"
2901
+ })
2902
+ }), ki = () => {
2903
+ let e = u(Ti), { handleSubmit: t } = ve(), n = _e(), r = e || !n, { SendButton: i = Oi, AttachmentPreviewList: a = x } = he("CustomMessageInput"), s = o.useRef(null);
2904
+ return o.useEffect(() => {
2905
+ let e = s.current;
2906
+ if (!e || typeof ResizeObserver > "u") return;
2907
+ let t = new ResizeObserver(() => {
2908
+ e.contains(document.activeElement) && (e.scrollTop = e.scrollHeight);
2909
+ });
2910
+ return t.observe(e), () => t.disconnect();
2911
+ }, []), o.useEffect(() => {
2912
+ let e = s.current;
2913
+ if (!e) return;
2914
+ let t = (e) => {
2915
+ Array.from(e.clipboardData?.items ?? []).some((e) => e.kind === "file") || e.stopPropagation();
2916
+ };
2917
+ return e.addEventListener("paste", t), () => e.removeEventListener("paste", t);
2918
+ }, []), /* @__PURE__ */ W("div", {
2919
+ ref: s,
2920
+ className: "central-container flex flex-col min-w-0 w-full max-h-[calc(var(--messaging-surface-height,100dvh)*0.5)] overflow-y-auto overscroll-contain 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)] [&>:not(.messaging-composer-previews):not(.messaging-composer-row)]:p-2",
2921
+ "data-dd-privacy": "mask",
2922
+ children: [/* @__PURE__ */ W("div", {
2923
+ className: "messaging-composer-previews empty:hidden flex flex-col gap-2 px-2 pt-2",
2924
+ children: [
2925
+ /* @__PURE__ */ U(te, {}),
2926
+ /* @__PURE__ */ U(wi, {}),
2927
+ /* @__PURE__ */ U(a, {})
2928
+ ]
2929
+ }), /* @__PURE__ */ W("div", {
2930
+ className: "messaging-composer-row flex items-start",
2931
+ children: [/* @__PURE__ */ U(ie, {
2932
+ "aria-disabled": e || void 0,
2933
+ containerClassName: "min-w-0 flex-1 leading-[0]",
2934
+ className: "w-full resize-none overflow-hidden bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm",
2935
+ autoFocus: !e,
2936
+ enterKeyHint: "send",
2937
+ maxRows: Infinity,
2938
+ readOnly: e,
2939
+ tabIndex: e ? -1 : void 0
2940
+ }), /* @__PURE__ */ U("div", {
2941
+ className: "sticky bottom-2 mt-auto mb-2 mr-2 shrink-0 pt-2",
2942
+ children: /* @__PURE__ */ U(i, {
2943
+ sendMessage: t,
2944
+ "aria-label": "Send",
2945
+ className: "str-chat__send-button relative flex justify-center items-center rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring before:absolute before:-inset-2 before:content-['']",
2946
+ "data-testid": "send-button",
2947
+ disabled: r,
2948
+ type: "button"
2949
+ })
2950
+ })]
2951
+ })]
2952
+ });
2953
+ }, Ai = () => /* @__PURE__ */ W("div", {
2954
+ className: "messaging-composer-backdrop",
2955
+ "aria-hidden": "true",
2956
+ children: [
2957
+ /* @__PURE__ */ U("div", { className: "messaging-composer-backdrop-blur" }),
2958
+ /* @__PURE__ */ U("div", { className: "messaging-composer-backdrop-blur" }),
2959
+ /* @__PURE__ */ U("div", { className: "messaging-composer-backdrop-blur" }),
2960
+ /* @__PURE__ */ U("div", { className: "messaging-composer-backdrop-blur" }),
2961
+ /* @__PURE__ */ U("div", { className: "messaging-composer-backdrop-blur" }),
2962
+ /* @__PURE__ */ U("div", { className: "messaging-composer-backdrop-gradient" })
2963
+ ]
2964
+ }), ji = ({ renderActions: e, renderHeader: t, renderFooter: n, disabled: r = !1, disabledReason: i, composerInput: a }) => {
2965
+ let { channel: s } = pe(), c = s?.data?.frozen === !0, l = !!a, u = o.useRef(null);
2966
+ return o.useEffect(() => {
2967
+ if (!l) return;
2968
+ let e = u.current, t = e?.parentElement;
2969
+ if (!e || !t) return;
2970
+ let n = e.offsetHeight, r = () => {
2971
+ let r = e.offsetHeight, i = r > n;
2972
+ n = r;
2973
+ let a = Array.from(t.querySelectorAll(".str-chat__list")).find((e) => e.scrollHeight > e.clientHeight) ?? null, o = a ? a.scrollHeight - a.scrollTop - a.clientHeight < Ei : !1;
2974
+ t.style.setProperty("--messaging-composer-height", `${r}px`), i && o && a && (a.scrollTop = a.scrollHeight);
2975
+ };
2976
+ if (r(), typeof ResizeObserver > "u") return;
2977
+ let i = new ResizeObserver(r);
2978
+ return i.observe(e), () => {
2979
+ i.disconnect(), t.style.removeProperty("--messaging-composer-height");
2980
+ };
2981
+ }, [l]), r ? l ? /* @__PURE__ */ W("div", {
2982
+ ref: u,
2983
+ className: "messaging-composer-chrome messaging-composer-chrome--floating",
2984
+ children: [/* @__PURE__ */ U(Ai, {}), /* @__PURE__ */ W("div", {
2985
+ className: "relative z-10 flex flex-col",
2986
+ children: [
2987
+ t?.(),
2988
+ /* @__PURE__ */ U("div", {
2989
+ className: "messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",
2990
+ children: i ? /* @__PURE__ */ U("p", {
2991
+ className: "max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",
2992
+ children: i
2993
+ }) : null
2994
+ }),
2995
+ n?.()
2996
+ ]
2997
+ })]
2998
+ }) : /* @__PURE__ */ W(H, { children: [
2999
+ t?.(),
3000
+ /* @__PURE__ */ U("div", {
3001
+ className: "messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",
3002
+ children: i ? /* @__PURE__ */ U("p", {
3003
+ className: "max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",
3004
+ children: i
3005
+ }) : null
3006
+ }),
3007
+ n?.()
3008
+ ] }) : l ? /* @__PURE__ */ W("div", {
3009
+ ref: u,
3010
+ className: "messaging-composer-chrome messaging-composer-chrome--floating",
3011
+ children: [/* @__PURE__ */ U(Ai, {}), /* @__PURE__ */ W("div", {
3012
+ className: "relative z-10 flex min-h-0 flex-col",
3013
+ children: [t?.(), /* @__PURE__ */ W("div", {
3014
+ className: "flex min-h-0 flex-col gap-4 p-3 pb-5 md:p-5",
3015
+ children: [/* @__PURE__ */ W("div", {
3016
+ inert: c ? "" : void 0,
3017
+ "aria-disabled": c || void 0,
3018
+ className: "message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",
3019
+ children: [e && /* @__PURE__ */ U("div", {
3020
+ className: "flex h-12 shrink-0 items-center justify-center",
3021
+ children: e()
3022
+ }), /* @__PURE__ */ U(Ti.Provider, {
3023
+ value: c,
3024
+ children: /* @__PURE__ */ U(N, { Input: a ?? ki })
3025
+ })]
3026
+ }), n?.()]
3027
+ })]
3028
+ })]
3029
+ }) : /* @__PURE__ */ W("div", {
3030
+ className: "flex min-h-0 flex-col gap-4 p-4",
3031
+ children: [
3032
+ t?.(),
3033
+ /* @__PURE__ */ W("div", {
3034
+ inert: c ? "" : void 0,
3035
+ "aria-disabled": c || void 0,
3036
+ className: "message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",
3037
+ children: [e && /* @__PURE__ */ U("div", {
3038
+ className: "flex h-12 shrink-0 items-center justify-center",
3039
+ children: e()
3040
+ }), /* @__PURE__ */ U(Ti.Provider, {
3041
+ value: c,
3042
+ children: /* @__PURE__ */ U(N, { Input: ki })
3043
+ })]
3044
+ }),
3045
+ n?.()
3046
+ ]
3047
+ });
3048
+ }, Mi = {
3049
+ SYSTEM_DM_AGENT_PAUSED: "DM Agent has left the conversation",
3050
+ SYSTEM_DM_AGENT_RESUMED: "DM Agent has rejoined the conversation"
3051
+ }, Ni = ["SYSTEM_AGE_SAFETY_BLOCKED"], Pi = { SYSTEM_AGE_SAFETY_BLOCKED: "This user isn’t able to reply because they don’t meet our age safety guidelines." }, Fi = "age safety guidelines.", Ii = "https://linktr.ee/s/about/contact", Li = (e) => Ni.includes(e), Ri = (e) => Li(e.metadata?.custom_type), zi = (e) => {
3052
+ let t = e.metadata?.custom_type;
3053
+ if (Ce(t)) return {
3054
+ kind: "dm-agent",
3055
+ type: t
3056
+ };
3057
+ if (K(t)) return {
3058
+ kind: "age-safety",
3059
+ type: t
3060
+ };
3061
+ let n = e.dm_agent_system_type;
3062
+ if (Ce(n)) return {
3063
+ kind: "dm-agent",
3064
+ type: n
3065
+ };
3066
+ }, Bi = (e) => {
3067
+ let t = e.indexOf(Fi);
3068
+ if (t === -1) return e;
3069
+ let n = t + 22;
3070
+ return /* @__PURE__ */ W(H, { children: [
3071
+ e.slice(0, t),
3072
+ /* @__PURE__ */ U("a", {
3073
+ href: Ii,
3074
+ target: "_blank",
3075
+ rel: "noopener noreferrer",
3076
+ className: "mes-age-safety-system-message__emphasis font-medium text-inherit underline",
3077
+ children: Fi
3078
+ }),
3079
+ e.slice(n)
3080
+ ] });
3081
+ }, Vi = (e) => {
3082
+ let t = !Ri(e.message), n = zi(e.message);
3083
+ if (n?.kind === "dm-agent") {
3084
+ let r = e.message.text?.trim() || Mi[n.type];
3085
+ return /* @__PURE__ */ W("div", {
3086
+ className: "str-chat__message--system",
3087
+ "data-testid": "message-system",
3088
+ children: [/* @__PURE__ */ W("div", {
3089
+ 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)]",
3090
+ "data-testid": "dm-agent-system-message",
3091
+ "data-dm-agent-system-type": n.type,
3092
+ children: [/* @__PURE__ */ U(He, {
3093
+ size: 16,
3094
+ weight: "regular",
3095
+ "aria-hidden": !0,
3096
+ className: "mes-dm-agent-system-message__sparkle shrink-0"
3097
+ }), /* @__PURE__ */ U("p", {
3098
+ className: "mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",
3099
+ children: r
3100
+ })]
3101
+ }), !t && /* @__PURE__ */ U(z, { message: e.message })]
3102
+ });
3103
+ }
3104
+ if (n?.kind === "age-safety") {
3105
+ let r = e.message.text?.trim() || Pi[n.type];
3106
+ return /* @__PURE__ */ W("div", {
3107
+ className: "str-chat__message--system",
3108
+ "data-testid": "message-system",
3109
+ children: [/* @__PURE__ */ W("div", {
3110
+ 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)]",
3111
+ "data-testid": "age-safety-system-message",
3112
+ "data-age-safety-system-type": n.type,
3113
+ children: [/* @__PURE__ */ U(ze, {
3114
+ size: 24,
3115
+ weight: "duotone",
3116
+ "aria-hidden": !0,
3117
+ className: "mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]",
3118
+ "data-testid": "age-safety-system-message-icon"
3119
+ }), /* @__PURE__ */ U("div", {
3120
+ className: "mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",
3121
+ children: /* @__PURE__ */ U("p", {
3122
+ className: "m-0 text-balance text-left text-[12px] font-normal leading-4 tracking-[0.21px] text-[color:var(--text-warning-on-warning,#894b00)]",
3123
+ children: Bi(r)
3124
+ })
3125
+ })]
3126
+ }), !t && /* @__PURE__ */ U(z, { message: e.message })]
3127
+ });
3128
+ }
3129
+ return /* @__PURE__ */ W("div", {
3130
+ className: "str-chat__message--system",
3131
+ "data-testid": "message-system",
3132
+ children: [/* @__PURE__ */ W("div", {
3133
+ className: "str-chat__message--system__text",
3134
+ children: [
3135
+ /* @__PURE__ */ U("div", { className: "str-chat__message--system__line" }),
3136
+ /* @__PURE__ */ U("p", { children: e.message.text }),
3137
+ /* @__PURE__ */ U("div", { className: "str-chat__message--system__line" })
3138
+ ]
3139
+ }), !t && /* @__PURE__ */ U(z, { message: e.message })]
3140
+ });
3141
+ }, Hi = c(!1), Ui = ({ cx: e, index: t }) => /* @__PURE__ */ U("circle", {
3142
+ cx: e,
3143
+ cy: "6.15",
3144
+ r: "3.9",
3145
+ fill: "#A0A0A0",
3146
+ children: /* @__PURE__ */ U("animateTransform", {
3147
+ attributeName: "transform",
3148
+ type: "translate",
3149
+ values: "0 0; 0 -2.25; 0 0;",
3150
+ dur: "900ms",
3151
+ begin: `${120 * t}ms`,
3152
+ repeatCount: "indefinite"
3153
+ })
3154
+ }), Wi = /* @__PURE__ */ new Set([
3155
+ y.Thinking,
3156
+ y.Generating,
3157
+ y.ExternalSources
3158
+ ]), Gi = ({ threadList: e }) => {
3159
+ let { channel: t, channelConfig: n, thread: r } = pe(), { client: i } = me(), { typing: a = {} } = xe(), { aiState: o } = fe(t), s = u(Hi);
3160
+ if (!e && s && Wi.has(o)) {
3161
+ let e = qi(t, i.user?.id);
3162
+ return /* @__PURE__ */ U(Ki, {
3163
+ avatarId: e?.id ?? "ai-agent",
3164
+ avatarName: e?.name ?? e?.id ?? "Agent",
3165
+ avatarImage: e?.image,
3166
+ testId: "typing-indicator-ai"
3167
+ });
3168
+ }
3169
+ if (n?.typing_events === !1) return null;
3170
+ let c = e ? [] : Object.values(a).filter(({ parent_id: e, user: t }) => t?.id !== i.user?.id && !e), l = e ? Object.values(a).filter(({ parent_id: e, user: t }) => t?.id !== i.user?.id && e === r?.id) : [], d = e ? l : c;
3171
+ if (!d.length) return null;
3172
+ let f = d[0]?.user, p = f?.id && t.state.members[f.id] ? t.state.members[f.id].user : void 0;
3173
+ return /* @__PURE__ */ U(Ki, {
3174
+ avatarId: f?.id ?? p?.id ?? "typing-user",
3175
+ avatarName: f?.name ?? p?.name ?? f?.id ?? "Typing user",
3176
+ avatarImage: f?.image ?? p?.image,
3177
+ testId: "typing-indicator"
3178
+ });
3179
+ }, Ki = ({ avatarId: e, avatarName: t, avatarImage: n, testId: r }) => /* @__PURE__ */ U("div", {
3180
+ className: "str-chat__li str-chat__li--single str-chat__typing-indicator !static",
3181
+ "data-testid": r,
3182
+ style: { marginBottom: "var(--messaging-channel-input-spacer-height, 80px)" },
3183
+ children: /* @__PURE__ */ W("div", {
3184
+ className: "str-chat__message str-chat__message-simple str-chat__message--regular str-chat__message--received str-chat__message--other str-chat__message--has-text",
3185
+ children: [/* @__PURE__ */ U(Z, {
3186
+ className: "str-chat__avatar str-chat__message-sender-avatar",
3187
+ id: e,
3188
+ name: t,
3189
+ image: n ?? void 0,
3190
+ size: 24,
3191
+ shape: "circle"
3192
+ }), /* @__PURE__ */ U("div", {
3193
+ className: "str-chat__message-inner mx-0",
3194
+ children: /* @__PURE__ */ U("div", {
3195
+ className: "str-chat__message-bubble-wrapper",
3196
+ children: /* @__PURE__ */ W("div", {
3197
+ className: "str-chat__message-bubble relative isolate",
3198
+ children: [/* @__PURE__ */ U("div", {
3199
+ className: "str-chat__message-text min-h-11 flex items-center",
3200
+ children: /* @__PURE__ */ U("div", {
3201
+ className: "str-chat__message-text-inner str-chat__message-simple-text-inner",
3202
+ children: /* @__PURE__ */ W("svg", {
3203
+ "aria-hidden": "true",
3204
+ className: "block overflow-visible",
3205
+ viewBox: "0 0 32 12.3",
3206
+ width: "32",
3207
+ height: "13",
3208
+ overflow: "visible",
3209
+ children: [
3210
+ /* @__PURE__ */ U(Ui, {
3211
+ cx: "4",
3212
+ index: 0
3213
+ }),
3214
+ /* @__PURE__ */ U(Ui, {
3215
+ cx: "16",
3216
+ index: 1
3217
+ }),
3218
+ /* @__PURE__ */ U(Ui, {
3219
+ cx: "28",
3220
+ index: 2
3221
+ })
3222
+ ]
3223
+ })
3224
+ })
3225
+ }), /* @__PURE__ */ U(rn, { side: "other" })]
3226
+ })
3227
+ })
3228
+ })]
3229
+ })
3230
+ });
3231
+ function qi(e, t) {
3232
+ let n = e?.state?.members ?? {};
3233
+ for (let e of Object.values(n)) {
3234
+ let n = e?.user;
3235
+ if (n && n.id !== t) return n;
3236
+ }
3237
+ }
3238
+ //#endregion
3239
+ //#region src/components/MessagingShell/ChannelEmptyState.tsx
3240
+ var Ji = () => null, Yi = ({ className: e, message: t }) => /* @__PURE__ */ W("div", {
3241
+ className: q("flex items-center justify-center h-full", e),
3242
+ children: [/* @__PURE__ */ W("svg", {
3243
+ viewBox: "0 0 100 100",
3244
+ className: "size-8 fill-pebble",
3245
+ stroke: "none",
3246
+ children: [
3247
+ /* @__PURE__ */ U("circle", {
3248
+ cx: "6",
3249
+ cy: "50",
3250
+ r: "6",
3251
+ children: /* @__PURE__ */ U("animateTransform", {
3252
+ attributeName: "transform",
3253
+ dur: "1s",
3254
+ type: "translate",
3255
+ values: "0 15 ; 0 -15; 0 15",
3256
+ repeatCount: "indefinite",
3257
+ begin: "0.1"
3258
+ })
3259
+ }),
3260
+ /* @__PURE__ */ U("circle", {
3261
+ cx: "30",
3262
+ cy: "50",
3263
+ r: "6",
3264
+ children: /* @__PURE__ */ U("animateTransform", {
3265
+ attributeName: "transform",
3266
+ dur: "1s",
3267
+ type: "translate",
3268
+ values: "0 10 ; 0 -10; 0 10",
3269
+ repeatCount: "indefinite",
3270
+ begin: "0.2"
3271
+ })
3272
+ }),
3273
+ /* @__PURE__ */ U("circle", {
3274
+ cx: "54",
3275
+ cy: "50",
3276
+ r: "6",
3277
+ children: /* @__PURE__ */ U("animateTransform", {
3278
+ attributeName: "transform",
3279
+ dur: "1s",
3280
+ type: "translate",
3281
+ values: "0 5 ; 0 -5; 0 5",
3282
+ repeatCount: "indefinite",
3283
+ begin: "0.3"
3284
+ })
3285
+ })
3286
+ ]
3287
+ }), t && /* @__PURE__ */ U("span", {
3288
+ className: "text-stone",
3289
+ children: t
3290
+ })]
3291
+ }), Xi = o.memo(() => /* @__PURE__ */ U("div", {
3292
+ className: "messaging-loading-state flex items-center justify-center h-full",
3293
+ children: /* @__PURE__ */ W("div", {
3294
+ className: "flex items-center",
3295
+ children: [/* @__PURE__ */ U(Yi, { className: "w-6 h-6" }), /* @__PURE__ */ U("span", {
3296
+ className: "text-sm text-stone",
3297
+ children: "Loading messages"
3298
+ })]
3299
+ })
3300
+ }));
3301
+ Xi.displayName = "LoadingState";
3302
+ //#endregion
3303
+ //#region src/components/ChannelView.tsx
3304
+ var Zi = ({ onBack: e, showBackButton: t, renderMessageInputActions: n, renderMessageInputFooter: r, renderConversationFooter: i, onLeaveConversation: a, onBlockParticipant: s, showDeleteConversation: c = !0, onDeleteConversationClick: u, onBlockParticipantClick: f, onReportParticipantClick: p, showBlockParticipant: h = !0, showReportParticipant: g = !0, composerDisabled: _ = !1, composerDisabledReason: v, showStarButton: y = !1, renderChannelBanner: b, customChannelActions: x, renderChannelActions: S, renderMessage: C, viewerLanguage: w, showChannelInfo: T = !0, onParticipantNameClick: E, onOutboundClick: D, resolveOutbound: O, composerInput: k }) => {
3305
+ let { channel: A, messages: j } = pe(), M = m(D);
3306
+ d(() => {
3307
+ M.current = D;
3308
+ }, [D]);
3309
+ let N = l((e) => {
3310
+ M.current?.(e);
3311
+ }, []), P = D ? N : void 0, I = ln(j, O), L = A.state.messages.some((e) => e.type !== "deleted"), R = b ? /* @__PURE__ */ U(o.Fragment, { children: b() }, "lt-channel-banner") : null, z = /* @__PURE__ */ U(yt, {
3312
+ className: "-mx-[var(--str-chat\\_\\_spacing-2)] px-[var(--str-chat\\_\\_spacing-2)] md:-mx-[min(var(--str-chat\\_\\_spacing-10),4%)] md:px-[min(var(--str-chat\\_\\_spacing-10),4%)]",
3313
+ onBack: e,
3314
+ showBackButton: t,
3315
+ showChannelInfo: T,
3316
+ showStarButton: y,
3317
+ onLeaveConversation: a,
3318
+ onBlockParticipant: s,
3319
+ showDeleteConversation: c,
3320
+ showBlockParticipant: h,
3321
+ showReportParticipant: g,
3322
+ onDeleteConversationClick: u,
3323
+ onBlockParticipantClick: f,
3324
+ onReportParticipantClick: p,
3325
+ customChannelActions: x,
3326
+ renderChannelActions: S,
3327
+ onParticipantNameClick: E
3328
+ }), ee = l((e) => {
3329
+ let { message: t } = V("ChannelView"), n = /* @__PURE__ */ U(yi, {
3330
+ ...e,
3331
+ viewerLanguage: w,
3332
+ onOutboundClick: P
3333
+ });
3334
+ return !C || !t ? n : C(n, t);
3335
+ }, [
3336
+ P,
3337
+ C,
3338
+ w
3339
+ ]);
3340
+ return /* @__PURE__ */ U(an.Provider, {
3341
+ value: I,
3342
+ children: /* @__PURE__ */ U(ae, {
3343
+ overrides: {
3344
+ Message: ee,
3345
+ MessageActions: Si,
3346
+ UnreadMessagesNotification: () => null,
3347
+ UnreadMessagesSeparator: () => null
3348
+ },
3349
+ children: /* @__PURE__ */ U(B, { children: k ? /* @__PURE__ */ W("div", {
3350
+ className: "messaging-channel-layout relative flex min-h-0 flex-1 flex-col",
3351
+ children: [/* @__PURE__ */ W("div", {
3352
+ className: "messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden",
3353
+ children: [!L && /* @__PURE__ */ U("div", {
3354
+ className: "str-chat__list",
3355
+ children: /* @__PURE__ */ W("div", {
3356
+ className: "str-chat__message-list-scroll",
3357
+ children: [z, R]
3358
+ })
3359
+ }), /* @__PURE__ */ U(F, {
3360
+ head: L ? /* @__PURE__ */ W("div", {
3361
+ className: "sticky top-0 z-10",
3362
+ children: [z, R]
3363
+ }) : void 0,
3364
+ hideDeletedMessages: !0,
3365
+ hideNewMessageSeparator: !1
3366
+ })]
3367
+ }, "lt-channel-message-list"), /* @__PURE__ */ U(ji, {
3368
+ ...n && { renderActions: () => n?.(A) },
3369
+ ...i && { renderHeader: () => i(A) },
3370
+ renderFooter: () => r?.(A),
3371
+ disabled: _,
3372
+ disabledReason: v,
3373
+ composerInput: k
3374
+ }, "lt-channel-message-input")]
3375
+ }) : /* @__PURE__ */ W(H, { children: [
3376
+ /* @__PURE__ */ W("div", {
3377
+ className: "flex-1 overflow-hidden relative",
3378
+ children: [!L && /* @__PURE__ */ U("div", {
3379
+ className: "str-chat__list",
3380
+ children: /* @__PURE__ */ W("div", {
3381
+ className: "str-chat__message-list-scroll",
3382
+ children: [z, R]
3383
+ })
3384
+ }), /* @__PURE__ */ U(F, {
3385
+ head: L ? /* @__PURE__ */ W("div", {
3386
+ className: "sticky top-0 z-10",
3387
+ children: [z, R]
3388
+ }) : void 0,
3389
+ hideDeletedMessages: !0,
3390
+ hideNewMessageSeparator: !1
3391
+ })]
3392
+ }, "lt-channel-message-list"),
3393
+ i ? /* @__PURE__ */ U(o.Fragment, { children: i(A) }, "lt-channel-conversation-footer") : null,
3394
+ /* @__PURE__ */ U(ji, {
3395
+ ...n && { renderActions: () => n?.(A) },
3396
+ renderFooter: () => r?.(A),
3397
+ disabled: _,
3398
+ disabledReason: v,
3399
+ composerInput: k
3400
+ }, "lt-channel-message-input")
3401
+ ] }) })
3402
+ })
3403
+ });
3404
+ }, Qi = o.memo(({ channel: e, onBack: t, showBackButton: n = !1, renderMessageInputActions: r, renderMessageInputFooter: i, renderConversationFooter: a, onLeaveConversation: o, onBlockParticipant: s, className: c, CustomChannelEmptyState: u = Ji, showDeleteConversation: f = !0, onDeleteConversationClick: p, onBlockParticipantClick: h, onReportParticipantClick: g, showBlockParticipant: _ = !0, showReportParticipant: v = !0, composerDisabled: y = !1, composerDisabledReason: b, dmAgentEnabled: x, messageMetadata: C, onMessageSent: w, showStarButton: T = !1, renderChannelBanner: E, customChannelActions: D, renderChannelActions: O, renderMessage: k, onMessageLinkClick: A, sendButton: j, attachmentPreviewList: M, viewerLanguage: N, showChannelInfo: P = !0, onParticipantNameClick: F, onOutboundClick: I, resolveOutbound: L, composerInput: R }) => {
3405
+ let z = l(async (t, n, r) => {
3406
+ let i = e.data?.chatbot_paused === !0, a = x && !i, o = {
3407
+ ...n,
3408
+ ...a && { silent: !0 },
3409
+ ...C && { metadata: {
3410
+ ...n.metadata ?? {},
3411
+ ...C
3412
+ } }
3413
+ }, s = {
3414
+ ...r,
3415
+ ...a && { skip_push: !0 }
3416
+ }, c = await e.sendMessage(o, s);
3417
+ return w?.(c), c;
3418
+ }, [
3419
+ e,
3420
+ x,
3421
+ C,
3422
+ w
3423
+ ]), ee = m(null);
3424
+ d(() => {
3425
+ if (!A) return;
3426
+ let t = ee.current;
3427
+ if (!t) return;
3428
+ let n = (t) => {
3429
+ let n = t.target?.closest("a[href]"), r = n?.getAttribute("href");
3430
+ if (!r) return;
3431
+ let i = (n?.closest("[data-message-id]"))?.getAttribute("data-message-id");
3432
+ A(r, i ? e.state.messages.find((e) => e.id === i) : void 0);
3433
+ };
3434
+ return t.addEventListener("click", n), () => t.removeEventListener("click", n);
3435
+ }, [A, e]);
3436
+ let te = we(e.type) ? { "--lt-msg-card-width": "368px" } : void 0;
3437
+ return /* @__PURE__ */ U("div", {
3438
+ ref: ee,
3439
+ className: q("messaging-channel-view h-full flex flex-col", c),
3440
+ style: te,
3441
+ children: /* @__PURE__ */ U(Hi.Provider, {
3442
+ value: x ?? !1,
3443
+ children: /* @__PURE__ */ U(S, {
3444
+ channel: e,
3445
+ MessageSystem: Vi,
3446
+ EmptyStateIndicator: u,
3447
+ LoadingIndicator: Xi,
3448
+ DateSeparator: bt,
3449
+ TypingIndicator: Gi,
3450
+ doSendMessageRequest: z,
3451
+ ...j ? { SendButton: j } : {},
3452
+ ...M ? { AttachmentPreviewList: M } : {},
3453
+ children: /* @__PURE__ */ U(Zi, {
3454
+ onBack: t,
3455
+ showBackButton: n,
3456
+ renderMessageInputActions: r,
3457
+ renderMessageInputFooter: i,
3458
+ renderConversationFooter: a,
3459
+ onLeaveConversation: o,
3460
+ onBlockParticipant: s,
3461
+ CustomChannelEmptyState: u,
3462
+ showDeleteConversation: f,
3463
+ onDeleteConversationClick: p,
3464
+ onBlockParticipantClick: h,
3465
+ onReportParticipantClick: g,
3466
+ showBlockParticipant: _,
3467
+ showReportParticipant: v,
3468
+ composerDisabled: y,
3469
+ composerDisabledReason: b,
3470
+ showStarButton: T,
3471
+ renderChannelBanner: E,
3472
+ customChannelActions: D,
3473
+ renderChannelActions: O,
3474
+ renderMessage: k,
3475
+ viewerLanguage: N,
3476
+ showChannelInfo: P,
3477
+ onParticipantNameClick: F,
3478
+ onOutboundClick: I,
3479
+ resolveOutbound: L,
3480
+ composerInput: R
3481
+ })
3482
+ })
3483
+ })
3484
+ });
3485
+ });
3486
+ Qi.displayName = "ChannelView";
3487
+ //#endregion
3488
+ //#region src/components/MessagingShell/ErrorState.tsx
3489
+ var $i = o.memo(({ message: e, onBack: t }) => /* @__PURE__ */ U("div", {
3490
+ className: "messaging-error-state flex items-center justify-center h-full p-8",
3491
+ children: /* @__PURE__ */ W("div", {
3492
+ className: "text-center max-w-sm",
3493
+ children: [
3494
+ /* @__PURE__ */ U("div", {
3495
+ className: "w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",
3496
+ children: /* @__PURE__ */ U("span", {
3497
+ className: "text-4xl",
3498
+ children: "⚠️"
3499
+ })
3500
+ }),
3501
+ /* @__PURE__ */ U("h2", {
3502
+ className: "font-semibold text-charcoal mb-2",
3503
+ children: "Oops!"
3504
+ }),
3505
+ /* @__PURE__ */ U("p", {
3506
+ className: "text-stone text-sm mb-6",
3507
+ children: e
3508
+ }),
3509
+ t && /* @__PURE__ */ U("button", {
3510
+ type: "button",
3511
+ onClick: t,
3512
+ 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",
3513
+ children: "Go Back"
3514
+ })
3515
+ ]
3516
+ })
3517
+ }));
3518
+ $i.displayName = "ErrorState";
3519
+ //#endregion
3520
+ //#region src/components/MessagingShell/index.tsx
3521
+ var ea = ({ capabilities: e = {}, renderMessageInputActions: t, renderConversationFooter: n, onChannelSelect: r, onExitConversation: i, initialParticipantFilter: a, initialParticipantData: o, CustomChannelEmptyState: s, onBlockParticipantClick: c, onReportParticipantClick: u, dmAgentEnabled: f, onMessageSent: p, viewerLanguage: g, renderChannelBanner: _, customChannelActions: v, renderChannelActions: y, onParticipantNameClick: b, onOutboundClick: x, resolveOutbound: S, renderMessage: C, onMessageLinkClick: w, showChannelInfo: T, composerInput: E, attachmentPreviewList: D }) => {
3522
+ let { client: O, isConnected: k, isLoading: A, error: j, refreshConnection: M, service: N, debug: P } = et(), [F, I] = h(null), [L, R] = h(null), [z, ee] = h(!1), { showDeleteConversation: te = !0 } = e, ne = m(o);
3523
+ ne.current = o;
3524
+ let re = m(r);
3525
+ re.current = r;
3526
+ let ie = m(null), B = m(null);
3527
+ d(() => {
3528
+ B.current = F;
3529
+ }, [F]), d(() => {
3530
+ if (!O || !k) return;
3531
+ let e = O.userID;
3532
+ if (!e) return;
3533
+ let t = `${e}::${a}`;
3534
+ if (ie.current === t) return;
3535
+ ie.current = t;
3536
+ let n = () => {
3537
+ ie.current === t && (ie.current = null);
3538
+ };
3539
+ (async () => {
3540
+ try {
3541
+ P && console.log("[MessagingShell] Loading initial conversation with:", a);
3542
+ let t = await O.queryChannels({
3543
+ type: "messaging",
3544
+ members: { $eq: [e, a] }
3545
+ }, {}, { limit: 1 });
3546
+ if (t.length > 0) {
3547
+ I(t[0]), R(null), re.current?.(t[0]), P && console.log("[MessagingShell] Initial conversation loaded:", t[0].id);
3548
+ return;
3549
+ }
3550
+ let r = ne.current;
3551
+ if (!r || !N) {
3552
+ n(), R("No conversation found with this account"), P && console.log("[MessagingShell] No conversation found for:", a);
3553
+ return;
3554
+ }
3555
+ try {
3556
+ let e = await N.startChannelWithParticipant({
3557
+ id: r.id,
3558
+ name: r.name,
3559
+ phone: r.phone
3560
+ });
3561
+ I(e), R(null), re.current?.(e), P && console.log("[MessagingShell] Channel created and loaded:", e.id);
3562
+ } catch (e) {
3563
+ console.error("[MessagingShell] Failed to create conversation:", e), n(), R("Failed to create conversation");
3564
+ }
3565
+ } catch (e) {
3566
+ console.error("[MessagingShell] Failed to load initial conversation:", e), n(), B.current || R("Failed to load conversation");
3567
+ }
3568
+ })();
3569
+ }, [
3570
+ a,
3571
+ O,
3572
+ k,
3573
+ N,
3574
+ P
3575
+ ]);
3576
+ let ae = m(i);
3577
+ ae.current = i;
3578
+ let oe = l(() => {
3579
+ I(null), ee(!0), ae.current?.();
3580
+ }, []);
3581
+ return A ? /* @__PURE__ */ U(Xi, {}) : j ? /* @__PURE__ */ U($i, {
3582
+ message: j,
3583
+ onBack: M
3584
+ }) : !k || !O ? /* @__PURE__ */ U($i, {
3585
+ message: "Not connected to messaging service",
3586
+ onBack: M
3587
+ }) : L ? /* @__PURE__ */ U($i, { message: L }) : z && !F ? /* @__PURE__ */ U($i, { message: "Conversation ended" }) : F ? /* @__PURE__ */ U("div", {
3588
+ className: "messaging-shell h-full bg-background-primary overflow-hidden",
3589
+ children: /* @__PURE__ */ U("div", {
3590
+ className: "flex h-full min-h-0 flex-col",
3591
+ children: /* @__PURE__ */ U(Qi, {
3592
+ channel: F,
3593
+ renderMessageInputActions: t,
3594
+ renderConversationFooter: n,
3595
+ renderChannelBanner: _,
3596
+ onLeaveConversation: oe,
3597
+ onBlockParticipant: oe,
3598
+ CustomChannelEmptyState: s,
3599
+ showDeleteConversation: te,
3600
+ onBlockParticipantClick: c,
3601
+ onReportParticipantClick: u,
3602
+ dmAgentEnabled: f,
3603
+ onMessageSent: p,
3604
+ viewerLanguage: g,
3605
+ customChannelActions: v,
3606
+ renderChannelActions: y,
3607
+ onParticipantNameClick: b,
3608
+ onOutboundClick: x,
3609
+ resolveOutbound: S,
3610
+ renderMessage: C,
3611
+ onMessageLinkClick: w,
3612
+ showChannelInfo: T,
3613
+ composerInput: E,
3614
+ attachmentPreviewList: D
3615
+ }, F.id)
3616
+ })
3617
+ }) : /* @__PURE__ */ U(Xi, {});
3618
+ };
3619
+ //#endregion
3620
+ //#region src/hooks/useRestorePendingMessages.ts
3621
+ function ta(e) {
3622
+ let t = e.state.pending_messages;
3623
+ if (t?.length) for (let n of t) e.state.addMessageSorted(n.message);
3624
+ }
3625
+ //#endregion
3626
+ //#region src/components/ChannelList/ChannelListContext.tsx
3627
+ var na = o.createContext({
3628
+ selectedChannel: void 0,
3629
+ onChannelSelect: () => {},
3630
+ debug: !1,
3631
+ renderMessagePreview: void 0,
3632
+ channelPreview: void 0,
3633
+ viewerLanguage: void 0
3634
+ }), ra = na.Provider, ia = () => o.useContext(na), aa = (e, t) => {
3635
+ let n = Date.UTC(e.getFullYear(), e.getMonth(), e.getDate()), r = Date.UTC(t.getFullYear(), t.getMonth(), t.getDate());
3636
+ return Math.floor((r - n) / 864e5);
3637
+ }, oa = (e) => {
3638
+ let t = /* @__PURE__ */ new Date();
3639
+ if (Math.floor((t.getTime() - e.getTime()) / 1e3) < 60) return "Just now";
3640
+ let n = aa(e, t);
3641
+ return n === 0 ? e.toLocaleTimeString([], {
3642
+ hour: "numeric",
3643
+ minute: "2-digit",
3644
+ hour12: !0
3645
+ }) : n === 1 ? "Yesterday" : n < 7 ? e.toLocaleDateString(void 0, { weekday: "short" }) : e.getFullYear() === t.getFullYear() ? e.toLocaleDateString(void 0, {
3646
+ month: "short",
3647
+ day: "numeric"
3648
+ }) : e.toLocaleDateString(void 0, {
3649
+ month: "short",
3650
+ day: "numeric",
3651
+ year: "numeric"
3652
+ });
3653
+ }, sa = o.memo((e) => {
3654
+ let { channel: t, unread: n } = e, { selectedChannel: r, onChannelSelect: i, debug: a, channelPreview: o, renderMessagePreview: s, viewerLanguage: c } = ia(), { client: l } = me(), u = r?.id === t?.id, d = tt(t);
3655
+ if (o) return /* @__PURE__ */ U(o, {
3656
+ ...e,
3657
+ active: u,
3658
+ selectedChannel: r,
3659
+ onChannelSelect: i,
3660
+ viewerLanguage: c
3661
+ });
3662
+ let f = () => {
3663
+ t && i(t);
3664
+ }, p = (e) => {
3665
+ let t = e.key === "Enter" || e.key === " ", n = e.repeat;
3666
+ !t || n || (e.preventDefault(), f());
3667
+ }, m = nt(t?.state?.members, l?.userID, t?.type), h = ot(m?.user), g = m?.user?.image, _ = (() => {
3668
+ let e = t?.state?.messages;
3669
+ if (e?.length) {
3670
+ for (let t = e.length - 1; t >= 0; t--) if (e[t].type !== "system") return e[t];
3671
+ }
3672
+ })(), v = (() => {
3673
+ let e = St({
3674
+ message: _,
3675
+ viewerLanguage: c
3676
+ }), { custom_type: t, attachment_content_type: n } = _?.metadata || {};
3677
+ if (t === G.TIP) return e || "Sent a tip";
3678
+ if (t === G.PAID) return e || "Sent a message";
3679
+ if (t === G.ATTACHMENT) {
3680
+ if (n === "text") return "🔒 Sent a locked message";
3681
+ if (n === "media") return "🔒 Sent a locked attachment";
3682
+ }
3683
+ if (e) return e;
3684
+ let r = _?.attachments?.[0];
3685
+ return r ? r.og_scrape_url ? r.og_scrape_url : r.type === "image" ? "📷 Sent an image" : r.type === "video" ? "🎥 Sent a video" : r.type === "audio" ? "🎵 Sent audio" : r.type === "file" ? "📎 Sent a file" : "📎 Sent an attachment" : "No messages yet";
3686
+ })(), y = _?.created_at ? oa(new Date(_.created_at)) : "", b = _ ? Yt(_) : !1, x = s ? s(_, v) : `${b ? "✨ " : ""}${v}`, S = n ?? 0;
3687
+ return a && console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER", {
3688
+ channelId: t?.id,
3689
+ isSelected: u,
3690
+ participantName: h,
3691
+ unreadCount: S,
3692
+ hasTimestamp: !!y
3693
+ }), /* @__PURE__ */ U("div", {
3694
+ role: "button",
3695
+ tabIndex: 0,
3696
+ onClick: f,
3697
+ onKeyDown: p,
3698
+ className: q("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring rounded-[12px] [&+&]:mt-2", {
3699
+ "bg-black/[0.04]": u,
3700
+ "hover:bg-black/[0.02]": !u
3701
+ }),
3702
+ "data-dd-privacy": "mask",
3703
+ children: /* @__PURE__ */ W("div", {
3704
+ className: "flex items-start gap-4",
3705
+ children: [/* @__PURE__ */ U(Z, {
3706
+ id: m?.user?.id || t.id || "unknown",
3707
+ name: h,
3708
+ image: g,
3709
+ size: 48,
3710
+ starred: d
3711
+ }), /* @__PURE__ */ W("div", {
3712
+ className: "flex-1 min-w-0 flex flex-col gap-1",
3713
+ children: [/* @__PURE__ */ W("div", {
3714
+ className: "flex items-center justify-between gap-2",
3715
+ children: [/* @__PURE__ */ W("h3", {
3716
+ className: q("text-sm font-medium truncate text-[#191918]"),
3717
+ children: [d && /* @__PURE__ */ U("span", {
3718
+ className: "sr-only",
3719
+ children: "Starred conversation. "
3720
+ }), h]
3721
+ }), y && /* @__PURE__ */ U("span", {
3722
+ className: "text-xs text-[#717070] flex-shrink-0",
3723
+ children: y
3724
+ })]
3725
+ }), /* @__PURE__ */ W("div", {
3726
+ className: "flex items-center justify-between gap-2 min-w-0",
3727
+ children: [/* @__PURE__ */ U("p", {
3728
+ className: "text-sm text-[#717070] flex-1 line-clamp-1",
3729
+ children: x
3730
+ }), S > 0 && /* @__PURE__ */ U("span", {
3731
+ className: "bg-[#7f22fe] text-white text-[10px] rounded-full h-4 flex items-center justify-center p-1 min-w-4 text-center flex-shrink-0",
3732
+ children: S > 99 ? "99+" : S
3733
+ })]
3734
+ })]
3735
+ })]
3736
+ })
3737
+ });
3738
+ });
3739
+ sa.displayName = "CustomChannelPreview";
3740
+ //#endregion
3741
+ //#region src/components/ChannelList/index.tsx
3742
+ var ca = { last_message_at: -1 }, la = o.memo(({ onChannelSelect: e, selectedChannel: t, filters: n, allowNewMessagesFromUnfilteredChannels: r = !1, channelRenderFilterFn: i, sort: a = ca, className: s, customEmptyStateIndicator: c, channelListPaginator: l = D, channelPreview: u, renderMessagePreview: d, viewerLanguage: f, lockChannelOrder: p, onMessageNewHandler: m, onMessageNew: h, onChannelVisible: g, onAddedToChannel: _, onChannelUpdated: v }) => {
3743
+ let y = o.useRef(0);
3744
+ y.current++;
3745
+ let { debug: b = !1 } = Qe(), x = o.useCallback((e) => {
3746
+ for (let t of e) ta(t);
3747
+ return i ? i(e) : e;
3748
+ }, [i]);
3749
+ b && console.log("📺 [ChannelList] 🔄 RENDER START", {
3750
+ renderCount: y.current,
3751
+ selectedChannelId: t?.id,
3752
+ filters: n
3753
+ });
3754
+ let S = o.useMemo(() => ({
3755
+ selectedChannel: t,
3756
+ onChannelSelect: e,
3757
+ debug: b,
3758
+ channelPreview: u,
3759
+ renderMessagePreview: d,
3760
+ viewerLanguage: f
3761
+ }), [
3762
+ t,
3763
+ e,
3764
+ b,
3765
+ u,
3766
+ d,
3767
+ f
3768
+ ]);
3769
+ return /* @__PURE__ */ U("div", {
3770
+ className: q("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden", s),
3771
+ children: /* @__PURE__ */ U("div", {
3772
+ className: "flex-1 overflow-hidden min-w-0",
3773
+ children: /* @__PURE__ */ U(ra, {
3774
+ value: S,
3775
+ children: /* @__PURE__ */ U(C, {
3776
+ filters: n,
3777
+ sort: a,
3778
+ options: { limit: 30 },
3779
+ allowNewMessagesFromUnfilteredChannels: r,
3780
+ channelRenderFilterFn: x,
3781
+ lockChannelOrder: p,
3782
+ onMessageNewHandler: m,
3783
+ onMessageNew: h,
3784
+ onChannelVisible: g,
3785
+ onAddedToChannel: _,
3786
+ onChannelUpdated: v,
3787
+ Paginator: l,
3788
+ Preview: sa,
3789
+ EmptyStateIndicator: c
3790
+ }, `${JSON.stringify(n)}:${JSON.stringify(a)}`)
3791
+ })
3792
+ })
3793
+ });
3794
+ });
3795
+ la.displayName = "ChannelList";
3796
+ //#endregion
3797
+ //#region src/components/RichCard/RichCardBody.tsx
3798
+ var ua = "line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px] [text-wrap:balance]", da = "text-[12px] leading-4 tracking-[0.24px] [text-wrap:pretty]", fa = ({ surface: e, actions: t, layout: n }) => {
3799
+ if (t == null || t.length === 0) return null;
3800
+ let r = n === "stacked";
3801
+ return /* @__PURE__ */ U("div", {
3802
+ className: q("flex gap-2", r ? "mt-3 flex-col" : "min-w-0 max-w-[60%] flex-row flex-wrap justify-end"),
3803
+ children: t.map((t, n) => /* @__PURE__ */ U(Sn, {
3804
+ variant: e,
3805
+ cta: t,
3806
+ fullWidth: r,
3807
+ standalone: !0
3808
+ }, `${t.label}-${n}`))
3809
+ });
3810
+ }, pa = ({ ctaSurface: e, chinTextColor: t, title: n, subtitle: r, subtitleLines: i = 3, appIcon: a, actions: o }) => {
3811
+ let s = n != null && n.trim() !== "", c = r != null && r.trim() !== "", l = o != null && o.length > 0;
3812
+ if (!s && !c && !l) return null;
3813
+ let u = { color: t }, d = i > 1 ? {
3814
+ ...u,
3815
+ display: "-webkit-box",
3816
+ WebkitBoxOrient: "vertical",
3817
+ WebkitLineClamp: i,
3818
+ overflow: "hidden"
3819
+ } : u, f = l && (o?.[0]?.variant ?? "primary") === "secondary", p = /* @__PURE__ */ W("div", {
3820
+ className: "flex min-w-0 flex-1 flex-col gap-[2px]",
3821
+ children: [s && /* @__PURE__ */ W("div", {
3822
+ className: "flex min-w-0 items-center gap-2",
3823
+ children: [a ? /* @__PURE__ */ U("span", {
3824
+ className: "shrink-0",
3825
+ children: a
3826
+ }) : null, /* @__PURE__ */ U("p", {
3827
+ className: q("min-w-0", ua),
3828
+ style: u,
3829
+ children: n
3830
+ })]
3831
+ }), c && /* @__PURE__ */ U("p", {
3832
+ className: q(da, i > 1 && "whitespace-pre-line", i <= 1 && "truncate"),
3833
+ style: d,
3834
+ children: r
3835
+ })]
3836
+ });
3837
+ return /* @__PURE__ */ U("div", {
3838
+ className: "shrink-0 px-4 py-3",
3839
+ children: f ? /* @__PURE__ */ W("div", {
3840
+ className: "flex items-center justify-between gap-3",
3841
+ children: [p, /* @__PURE__ */ U(fa, {
3842
+ surface: e,
3843
+ actions: o,
3844
+ layout: "row"
3845
+ })]
3846
+ }) : /* @__PURE__ */ W(H, { children: [p, /* @__PURE__ */ U(fa, {
3847
+ surface: e,
3848
+ actions: o,
3849
+ layout: "stacked"
3850
+ })] })
3851
+ });
3852
+ }, ma = {
3853
+ dark: "bg-white/[0.06]",
3854
+ light: "bg-black/[0.04]"
3855
+ }, ha = {
3856
+ 1: [0],
3857
+ 2: [-10, 10],
3858
+ 3: [
3859
+ -13,
3860
+ 0,
3861
+ 13
3862
+ ]
3863
+ }, ga = {
3864
+ 1: [0],
3865
+ 2: [-26, 26],
3866
+ 3: [
3867
+ -40,
3868
+ 0,
3869
+ 40
3870
+ ]
3871
+ }, _a = {
3872
+ 1: [0],
3873
+ 2: [0, 1],
3874
+ 3: [
3875
+ 1,
3876
+ 3,
3877
+ 2
3878
+ ]
3879
+ }, va = {
3880
+ 1: [1],
3881
+ 2: [1, 1],
3882
+ 3: [
3883
+ 1,
3884
+ 1.08,
3885
+ 1
3886
+ ]
3887
+ }, ya = ({ variant: e, images: t }) => {
3888
+ let [n, i] = o.useState({}), a = t.join("\n"), [s, c] = o.useState(a);
3889
+ a !== s && (c(a), i({}));
3890
+ let l = t.slice(0, 3).map((e, t) => ({
3891
+ src: e,
3892
+ index: t
3893
+ })).filter(({ index: e }) => !n[e]), u = l.length >= 3 ? 3 : l.length === 2 ? 2 : 1, d = ha[u], f = ga[u], p = _a[u], m = va[u];
3894
+ return /* @__PURE__ */ U("div", {
3895
+ className: q("relative flex min-h-0 w-full flex-1 items-center justify-center overflow-hidden", ma[e]),
3896
+ children: l.map(({ src: e, index: t }, n) => /* @__PURE__ */ U("img", {
3897
+ src: r(e) ?? e,
3898
+ alt: "",
3899
+ draggable: !1,
3900
+ loading: "lazy",
3901
+ decoding: "async",
3902
+ onError: () => i((e) => ({
3903
+ ...e,
3904
+ [t]: !0
3905
+ })),
3906
+ className: "absolute left-1/2 top-1/2 w-[62%] aspect-[3/2] rounded-[12px] bg-[#ffffff] object-cover shadow-md",
3907
+ style: {
3908
+ transform: `translate(-50%, -50%) translateX(${f[n]}px) rotate(${d[n]}deg) scale(${m[n]})`,
3909
+ zIndex: p[n]
3910
+ }
3911
+ }, `${e}-${t}`))
3912
+ });
3913
+ }, ba = "flex h-[180px] w-full shrink-0 flex-col overflow-hidden", xa = ({ variant: e, presentation: t, images: n, title: r, heroUrl: i, onHeroError: a }) => /* @__PURE__ */ U("div", {
3914
+ className: ba,
3915
+ children: t === "fan" ? /* @__PURE__ */ U(ya, {
3916
+ variant: e,
3917
+ images: n
3918
+ }) : /* @__PURE__ */ U(Ln, {
3919
+ variant: e,
3920
+ thumbnailUrl: i,
3921
+ title: r,
3922
+ mimeType: "image/*",
3923
+ onImageError: a
3924
+ })
3925
+ }), Sa = ({ variant: e, title: t, subtitle: n, subtitleLines: r, images: i = [], imagePresentation: a, actions: o, appIcon: s, accentColor: c, groupPosition: l = "single" }) => {
3926
+ let u = Te({
3927
+ imagePresentation: a,
3928
+ images: i
3929
+ }), d = i.length > 0, f = d && u === "hero", p = Un({
3930
+ variant: e,
3931
+ accentColor: c,
3932
+ layout: "featured",
3933
+ thumbnailUrl: f ? i[0] : void 0
3934
+ }), m = l === "single" || l === "end";
3935
+ return /* @__PURE__ */ U(qn, {
3936
+ accentHex: p.accentHex,
3937
+ side: e === "dark" ? "sender" : "receiver",
3938
+ visible: m,
3939
+ children: /* @__PURE__ */ W(jn, {
3940
+ variant: e,
3941
+ accentHex: p.accentHex,
3942
+ "data-testid": "rich-card",
3943
+ children: [d && /* @__PURE__ */ U(xa, {
3944
+ variant: e,
3945
+ presentation: u,
3946
+ images: i,
3947
+ title: t,
3948
+ heroUrl: f ? p.thumbnailUrl : void 0,
3949
+ onHeroError: p.onImageError
3950
+ }), /* @__PURE__ */ U(pa, {
3951
+ ctaSurface: p.surface,
3952
+ chinTextColor: p.chinTextColor,
3953
+ title: t,
3954
+ subtitle: n,
3955
+ subtitleLines: r,
3956
+ appIcon: s,
3957
+ actions: o
3958
+ })]
3959
+ })
3960
+ });
3961
+ }, Ca = {
3962
+ Sent: (e) => /* @__PURE__ */ U(Sa, {
3963
+ ...e,
3964
+ variant: "dark"
3965
+ }),
3966
+ Received: (e) => /* @__PURE__ */ U(Sa, {
3967
+ ...e,
3968
+ variant: "light"
3969
+ })
3970
+ }, wa = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='23' fill='none'%3E%3Cpath fill='black' d='M0 0H15C15 10.1934 15.859 15.2345 19.168 21.4893C19.527 22.168 19.039 22.9917 18.274 22.9178C5.176 21.6506 0.32 6.0737 0 0Z'/%3E%3C/svg%3E\") no-repeat center / 100% 100%", Ta = {
3971
+ sent: "var(--str-chat__own-message-bubble-background-color, #1e2330)",
3972
+ received: "var(--str-chat__message-bubble-background-color, #f1f0ee)"
3973
+ }, Ea = ({ variant: e }) => /* @__PURE__ */ U("span", {
3974
+ "aria-hidden": "true",
3975
+ className: "pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",
3976
+ style: {
3977
+ insetInlineEnd: e === "sent" ? "calc(-1 * 0.25rem)" : void 0,
3978
+ insetInlineStart: e === "received" ? "calc(-1 * 0.25rem)" : void 0,
3979
+ transform: e === "received" ? "scaleX(-1)" : void 0,
3980
+ transformOrigin: "center",
3981
+ backgroundColor: Ta[e],
3982
+ WebkitMask: wa,
3983
+ mask: wa
3984
+ }
3985
+ }), Da = {
3986
+ sent: {
3987
+ backgroundColor: "var(--str-chat__own-message-bubble-background-color, #1e2330)",
3988
+ color: "var(--str-chat__own-message-bubble-color, #fff)"
3989
+ },
3990
+ received: {
3991
+ backgroundColor: "var(--str-chat__message-bubble-background-color, #f1f0ee)",
3992
+ color: "var(--str-chat__message-bubble-color, #000000)"
3993
+ }
3994
+ }, Oa = ({ variant: e, text: t, tail: n = !0, header: r, className: i }) => /* @__PURE__ */ W("div", {
3995
+ "data-dd-privacy": "mask",
3996
+ className: q("relative px-4 py-3", "text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]", i),
3997
+ style: {
3998
+ ...Da[e],
3999
+ borderRadius: "var(--str-chat__message-bubble-border-radius, 1.5rem)",
4000
+ isolation: "isolate"
4001
+ },
4002
+ children: [
4003
+ r != null && /* @__PURE__ */ U("div", {
4004
+ className: "mb-1 font-medium",
4005
+ "data-testid": "message-bubble-header",
4006
+ children: r
4007
+ }),
4008
+ /* @__PURE__ */ U("p", {
4009
+ className: "m-0 whitespace-pre-wrap break-words hyphens-manual",
4010
+ children: t
4011
+ }),
4012
+ n && /* @__PURE__ */ U(Ea, { variant: e })
4013
+ ]
4014
+ }), ka = {
4015
+ Sent: ({ text: e, tail: t, className: n }) => /* @__PURE__ */ U(Oa, {
4016
+ variant: "sent",
4017
+ text: e,
4018
+ tail: t,
4019
+ className: n
4020
+ }),
4021
+ Received: ({ text: e, tail: t, header: n, className: r }) => /* @__PURE__ */ U(Oa, {
4022
+ variant: "received",
4023
+ text: e,
4024
+ tail: t,
4025
+ header: n,
4026
+ className: r
4027
+ })
4028
+ }, Aa = ({ question: e, onClick: t, loading: n = !1, className: r }) => /* @__PURE__ */ U("button", {
4029
+ type: "button",
4030
+ onClick: t,
4031
+ disabled: n,
4032
+ style: { backgroundColor: "#E6E5E3" },
4033
+ className: q("w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring", {
4034
+ "hover:brightness-95 active:brightness-90": !n,
4035
+ "opacity-50 cursor-not-allowed": n
4036
+ }, r),
4037
+ children: e
4038
+ }), ja = ({ faqs: e, onFaqClick: t, loadingFaqId: n, headerText: r, className: i, avatarImage: a, avatarName: o }) => {
4039
+ let s = Ee(e);
4040
+ return s.length === 0 ? null : /* @__PURE__ */ U("div", {
4041
+ className: i,
4042
+ children: /* @__PURE__ */ W("div", {
4043
+ className: "flex gap-3 items-end",
4044
+ children: [(a || o) && /* @__PURE__ */ U("div", {
4045
+ className: "flex-none",
4046
+ children: /* @__PURE__ */ U(Z, {
4047
+ id: o || "account",
4048
+ name: o || "Account",
4049
+ image: a,
4050
+ size: 24,
4051
+ shape: "circle"
4052
+ })
4053
+ }), /* @__PURE__ */ W("div", {
4054
+ className: "flex-1 flex flex-col gap-3 rounded-lg p-4",
4055
+ style: { backgroundColor: "#F1F0EE" },
4056
+ children: [r && /* @__PURE__ */ U("p", {
4057
+ className: "text-md text-charcoal mb-4",
4058
+ children: r
4059
+ }), s.map((e) => /* @__PURE__ */ U(Aa, {
4060
+ question: e.question,
4061
+ onClick: () => t(e.id),
4062
+ loading: n === e.id
4063
+ }, e.id))]
4064
+ })]
4065
+ })
4066
+ });
4067
+ };
4068
+ //#endregion
4069
+ export { mt as ActionButton, Z as Avatar, Ji as ChannelEmptyState, la as ChannelList, Qi as ChannelView, Vt as CustomMessageProvider, ja as FaqList, Aa as FaqListItem, Jn as LinkAttachment, Kt as LockedAttachment, Rt as MediaMessage, ii as MessageAttachment, ka as MessageBubble, $e as MessagingProvider, ea as MessagingShell, Ca as RichCard, dn as TipMessage, dr as buildCompactMetaLabel, cr as formatFileSize, oa as formatRelativeTime, ur as getFileExtensionLabel, St as getMessageDisplayText, jt as isLinkAttachment, un as isTipMessage, it as isUuidLike, rr as messageAttachmentGroupPositionFromStream, xt as normalizeLanguageCode, r as optimizeMessagingAttachmentUrl, nt as resolveConversationParticipant, Mt as resolveLinkAttachment, Ft as resolveMediaFromMessage, ot as resolveParticipantDisplayName, Di as useComposerLocked, Ht as useCustomMessage, et as useMessaging };
4070
+
4071
+ //# sourceMappingURL=index.js.map