UNPKG

reactjs-tiptap-editor

Version:

A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React

1,549 lines 53.8 kB
import { j as U, a8 as rt, h as Mt, N as jt, m as Wt, a9 as Bt, k as Ft } from "./clsx-DaPvp9ji.js"; import { jsx as r, jsxs as h, Fragment as Pt } from "react/jsx-runtime"; import Be, { useState as se, Fragment as Ut, useEffect as Fe, useMemo as Pe, createContext as zt, useLayoutEffect as Ht, useContext as Gt, useRef as K, useCallback as Te, useDebugValue as Xt } from "react"; import { L as Kt, j as Qt, B as Jt, h as Yt, u as Zt, d as en, A as tn, I as nn } from "./index-RcSPeQHn.js"; import "./theme.js"; import { u as rn } from "./index-C07N8gA1.js"; import { P as on, a as an, b as sn } from "./popover-CtinPbiy.js"; const cn = "_verified_lvyh0_1", Ue = { verified: cn }, ln = () => /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", "aria-label": "Verified account", role: "img", className: Ue.verified, children: /* @__PURE__ */ r("g", { children: /* @__PURE__ */ r("path", { d: "M22.25 12c0-1.43-.88-2.67-2.19-3.34.46-1.39.2-2.9-.81-3.91s-2.52-1.27-3.91-.81c-.66-1.31-1.91-2.19-3.34-2.19s-2.67.88-3.33 2.19c-1.4-.46-2.91-.2-3.92.81s-1.26 2.52-.8 3.91c-1.31.67-2.2 1.91-2.2 3.34s.89 2.67 2.2 3.34c-.46 1.39-.21 2.9.8 3.91s2.52 1.26 3.91.81c.67 1.31 1.91 2.19 3.34 2.19s2.68-.88 3.34-2.19c1.39.45 2.9.2 3.91-.81s1.27-2.52.81-3.91c1.31-.67 2.19-1.91 2.19-3.34zm-11.71 4.2L6.8 12.46l1.41-1.42 2.26 2.26 4.8-5.23 1.47 1.36-6.2 6.77z" }) }) }), dn = () => /* @__PURE__ */ r("svg", { viewBox: "0 0 22 22", "aria-label": "Verified account", role: "img", className: Ue.verified, children: /* @__PURE__ */ h("g", { children: [ /* @__PURE__ */ h("linearGradient", { gradientUnits: "userSpaceOnUse", id: "0-a", x1: "4.411", x2: "18.083", y1: "2.495", y2: "21.508", children: [ /* @__PURE__ */ r("stop", { offset: "0", stopColor: "#f4e72a" }), /* @__PURE__ */ r("stop", { offset: ".539", stopColor: "#cd8105" }), /* @__PURE__ */ r("stop", { offset: ".68", stopColor: "#cb7b00" }), /* @__PURE__ */ r("stop", { offset: "1", stopColor: "#f4ec26" }), /* @__PURE__ */ r("stop", { offset: "1", stopColor: "#f4e72a" }) ] }), /* @__PURE__ */ h("linearGradient", { gradientUnits: "userSpaceOnUse", id: "0-b", x1: "5.355", x2: "16.361", y1: "3.395", y2: "19.133", children: [ /* @__PURE__ */ r("stop", { offset: "0", stopColor: "#f9e87f" }), /* @__PURE__ */ r("stop", { offset: ".406", stopColor: "#e2b719" }), /* @__PURE__ */ r("stop", { offset: ".989", stopColor: "#e2b719" }) ] }), /* @__PURE__ */ h("g", { clipRule: "evenodd", fillRule: "evenodd", children: [ /* @__PURE__ */ r("path", { d: "M13.324 3.848L11 1.6 8.676 3.848l-3.201-.453-.559 3.184L2.06 8.095 3.48 11l-1.42 2.904 2.856 1.516.559 3.184 3.201-.452L11 20.4l2.324-2.248 3.201.452.559-3.184 2.856-1.516L18.52 11l1.42-2.905-2.856-1.516-.559-3.184zm-7.09 7.575l3.428 3.428 5.683-6.206-1.347-1.247-4.4 4.795-2.072-2.072z", fill: "url(#0-a)" }), /* @__PURE__ */ r("path", { d: "M13.101 4.533L11 2.5 8.899 4.533l-2.895-.41-.505 2.88-2.583 1.37L4.2 11l-1.284 2.627 2.583 1.37.505 2.88 2.895-.41L11 19.5l2.101-2.033 2.895.41.505-2.88 2.583-1.37L17.8 11l1.284-2.627-2.583-1.37-.505-2.88zm-6.868 6.89l3.429 3.428 5.683-6.206-1.347-1.247-4.4 4.795-2.072-2.072z", fill: "url(#0-b)" }), /* @__PURE__ */ r("path", { d: "M6.233 11.423l3.429 3.428 5.65-6.17.038-.033-.005 1.398-5.683 6.206-3.429-3.429-.003-1.405.005.003z", fill: "#d18800" }) ] }) ] }) }), un = () => /* @__PURE__ */ r("svg", { viewBox: "0 0 22 22", "aria-label": "Verified account", role: "img", className: Ue.verified, children: /* @__PURE__ */ r("g", { children: /* @__PURE__ */ r("path", { clipRule: "evenodd", d: "M12.05 2.056c-.568-.608-1.532-.608-2.1 0l-1.393 1.49c-.284.303-.685.47-1.1.455L5.42 3.932c-.832-.028-1.514.654-1.486 1.486l.069 2.039c.014.415-.152.816-.456 1.1l-1.49 1.392c-.608.568-.608 1.533 0 2.101l1.49 1.393c.304.284.47.684.456 1.1l-.07 2.038c-.027.832.655 1.514 1.487 1.486l2.038-.069c.415-.014.816.152 1.1.455l1.392 1.49c.569.609 1.533.609 2.102 0l1.393-1.49c.283-.303.684-.47 1.099-.455l2.038.069c.832.028 1.515-.654 1.486-1.486L18 14.542c-.015-.415.152-.815.455-1.099l1.49-1.393c.608-.568.608-1.533 0-2.101l-1.49-1.393c-.303-.283-.47-.684-.455-1.1l.068-2.038c.029-.832-.654-1.514-1.486-1.486l-2.038.07c-.415.013-.816-.153-1.1-.456zm-5.817 9.367l3.429 3.428 5.683-6.206-1.347-1.247-4.4 4.795-2.072-2.072z", fillRule: "evenodd" }) }) }), fn = "_root_98iqw_1", hn = "_article_98iqw_21", ot = { root: fn, article: hn }, ze = ({ className: e, children: t }) => /* @__PURE__ */ r("div", { className: U("react-tweet-theme", ot.root, e), children: /* @__PURE__ */ r("article", { className: ot.article, children: t }) }), vt = (e) => /* @__PURE__ */ r("img", { ...e }), _n = "_verifiedOld_lcna5_1", mn = "_verifiedBlue_lcna5_4", pn = "_verifiedGovernment_lcna5_7", xe = { verifiedOld: _n, verifiedBlue: mn, verifiedGovernment: pn }, gt = ({ user: e, className: t }) => { const n = e.verified || e.is_blue_verified || e.verified_type; let o = /* @__PURE__ */ r(ln, {}), a = xe.verifiedBlue; if (n) switch (e.is_blue_verified || (a = xe.verifiedOld), e.verified_type) { case "Government": o = /* @__PURE__ */ r(un, {}), a = xe.verifiedGovernment; break; case "Business": o = /* @__PURE__ */ r(dn, {}), a = null; break; } return n ? /* @__PURE__ */ r("div", { className: U(t, a), children: o }) : null; }, vn = "_label_36ucz_1", gn = { label: vn }, wt = ({ user: e, className: t }) => { var n; const o = e.highlighted_label; if (!o) return null; const a = (n = o.badge) == null ? void 0 : n.url; return a ? /* @__PURE__ */ r("div", { className: U(gn.label, t), children: /* @__PURE__ */ r("img", { src: a, alt: o.description }) }) : null; }, wn = "_header_nqq4j_1", yn = "_avatar_nqq4j_11", bn = "_avatarOverflow_nqq4j_16", Tn = "_avatarSquare_nqq4j_23", xn = "_avatarShadow_nqq4j_26", Nn = "_author_nqq4j_37", In = "_authorLink_nqq4j_44", Rn = "_authorVerified_nqq4j_53", Sn = "_authorLinkText_nqq4j_56", kn = "_authorMeta_nqq4j_63", En = "_authorFollow_nqq4j_66", Cn = "_username_nqq4j_69", On = "_follow_nqq4j_74", Ln = "_separator_nqq4j_82", $n = "_brand_nqq4j_86", qn = "_twitterIcon_nqq4j_90", N = { header: wn, avatar: yn, avatarOverflow: bn, avatarSquare: Tn, avatarShadow: xn, author: Nn, authorLink: In, authorVerified: Rn, authorLinkText: Sn, authorMeta: kn, authorFollow: En, username: Cn, follow: On, separator: Ln, brand: $n, twitterIcon: qn }, Dn = ({ tweet: e, components: t }) => { var n; const o = (n = t == null ? void 0 : t.AvatarImg) != null ? n : vt, { user: a } = e; return /* @__PURE__ */ h("div", { className: N.header, children: [ /* @__PURE__ */ h("a", { href: e.url, className: N.avatar, target: "_blank", rel: "noopener noreferrer", children: [ /* @__PURE__ */ r("div", { className: U(N.avatarOverflow, a.profile_image_shape === "Square" && N.avatarSquare), children: /* @__PURE__ */ r(o, { src: a.profile_image_url_https, alt: a.name, width: 48, height: 48 }) }), /* @__PURE__ */ r("div", { className: N.avatarOverflow, children: /* @__PURE__ */ r("div", { className: N.avatarShadow }) }) ] }), /* @__PURE__ */ h("div", { className: N.author, children: [ /* @__PURE__ */ h("a", { href: e.url, className: N.authorLink, target: "_blank", rel: "noopener noreferrer", children: [ /* @__PURE__ */ r("div", { className: N.authorLinkText, children: /* @__PURE__ */ r("span", { title: a.name, children: a.name }) }), /* @__PURE__ */ r(gt, { user: a, className: N.authorVerified }), /* @__PURE__ */ r(wt, { user: a }) ] }), /* @__PURE__ */ h("div", { className: N.authorMeta, children: [ /* @__PURE__ */ r("a", { href: e.url, className: N.username, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ h("span", { title: `@${a.screen_name}`, children: [ "@", a.screen_name ] }) }), /* @__PURE__ */ h("div", { className: N.authorFollow, children: [ /* @__PURE__ */ r("span", { className: N.separator, children: "·" }), /* @__PURE__ */ r("a", { href: a.follow_url, className: N.follow, target: "_blank", rel: "noopener noreferrer", children: "Follow" }) ] }) ] }) ] }), /* @__PURE__ */ r("a", { href: e.url, className: N.brand, target: "_blank", rel: "noopener noreferrer", "aria-label": "View on Twitter", children: /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", className: N.twitterIcon, children: /* @__PURE__ */ r("g", { children: /* @__PURE__ */ r("path", { d: "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" }) }) }) }) ] }); }, An = "_root_1ec15_1", Vn = { root: An }, Mn = ({ tweet: e }) => /* @__PURE__ */ h("a", { href: e.in_reply_to_url, className: Vn.root, target: "_blank", rel: "noopener noreferrer", children: [ "Replying to @", e.in_reply_to_screen_name ] }), jn = "_root_eihfa_1", Wn = { root: jn }, yt = ({ href: e, children: t }) => /* @__PURE__ */ r("a", { href: e, className: Wn.root, target: "_blank", rel: "noopener noreferrer nofollow", children: t }), Bn = "_root_1xq52_1", Fn = { root: Bn }, Pn = ({ tweet: e }) => /* @__PURE__ */ h("p", { className: Fn.root, lang: e.lang, dir: "auto", children: [ e.entities.map((t, n) => { switch (t.type) { case "hashtag": case "mention": case "url": case "symbol": return /* @__PURE__ */ r(yt, { href: t.href, children: t.text }, n); case "media": return; default: return /* @__PURE__ */ r("span", { dangerouslySetInnerHTML: { __html: t.text } }, n); } }), e.note_tweet ? /* @__PURE__ */ r(Un, { tweet: e }) : null ] }); function Un({ tweet: e }) { return /* @__PURE__ */ h(yt, { href: e.url, children: [ /* @__PURE__ */ r("span", { children: " " }), "Show more" ] }); } const zn = { hour: "numeric", minute: "2-digit", hour12: !0, weekday: "short", month: "short", day: "numeric", year: "numeric" }, Hn = new Intl.DateTimeFormat("en-US", zn), Gn = (e) => { const t = {}; for (const n of e) t[n.type] = n.value; return t; }, Xn = (e) => { const t = Gn(Hn.formatToParts(e)), n = `${t.hour}:${t.minute} ${t.dayPeriod}`, o = `${t.month} ${t.day}, ${t.year}`; return `${n} · ${o}`; }, at = (e) => `https://x.com/${e.user.screen_name}/status/${e.id_str}`, bt = (e) => `https://x.com/${typeof e == "string" ? e : e.user.screen_name}`, Kn = (e) => `https://x.com/intent/like?tweet_id=${e.id_str}`, Qn = (e) => `https://x.com/intent/tweet?in_reply_to=${e.id_str}`, Jn = (e) => `https://x.com/intent/follow?screen_name=${e.user.screen_name}`, Yn = (e) => `https://x.com/hashtag/${e.text}`, Zn = (e) => `https://x.com/search?q=%24${e.text}`, er = (e) => `https://x.com/${e.in_reply_to_screen_name}/status/${e.in_reply_to_status_id_str}`, Tt = (e, t) => { const n = new URL(e.media_url_https), o = n.pathname.split(".").pop(); return o ? (n.pathname = n.pathname.replace(`.${o}`, ""), n.searchParams.set("format", o), n.searchParams.set("name", t), n.toString()) : e.media_url_https; }, tr = (e) => { const { variants: t } = e.video_info; return t.filter((o) => o.content_type === "video/mp4").sort((o, a) => { var i, s; return ((i = a.bitrate) != null ? i : 0) - ((s = o.bitrate) != null ? s : 0); }); }, nr = (e) => { const t = tr(e); return t.length > 1 ? t[1] : t[0]; }, Le = (e) => e > 999999 ? `${(e / 1e6).toFixed(1)}M` : e > 999 ? `${(e / 1e3).toFixed(1)}K` : e.toString(); function st(e) { const t = Array.from(e.text), n = [ { indices: e.display_text_range, type: "text" } ]; return de(n, "hashtag", e.entities.hashtags), de(n, "mention", e.entities.user_mentions), de(n, "url", e.entities.urls), de(n, "symbol", e.entities.symbols), e.entities.media && de(n, "media", e.entities.media), rr(e, n), n.map((o) => { const a = t.slice(o.indices[0], o.indices[1]).join(""); switch (o.type) { case "hashtag": return Object.assign(o, { href: Yn(o), text: a }); case "mention": return Object.assign(o, { href: bt(o.screen_name), text: a }); case "url": case "media": return Object.assign(o, { href: o.expanded_url, text: o.display_url }); case "symbol": return Object.assign(o, { href: Zn(o), text: a }); default: return Object.assign(o, { text: a }); } }); } function de(e, t, n) { for (const o of n) for (const [a, i] of e.entries()) { if (i.indices[0] > o.indices[0] || i.indices[1] < o.indices[1]) continue; const s = [ { ...o, type: t } ]; i.indices[0] < o.indices[0] && s.unshift({ indices: [ i.indices[0], o.indices[0] ], type: "text" }), i.indices[1] > o.indices[1] && s.push({ indices: [ o.indices[1], i.indices[1] ], type: "text" }), e.splice(a, 1, ...s); break; } } function rr(e, t) { e.entities.media && e.entities.media[0].indices[0] < e.display_text_range[1] && (e.display_text_range[1] = e.entities.media[0].indices[0]); const n = t.at(-1); n && n.indices[1] > e.display_text_range[1] && (n.indices[1] = e.display_text_range[1]); } const or = (e) => ({ ...e, url: at(e), user: { ...e.user, url: bt(e), follow_url: Jn(e) }, like_url: Kn(e), reply_url: Qn(e), in_reply_to_url: e.in_reply_to_screen_name ? er(e) : void 0, entities: st(e), quoted_tweet: e.quoted_tweet ? { ...e.quoted_tweet, url: at(e.quoted_tweet), entities: st(e.quoted_tweet) } : void 0 }), ar = "_root_g9tkv_1", sr = "_rounded_g9tkv_6", ir = "_mediaWrapper_g9tkv_10", cr = "_grid2Columns_g9tkv_17", lr = "_grid3_g9tkv_20", dr = "_grid2x2_g9tkv_23", ur = "_mediaContainer_g9tkv_26", fr = "_mediaLink_g9tkv_34", hr = "_skeleton_g9tkv_38", _r = "_image_g9tkv_43", C = { root: ar, rounded: sr, mediaWrapper: ir, grid2Columns: cr, grid3: lr, grid2x2: dr, mediaContainer: ur, mediaLink: fr, skeleton: hr, image: _r }, mr = "_anchor_fp31d_1", pr = "_videoButton_fp31d_17", vr = "_videoButtonIcon_fp31d_35", gr = "_watchOnTwitter_fp31d_44", wr = "_viewReplies_fp31d_60", ae = { anchor: mr, videoButton: pr, videoButtonIcon: vr, watchOnTwitter: gr, viewReplies: wr }, yr = ({ tweet: e, media: t }) => { const [n, o] = se(!0), [a, i] = se(!1), [s, c] = se(!1), f = nr(t); let d = 0; return /* @__PURE__ */ h(Pt, { children: [ /* @__PURE__ */ r("video", { className: C.image, poster: Tt(t, "small"), controls: !n, playsInline: !0, preload: "none", tabIndex: n ? -1 : 0, onPlay: () => { d && window.clearTimeout(d), a || i(!0), s && c(!1); }, onPause: () => { d && window.clearTimeout(d), d = window.setTimeout(() => { a && i(!1), d = 0; }, 100); }, onEnded: () => { c(!0); }, children: /* @__PURE__ */ r("source", { src: f.url, type: f.content_type }) }), n && /* @__PURE__ */ r("button", { type: "button", className: ae.videoButton, "aria-label": "View video on X", onClick: (g) => { const m = g.currentTarget.previousSibling; g.preventDefault(), o(!1), m.load(), m.play().then(() => { i(!0), m.focus(); }).catch((b) => { console.error("Error playing video:", b), o(!0), i(!1); }); }, children: /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", className: ae.videoButtonIcon, "aria-hidden": "true", children: /* @__PURE__ */ r("g", { children: /* @__PURE__ */ r("path", { d: "M21 12L4 2v20l17-10z" }) }) }) }), !a && !s && /* @__PURE__ */ r("div", { className: ae.watchOnTwitter, children: /* @__PURE__ */ r("a", { href: e.url, className: ae.anchor, target: "_blank", rel: "noopener noreferrer", children: n ? "Watch on X" : "Continue watching on X" }) }), s && /* @__PURE__ */ r("a", { href: e.url, className: U(ae.anchor, ae.viewReplies), target: "_blank", rel: "noopener noreferrer", children: "View replies" }) ] }); }, br = (e) => /* @__PURE__ */ r("img", { ...e }), it = (e, t) => { let n = 56.25; return t === 1 && (n = 100 / e.original_info.width * e.original_info.height), t === 2 && (n = n * 2), { width: e.type === "photo" ? void 0 : "unset", paddingBottom: `${n}%` }; }, xt = ({ tweet: e, components: t, quoted: n }) => { var o, a, i; const s = (i = (o = e.mediaDetails) == null ? void 0 : o.length) != null ? i : 0; var c; const f = (c = t == null ? void 0 : t.MediaImg) != null ? c : br; return /* @__PURE__ */ r("div", { className: U(C.root, !n && C.rounded), children: /* @__PURE__ */ r("div", { className: U(C.mediaWrapper, s > 1 && C.grid2Columns, s === 3 && C.grid3, s > 4 && C.grid2x2), children: (a = e.mediaDetails) == null ? void 0 : a.map((d) => /* @__PURE__ */ r(Ut, { children: d.type === "photo" ? /* @__PURE__ */ h("a", { href: e.url, className: U(C.mediaContainer, C.mediaLink), target: "_blank", rel: "noopener noreferrer", children: [ /* @__PURE__ */ r("div", { className: C.skeleton, style: it(d, s) }), /* @__PURE__ */ r(f, { src: Tt(d, "small"), alt: d.ext_alt_text || "Image", className: C.image, draggable: !0 }) ] }, d.media_url_https) : /* @__PURE__ */ h("div", { className: C.mediaContainer, children: [ /* @__PURE__ */ r("div", { className: C.skeleton, style: it(d, s) }), /* @__PURE__ */ r(yr, { tweet: e, media: d }) ] }, d.media_url_https) }, d.media_url_https)) }) }); }, Tr = "_root_i24yn_1", xr = { root: Tr }, Nr = ({ tweet: e }) => { const t = new Date(e.created_at), n = Xn(t); return /* @__PURE__ */ r("a", { className: xr.root, href: e.url, target: "_blank", rel: "noopener noreferrer", "aria-label": n, children: /* @__PURE__ */ r("time", { dateTime: t.toISOString(), children: n }) }); }, Ir = "_info_19qcj_1", Rr = "_infoLink_19qcj_10", Sr = "_infoIcon_19qcj_30", Ne = { info: Ir, infoLink: Rr, infoIcon: Sr }, kr = ({ tweet: e }) => /* @__PURE__ */ h("div", { className: Ne.info, children: [ /* @__PURE__ */ r(Nr, { tweet: e }), /* @__PURE__ */ r("a", { className: Ne.infoLink, href: "https://help.x.com/en/x-for-websites-ads-info-and-privacy", target: "_blank", rel: "noopener noreferrer", "aria-label": "Twitter for Websites, Ads Information and Privacy", children: /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", className: Ne.infoIcon, children: /* @__PURE__ */ r("g", { children: /* @__PURE__ */ r("path", { d: "M13.5 8.5c0 .83-.67 1.5-1.5 1.5s-1.5-.67-1.5-1.5S11.17 7 12 7s1.5.67 1.5 1.5zM13 17v-5h-2v5h2zm-1 5.25c5.66 0 10.25-4.59 10.25-10.25S17.66 1.75 12 1.75 1.75 6.34 1.75 12 6.34 22.25 12 22.25zM20.25 12c0 4.56-3.69 8.25-8.25 8.25S3.75 16.56 3.75 12 7.44 3.75 12 3.75s8.25 3.69 8.25 8.25z" }) }) }) }) ] }), Er = "_actions_n2anf_1", Cr = "_like_n2anf_13", Or = "_reply_n2anf_14", Lr = "_copy_n2anf_15", $r = "_likeIconWrapper_n2anf_27", qr = "_likeCount_n2anf_30", Dr = "_replyIconWrapper_n2anf_35", Ar = "_copyIconWrapper_n2anf_36", Vr = "_likeIcon_n2anf_27", Mr = "_replyIcon_n2anf_35", jr = "_copyIcon_n2anf_36", Wr = "_replyText_n2anf_56", Br = "_copyText_n2anf_57", k = { actions: Er, like: Cr, reply: Or, copy: Lr, likeIconWrapper: $r, likeCount: qr, replyIconWrapper: Dr, copyIconWrapper: Ar, likeIcon: Vr, replyIcon: Mr, copyIcon: jr, replyText: Wr, copyText: Br }, Fr = ({ tweet: e }) => { const [t, n] = se(!1), o = () => { navigator.clipboard.writeText(e.url), n(!0); }; return Fe(() => { if (t) { const a = setTimeout(() => { n(!1); }, 6e3); return () => clearTimeout(a); } }, [ t ]), /* @__PURE__ */ h("button", { type: "button", className: k.copy, "aria-label": "Copy link", onClick: o, children: [ /* @__PURE__ */ r("div", { className: k.copyIconWrapper, children: t ? /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", className: k.copyIcon, "aria-hidden": "true", children: /* @__PURE__ */ r("g", { children: /* @__PURE__ */ r("path", { d: "M9.64 18.952l-5.55-4.861 1.317-1.504 3.951 3.459 8.459-10.948L19.4 6.32 9.64 18.952z" }) }) }) : /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", className: k.copyIcon, "aria-hidden": "true", children: /* @__PURE__ */ r("g", { children: /* @__PURE__ */ r("path", { d: "M18.36 5.64c-1.95-1.96-5.11-1.96-7.07 0L9.88 7.05 8.46 5.64l1.42-1.42c2.73-2.73 7.16-2.73 9.9 0 2.73 2.74 2.73 7.17 0 9.9l-1.42 1.42-1.41-1.42 1.41-1.41c1.96-1.96 1.96-5.12 0-7.07zm-2.12 3.53l-7.07 7.07-1.41-1.41 7.07-7.07 1.41 1.41zm-12.02.71l1.42-1.42 1.41 1.42-1.41 1.41c-1.96 1.96-1.96 5.12 0 7.07 1.95 1.96 5.11 1.96 7.07 0l1.41-1.41 1.42 1.41-1.42 1.42c-2.73 2.73-7.16 2.73-9.9 0-2.73-2.74-2.73-7.17 0-9.9z" }) }) }) }), /* @__PURE__ */ r("span", { className: k.copyText, children: t ? "Copied!" : "Copy link" }) ] }); }, Pr = ({ tweet: e }) => { const t = Le(e.favorite_count); return /* @__PURE__ */ h("div", { className: k.actions, children: [ /* @__PURE__ */ h("a", { className: k.like, href: e.like_url, target: "_blank", rel: "noopener noreferrer", "aria-label": `Like. This Tweet has ${t} likes`, children: [ /* @__PURE__ */ r("div", { className: k.likeIconWrapper, children: /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", className: k.likeIcon, "aria-hidden": "true", children: /* @__PURE__ */ r("g", { children: /* @__PURE__ */ r("path", { d: "M20.884 13.19c-1.351 2.48-4.001 5.12-8.379 7.67l-.503.3-.504-.3c-4.379-2.55-7.029-5.19-8.382-7.67-1.36-2.5-1.41-4.86-.514-6.67.887-1.79 2.647-2.91 4.601-3.01 1.651-.09 3.368.56 4.798 2.01 1.429-1.45 3.146-2.1 4.796-2.01 1.954.1 3.714 1.22 4.601 3.01.896 1.81.846 4.17-.514 6.67z" }) }) }) }), /* @__PURE__ */ r("span", { className: k.likeCount, children: t }) ] }), /* @__PURE__ */ h("a", { className: k.reply, href: e.reply_url, target: "_blank", rel: "noopener noreferrer", "aria-label": "Reply to this Tweet on Twitter", children: [ /* @__PURE__ */ r("div", { className: k.replyIconWrapper, children: /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", className: k.replyIcon, "aria-hidden": "true", children: /* @__PURE__ */ r("g", { children: /* @__PURE__ */ r("path", { d: "M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01z" }) }) }) }), /* @__PURE__ */ r("span", { className: k.replyText, children: "Reply" }) ] }), /* @__PURE__ */ r(Fr, { tweet: e }) ] }); }, Ur = "_replies_1cutb_1", zr = "_link_1cutb_4", Hr = "_text_1cutb_23", Ie = { replies: Ur, link: zr, text: Hr }, Gr = ({ tweet: e }) => /* @__PURE__ */ r("div", { className: Ie.replies, children: /* @__PURE__ */ r("a", { className: Ie.link, href: e.url, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ r("span", { className: Ie.text, children: e.conversation_count === 0 ? "Read more on X" : e.conversation_count === 1 ? `Read ${Le(e.conversation_count)} reply` : `Read ${Le(e.conversation_count)} replies` }) }) }), Xr = "_root_q5799_1", Kr = "_article_q5799_16", ct = { root: Xr, article: Kr }, Qr = ({ tweet: e, children: t }) => /* @__PURE__ */ r("div", { className: ct.root, onClick: (n) => { n.preventDefault(), window.open(e.url, "_blank"); }, children: /* @__PURE__ */ r("article", { className: ct.article, children: t }) }), Jr = "_header_f00ab_1", Yr = "_avatar_f00ab_11", Zr = "_avatarOverflow_f00ab_16", eo = "_avatarSquare_f00ab_23", to = "_author_f00ab_27", no = "_authorText_f00ab_33", ro = "_username_f00ab_40", Q = { header: Jr, avatar: Yr, avatarOverflow: Zr, avatarSquare: eo, author: to, authorText: no, username: ro }, oo = ({ tweet: e, components: t }) => { const { user: n } = e; var o; const a = (o = t == null ? void 0 : t.AvatarImg) != null ? o : vt; return /* @__PURE__ */ h("div", { className: Q.header, children: [ /* @__PURE__ */ r("a", { href: e.url, className: Q.avatar, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ r("div", { className: U(Q.avatarOverflow, n.profile_image_shape === "Square" && Q.avatarSquare), children: /* @__PURE__ */ r(a, { src: n.profile_image_url_https, alt: n.name, width: 20, height: 20 }) }) }), /* @__PURE__ */ h("div", { className: Q.author, children: [ /* @__PURE__ */ r("div", { className: Q.authorText, children: /* @__PURE__ */ r("span", { title: n.name, children: n.name }) }), /* @__PURE__ */ r(gt, { user: n }), /* @__PURE__ */ r(wt, { user: n }), /* @__PURE__ */ r("div", { className: Q.username, children: /* @__PURE__ */ h("span", { title: `@${n.screen_name}`, children: [ "@", n.screen_name ] }) }) ] }) ] }); }, ao = "_root_175ot_1", so = { root: ao }, io = ({ tweet: e }) => /* @__PURE__ */ r("p", { className: so.root, lang: e.lang, dir: "auto", children: e.entities.map((t, n) => /* @__PURE__ */ r("span", { dangerouslySetInnerHTML: { __html: t.text } }, n)) }), co = ({ tweet: e, components: t }) => { var n; return /* @__PURE__ */ h(Qr, { tweet: e, children: [ /* @__PURE__ */ r(oo, { tweet: e, components: t }), /* @__PURE__ */ r(io, { tweet: e }), (n = e.mediaDetails) != null && n.length ? /* @__PURE__ */ r(xt, { quoted: !0, tweet: e }) : null ] }); }, lo = ({ tweet: e, components: t }) => { var n; const o = Pe(() => or(e), [ e ]); return /* @__PURE__ */ h(ze, { children: [ /* @__PURE__ */ r(Dn, { tweet: o, components: t }), o.in_reply_to_status_id_str && /* @__PURE__ */ r(Mn, { tweet: o }), /* @__PURE__ */ r(Pn, { tweet: o }), (n = o.mediaDetails) != null && n.length ? /* @__PURE__ */ r(xt, { tweet: o, components: t }) : null, o.quoted_tweet && /* @__PURE__ */ r(co, { tweet: o.quoted_tweet, components: t }), /* @__PURE__ */ r(kr, { tweet: o }), /* @__PURE__ */ r(Pr, { tweet: o }), /* @__PURE__ */ r(Gr, { tweet: o }) ] }); }, uo = "_root_16yxa_1", fo = { root: uo }, ho = (e) => /* @__PURE__ */ r(ze, { children: /* @__PURE__ */ h("div", { className: fo.root, children: [ /* @__PURE__ */ r("h3", { children: "Tweet not found" }), /* @__PURE__ */ r("p", { children: "The embedded tweet could not be found…" }) ] }) }), _o = "_skeleton_oi7hr_1", mo = { skeleton: _o }, pe = ({ style: e }) => /* @__PURE__ */ r("span", { className: mo.skeleton, style: e }), po = "_root_17qqv_1", vo = { root: po }, go = () => /* @__PURE__ */ h(ze, { className: vo.root, children: [ /* @__PURE__ */ r(pe, { style: { height: "3rem", marginBottom: "0.75rem" } }), /* @__PURE__ */ r(pe, { style: { height: "6rem", margin: "0.5rem 0" } }), /* @__PURE__ */ r("div", { style: { borderTop: "var(--tweet-border)", margin: "0.5rem 0" } }), /* @__PURE__ */ r(pe, { style: { height: "2rem" } }), /* @__PURE__ */ r(pe, { style: { height: "2rem", borderRadius: "9999px", marginTop: "0.5rem" } }) ] }), Nt = 0, It = 1, Rt = 2, lt = 3; var dt = Object.prototype.hasOwnProperty; function $e(e, t) { var n, o; if (e === t) return !0; if (e && t && (n = e.constructor) === t.constructor) { if (n === Date) return e.getTime() === t.getTime(); if (n === RegExp) return e.toString() === t.toString(); if (n === Array) { if ((o = e.length) === t.length) for (; o-- && $e(e[o], t[o]); ) ; return o === -1; } if (!n || typeof e == "object") { o = 0; for (n in e) if (dt.call(e, n) && ++o && !dt.call(t, n) || !(n in t) || !$e(e[n], t[n])) return !1; return Object.keys(t).length === o; } } return e !== e && t !== t; } const F = /* @__PURE__ */ new WeakMap(), P = () => { }, R = ( /*#__NOINLINE__*/ P() ), qe = Object, u = (e) => e === R, j = (e) => typeof e == "function", z = (e, t) => ({ ...e, ...t }), St = (e) => j(e.then), Re = {}, ve = {}, He = "undefined", ue = typeof window != He, De = typeof document != He, wo = ue && "Deno" in window, yo = () => ue && typeof window.requestAnimationFrame != He, kt = (e, t) => { const n = F.get(e); return [ // Getter () => !u(t) && e.get(t) || Re, // Setter (o) => { if (!u(t)) { const a = e.get(t); t in ve || (ve[t] = a), n[5](t, z(a, o), a || Re); } }, // Subscriber n[6], // Get server cache snapshot () => !u(t) && t in ve ? ve[t] : !u(t) && e.get(t) || Re ]; }; let Ae = !0; const bo = () => Ae, [Ve, Me] = ue && window.addEventListener ? [ window.addEventListener.bind(window), window.removeEventListener.bind(window) ] : [ P, P ], To = () => { const e = De && document.visibilityState; return u(e) || e !== "hidden"; }, xo = (e) => (De && document.addEventListener("visibilitychange", e), Ve("focus", e), () => { De && document.removeEventListener("visibilitychange", e), Me("focus", e); }), No = (e) => { const t = () => { Ae = !0, e(); }, n = () => { Ae = !1; }; return Ve("online", t), Ve("offline", n), () => { Me("online", t), Me("offline", n); }; }, Io = { isOnline: bo, isVisible: To }, Ro = { initFocus: xo, initReconnect: No }, ut = !Be.useId, ie = !ue || wo, So = (e) => yo() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Se = ie ? Fe : Ht, ke = typeof navigator < "u" && navigator.connection, ft = !ie && ke && ([ "slow-2g", "2g" ].includes(ke.effectiveType) || ke.saveData), ge = /* @__PURE__ */ new WeakMap(), ko = (e) => qe.prototype.toString.call(e), Ee = (e, t) => e === `[object ${t}]`; let Eo = 0; const je = (e) => { const t = typeof e, n = ko(e), o = Ee(n, "Date"), a = Ee(n, "RegExp"), i = Ee(n, "Object"); let s, c; if (qe(e) === e && !o && !a) { if (s = ge.get(e), s) return s; if (s = ++Eo + "~", ge.set(e, s), Array.isArray(e)) { for (s = "@", c = 0; c < e.length; c++) s += je(e[c]) + ","; ge.set(e, s); } if (i) { s = "#"; const f = qe.keys(e).sort(); for (; !u(c = f.pop()); ) u(e[c]) || (s += c + ":" + je(e[c]) + ","); ge.set(e, s); } } else s = o ? e.toJSON() : t == "symbol" ? e.toString() : t == "string" ? JSON.stringify(e) : "" + e; return s; }, Ge = (e) => { if (j(e)) try { e = e(); } catch { e = ""; } const t = e; return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? je(e) : "", [ e, t ]; }; let Co = 0; const We = () => ++Co; async function Et(...e) { const [t, n, o, a] = e, i = z({ populateCache: !0, throwOnError: !0 }, typeof a == "boolean" ? { revalidate: a } : a || {}); let s = i.populateCache; const c = i.rollbackOnError; let f = i.optimisticData; const d = (b) => typeof c == "function" ? c(b) : c !== !1, g = i.throwOnError; if (j(n)) { const b = n, I = [], E = t.keys(); for (const L of E) // Skip the special useSWRInfinite and useSWRSubscription keys. !/^\$(inf|sub)\$/.test(L) && b(t.get(L)._k) && I.push(L); return Promise.all(I.map(m)); } return m(n); async function m(b) { const [I] = Ge(b); if (!I) return; const [E, L] = kt(t, I), [D, ce, l, fe] = F.get(t), J = () => { const $ = D[I]; return (j(i.revalidate) ? i.revalidate(E().data, b) : i.revalidate !== !1) && (delete l[I], delete fe[I], $ && $[0]) ? $[0](Rt).then(() => E().data) : E().data; }; if (e.length < 3) return J(); let T = o, A, V = !1; const Y = We(); ce[I] = [ Y, 0 ]; const p = !u(f), Z = E(), M = Z.data, ee = Z._c, H = u(ee) ? M : ee; if (p && (f = j(f) ? f(H, M) : f, L({ data: f, _c: H })), j(T)) try { T = T(H); } catch ($) { A = $, V = !0; } if (T && St(T)) if (T = await T.catch(($) => { A = $, V = !0; }), Y !== ce[I][0]) { if (V) throw A; return T; } else V && p && d(A) && (s = !0, L({ data: H, _c: R })); if (s && !V) if (j(s)) { const $ = s(T, H); L({ data: $, error: R, _c: R }); } else L({ data: T, error: R, _c: R }); if (ce[I][1] = We(), Promise.resolve(J()).then(() => { L({ _c: R }); }), V) { if (g) throw A; return; } return T; } } const ht = (e, t) => { for (const n in e) e[n][0] && e[n][0](t); }, Oo = (e, t) => { if (!F.has(e)) { const n = z(Ro, t), o = /* @__PURE__ */ Object.create(null), a = Et.bind(R, e); let i = P; const s = /* @__PURE__ */ Object.create(null), c = (g, m) => { const b = s[g] || []; return s[g] = b, b.push(m), () => b.splice(b.indexOf(m), 1); }, f = (g, m, b) => { e.set(g, m); const I = s[g]; if (I) for (const E of I) E(m, b); }, d = () => { if (!F.has(e) && (F.set(e, [ o, /* @__PURE__ */ Object.create(null), /* @__PURE__ */ Object.create(null), /* @__PURE__ */ Object.create(null), a, f, c ]), !ie)) { const g = n.initFocus(setTimeout.bind(R, ht.bind(R, o, Nt))), m = n.initReconnect(setTimeout.bind(R, ht.bind(R, o, It))); i = () => { g && g(), m && m(), F.delete(e); }; } }; return d(), [ e, a, d, i ]; } return [ e, F.get(e)[4] ]; }, Lo = (e, t, n, o, a) => { const i = n.errorRetryCount, s = a.retryCount, c = ~~((Math.random() + 0.5) * (1 << (s < 8 ? s : 8))) * n.errorRetryInterval; !u(i) && s > i || setTimeout(o, c, a); }, $o = $e, [Ct, qo] = Oo(/* @__PURE__ */ new Map()), Do = z( { // events onLoadingSlow: P, onSuccess: P, onError: P, onErrorRetry: Lo, onDiscarded: P, // switches revalidateOnFocus: !0, revalidateOnReconnect: !0, revalidateIfStale: !0, shouldRetryOnError: !0, // timeouts errorRetryInterval: ft ? 1e4 : 5e3, focusThrottleInterval: 5 * 1e3, dedupingInterval: 2 * 1e3, loadingTimeout: ft ? 5e3 : 3e3, // providers compare: $o, isPaused: () => !1, cache: Ct, mutate: qo, fallback: {} }, // use web preset by default Io ), Ao = (e, t) => { const n = z(e, t); if (t) { const { use: o, fallback: a } = e, { use: i, fallback: s } = t; o && i && (n.use = o.concat(i)), a && s && (n.fallback = z(a, s)); } return n; }, Vo = zt({}), Mo = "$inf$", Ot = ue && window.__SWR_DEVTOOLS_USE__, jo = Ot ? window.__SWR_DEVTOOLS_USE__ : [], Wo = () => { Ot && (window.__SWR_DEVTOOLS_REACT__ = Be); }, Bo = (e) => j(e[1]) ? [ e[0], e[1], e[2] || {} ] : [ e[0], null, (e[1] === null ? e[2] : e[1]) || {} ], Fo = () => { const e = Gt(Vo); return Pe(() => z(Do, e), [ e ]); }, Po = (e) => (t, n, o) => e(t, n && ((...i) => { const [s] = Ge(t), [, , , c] = F.get(Ct); if (s.startsWith(Mo)) return n(...i); const f = c[s]; return u(f) ? n(...i) : (delete c[s], f); }), o), Uo = jo.concat(Po), zo = (e) => function(...n) { const o = Fo(), [a, i, s] = Bo(n), c = Ao(o, s); let f = e; const { use: d } = c, g = (d || []).concat(Uo); for (let m = g.length; m--; ) f = g[m](f); return f(a, i || c.fetcher || null, c); }, Ho = (e, t, n) => { const o = t[e] || (t[e] = []); return o.push(n), () => { const a = o.indexOf(n); a >= 0 && (o[a] = o[o.length - 1], o.pop()); }; }; Wo(); const Ce = Be.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax // and emitting an error. // We assume that this is only for the `use(thenable)` case, not `use(context)`. // https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45 ((e) => { switch (e.status) { case "pending": throw e; case "fulfilled": return e.value; case "rejected": throw e.reason; default: throw e.status = "pending", e.then((t) => { e.status = "fulfilled", e.value = t; }, (t) => { e.status = "rejected", e.reason = t; }), e; } }), Oe = { dedupe: !0 }, _t = Promise.resolve(R), Go = (e, t, n) => { const { cache: o, compare: a, suspense: i, fallbackData: s, revalidateOnMount: c, revalidateIfStale: f, refreshInterval: d, refreshWhenHidden: g, refreshWhenOffline: m, keepPreviousData: b, strictServerPrefetchWarning: I } = n, [E, L, D, ce] = F.get(o), [l, fe] = Ge(e), J = K(!1), T = K(!1), A = K(l), V = K(t), Y = K(n), p = () => Y.current, Z = () => p().isVisible() && p().isOnline(), [M, ee, H, $] = kt(o, l), te = K({}).current, he = u(s) ? u(n.fallback) ? R : n.fallback[l] : s, Xe = (_, v) => { for (const y in te) { const w = y; if (w === "data") { if (!a(_[w], v[w]) && (!u(_[w]) || !a(me, v[w]))) return !1; } else if (v[w] !== _[w]) return !1; } return !0; }, Ke = Pe(() => { const _ = !l || !t ? !1 : u(c) ? p().isPaused() || i ? !1 : f !== !1 : c, v = (S) => { const W = z(S); return delete W._k, _ ? { isValidating: !0, isLoading: !0, ...W } : W; }, y = M(), w = $(), q = v(y), oe = y === w ? q : v(w); let x = q; return [ () => { const S = v(M()); return Xe(S, x) ? (x.data = S.data, x.isLoading = S.isLoading, x.isValidating = S.isValidating, x.error = S.error, x) : (x = S, S); }, () => oe ]; }, [ o, l ]), ne = rt.useSyncExternalStore(Te( (_) => H(l, (v, y) => { Xe(y, v) || _(); }), // eslint-disable-next-line react-hooks/exhaustive-deps [ o, l ] ), Ke[0], Ke[1]), Qe = !J.current, $t = E[l] && E[l].length > 0, re = ne.data, G = u(re) ? he && St(he) ? Ce(he) : he : re, _e = ne.error, we = K(G), me = b ? u(re) ? u(we.current) ? G : we.current : re : G, X = l && u(G), qt = !ie && // eslint-disable-next-line react-hooks/rules-of-hooks rt.useSyncExternalStore(() => P, () => !1, () => !0); I && qt && !i && X && console.warn(`Missing pre-initiated data for serialized key "${l}" during server-side rendering. Data fethcing should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`); const Je = $t && !u(_e) ? !1 : Qe && !u(c) ? c : p().isPaused() ? !1 : i ? u(G) ? !1 : f : u(G) || f, Ye = !!(l && t && Qe && Je), Dt = u(ne.isValidating) ? Ye : ne.isValidating, At = u(ne.isLoading) ? Ye : ne.isLoading, le = Te( async (_) => { const v = V.current; if (!l || !v || T.current || p().isPaused()) return !1; let y, w, q = !0; const oe = _ || {}, x = !D[l] || !oe.dedupe, S = () => ut ? !T.current && l === A.current && J.current : l === A.current, W = { isValidating: !1, isLoading: !1 }, et = () => { ee(W); }, tt = () => { const O = D[l]; O && O[1] === w && delete D[l]; }, nt = { isValidating: !0 }; u(M().data) && (nt.isLoading = !0); try { if (x && (ee(nt), n.loadingTimeout && u(M().data) && setTimeout(() => { q && S() && p().onLoadingSlow(l, n); }, n.loadingTimeout), D[l] = [ v(fe), We() ]), [y, w] = D[l], y = await y, x && setTimeout(tt, n.dedupingInterval), !D[l] || D[l][1] !== w) return x && S() && p().onDiscarded(l), !1; W.error = R; const O = L[l]; if (!u(O) && // case 1 (w <= O[0] || // case 2 w <= O[1] || // case 3 O[1] === 0)) return et(), x && S() && p().onDiscarded(l), !1; const B = M().data; W.data = a(B, y) ? B : y, x && S() && p().onSuccess(y, l, n); } catch (O) { tt(); const B = p(), { shouldRetryOnError: ye } = B; B.isPaused() || (W.error = O, x && S() && (B.onError(O, l, B), (ye === !0 || j(ye) && ye(O)) && (!p().revalidateOnFocus || !p().revalidateOnReconnect || Z()) && B.onErrorRetry(O, l, B, (Vt) => { const be = E[l]; be && be[0] && be[0](lt, Vt); }, { retryCount: (oe.retryCount || 0) + 1, dedupe: !0 }))); } return q = !1, et(), !0; }, // `setState` is immutable, and `eventsCallback`, `fnArg`, and // `keyValidating` are depending on `key`, so we can exclude them from // the deps array. // // FIXME: // `fn` and `config` might be changed during the lifecycle, // but they might be changed every render like this. // `useSWR('key', () => fetch('/api/'), { suspense: true })` // So we omit the values from the deps array // even though it might cause unexpected behaviors. // eslint-disable-next-line react-hooks/exhaustive-deps [ l, o ] ), Ze = Te( // Use callback to make sure `keyRef.current` returns latest result every time (..._) => Et(o, A.current, ..._), // eslint-disable-next-line react-hooks/exhaustive-deps [] ); if (Se(() => { V.current = t, Y.current = n, u(re) || (we.current = re); }), Se(() => { if (!l) return; const _ = le.bind(R, Oe); let v = 0; p().revalidateOnFocus && (v = Date.now() + p().focusThrottleInterval); const w = Ho(l, E, (q, oe = {}) => { if (q == Nt) { const x = Date.now(); p().revalidateOnFocus && x > v && Z() && (v = x + p().focusThrottleInterval, _()); } else if (q == It) p().revalidateOnReconnect && Z() && _(); else { if (q == Rt) return le(); if (q == lt) return le(oe); } }); return T.current = !1, A.current = l, J.current = !0, ee({ _k: fe }), Je && (D[l] || (u(G) || ie ? _() : So(_))), () => { T.current = !0, w(); }; }, [ l ]), Se(() => { let _; function v() { const w = j(d) ? d(M().data) : d; w && _ !== -1 && (_ = setTimeout(y, w)); } function y() { !M().error && (g || p().isVisible()) && (m || p().isOnline()) ? le(Oe).then(v) : v(); } return v(), () => { _ && (clearTimeout(_), _ = -1); }; }, [ d, g, m, l ]), Xt(me), i) { if (!ut && ie && X) throw new Error("Fallback data is required when using Suspense in SSR."); X && (V.current = t, Y.current = n, T.current = !1); const _ = ce[l], v = !u(_) && X ? Ze(_) : _t; if (Ce(v), !u(_e) && X) throw _e; const y = X ? le(Oe) : _t; !u(me) && X && (y.status = "fulfilled", y.value = !0), Ce(y); } return { mutate: Ze, get data() { return te.data = !0, me; }, get error() { return te.error = !0, _e; }, get isValidating() { return te.isValidating = !0, Dt; }, get isLoading() { return te.isLoading = !0, At; } }; }, mt = zo(Go); class Xo extends Error { constructor({ message: t, status: n, data: o }) { super(t), this.name = "TwitterApiError", this.status = n, this.data = o; } } const Ko = mt.default || mt, Qo = "https://react-tweet.vercel.app"; async function Jo([e, t]) { const n = await fetch(e, t), o = await n.json(); if (n.ok) return o.data || null; throw new Xo({ message: `Failed to fetch tweet at "${e}" with "${n.status}".`, data: o, status: n.status }); } const Yo = (e, t, n) => { const { isLoading: o, data: a, error: i } = Ko(() => t || e ? [ t || e && `${Qo}/api/tweet/${e}`, n ] : null, Jo, { revalidateIfStale: !1, revalidateOnFocus: !1, shouldRetryOnError: !1 }); return { // If data is `undefined` then it might be the first render where SWR hasn't started doing // any work, so we set `isLoading` to `true`. isLoading: !!(o || a === void 0 && !i), data: a, error: i }; }, Zo = ({ id: e, apiUrl: t, fallback: n = /* @__PURE__ */ r(go, {}), components: o, fetchOptions: a, onError: i }) => { const { data: s, error: c, isLoading: f } = Yo(e, t, a); if (f) return n; if (c || !s) { const d = (o == null ? void 0 : o.TweetNotFound) || ho; return /* @__PURE__ */ r(d, { error: i ? i(c) : c }); } return /* @__PURE__ */ r(lo, { tweet: s, components: o }); }; function ea({ node: e }) { var o; const t = ((o = e == null ? void 0 : e.attrs) == null ? void 0 : o.src) || "", n = t == null ? void 0 : t.split("/").pop(); return n ? /* @__PURE__ */ r(Mt, { children: /* @__PURE__ */ r("div", { "data-twitter": "", children: /* @__PURE__ */ r(Zo, { id: n }) }) }) : null; } function ta(e) { const { t } = rn(), [n, o] = se(""); Fe(() => { var i; if (e != null && e.editor) { const { src: s } = (i = e.editor) == null ? void 0 : i.getAttributes(Lt.name); s && o(s); } }, [e == null ? void 0 : e.editor]); function a(i) { i.preventDefault(), i.stopPropagation(), e == null || e.onSetLink(n); } return /* @__PURE__ */ h( "form", { className: "richtext-flex richtext-flex-col richte