@postrun/react 2.7.0 → 2.8.0

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.
package/dist/index.cjs CHANGED
@@ -15,6 +15,7 @@ var fi = require('react-icons/fi');
15
15
  var twitterText = require('twitter-text');
16
16
  var lu = require('react-icons/lu');
17
17
  var useEmblaCarousel = require('embla-carousel-react');
18
+ var md = require('react-icons/md');
18
19
  var io5 = require('react-icons/io5');
19
20
 
20
21
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -1355,6 +1356,8 @@ function XPostPreviewImpl({
1355
1356
  );
1356
1357
  }
1357
1358
  var XPostPreview = react.memo(XPostPreviewImpl);
1359
+
1360
+ // src/preview/linkedin/theme.ts
1358
1361
  var LI_VAR = {
1359
1362
  bg: "--pr-li-bg",
1360
1363
  text: "--pr-li-text",
@@ -1362,53 +1365,20 @@ var LI_VAR = {
1362
1365
  border: "--pr-li-border",
1363
1366
  accent: "--pr-li-accent"
1364
1367
  };
1365
- var LIGHT = {
1366
- bg: "#ffffff",
1367
- text: "rgba(0,0,0,0.9)",
1368
- muted: "rgba(0,0,0,0.6)",
1369
- border: "rgba(0,0,0,0.08)",
1370
- accent: "rgb(10,102,194)"
1371
- };
1372
- var DARK = {
1373
- bg: "#1b1f23",
1374
- text: "rgba(255,255,255,0.9)",
1375
- muted: "rgba(255,255,255,0.6)",
1376
- border: "rgba(255,255,255,0.15)",
1377
- accent: "rgb(112,181,249)"
1378
- };
1379
1368
  function varRef(name) {
1380
1369
  return `var(${name})`;
1381
1370
  }
1382
- function paletteVars(dark) {
1383
- const p = dark ? DARK : LIGHT;
1371
+ function paletteVars() {
1384
1372
  return {
1385
- "--pr-li-bg": p.bg,
1386
- "--pr-li-text": p.text,
1387
- "--pr-li-muted": p.muted,
1388
- "--pr-li-border": p.border,
1389
- "--pr-li-accent": p.accent
1373
+ [LI_VAR.bg]: "light-dark(#ffffff, #1b1f23)",
1374
+ [LI_VAR.text]: "light-dark(rgba(0,0,0,0.9), rgba(255,255,255,0.9))",
1375
+ [LI_VAR.muted]: "light-dark(rgba(0,0,0,0.6), rgba(255,255,255,0.6))",
1376
+ [LI_VAR.border]: "light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.15))",
1377
+ [LI_VAR.accent]: "light-dark(rgb(10,102,194), rgb(112,181,249))"
1390
1378
  };
1391
1379
  }
1392
- function usePrefersDark() {
1393
- const [dark, setDark] = react.useState(false);
1394
- react.useEffect(() => {
1395
- if (typeof window === "undefined" || !window.matchMedia) {
1396
- return;
1397
- }
1398
- const mq = window.matchMedia("(prefers-color-scheme: dark)");
1399
- setDark(mq.matches);
1400
- const onChange = (event) => setDark(event.matches);
1401
- mq.addEventListener("change", onChange);
1402
- return () => mq.removeEventListener("change", onChange);
1403
- }, []);
1404
- return dark;
1405
- }
1406
- function useIsDark(theme) {
1407
- const prefersDark = usePrefersDark();
1408
- if (theme === "auto") {
1409
- return prefersDark;
1410
- }
1411
- return theme === "dark";
1380
+ function colorSchemeFor(theme) {
1381
+ return theme === "auto" ? "light dark" : theme;
1412
1382
  }
1413
1383
  function domainOf(source) {
1414
1384
  try {
@@ -1875,7 +1845,6 @@ function LinkedInPostPreviewImpl({
1875
1845
  className,
1876
1846
  style
1877
1847
  }) {
1878
- const dark = useIsDark(theme);
1879
1848
  const resolvedMedia = useResolvedMedia(
1880
1849
  media,
1881
1850
  variant.media,
@@ -1887,8 +1856,9 @@ function LinkedInPostPreviewImpl({
1887
1856
  accent: varRef(LI_VAR.accent),
1888
1857
  muted: varRef(LI_VAR.muted)
1889
1858
  };
1890
- const cardStyle4 = {
1891
- ...paletteVars(dark),
1859
+ const cardStyle5 = {
1860
+ ...paletteVars(),
1861
+ colorScheme: colorSchemeFor(theme),
1892
1862
  background: varRef(LI_VAR.bg),
1893
1863
  color: varRef(LI_VAR.text),
1894
1864
  border: `1px solid ${varRef(LI_VAR.border)}`,
@@ -1898,7 +1868,7 @@ function LinkedInPostPreviewImpl({
1898
1868
  fontFamily: FONT_STACK,
1899
1869
  ...style
1900
1870
  };
1901
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: cardStyle4, children: [
1871
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: cardStyle5, children: [
1902
1872
  /* @__PURE__ */ jsxRuntime.jsx(Header, { author, visibility, time }),
1903
1873
  variant.body ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "8px 16px 0" }, children: /* @__PURE__ */ jsxRuntime.jsx(
1904
1874
  PostBody,
@@ -1929,10 +1899,58 @@ function renderContent(variant, media) {
1929
1899
  }
1930
1900
  var INSET = { padding: "12px 16px 0" };
1931
1901
  var LinkedInPostPreview = react.memo(LinkedInPostPreviewImpl);
1932
- var LINK_COLOR = "#8ab4ff";
1933
- var TOKEN = /([#@][\p{L}\p{N}_.]+)/gu;
1934
- var IS_TOKEN = /^[#@][\p{L}\p{N}_.]+$/u;
1935
- function Caption({ body }) {
1902
+
1903
+ // src/preview/instagram/theme.ts
1904
+ var IG_VAR = {
1905
+ bg: "--pr-ig-bg",
1906
+ text: "--pr-ig-text",
1907
+ muted: "--pr-ig-muted",
1908
+ border: "--pr-ig-border",
1909
+ accent: "--pr-ig-accent"
1910
+ };
1911
+ function varRef2(name) {
1912
+ return `var(${name})`;
1913
+ }
1914
+ function paletteVars2() {
1915
+ return {
1916
+ [IG_VAR.bg]: "light-dark(#ffffff, #000000)",
1917
+ [IG_VAR.text]: "light-dark(#000000, #f5f5f5)",
1918
+ [IG_VAR.muted]: "light-dark(#737373, #a8a8a8)",
1919
+ [IG_VAR.border]: "light-dark(#dbdbdb, #262626)",
1920
+ [IG_VAR.accent]: "light-dark(#00376b, #e0f1ff)"
1921
+ };
1922
+ }
1923
+ function colorSchemeFor2(theme) {
1924
+ return theme === "auto" ? "light dark" : theme;
1925
+ }
1926
+ function Actions() {
1927
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: rowStyle, children: [
1928
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: leftStyle, children: [
1929
+ /* @__PURE__ */ jsxRuntime.jsx(fi.FiHeart, { size: 24, "aria-label": "Like", role: "img" }),
1930
+ /* @__PURE__ */ jsxRuntime.jsx(fi.FiMessageCircle, { size: 24, "aria-label": "Comment", role: "img" }),
1931
+ /* @__PURE__ */ jsxRuntime.jsx(fi.FiSend, { size: 24, "aria-label": "Share", role: "img" })
1932
+ ] }),
1933
+ /* @__PURE__ */ jsxRuntime.jsx(fi.FiBookmark, { size: 24, "aria-label": "Save", role: "img" })
1934
+ ] });
1935
+ }
1936
+ var rowStyle = {
1937
+ display: "flex",
1938
+ alignItems: "center",
1939
+ justifyContent: "space-between",
1940
+ padding: "10px 12px 4px",
1941
+ color: varRef2(IG_VAR.text)
1942
+ };
1943
+ var leftStyle = {
1944
+ display: "flex",
1945
+ alignItems: "center",
1946
+ gap: 16
1947
+ };
1948
+ function ExpandableText({
1949
+ children,
1950
+ lines = 2,
1951
+ toggleColor,
1952
+ style
1953
+ }) {
1936
1954
  const [expanded, setExpanded] = react.useState(false);
1937
1955
  const [overflowing, setOverflowing] = react.useState(false);
1938
1956
  const ref = react.useRef(null);
@@ -1942,55 +1960,406 @@ function Caption({ body }) {
1942
1960
  return;
1943
1961
  }
1944
1962
  setOverflowing(el.scrollHeight > el.clientHeight + 1);
1945
- }, [body, expanded]);
1946
- const parts = body.split(TOKEN);
1947
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: wrapStyle3, children: [
1948
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref, style: expanded ? expandedTextStyle : clampedTextStyle, children: parts.map(
1949
- (part, i) => IS_TOKEN.test(part) ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: LINK_COLOR }, children: part }, i) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: part }, i)
1950
- ) }),
1963
+ }, [expanded, children]);
1964
+ const textStyle = expanded ? FULL : { ...FULL, ...clampStyle(lines) };
1965
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style, children: [
1966
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref, style: textStyle, children }),
1951
1967
  overflowing || expanded ? /* @__PURE__ */ jsxRuntime.jsx(
1952
1968
  "button",
1953
1969
  {
1954
1970
  type: "button",
1955
1971
  "aria-expanded": expanded,
1956
- "aria-label": expanded ? "Collapse caption" : "Expand caption",
1972
+ "aria-label": expanded ? "Show less" : "Show more",
1957
1973
  onClick: () => setExpanded((v) => !v),
1958
- style: moreStyle,
1974
+ style: { ...toggleStyle, color: toggleColor ?? "inherit" },
1959
1975
  children: expanded ? "less" : "more"
1960
1976
  }
1961
1977
  ) : null
1962
1978
  ] });
