@linktr.ee/messaging-react 4.2.1 → 4.3.0-rc-1787410254

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