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

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