1963
1979
  }
1964
- var wrapStyle3 = {
1965
- fontSize: 14,
1966
- lineHeight: 1.35
1967
- };
1968
- var clampedTextStyle = {
1969
- display: "-webkit-box",
1970
- WebkitLineClamp: 2,
1971
- WebkitBoxOrient: "vertical",
1972
- overflow: "hidden",
1980
+ var FULL = {
1973
1981
  whiteSpace: "pre-wrap",
1974
1982
  wordBreak: "break-word"
1975
1983
  };
1976
- var expandedTextStyle = {
1977
- maxHeight: 180,
1978
- overflowY: "auto",
1979
- whiteSpace: "pre-wrap",
1980
- wordBreak: "break-word",
1981
- overscrollBehavior: "contain"
1982
- };
1983
- var moreStyle = {
1984
+ function clampStyle(lines) {
1985
+ return {
1986
+ display: "-webkit-box",
1987
+ WebkitLineClamp: lines,
1988
+ WebkitBoxOrient: "vertical",
1989
+ overflow: "hidden"
1990
+ };
1991
+ }
1992
+ var toggleStyle = {
1984
1993
  display: "inline-block",
1985
1994
  marginTop: 2,
1986
1995
  padding: 0,
1987
1996
  border: 0,
1988
1997
  background: "transparent",
1989
- color: "rgba(255,255,255,0.82)",
1990
- fontSize: 13,
1998
+ font: "inherit",
1999
+ fontWeight: 600,
2000
+ cursor: "pointer"
2001
+ };
2002
+ var TOKEN = /([#@][\p{L}\p{N}_.]+)/gu;
2003
+ var IS_TOKEN = /^[#@][\p{L}\p{N}_.]+$/u;
2004
+ function Caption({
2005
+ username,
2006
+ body
2007
+ }) {
2008
+ const parts = body.split(TOKEN);
2009
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2010
+ ExpandableText,
2011
+ {
2012
+ lines: 2,
2013
+ toggleColor: varRef2(IG_VAR.muted),
2014
+ style: wrapStyle3,
2015
+ children: [
2016
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontWeight: 600 }, children: [
2017
+ username,
2018
+ " "
2019
+ ] }),
2020
+ parts.map(
2021
+ (part, i) => IS_TOKEN.test(part) ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: varRef2(IG_VAR.accent) }, children: part }, i) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: part }, i)
2022
+ )
2023
+ ]
2024
+ }
2025
+ );
2026
+ }
2027
+ var wrapStyle3 = {
2028
+ padding: "4px 12px 0",
2029
+ fontSize: 14,
2030
+ lineHeight: 1.4,
2031
+ color: varRef2(IG_VAR.text)
2032
+ };
2033
+ function FeedMedia({ media }) {
2034
+ if (media.length <= 1) {
2035
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: frameStyle, children: media[0] ? /* @__PURE__ */ jsxRuntime.jsx(Tile2, { item: media[0] }) : null });
2036
+ }
2037
+ return /* @__PURE__ */ jsxRuntime.jsx(Carousel, { media });
2038
+ }
2039
+ function Tile2({ item }) {
2040
+ if (item.kind === "video") {
2041
+ return /* @__PURE__ */ jsxRuntime.jsx("video", { src: item.src, poster: item.posterSrc, controls: true, style: mediaStyle });
2042
+ }
2043
+ return /* @__PURE__ */ jsxRuntime.jsx("img", { src: item.src, alt: item.alt ?? "", style: mediaStyle });
2044
+ }
2045
+ function Carousel({ media }) {
2046
+ const [emblaRef, emblaApi] = useEmblaCarousel__default.default({ loop: false, align: "start" });
2047
+ const [selected, setSelected] = react.useState(0);
2048
+ const sync = react.useCallback((api) => {
2049
+ setSelected(api.selectedScrollSnap());
2050
+ }, []);
2051
+ react.useEffect(() => {
2052
+ if (!emblaApi) {
2053
+ return;
2054
+ }
2055
+ sync(emblaApi);
2056
+ emblaApi.on("select", sync).on("reInit", sync);
2057
+ return () => {
2058
+ emblaApi.off("select", sync).off("reInit", sync);
2059
+ };
2060
+ }, [emblaApi, sync]);
2061
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: frameStyle, children: [
2062
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: emblaRef, style: { position: "absolute", inset: 0, overflow: "hidden" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", height: "100%" }, children: media.map((item, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: slideStyle, children: /* @__PURE__ */ jsxRuntime.jsx(Tile2, { item }) }, `${item.src}-${i}`)) }) }),
2063
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: pillStyle, children: [
2064
+ selected + 1,
2065
+ "/",
2066
+ media.length
2067
+ ] }),
2068
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: dotsStyle, children: media.map((item, i) => /* @__PURE__ */ jsxRuntime.jsx(
2069
+ "span",
2070
+ {
2071
+ style: { ...dotStyle, opacity: i === selected ? 1 : 0.5 }
2072
+ },
2073
+ `dot-${item.src}-${i}`
2074
+ )) })
2075
+ ] });
2076
+ }
2077
+ var frameStyle = {
2078
+ position: "relative",
2079
+ width: "100%",
2080
+ aspectRatio: "1 / 1",
2081
+ background: "#000",
2082
+ overflow: "hidden"
2083
+ };
2084
+ var mediaStyle = {
2085
+ position: "absolute",
2086
+ inset: 0,
2087
+ width: "100%",
2088
+ height: "100%",
2089
+ objectFit: "cover"
2090
+ };
2091
+ var slideStyle = {
2092
+ position: "relative",
2093
+ flex: "0 0 100%",
2094
+ minWidth: 0,
2095
+ height: "100%"
2096
+ };
2097
+ var pillStyle = {
2098
+ position: "absolute",
2099
+ top: 12,
2100
+ right: 12,
2101
+ background: "rgba(0,0,0,0.6)",
2102
+ color: "#fff",
2103
+ fontSize: 12,
2104
+ fontWeight: 600,
2105
+ padding: "2px 9px",
2106
+ borderRadius: 999
2107
+ };
2108
+ var dotsStyle = {
2109
+ position: "absolute",
2110
+ bottom: 10,
2111
+ left: "50%",
2112
+ transform: "translateX(-50%)",
2113
+ display: "flex",
2114
+ gap: 4
2115
+ };
2116
+ var dotStyle = {
2117
+ width: 6,
2118
+ height: 6,
2119
+ borderRadius: "50%",
2120
+ background: "#fff"
2121
+ };
2122
+ var PLACEHOLDER_AVATAR3 = "data:image/svg+xml;utf8," + encodeURIComponent(
2123
+ '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><circle cx="16" cy="16" r="16" fill="#b3b3b3"/></svg>'
2124
+ );
2125
+ function Header2({
2126
+ author,
2127
+ collaborators
2128
+ }) {
2129
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: rowStyle2, children: [
2130
+ /* @__PURE__ */ jsxRuntime.jsx(
2131
+ "img",
2132
+ {
2133
+ src: author.avatar_url ?? PLACEHOLDER_AVATAR3,
2134
+ alt: "",
2135
+ width: 32,
2136
+ height: 32,
2137
+ style: avatarStyle
2138
+ }
2139
+ ),
2140
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { minWidth: 0, display: "flex", flexDirection: "column" }, children: [
2141
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: nameStyle, children: [
2142
+ author.username ?? "",
2143
+ author.verified ? /* @__PURE__ */ jsxRuntime.jsx(
2144
+ md.MdVerified,
2145
+ {
2146
+ size: 13,
2147
+ "aria-label": "Verified",
2148
+ role: "img",
2149
+ style: { color: "#3897f0", marginLeft: 3, flex: "0 0 auto" }
2150
+ }
2151
+ ) : null
2152
+ ] }),
2153
+ collaborators.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { style: collabStyle, children: [
2154
+ "with ",
2155
+ collaborators.map((c) => `@${c}`).join(", ")
2156
+ ] }) : null
2157
+ ] }),
2158
+ /* @__PURE__ */ jsxRuntime.jsx(
2159
+ fi.FiMoreHorizontal,
2160
+ {
2161
+ size: 18,
2162
+ "aria-hidden": true,
2163
+ style: { marginLeft: "auto", color: varRef2(IG_VAR.text) }
2164
+ }
2165
+ )
2166
+ ] });
2167
+ }
2168
+ var rowStyle2 = {
2169
+ display: "flex",
2170
+ alignItems: "center",
2171
+ gap: 10,
2172
+ padding: "10px 12px"
2173
+ };
2174
+ var avatarStyle = {
2175
+ width: 32,
2176
+ height: 32,
2177
+ borderRadius: "50%",
2178
+ objectFit: "cover",
2179
+ flex: "0 0 auto"
2180
+ };
2181
+ var nameStyle = {
2182
+ display: "flex",
2183
+ alignItems: "center",
2184
+ fontSize: 14,
1991
2185
  fontWeight: 600,
1992
- cursor: "pointer",
1993
- fontFamily: "inherit"
2186
+ color: varRef2(IG_VAR.text),
2187
+ lineHeight: 1.2
2188
+ };
2189
+ var collabStyle = {
2190
+ fontSize: 12,
2191
+ color: varRef2(IG_VAR.muted),
2192
+ lineHeight: 1.2
2193
+ };
2194
+ function ReelPreview({
2195
+ author,
2196
+ body,
2197
+ media,
2198
+ audioName,
2199
+ className,
2200
+ style
2201
+ }) {
2202
+ const first = media[0];
2203
+ const username = author.username ?? "";
2204
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...cardStyle3, ...style }, children: [
2205
+ first ? first.kind === "video" ? /* @__PURE__ */ jsxRuntime.jsx(
2206
+ "video",
2207
+ {
2208
+ src: first.src,
2209
+ poster: first.posterSrc,
2210
+ autoPlay: true,
2211
+ muted: true,
2212
+ loop: true,
2213
+ playsInline: true,
2214
+ style: coverStyle2
2215
+ }
2216
+ ) : /* @__PURE__ */ jsxRuntime.jsx("img", { src: first.src, alt: first.alt ?? "", style: coverStyle2 }) : null,
2217
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: scrimStyle }),
2218
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: infoStyle, children: [
2219
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: authorRowStyle, children: [
2220
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 600, fontSize: 14 }, children: username }),
2221
+ author.verified ? /* @__PURE__ */ jsxRuntime.jsx(md.MdVerified, { size: 13, "aria-label": "Verified", role: "img", style: { color: "#fff" } }) : null
2222
+ ] }),
2223
+ body ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: captionStyle, children: body }) : null,
2224
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: audioStyle, children: [
2225
+ /* @__PURE__ */ jsxRuntime.jsx(md.MdMusicNote, { size: 14, "aria-hidden": true }),
2226
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: audioName ?? "Original audio" })
2227
+ ] })
2228
+ ] }),
2229
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: railStyle, children: [
2230
+ /* @__PURE__ */ jsxRuntime.jsx(fi.FiHeart, { size: 26, "aria-label": "Like", role: "img" }),
2231
+ /* @__PURE__ */ jsxRuntime.jsx(fi.FiMessageCircle, { size: 26, "aria-label": "Comment", role: "img" }),
2232
+ /* @__PURE__ */ jsxRuntime.jsx(fi.FiSend, { size: 26, "aria-label": "Share", role: "img" }),
2233
+ /* @__PURE__ */ jsxRuntime.jsx(fi.FiBookmark, { size: 26, "aria-label": "Save", role: "img" }),
2234
+ /* @__PURE__ */ jsxRuntime.jsx(fi.FiMoreHorizontal, { size: 22, "aria-hidden": true })
2235
+ ] })
2236
+ ] });
2237
+ }
2238
+ var cardStyle3 = {
2239
+ position: "relative",
2240
+ width: "100%",
2241
+ maxWidth: 320,
2242
+ aspectRatio: "9 / 16",
2243
+ borderRadius: 12,
2244
+ overflow: "hidden",
2245
+ background: "#000",
2246
+ color: "#fff",
2247
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'
2248
+ };
2249
+ var coverStyle2 = {
2250
+ position: "absolute",
2251
+ inset: 0,
2252
+ width: "100%",
2253
+ height: "100%",
2254
+ objectFit: "cover"
2255
+ };
2256
+ var scrimStyle = {
2257
+ position: "absolute",
2258
+ inset: 0,
2259
+ background: "linear-gradient(180deg, rgba(0,0,0,0) 60%, rgba(0,0,0,0.55) 100%)",
2260
+ pointerEvents: "none"
2261
+ };
2262
+ var infoStyle = {
2263
+ position: "absolute",
2264
+ left: 12,
2265
+ right: 60,
2266
+ bottom: 14,
2267
+ display: "flex",
2268
+ flexDirection: "column",
2269
+ gap: 6,
2270
+ textShadow: "0 1px 3px rgba(0,0,0,0.5)"
2271
+ };
2272
+ var authorRowStyle = {
2273
+ display: "flex",
2274
+ alignItems: "center",
2275
+ gap: 5
2276
+ };
2277
+ var captionStyle = {
2278
+ fontSize: 13,
2279
+ lineHeight: 1.35,
2280
+ display: "-webkit-box",
2281
+ WebkitLineClamp: 2,
2282
+ WebkitBoxOrient: "vertical",
2283
+ overflow: "hidden"
2284
+ };
2285
+ var audioStyle = {
2286
+ display: "flex",
2287
+ alignItems: "center",
2288
+ gap: 6,
2289
+ fontSize: 12
2290
+ };
2291
+ var railStyle = {
2292
+ position: "absolute",
2293
+ right: 8,
2294
+ bottom: 16,
2295
+ display: "flex",
2296
+ flexDirection: "column",
2297
+ alignItems: "center",
2298
+ gap: 18,
2299
+ color: "#fff",
2300
+ filter: "drop-shadow(0 1px 2px rgba(0,0,0,0.4))"
2301
+ };
2302
+ function InstagramPostPreviewImpl({
2303
+ variant,
2304
+ author,
2305
+ media,
2306
+ theme = "auto",
2307
+ className,
2308
+ style
2309
+ }) {
2310
+ const resolvedMedia = useResolvedMedia(
2311
+ media,
2312
+ variant.media,
2313
+ altSignatureOf(variant.media)
2314
+ );
2315
+ const settings = variant.settings;
2316
+ const isReel = variant.post_type === "reel" || settings?.media_type === "REELS";
2317
+ if (isReel) {
2318
+ return /* @__PURE__ */ jsxRuntime.jsx(
2319
+ ReelPreview,
2320
+ {
2321
+ author,
2322
+ body: variant.body ?? "",
2323
+ media: resolvedMedia,
2324
+ audioName: settings?.audio_name,
2325
+ className,
2326
+ style
2327
+ }
2328
+ );
2329
+ }
2330
+ const collaborators = settings?.collaborators ?? [];
2331
+ const cardStyle5 = {
2332
+ ...paletteVars2(),
2333
+ colorScheme: colorSchemeFor2(theme),
2334
+ background: varRef2(IG_VAR.bg),
2335
+ color: varRef2(IG_VAR.text),
2336
+ border: `1px solid ${varRef2(IG_VAR.border)}`,
2337
+ borderRadius: 8,
2338
+ maxWidth: 470,
2339
+ overflow: "hidden",
2340
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
2341
+ ...style
2342
+ };
2343
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: cardStyle5, children: [
2344
+ /* @__PURE__ */ jsxRuntime.jsx(Header2, { author, collaborators }),
2345
+ /* @__PURE__ */ jsxRuntime.jsx(FeedMedia, { media: resolvedMedia }),
2346
+ /* @__PURE__ */ jsxRuntime.jsx(Actions, {}),
2347
+ variant.body ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { paddingBottom: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(Caption, { username: author.username ?? "", body: variant.body }) }) : null
2348
+ ] });
2349
+ }
2350
+ var InstagramPostPreview = react.memo(InstagramPostPreviewImpl);
2351
+ var LINK_COLOR = "#8ab4ff";
2352
+ var TOKEN2 = /([#@][\p{L}\p{N}_.]+)/gu;
2353
+ var IS_TOKEN2 = /^[#@][\p{L}\p{N}_.]+$/u;
2354
+ function Caption2({ body }) {
2355
+ const parts = body.split(TOKEN2);
2356
+ return /* @__PURE__ */ jsxRuntime.jsx(ExpandableText, { lines: 2, toggleColor: "rgba(255,255,255,0.82)", style: wrapStyle4, children: parts.map(
2357
+ (part, i) => IS_TOKEN2.test(part) ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: LINK_COLOR }, children: part }, i) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: part }, i)
2358
+ ) });
2359
+ }
2360
+ var wrapStyle4 = {
2361
+ fontSize: 14,
2362
+ lineHeight: 1.35
1994
2363
  };
