@linktr.ee/messaging-react 3.10.0 → 3.11.0-rc-1783756377

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 (88) hide show
  1. package/dist/Card-415OfRhw.cjs +2 -0
  2. package/dist/Card-415OfRhw.cjs.map +1 -0
  3. package/dist/Card-BnbNynLQ.js +694 -0
  4. package/dist/Card-BnbNynLQ.js.map +1 -0
  5. package/dist/Card-UnwKmYzt.cjs +2 -0
  6. package/dist/Card-UnwKmYzt.cjs.map +1 -0
  7. package/dist/Card-qS17qnN0.js +103 -0
  8. package/dist/Card-qS17qnN0.js.map +1 -0
  9. package/dist/LoadingDots-Ct3WmVlT.js +59 -0
  10. package/dist/LoadingDots-Ct3WmVlT.js.map +1 -0
  11. package/dist/LoadingDots-D9GGphgM.cjs +2 -0
  12. package/dist/LoadingDots-D9GGphgM.cjs.map +1 -0
  13. package/dist/assets/index.css +1 -1
  14. package/dist/index-CyHyftBi.cjs +2 -0
  15. package/dist/index-CyHyftBi.cjs.map +1 -0
  16. package/dist/{index-BxzzWK4K.js → index-DJXjS2H9.js} +1397 -1358
  17. package/dist/index-DJXjS2H9.js.map +1 -0
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.ts +196 -101
  20. package/dist/index.js +1 -1
  21. package/dist/testing.d.ts +1 -0
  22. package/package.json +2 -2
  23. package/src/components/ChannelList/CustomChannelPreview.test.tsx +95 -0
  24. package/src/components/ChannelList/CustomChannelPreview.tsx +21 -9
  25. package/src/components/ChannelList/index.test.tsx +46 -0
  26. package/src/components/ChannelList/index.tsx +12 -0
  27. package/src/components/CustomMessage/CustomMessage.stories.tsx +54 -1
  28. package/src/components/CustomMessage/LockedAttachment/LockedAttachment.stories.tsx +541 -0
  29. package/src/components/CustomMessage/LockedAttachment/LockedAttachment.test.tsx +117 -0
  30. package/src/components/CustomMessage/LockedAttachment/components/Media/Card.tsx +358 -0
  31. package/src/components/{LockedAttachment/components/Received → CustomMessage/LockedAttachment/components/Media}/CardActions.tsx +9 -2
  32. package/src/components/CustomMessage/LockedAttachment/components/Media/types.ts +79 -0
  33. package/src/components/CustomMessage/LockedAttachment/components/Text/Card.tsx +153 -0
  34. package/src/components/CustomMessage/LockedAttachment/components/Text/types.ts +58 -0
  35. package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/CardBody.tsx +8 -7
  36. package/src/components/CustomMessage/LockedAttachment/components/_shared/CardThumbnail.tsx +92 -0
  37. package/src/components/{LockedAttachment → CustomMessage/LockedAttachment}/components/_shared/GalleryThumbnail.tsx +31 -39
  38. package/src/components/CustomMessage/LockedAttachment/components/_shared/LoadingDots.tsx +36 -0
  39. package/src/components/CustomMessage/LockedAttachment/components/_shared/LockBadge.tsx +63 -0
  40. package/src/components/{LockedAttachment/components/_shared/LockedCardShell.tsx → CustomMessage/LockedAttachment/components/_shared/MediaShell.tsx} +8 -8
  41. package/src/components/CustomMessage/LockedAttachment/components/_shared/PreviewToggle.tsx +58 -0
  42. package/src/components/CustomMessage/LockedAttachment/components/_shared/PriceLockRow.tsx +21 -0
  43. package/src/components/CustomMessage/LockedAttachment/components/_shared/PurchaseStatusBadge.tsx +74 -0
  44. package/src/components/{LockedAttachment/components/_shared/LockedThumbnail.tsx → CustomMessage/LockedAttachment/components/_shared/SingleThumbnail.tsx} +11 -7
  45. package/src/components/CustomMessage/LockedAttachment/components/_shared/SkeletonTextLines.tsx +29 -0
  46. package/src/components/CustomMessage/LockedAttachment/components/_shared/TextShell.tsx +28 -0
  47. package/src/components/CustomMessage/LockedAttachment/components/_shared/usePreviewToggle.test.ts +67 -0
  48. package/src/components/CustomMessage/LockedAttachment/components/_shared/usePreviewToggle.ts +89 -0
  49. package/src/components/CustomMessage/LockedAttachment/components/_shared/useReceivedSource.ts +83 -0
  50. package/src/components/CustomMessage/LockedAttachment/index.tsx +105 -0
  51. package/src/components/CustomMessage/LockedAttachment/types.ts +44 -0
  52. package/src/components/CustomMessage/MessageTag.tsx +8 -0
  53. package/src/components/CustomMessage/context.tsx +1 -1
  54. package/src/components/CustomMessage/index.tsx +76 -42
  55. package/src/components/CustomMessageInput/CustomMessageInput.stories.tsx +5 -3
  56. package/src/index.ts +3 -8
  57. package/src/stream-custom-data.ts +1 -0
  58. package/src/styles.css +12 -0
  59. package/src/types.ts +35 -2
  60. package/dist/Card-B-L2MST4.js +0 -107
  61. package/dist/Card-B-L2MST4.js.map +0 -1
  62. package/dist/Card-B56QxJW3.cjs +0 -2
  63. package/dist/Card-B56QxJW3.cjs.map +0 -1
  64. package/dist/Card-Bqh-BQaX.js +0 -132
  65. package/dist/Card-Bqh-BQaX.js.map +0 -1
  66. package/dist/Card-ZCE6Lhfc.cjs +0 -2
  67. package/dist/Card-ZCE6Lhfc.cjs.map +0 -1
  68. package/dist/Card-g4JD-2ES.js +0 -163
  69. package/dist/Card-g4JD-2ES.js.map +0 -1
  70. package/dist/Card-wac6AMNc.cjs +0 -2
  71. package/dist/Card-wac6AMNc.cjs.map +0 -1
  72. package/dist/LockedThumbnail-BAQmoIff.js +0 -220
  73. package/dist/LockedThumbnail-BAQmoIff.js.map +0 -1
  74. package/dist/LockedThumbnail-Cr0Gqs3Y.cjs +0 -2
  75. package/dist/LockedThumbnail-Cr0Gqs3Y.cjs.map +0 -1
  76. package/dist/index-BPhZyaxT.cjs +0 -2
  77. package/dist/index-BPhZyaxT.cjs.map +0 -1
  78. package/dist/index-BxzzWK4K.js.map +0 -1
  79. package/src/components/LockedAttachment/LockedAttachment.stories.tsx +0 -450
  80. package/src/components/LockedAttachment/components/Composer/Card.tsx +0 -221
  81. package/src/components/LockedAttachment/components/Composer/index.ts +0 -2
  82. package/src/components/LockedAttachment/components/Received/Card.tsx +0 -191
  83. package/src/components/LockedAttachment/components/Received/index.ts +0 -2
  84. package/src/components/LockedAttachment/components/Sent/Card.tsx +0 -177
  85. package/src/components/LockedAttachment/components/Sent/index.ts +0 -2
  86. package/src/components/LockedAttachment/components/_shared/LockBadge.tsx +0 -39
  87. package/src/components/LockedAttachment/index.tsx +0 -63
  88. package/src/components/LockedAttachment/types.ts +0 -51
