@linktr.ee/messaging-react 3.9.0-rc-1783407048 → 3.9.0-rc-1783472582

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 (64) hide show
  1. package/dist/{Card-qDLtjK6u.js → Card-BVZM0-06.js} +26 -26
  2. package/dist/Card-BVZM0-06.js.map +1 -0
  3. package/dist/{Card-DX9nBx1S.js → Card-D0hLrOxX.js} +61 -61
  4. package/dist/Card-D0hLrOxX.js.map +1 -0
  5. package/dist/Card-DIr1UnfC.cjs +2 -0
  6. package/dist/Card-DIr1UnfC.cjs.map +1 -0
  7. package/dist/Card-DeSgaRTL.cjs +2 -0
  8. package/dist/Card-DeSgaRTL.cjs.map +1 -0
  9. package/dist/Card-DnaXMVrT.cjs +2 -0
  10. package/dist/Card-DnaXMVrT.cjs.map +1 -0
  11. package/dist/Card-xv52Ug43.js +61 -0
  12. package/dist/Card-xv52Ug43.js.map +1 -0
  13. package/dist/LoadingDots-Cn2y7g7L.cjs +2 -0
  14. package/dist/LoadingDots-Cn2y7g7L.cjs.map +1 -0
  15. package/dist/LoadingDots-nW6r0-Kg.js +62 -0
  16. package/dist/LoadingDots-nW6r0-Kg.js.map +1 -0
  17. package/dist/TextShell-CKQOFxoH.cjs +2 -0
  18. package/dist/TextShell-CKQOFxoH.cjs.map +1 -0
  19. package/dist/TextShell-DIyj9zQ7.js +40 -0
  20. package/dist/TextShell-DIyj9zQ7.js.map +1 -0
  21. package/dist/{index-CZTUyiPe.js → index-B8gqCioX.js} +2 -2
  22. package/dist/{index-CZTUyiPe.js.map → index-B8gqCioX.js.map} +1 -1
  23. package/dist/{index-DwUOvMxg.cjs → index-IkikzyWM.cjs} +2 -2
  24. package/dist/{index-DwUOvMxg.cjs.map → index-IkikzyWM.cjs.map} +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/usePreviewToggle-B0B8cfxy.cjs +2 -0
  28. package/dist/usePreviewToggle-B0B8cfxy.cjs.map +1 -0
  29. package/dist/usePreviewToggle-DRhRTUou.js +357 -0
  30. package/dist/usePreviewToggle-DRhRTUou.js.map +1 -0
  31. package/package.json +2 -2
  32. package/src/components/LockedAttachment/LockedAttachment.stories.tsx +19 -14
  33. package/src/components/LockedAttachment/components/Composer/Card.tsx +5 -2
  34. package/src/components/LockedAttachment/components/Media/Card.tsx +1 -3
  35. package/src/components/LockedAttachment/components/Media/CardActions.tsx +3 -1
  36. package/src/components/LockedAttachment/components/Text/Card.tsx +4 -4
  37. package/src/components/LockedAttachment/components/_shared/GalleryThumbnail.tsx +24 -10
  38. package/src/components/LockedAttachment/components/_shared/LockBadge.tsx +23 -9
  39. package/src/components/LockedAttachment/components/_shared/MediaShell.tsx +1 -2
  40. package/src/components/LockedAttachment/components/_shared/PurchaseStatusBadge.tsx +0 -1
  41. package/src/components/LockedAttachment/components/_shared/SingleThumbnail.tsx +5 -1
  42. package/src/components/LockedAttachment/components/_shared/TextShell.tsx +4 -4
  43. package/dist/Card-D8yiJ8Uw.cjs +0 -2
  44. package/dist/Card-D8yiJ8Uw.cjs.map +0 -1
  45. package/dist/Card-DSG-wR8t.js +0 -96
  46. package/dist/Card-DSG-wR8t.js.map +0 -1
  47. package/dist/Card-DVfSiq9b.cjs +0 -2
  48. package/dist/Card-DVfSiq9b.cjs.map +0 -1
  49. package/dist/Card-DX9nBx1S.js.map +0 -1
  50. package/dist/Card-iKTcn1wg.cjs +0 -2
  51. package/dist/Card-iKTcn1wg.cjs.map +0 -1
  52. package/dist/Card-qDLtjK6u.js.map +0 -1
  53. package/dist/PurchaseStatusBadge-CJH4S-8Z.js +0 -36
  54. package/dist/PurchaseStatusBadge-CJH4S-8Z.js.map +0 -1
  55. package/dist/PurchaseStatusBadge-UjDzZhLj.cjs +0 -2
  56. package/dist/PurchaseStatusBadge-UjDzZhLj.cjs.map +0 -1
  57. package/dist/TextShell-BiqF2UB0.js +0 -32
  58. package/dist/TextShell-BiqF2UB0.js.map +0 -1
  59. package/dist/TextShell-Bnzh0T75.cjs +0 -2
  60. package/dist/TextShell-Bnzh0T75.cjs.map +0 -1
  61. package/dist/usePreviewToggle-BG-pfsgP.js +0 -323
  62. package/dist/usePreviewToggle-BG-pfsgP.js.map +0 -1
  63. package/dist/usePreviewToggle-DXQT07ws.cjs +0 -2
  64. package/dist/usePreviewToggle-DXQT07ws.cjs.map +0 -1
@@ -1,16 +1,16 @@
1
1
  import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
2
  import { XIcon as m, PencilSimpleIcon as z } from "@phosphor-icons/react";
3
3
  import B from "react";
