@linktr.ee/messaging-react 4.2.1 → 4.2.2-rc-1787413840

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