1995
2364
  function Media2({
1996
2365
  media,
@@ -2010,7 +2379,7 @@ function Media2({
2010
2379
  muted: true,
2011
2380
  loop: true,
2012
2381
  playsInline: true,
2013
- style: coverStyle2
2382
+ style: coverStyle3
2014
2383
  }
2015
2384
  );
2016
2385
  }
@@ -2037,11 +2406,11 @@ function PhotoCarousel({ media }) {
2037
2406
  };
2038
2407
  }, [emblaApi, sync]);
2039
2408
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "absolute", inset: 0 }, children: [
2040
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: emblaRef, style: viewportStyle, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: containerStyle, children: media.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: slideStyle, children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: m.src, alt: m.alt ?? "", style: coverStyle2 }) }, `${m.src}-${i}`)) }) }),
2041
- media.length > 1 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: dotsStyle, children: media.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx(
2409
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: emblaRef, style: viewportStyle, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: containerStyle, children: media.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: slideStyle2, children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: m.src, alt: m.alt ?? "", style: coverStyle3 }) }, `${m.src}-${i}`)) }) }),
2410
+ media.length > 1 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: dotsStyle2, children: media.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx(
2042
2411
  "span",
2043
2412
  {
2044
- style: { ...dotStyle, opacity: i === selected ? 1 : 0.4 }
2413
+ style: { ...dotStyle2, opacity: i === selected ? 1 : 0.4 }
2045
2414
  },
2046
2415
  `dot-${m.src}-${i}`
2047
2416
  )) }) : null