4
- import { i as j, u as T, M as I, P as L, C as M, a as R, g as S } from "./usePreviewToggle-BG-pfsgP.js";
5
- import { T as A, P as G } from "./TextShell-BiqF2UB0.js";
6
- const V = ({
4
+ import { i as T, u as j, M as S, P as L, C as M, a as I, g as R } from "./usePreviewToggle-DRhRTUou.js";
5
+ import { T as A, S as G, P as V } from "./TextShell-DIyj9zQ7.js";
6
+ const F = ({
7
7
  text: t,
8
8
  amountText: i,
9
9
  placeholderAmountText: s,
10
10
  onDismiss: a
11
- }) => /* @__PURE__ */ r(A, { children: [
12
- /* @__PURE__ */ e("div", { className: "pr-8", children: t }),
13
- /* @__PURE__ */ e(G, { children: /* @__PURE__ */ e("span", { className: i ? "text-white/55" : "text-white/30", children: i || s }) }),
11
+ }) => /* @__PURE__ */ r(A, { isMine: !0, children: [
12
+ /* @__PURE__ */ e("div", { className: "pr-8", children: t || /* @__PURE__ */ e(G, { variant: "dark", animate: !1 }) }),
13
+ /* @__PURE__ */ e(V, { children: /* @__PURE__ */ e("span", { className: i ? "text-white/55" : "text-white/30", children: i || s }) }),
14
14
  a && /* @__PURE__ */ e(
15
15
  "button",
16
16
  {
@@ -21,41 +21,41 @@ const V = ({
21
21
  children: /* @__PURE__ */ e(m, { className: "size-3", weight: "bold" })
22
22
  }
23
23
  )
24
- ] }), F = ({
24
+ ] }), X = ({
25
25
  title: t,
26
26
  mimeType: i = "application/octet-stream",
27
27
  thumbnailUrl: s,
28
28
  detail: a,
29
- amountText: o,
29
+ amountText: n,
30
30
  placeholderTitle: u = "Attachment title",
31
31
  placeholderAmountText: g,
32
- gallery: n = [],
32
+ gallery: o = [],
33
33
  onDismiss: l,
34
34
  onPreviewClick: w,
35
35
  onFetchSource: x,
36
36
  onEditClick: c
37
37
  }) => {
38
- const d = j(n), { source: b, isPreviewVisible: p, isLoadingPreview: f, togglePreview: v } = T({ isGallery: d, onFetchSource: x, onPreviewClick: w }), h = !p, C = f, y = /* @__PURE__ */ r(B.Fragment, { children: [
38
+ const d = T(o), { source: b, isPreviewVisible: f, isLoadingPreview: p, togglePreview: v } = j({ isGallery: d, onFetchSource: x, onPreviewClick: w }), h = !f, C = p, k = /* @__PURE__ */ r(B.Fragment, { children: [
39
39
  /* @__PURE__ */ e("span", { className: "text-xs font-medium text-white/55", children: "•" }),
40
40
  /* @__PURE__ */ e(
41
41
  "span",
42
42
  {
43
- className: o ? "text-xs font-medium text-white/55" : "text-xs font-medium text-white/30",
44
- children: o || g
43
+ className: n ? "text-xs font-medium text-white/55" : "text-xs font-medium text-white/30",
44
+ children: n || g
45
45
  }
46
46
  )
47
- ] }), P = l ? /* @__PURE__ */ e(
47
+ ] }), y = l ? /* @__PURE__ */ e(
48
48
  "button",
49
49
  {
50
50
  type: "button",
51
- onClick: (k) => {
52
- k.stopPropagation(), l();
51
+ onClick: (N) => {
52
+ N.stopPropagation(), l();
53
53
  },
54
54
  className: "flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",
55
55
  "aria-label": "Dismiss attachment",
56
56
  children: /* @__PURE__ */ e(m, { className: "size-3", weight: "bold" })
57
57
  }
58
- ) : void 0, N = c ? /* @__PURE__ */ e(
58
+ ) : void 0, P = c ? /* @__PURE__ */ e(
59
59
  "button",
60
60
  {
61
61
  type: "button",
@@ -65,7 +65,7 @@ const V = ({
65
65
  children: /* @__PURE__ */ e(z, { className: "size-5", weight: "regular" })
66
66
  }
67
67
  ) : void 0;
68
- return /* @__PURE__ */ r(I, { variant: "dark", children: [
68
+ return /* @__PURE__ */ r(S, { variant: "dark", children: [
69
69
  /* @__PURE__ */ e(
70
70
  L,
71
71
  {
@@ -76,33 +76,33 @@ const V = ({
76
76
  M,
77
77
  {
78
78
  variant: "dark",
79
- gallery: n,
79
+ gallery: o,
80
80
  title: t,
81
81
  showLocked: h,
82
82
  mimeType: i,
83
83
  thumbnailUrl: s,
84
84
  source: b,
85
- topRight: P
85
+ topRight: y
86
86
  }
87
87
  )
88
88
  }
89
89
  ),
90
90
  /* @__PURE__ */ e(
91
- R,
91
+ I,
92
92
  {
93
93
  variant: "dark",
94
94
  title: t,
95
95
  placeholderTitle: u,
96
96
  mimeType: i,
97
97
  detail: a,
98
- statusBadge: y,
99
- icon: d ? S("dark") : void 0,
100
- trailingAction: N
98
+ statusBadge: k,
99
+ icon: d ? R("dark") : void 0,
100
+ trailingAction: P
101
101
  }
102
102
  )
103
103
  ] });
104
- }, J = (t) => t.contentType === "text" ? /* @__PURE__ */ e(V, { ...t }) : /* @__PURE__ */ e(F, { ...t });
104
+ }, K = (t) => t.contentType === "text" ? /* @__PURE__ */ e(F, { ...t }) : /* @__PURE__ */ e(X, { ...t });
105
105
  export {
106
- J as default
106
+ K as default
107
107
  };
108
- //# sourceMappingURL=Card-qDLtjK6u.js.map
108
+ //# sourceMappingURL=Card-BVZM0-06.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-BVZM0-06.js","sources":["../src/components/LockedAttachment/components/Composer/Card.tsx"],"sourcesContent":["import { PencilSimpleIcon, XIcon } from '@phosphor-icons/react'\nimport React from 'react'\n\nimport type { FetchSourceHandler, LockedAttachmentBaseProps } from '../../types'\nimport CardBody from '../_shared/CardBody'\nimport CardThumbnail, {\n galleryBodyIcon,\n isGalleryCard,\n} from '../_shared/CardThumbnail'\nimport MediaShell from '../_shared/MediaShell'\nimport PreviewToggle from '../_shared/PreviewToggle'\nimport PriceLockRow from '../_shared/PriceLockRow'\nimport SkeletonTextLines from '../_shared/SkeletonTextLines'\nimport TextShell from '../_shared/TextShell'\nimport { usePreviewToggle } from '../_shared/usePreviewToggle'\n\nexport interface ComposerCardProps extends LockedAttachmentBaseProps {\n /**\n * The message's own text, shown as-is (not redacted yet — the message\n * hasn't been sent). Only used when `contentType` is `\"text\"`.\n */\n text?: string\n /** Placeholder shown in the amount slot before one is configured. */\n placeholderAmountText?: string\n /**\n * Renders a persistent dismiss X on the thumbnail (media) or next to the\n * text (text mode); called to remove the draft attachment. Unrelated to\n * `TextCardProps.onDismiss`, which only appears for `isMine` after a\n * failed payment.\n */\n onDismiss?: () => void\n /** Fired the first time the composer taps the thumbnail to preview. */\n onPreviewClick?: () => void\n /**\n * Lazily loads the underlying source so the composer can preview the\n * attachment they're about to send. Called the first time the thumbnail is\n * tapped; the returned source is cached and reused on subsequent toggles.\n * Ignored when `contentType` is `\"text\"`.\n */\n onFetchSource?: FetchSourceHandler\n /**\n * When provided, renders a pencil button in the body bottom-right that the\n * composer can use to edit the attachment metadata (e.g. open the price /\n * gallery editor). Matches the Composer \"Button\" instance in Figma.\n */\n onEditClick?: () => void\n}\n\n/**\n * Composer card in text mode: a normal outgoing chat bubble showing the real\n * draft text (it hasn't been sent/redacted yet) plus a dismiss X and a price\n * row. Media-only props are ignored here.\n */\nconst ComposerTextCard: React.FC<ComposerCardProps> = ({\n text,\n amountText,\n placeholderAmountText,\n onDismiss,\n}) => (\n <TextShell isMine>\n <div className=\"pr-8\">\n {text ? text : <SkeletonTextLines variant=\"dark\" animate={false} />}\n </div>\n <PriceLockRow>\n <span className={amountText ? 'text-white/55' : 'text-white/30'}>\n {amountText || placeholderAmountText}\n </span>\n </PriceLockRow>\n {onDismiss && (\n <button\n type=\"button\"\n onClick={onDismiss}\n className=\"absolute right-3 top-3 flex size-6 shrink-0 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15\"\n aria-label=\"Dismiss attachment\"\n >\n <XIcon className=\"size-3\" weight=\"bold\" />\n </button>\n )}\n </TextShell>\n)\n\n/**\n * Composer card in media mode: the locked thumbnail (single or gallery) the\n * composer taps to preview the attachment they're about to send, plus the\n * title/price body with optional dismiss X and edit pencil.\n */\nconst ComposerMediaCard: React.FC<ComposerCardProps> = ({\n title,\n mimeType = 'application/octet-stream',\n thumbnailUrl,\n detail,\n amountText,\n placeholderTitle = 'Attachment title',\n placeholderAmountText,\n gallery = [],\n onDismiss,\n onPreviewClick,\n onFetchSource,\n onEditClick,\n}) => {\n const isGallery = isGalleryCard(gallery)\n\n // Gallery is always previewable in the composer because each item's source\n // is already provided up-front via `gallery[*].sourceUrl`.\n const { source, isPreviewVisible, isLoadingPreview, togglePreview } =\n usePreviewToggle({ isGallery, onFetchSource, onPreviewClick })\n\n const showLocked = !isPreviewVisible\n const isBusy = isLoadingPreview\n\n const statusBadge = (\n <React.Fragment>\n <span className=\"text-xs font-medium text-white/55\">&bull;</span>\n <span\n className={\n amountText\n ? 'text-xs font-medium text-white/55'\n : 'text-xs font-medium text-white/30'\n }\n >\n {amountText || placeholderAmountText}\n </span>\n </React.Fragment>\n )\n\n const dismissButton = onDismiss ? (\n <button\n type=\"button\"\n onClick={(e) => {\n // Stop the click from bubbling up into the outer preview-toggle\n // wrapper when both are wired up at the same time.\n e.stopPropagation()\n onDismiss()\n }}\n className=\"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white\"\n aria-label=\"Dismiss attachment\"\n >\n <XIcon className=\"size-3\" weight=\"bold\" />\n </button>\n ) : undefined\n\n const editButton = onEditClick ? (\n <button\n type=\"button\"\n onClick={onEditClick}\n aria-label=\"Edit attachment\"\n className=\"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15\"\n >\n <PencilSimpleIcon className=\"size-5\" weight=\"regular\" />\n </button>\n ) : undefined\n\n return (\n <MediaShell variant=\"dark\">\n <PreviewToggle\n onToggle={togglePreview}\n isBusy={isBusy}\n isPreviewVisible={!showLocked}\n >\n <CardThumbnail\n variant=\"dark\"\n gallery={gallery}\n title={title}\n showLocked={showLocked}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n source={source}\n topRight={dismissButton}\n />\n </PreviewToggle>\n\n <CardBody\n variant=\"dark\"\n title={title}\n placeholderTitle={placeholderTitle}\n mimeType={mimeType}\n detail={detail}\n statusBadge={statusBadge}\n icon={isGallery ? galleryBodyIcon('dark') : undefined}\n trailingAction={editButton}\n />\n </MediaShell>\n )\n}\n\n/**\n * The card the composer sees while drafting a paid attachment.\n * Matches the Composer column of the messaging design system in Figma.\n *\n * When `contentType === \"text\"`, renders as a normal outgoing chat bubble\n * showing the real draft text (it hasn't been sent/redacted yet) plus a\n * dismiss X and a price row, instead of a media thumbnail card.\n */\nconst ComposerCard: React.FC<ComposerCardProps> = (props) =>\n props.contentType === 'text' ? (\n <ComposerTextCard {...props} />\n ) : (\n <ComposerMediaCard {...props} />\n )\n\nexport default ComposerCard\n"],"names":["ComposerTextCard","text","amountText","placeholderAmountText","onDismiss","jsxs","TextShell","jsx","SkeletonTextLines","PriceLockRow","XIcon","ComposerMediaCard","title","mimeType","thumbnailUrl","detail","placeholderTitle","gallery","onPreviewClick","onFetchSource","onEditClick","isGallery","isGalleryCard","source","isPreviewVisible","isLoadingPreview","togglePreview","usePreviewToggle","showLocked","isBusy","statusBadge","React","dismissButton","e","editButton","PencilSimpleIcon","MediaShell","PreviewToggle","CardThumbnail","CardBody","galleryBodyIcon","ComposerCard","props"],"mappings":";;;;;AAqDA,MAAMA,IAAgD,CAAC;AAAA,EACrD,MAAAC;AAAA,EACA,YAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,WAAAC;AACF,MACE,gBAAAC,EAACC,GAAA,EAAU,QAAM,IACf,UAAA;AAAA,EAAA,gBAAAC,EAAC,OAAA,EAAI,WAAU,QACZ,UAAAN,KAAc,gBAAAM,EAACC,GAAA,EAAkB,SAAQ,QAAO,SAAS,GAAA,CAAO,GACnE;AAAA,EACA,gBAAAD,EAACE,GAAA,EACC,UAAA,gB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sx as r, jsxs as m } from "react/jsx-runtime";
1
+ import { jsx as r, jsxs as v } from "react/jsx-runtime";
2
2
  import "classnames";
3
- import { LockSimpleIcon as U, DownloadSimpleIcon as M } from "@phosphor-icons/react";
4
- import j, { useState as G, useRef as p, useCallback as R, useEffect as O } from "react";
5
- import { g as T } from "./index-CZTUyiPe.js";
6
- import { i as B, u as A, M as N, P as D, C as k, a as I, g as y } from "./usePreviewToggle-BG-pfsgP.js";
7
- import { P as z } from "./PurchaseStatusBadge-CJH4S-8Z.js";
8
- function S({
3
+ import { LockSimpleIcon as j, DownloadSimpleIcon as x } from "@phosphor-icons/react";
4
+ import z, { useState as D, useRef as p, useCallback as M, useEffect as G } from "react";
5
+ import { g as O } from "./index-B8gqCioX.js";
6
+ import { i as R, u as T, M as B, P as A, C as k, a as I, g as L } from "./usePreviewToggle-DRhRTUou.js";
7
+ import { L as S, P as N } from "./LoadingDots-nW6r0-Kg.js";
8
+ function V({
9
9
  paymentStatus: e,
10
10
  onFetchSource: c,
11
- onUnlockClick: a
11
+ onUnlockClick: o
12
12
  }) {
13
- const [t, l] = G(), i = p(null), n = p(!1), d = p(c);
13
+ const [t, l] = D(), i = p(null), n = p(!1), d = p(c);
14
14
  d.current = c;
15
- const f = R(async () => {
15
+ const f = M(async () => {
16
16
  var s;
17
17
  if (!n.current) {
18
18
  n.current = !0;
19
19
  try {
20
- const o = await ((s = d.current) == null ? void 0 : s.call(d));
21
- o && l(o);
20
+ const a = await ((s = d.current) == null ? void 0 : s.call(d));
21
+ a && l(a);
22
22
  } finally {
23
23
  n.current = !1;
24
24
  }
25
25
  }
26
- }, []), h = R(() => {
27
- e === "paid" ? f() : a == null || a();
28
- }, [e, f, a]);
29
- return O(() => {
26
+ }, []), g = M(() => {
27
+ e === "paid" ? f() : o == null || o();
28
+ }, [e, f, o]);
29
+ return G(() => {
30
30
  if (!i.current || e !== "paid" || t !== void 0) return;
31
31
  const s = new IntersectionObserver(
32
- ([o]) => {
33
- o.isIntersecting && (f(), s.disconnect());
32
+ ([a]) => {
33
+ a.isIntersecting && (f(), s.disconnect());
34
34
  },
35
35
  { threshold: 1 }
36
36
  );
37
37
  return s.observe(i.current), () => s.disconnect();
38
- }, [e, t, f]), { source: t, cardRef: i, handleUnlockClick: h };
38
+ }, [e, t, f]), { source: t, cardRef: i, handleUnlockClick: g };
39
39
  }
40
- 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] disabled:opacity-70", V = ({
40
+ 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] disabled:opacity-70", E = ({
41
41
  isLocked: e,
42
42
  sourceUrl: c,
43
- redeemUrl: a,
43
+ redeemUrl: o,
44
44
  onUnlockClicked: t,
45
45
  onDownloadClicked: l,
46
46
  isUnlocking: i = !1
@@ -53,15 +53,15 @@ const C = "mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounde
53
53
  onClick: t,
54
54
  disabled: i,
55
55
  className: C,
56
- children: i ? /* @__PURE__ */ r("span", { className: "size-4 animate-spin rounded-full border-2 border-white/30 border-t-white" }) : /* @__PURE__ */ m(j.Fragment, { children: [
57
- /* @__PURE__ */ r(U, { className: "size-4", weight: "fill" }),
56
+ children: i ? /* @__PURE__ */ r(S, {}) : /* @__PURE__ */ v(z.Fragment, { children: [
57
+ /* @__PURE__ */ r(j, { className: "size-4", weight: "fill" }),
58
58
  "Unlock"
59
59
  ] })
60
60
  }
61
61
  );
62
62
  if (!e && l != null) {
63
- const n = a ?? c;
64
- return n != null ? /* @__PURE__ */ m(
63
+ const n = o ?? c;
64
+ return n != null ? /* @__PURE__ */ v(
65
65
  "a",
66
66
  {
67
67
  href: n,
@@ -70,55 +70,55 @@ const C = "mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounde
70
70
  onClick: l,
71
71
  className: `${C} !text-white`,
72
72
  children: [
73
- /* @__PURE__ */ r(M, { className: "size-4", weight: "bold" }),
73
+ /* @__PURE__ */ r(x, { className: "size-4", weight: "bold" }),
74
74
  "Download"
75
75
  ]
76
76
  }
77
- ) : /* @__PURE__ */ m(
77
+ ) : /* @__PURE__ */ v(
78
78
  "button",
79
79
  {
80
80
  type: "button",
81
81
  onClick: l,
82
82
  className: C,
83
83
  children: [
84
- /* @__PURE__ */ r(M, { className: "size-4", weight: "bold" }),
84
+ /* @__PURE__ */ r(x, { className: "size-4", weight: "bold" }),
85
85
  "Download"
86
86
  ]
87
87
  }
88
88
  );
89
89
  }
90
90
  return null;
91
- }, E = ({
91
+ }, _ = ({
92
92
  title: e,
93
93
  mimeType: c = "application/octet-stream",
94
- thumbnailUrl: a,
94
+ thumbnailUrl: o,
95
95
  detail: t,
96
96
  amountText: l,
97
97
  placeholderTitle: i = "Attachment title",
98
98
  paymentStatus: n = "pending",
99
99
  gallery: d = [],
100
100
  onPreviewClick: f,
101
- onFetchSource: h
101
+ onFetchSource: g
102
102
  }) => {
103
- const s = B(d), { source: o, isPreviewVisible: u, isLoadingPreview: v, togglePreview: b } = A({ isGallery: s, onFetchSource: h, onPreviewClick: f }), g = !u;
104
- return /* @__PURE__ */ m(N, { variant: "dark", children: [
103
+ const s = R(d), { source: a, isPreviewVisible: u, isLoadingPreview: m, togglePreview: b } = T({ isGallery: s, onFetchSource: g, onPreviewClick: f }), h = !u;
104
+ return /* @__PURE__ */ v(B, { variant: "dark", children: [
105
105
  /* @__PURE__ */ r(
106
- D,
106
+ A,
107
107
  {
108
108
  onToggle: b,
109
- isBusy: v,
110
- isPreviewVisible: !g,
109
+ isBusy: m,
110
+ isPreviewVisible: !h,
111
111
  children: /* @__PURE__ */ r(
112
112
  k,
113
113
  {
114
114
  variant: "dark",
115
115
  gallery: d,
116
116
  title: e,
117
- showLocked: g,
117
+ showLocked: h,
118
118
  paymentStatus: n,
119
119
  mimeType: c,
120
- thumbnailUrl: a,
121
- source: o
120
+ thumbnailUrl: o,
121
+ source: a
122
122
  }
123
123
  )
124
124
  }
@@ -132,40 +132,40 @@ const C = "mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounde
132
132
  mimeType: c,
133
133
  detail: t,
134
134
  statusBadge: /* @__PURE__ */ r(
135
- z,
135
+ N,
136
136
  {
137
137
  isMine: !0,
138
138
  paymentStatus: n,
139
139
  amountText: l
140
140
  }
141
141
  ),
142
- icon: s ? y("dark") : void 0
142
+ icon: s ? L("dark") : void 0
143
143
  }
144
144
  )
145
145
  ] });
146
- }, _ = ({
146
+ }, $ = ({
147
147
  title: e,
148
148
  amountText: c,
149
- thumbnailUrl: a,
149
+ thumbnailUrl: o,
150
150
  mimeType: t = "application/octet-stream",
151
151
  detail: l,
152
152
  gallery: i = [],
153
153
  onUnlockClick: n,
154
154
  onFetchSource: d,
155
155
  onDownloadClick: f,
156
- paymentStatus: h,
156
+ paymentStatus: g,
157
157
  isUnlocking: s = !1
158
158
  }) => {
159
- const o = B(i), { source: u, cardRef: v, handleUnlockClick: b } = S({
160
- paymentStatus: h,
159
+ const a = R(i), { source: u, cardRef: m, handleUnlockClick: b } = V({
160
+ paymentStatus: g,
161
161
  onFetchSource: d,
162
162
  onUnlockClick: n
163
- }), g = u == null ? void 0 : u.sourceUrl, P = u == null ? void 0 : u.redeemUrl, w = o ? h !== "paid" : g === void 0, x = T(t), L = o ? void 0 : g;
164
- return /* @__PURE__ */ m(
165
- N,
163
+ }), h = u == null ? void 0 : u.sourceUrl, P = u == null ? void 0 : u.redeemUrl, w = a ? g !== "paid" : h === void 0, y = O(t), U = a ? void 0 : h;
164
+ return /* @__PURE__ */ v(
165
+ B,
166
166
  {
167
167
  variant: "light",
168
- rootRef: v,
168
+ rootRef: m,
169
169
  "data-testid": "locked-attachment",
170
170
  children: [
171
171
  /* @__PURE__ */ r(
@@ -175,11 +175,11 @@ const C = "mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounde
175
175
  gallery: i,
176
176
  title: e,
177
177
  showLocked: w,
178
- paymentStatus: h,
178
+ paymentStatus: g,
179
179
  mimeType: t,
180
- thumbnailUrl: a,
180
+ thumbnailUrl: o,
181
181
  source: u,
182
- containedImage: !w && (x === "image" || x === "document")
182
+ containedImage: !w && y === "document"
183
183
  }
184
184
  ),
185
185
  /* @__PURE__ */ r(
@@ -190,20 +190,20 @@ const C = "mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounde
190
190
  mimeType: t,
191
191
  detail: l,
192
192
  statusBadge: /* @__PURE__ */ r(
193
- z,
193
+ N,
194
194
  {
195
195
  isMine: !1,
196
- paymentStatus: h,
196
+ paymentStatus: g,
197
197
  amountText: c
198
198
  }
199
199
  ),
200
- icon: o ? y("light") : void 0,
200
+ icon: a ? L("light") : void 0,
201
201
  action: /* @__PURE__ */ r(
202
- V,
202
+ E,
203
203
  {
204
204
  isLocked: w,
205
205
  isUnlocking: s,
206
- sourceUrl: L,
206
+ sourceUrl: U,
207
207
  redeemUrl: P,
208
208
  onUnlockClicked: b,
209
209
  onDownloadClicked: f
@@ -214,8 +214,8 @@ const C = "mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounde
214
214
  ]
215
215
  }
216
216
  );
217
- }, X = (e) => e.isMine ? /* @__PURE__ */ r(E, { ...e }) : /* @__PURE__ */ r(_, { ...e });
217
+ }, Y = (e) => e.isMine ? /* @__PURE__ */ r(_, { ...e }) : /* @__PURE__ */ r($, { ...e });
218
218
  export {
219
- X as default
219
+ Y as default
220
220
  };
221
- //# sourceMappingURL=Card-DX9nBx1S.js.map
221
+ //# sourceMappingURL=Card-D0hLrOxX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-D0hLrOxX.js","sources":["../src/components/LockedAttachment/components/_shared/useReceivedSource.ts","../src/components/LockedAttachment/components/Media/CardActions.tsx","../src/components/LockedAttachment/components/Media/Card.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\n\nimport type {\n FetchSourceHandler,\n LockedAttachmentSource,\n PaymentStatus,\n} from '../../types'\n\nexport interface UseReceivedSourceOptions {\n paymentStatus?: PaymentStatus\n onFetchSource?: FetchSourceHandler\n /** Called on Unlock click while the card is still unpaid (opens checkout). */\n onUnlockClick?: () => void\n}\n\nexport interface UseReceivedSourceResult {\n source: LockedAttachmentSource | undefined\n /** Attach to the card root so the paid-source auto-fetch can observe it. */\n cardRef: React.RefObject<HTMLDivElement>\n /** Fetches the source when already paid, else defers to `onUnlockClick`. */\n handleUnlockClick: () => void\n}\n\n/**\n * Media !isMine's source-reveal logic: unlike Composer/Media isMine's\n * tap-to-toggle (`usePreviewToggle`), the recipient's card reveals its source\n * by fetching once — on click when already paid, or automatically the first\n * time a paid card scrolls fully into view. The fetch is guarded so it runs\n * at most once in flight.\n */\nexport function useReceivedSource({\n paymentStatus,\n onFetchSource,\n onUnlockClick,\n}: UseReceivedSourceOptions): UseReceivedSourceResult {\n const [source, setSource] = useState<LockedAttachmentSource | undefined>()\n\n const cardRef = useRef<HTMLDivElement>(null)\n const fetchingRef = useRef(false)\n\n const onFetchSourceRef = useRef(onFetchSource)\n onFetchSourceRef.current = onFetchSource\n\n const fetchSource = useCallback(async (): Promise<void> => {\n if (fetchingRef.current) return\n fetchingRef.current = true\n try {\n const result = await onFetchSourceRef.current?.()\n if (result) setSource(result)\n } finally {\n fetchingRef.current = false\n }\n }, [])\n\n const handleUnlockClick = useCallback(() => {\n if (paymentStatus === 'paid') {\n void fetchSource()\n } else {\n onUnlockClick?.()\n }\n }, [paymentStatus, fetchSource, onUnlockClick])\n\n // Auto-fetch the source once the paid card scrolls into view.\n useEffect(() => {\n if (!cardRef.current) return\n if (paymentStatus !== 'paid' || source !== undefined) return\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) {\n void fetchSource()\n observer.disconnect()\n }\n },\n { threshold: 1.0 }\n )\n\n observer.observe(cardRef.current)\n return () => observer.disconnect()\n }, [paymentStatus, source, fetchSource])\n\n return { source, cardRef, handleUnlockClick }\n}\n","import { DownloadSimpleIcon, LockSimpleIcon } from '@phosphor-icons/react'\nimport React from 'react'\n\nimport LoadingDots from '../_shared/LoadingDots'\n\nexport interface ReceivedCardActionsProps {\n /** Whether the card is currently locked. Drives which CTA we render. */\n isLocked: boolean\n /**\n * When unlocked, the URL used as the Download link's `href` (opens in a new\n * tab). When omitted, the Download CTA falls back to a plain `<button>`\n * that just calls `onDownloadClicked` — useful for galleries where the\n * single-source URL doesn't exist.\n */\n sourceUrl?: string\n /** Optional alternate href that takes precedence over `sourceUrl`. */\n redeemUrl?: string\n onUnlockClicked?: () => void\n onDownloadClicked?: () => void\n isUnlocking?: boolean\n}\n\nconst buttonClass =\n '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'\n\n/**\n * Renders the primary CTA below the body of a Received card.\n * - Locked + onUnlockClicked → \"Unlock\" button\n * - Unlocked + onDownloadClicked + (redeemUrl || sourceUrl) → \"Download\" link\n * - Unlocked + onDownloadClicked + no URL → \"Download\" button (e.g. gallery)\n * Otherwise renders nothing.\n */\nconst ReceivedCardActions: React.FC<ReceivedCardActionsProps> = ({\n isLocked,\n sourceUrl,\n redeemUrl,\n onUnlockClicked,\n onDownloadClicked,\n isUnlocking = false,\n}) => {\n if (isLocked && onUnlockClicked != null) {\n return (\n <button\n type=\"button\"\n onClick={onUnlockClicked}\n disabled={isUnlocking}\n className={buttonClass}\n >\n {isUnlocking ? (\n <LoadingDots />\n ) : (\n <React.Fragment>\n <LockSimpleIcon className=\"size-4\" weight=\"fill\" />\n Unlock\n </React.Fragment>\n )}\n </button>\n )\n }\n\n if (!isLocked && onDownloadClicked != null) {\n const href = redeemUrl ?? sourceUrl\n if (href != null) {\n return (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={onDownloadClicked}\n className={`${buttonClass} !text-white`}\n >\n <DownloadSimpleIcon className=\"size-4\" weight=\"bold\" />\n Download\n </a>\n )\n }\n\n return (\n <button\n type=\"button\"\n onClick={onDownloadClicked}\n className={buttonClass}\n >\n <DownloadSimpleIcon className=\"size-4\" weight=\"bold\" />\n Download\n </button>\n )\n }\n\n return null\n}\n\nexport default ReceivedCardActions\n","import type React from 'react'\n\nimport { getSourceType } from '../../../AttachmentCard'\nimport type {\n FetchSourceHandler,\n LockedAttachmentGalleryItem,\n PaymentStatus,\n} from '../../types'\nimport CardBody from '../_shared/CardBody'\nimport CardThumbnail, {\n galleryBodyIcon,\n isGalleryCard,\n} from '../_shared/CardThumbnail'\nimport MediaShell from '../_shared/MediaShell'\nimport PreviewToggle from '../_shared/PreviewToggle'\nimport PurchaseStatusBadge from '../_shared/PurchaseStatusBadge'\nimport { usePreviewToggle } from '../_shared/usePreviewToggle'\nimport { useReceivedSource } from '../_shared/useReceivedSource'\n\nimport ReceivedCardActions from './CardActions'\n\ninterface MediaCardSharedProps {\n title?: string\n mimeType?: string\n thumbnailUrl?: string\n detail?: string\n amountText?: string\n paymentStatus?: PaymentStatus\n gallery?: LockedAttachmentGalleryItem[]\n onFetchSource?: FetchSourceHandler\n}\n\nexport type MediaCardProps =\n | (MediaCardSharedProps & {\n isMine: true\n /** Dimmed fallback shown in the title slot when `title` is unset. */\n placeholderTitle?: string\n /** Fired the first time the sender taps the thumbnail to preview their own attachment. */\n onPreviewClick?: () => void\n })\n | (MediaCardSharedProps & {\n isMine: false\n /**\n * When true, shows a loading spinner on the Unlock button. Driven by\n * the LockedAttachmentContext (e.g. checkout in progress).\n */\n isUnlocking?: boolean\n /**\n * Called when the recipient clicks Unlock on an unpaid attachment.\n * Use this to open a checkout flow. Omit to hide the Unlock button.\n */\n onUnlockClick?: () => void\n /**\n * Called when the recipient clicks Download on an unlocked card.\n * Omit to hide the Download button.\n */\n onDownloadClick?: () => void\n })\n\n/**\n * The sender's ('mine') view of a paid media attachment: the locked\n * thumbnail (single or gallery) they can tap to preview their own\n * attachment, plus the title/purchase-status body.\n */\nconst OwnMediaCard: React.FC<\n MediaCardSharedProps & {\n isMine: true\n placeholderTitle?: string\n onPreviewClick?: () => void\n }\n> = ({\n title,\n mimeType = 'application/octet-stream',\n thumbnailUrl,\n detail,\n amountText,\n placeholderTitle = 'Attachment title',\n paymentStatus = 'pending',\n gallery = [],\n onPreviewClick,\n onFetchSource,\n}) => {\n const isGallery = isGalleryCard(gallery)\n\n // Gallery is always previewable for the sender because each item's source\n // is already provided up-front via `gallery[*].sourceUrl`.\n const { source, isPreviewVisible, isLoadingPreview, togglePreview } =\n usePreviewToggle({ isGallery, onFetchSource, onPreviewClick })\n\n const showLocked = !isPreviewVisible\n const isBusy = isLoadingPreview\n\n return (\n <MediaShell variant=\"dark\">\n <PreviewToggle\n onToggle={togglePreview}\n isBusy={isBusy}\n isPreviewVisible={!showLocked}\n >\n <CardThumbnail\n variant=\"dark\"\n gallery={gallery}\n title={title}\n showLocked={showLocked}\n paymentStatus={paymentStatus}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n source={source}\n />\n </PreviewToggle>\n\n <CardBody\n variant=\"dark\"\n title={title}\n placeholderTitle={placeholderTitle}\n mimeType={mimeType}\n detail={detail}\n statusBadge={\n <PurchaseStatusBadge\n isMine={true}\n paymentStatus={paymentStatus}\n amountText={amountText}\n />\n }\n icon={isGallery ? galleryBodyIcon('dark') : undefined}\n />\n </MediaShell>\n )\n}\n\n/**\n * The recipient's ('other') view of a paid media attachment: the locked\n * thumbnail (single or gallery) with an Unlock/Download CTA. The source is\n * revealed by fetching once — on click when already paid, or automatically\n * the first time a paid card scrolls into view.\n */\nconst OtherMediaCard: React.FC<\n MediaCardSharedProps & {\n isMine: false\n onUnlockClick?: () => void\n onDownloadClick?: () => void\n isUnlocking?: boolean\n }\n> = ({\n title,\n amountText,\n thumbnailUrl,\n mimeType = 'application/octet-stream',\n detail,\n gallery = [],\n onUnlockClick,\n onFetchSource,\n onDownloadClick,\n paymentStatus,\n isUnlocking = false,\n}) => {\n const isGallery = isGalleryCard(gallery)\n\n const { source, cardRef, handleUnlockClick } = useReceivedSource({\n paymentStatus,\n onFetchSource,\n onUnlockClick,\n })\n\n const effectiveSourceUrl = source?.sourceUrl\n const effectiveRedeemUrl = source?.redeemUrl\n\n // For gallery, the per-item sources are carried by `gallery` itself, so\n // the lock state is driven by paymentStatus rather than the single\n // `effectiveSourceUrl`. Everything else still respects the source fetch.\n const isLocked = isGallery\n ? paymentStatus !== 'paid'\n : effectiveSourceUrl === undefined\n const sourceType = getSourceType(mimeType)\n\n // For gallery, ReceivedCardActions falls back to a plain <button>\n // (no anchor) because the gallery has no single sourceUrl to link to —\n // the per-item sources live on `gallery` itself.\n const actionSourceUrl = isGallery ? undefined : effectiveSourceUrl\n\n return (\n <MediaShell\n variant=\"light\"\n rootRef={cardRef}\n data-testid=\"locked-attachment\"\n >\n <CardThumbnail\n variant=\"light\"\n gallery={gallery}\n title={title}\n showLocked={isLocked}\n paymentStatus={paymentStatus}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n source={source}\n containedImage={!isLocked && sourceType === 'document'}\n />\n\n <CardBody\n variant=\"light\"\n title={title}\n mimeType={mimeType}\n detail={detail}\n statusBadge={\n <PurchaseStatusBadge\n isMine={false}\n paymentStatus={paymentStatus}\n amountText={amountText}\n />\n }\n icon={isGallery ? galleryBodyIcon('light') : undefined}\n action={\n <ReceivedCardActions\n isLocked={isLocked}\n isUnlocking={isUnlocking}\n sourceUrl={actionSourceUrl}\n redeemUrl={effectiveRedeemUrl}\n onUnlockClicked={handleUnlockClick}\n onDownloadClicked={onDownloadClick}\n />\n }\n />\n </MediaShell>\n )\n}\n\n/**\n * The card either party sees for a paid media attachment. `isMine` selects\n * the sender's preview view (tap-to-preview own draft) vs. the recipient's\n * unlock/download view.\n */\nconst MediaCard: React.FC<MediaCardProps> = (props) =>\n props.isMine ? <OwnMediaCard {...props} /> : <OtherMediaCard {...props} />\n\nexport default MediaCard\n"],"names":["useReceivedSource","paymentStatus","onFetchSource","onUnlockClick","source","setSource","useState","cardRef","useRef","fetchingRef","onFetchSourceRef","fetchSource","useCallback","result","_a","handleUnlockClick","useEffect","observer","entry","buttonClass","ReceivedCardActions","isLocked","sourceUrl","redeemUrl","onUnlockClicked","onDownloadClicked","isUnlocking","jsx","LoadingDots","jsxs","React","LockSimpleIcon","href","DownloadSimpleIcon","OwnMediaCard","title","mimeType","thumbnailUrl","detail","amountText","placeholderTitle","gallery","onPreviewClick","isGallery","isGalleryCard","isPreviewVisible","isLoadingPreview","togglePreview","usePreviewToggle","showLocked","MediaShell","PreviewToggle","CardThumbnail","CardBody","PurchaseStatusBadge","galleryBodyIcon","OtherMediaCard","onDownloadClick","effectiveSourceUrl","effectiveRedeemUrl","sourceType","getSourceType","actionSourceUrl","MediaCard","props"],"mappings":";;;;;;;AA8BO,SAASA,EAAkB;AAAA,EAChC,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AACF,GAAsD;AACpD,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAA,GAEtBC,IAAUC,EAAuB,IAAI,GACrCC,IAAcD,EAAO,EAAK,GAE1BE,IAAmBF,EAAON,CAAa;AAC7C,EAAAQ,EAAiB,UAAUR;AAE3B,QAAMS,IAAcC,EAAY,YAA2B;;AACzD,QAAI,CAAAH,EAAY,SAChB;AAAA,MAAAA,EAAY,UAAU;AACtB,UAAI;AACF,cAAMI,IAAS,QAAMC,IAAAJ,EAAiB,YAAjB,gBAAAI,EAAA,KAAAJ;AACrB,QAAIG,OAAkBA,CAAM;AAAA,MAC9B,UAAA;AACE,QAAAJ,EAAY,UAAU;AAAA,MACxB;AAAA;AAAA,EACF,GAAG,CAAA,CAAE,GAECM,IAAoBH,EAAY,MAAM;AAC1C,IAAIX,MAAkB,SACfU,EAAA,IAELR,KAAA,QAAAA;AAAA,EAEJ,GAAG,CAACF,GAAeU,GAAaR,CAAa,CAAC;AAG9C,SAAAa,EAAU,MAAM;AAEd,QADI,CAACT,EAAQ,WACTN,MAAkB,UAAUG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AgB,CAACiB,KAAYuC,MAAe;AAAA,UAAA;AAAA,QAAA;AAAA,QAG9C,gBAAAjC;AAAA,UAAC0B;AAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,OAAAlB;AAAA,YACA,UAAAC;AAAA,YACA,QAAAE;AAAA,YACA,aACE,gBAAAX;AAAA,cAAC2B;AAAA,cAAA;AAAA,gBACC,QAAQ;AAAA,gBACR,eAAArD;AAAA,gBACA,YAAAsC;AAAA,cAAA;AAAA,YAAA;AAAA,YAGJ,MAAMI,IAAYY,EAAgB,OAAO,IAAI;AAAA,YAC7C,QACE,gBAAA5B;AAAA,cAACP;AAAA,cAAA;AAAA,gBACC,UAAAC;AAAA,gBACA,aAAAK;AAAA,gBACA,WAAWoC;AAAA,gBACX,WAAWH;AAAA,gBACX,iBAAiB5C;AAAA,gBACjB,mBAAmB0C;AAAA,cAAA;AAAA,YAAA;AAAA,UACrB;AAAA,QAAA;AAAA,MAEJ;AAAA,IAAA;AAAA,EAAA;AAGN,GAOMM,IAAsC,CAACC,MAC3CA,EAAM,SAAS,gBAAArC,EAACO,GAAA,EAAc,GAAG8B,EAAA,CAAO,IAAK,gBAAArC,EAAC6B,GAAA,EAAgB,GAAGQ,EAAA,CAAO;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime");require("classnames");const C=require("@phosphor-icons/react"),v=require("react"),M=require("./index-IkikzyWM.cjs"),s=require("./usePreviewToggle-B0B8cfxy.cjs"),y=require("./LoadingDots-Cn2y7g7L.cjs");function I({paymentStatus:r,onFetchSource:l,onUnlockClick:a}){const[t,d]=v.useState(),i=v.useRef(null),n=v.useRef(!1),u=v.useRef(l);u.current=l;const g=v.useCallback(async()=>{var o;if(!n.current){n.current=!0;try{const c=await((o=u.current)==null?void 0:o.call(u));c&&d(c)}finally{n.current=!1}}},[]),h=v.useCallback(()=>{r==="paid"?g():a==null||a()},[r,g,a]);return v.useEffect(()=>{if(!i.current||r!=="paid"||t!==void 0)return;const o=new IntersectionObserver(([c])=>{c.isIntersecting&&(g(),o.disconnect())},{threshold:1});return o.observe(i.current),()=>o.disconnect()},[r,t,g]),{source:t,cardRef:i,handleUnlockClick:h}}const R="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",k=({isLocked:r,sourceUrl:l,redeemUrl:a,onUnlockClicked:t,onDownloadClicked:d,isUnlocking:i=!1})=>{if(r&&t!=null)return e.jsx("button",{type:"button",onClick:t,disabled:i,className:R,children:i?e.jsx(y.LoadingDots,{}):e.jsxs(v.Fragment,{children:[e.jsx(C.LockSimpleIcon,{className:"size-4",weight:"fill"}),"Unlock"]})});if(!r&&d!=null){const n=a??l;return n!=null?e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",onClick:d,className:`${R} !text-white`,children:[e.jsx(C.DownloadSimpleIcon,{className:"size-4",weight:"bold"}),"Download"]}):e.jsxs("button",{type:"button",onClick:d,className:R,children:[e.jsx(C.DownloadSimpleIcon,{className:"size-4",weight:"bold"}),"Download"]})}return null},q=({title:r,mimeType:l="application/octet-stream",thumbnailUrl:a,detail:t,amountText:d,placeholderTitle:i="Attachment title",paymentStatus:n="pending",gallery:u=[],onPreviewClick:g,onFetchSource:h})=>{const o=s.isGalleryCard(u),{source:c,isPreviewVisible:f,isLoadingPreview:b,togglePreview:j}=s.usePreviewToggle({isGallery:o,onFetchSource:h,onPreviewClick:g}),x=!f,w=b;return e.jsxs(s.MediaShell,{variant:"dark",children:[e.jsx(s.PreviewToggle,{onToggle:j,isBusy:w,isPreviewVisible:!x,children:e.jsx(s.CardThumbnail,{variant:"dark",gallery:u,title:r,showLocked:x,paymentStatus:n,mimeType:l,thumbnailUrl:a,source:c})}),e.jsx(s.CardBody,{variant:"dark",title:r,placeholderTitle:i,mimeType:l,detail:t,statusBadge:e.jsx(y.PurchaseStatusBadge,{isMine:!0,paymentStatus:n,amountText:d}),icon:o?s.galleryBodyIcon("dark"):void 0})]})},S=({title:r,amountText:l,thumbnailUrl:a,mimeType:t="application/octet-stream",detail:d,gallery:i=[],onUnlockClick:n,onFetchSource:u,onDownloadClick:g,paymentStatus:h,isUnlocking:o=!1})=>{const c=s.isGalleryCard(i),{source:f,cardRef:b,handleUnlockClick:j}=I({paymentStatus:h,onFetchSource:u,onUnlockClick:n}),x=f==null?void 0:f.sourceUrl,w=f==null?void 0:f.redeemUrl,m=c?h!=="paid":x===void 0,P=M.getSourceType(t),B=c?void 0:x;return e.jsxs(s.MediaShell,{variant:"light",rootRef:b,"data-testid":"locked-attachment",children:[e.jsx(s.CardThumbnail,{variant:"light",gallery:i,title:r,showLocked:m,paymentStatus:h,mimeType:t,thumbnailUrl:a,source:f,containedImage:!m&&P==="document"}),e.jsx(s.CardBody,{variant:"light",title:r,mimeType:t,detail:d,statusBadge:e.jsx(y.PurchaseStatusBadge,{isMine:!1,paymentStatus:h,amountText:l}),icon:c?s.galleryBodyIcon("light"):void 0,action:e.jsx(k,{isLocked:m,isUnlocking:o,sourceUrl:B,redeemUrl:w,onUnlockClicked:j,onDownloadClicked:g})})]})},p=r=>r.isMine?e.jsx(q,{...r}):e.jsx(S,{...r});exports.default=p;
2
+ //# sourceMappingURL=Card-DIr1UnfC.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-DIr1UnfC.cjs","sources":["../src/components/LockedAttachment/components/_shared/useReceivedSource.ts","../src/components/LockedAttachment/components/Media/CardActions.tsx","../src/components/LockedAttachment/components/Media/Card.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\n\nimport type {\n FetchSourceHandler,\n LockedAttachmentSource,\n PaymentStatus,\n} from '../../types'\n\nexport interface UseReceivedSourceOptions {\n paymentStatus?: PaymentStatus\n onFetchSource?: FetchSourceHandler\n /** Called on Unlock click while the card is still unpaid (opens checkout). */\n onUnlockClick?: () => void\n}\n\nexport interface UseReceivedSourceResult {\n source: LockedAttachmentSource | undefined\n /** Attach to the card root so the paid-source auto-fetch can observe it. */\n cardRef: React.RefObject<HTMLDivElement>\n /** Fetches the source when already paid, else defers to `onUnlockClick`. */\n handleUnlockClick: () => void\n}\n\n/**\n * Media !isMine's source-reveal logic: unlike Composer/Media isMine's\n * tap-to-toggle (`usePreviewToggle`), the recipient's card reveals its source\n * by fetching once — on click when already paid, or automatically the first\n * time a paid card scrolls fully into view. The fetch is guarded so it runs\n * at most once in flight.\n */\nexport function useReceivedSource({\n paymentStatus,\n onFetchSource,\n onUnlockClick,\n}: UseReceivedSourceOptions): UseReceivedSourceResult {\n const [source, setSource] = useState<LockedAttachmentSource | undefined>()\n\n const cardRef = useRef<HTMLDivElement>(null)\n const fetchingRef = useRef(false)\n\n const onFetchSourceRef = useRef(onFetchSource)\n onFetchSourceRef.current = onFetchSource\n\n const fetchSource = useCallback(async (): Promise<void> => {\n if (fetchingRef.current) return\n fetchingRef.current = true\n try {\n const result = await onFetchSourceRef.current?.()\n if (result) setSource(result)\n } finally {\n fetchingRef.current = false\n }\n }, [])\n\n const handleUnlockClick = useCallback(() => {\n if (paymentStatus === 'paid') {\n void fetchSource()\n } else {\n onUnlockClick?.()\n }\n }, [paymentStatus, fetchSource, onUnlockClick])\n\n // Auto-fetch the source once the paid card scrolls into view.\n useEffect(() => {\n if (!cardRef.current) return\n if (paymentStatus !== 'paid' || source !== undefined) return\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) {\n void fetchSource()\n observer.disconnect()\n }\n },\n { threshold: 1.0 }\n )\n\n observer.observe(cardRef.current)\n return () => observer.disconnect()\n }, [paymentStatus, source, fetchSource])\n\n return { source, cardRef, handleUnlockClick }\n}\n","import { DownloadSimpleIcon, LockSimpleIcon } from '@phosphor-icons/react'\nimport React from 'react'\n\nimport LoadingDots from '../_shared/LoadingDots'\n\nexport interface ReceivedCardActionsProps {\n /** Whether the card is currently locked. Drives which CTA we render. */\n isLocked: boolean\n /**\n * When unlocked, the URL used as the Download link's `href` (opens in a new\n * tab). When omitted, the Download CTA falls back to a plain `<button>`\n * that just calls `onDownloadClicked` — useful for galleries where the\n * single-source URL doesn't exist.\n */\n sourceUrl?: string\n /** Optional alternate href that takes precedence over `sourceUrl`. */\n redeemUrl?: string\n onUnlockClicked?: () => void\n onDownloadClicked?: () => void\n isUnlocking?: boolean\n}\n\nconst buttonClass =\n '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'\n\n/**\n * Renders the primary CTA below the body of a Received card.\n * - Locked + onUnlockClicked → \"Unlock\" button\n * - Unlocked + onDownloadClicked + (redeemUrl || sourceUrl) → \"Download\" link\n * - Unlocked + onDownloadClicked + no URL → \"Download\" button (e.g. gallery)\n * Otherwise renders nothing.\n */\nconst ReceivedCardActions: React.FC<ReceivedCardActionsProps> = ({\n isLocked,\n sourceUrl,\n redeemUrl,\n onUnlockClicked,\n onDownloadClicked,\n isUnlocking = false,\n}) => {\n if (isLocked && onUnlockClicked != null) {\n return (\n <button\n type=\"button\"\n onClick={onUnlockClicked}\n disabled={isUnlocking}\n className={buttonClass}\n >\n {isUnlocking ? (\n <LoadingDots />\n ) : (\n <React.Fragment>\n <LockSimpleIcon className=\"size-4\" weight=\"fill\" />\n Unlock\n </React.Fragment>\n )}\n </button>\n )\n }\n\n if (!isLocked && onDownloadClicked != null) {\n const href = redeemUrl ?? sourceUrl\n if (href != null) {\n return (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={onDownloadClicked}\n className={`${buttonClass} !text-white`}\n >\n <DownloadSimpleIcon className=\"size-4\" weight=\"bold\" />\n Download\n </a>\n )\n }\n\n return (\n <button\n type=\"button\"\n onClick={onDownloadClicked}\n className={buttonClass}\n >\n <DownloadSimpleIcon className=\"size-4\" weight=\"bold\" />\n Download\n </button>\n )\n }\n\n return null\n}\n\nexport default ReceivedCardActions\n","import type React from 'react'\n\nimport { getSourceType } from '../../../AttachmentCard'\nimport type {\n FetchSourceHandler,\n LockedAttachmentGalleryItem,\n PaymentStatus,\n} from '../../types'\nimport CardBody from '../_shared/CardBody'\nimport CardThumbnail, {\n galleryBodyIcon,\n isGalleryCard,\n} from '../_shared/CardThumbnail'\nimport MediaShell from '../_shared/MediaShell'\nimport PreviewToggle from '../_shared/PreviewToggle'\nimport PurchaseStatusBadge from '../_shared/PurchaseStatusBadge'\nimport { usePreviewToggle } from '../_shared/usePreviewToggle'\nimport { useReceivedSource } from '../_shared/useReceivedSource'\n\nimport ReceivedCardActions from './CardActions'\n\ninterface MediaCardSharedProps {\n title?: string\n mimeType?: string\n thumbnailUrl?: string\n detail?: string\n amountText?: string\n paymentStatus?: PaymentStatus\n gallery?: LockedAttachmentGalleryItem[]\n onFetchSource?: FetchSourceHandler\n}\n\nexport type MediaCardProps =\n | (MediaCardSharedProps & {\n isMine: true\n /** Dimmed fallback shown in the title slot when `title` is unset. */\n placeholderTitle?: string\n /** Fired the first time the sender taps the thumbnail to preview their own attachment. */\n onPreviewClick?: () => void\n })\n | (MediaCardSharedProps & {\n isMine: false\n /**\n * When true, shows a loading spinner on the Unlock button. Driven by\n * the LockedAttachmentContext (e.g. checkout in progress).\n */\n isUnlocking?: boolean\n /**\n * Called when the recipient clicks Unlock on an unpaid attachment.\n * Use this to open a checkout flow. Omit to hide the Unlock button.\n */\n onUnlockClick?: () => void\n /**\n * Called when the recipient clicks Download on an unlocked card.\n * Omit to hide the Download button.\n */\n onDownloadClick?: () => void\n })\n\n/**\n * The sender's ('mine') view of a paid media attachment: the locked\n * thumbnail (single or gallery) they can tap to preview their own\n * attachment, plus the title/purchase-status body.\n */\nconst OwnMediaCard: React.FC<\n MediaCardSharedProps & {\n isMine: true\n placeholderTitle?: string\n onPreviewClick?: () => void\n }\n> = ({\n title,\n mimeType = 'application/octet-stream',\n thumbnailUrl,\n detail,\n amountText,\n placeholderTitle = 'Attachment title',\n paymentStatus = 'pending',\n gallery = [],\n onPreviewClick,\n onFetchSource,\n}) => {\n const isGallery = isGalleryCard(gallery)\n\n // Gallery is always previewable for the sender because each item's source\n // is already provided up-front via `gallery[*].sourceUrl`.\n const { source, isPreviewVisible, isLoadingPreview, togglePreview } =\n usePreviewToggle({ isGallery, onFetchSource, onPreviewClick })\n\n const showLocked = !isPreviewVisible\n const isBusy = isLoadingPreview\n\n return (\n <MediaShell variant=\"dark\">\n <PreviewToggle\n onToggle={togglePreview}\n isBusy={isBusy}\n isPreviewVisible={!showLocked}\n >\n <CardThumbnail\n variant=\"dark\"\n gallery={gallery}\n title={title}\n showLocked={showLocked}\n paymentStatus={paymentStatus}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n source={source}\n />\n </PreviewToggle>\n\n <CardBody\n variant=\"dark\"\n title={title}\n placeholderTitle={placeholderTitle}\n mimeType={mimeType}\n detail={detail}\n statusBadge={\n <PurchaseStatusBadge\n isMine={true}\n paymentStatus={paymentStatus}\n amountText={amountText}\n />\n }\n icon={isGallery ? galleryBodyIcon('dark') : undefined}\n />\n </MediaShell>\n )\n}\n\n/**\n * The recipient's ('other') view of a paid media attachment: the locked\n * thumbnail (single or gallery) with an Unlock/Download CTA. The source is\n * revealed by fetching once — on click when already paid, or automatically\n * the first time a paid card scrolls into view.\n */\nconst OtherMediaCard: React.FC<\n MediaCardSharedProps & {\n isMine: false\n onUnlockClick?: () => void\n onDownloadClick?: () => void\n isUnlocking?: boolean\n }\n> = ({\n title,\n amountText,\n thumbnailUrl,\n mimeType = 'application/octet-stream',\n detail,\n gallery = [],\n onUnlockClick,\n onFetchSource,\n onDownloadClick,\n paymentStatus,\n isUnlocking = false,\n}) => {\n const isGallery = isGalleryCard(gallery)\n\n const { source, cardRef, handleUnlockClick } = useReceivedSource({\n paymentStatus,\n onFetchSource,\n onUnlockClick,\n })\n\n const effectiveSourceUrl = source?.sourceUrl\n const effectiveRedeemUrl = source?.redeemUrl\n\n // For gallery, the per-item sources are carried by `gallery` itself, so\n // the lock state is driven by paymentStatus rather than the single\n // `effectiveSourceUrl`. Everything else still respects the source fetch.\n const isLocked = isGallery\n ? paymentStatus !== 'paid'\n : effectiveSourceUrl === undefined\n const sourceType = getSourceType(mimeType)\n\n // For gallery, ReceivedCardActions falls back to a plain <button>\n // (no anchor) because the gallery has no single sourceUrl to link to —\n // the per-item sources live on `gallery` itself.\n const actionSourceUrl = isGallery ? undefined : effectiveSourceUrl\n\n return (\n <MediaShell\n variant=\"light\"\n rootRef={cardRef}\n data-testid=\"locked-attachment\"\n >\n <CardThumbnail\n variant=\"light\"\n gallery={gallery}\n title={title}\n showLocked={isLocked}\n paymentStatus={paymentStatus}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n source={source}\n containedImage={!isLocked && sourceType === 'document'}\n />\n\n <CardBody\n variant=\"light\"\n title={title}\n mimeType={mimeType}\n detail={detail}\n statusBadge={\n <PurchaseStatusBadge\n isMine={false}\n paymentStatus={paymentStatus}\n amountText={amountText}\n />\n }\n icon={isGallery ? galleryBodyIcon('light') : undefined}\n action={\n <ReceivedCardActions\n isLocked={isLocked}\n isUnlocking={isUnlocking}\n sourceUrl={actionSourceUrl}\n redeemUrl={effectiveRedeemUrl}\n onUnlockClicked={handleUnlockClick}\n onDownloadClicked={onDownloadClick}\n />\n }\n />\n </MediaShell>\n )\n}\n\n/**\n * The card either party sees for a paid media attachment. `isMine` selects\n * the sender's preview view (tap-to-preview own draft) vs. the recipient's\n * unlock/download view.\n */\nconst MediaCard: React.FC<MediaCardProps> = (props) =>\n props.isMine ? <OwnMediaCard {...props} /> : <OtherMediaCard {...props} />\n\nexport default MediaCard\n"],"names":["useReceivedSource","paymentStatus","onFetchSource","onUnlockClick","source","setSource","useState","cardRef","useRef","fetchingRef","onFetchSourceRef","fetchSource","useCallback","result","_a","handleUnlockClick","useEffect","observer","entry","buttonClass","ReceivedCardActions","isLocked","sourceUrl","redeemUrl","onUnlockClicked","onDownloadClicked","isUnlocking","jsx","LoadingDots","jsxs","React","LockSimpleIcon","href","DownloadSimpleIcon","OwnMediaCard","title","mimeType","thumbnailUrl","detail","amountText","placeholderTitle","gallery","onPreviewClick","isGallery","isGalleryCard","isPreviewVisible","isLoadingPreview","togglePreview","usePreviewToggle","showLocked","isBusy","MediaShell","PreviewToggle","CardThumbnail","CardBody","PurchaseStatusBadge","galleryBodyIcon","OtherMediaCard","onDownloadClick","effectiveSourceUrl","effectiveRedeemUrl","sourceType","getSourceType","actionSourceUrl","MediaCard","props"],"mappings":"8TA8BO,SAASA,EAAkB,CAChC,cAAAC,EACA,cAAAC,EACA,cAAAC,CACF,EAAsD,CACpD,KAAM,CAACC,EAAQC,CAAS,EAAIC,WAAA,EAEtBC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAcD,EAAAA,OAAO,EAAK,EAE1BE,EAAmBF,EAAAA,OAAON,CAAa,EAC7CQ,EAAiB,QAAUR,EAE3B,MAAMS,EAAcC,EAAAA,YAAY,SAA2B,OACzD,GAAI,CAAAH,EAAY,QAChB,CAAAA,EAAY,QAAU,GACtB,GAAI,CACF,MAAMI,EAAS,OAAMC,EAAAJ,EAAiB,UAAjB,YAAAI,EAAA,KAAAJ,IACjBG,KAAkBA,CAAM,CAC9B,QAAA,CACEJ,EAAY,QAAU,EACxB,EACF,EAAG,CAAA,CAAE,EAECM,EAAoBH,EAAAA,YAAY,IAAM,CACtCX,IAAkB,OACfU,EAAA,EAELR,GAAA,MAAAA,GAEJ,EAAG,CAACF,EAAeU,EAAaR,CAAa,CAAC,EAG9Ca,OAAAA,EAAAA,UAAU,IAAM,CAEd,GADI,CAACT,EAAQ,SACTN,IAAkB,QAAUG,IAAW,OAAW,OAEtD,MAAMa,EAAW,IAAI,qBACnB,CAAC,CAACC,CAAK,IAAM,CACPA,EAAM,iBACHP,EAAA,EACLM,EAAS,WAAA,EAEb,EACA,CAAE,UAAW,CAAA,CAAI,EAGnB,OAAAA,EAAS,QAAQV,EAAQ,OA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AA,YAAAA,EAAQ,UAK7BiB,EAAWsB,EACb1C,IAAkB,OAClB0D,IAAuB,OACrBE,EAAaC,EAAAA,cAAc1B,CAAQ,EAKnC2B,EAAkBpB,EAAY,OAAYgB,EAEhD,OACE9B,EAAAA,KAACsB,EAAAA,WAAA,CACC,QAAQ,QACR,QAAS5C,EACT,cAAY,oBAEZ,SAAA,CAAAoB,EAAAA,IAAC0B,EAAAA,cAAA,CACC,QAAQ,QACR,QAAAZ,EACA,MAAAN,EACA,WAAYd,EACZ,cAAApB,EACA,SAAAmC,EACA,aAAAC,EACA,OAAAjC,EACA,eAAgB,CAACiB,GAAYwC,IAAe,UAAA,CAAA,EAG9ClC,EAAAA,IAAC2B,EAAAA,SAAA,CACC,QAAQ,QACR,MAAAnB,EACA,SAAAC,EACA,OAAAE,EACA,YACEX,EAAAA,IAAC4B,EAAAA,oBAAA,CACC,OAAQ,GACR,cAAAtD,EACA,WAAAsC,CAAA,CAAA,EAGJ,KAAMI,EAAYa,kBAAgB,OAAO,EAAI,OAC7C,OACE7B,EAAAA,IAACP,EAAA,CACC,SAAAC,EACA,YAAAK,EACA,UAAWqC,EACX,UAAWH,EACX,gBAAiB7C,EACjB,kBAAmB2C,CAAA,CAAA,CACrB,CAAA,CAEJ,CAAA,CAAA,CAGN,EAOMM,EAAuCC,GAC3CA,EAAM,OAAStC,EAAAA,IAACO,EAAA,CAAc,GAAG+B,CAAA,CAAO,EAAKtC,EAAAA,IAAC8B,EAAA,CAAgB,GAAGQ,CAAA,CAAO"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("@phosphor-icons/react"),T=require("react"),s=require("./usePreviewToggle-B0B8cfxy.cjs"),r=require("./TextShell-CKQOFxoH.cjs"),S=({text:t,amountText:i,placeholderAmountText:n,onDismiss:a})=>e.jsxs(r.TextShell,{isMine:!0,children:[e.jsx("div",{className:"pr-8",children:t||e.jsx(r.SkeletonTextLines,{variant:"dark",animate:!1})}),e.jsx(r.PriceLockRow,{children:e.jsx("span",{className:i?"text-white/55":"text-white/30",children:i||n})}),a&&e.jsx("button",{type:"button",onClick:a,className:"absolute right-3 top-3 flex size-6 shrink-0 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15","aria-label":"Dismiss attachment",children:e.jsx(o.XIcon,{className:"size-3",weight:"bold"})})]}),z=({title:t,mimeType:i="application/octet-stream",thumbnailUrl:n,detail:a,amountText:l,placeholderTitle:m="Attachment title",placeholderAmountText:g,gallery:c=[],onDismiss:d,onPreviewClick:j,onFetchSource:w,onEditClick:h})=>{const x=s.isGalleryCard(c),{source:b,isPreviewVisible:v,isLoadingPreview:f,togglePreview:p}=s.usePreviewToggle({isGallery:x,onFetchSource:w,onPreviewClick:j}),u=!v,y=f,k=e.jsxs(T.Fragment,{children:[e.jsx("span",{className:"text-xs font-medium text-white/55",children:"•"}),e.jsx("span",{className:l?"text-xs font-medium text-white/55":"text-xs font-medium text-white/30",children:l||g})]}),C=d?e.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),d()},className:"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white","aria-label":"Dismiss attachment",children:e.jsx(o.XIcon,{className:"size-3",weight:"bold"})}):void 0,P=h?e.jsx("button",{type:"button",onClick:h,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:e.jsx(o.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return e.jsxs(s.MediaShell,{variant:"dark",children:[e.jsx(s.PreviewToggle,{onToggle:p,isBusy:y,isPreviewVisible:!u,children:e.jsx(s.CardThumbnail,{variant:"dark",gallery:c,title:t,showLocked:u,mimeType:i,thumbnailUrl:n,source:b,topRight:C})}),e.jsx(s.CardBody,{variant:"dark",title:t,placeholderTitle:m,mimeType:i,detail:a,statusBadge:k,icon:x?s.galleryBodyIcon("dark"):void 0,trailingAction:P})]})},B=t=>t.contentType==="text"?e.jsx(S,{...t}):e.jsx(z,{...t});exports.default=B;
2
+ //# sourceMappingURL=Card-DeSgaRTL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-DeSgaRTL.cjs","sources":["../src/components/LockedAttachment/components/Composer/Card.tsx"],"sourcesContent":["import { PencilSimpleIcon, XIcon } from '@phosphor-icons/react'\nimport React from 'react'\n\nimport type { FetchSourceHandler, LockedAttachmentBaseProps } from '../../types'\nimport CardBody from '../_shared/CardBody'\nimport CardThumbnail, {\n galleryBodyIcon,\n isGalleryCard,\n} from '../_shared/CardThumbnail'\nimport MediaShell from '../_shared/MediaShell'\nimport PreviewToggle from '../_shared/PreviewToggle'\nimport PriceLockRow from '../_shared/PriceLockRow'\nimport SkeletonTextLines from '../_shared/SkeletonTextLines'\nimport TextShell from '../_shared/TextShell'\nimport { usePreviewToggle } from '../_shared/usePreviewToggle'\n\nexport interface ComposerCardProps extends LockedAttachmentBaseProps {\n /**\n * The message's own text, shown as-is (not redacted yet — the message\n * hasn't been sent). Only used when `contentType` is `\"text\"`.\n */\n text?: string\n /** Placeholder shown in the amount slot before one is configured. */\n placeholderAmountText?: string\n /**\n * Renders a persistent dismiss X on the thumbnail (media) or next to the\n * text (text mode); called to remove the draft attachment. Unrelated to\n * `TextCardProps.onDismiss`, which only appears for `isMine` after a\n * failed payment.\n */\n onDismiss?: () => void\n /** Fired the first time the composer taps the thumbnail to preview. */\n onPreviewClick?: () => void\n /**\n * Lazily loads the underlying source so the composer can preview the\n * attachment they're about to send. Called the first time the thumbnail is\n * tapped; the returned source is cached and reused on subsequent toggles.\n * Ignored when `contentType` is `\"text\"`.\n */\n onFetchSource?: FetchSourceHandler\n /**\n * When provided, renders a pencil button in the body bottom-right that the\n * composer can use to edit the attachment metadata (e.g. open the price /\n * gallery editor). Matches the Composer \"Button\" instance in Figma.\n */\n onEditClick?: () => void\n}\n\n/**\n * Composer card in text mode: a normal outgoing chat bubble showing the real\n * draft text (it hasn't been sent/redacted yet) plus a dismiss X and a price\n * row. Media-only props are ignored here.\n */\nconst ComposerTextCard: React.FC<ComposerCardProps> = ({\n text,\n amountText,\n placeholderAmountText,\n onDismiss,\n}) => (\n <TextShell isMine>\n <div className=\"pr-8\">\n {text ? text : <SkeletonTextLines variant=\"dark\" animate={false} />}\n </div>\n <PriceLockRow>\n <span className={amountText ? 'text-white/55' : 'text-white/30'}>\n {amountText || placeholderAmountText}\n </span>\n </PriceLockRow>\n {onDismiss && (\n <button\n type=\"button\"\n onClick={onDismiss}\n className=\"absolute right-3 top-3 flex size-6 shrink-0 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15\"\n aria-label=\"Dismiss attachment\"\n >\n <XIcon className=\"size-3\" weight=\"bold\" />\n </button>\n )}\n </TextShell>\n)\n\n/**\n * Composer card in media mode: the locked thumbnail (single or gallery) the\n * composer taps to preview the attachment they're about to send, plus the\n * title/price body with optional dismiss X and edit pencil.\n */\nconst ComposerMediaCard: React.FC<ComposerCardProps> = ({\n title,\n mimeType = 'application/octet-stream',\n thumbnailUrl,\n detail,\n amountText,\n placeholderTitle = 'Attachment title',\n placeholderAmountText,\n gallery = [],\n onDismiss,\n onPreviewClick,\n onFetchSource,\n onEditClick,\n}) => {\n const isGallery = isGalleryCard(gallery)\n\n // Gallery is always previewable in the composer because each item's source\n // is already provided up-front via `gallery[*].sourceUrl`.\n const { source, isPreviewVisible, isLoadingPreview, togglePreview } =\n usePreviewToggle({ isGallery, onFetchSource, onPreviewClick })\n\n const showLocked = !isPreviewVisible\n const isBusy = isLoadingPreview\n\n const statusBadge = (\n <React.Fragment>\n <span className=\"text-xs font-medium text-white/55\">&bull;</span>\n <span\n className={\n amountText\n ? 'text-xs font-medium text-white/55'\n : 'text-xs font-medium text-white/30'\n }\n >\n {amountText || placeholderAmountText}\n </span>\n </React.Fragment>\n )\n\n const dismissButton = onDismiss ? (\n <button\n type=\"button\"\n onClick={(e) => {\n // Stop the click from bubbling up into the outer preview-toggle\n // wrapper when both are wired up at the same time.\n e.stopPropagation()\n onDismiss()\n }}\n className=\"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white\"\n aria-label=\"Dismiss attachment\"\n >\n <XIcon className=\"size-3\" weight=\"bold\" />\n </button>\n ) : undefined\n\n const editButton = onEditClick ? (\n <button\n type=\"button\"\n onClick={onEditClick}\n aria-label=\"Edit attachment\"\n className=\"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15\"\n >\n <PencilSimpleIcon className=\"size-5\" weight=\"regular\" />\n </button>\n ) : undefined\n\n return (\n <MediaShell variant=\"dark\">\n <PreviewToggle\n onToggle={togglePreview}\n isBusy={isBusy}\n isPreviewVisible={!showLocked}\n >\n <CardThumbnail\n variant=\"dark\"\n gallery={gallery}\n title={title}\n showLocked={showLocked}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n source={source}\n topRight={dismissButton}\n />\n </PreviewToggle>\n\n <CardBody\n variant=\"dark\"\n title={title}\n placeholderTitle={placeholderTitle}\n mimeType={mimeType}\n detail={detail}\n statusBadge={statusBadge}\n icon={isGallery ? galleryBodyIcon('dark') : undefined}\n trailingAction={editButton}\n />\n </MediaShell>\n )\n}\n\n/**\n * The card the composer sees while drafting a paid attachment.\n * Matches the Composer column of the messaging design system in Figma.\n *\n * When `contentType === \"text\"`, renders as a normal outgoing chat bubble\n * showing the real draft text (it hasn't been sent/redacted yet) plus a\n * dismiss X and a price row, instead of a media thumbnail card.\n */\nconst ComposerCard: React.FC<ComposerCardProps> = (props) =>\n props.contentType === 'text' ? (\n <ComposerTextCard {...props} />\n ) : (\n <ComposerMediaCard {...props} />\n )\n\nexport default ComposerCard\n"],"names":["ComposerTextCard","text","amountText","placeholderAmountText","onDismiss","jsxs","TextShell","jsx","SkeletonTextLines","PriceLockRow","XIcon","ComposerMediaCard","title","mimeType","thumbnailUrl","detail","placeholderTitle","gallery","onPreviewClick","onFetchSource","onEditClick","isGallery","isGalleryCard","source","isPreviewVisible","isLoadingPreview","togglePreview","usePreviewToggle","showLocked","isBusy","statusBadge","React","dismissButton","e","editButton","PencilSimpleIcon","MediaShell","PreviewToggle","CardThumbnail","CardBody","galleryBodyIcon","ComposerCard","props"],"mappings":"8PAqDMA,EAAgD,CAAC,CACrD,KAAAC,EACA,WAAAC,EACA,sBAAAC,EACA,UAAAC,CACF,IACEC,EAAAA,KAACC,EAAAA,UAAA,CAAU,OAAM,GACf,SAAA,CAAAC,EAAAA,IAAC,MAAA,CAAI,UAAU,OACZ,SAAAN,GAAcM,EAAAA,IAACC,EAAAA,kBAAA,CAAkB,QAAQ,OAAO,QAAS,EAAA,CAAO,EACnE,EACAD,EAAAA,IAACE,EAAAA,aAAA,CACC,SAAAF,EAAAA,IAAC,OAAA,CAAK,UAAWL,EAAa,gBAAkB,gBAC7C,SAAAA,GAAcC,CAAA,CACjB,CAAA,CACF,EACCC,GACCG,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,QAASH,EACT,UAAU,gIACV,aAAW,qBAEX,SAAAG,EAAAA,IAACG,QAAA,CAAM,UAAU,SAAS,OAAO,MAAA,CAAO,CAAA,CAAA,CAC1C,EAEJ,EAQIC,EAAiD,CAAC,CACtD,MAAAC,EACA,SAAAC,EAAW,2BACX,aAAAC,EACA,OAAAC,EACA,WAAAb,EACA,iBAAAc,EAAmB,mBACnB,sBAAAb,EACA,QAAAc,EAAU,CAAA,EACV,UAAAb,EACA,eAAAc,EACA,cAAAC,EACA,YAAAC,CACF,IAAM,CACJ,MAAMC,EAAYC,EAAAA,cAAcL,CAAO,EAIjC,CAAE,OAAAM,EAAQ,iBAAAC,EAAkB,iBAAAC,EAAkB,cAAAC,CAAA,EAClDC,EAAAA,iBAAiB,CAAE,UAAAN,EAAW,cAAAF,EAAe,eAAAD,EAAgB,EAEzDU,EAAa,CAACJ,EACdK,EAASJ,EAETK,EACJzB,EAAAA,KAAC0B,EAAM,SAAN,CACC,SAAA,CAAAxB,EAAAA,IAAC,OAAA,CAAK,UAAU,oCAAoC,SAAA,IAAM,EAC1DA,EAAAA,IAAC,OAAA,CACC,UACEL,EACI,oCACA,oCAGL,SAAAA,GAAcC,CAAA,CAAA,CACjB,EACF,EAGI6B,EAAgB5B,EACpBG,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,QAAU0B,GAAM,CAGdA,EAAE,gBAAA,EACF7B,EAAA,CACF,EACA,UAAU,+EACV,aAAW,qBAEX,SAAAG,EAAAA,IAACG,QAAA,CAAM,UAAU,SAAS,OAAO,MAAA,CAAO,CAAA,CAAA,EAExC,OAEEwB,EAAad,EACjBb,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,QAASa,EACT,aAAW,kBACX,UAAU,iGAEV,SAAAb,EAAAA,IAAC4B,mBAAA,CAAiB,UAAU,SAAS,OAAO,SAAA,CAAU,CAAA,CAAA,EAEtD,OAEJ,OACE9B,EAAAA,KAAC+B,EAAAA,WAAA,CAAW,QAAQ,OAClB,SAAA,CAAA7B,EAAAA,IAAC8B,EAAAA,cAAA,CACC,SAAUX,EACV,OAAAG,EACA,iBAAkB,CAACD,EAEnB,SAAArB,EAAAA,IAAC+B,EAAAA,cAAA,CACC,QAAQ,OACR,QAAArB,EACA,MAAAL,EACA,WAAAgB,EACA,SAAAf,EACA,aAAAC,EACA,OAAAS,EACA,SAAUS,CAAA,CAAA,CACZ,CAAA,EAGFzB,EAAAA,IAACgC,EAAAA,SAAA,CACC,QAAQ,OACR,MAAA3B,EACA,iBAAAI,EACA,SAAAH,EACA,OAAAE,EACA,YAAAe,EACA,KAAMT,EAAYmB,kBAAgB,MAAM,EAAI,OAC5C,eAAgBN,CAAA,CAAA,CAClB,EACF,CAEJ,EAUMO,EAA6CC,GACjDA,EAAM,cAAgB,OACpBnC,EAAAA,IAACP,EAAA,CAAkB,GAAG0C,CAAA,CAAO,EAE7BnC,EAAAA,IAACI,EAAA,CAAmB,GAAG+B,CAAA,CAAO"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("@phosphor-icons/react"),r=require("./LoadingDots-Cn2y7g7L.cjs"),i=require("./TextShell-CKQOFxoH.cjs"),x=({amountText:s,paymentStatus:a="pending",children:n})=>{const l=a==="failed";if(a==="paid"&&n)return e.jsxs(i.TextShell,{isMine:!0,children:[n,e.jsx("span",{className:"sr-only","aria-live":"polite",children:"Sold."}),e.jsxs(i.PriceLockRow,{children:[s!=null&&e.jsx("span",{className:"text-white/55",children:s}),e.jsx(r.PurchaseStatusBadge,{isMine:!0,paymentStatus:a})]})]});const t=l?"Payment failed.":a==="refunded"?"Refunded.":"Payment pending.";return e.jsxs(i.TextShell,{isMine:!0,children:[e.jsx(i.SkeletonTextLines,{variant:"dark",animate:a==="pending"}),e.jsx("span",{className:"sr-only","aria-live":"polite",children:t}),e.jsxs(i.PriceLockRow,{children:[s!=null&&e.jsx("span",{className:"text-white/55",children:s}),e.jsx(r.PurchaseStatusBadge,{isMine:!0,paymentStatus:a})]})]})},h=({amountText:s,paymentStatus:a,onUnlockClick:n,isUnlocking:l=!1,children:c})=>{if(a==="paid"&&c)return e.jsxs(i.TextShell,{isMine:!1,children:[c,e.jsxs(i.PriceLockRow,{children:[s!=null&&e.jsx("span",{className:"opacity-55",children:s}),e.jsx(r.PurchaseStatusBadge,{isMine:!1,paymentStatus:"paid"})]})]});const d=l?"Unlocking.":"Locked message available to unlock.";return e.jsx(i.TextShell,{isMine:!1,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[e.jsx(i.SkeletonTextLines,{variant:"light",animate:l}),e.jsx("span",{className:"sr-only","aria-live":"polite",children:d}),e.jsx(i.PriceLockRow,{children:s!=null&&e.jsx("span",{className:"opacity-55",children:s})})]}),e.jsx("button",{type:"button",onClick:n,disabled:l,"aria-label":l?"Unlocking":"Unlock","aria-busy":l,title:l?"Unlocking":"Unlock",className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-[#121110] text-white hover:bg-[#2a2928]",children:l?e.jsx(r.LoadingDots,{}):e.jsx(o.LockSimpleIcon,{className:"size-4",weight:"fill","aria-hidden":!0})})]})})},j=s=>s.isMine?e.jsx(x,{...s}):e.jsx(h,{...s});exports.default=j;
2
+ //# sourceMappingURL=Card-DnaXMVrT.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-DnaXMVrT.cjs","sources":["../src/components/LockedAttachment/components/Text/Card.tsx"],"sourcesContent":["import { LockSimpleIcon } from '@phosphor-icons/react'\nimport type React from 'react'\n\nimport type { PaymentStatus } from '../../types'\nimport LoadingDots from '../_shared/LoadingDots'\nimport PriceLockRow from '../_shared/PriceLockRow'\nimport PurchaseStatusBadge from '../_shared/PurchaseStatusBadge'\nimport SkeletonTextLines from '../_shared/SkeletonTextLines'\nimport TextShell from '../_shared/TextShell'\n\ninterface TextCardSharedProps {\n amountText?: string\n paymentStatus?: PaymentStatus\n /**\n * The message's real, revealed content — shown instead of the skeleton\n * loader once `paymentStatus` is `'paid'`. Ignored otherwise. Lets the\n * caller supply its own text renderer (e.g. Stream's `MessageText`)\n * without `LockedAttachment` depending on it.\n */\n children?: React.ReactNode\n}\n\nexport type TextCardProps =\n | (TextCardSharedProps & {\n isMine: true\n })\n | (TextCardSharedProps & {\n isMine: false\n /**\n * Called when the recipient clicks Unlock on an unpaid attachment.\n * Use this to open a checkout flow. Omit to hide the Unlock button.\n */\n onUnlockClick?: () => void\n /**\n * When true, shows a loading spinner on the Unlock button. Driven by\n * the LockedAttachmentContext (e.g. checkout in progress).\n */\n isUnlocking?: boolean\n })\n\n/**\n * The sender's ('mine') view of a paid text-only message: an outgoing chat\n * bubble showing a skeleton text loader in place of the redacted content (or\n * `children`, once paid), plus a lock/price/status row.\n */\nconst OwnTextCard: React.FC<TextCardSharedProps & { isMine: true }> = ({\n amountText,\n paymentStatus = 'pending',\n children,\n}) => {\n const isFailed = paymentStatus === 'failed'\n const isPaid = paymentStatus === 'paid'\n\n if (isPaid && children) {\n return (\n <TextShell isMine>\n {children}\n <span className=\"sr-only\" aria-live=\"polite\">\n Sold.\n </span>\n <PriceLockRow>\n {amountText != null && (\n <span className=\"text-white/55\">{amountText}</span>\n )}\n <PurchaseStatusBadge isMine={true} paymentStatus={paymentStatus} />\n </PriceLockRow>\n </TextShell>\n )\n }\n\n const liveMessage = isFailed\n ? 'Payment failed.'\n : paymentStatus === 'refunded'\n ? 'Refunded.'\n : 'Payment pending.'\n\n return (\n <TextShell isMine>\n <SkeletonTextLines variant=\"dark\" animate={paymentStatus === 'pending'} />\n <span className=\"sr-only\" aria-live=\"polite\">\n {liveMessage}\n </span>\n <PriceLockRow>\n {amountText != null && (\n <span className=\"text-white/55\">{amountText}</span>\n )}\n <PurchaseStatusBadge isMine={true} paymentStatus={paymentStatus} />\n </PriceLockRow>\n </TextShell>\n )\n}\n\n/**\n * The recipient's ('other') view of a paid text-only message: a plain chat\n * bubble whose content is a skeleton text loader (or `children`, once paid)\n * plus a lock/price/status row. Two pre-purchase states exist — idle and\n * unlocking (checkout in flight) — plus the revealed state once\n * `paymentStatus` is `'paid'`.\n */\nconst OtherTextCard: React.FC<\n TextCardSharedProps & {\n isMine: false\n onUnlockClick?: () => void\n isUnlocking?: boolean\n }\n> = ({\n amountText,\n paymentStatus,\n onUnlockClick,\n isUnlocking = false,\n children,\n}) => {\n const isPaid = paymentStatus === 'paid'\n\n if (isPaid && children) {\n return (\n <TextShell isMine={false}>\n {children}\n <PriceLockRow>\n {amountText != null && (\n <span className=\"opacity-55\">{amountText}</span>\n )}\n <PurchaseStatusBadge isMine={false} paymentStatus=\"paid\" />\n </PriceLockRow>\n </TextShell>\n )\n }\n\n const ariaLabel = isUnlocking\n ? 'Unlocking.'\n : 'Locked message available to unlock.'\n\n return (\n <TextShell isMine={false}>\n <div className=\"flex items-center gap-3\">\n <div className=\"flex flex-1 flex-col gap-2\">\n <SkeletonTextLines variant=\"light\" animate={isUnlocking} />\n <span className=\"sr-only\" aria-live=\"polite\">\n {ariaLabel}\n </span>\n <PriceLockRow>\n {amountText != null && (\n <span className=\"opacity-55\">{amountText}</span>\n )}\n </PriceLockRow>\n </div>\n <button\n type=\"button\"\n onClick={onUnlockClick}\n disabled={isUnlocking}\n aria-label={isUnlocking ? 'Unlocking' : 'Unlock'}\n aria-busy={isUnlocking}\n title={isUnlocking ? 'Unlocking' : 'Unlock'}\n className=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-[#121110] text-white hover:bg-[#2a2928]\"\n >\n {isUnlocking ? (\n <LoadingDots />\n ) : (\n <LockSimpleIcon className=\"size-4\" weight=\"fill\" aria-hidden />\n )}\n </button>\n </div>\n </TextShell>\n )\n}\n\n/**\n * The card either party sees for a paid text-only message — a chat bubble\n * showing a skeleton text loader (or `children`, once revealed) plus a\n * lock/price/status row. `isMine` selects the sender's payment-lifecycle view\n * (pending/failed/refunded/paid + Dismiss) vs. the recipient's unlock-flow\n * view (idle/unlocking + Unlock CTA).\n */\nconst TextCard: React.FC<TextCardProps> = (props) =>\n props.isMine ? <OwnTextCard {...props} /> : <OtherTextCard {...props} />\n\nexport default TextCard\n"],"names":["OwnTextCard","amountText","paymentStatus","children","isFailed","jsxs","TextShell","PriceLockRow","jsx","PurchaseStatusBadge","liveMessage","SkeletonTextLines","OtherTextCard","onUnlockClick","isUnlocking","ariaLabel","LoadingDots","LockSimpleIcon","TextCard","props"],"mappings":"sOA6CMA,EAAgE,CAAC,CACrE,WAAAC,EACA,cAAAC,EAAgB,UAChB,SAAAC,CACF,IAAM,CACJ,MAAMC,EAAWF,IAAkB,SAGnC,GAFeA,IAAkB,QAEnBC,EACZ,OACEE,EAAAA,KAACC,EAAAA,UAAA,CAAU,OAAM,GACd,SAAA,CAAAH,QACA,OAAA,CAAK,UAAU,UAAU,YAAU,SAAS,SAAA,QAE7C,SACCI,EAAAA,aAAA,CACE,SAAA,CAAAN,GAAc,MACbO,EAAAA,IAAC,OAAA,CAAK,UAAU,gBAAiB,SAAAP,EAAW,EAE9CO,EAAAA,IAACC,EAAAA,oB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