@@ -0,0 +1,694 @@
1
+ import { jsxs as h, jsx as e } from "react/jsx-runtime";
2
+ import { PlayIcon as B, LockOpenIcon as q, LockSimpleIcon as V, CaretLeftIcon as F, CaretRightIcon as H, ImagesIcon as J, DownloadSimpleIcon as R, XIcon as Q, PencilSimpleIcon as W } from "@phosphor-icons/react";
3
+ import y, { useState as k, useRef as I, useCallback as L, useEffect as Y } from "react";
4
+ import v from "classnames";
5
+ import { r as A, g as T, A as G } from "./index-DJXjS2H9.js";
6
+ import { L as Z, P as O } from "./LoadingDots-Ct3WmVlT.js";
7
+ const z = ({
8
+ variant: t,
9
+ title: a,
10
+ placeholderTitle: n = "Attachment title",
11
+ mimeType: r,
12
+ detail: i,
13
+ statusBadge: s,
14
+ action: c,
15
+ icon: u,
16
+ trailingAction: d
17
+ }) => {
18
+ const l = t === "dark", o = a || n, f = !a, m = u ?? A(r, {
19
+ className: v(
20
+ "size-5 shrink-0",
21
+ l ? "text-white/55" : "text-black/55"
22
+ ),
23
+ weight: "regular"
24
+ });
25
+ return /* @__PURE__ */ h("div", { className: "px-4 py-3", children: [
26
+ /* @__PURE__ */ h("div", { className: "flex items-end gap-3", children: [
27
+ /* @__PURE__ */ h("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
28
+ o.trim() !== "" && /* @__PURE__ */ e(
29
+ "p",
30
+ {
31
+ className: v("truncate text-base font-medium leading-6", {
32
+ "text-black/90": !l && !f,
33
+ "text-black/30": !l && f,
34
+ "text-white/30": l && f,
35
+ "text-white": l && !f
36
+ }),
37
+ children: o
38
+ }
39
+ ),
40
+ /* @__PURE__ */ h("div", { className: "flex flex-wrap items-center gap-1", children: [
41
+ m,
42
+ i != null && i !== "" && /* @__PURE__ */ e(
43
+ "span",
44
+ {
45
+ className: v(
46
+ "text-xs font-medium",
47
+ l ? "text-white/55" : "text-black/55"
48
+ ),
49
+ children: i
50
+ }
51
+ ),
52
+ s
53
+ ] })
54
+ ] }),
55
+ d && /* @__PURE__ */ e("div", { className: "shrink-0", children: d })
56
+ ] }),
57
+ c
58
+ ] });
59
+ }, _ = ({
60
+ paymentStatus: t,
61
+ mimeType: a,
62
+ isPlayable: n,
63
+ isLocked: r
64
+ }) => {
65
+ const i = a ? T(a) : void 0, c = (n ?? (i === "video" || i === "audio")) && !r ? B : t === "paid" ? q : V;
66
+ return /* @__PURE__ */ e("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e(
67
+ "div",
68
+ {
69
+ className: v(
70
+ "flex size-12 items-center justify-center rounded-full bg-black/30 text-white",
71
+ c === B && "group-hover:bg-black/40"
72
+ ),
73
+ children: /* @__PURE__ */ e(c, { className: "size-6", weight: "fill" })
74
+ }
75
+ ) });
76
+ };
77
+ function ee(t) {
78
+ const a = T(t.mimeType);
79
+ return a === "video" || a === "audio";
80
+ }
81
+ const te = ({
82
+ variant: t,
83
+ gallery: a,
84
+ title: n,
85
+ showLocked: r,
86
+ paymentStatus: i,
87
+ topRight: s
88
+ }) => {
89
+ const [c, u] = k(0), d = a.length, l = Math.min(c, d - 1), o = a[l], f = ee(o), m = (g) => {
90
+ g.stopPropagation(), u((p) => Math.max(0, p - 1));
91
+ }, w = (g) => {
92
+ g.stopPropagation(), u((p) => Math.min(d - 1, p + 1));
93
+ }, x = l === 0, b = l === d - 1, N = t === "dark";
94
+ return /* @__PURE__ */ h(
95
+ "div",
96
+ {
97
+ className: v(
98
+ "group relative overflow-hidden rounded-t-md",
99
+ r ? "aspect-[337/386]" : void 0
100
+ ),
101
+ children: [
102
+ r ? /* @__PURE__ */ e(
103
+ "div",
104
+ {
105
+ className: v(
106
+ "absolute inset-0",
107
+ N ? "bg-white/10" : "bg-black/5"
108
+ ),
109
+ children: o.thumbnailUrl && /* @__PURE__ */ e(
110
+ "img",
111
+ {
112
+ src: o.thumbnailUrl,
113
+ alt: "",
114
+ "aria-hidden": !0,
115
+ draggable: !1,
116
+ className: "absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]"
117
+ }
118
+ )
119
+ }
120
+ ) : /* @__PURE__ */ e(
121
+ G,
122
+ {
123
+ mimeType: o.mimeType,
124
+ sourceUrl: o.sourceUrl,
125
+ thumbnailUrl: o.thumbnailUrl,
126
+ title: n,
127
+ variant: t,
128
+ mediaPlayerProps: { autoPlay: !0 }
129
+ },
130
+ l
131
+ ),
132
+ r && /* @__PURE__ */ e(
133
+ _,
134
+ {
135
+ paymentStatus: i,
136
+ isPlayable: f,
137
+ isLocked: r
138
+ }
139
+ ),
140
+ d > 1 && /* @__PURE__ */ h(y.Fragment, { children: [
141
+ /* @__PURE__ */ e(
142
+ "button",
143
+ {
144
+ type: "button",
145
+ onClick: m,
146
+ disabled: x,
147
+ "aria-label": "Previous item",
148
+ className: v(
149
+ "absolute left-3 top-1/2 -translate-y-1/2 flex size-7 items-center justify-center rounded-full bg-black/30 text-white transition-opacity",
150
+ x ? "opacity-40" : "hover:bg-black/40"
151
+ ),
152
+ children: /* @__PURE__ */ e(F, { className: "size-5", weight: "bold" })
153
+ }
154
+ ),
155
+ /* @__PURE__ */ e(
156
+ "button",
157
+ {
158
+ type: "button",
159
+ onClick: w,
160
+ disabled: b,
161
+ "aria-label": "Next item",
162
+ className: v(
163
+ "absolute right-3 top-1/2 -translate-y-1/2 flex size-7 items-center justify-center rounded-full bg-black/30 text-white transition-opacity",
164
+ b ? "opacity-40" : "hover:bg-black/40"
165
+ ),
166
+ children: /* @__PURE__ */ e(H, { className: "size-5", weight: "bold" })
167
+ }
168
+ ),
169
+ /* @__PURE__ */ e("div", { className: "pointer-events-none absolute bottom-10 left-1/2 flex size-8 -translate-x-1/2 items-center justify-center rounded-full bg-black/30", children: /* @__PURE__ */ h("span", { className: "text-xs font-medium leading-none text-white", children: [
170
+ l + 1,
171
+ "/",
172
+ d
173
+ ] }) })
174
+ ] }),
175
+ s && /* @__PURE__ */ e("div", { className: "pointer-events-auto absolute right-3 top-3 z-10", children: s })
176
+ ]
177
+ }
178
+ );
179
+ }, ae = ({
180
+ variant: t,
181
+ mimeType: a,
182
+ thumbnailUrl: n,
183
+ title: r,
184
+ source: i,
185
+ showLocked: s,
186
+ paymentStatus: c,
187
+ topRight: u,
188
+ containedImage: d = !1
189
+ }) => {
190
+ const l = s || i == null ? void 0 : i.sourceUrl, o = s ? n : (i == null ? void 0 : i.thumbnailUrl) ?? n, f = t === "dark";
191
+ return /* @__PURE__ */ h("div", { className: "relative overflow-hidden rounded-t-md", children: [
192
+ s ? /* @__PURE__ */ h(
193
+ "div",
194
+ {
195
+ className: v(
196
+ "relative aspect-video overflow-hidden",
197
+ f ? "bg-white/10" : "bg-black/5"
198
+ ),
199
+ children: [
200
+ o ? /* @__PURE__ */ e(
201
+ "img",
202
+ {
203
+ src: o,
204
+ alt: "",
205
+ "aria-hidden": !0,
206
+ draggable: !1,
207
+ className: "absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]"
208
+ }
209
+ ) : /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: A(a, {
210
+ className: f ? "size-12 text-white/20" : "size-12 text-black/20",
211
+ weight: "regular"
212
+ }) }),
213
+ /* @__PURE__ */ e(
214
+ _,
215
+ {
216
+ paymentStatus: c,
217
+ mimeType: a,
218
+ isLocked: s
219
+ }
220
+ )
221
+ ]
222
+ }
223
+ ) : /* @__PURE__ */ e(
224
+ G,
225
+ {
226
+ mimeType: a,
227
+ sourceUrl: l,
228
+ thumbnailUrl: o,
229
+ title: r,
230
+ variant: t,
231
+ containedImage: d,
232
+ mediaPlayerProps: l ? { autoPlay: !0, loop: !0, controls: !0, muted: !1 } : void 0
233
+ }
234
+ ),
235
+ u && /* @__PURE__ */ e("div", { className: "pointer-events-auto absolute right-3 top-3 z-10", children: u })
236
+ ] });
237
+ }, P = (t) => t.length >= 2, U = (t) => /* @__PURE__ */ e(
238
+ J,
239
+ {
240
+ className: t === "dark" ? "size-5 shrink-0 text-white/55" : "size-5 shrink-0 text-black/55"
241
+ }
242
+ ), j = ({
243
+ variant: t,
244
+ gallery: a,
245
+ title: n,
246
+ showLocked: r,
247
+ paymentStatus: i,
248
+ mimeType: s,
249
+ thumbnailUrl: c,
250
+ source: u,
251
+ containedImage: d,
252
+ topRight: l
253
+ }) => P(a) ? /* @__PURE__ */ e(
254
+ te,
255
+ {
256
+ variant: t,
257
+ gallery: a,
258
+ title: n,
259
+ showLocked: r,
260
+ paymentStatus: i,
261
+ topRight: l
262
+ }
263
+ ) : /* @__PURE__ */ e(
264
+ ae,
265
+ {
266
+ variant: t,
267
+ mimeType: s,
268
+ thumbnailUrl: c,
269
+ title: n,
270
+ source: u,
271
+ showLocked: r,
272
+ paymentStatus: i,
273
+ topRight: l,
274
+ containedImage: d
275
+ }
276
+ ), D = ({
277
+ variant: t,
278
+ children: a,
279
+ rootRef: n,
280
+ "data-testid": r
281
+ }) => /* @__PURE__ */ e(
282
+ "div",
283
+ {
284
+ ref: n,
285
+ "data-testid": r,
286
+ className: v(
287
+ "relative w-[280px] select-none overflow-hidden rounded-md",
288
+ t === "dark" ? "bg-[#1e2330]" : "bg-white",
289
+ "shadow-[0_1px_2px_rgba(0,0,0,0.08)]"
290
+ ),
291
+ children: a
292
+ }
293
+ ), E = ({
294
+ onToggle: t,
295
+ isBusy: a,
296
+ isPreviewVisible: n,
297
+ children: r
298
+ }) => t ? /* @__PURE__ */ e(
299
+ "div",
300
+ {
301
+ role: "button",
302
+ tabIndex: a ? -1 : 0,
303
+ "aria-label": "Toggle preview",
304
+ "aria-busy": a,
305
+ "aria-pressed": n,
306
+ "aria-disabled": a || void 0,
307
+ onClick: a ? void 0 : t,
308
+ onKeyDown: (i) => {
309
+ a || i.target === i.currentTarget && (i.key === "Enter" || i.key === " ") && (i.preventDefault(), t());
310
+ },
311
+ className: a ? "block w-full text-left" : "block w-full cursor-pointer text-left",
312
+ children: r
313
+ }
314
+ ) : /* @__PURE__ */ e(y.Fragment, { children: r });
315
+ function S({
316
+ isGallery: t,
317
+ onFetchSource: a,
318
+ onPreviewClick: n
319
+ }) {
320
+ const [r, i] = k(), [s, c] = k(!1), [u, d] = k(!1), l = I(!1), o = L(async () => {
321
+ if (n == null || n(), s) {
322
+ c(!1);
323
+ return;
324
+ }
325
+ if (t) {
326
+ c(!0);
327
+ return;
328
+ }
329
+ if (r) {
330
+ c(!0);
331
+ return;
332
+ }
333
+ if (a && !l.current) {
334
+ l.current = !0, d(!0);
335
+ try {
336
+ const m = await a();
337
+ m && (i(m), c(!0));
338
+ } finally {
339
+ l.current = !1, d(!1);
340
+ }
341
+ }
342
+ }, [s, t, r, n, a]), f = t || a != null || n != null ? o : void 0;
343
+ return {
344
+ source: r,
345
+ isPreviewVisible: s,
346
+ isLoadingPreview: u,
347
+ handleToggle: o,
348
+ togglePreview: f
349
+ };
350
+ }
351
+ function ie({
352
+ paymentStatus: t,
353
+ onFetchSource: a,
354
+ onUnlockClick: n
355
+ }) {
356
+ const [r, i] = k(), s = I(null), c = I(!1), u = I(a);
357
+ u.current = a;
358
+ const d = L(async () => {
359
+ var o;
360
+ if (!c.current) {
361
+ c.current = !0;
362
+ try {
363
+ const f = await ((o = u.current) == null ? void 0 : o.call(u));
364
+ f && i(f);
365
+ } finally {
366
+ c.current = !1;
367
+ }
368
+ }
369
+ }, []), l = L(() => {
370
+ t === "paid" ? d() : n == null || n();
371
+ }, [t, d, n]);
372
+ return Y(() => {
373
+ if (!s.current || t !== "paid" || r !== void 0) return;
374
+ const o = new IntersectionObserver(
375
+ ([f]) => {
376
+ f.isIntersecting && (d(), o.disconnect());
377
+ },
378
+ { threshold: 1 }
379
+ );
380
+ return o.observe(s.current), () => o.disconnect();
381
+ }, [t, r, d]), { source: r, cardRef: s, handleUnlockClick: l };
382
+ }
383
+ const C = "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]", re = ({
384
+ isLocked: t,
385
+ sourceUrl: a,
386
+ redeemUrl: n,
387
+ onUnlockClicked: r,
388
+ onDownloadClicked: i,
389
+ isUnlocking: s = !1
390
+ }) => {
391
+ if (t && r != null)
392
+ return /* @__PURE__ */ e(
393
+ "button",
394
+ {
395
+ type: "button",
396
+ onClick: r,
397
+ disabled: s,
398
+ "aria-label": s ? "Unlocking" : "Unlock",
399
+ "aria-busy": s,
400
+ title: s ? "Unlocking" : "Unlock",
401
+ className: C,
402
+ children: s ? /* @__PURE__ */ e(Z, {}) : /* @__PURE__ */ h(y.Fragment, { children: [
403
+ /* @__PURE__ */ e(V, { className: "size-4", weight: "fill" }),
404
+ "Unlock"
405
+ ] })
406
+ }
407
+ );
408
+ if (!t && i != null) {
409
+ const c = n ?? a;
410
+ return c != null ? /* @__PURE__ */ h(
411
+ "a",
412
+ {
413
+ href: c,
414
+ "aria-label": "Download",
415
+ target: "_blank",
416
+ rel: "noopener noreferrer",
417
+ onClick: i,
418
+ className: `${C} !text-white`,
419
+ children: [
420
+ /* @__PURE__ */ e(R, { className: "size-4", weight: "bold" }),
421
+ "Download"
422
+ ]
423
+ }
424
+ ) : /* @__PURE__ */ h(
425
+ "button",
426
+ {
427
+ type: "button",
428
+ onClick: i,
429
+ "aria-label": "Download",
430
+ className: C,
431
+ children: [
432
+ /* @__PURE__ */ e(R, { className: "size-4", weight: "bold" }),
433
+ "Download"
434
+ ]
435
+ }
436
+ );
437
+ }
438
+ return null;
439
+ }, ne = ({
440
+ title: t,
441
+ mimeType: a = "application/octet-stream",
442
+ thumbnailUrl: n,
443
+ detail: r,
444
+ amountText: i,
445
+ placeholderTitle: s,
446
+ placeholderAmountText: c,
447
+ gallery: u = [],
448
+ onDismiss: d,
449
+ onPreviewClick: l,
450
+ onFetchSource: o,
451
+ onEditClick: f
452
+ }) => {
453
+ const m = P(u), { source: w, isPreviewVisible: x, isLoadingPreview: b, togglePreview: N } = S({ isGallery: m, onFetchSource: o, onPreviewClick: l }), g = !x, p = b, M = /* @__PURE__ */ h(y.Fragment, { children: [
454
+ /* @__PURE__ */ e("span", { className: "text-xs font-medium text-white/55", children: "•" }),
455
+ /* @__PURE__ */ e(
456
+ "span",
457
+ {
458
+ className: i ? "text-xs font-medium text-white/55" : "text-xs font-medium text-white/30",
459
+ children: i || c
460
+ }
461
+ )
462
+ ] }), K = d ? /* @__PURE__ */ e(
463
+ "button",
464
+ {
465
+ type: "button",
466
+ onClick: ($) => {
467
+ $.stopPropagation(), d();
468
+ },
469
+ className: "flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",
470
+ "aria-label": "Dismiss attachment",
471
+ children: /* @__PURE__ */ e(Q, { className: "size-3", weight: "bold" })
472
+ }
473
+ ) : void 0, X = f ? /* @__PURE__ */ e(
474
+ "button",
475
+ {
476
+ type: "button",
477
+ onClick: f,
478
+ "aria-label": "Edit attachment",
479
+ className: "flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",
480
+ children: /* @__PURE__ */ e(W, { className: "size-5", weight: "regular" })
481
+ }
482
+ ) : void 0;
483
+ return /* @__PURE__ */ h(D, { variant: "dark", children: [
484
+ /* @__PURE__ */ e(
485
+ E,
486
+ {
487
+ onToggle: N,
488
+ isBusy: p,
489
+ isPreviewVisible: !g,
490
+ children: /* @__PURE__ */ e(
491
+ j,
492
+ {
493
+ variant: "dark",
494
+ gallery: u,
495
+ title: t,
496
+ showLocked: g,
497
+ mimeType: a,
498
+ thumbnailUrl: n,
499
+ source: w,
500
+ topRight: K
501
+ }
502
+ )
503
+ }
504
+ ),
505
+ /* @__PURE__ */ e(
506
+ z,
507
+ {
508
+ variant: "dark",
509
+ title: t,
510
+ placeholderTitle: s,
511
+ mimeType: a,
512
+ detail: r,
513
+ statusBadge: M,
514
+ icon: m ? U("dark") : void 0,
515
+ trailingAction: X
516
+ }
517
+ )
518
+ ] });
519
+ }, se = ({
520
+ title: t,
521
+ mimeType: a = "application/octet-stream",
522
+ thumbnailUrl: n,
523
+ detail: r,
524
+ amountText: i,
525
+ placeholderTitle: s,
526
+ placeholderAmountText: c,
527
+ gallery: u = []
528
+ }) => {
529
+ const d = P(u), l = /* @__PURE__ */ h(y.Fragment, { children: [
530
+ /* @__PURE__ */ e("span", { className: "text-xs font-medium text-black/55", children: "•" }),
531
+ /* @__PURE__ */ e(
532
+ "span",
533
+ {
534
+ className: i ? "text-xs font-medium text-black/55" : "text-xs font-medium text-black/30",
535
+ children: i || c
536
+ }
537
+ )
538
+ ] });
539
+ return /* @__PURE__ */ h(D, { variant: "light", children: [
540
+ /* @__PURE__ */ e(
541
+ j,
542
+ {
543
+ variant: "light",
544
+ gallery: u,
545
+ title: t,
546
+ showLocked: !0,
547
+ mimeType: a,
548
+ thumbnailUrl: n
549
+ }
550
+ ),
551
+ /* @__PURE__ */ e(
552
+ z,
553
+ {
554
+ variant: "light",
555
+ title: t,
556
+ placeholderTitle: s,
557
+ mimeType: a,
558
+ detail: r,
559
+ statusBadge: l,
560
+ icon: d ? U("light") : void 0
561
+ }
562
+ )
563
+ ] });
564
+ }, le = ({
565
+ title: t,
566
+ mimeType: a = "application/octet-stream",
567
+ thumbnailUrl: n,
568
+ detail: r,
569
+ amountText: i,
570
+ placeholderTitle: s,
571
+ paymentStatus: c = "pending",
572
+ gallery: u = [],
573
+ onPreviewClick: d,
574
+ onFetchSource: l
575
+ }) => {
576
+ const o = P(u), { source: f, isPreviewVisible: m, isLoadingPreview: w, togglePreview: x } = S({ isGallery: o, onFetchSource: l, onPreviewClick: d }), b = !m;
577
+ return /* @__PURE__ */ h(D, { variant: "dark", children: [
578
+ /* @__PURE__ */ e(
579
+ E,
580
+ {
581
+ onToggle: x,
582
+ isBusy: w,
583
+ isPreviewVisible: !b,
584
+ children: /* @__PURE__ */ e(
585
+ j,
586
+ {
587
+ variant: "dark",
588
+ gallery: u,
589
+ title: t,
590
+ showLocked: b,
591
+ paymentStatus: c,
592
+ mimeType: a,
593
+ thumbnailUrl: n,
594
+ source: f
595
+ }
596
+ )
597
+ }
598
+ ),
599
+ /* @__PURE__ */ e(
600
+ z,
601
+ {
602
+ variant: "dark",
603
+ title: t,
604
+ placeholderTitle: s,
605
+ mimeType: a,
606
+ detail: r,
607
+ statusBadge: /* @__PURE__ */ e(
608
+ O,
609
+ {
610
+ isMine: !0,
611
+ paymentStatus: c,
612
+ amountText: i
613
+ }
614
+ ),
615
+ icon: o ? U("dark") : void 0
616
+ }
617
+ )
618
+ ] });
619
+ }, ce = ({
620
+ title: t,
621
+ amountText: a,
622
+ thumbnailUrl: n,
623
+ mimeType: r = "application/octet-stream",
624
+ detail: i,
625
+ gallery: s = [],
626
+ onUnlockClick: c,
627
+ onFetchSource: u,
628
+ onDownloadClick: d,
629
+ paymentStatus: l,
630
+ isUnlocking: o = !1
631
+ }) => {
632
+ const f = P(s), { source: m, cardRef: w, handleUnlockClick: x } = ie({
633
+ paymentStatus: l,
634
+ onFetchSource: u,
635
+ onUnlockClick: c
636
+ }), b = m == null ? void 0 : m.sourceUrl, N = m == null ? void 0 : m.redeemUrl, g = f ? l !== "paid" : b === void 0, p = T(r), M = f ? void 0 : b;
637
+ return /* @__PURE__ */ h(
638
+ D,
639
+ {
640
+ variant: "light",
641
+ rootRef: w,
642
+ "data-testid": "locked-attachment",
643
+ children: [
644
+ /* @__PURE__ */ e(
645
+ j,
646
+ {
647
+ variant: "light",
648
+ gallery: s,
649
+ title: t,
650
+ showLocked: g,
651
+ paymentStatus: l,
652
+ mimeType: r,
653
+ thumbnailUrl: n,
654
+ source: m,
655
+ containedImage: !g && p === "document"
656
+ }
657
+ ),
658
+ /* @__PURE__ */ e(
659
+ z,
660
+ {
661
+ variant: "light",
662
+ title: t,
663
+ mimeType: r,
664
+ detail: i,
665
+ statusBadge: /* @__PURE__ */ e(
666
+ O,
667
+ {
668
+ isMine: !1,
669
+ paymentStatus: l,
670
+ amountText: a
671
+ }
672
+ ),
673
+ icon: f ? U("light") : void 0,
674
+ action: /* @__PURE__ */ e(
675
+ re,
676
+ {
677
+ isLocked: g,
678
+ isUnlocking: o,
679
+ sourceUrl: M,
680
+ redeemUrl: N,
681
+ onUnlockClicked: x,
682
+ onDownloadClicked: d
683
+ }
684
+ )
685
+ }
686
+ )
687
+ ]
688
+ }
689
+ );
690
+ }, be = (t) => t.isDraft ? /* @__PURE__ */ e(ne, { ...t }) : t.isPreview ? /* @__PURE__ */ e(se, { ...t }) : t.isMine ? /* @__PURE__ */ e(le, { ...t }) : /* @__PURE__ */ e(ce, { ...t });
691
+ export {
692
+ be as default
693
+ };
694
+ //# sourceMappingURL=Card-BnbNynLQ.js.map