@@ -2056,7 +2425,7 @@ function ProcessingMedia() {
2056
2425
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: { position: "relative", zIndex: 1 }, children: "Processing media\u2026" })
2057
2426
  ] });
2058
2427
  }
2059
- var coverStyle2 = {
2428
+ var coverStyle3 = {
2060
2429
  position: "absolute",
2061
2430
  inset: 0,
2062
2431
  width: "100%",
@@ -2072,13 +2441,13 @@ var containerStyle = {
2072
2441
  display: "flex",
2073
2442
  height: "100%"
2074
2443
  };
2075
- var slideStyle = {
2444
+ var slideStyle2 = {
2076
2445
  position: "relative",
2077
2446
  flex: "0 0 100%",
2078
2447
  minWidth: 0,
2079
2448
  height: "100%"
2080
2449
  };
2081
- var dotsStyle = {
2450
+ var dotsStyle2 = {
2082
2451
  position: "absolute",
2083
2452
  bottom: 124,
2084
2453
  left: "50%",
@@ -2087,7 +2456,7 @@ var dotsStyle = {
2087
2456
  gap: 5,
2088
2457
  alignItems: "center"
2089
2458
  };
2090
- var dotStyle = {
2459
+ var dotStyle2 = {
2091
2460
  width: 6,
2092
2461
  height: 6,
2093
2462
  borderRadius: "50%",
@@ -2182,16 +2551,16 @@ function TikTokPostPreviewImpl({
2182
2551
  const label = commercialLabel(variant.settings);
2183
2552
  const isAigc = Boolean(variant.settings?.is_aigc);
2184
2553
  const pending = (media?.length ?? 0) > 0 && resolvedMedia.length === 0;
2185
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...cardStyle3, ...style }, children: [
2554
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...cardStyle4, ...style }, children: [
2186
2555
  /* @__PURE__ */ jsxRuntime.jsx("style", { children: KEYFRAMES }),
2187
2556
  /* @__PURE__ */ jsxRuntime.jsx(Media2, { media: resolvedMedia, pending }),
2188
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: scrimStyle }),
2189
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: infoStyle, children: [
2557
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: scrimStyle2 }),
2558
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: infoStyle2, children: [
2190
2559
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: usernameStyle, children: handle }),
2191
- variant.body ? /* @__PURE__ */ jsxRuntime.jsx(Caption, { body: variant.body }) : null,
2560
+ variant.body ? /* @__PURE__ */ jsxRuntime.jsx(Caption2, { body: variant.body }) : null,
2192
2561
  label || isAigc ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: labelsStyle, children: [
2193
- label ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: pillStyle, children: label }) : null,
2194
- isAigc ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: pillStyle, children: "Creator labeled as AI-generated" }) : null
2562
+ label ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: pillStyle2, children: label }) : null,
2563
+ isAigc ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: pillStyle2, children: "Creator labeled as AI-generated" }) : null
2195
2564
  ] }) : null,
