@linktr.ee/messaging-react 4.3.0 → 4.3.1-rc-1787498437

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