2196
2565
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: musicRowStyle, children: [
2197
2566
  /* @__PURE__ */ jsxRuntime.jsx(io5.IoMusicalNotes, { size: 13 }),
@@ -2201,7 +2570,7 @@ function TikTokPostPreviewImpl({
2201
2570
  ] })
2202
2571
  ] })
2203
2572
  ] }),
2204
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: railStyle, children: [
2573
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: railStyle2, children: [
2205
2574
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: avatarWrapStyle, children: [
2206
2575
  /* @__PURE__ */ jsxRuntime.jsx(Avatar, { url: creator.avatar_url, name: creator.nickname }),
2207
2576
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: followBadgeStyle, children: /* @__PURE__ */ jsxRuntime.jsx(PlusIcon, { size: 14 }) })
@@ -2222,14 +2591,14 @@ function RailAction({ icon, count }) {
2222
2591
  }
2223
2592
  function Avatar({ url, name }) {
2224
2593
  if (url) {
2225
- return /* @__PURE__ */ jsxRuntime.jsx("img", { src: url, alt: name, style: avatarStyle });
2594
+ return /* @__PURE__ */ jsxRuntime.jsx("img", { src: url, alt: name, style: avatarStyle2 });
2226
2595
  }
2227
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...avatarStyle, ...avatarFallbackStyle }, children: name.slice(0, 1).toUpperCase() });
2596
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...avatarStyle2, ...avatarFallbackStyle }, children: name.slice(0, 1).toUpperCase() });
2228
2597
  }
2229
2598
  function Disc({ url }) {
2230
2599
  return /* @__PURE__ */ jsxRuntime.jsx("div", { style: discStyle, children: url ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: url, alt: "", style: discImgStyle }) : null });
2231
2600
  }
2232
- var cardStyle3 = {
2601
+ var cardStyle4 = {
2233
2602
  position: "relative",
2234
2603
  width: "100%",
2235
2604
  maxWidth: 320,
@@ -2240,13 +2609,13 @@ var cardStyle3 = {
2240
2609
  color: "#fff",
2241
2610
  fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'
2242
2611
  };
2243
- var scrimStyle = {
2612
+ var scrimStyle2 = {
2244
2613
  position: "absolute",
2245
2614
  inset: 0,
2246
2615
  background: "linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%)",
2247
2616
  pointerEvents: "none"
2248
2617
  };
2249
- var infoStyle = {
2618
+ var infoStyle2 = {
2250
2619
  position: "absolute",
2251
2620
  left: 14,
2252
2621
  right: 70,
@@ -2267,7 +2636,7 @@ var labelsStyle = {
2267
2636
  gap: 4,
2268
2637
  marginTop: 2
2269
2638
  };
2270
- var pillStyle = {
2639
+ var pillStyle2 = {
2271
2640
  display: "inline-flex",
2272
2641
  alignItems: "center",
2273
2642
  background: "rgba(255,255,255,0.18)",
@@ -2284,7 +2653,7 @@ var musicRowStyle = {
2284
2653
  fontSize: 13,
2285
2654
  marginTop: 4
2286
2655
  };
2287
- var railStyle = {
2656
+ var railStyle2 = {
2288
2657
  position: "absolute",
2289
2658
  right: 8,
2290
2659
  bottom: 14,
@@ -2298,7 +2667,7 @@ var avatarWrapStyle = {
2298
2667
  position: "relative",
2299
2668
  marginBottom: 8
2300
2669
  };
2301
- var avatarStyle = {
2670
+ var avatarStyle2 = {
2302
2671
  width: 46,
2303
2672
  height: 46,
2304
2673
  borderRadius: "50%",
@@ -2361,6 +2730,8 @@ var discImgStyle = {
2361
2730
  };
2362
2731
  var KEYFRAMES = `@keyframes pr-tt-spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes pr-tt-shimmer{0%{background-position:-200% 0}100%{background-position:200% 0}}`;
2363
2732
  var TikTokPostPreview = react.memo(TikTokPostPreviewImpl);
2733
+
2734
+ // src/preview/tiktok/theme.ts
2364
2735
  var TT_VAR = {
2365
2736
  text: "--pr-tt-text",
2366
2737
  muted: "--pr-tt-muted",
@@ -2368,58 +2739,25 @@ var TT_VAR = {
2368
2739
  accent: "--pr-tt-accent",
2369
2740
  switchOff: "--pr-tt-switch-off"
2370
2741
  };
2371
- var LIGHT2 = {
2372
- text: "rgba(0,0,0,0.9)",
2373
- muted: "rgba(0,0,0,0.55)",
2374
- border: "rgba(0,0,0,0.12)",
2375
- accent: "#fe2c55",
2376
- switchOff: "rgba(0,0,0,0.18)"
2377
- };
2378
- var DARK2 = {
2379
- text: "rgba(255,255,255,0.92)",
2380
- muted: "#8a8a92",
2381
- border: "rgba(255,255,255,0.14)",
2382
- accent: "#fe2c55",
2383
- switchOff: "rgba(255,255,255,0.22)"
2384
- };
2385
- function varRef2(name) {
2742
+ function varRef3(name) {
2386
2743
  return `var(${name})`;
2387
2744
  }
2388
- function paletteVars2(dark) {
2389
- const p = dark ? DARK2 : LIGHT2;
2745
+ function paletteVars3() {
2390
2746
  return {
2391
- [TT_VAR.text]: p.text,
2392
- [TT_VAR.muted]: p.muted,
2393
- [TT_VAR.border]: p.border,
2394
- [TT_VAR.accent]: p.accent,
2395
- [TT_VAR.switchOff]: p.switchOff
2747
+ [TT_VAR.text]: "light-dark(rgba(0,0,0,0.9), rgba(255,255,255,0.92))",
2748
+ [TT_VAR.muted]: "light-dark(rgba(0,0,0,0.55), #8a8a92)",
2749
+ [TT_VAR.border]: "light-dark(rgba(0,0,0,0.12), rgba(255,255,255,0.14))",
2750
+ [TT_VAR.accent]: "#fe2c55",
2751
+ [TT_VAR.switchOff]: "light-dark(rgba(0,0,0,0.18), rgba(255,255,255,0.22))"
2396
2752
  };
2397
2753
  }
2398
- function usePrefersDark2() {
2399
- const [dark, setDark] = react.useState(false);
2400
- react.useEffect(() => {
2401
- if (typeof window === "undefined" || !window.matchMedia) {
2402
- return;
2403
- }
2404
- const mq = window.matchMedia("(prefers-color-scheme: dark)");
2405
- setDark(mq.matches);
2406
- const onChange = (event) => setDark(event.matches);
2407
- mq.addEventListener("change", onChange);
2408
- return () => mq.removeEventListener("change", onChange);
2409
- }, []);
2410
- return dark;
2754
+ function colorSchemeFor3(theme) {
2755
+ return theme === "auto" ? "light dark" : theme;
2411
2756
  }
2412
- function useIsDark2(theme) {
2413
- const prefersDark = usePrefersDark2();
2414
- if (theme === "auto") {
2415
- return prefersDark;
2416
- }
2417
- return theme === "dark";
2418
- }
2419
- var MUTED2 = varRef2(TT_VAR.muted);
2420
- var BORDER = varRef2(TT_VAR.border);
2421
- var ACCENT = varRef2(TT_VAR.accent);
2422
- var SWITCH_OFF = varRef2(TT_VAR.switchOff);
2757
+ var MUTED2 = varRef3(TT_VAR.muted);
2758
+ var BORDER = varRef3(TT_VAR.border);
2759
+ var ACCENT = varRef3(TT_VAR.accent);
2760
+ var SWITCH_OFF = varRef3(TT_VAR.switchOff);
2423
2761
  var ON = "#34c759";
2424
2762
  function Row({
2425
2763
  label,
@@ -2427,7 +2765,7 @@ function Row({
2427
2765
  control,
2428
2766
  htmlFor
2429
2767
  }) {
2430
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: rowStyle, children: [
2768
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: rowStyle3, children: [
2431
2769
  /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor, style: { display: "flex", flexDirection: "column", gap: 2 }, children: [
2432
2770
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 14 }, children: label }),
2433
2771
  sublabel ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: MUTED2 }, children: sublabel }) : null
@@ -2499,7 +2837,7 @@ function CheckRow({
2499
2837
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 14 }, children: label })
2500
2838
  ] });
2501
2839
  }
2502
- var rowStyle = {
2840
+ var rowStyle3 = {
2503
2841
  display: "flex",
2504
2842
  alignItems: "center",
2505
2843
  justifyContent: "space-between",
@@ -2604,7 +2942,7 @@ function TikTokCaptionField({
2604
2942
  const max = js.captionMaxFor(postType);
2605
2943
  const count = value.length;
2606
2944
  const over = count > max;
2607
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...wrapStyle4, ...style }, children: [
2945
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...wrapStyle5, ...style }, children: [
2608
2946
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: labelRowStyle, children: [
2609
2947
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, style: labelStyle, children: "Caption" }),
2610
2948
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2612,7 +2950,7 @@ function TikTokCaptionField({
2612
2950
  {
2613
2951
  style: {
2614
2952
  ...countStyle,
2615
- color: over ? varRef2(TT_VAR.accent) : varRef2(TT_VAR.muted)
2953
+ color: over ? varRef3(TT_VAR.accent) : varRef3(TT_VAR.muted)
2616
2954
  },
2617
2955
  children: [
2618
2956
  count.toLocaleString(),
@@ -2632,13 +2970,13 @@ function TikTokCaptionField({
2632
2970
  rows: 4,
2633
2971
  style: {
2634
2972
  ...textareaStyle,
2635
- borderColor: over ? varRef2(TT_VAR.accent) : varRef2(TT_VAR.border)
2973
+ borderColor: over ? varRef3(TT_VAR.accent) : varRef3(TT_VAR.border)
2636
2974
  }
2637
2975
  }
2638
2976
  )
2639
2977
  ] });
2640
2978
  }
2641
- var wrapStyle4 = {
2979
+ var wrapStyle5 = {
2642
2980
  display: "flex",
2643
2981
  flexDirection: "column",
2644
2982
  gap: 6,
@@ -2794,7 +3132,6 @@ function TikTokPublishPanel({
2794
3132
  className,
2795
3133
  style
2796
3134
  }) {
2797
- const dark = useIsDark2(theme);
2798
3135
  const isVideo = variant.post_type === "video";
2799
3136
  const captionOver = caption.length > js.captionMaxFor(variant.post_type);
2800
3137
  const mediaOk = mediaCountValid(variant.post_type, variant.media?.length ?? 0);
@@ -2804,9 +3141,10 @@ function TikTokPublishPanel({
2804
3141
  {
2805
3142
  className,
2806
3143
  style: {
2807
- ...paletteVars2(dark),
3144
+ ...paletteVars3(),
3145
+ colorScheme: colorSchemeFor3(theme),
2808
3146
  ...panelStyle,
2809
- color: varRef2(TT_VAR.text),
3147
+ color: varRef3(TT_VAR.text),
2810
3148
  ...style
2811
3149
  },
2812
3150
  children: [
@@ -2911,10 +3249,12 @@ exports.CommercialDisclosure = CommercialDisclosure;
2911
3249
  exports.Connect = Connect;
2912
3250
  exports.Declaration = Declaration;
2913
3251
  exports.DocumentCard = DocumentCard;
3252
+ exports.InstagramPostPreview = InstagramPostPreview;
2914
3253
  exports.InteractionToggles = InteractionToggles;
2915
3254
  exports.LinkedInPostPreview = LinkedInPostPreview;
2916
3255
  exports.Poll = Poll;
2917
3256
  exports.PostrunProvider = PostrunProvider;
3257
+ exports.ReelPreview = ReelPreview;
2918
3258
  exports.TikTokCaptionField = TikTokCaptionField;
2919
3259
  exports.TikTokPostPreview = TikTokPostPreview;
2920
3260
  exports.TikTokPublishPanel = TikTokPublishPanel;