fansunited-frontend-components 0.0.98 → 1.0.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.
Files changed (68) hide show
  1. package/Betslip.js +2 -2
  2. package/ChanceGame.js +952 -1467
  3. package/ClassicQuizPlay.js +2 -2
  4. package/CollectLead.js +405 -1163
  5. package/CompetitionStatistics.js +2042 -2215
  6. package/CompetitorCard.js +4251 -5085
  7. package/Discussion.js +2 -2
  8. package/EitherOrPlay.js +2 -2
  9. package/EventCard.js +6062 -7544
  10. package/EventGamePlay.js +2 -2
  11. package/Leaderboard.js +556 -849
  12. package/List.js +689 -718
  13. package/MatchQuizPlay.js +2 -2
  14. package/Odds.js +50 -42
  15. package/PersonalityQuizPlay.js +2 -2
  16. package/PickThePair.js +925 -1824
  17. package/PlayerOfTheMatch.js +2106 -2207
  18. package/PollVote.js +2 -2
  19. package/Predictor.js +4208 -18675
  20. package/README.md +1 -1
  21. package/Standings.js +1014 -1336
  22. package/TopX.js +3223 -17005
  23. package/chunks/{ChanceGameEmbedVariant-CVys-3Zh.js → ChanceGameEmbedVariant-z8XYzgDW.js} +2 -2
  24. package/chunks/OddsSkeleton-DP5Yfqpr.js +522 -0
  25. package/chunks/PickOneOfX-IvE4OvyT.js +3146 -0
  26. package/chunks/index-BNl8scz6.js +4 -0
  27. package/chunks/index-CSa2JU4m.js +4 -0
  28. package/chunks/index-CVRI82Gb.js +4 -0
  29. package/chunks/index-Cd1dg0KI.js +4 -0
  30. package/chunks/index-Cei2fzi7.js +4 -0
  31. package/chunks/index-Cxb4wEJU.js +4 -0
  32. package/chunks/index-w1LGN5dz.js +4 -0
  33. package/chunks/main-07vzblS8.js +2091 -0
  34. package/chunks/main-C7X4dM_P.js +4827 -0
  35. package/chunks/main-D_QDfmAw.js +6417 -0
  36. package/chunks/main-DdL0UekL.js +4775 -0
  37. package/chunks/main-DmBfwyb4.js +2992 -0
  38. package/chunks/main-LEE8n2cG.js +3117 -0
  39. package/chunks/main-P2WNvBZE.js +1804 -0
  40. package/chunks/main-gV165E-A.js +1928 -0
  41. package/chunks/predictionsHelpers-fwXaMadu.js +10063 -0
  42. package/chunks/{withVersionStamp-T8seRk9h.js → withVersionStamp-CPDfSE5H.js} +1 -1
  43. package/package.json +2 -6
  44. package/withVersionStamp.d.ts.map +1 -1
  45. package/chunks/OddsSkeleton-ClJE2xhR.js +0 -26
  46. package/chunks/OddsStrip-BnSp5TXa.js +0 -383
  47. package/chunks/PickOneOfX-DaJtkbCw.js +0 -4206
  48. package/chunks/chevron-left-CxfCSZcr.js +0 -13
  49. package/chunks/chevron-right-BEQMacFn.js +0 -13
  50. package/chunks/chevrons-right-CXSpQt9w.js +0 -25
  51. package/chunks/createLucideIcon-YBRjY5Kl.js +0 -79
  52. package/chunks/index-Aq5MbUB9.js +0 -4
  53. package/chunks/index-BBQm_8LD.js +0 -4
  54. package/chunks/index-BC_sWWgc.js +0 -4
  55. package/chunks/index-DXKDJ1Vp.js +0 -4
  56. package/chunks/index-DjT5NrbA.js +0 -4
  57. package/chunks/index-DvLRehH6.js +0 -4
  58. package/chunks/index-aIMaxR-p.js +0 -4
  59. package/chunks/main-52Wff7qC.js +0 -11441
  60. package/chunks/main-65WcUqAl.js +0 -4013
  61. package/chunks/main-B58mi9jx.js +0 -5622
  62. package/chunks/main-BIdXUTZS.js +0 -7308
  63. package/chunks/main-DD-NEzC7.js +0 -8241
  64. package/chunks/main-DUnfJPzY.js +0 -3608
  65. package/chunks/main-DpCBqqg_.js +0 -1950
  66. package/chunks/main-Drznt1ak.js +0 -1790
  67. package/chunks/users-wbJRbqW8.js +0 -16
  68. package/chunks/x-CK4GYo7T.js +0 -14
@@ -0,0 +1,1928 @@
1
+ import { jsxs as b, jsx as n, Fragment as Re } from "@emotion/react/jsx-runtime";
2
+ import { InlineSpinner as bt, useTextareaAutosize as xt, autosizeShadowStyle as vt, Modal as lt, Avatar as St, Notification as dt, useSelect as wt, Spinner as Oe, WidgetPortal as Ct } from "fansunited-frontend-core/ui/emotion";
3
+ import Ie, { useState as I, useEffect as he, useRef as V, useCallback as Ce, useLayoutEffect as kt, useId as Rt } from "react";
4
+ import { useDisableCache as It, useColors as Et, bidiIsolateAuto as Dt, useIsRtl as Bt, useConstantContext as Ke, ConstantsContext as Ue, toIntlLocale as ut } from "fansunited-frontend-core";
5
+ import { css as o } from "@emotion/react";
6
+ import { useTranslation as be } from "react-i18next";
7
+ import { ThumbUpIcon as Pt, ThumbDownIcon as Tt, FavoriteIcon as At, SentimentSatisfiedIcon as Mt, FavoriteBorderIcon as Lt, EmojiEmotionsIcon as zt, SentimentVeryDissatisfiedIcon as Ft, MoodBadIcon as $t, ReplyIcon as Xt, MoreVertIcon as Ht, DeleteIcon as Ot, FlagIcon as Nt, CloseIcon as Wt, PersonIcon as Kt, RemoveCircleOutlineIcon as Ut, BlockIcon as Vt, KeyboardArrowDownIcon as _t, UnfoldIcon as jt } from "fansunited-frontend-core/ui/icons";
8
+ import { createPortal as Yt } from "react-dom";
9
+ const Gt = (t, r) => {
10
+ const [i, s] = I(null), [u, a] = I(!0), [m, d] = I(null), [l, c] = I(!1);
11
+ return he(() => {
12
+ r && (async () => {
13
+ try {
14
+ a(!0);
15
+ const f = await t.discussions.getById(r);
16
+ s(f), d(null), c(!1);
17
+ } catch (f) {
18
+ (t.helpers.getSDKConfiguration().errorHandlingMode === "standard" ? f.error.code === 404 : f.data.error.code === 404) ? (c(!0), d(null), s(null)) : (d(m), s(null), c(!1));
19
+ } finally {
20
+ a(!1);
21
+ }
22
+ })();
23
+ }, [t, r]), { discussion: i, setDiscussion: s, isLoading: u, error: m, isNotFound: l };
24
+ }, Jt = 5e3, qt = 5, Qt = (t, r, i = null, s = "", u = "LATEST", a = 20, m, d = !1, l = 0) => {
25
+ const c = a <= 0, [y, f] = I([]), [k, x] = I(!c), [g, E] = I(!1), [T, v] = I(null), [p, D] = I(u), [M, R] = I(
26
+ null
27
+ ), [F, J] = I(!1), [K, _] = I(() => /* @__PURE__ */ new Set()), q = V(0), B = Ce(
28
+ async (C, S, w = !1) => {
29
+ var A, N;
30
+ w || (q.current += 1, _(/* @__PURE__ */ new Set()));
31
+ try {
32
+ x(!0);
33
+ const H = await t.discussions.getPosts(r, {
34
+ sort: C,
35
+ limit: a,
36
+ startAfter: S,
37
+ skipDeleted: !0,
38
+ skipModerated: !d
39
+ }), ae = H.data;
40
+ f(w ? ($) => [...$, ...ae] : ae);
41
+ const h = !!((A = H.meta.pagination) != null && A.nextPageStartsAfter) && ae.length === a;
42
+ R(
43
+ ((N = H.meta.pagination) == null ? void 0 : N.nextPageStartsAfter) || null
44
+ ), J(h), v(null);
45
+ } catch (H) {
46
+ (t.helpers.getSDKConfiguration().errorHandlingMode === "standard" ? H.error.code === 404 : H.data.error.code === 404) ? (f([]), J(!1), R(null), v(null)) : v(T);
47
+ } finally {
48
+ x(!1);
49
+ }
50
+ },
51
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- keyed on the query inputs; the setError(error) no-op is deliberate
52
+ [t, r, a, d]
53
+ );
54
+ he(() => {
55
+ if (c) {
56
+ f([]), J(!1), x(!1);
57
+ return;
58
+ }
59
+ r && B(p);
60
+ }, [r, p, B, c]);
61
+ const j = (C) => {
62
+ D(C), R(null);
63
+ }, oe = V(k);
64
+ oe.current = k;
65
+ const ne = V(M);
66
+ ne.current = M;
67
+ const pe = Ce(() => {
68
+ ne.current && !oe.current && B(p, ne.current, !0);
69
+ }, [B, p]), Q = V(y);
70
+ Q.current = y;
71
+ const de = V(F);
72
+ de.current = F;
73
+ const re = V(m);
74
+ re.current = m;
75
+ const ie = V(!1), Z = Ce(async () => {
76
+ var H, ae;
77
+ if (oe.current || ie.current) return;
78
+ const C = p === "LATEST" || !de.current;
79
+ ie.current = !0;
80
+ const S = q.current, w = Q.current, A = new Map(w.map((h) => [h.id, h])), N = (h) => !A.has(h.id);
81
+ try {
82
+ const h = [], $ = /* @__PURE__ */ new Map();
83
+ let ee;
84
+ for (let W = 0; W < qt; W++) {
85
+ const Y = await t.discussions.getPosts(r, {
86
+ sort: "LATEST",
87
+ limit: a,
88
+ startAfter: ee,
89
+ skipDeleted: !0,
90
+ // Always included, so a shown post that got moderated can be detected
91
+ skipModerated: !1
92
+ }), G = Y.data;
93
+ G.forEach((fe) => {
94
+ const je = A.get(fe.id);
95
+ je ? fe.moderated && !je.moderated && $.set(fe.id, fe) : (d || !fe.moderated) && h.push(fe);
96
+ }), ee = ((H = Y.meta.pagination) == null ? void 0 : H.nextPageStartsAfter) || void 0;
97
+ const xe = G.length === a && G.every(N);
98
+ if (!C || !w.length || !xe || !ee) break;
99
+ }
100
+ if (S !== q.current || ($.size && f(
101
+ (W) => d ? W.map((Y) => {
102
+ const G = $.get(Y.id);
103
+ return G ? {
104
+ ...Y,
105
+ moderated: !0,
106
+ moderatedAt: G.moderatedAt,
107
+ moderatedBy: G.moderatedBy,
108
+ moderatedReason: G.moderatedReason
109
+ } : Y;
110
+ }) : W.filter((Y) => !$.has(Y.id))
111
+ ), !C)) return;
112
+ const ke = new Set(Q.current.map((W) => W.id)), ce = h.filter((W) => !ke.has(W.id));
113
+ if (!ce.length) return;
114
+ w.length ? f((W) => {
115
+ const Y = new Set(W.map((xe) => xe.id)), G = ce.filter((xe) => !Y.has(xe.id));
116
+ return p === "LATEST" ? [...G, ...W].sort(
117
+ (xe, fe) => Date.parse(fe.createdAt) - Date.parse(xe.createdAt)
118
+ ) : [...W, ...G.reverse()];
119
+ }) : await B(p), _((W) => {
120
+ const Y = new Set(W);
121
+ return ce.forEach((G) => Y.add(G.id)), Y;
122
+ }), (ae = re.current) == null || ae.call(re, ce.length);
123
+ } catch {
124
+ } finally {
125
+ ie.current = !1;
126
+ }
127
+ }, [
128
+ t,
129
+ r,
130
+ a,
131
+ d,
132
+ p,
133
+ B
134
+ ]), se = l > 0 ? Math.max(l, Jt) : 0;
135
+ he(() => {
136
+ if (!se || c || !r) return;
137
+ const C = () => {
138
+ document.visibilityState !== "hidden" && Z();
139
+ }, S = () => {
140
+ document.visibilityState === "visible" && Z();
141
+ }, w = setInterval(C, se);
142
+ return document.addEventListener("visibilitychange", S), () => {
143
+ clearInterval(w), document.removeEventListener("visibilitychange", S);
144
+ };
145
+ }, [se, c, r, Z]);
146
+ const P = Ce((C) => {
147
+ _((S) => {
148
+ if (!S.has(C)) return S;
149
+ const w = new Set(S);
150
+ return w.delete(C), w;
151
+ });
152
+ }, []);
153
+ return {
154
+ posts: y,
155
+ postsHidden: c,
156
+ isLoading: k,
157
+ isSubmitting: g,
158
+ error: T,
159
+ currentSort: p,
160
+ hasMore: F,
161
+ newPostIds: K,
162
+ markPostSeen: P,
163
+ handleSortChange: j,
164
+ handleLoadMore: pe,
165
+ handleCreatePost: async (C, S) => {
166
+ try {
167
+ E(!0);
168
+ let A = await t.discussions.createPost(r, {
169
+ content: C,
170
+ replyId: S || null,
171
+ userNickname: null,
172
+ discussionLabel: i,
173
+ discussionUrl: s,
174
+ context: {
175
+ content: null,
176
+ tags: [],
177
+ campaign: null
178
+ }
179
+ });
180
+ try {
181
+ const N = await t.profile.getOwn().getInfo();
182
+ A = { ...A, userModel: N };
183
+ } catch {
184
+ }
185
+ S ? f(
186
+ (N) => N.map(
187
+ (H) => H.id === S ? { ...H, repliesCount: (H.repliesCount || 0) + 1 } : H
188
+ )
189
+ ) : c || f((N) => [A, ...N]), m == null || m(1), v(null);
190
+ } catch (w) {
191
+ throw v(
192
+ w
193
+ ), w;
194
+ } finally {
195
+ E(!1);
196
+ }
197
+ },
198
+ handleReact: async (C, S) => {
199
+ try {
200
+ const w = await t.discussions.react(C, S);
201
+ return f(
202
+ (A) => A.map((N) => N.id === C ? w : N)
203
+ ), v(null), w;
204
+ } catch (w) {
205
+ throw console.error("Error reacting to post:", w), v(
206
+ w
207
+ ), w;
208
+ }
209
+ },
210
+ handleDeletePost: async (C, S) => {
211
+ try {
212
+ await t.discussions.deletePost(C), f((w) => w.filter((A) => A.id !== C)), S && f(
213
+ (w) => w.map(
214
+ (A) => A.id === S ? { ...A, repliesCount: Math.max(0, (A.repliesCount || 0) - 1) } : A
215
+ )
216
+ ), m == null || m(-1), v(null);
217
+ } catch (w) {
218
+ throw v(
219
+ w
220
+ ), w;
221
+ }
222
+ },
223
+ handleReportPost: async (C, S, w) => {
224
+ try {
225
+ await t.discussions.reportPost(C, S, w), v(null);
226
+ } catch (A) {
227
+ throw v(
228
+ A
229
+ ), A;
230
+ }
231
+ }
232
+ };
233
+ }, Zt = async (t) => {
234
+ var r;
235
+ try {
236
+ const s = (r = t.helpers.getSDKConfiguration().authProvider) == null ? void 0 : r.getIdToken(), u = s == null ? void 0 : s.split(".")[1];
237
+ if (!u) return null;
238
+ const { sub: a } = JSON.parse(
239
+ atob(u.replace(/-/g, "+").replace(/_/g, "/"))
240
+ );
241
+ return typeof a == "string" && a ? a : null;
242
+ } catch {
243
+ return null;
244
+ }
245
+ }, eo = (t, r) => {
246
+ var d;
247
+ const [i, s] = I(null), u = It(), a = Ce(
248
+ async (l) => {
249
+ if (!r) {
250
+ s(null);
251
+ return;
252
+ }
253
+ try {
254
+ const c = await Zt(t);
255
+ if (!c) return;
256
+ s(await t.discussions.getUserBan(c, l));
257
+ } catch (c) {
258
+ console.error("Failed to get user ban:", c);
259
+ }
260
+ },
261
+ [t, r]
262
+ );
263
+ he(() => {
264
+ a(u);
265
+ }, [a, u]);
266
+ const m = Ce(() => a(!0), [a]);
267
+ return { ban: i, isBanned: !!((d = i == null ? void 0 : i.activeBan) != null && d.banned), refresh: m };
268
+ }, pt = (t) => {
269
+ var r, i, s;
270
+ return (((r = t == null ? void 0 : t.error) == null ? void 0 : r.status) ?? ((s = (i = t == null ? void 0 : t.data) == null ? void 0 : i.error) == null ? void 0 : s.status)) === "ban";
271
+ }, e = {
272
+ surface: "var(--fu-ucrc-surface)",
273
+ surfaceVariant: "var(--fu-ucrc-surface-variant)",
274
+ text: "var(--fu-ucrc-text-primary)",
275
+ textSecondary: "var(--fu-ucrc-text-secondary)",
276
+ textBody: "var(--fu-ucrc-text-body)",
277
+ border: "var(--fu-ucrc-outline-enabled-border)",
278
+ primary: "var(--fu-ucrc-primary-plain-color)",
279
+ onPrimary: "var(--fu-ucrc-primary-on-primary)",
280
+ danger: "var(--fu-ucrc-danger-plain-color)",
281
+ dangerSoft: "var(--fu-ucrc-danger-soft-bg)",
282
+ // Joy's own defaults, where a Joy component painted something the client theme doesn't set.
283
+ paletteTextPrimary: "var(--fu-ucrc-palette-text-primary)",
284
+ icon: "var(--fu-ucrc-palette-text-icon)",
285
+ focus: "var(--fu-ucrc-focus-visible)",
286
+ fontPrimary: "var(--fu-ucrc-font-primary)",
287
+ fontBody: "var(--fu-ucrc-font-body)",
288
+ radiusXs: "var(--fu-ucrc-radius-xs)",
289
+ radiusSm: "var(--fu-ucrc-radius-sm)",
290
+ radiusMd: "var(--fu-ucrc-radius-md)",
291
+ radiusLg: "var(--fu-ucrc-radius-lg)",
292
+ radiusFull: "var(--fu-ucrc-radius-full)",
293
+ space2xs: "var(--fu-ucrc-space-2xs)",
294
+ spaceXs: "var(--fu-ucrc-space-xs)",
295
+ spaceSm: "var(--fu-ucrc-space-sm)",
296
+ spaceMd: "var(--fu-ucrc-space-md)",
297
+ spaceLg: "var(--fu-ucrc-space-lg)",
298
+ spaceXl: "var(--fu-ucrc-space-xl)",
299
+ primary14: "var(--fu-ucrc-dsc-primary-14)",
300
+ primary1a: "var(--fu-ucrc-dsc-primary-1a)",
301
+ primary1f: "var(--fu-ucrc-dsc-primary-1f)",
302
+ text14: "var(--fu-ucrc-dsc-text-14)",
303
+ danger1f: "var(--fu-ucrc-dsc-danger-1f)",
304
+ danger33: "var(--fu-ucrc-dsc-danger-33)"
305
+ }, Ve = () => {
306
+ const t = Et(), r = t.palette.primary.plainColor, i = t.palette.danger.plainColor, s = t.textPrimary;
307
+ return Ie.useMemo(
308
+ () => ({
309
+ "--fu-ucrc-dsc-primary-14": `${r}14`,
310
+ "--fu-ucrc-dsc-primary-1a": `${r}1A`,
311
+ "--fu-ucrc-dsc-primary-1f": `${r}1F`,
312
+ "--fu-ucrc-dsc-text-14": `${s}14`,
313
+ "--fu-ucrc-dsc-danger-1f": `${i}1F`,
314
+ "--fu-ucrc-dsc-danger-33": `${i}33`
315
+ }),
316
+ [r, i, s]
317
+ );
318
+ }, ve = (t, r, i) => o({ margin: 0, fontFamily: e.fontBody, fontSize: t, fontWeight: r, lineHeight: i }), z = {
319
+ h3: o(ve("1.5em", 600, 1.33334), { letterSpacing: "-0.025em", color: e.paletteTextPrimary }),
320
+ titleLg: o(ve("1.25em", 600, 1.33334), { color: e.paletteTextPrimary }),
321
+ titleMd: o(ve("1em", 500, 1.5), { color: e.paletteTextPrimary }),
322
+ titleSm: ve("0.875em", 500, 1.42858),
323
+ bodyMd: ve("1em", 400, 1.5),
324
+ bodySm: ve("0.875em", 400, 1.5),
325
+ bodyXs: ve("0.75em", 500, 1.5)
326
+ }, _e = o({
327
+ boxSizing: "border-box",
328
+ position: "relative",
329
+ display: "inline-flex",
330
+ alignItems: "center",
331
+ justifyContent: "center",
332
+ minHeight: "2.25em",
333
+ margin: 0,
334
+ paddingBlock: "0.375em",
335
+ paddingInline: "1em",
336
+ border: "none",
337
+ borderRadius: e.radiusSm,
338
+ font: "inherit",
339
+ fontSize: "1em",
340
+ backgroundColor: "transparent",
341
+ cursor: "pointer",
342
+ userSelect: "none",
343
+ "&:focus-visible": { outline: `2px solid ${e.focus}`, outlineOffset: "2px" },
344
+ "&:disabled": { pointerEvents: "none", cursor: "default" }
345
+ }), to = o(_e, {
346
+ fontFamily: e.fontPrimary,
347
+ color: e.onPrimary,
348
+ backgroundColor: e.primary,
349
+ "&:active": { backgroundColor: "var(--fu-ucrc-primary-solid-active-bg)" },
350
+ "&:hover": { backgroundColor: e.primary, opacity: 0.9 },
351
+ "&:disabled": { opacity: 0.4 }
352
+ }), Ye = o(_e, {
353
+ fontFamily: e.fontPrimary,
354
+ color: e.text,
355
+ "&:active": { backgroundColor: "var(--fu-ucrc-primary-plain-active-bg)" },
356
+ "&:hover": { backgroundColor: e.text14 },
357
+ "&:disabled": { color: "var(--fu-ucrc-neutral-plain-disabled-color)" }
358
+ }), Ge = o(_e, {
359
+ border: `1px solid ${e.primary}`,
360
+ color: e.primary,
361
+ "&:active": { backgroundColor: "var(--fu-ucrc-primary-outlined-active-bg)" },
362
+ "&:hover": { backgroundColor: e.primary14, borderColor: e.primary },
363
+ "&:disabled": { opacity: 0.4 }
364
+ }), Pe = {
365
+ solid: to,
366
+ plain: Ye,
367
+ outlined: Ge,
368
+ signIn: o(Ge, { width: "100%", paddingBlock: e.spaceSm, fontFamily: e.fontPrimary }),
369
+ // Joy's small plain button, as the post's Reply action.
370
+ reply: o(Ye, {
371
+ minHeight: "auto",
372
+ marginInlineStart: e.spaceXs,
373
+ paddingBlock: e.space2xs,
374
+ paddingInline: e.spaceXs,
375
+ fontSize: "0.8125em",
376
+ fontWeight: 600
377
+ }),
378
+ decorator: o({ display: "inherit", marginInlineEnd: "calc(0.375em / 0.8125)" }),
379
+ loading: o({ display: "flex", position: "absolute", left: "50%", transform: "translateX(-50%)" })
380
+ }, ue = ({ look: t, loading: r, startDecorator: i, disabled: s, children: u, ...a }) => /* @__PURE__ */ b("button", { type: "button", css: Pe[t], disabled: s || r, ...a, children: [
381
+ i && /* @__PURE__ */ n("span", { css: Pe.decorator, children: i }),
382
+ u,
383
+ r && /* @__PURE__ */ n("span", { css: Pe.loading, children: /* @__PURE__ */ n(bt, { size: 20, color: "var(--fu-ucrc-primary-solid-bg)" }) })
384
+ ] }), Te = {
385
+ // Joy's outlined Textarea with the widget's overrides.
386
+ root: o({
387
+ boxSizing: "border-box",
388
+ position: "relative",
389
+ display: "flex",
390
+ flexDirection: "column",
391
+ minWidth: 0,
392
+ minHeight: "2.25em",
393
+ paddingBlock: "calc(0.375em - 1px)",
394
+ paddingInlineStart: "0.75em",
395
+ border: `1px solid ${e.border}`,
396
+ borderRadius: e.radiusSm,
397
+ backgroundColor: e.surfaceVariant,
398
+ color: e.text,
399
+ fontFamily: e.fontBody,
400
+ fontSize: "1em",
401
+ fontWeight: 400,
402
+ lineHeight: 1.5,
403
+ cursor: "text",
404
+ "&:focus-within": { borderColor: e.primary },
405
+ "&[data-disabled]": {
406
+ pointerEvents: "none",
407
+ cursor: "default",
408
+ color: "var(--fu-ucrc-neutral-outlined-disabled-color)",
409
+ borderColor: "var(--fu-ucrc-neutral-outlined-disabled-border)"
410
+ }
411
+ }),
412
+ textarea: o({
413
+ flex: "auto",
414
+ alignSelf: "stretch",
415
+ minWidth: 0,
416
+ margin: 0,
417
+ padding: 0,
418
+ paddingInlineEnd: "0.75em",
419
+ border: "none",
420
+ outline: 0,
421
+ resize: "none",
422
+ color: "inherit",
423
+ backgroundColor: "transparent",
424
+ font: "inherit",
425
+ "&::placeholder": { color: "inherit", opacity: 0.64 }
426
+ })
427
+ }, mt = ({
428
+ value: t,
429
+ onChange: r,
430
+ placeholder: i,
431
+ minRows: s,
432
+ maxRows: u,
433
+ disabled: a,
434
+ marginBottom: m
435
+ }) => {
436
+ const { inputRef: d, shadowRef: l } = xt(s, u, i);
437
+ return /* @__PURE__ */ b("div", { css: Te.root, "data-disabled": a || void 0, style: { marginBottom: m }, children: [
438
+ /* @__PURE__ */ n(
439
+ "textarea",
440
+ {
441
+ ref: d,
442
+ css: Te.textarea,
443
+ rows: s,
444
+ value: t,
445
+ placeholder: i,
446
+ disabled: a,
447
+ onChange: (c) => r(c.target.value)
448
+ }
449
+ ),
450
+ /* @__PURE__ */ n("textarea", { ref: l, css: Te.textarea, "aria-hidden": !0, readOnly: !0, tabIndex: -1, style: vt })
451
+ ] });
452
+ }, De = {
453
+ form: o({ marginBottom: e.spaceLg }),
454
+ replyingTo: o(z.bodySm, { marginBottom: e.spaceXs, color: e.textSecondary }),
455
+ actions: o({ display: "flex", gap: e.spaceXs, justifyContent: "flex-end" })
456
+ }, ft = ({
457
+ onSubmit: t,
458
+ userIsLoggedIn: r,
459
+ onSignInClick: i,
460
+ placeholder: s,
461
+ isSubmitting: u,
462
+ replyTo: a,
463
+ onCancel: m,
464
+ disabled: d = !1
465
+ }) => {
466
+ const { t: l } = be(), [c, y] = I(""), f = async (k) => {
467
+ if (k.preventDefault(), !(!c.trim() || d))
468
+ try {
469
+ await t(c), y("");
470
+ } catch (x) {
471
+ console.error("Failed to submit comment:", x);
472
+ }
473
+ };
474
+ return r ? /* @__PURE__ */ b("form", { onSubmit: f, css: De.form, children: [
475
+ a && /* @__PURE__ */ n("p", { css: De.replyingTo, children: l("discussion.replyingTo", "Replying to {{name}}", {
476
+ name: Dt(a)
477
+ }) }),
478
+ /* @__PURE__ */ n(
479
+ mt,
480
+ {
481
+ placeholder: s || l("discussion.writeComment", "Write a comment..."),
482
+ value: c,
483
+ onChange: y,
484
+ minRows: 3,
485
+ maxRows: 8,
486
+ disabled: u || d,
487
+ marginBottom: e.spaceSm
488
+ }
489
+ ),
490
+ /* @__PURE__ */ b("div", { css: De.actions, children: [
491
+ m && /* @__PURE__ */ n(ue, { look: "plain", onClick: m, disabled: u, children: l("common.cancel", "Cancel") }),
492
+ /* @__PURE__ */ n(
493
+ ue,
494
+ {
495
+ look: "solid",
496
+ type: "submit",
497
+ disabled: !c.trim() || u || d,
498
+ loading: u,
499
+ children: a ? l("discussion.reply", "Reply") : l("discussion.post", "Post")
500
+ }
501
+ )
502
+ ] })
503
+ ] }) : /* @__PURE__ */ n("div", { css: De.form, children: /* @__PURE__ */ n(ue, { look: "signIn", onClick: i, children: l("discussion.signInToPost", "Sign in to post") }) });
504
+ }, ge = { size: "1em", color: e.icon }, oo = {
505
+ LIKE: /* @__PURE__ */ n(Pt, { ...ge }),
506
+ DISLIKE: /* @__PURE__ */ n(Tt, { ...ge }),
507
+ LOVE: /* @__PURE__ */ n(At, { ...ge }),
508
+ LAUGH: /* @__PURE__ */ n(Mt, { ...ge }),
509
+ CARE: /* @__PURE__ */ n(Lt, { ...ge }),
510
+ WOW: /* @__PURE__ */ n(zt, { ...ge }),
511
+ SAD: /* @__PURE__ */ n(Ft, { ...ge }),
512
+ ANGRY: /* @__PURE__ */ n($t, { ...ge })
513
+ }, Ae = o({
514
+ display: "inline-flex",
515
+ alignItems: "center",
516
+ gap: e.space2xs,
517
+ paddingInline: e.spaceSm,
518
+ paddingBlock: e.space2xs,
519
+ borderRadius: "18px",
520
+ backgroundColor: "transparent",
521
+ color: e.textSecondary
522
+ }), Me = o(z.bodySm, { fontWeight: 500, color: e.text }), Se = {
523
+ idle: Ae,
524
+ primary: o(Ae, { backgroundColor: "var(--fu-ucrc-neutral-soft-bg)", color: e.primary }),
525
+ danger: o(Ae, { backgroundColor: "var(--fu-ucrc-neutral-soft-bg)", color: e.danger })
526
+ }, Le = {
527
+ cursor: "pointer",
528
+ "&:hover": { backgroundColor: "var(--fu-ucrc-neutral-soft-hover-bg)" }
529
+ }, ze = { opacity: 0.5 }, Fe = {
530
+ pill: {
531
+ enabled: {
532
+ idle: o(Se.idle, Le),
533
+ primary: o(Se.primary, Le),
534
+ danger: o(Se.danger, Le)
535
+ },
536
+ disabled: {
537
+ idle: o(Se.idle, ze),
538
+ primary: o(Se.primary, ze),
539
+ danger: o(Se.danger, ze)
540
+ }
541
+ },
542
+ icon: o({ display: "flex", alignItems: "center", fontSize: "1.25em", color: "inherit" }),
543
+ count: { idle: Me, primary: o(Me, { color: e.primary }), danger: o(Me, { color: e.danger }) }
544
+ }, Je = ({
545
+ reaction: t,
546
+ count: r,
547
+ isActive: i,
548
+ onClick: s,
549
+ disabled: u
550
+ }) => {
551
+ const a = (d) => d >= 1e6 ? (d / 1e6).toFixed(1).replace(/\.0$/, "") + "M" : d >= 1e3 ? (d / 1e3).toFixed(1).replace(/\.0$/, "") + "K" : d.toString(), m = i ? t === "LOVE" || t === "ANGRY" ? "danger" : "primary" : "idle";
552
+ return /* @__PURE__ */ b(
553
+ "div",
554
+ {
555
+ css: Fe.pill[u ? "disabled" : "enabled"][m],
556
+ onClick: u ? void 0 : s,
557
+ children: [
558
+ /* @__PURE__ */ n("div", { css: Fe.icon, children: oo[t] }),
559
+ r > 0 && /* @__PURE__ */ n("p", { css: Fe.count[m], children: a(r) })
560
+ ]
561
+ }
562
+ );
563
+ }, gt = (t, r) => {
564
+ const [i, s] = I(null);
565
+ return he(() => {
566
+ (async () => {
567
+ if (r)
568
+ try {
569
+ const a = await t.profile.getOwn().getInfo();
570
+ s(a.id);
571
+ } catch (a) {
572
+ console.error("Failed to get current user ID:", a);
573
+ }
574
+ })();
575
+ }, [r, t]), i;
576
+ }, qe = {
577
+ row: o({
578
+ display: "flex",
579
+ gap: e.spaceXs,
580
+ alignItems: "center",
581
+ flexWrap: "wrap",
582
+ marginBottom: e.spaceXs
583
+ }),
584
+ // Joy set --Icon-color to the text colour on this button; disabled, it follows the label.
585
+ replyIcon: o({ color: e.text, "button:disabled &": { color: "currentColor" } })
586
+ }, no = ({
587
+ post: t,
588
+ sdk: r,
589
+ userIsLoggedIn: i,
590
+ onSignInClick: s,
591
+ onReact: u,
592
+ showReactions: a = !0,
593
+ showReplyButton: m = !0,
594
+ onReplyClick: d,
595
+ isBanned: l = !1
596
+ }) => {
597
+ var g, E, T, v;
598
+ const { t: c } = be(), y = gt(r, i), k = (() => {
599
+ if (!y || !t.reactions)
600
+ return null;
601
+ for (const p of t.reactions)
602
+ if (p.userIds.includes(y))
603
+ return p.type;
604
+ return null;
605
+ })(), x = (p) => {
606
+ if (!i) {
607
+ s == null || s();
608
+ return;
609
+ }
610
+ u(t.id, p).catch(() => {
611
+ });
612
+ };
613
+ return /* @__PURE__ */ b("div", { css: qe.row, children: [
614
+ a && /* @__PURE__ */ b(Re, { children: [
615
+ /* @__PURE__ */ n(
616
+ Je,
617
+ {
618
+ reaction: "LIKE",
619
+ count: ((E = (g = t.reactions) == null ? void 0 : g.find((p) => p.type === "LIKE")) == null ? void 0 : E.reactionCount) || 0,
620
+ isActive: k === "LIKE",
621
+ onClick: () => x("LIKE"),
622
+ disabled: !i || l
623
+ }
624
+ ),
625
+ /* @__PURE__ */ n(
626
+ Je,
627
+ {
628
+ reaction: "DISLIKE",
629
+ count: ((v = (T = t.reactions) == null ? void 0 : T.find((p) => p.type === "DISLIKE")) == null ? void 0 : v.reactionCount) || 0,
630
+ isActive: k === "DISLIKE",
631
+ onClick: () => x("DISLIKE"),
632
+ disabled: !i || l
633
+ }
634
+ )
635
+ ] }),
636
+ m && /* @__PURE__ */ n(
637
+ ue,
638
+ {
639
+ look: "reply",
640
+ onClick: d,
641
+ disabled: l,
642
+ startDecorator: /* @__PURE__ */ n(Xt, { size: "1em", css: qe.replyIcon, style: { marginLeft: "calc(0.375em / -1.625)" } }),
643
+ children: c("discussion.reply", "Reply")
644
+ }
645
+ )
646
+ ] });
647
+ }, $e = 4, Qe = { visibility: "hidden" }, ht = (t, r, i, s) => {
648
+ const u = Bt(), [a, m] = I(Qe);
649
+ return kt(() => {
650
+ if (!t) {
651
+ m(Qe);
652
+ return;
653
+ }
654
+ const d = () => {
655
+ var E;
656
+ const l = (E = r.current) == null ? void 0 : E.getBoundingClientRect(), c = i.current;
657
+ if (!l || !c) return;
658
+ s === "start" && (c.style.width = `${l.width}px`);
659
+ const { width: y, height: f } = c.getBoundingClientRect(), k = document.documentElement;
660
+ let x = s === "center" ? l.left + l.width / 2 - y / 2 : u ? l.right - y : l.left;
661
+ x = Math.max(0, Math.min(x, k.clientWidth - y));
662
+ let g = l.bottom + $e;
663
+ g + f > k.clientHeight && l.top - $e - f >= 0 && (g = l.top - $e - f), m({
664
+ left: Math.round(x),
665
+ top: Math.round(g),
666
+ width: s === "start" ? l.width : void 0
667
+ });
668
+ };
669
+ return d(), window.addEventListener("resize", d), window.addEventListener("scroll", d, { capture: !0, passive: !0 }), () => {
670
+ window.removeEventListener("resize", d), window.removeEventListener("scroll", d, { capture: !0 });
671
+ };
672
+ }, [t, s, u, r, i]), a;
673
+ }, Xe = {
674
+ // Joy's small plain IconButton; its radius variable never resolved, so it's square.
675
+ trigger: o({
676
+ boxSizing: "border-box",
677
+ position: "relative",
678
+ display: "inline-flex",
679
+ alignItems: "center",
680
+ justifyContent: "center",
681
+ minWidth: "2em",
682
+ minHeight: "2em",
683
+ margin: 0,
684
+ marginLeft: "auto",
685
+ paddingBlock: 0,
686
+ paddingInline: "2px",
687
+ border: "none",
688
+ backgroundColor: "transparent",
689
+ color: e.text,
690
+ font: "inherit",
691
+ fontSize: "1em",
692
+ // Unlike Joy's Button, its IconButton kept the browser's line height.
693
+ lineHeight: "normal",
694
+ cursor: "pointer",
695
+ "& svg": { color: e.icon },
696
+ "&:hover": { backgroundColor: e.text14, color: "var(--fu-ucrc-neutral-plain-hover-color)" },
697
+ "&:active": { backgroundColor: "var(--fu-ucrc-neutral-plain-active-bg)" },
698
+ "&:hover svg, &:active svg, &:focus-visible svg": { color: "currentColor" },
699
+ "&:focus-visible": { outline: `2px solid ${e.focus}`, outlineOffset: "2px" }
700
+ }),
701
+ menu: o({
702
+ position: "fixed",
703
+ zIndex: 1300,
704
+ boxSizing: "border-box",
705
+ display: "flex",
706
+ flexDirection: "column",
707
+ margin: 0,
708
+ paddingBlock: "0.375em",
709
+ paddingInline: 0,
710
+ listStyle: "none",
711
+ overflow: "auto",
712
+ outline: 0,
713
+ border: `1px solid ${e.border}`,
714
+ borderRadius: e.radiusSm,
715
+ backgroundColor: e.surface,
716
+ color: "var(--fu-ucrc-neutral-outlined-color)",
717
+ fontFamily: e.fontBody,
718
+ fontSize: "1em",
719
+ fontWeight: 400,
720
+ lineHeight: 1.5
721
+ }),
722
+ item: o({
723
+ boxSizing: "border-box",
724
+ position: "relative",
725
+ display: "flex",
726
+ alignItems: "center",
727
+ flexShrink: 0,
728
+ gap: "0.625em",
729
+ minHeight: "2.25em",
730
+ paddingBlock: "0.25em",
731
+ paddingInline: "0.75em",
732
+ border: "1px solid transparent",
733
+ color: e.text,
734
+ backgroundColor: e.surface,
735
+ cursor: "pointer",
736
+ outline: 0,
737
+ "&:hover, &:focus-visible": { backgroundColor: e.surfaceVariant },
738
+ "&[aria-disabled='true']": { pointerEvents: "none", cursor: "default" }
739
+ })
740
+ }, Ze = { marginInlineEnd: e.spaceXs }, ro = ({
741
+ isOwnPost: t,
742
+ canReport: r,
743
+ onDelete: i,
744
+ onReport: s,
745
+ disabled: u = !1
746
+ }) => {
747
+ const { t: a } = be(), { shadowRootElement: m } = Ke(Ue), d = Rt(), [l, c] = Ie.useState(!1), y = V(null), f = V(null), k = ht(l, y, f, "center");
748
+ if (Ie.useEffect(() => {
749
+ if (!l) return;
750
+ const p = (M) => {
751
+ const R = M.composedPath();
752
+ y.current && R.includes(y.current) || f.current && R.includes(f.current) || c(!1);
753
+ }, D = setTimeout(() => {
754
+ document.addEventListener("click", p, !0);
755
+ }, 0);
756
+ return () => {
757
+ clearTimeout(D), document.removeEventListener("click", p, !0);
758
+ };
759
+ }, [l]), !t && !r) return null;
760
+ const x = () => {
761
+ var p;
762
+ return [...((p = f.current) == null ? void 0 : p.querySelectorAll('[role="menuitem"]')) ?? []];
763
+ }, g = () => {
764
+ var p;
765
+ c(!1), (p = y.current) == null || p.focus();
766
+ }, E = (p) => {
767
+ var D;
768
+ c(!1), (D = y.current) == null || D.focus(), p();
769
+ }, T = (p) => {
770
+ const D = x(), M = D.indexOf(p.target), R = (J) => {
771
+ var K;
772
+ return (K = D[(J + D.length) % D.length]) == null ? void 0 : K.focus();
773
+ }, F = {
774
+ ArrowDown: () => R(M + 1),
775
+ ArrowUp: () => R(M - 1),
776
+ Home: () => R(0),
777
+ End: () => R(D.length - 1),
778
+ Escape: g
779
+ };
780
+ F[p.key] ? (p.preventDefault(), F[p.key]()) : p.key === "Tab" && c(!1);
781
+ }, v = (p, D, M, R) => /* @__PURE__ */ b(
782
+ "li",
783
+ {
784
+ role: "menuitem",
785
+ tabIndex: -1,
786
+ "aria-disabled": u,
787
+ css: Xe.item,
788
+ onClick: () => E(R),
789
+ onKeyDown: (F) => {
790
+ F.key !== "Enter" && F.key !== " " || (F.preventDefault(), u || E(R));
791
+ },
792
+ children: [
793
+ D,
794
+ M
795
+ ]
796
+ },
797
+ p
798
+ );
799
+ return /* @__PURE__ */ b(Re, { children: [
800
+ /* @__PURE__ */ n(
801
+ "button",
802
+ {
803
+ ref: y,
804
+ type: "button",
805
+ "aria-haspopup": "menu",
806
+ "aria-expanded": l,
807
+ "aria-controls": l ? d : void 0,
808
+ css: Xe.trigger,
809
+ onClick: (p) => {
810
+ c(!l), !l && p.detail === 0 && requestAnimationFrame(() => {
811
+ var D;
812
+ return (D = x()[0]) == null ? void 0 : D.focus();
813
+ });
814
+ },
815
+ children: /* @__PURE__ */ n(Ht, { size: "1.25em" })
816
+ }
817
+ ),
818
+ l && m && Yt(
819
+ /* @__PURE__ */ b("ul", { ref: f, id: d, role: "menu", css: Xe.menu, style: k, onKeyDown: T, children: [
820
+ t && v("delete", /* @__PURE__ */ n(Ot, { size: "1em", color: e.icon, style: Ze }), a("discussion.delete.action", "Delete"), i),
821
+ r && v("report", /* @__PURE__ */ n(Nt, { size: "1em", color: e.icon, style: Ze }), a("discussion.report.action", "Report"), s)
822
+ ] }),
823
+ m
824
+ )
825
+ ] });
826
+ }, et = "rgba(var(--fu-ucrc-shadow-channel) / var(--fu-ucrc-shadow-opacity))", tt = o({
827
+ position: "absolute",
828
+ top: "50%",
829
+ left: "50%",
830
+ transform: "translate(-50%, -50%)",
831
+ boxSizing: "border-box",
832
+ display: "flex",
833
+ flexDirection: "column",
834
+ gap: "0.75em 1em",
835
+ minWidth: "320px",
836
+ maxHeight: "calc(100% - 3em)",
837
+ padding: e.spaceLg,
838
+ border: "1px solid var(--fu-ucrc-neutral-outlined-border)",
839
+ borderRadius: e.radiusMd,
840
+ outline: 0,
841
+ boxShadow: `var(--fu-ucrc-shadow-ring), 0px 2px 8px -2px ${et}, 0px 6px 12px -2px ${et}`,
842
+ backgroundColor: e.surface,
843
+ color: e.text,
844
+ fontFamily: e.fontBody,
845
+ fontSize: "1em",
846
+ fontWeight: 400,
847
+ lineHeight: 1.5
848
+ }), ye = {
849
+ delete: o(tt, { maxWidth: "400px" }),
850
+ report: o(tt, { maxWidth: "440px" }),
851
+ title: o(z.titleLg, { fontFamily: e.fontPrimary }),
852
+ description: o(z.bodySm, { color: e.textSecondary }),
853
+ actions: o({ display: "flex", gap: e.spaceXs, justifyContent: "flex-end" })
854
+ }, ot = {
855
+ title: o(ye.title, { marginBottom: e.spaceXs }),
856
+ description: o(ye.description, { marginBottom: e.spaceLg })
857
+ }, io = ({
858
+ open: t,
859
+ onClose: r,
860
+ onConfirm: i,
861
+ onError: s
862
+ }) => {
863
+ const { t: u } = be(), a = Ve(), m = Ie.useId(), [d, l] = I(!1), c = async () => {
864
+ l(!0);
865
+ try {
866
+ await i(), r();
867
+ } catch {
868
+ s(
869
+ u(
870
+ "discussion.delete.error",
871
+ "Failed to delete comment. Please try again."
872
+ )
873
+ );
874
+ } finally {
875
+ l(!1);
876
+ }
877
+ };
878
+ return /* @__PURE__ */ n(lt, { open: t, onClose: r, children: /* @__PURE__ */ b("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": m, tabIndex: -1, css: ye.delete, style: a, children: [
879
+ /* @__PURE__ */ n("p", { id: m, css: ot.title, children: u("discussion.delete.title", "Delete comment") }),
880
+ /* @__PURE__ */ n("p", { css: ot.description, children: u(
881
+ "discussion.delete.description",
882
+ "Are you sure you want to delete this comment? This action cannot be undone."
883
+ ) }),
884
+ /* @__PURE__ */ b("div", { css: ye.actions, children: [
885
+ /* @__PURE__ */ n(ue, { look: "plain", onClick: r, children: u("common.cancel", "Cancel") }),
886
+ /* @__PURE__ */ n(ue, { look: "solid", loading: d, onClick: c, children: u("discussion.delete.action", "Delete") })
887
+ ] })
888
+ ] }) });
889
+ }, nt = o({
890
+ boxSizing: "border-box",
891
+ display: "inline-flex",
892
+ justifyContent: "center",
893
+ alignItems: "center",
894
+ flexShrink: 0,
895
+ width: "1.25em",
896
+ height: "1.25em",
897
+ margin: 0,
898
+ borderRadius: "1.25em",
899
+ border: `1px solid ${e.border}`,
900
+ backgroundColor: e.surfaceVariant,
901
+ color: "var(--fu-ucrc-neutral-outlined-color)",
902
+ "&:active": { backgroundColor: "var(--fu-ucrc-neutral-outlined-active-bg)" },
903
+ "&:hover": { backgroundColor: e.surface, borderColor: e.border }
904
+ }), rt = o({
905
+ width: "0.625em",
906
+ height: "0.625em",
907
+ borderRadius: "inherit",
908
+ color: "inherit",
909
+ backgroundColor: "currentColor",
910
+ transform: "scale(0)"
911
+ }), le = {
912
+ title: o(ye.title, { marginBottom: e.spaceMd }),
913
+ description: o(ye.description, { marginBottom: e.spaceMd }),
914
+ // Joy's ModalClose: an 8px inset, 2rem square.
915
+ close: o({
916
+ position: "absolute",
917
+ zIndex: 1,
918
+ top: "0.5em",
919
+ right: "0.5em",
920
+ boxSizing: "border-box",
921
+ display: "inline-flex",
922
+ alignItems: "center",
923
+ justifyContent: "center",
924
+ minWidth: "2em",
925
+ minHeight: "2em",
926
+ margin: 0,
927
+ paddingBlock: 0,
928
+ paddingInline: "0.25em",
929
+ border: "none",
930
+ borderRadius: "4px",
931
+ backgroundColor: "transparent",
932
+ color: e.text,
933
+ fontFamily: e.fontBody,
934
+ fontSize: "1em",
935
+ cursor: "pointer",
936
+ "& svg": { color: e.icon },
937
+ "&:active": { backgroundColor: "var(--fu-ucrc-neutral-plain-active-bg)" },
938
+ "&:hover": { backgroundColor: e.text14, color: "var(--fu-ucrc-neutral-plain-hover-color)" },
939
+ "&:hover svg, &:active svg, &:focus-visible svg": { color: "currentColor" },
940
+ "&:focus-visible": { outline: `2px solid ${e.focus}`, outlineOffset: "2px" }
941
+ }),
942
+ group: o({
943
+ display: "flex",
944
+ flexDirection: "column",
945
+ gap: e.spaceXs,
946
+ marginBottom: e.spaceMd,
947
+ color: "var(--fu-ucrc-neutral-plain-color)"
948
+ }),
949
+ radio: o({
950
+ position: "relative",
951
+ display: "inline-flex",
952
+ boxSizing: "border-box",
953
+ minWidth: 0,
954
+ gap: "0.625em",
955
+ fontFamily: e.fontPrimary,
956
+ fontSize: "1em",
957
+ lineHeight: "1.25em",
958
+ color: e.text,
959
+ "& + &": { marginBlockStart: "0.875em" }
960
+ }),
961
+ circle: {
962
+ unchecked: nt,
963
+ checked: o(nt, {
964
+ color: "var(--fu-ucrc-primary-outlined-color)",
965
+ "&:active": { backgroundColor: "var(--fu-ucrc-primary-outlined-active-bg)" },
966
+ "&:hover": { backgroundColor: e.surface, borderColor: e.border }
967
+ })
968
+ },
969
+ dot: { unchecked: rt, checked: o(rt, { transform: "none" }) },
970
+ action: o({
971
+ position: "absolute",
972
+ inset: "-1px",
973
+ zIndex: 1,
974
+ borderRadius: "inherit",
975
+ "&:has(input:focus-visible)": { outline: `2px solid ${e.focus}`, outlineOffset: "2px" }
976
+ }),
977
+ input: o({
978
+ position: "absolute",
979
+ width: "100%",
980
+ height: "100%",
981
+ margin: 0,
982
+ opacity: 0,
983
+ cursor: "pointer"
984
+ }),
985
+ label: o({ flex: 1, minWidth: 0 })
986
+ }, so = [
987
+ { value: "SPAM", labelKey: "discussion.report.spam", fallback: "Spam" },
988
+ {
989
+ value: "NOT_ON_THE_SUBJECT",
990
+ labelKey: "discussion.report.offTopic",
991
+ fallback: "Off topic"
992
+ },
993
+ { value: "AD", labelKey: "discussion.report.ad", fallback: "Advertisement" },
994
+ {
995
+ value: "COPYRIGHT",
996
+ labelKey: "discussion.report.copyright",
997
+ fallback: "Copyright violation"
998
+ },
999
+ {
1000
+ value: "EXPLICIT_SEXUAL_CONTENT",
1001
+ labelKey: "discussion.report.explicit",
1002
+ fallback: "Explicit sexual content"
1003
+ },
1004
+ {
1005
+ value: "HATEFUL_SPEECH",
1006
+ labelKey: "discussion.report.hateful",
1007
+ fallback: "Hateful speech"
1008
+ },
1009
+ { value: "INSULT", labelKey: "discussion.report.insult", fallback: "Insult" },
1010
+ { value: "OTHER", labelKey: "discussion.report.other", fallback: "Other" }
1011
+ ], ao = ({
1012
+ open: t,
1013
+ onClose: r,
1014
+ onSubmit: i,
1015
+ onSuccess: s,
1016
+ onError: u
1017
+ }) => {
1018
+ const { t: a } = be(), m = Ve(), d = Ie.useId(), [l, c] = I(""), [y, f] = I(""), [k, x] = I(!1), g = () => {
1019
+ r(), c(""), f("");
1020
+ }, E = async () => {
1021
+ x(!0);
1022
+ try {
1023
+ await i(
1024
+ l,
1025
+ l === "OTHER" ? y : void 0
1026
+ ), s(
1027
+ a(
1028
+ "discussion.report.success",
1029
+ "Post reported successfully. Thank you."
1030
+ )
1031
+ ), g();
1032
+ } catch {
1033
+ u(
1034
+ a(
1035
+ "discussion.report.error",
1036
+ "Failed to report post. Please try again."
1037
+ )
1038
+ );
1039
+ } finally {
1040
+ x(!1);
1041
+ }
1042
+ };
1043
+ return /* @__PURE__ */ n(lt, { open: t, onClose: g, children: /* @__PURE__ */ b("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": `${d}title`, tabIndex: -1, css: ye.report, style: m, children: [
1044
+ /* @__PURE__ */ n("button", { type: "button", "aria-label": a("common.rules.close", "Close"), css: le.close, onClick: g, children: /* @__PURE__ */ n(Wt, { size: "calc(2em / 1.5)" }) }),
1045
+ /* @__PURE__ */ n("p", { id: `${d}title`, css: le.title, children: a("discussion.report.title", "Report post") }),
1046
+ /* @__PURE__ */ n("p", { css: le.description, children: a(
1047
+ "discussion.report.description",
1048
+ "Why are you reporting this post?"
1049
+ ) }),
1050
+ /* @__PURE__ */ n("div", { role: "radiogroup", css: le.group, children: so.map((T) => {
1051
+ const v = l === T.value, p = v ? "checked" : "unchecked";
1052
+ return /* @__PURE__ */ b("span", { css: le.radio, children: [
1053
+ /* @__PURE__ */ b("span", { css: le.circle[p], children: [
1054
+ /* @__PURE__ */ n("span", { css: le.dot[p] }),
1055
+ /* @__PURE__ */ n("span", { css: le.action, children: /* @__PURE__ */ n(
1056
+ "input",
1057
+ {
1058
+ id: `${d}${T.value}`,
1059
+ type: "radio",
1060
+ name: `${d}reason`,
1061
+ value: T.value,
1062
+ checked: v,
1063
+ onChange: (D) => c(D.target.value),
1064
+ css: le.input
1065
+ }
1066
+ ) })
1067
+ ] }),
1068
+ /* @__PURE__ */ n("label", { htmlFor: `${d}${T.value}`, css: le.label, children: a(T.labelKey, T.fallback) })
1069
+ ] }, T.value);
1070
+ }) }),
1071
+ l === "OTHER" && /* @__PURE__ */ n(
1072
+ mt,
1073
+ {
1074
+ placeholder: a(
1075
+ "discussion.report.detailsPlaceholder",
1076
+ "Please provide more details..."
1077
+ ),
1078
+ value: y,
1079
+ onChange: f,
1080
+ minRows: 2,
1081
+ maxRows: 4,
1082
+ marginBottom: e.spaceMd
1083
+ }
1084
+ ),
1085
+ /* @__PURE__ */ b("div", { css: ye.actions, children: [
1086
+ /* @__PURE__ */ n(ue, { look: "plain", onClick: g, children: a("common.cancel", "Cancel") }),
1087
+ /* @__PURE__ */ n(
1088
+ ue,
1089
+ {
1090
+ look: "solid",
1091
+ disabled: !l,
1092
+ loading: k,
1093
+ onClick: E,
1094
+ children: a("discussion.report.action", "Report")
1095
+ }
1096
+ )
1097
+ ] })
1098
+ ] }) });
1099
+ }, co = (t, r, i) => {
1100
+ const s = new Date(t), a = (/* @__PURE__ */ new Date()).getTime() - s.getTime(), m = Math.floor(a / 6e4), d = Math.floor(a / 36e5), l = Math.floor(a / 864e5);
1101
+ return m < 1 ? r("discussion.justNow", "Just now") : m < 60 ? r("discussion.minutesAgo", "{{count}}m ago", { count: m }) : d < 24 ? r("discussion.hoursAgo", "{{count}}h ago", { count: d }) : l < 7 ? r("discussion.daysAgo", "{{count}}d ago", { count: l }) : s.toLocaleDateString(ut(i));
1102
+ }, Ne = o({ marginBottom: e.spaceMd }), We = o(Ne, {
1103
+ paddingInline: e.spaceSm,
1104
+ paddingBlock: e.spaceXs,
1105
+ borderInlineStart: "3px solid transparent",
1106
+ borderRadius: e.radiusXs,
1107
+ backgroundColor: "transparent",
1108
+ transition: "background-color 0.6s ease, border-color 0.6s ease"
1109
+ }), it = o(We, { borderInlineStartColor: e.primary, backgroundColor: e.primary1a }), lo = { width: "64%", height: "64%" }, uo = { marginTop: "2px" }, O = {
1110
+ post: { top: Ne, reply: o(Ne, { marginLeft: e.spaceXl }) },
1111
+ highlightable: { top: We, reply: o(We, { marginLeft: e.spaceXl }) },
1112
+ highlighted: { top: it, reply: o(it, { marginLeft: e.spaceXl }) },
1113
+ row: o({ display: "flex", gap: e.spaceSm }),
1114
+ // Joy's small soft Avatar: 2rem square, in its own 0.875em font.
1115
+ avatar: o({
1116
+ position: "relative",
1117
+ width: "calc(2em / 0.875)",
1118
+ height: "calc(2em / 0.875)",
1119
+ userSelect: "none",
1120
+ backgroundColor: e.surfaceVariant,
1121
+ color: e.text,
1122
+ fontFamily: e.fontBody,
1123
+ fontSize: "0.875em",
1124
+ fontWeight: 500
1125
+ }),
1126
+ body: o({ flex: 1, minWidth: 0 }),
1127
+ header: o({ display: "flex", alignItems: "center", gap: e.spaceXs, marginBottom: e.space2xs }),
1128
+ name: o(z.titleSm, { color: e.text, unicodeBidi: "plaintext" }),
1129
+ time: o(z.bodyXs, { color: e.textSecondary }),
1130
+ badge: o(z.bodyXs, {
1131
+ fontWeight: 600,
1132
+ paddingInline: e.spaceXs,
1133
+ borderRadius: e.radiusFull,
1134
+ color: e.primary,
1135
+ backgroundColor: e.primary1f
1136
+ }),
1137
+ moderated: o({
1138
+ display: "flex",
1139
+ alignItems: "flex-start",
1140
+ gap: e.spaceXs,
1141
+ marginBottom: e.spaceXs,
1142
+ marginRight: e.spaceMd,
1143
+ paddingInline: e.spaceSm,
1144
+ paddingBlock: e.spaceXs,
1145
+ borderRadius: e.radiusXs,
1146
+ borderLeft: `3px solid ${e.border}`,
1147
+ backgroundColor: e.surfaceVariant
1148
+ }),
1149
+ moderatedText: o(z.bodySm, { fontStyle: "italic", color: e.textSecondary, unicodeBidi: "plaintext" }),
1150
+ // User text: each line takes its own direction.
1151
+ content: o(z.bodySm, { marginBottom: e.spaceXs, whiteSpace: "pre-wrap", color: e.textBody, unicodeBidi: "plaintext" }),
1152
+ repliesRow: o({ marginBottom: e.spaceXs }),
1153
+ repliesToggle: o(z.bodySm, {
1154
+ display: "flex",
1155
+ alignItems: "center",
1156
+ gap: e.space2xs,
1157
+ fontWeight: 600,
1158
+ color: e.primary,
1159
+ cursor: "pointer",
1160
+ "&:hover": { textDecoration: "underline", textUnderlineOffset: "2px" }
1161
+ }),
1162
+ nested: o({ marginTop: e.spaceMd })
1163
+ }, po = 8e3, yt = ({
1164
+ post: t,
1165
+ sdk: r,
1166
+ userIsLoggedIn: i,
1167
+ onSignInClick: s,
1168
+ showReactions: u = !0,
1169
+ showReplies: a = !0,
1170
+ showReportPost: m = !0,
1171
+ onReply: d,
1172
+ onReact: l,
1173
+ onDelete: c,
1174
+ onReport: y,
1175
+ isSubmitting: f,
1176
+ showModeratedPosts: k = !1,
1177
+ isBanned: x = !1,
1178
+ highlightable: g = !1,
1179
+ isNew: E = !1,
1180
+ onNewSeen: T,
1181
+ depth: v = 0,
1182
+ parentPostId: p,
1183
+ onReplyCreated: D,
1184
+ onDeleteSuccess: M
1185
+ }) => {
1186
+ var A, N, H, ae;
1187
+ const { t: R } = be(), { language: F } = Ke(Ue), J = gt(r, i), [K, _] = I(!1), [q, B] = I([]), [j, oe] = I(!1), [ne, pe] = I(!1), [Q, de] = I(!1), [re, ie] = I({ open: !1, variant: "success", title: "", message: "" }), Z = V(null);
1188
+ he(() => {
1189
+ if (!E || !T || !Z.current) return;
1190
+ let h;
1191
+ const $ = new IntersectionObserver(
1192
+ ([ee]) => {
1193
+ ee.isIntersecting && ($.disconnect(), h = setTimeout(() => T(t.id), po));
1194
+ },
1195
+ { threshold: 0.5 }
1196
+ );
1197
+ return $.observe(Z.current), () => {
1198
+ $.disconnect(), clearTimeout(h);
1199
+ };
1200
+ }, [E, T, t.id]);
1201
+ const se = !!(i && J && t.userId === J), P = !!t.moderated, U = async (h) => {
1202
+ var ce;
1203
+ const $ = v === 1 && p || t.id, ee = ((ce = t.userModel) == null ? void 0 : ce.name) || t.anonymousNickname || R("discussion.anonymous", "Anonymous"), ke = v === 1 ? `@${ee} ${h}` : h;
1204
+ await d($, ke), _(!1), v === 1 && D ? D() : v === 0 && (oe(!0), X());
1205
+ }, X = async () => {
1206
+ if (!(!a || v >= 2))
1207
+ try {
1208
+ const h = await r.discussions.getPostReplies(t.id, {
1209
+ limit: 25,
1210
+ skipDeleted: !0,
1211
+ skipModerated: !k
1212
+ });
1213
+ B(h.data);
1214
+ } catch (h) {
1215
+ console.error("Failed to load replies:", h);
1216
+ }
1217
+ };
1218
+ he(() => {
1219
+ j && q.length === 0 && X();
1220
+ }, [j]);
1221
+ const Ee = async (h) => {
1222
+ await c(h, t.id), B(($) => $.filter((ee) => ee.id !== h));
1223
+ }, me = async (h, $) => {
1224
+ const ee = await l(h, $);
1225
+ ee && q.length > 0 && B(
1226
+ (ke) => ke.map((ce) => ce.id === h ? ee : ce)
1227
+ );
1228
+ }, C = (h, $) => {
1229
+ ie({ open: !0, variant: $, title: "", message: h });
1230
+ }, S = v > 0 ? "reply" : "top", w = ((A = t.userModel) == null ? void 0 : A.name) || t.anonymousNickname || "User";
1231
+ return /* @__PURE__ */ b(
1232
+ "div",
1233
+ {
1234
+ css: g ? E ? O.highlighted[S] : O.highlightable[S] : O.post[S],
1235
+ children: [
1236
+ /* @__PURE__ */ b("div", { css: O.row, children: [
1237
+ /* @__PURE__ */ n(St, { src: (N = t.userModel) == null ? void 0 : N.avatar, alt: w, css: O.avatar, children: /* @__PURE__ */ n(Kt, { color: e.icon, style: lo }) }),
1238
+ /* @__PURE__ */ b("div", { css: O.body, children: [
1239
+ /* @__PURE__ */ b("div", { ref: Z, css: O.header, children: [
1240
+ /* @__PURE__ */ n("p", { css: O.name, children: ((H = t.userModel) == null ? void 0 : H.name) || t.anonymousNickname || R("discussion.anonymous", "Anonymous") }),
1241
+ /* @__PURE__ */ n("span", { css: O.time, children: co(t.createdAt, R, F) }),
1242
+ E && /* @__PURE__ */ n("span", { css: O.badge, children: R("discussion.newPost", "New") }),
1243
+ /* @__PURE__ */ n(
1244
+ ro,
1245
+ {
1246
+ isOwnPost: se,
1247
+ canReport: !!(m && i && !se) && !P,
1248
+ onDelete: () => pe(!0),
1249
+ onReport: () => de(!0),
1250
+ disabled: x
1251
+ }
1252
+ )
1253
+ ] }),
1254
+ P && k ? /* @__PURE__ */ b("div", { css: O.moderated, children: [
1255
+ /* @__PURE__ */ n(Ut, { size: "0.9375em", color: e.textSecondary, style: uo }),
1256
+ /* @__PURE__ */ n("p", { css: O.moderatedText, children: t.moderatedReason || R(
1257
+ "discussion.moderatedPost",
1258
+ "This comment has been moderated"
1259
+ ) })
1260
+ ] }) : /* @__PURE__ */ n("p", { css: O.content, children: t.content }),
1261
+ !P && /* @__PURE__ */ n(
1262
+ no,
1263
+ {
1264
+ post: t,
1265
+ sdk: r,
1266
+ userIsLoggedIn: i,
1267
+ onSignInClick: s,
1268
+ onReact: l,
1269
+ showReactions: u,
1270
+ showReplyButton: a && v < 2,
1271
+ onReplyClick: () => _(!K),
1272
+ isBanned: x
1273
+ }
1274
+ ),
1275
+ a && t.repliesCount > 0 && /* @__PURE__ */ n("div", { css: O.repliesRow, children: /* @__PURE__ */ b(
1276
+ "p",
1277
+ {
1278
+ css: O.repliesToggle,
1279
+ onClick: () => oe(!j),
1280
+ children: [
1281
+ j ? R("discussion.hideReplies", "Hide replies") : R("discussion.repliesCount", "{{count}} replies", {
1282
+ count: t.repliesCount
1283
+ }),
1284
+ !j && " ▼"
1285
+ ]
1286
+ }
1287
+ ) }),
1288
+ K && !P && /* @__PURE__ */ n("div", { css: O.nested, children: /* @__PURE__ */ n(
1289
+ ft,
1290
+ {
1291
+ onSubmit: U,
1292
+ userIsLoggedIn: i,
1293
+ onSignInClick: s,
1294
+ placeholder: R("discussion.writeReply", "Write a reply..."),
1295
+ isSubmitting: f,
1296
+ replyTo: ((ae = t.userModel) == null ? void 0 : ae.name) || t.anonymousNickname,
1297
+ onCancel: () => _(!1),
1298
+ disabled: x
1299
+ }
1300
+ ) }),
1301
+ j && q.length > 0 && /* @__PURE__ */ n("div", { css: O.nested, children: q.map((h) => /* @__PURE__ */ n(
1302
+ yt,
1303
+ {
1304
+ post: h,
1305
+ sdk: r,
1306
+ userIsLoggedIn: i,
1307
+ onSignInClick: s,
1308
+ showReactions: u,
1309
+ showReplies: a,
1310
+ showReportPost: m,
1311
+ onReply: d,
1312
+ onReact: me,
1313
+ onDelete: Ee,
1314
+ onReport: y,
1315
+ isSubmitting: f,
1316
+ showModeratedPosts: k,
1317
+ isBanned: x,
1318
+ depth: v + 1,
1319
+ parentPostId: v === 0 ? t.id : p,
1320
+ onReplyCreated: v === 0 ? X : void 0,
1321
+ onDeleteSuccess: M
1322
+ },
1323
+ h.id
1324
+ )) })
1325
+ ] })
1326
+ ] }),
1327
+ /* @__PURE__ */ n(
1328
+ io,
1329
+ {
1330
+ open: ne,
1331
+ onClose: () => pe(!1),
1332
+ onConfirm: async () => {
1333
+ await c(t.id), M == null || M();
1334
+ },
1335
+ onError: (h) => C(h, "error")
1336
+ }
1337
+ ),
1338
+ /* @__PURE__ */ n(
1339
+ ao,
1340
+ {
1341
+ open: Q,
1342
+ onClose: () => de(!1),
1343
+ onSubmit: (h, $) => y(t.id, h, $),
1344
+ onSuccess: (h) => C(h, "success"),
1345
+ onError: (h) => C(h, "error")
1346
+ }
1347
+ ),
1348
+ /* @__PURE__ */ n(
1349
+ dt,
1350
+ {
1351
+ notification: re,
1352
+ onClose: () => ie((h) => ({ ...h, open: !1 }))
1353
+ }
1354
+ )
1355
+ ]
1356
+ }
1357
+ );
1358
+ }, He = 864e5, st = -1, Be = o(z.bodyMd, { fontSize: "0.8125em", color: e.textSecondary }), at = o({ transition: "transform 0.2s" }), L = {
1359
+ root: o({
1360
+ fontSize: "1em",
1361
+ marginBottom: e.spaceSm,
1362
+ padding: e.spaceMd,
1363
+ backgroundColor: e.dangerSoft,
1364
+ borderLeft: `4px solid ${e.danger}`,
1365
+ borderRadius: e.radiusSm
1366
+ }),
1367
+ row: o({ display: "flex", gap: e.spaceSm, alignItems: "flex-start" }),
1368
+ badge: o({
1369
+ flexShrink: 0,
1370
+ display: "flex",
1371
+ alignItems: "center",
1372
+ justifyContent: "center",
1373
+ width: "2.25em",
1374
+ height: "2.25em",
1375
+ borderRadius: "50%",
1376
+ backgroundColor: e.danger1f,
1377
+ color: e.danger
1378
+ }),
1379
+ body: o({ flex: 1, minWidth: 0 }),
1380
+ title: o(z.titleMd, { fontWeight: 700, fontFamily: e.fontPrimary, color: e.text }),
1381
+ description: o(z.bodySm, { marginTop: e.space2xs, color: e.textBody }),
1382
+ pills: o({ display: "flex", flexWrap: "wrap", alignItems: "center", gap: e.spaceXs, marginTop: e.spaceSm }),
1383
+ pill: o(z.bodyMd, {
1384
+ fontSize: "0.75em",
1385
+ fontWeight: 600,
1386
+ color: e.danger,
1387
+ border: `1px solid ${e.danger}`,
1388
+ borderRadius: e.radiusLg,
1389
+ paddingInline: e.spaceXs,
1390
+ paddingBlock: "0.125em"
1391
+ }),
1392
+ meta: Be,
1393
+ reasonBox: o({
1394
+ marginTop: e.spaceSm,
1395
+ paddingInline: e.spaceSm,
1396
+ paddingBlock: e.spaceXs,
1397
+ backgroundColor: e.surface,
1398
+ borderRadius: e.radiusXs
1399
+ }),
1400
+ // A Joy Typography span is a block.
1401
+ reasonLabel: o(z.bodyXs, { display: "block", fontWeight: 600, textTransform: "uppercase", color: e.textSecondary }),
1402
+ reason: o(z.bodySm, { color: e.text, whiteSpace: "pre-wrap", unicodeBidi: "plaintext" }),
1403
+ history: o({ marginTop: e.spaceSm }),
1404
+ // Typography as a button: Joy's reset plus the widget's look.
1405
+ toggle: o(z.bodyMd, {
1406
+ fontSize: "0.8125em",
1407
+ fontWeight: 600,
1408
+ fontFamily: e.fontPrimary,
1409
+ color: e.text,
1410
+ display: "inline-flex",
1411
+ alignItems: "center",
1412
+ gap: e.space2xs,
1413
+ padding: 0,
1414
+ border: "none",
1415
+ backgroundColor: "transparent",
1416
+ cursor: "pointer"
1417
+ }),
1418
+ chevron: { closed: at, open: o(at, { transform: "rotate(180deg)" }) },
1419
+ list: o({ listStyle: "none", margin: 0, padding: 0, marginTop: e.spaceXs }),
1420
+ entry: o({ paddingBlock: e.spaceXs, borderTop: `1px solid ${e.danger33}` }),
1421
+ entryDates: o(Be, { fontWeight: 600, color: e.text }),
1422
+ entryReason: o(Be, { unicodeBidi: "plaintext" }),
1423
+ entryLifted: o(Be, { fontStyle: "italic" }),
1424
+ isolate: o({ unicodeBidi: "isolate" })
1425
+ }, mo = ({
1426
+ ban: t,
1427
+ showBanHistory: r = !1
1428
+ }) => {
1429
+ const { t: i } = be(), { language: s } = Ke(Ue), [u, a] = I(!1), m = ut(s), d = (g) => new Date(g).toLocaleDateString(m, { dateStyle: "medium" }), l = (g) => new Date(g).toLocaleString(m, {
1430
+ dateStyle: "medium",
1431
+ timeStyle: "short"
1432
+ }), { activeBan: c } = t, y = c.bannedPeriodInDays === st, f = new Date(
1433
+ new Date(c.bannedAt).getTime() + c.bannedPeriodInDays * He
1434
+ ), k = Math.max(
1435
+ 1,
1436
+ Math.ceil((f.getTime() - Date.now()) / He)
1437
+ ), x = (t.history || []).filter(
1438
+ (g) => g.bannedAt !== c.bannedAt
1439
+ );
1440
+ return /* @__PURE__ */ n("div", { role: "status", css: L.root, children: /* @__PURE__ */ b("div", { css: L.row, children: [
1441
+ /* @__PURE__ */ n("div", { css: L.badge, children: /* @__PURE__ */ n(Vt, { size: "1.25em", color: e.icon }) }),
1442
+ /* @__PURE__ */ b("div", { css: L.body, children: [
1443
+ /* @__PURE__ */ n("p", { css: L.title, children: i("discussion.ban.title", "You've been banned from commenting") }),
1444
+ /* @__PURE__ */ n("p", { css: L.description, children: y ? i(
1445
+ "discussion.ban.descriptionPermanent",
1446
+ "You can still read the discussion, but you can no longer post, reply or react."
1447
+ ) : i(
1448
+ "discussion.ban.description",
1449
+ "You can still read the discussion, but you can't post, reply or react until the ban ends."
1450
+ ) }),
1451
+ /* @__PURE__ */ b("div", { css: L.pills, children: [
1452
+ /* @__PURE__ */ n("span", { css: L.pill, children: y ? i("discussion.ban.permanent", "Permanent ban") : i("discussion.ban.daysLeft", "{{count}} days left", {
1453
+ count: k
1454
+ }) }),
1455
+ /* @__PURE__ */ n("span", { css: L.meta, children: i("discussion.ban.since", "Since {{date}}", {
1456
+ date: d(c.bannedAt)
1457
+ }) }),
1458
+ !y && /* @__PURE__ */ b("span", { css: L.meta, children: [
1459
+ "·",
1460
+ " ",
1461
+ i("discussion.ban.until", "Until {{date}}", {
1462
+ date: l(f)
1463
+ })
1464
+ ] })
1465
+ ] }),
1466
+ c.bannedReason && /* @__PURE__ */ b("div", { css: L.reasonBox, children: [
1467
+ /* @__PURE__ */ n("span", { css: L.reasonLabel, children: i("discussion.ban.reason", "Reason") }),
1468
+ /* @__PURE__ */ n("p", { css: L.reason, children: c.bannedReason })
1469
+ ] }),
1470
+ r && x.length > 0 && /* @__PURE__ */ b("div", { css: L.history, children: [
1471
+ /* @__PURE__ */ b(
1472
+ "button",
1473
+ {
1474
+ type: "button",
1475
+ "aria-expanded": u,
1476
+ onClick: () => a((g) => !g),
1477
+ css: L.toggle,
1478
+ children: [
1479
+ i("discussion.ban.previousBans", "Previous bans ({{count}})", {
1480
+ count: x.length
1481
+ }),
1482
+ /* @__PURE__ */ n(
1483
+ _t,
1484
+ {
1485
+ size: "1.25em",
1486
+ color: e.icon,
1487
+ css: u ? L.chevron.open : L.chevron.closed
1488
+ }
1489
+ )
1490
+ ]
1491
+ }
1492
+ ),
1493
+ u && /* @__PURE__ */ n("ul", { css: L.list, children: x.map((g) => {
1494
+ const E = g.unbannedAt ?? (g.bannedPeriodInDays > 0 ? new Date(
1495
+ new Date(g.bannedAt).getTime() + g.bannedPeriodInDays * He
1496
+ ) : null);
1497
+ return /* @__PURE__ */ b("li", { css: L.entry, children: [
1498
+ /* @__PURE__ */ b("p", { css: L.entryDates, children: [
1499
+ d(g.bannedAt),
1500
+ E && ` – ${d(E)}`,
1501
+ g.bannedPeriodInDays === st && ` · ${i("discussion.ban.permanent", "Permanent ban")}`,
1502
+ g.bannedPeriodInDays > 0 && ` · ${i("discussion.ban.days", "{{count}} days", { count: g.bannedPeriodInDays })}`
1503
+ ] }),
1504
+ g.bannedReason && /* @__PURE__ */ n("p", { css: L.entryReason, children: g.bannedReason }),
1505
+ g.unbannedAt && /* @__PURE__ */ b("p", { css: L.entryLifted, children: [
1506
+ i("discussion.ban.lifted", "Lifted on {{date}}", {
1507
+ date: d(g.unbannedAt)
1508
+ }),
1509
+ g.unbannedReason && /* @__PURE__ */ b(Re, { children: [
1510
+ ": ",
1511
+ /* @__PURE__ */ n("span", { css: L.isolate, children: g.unbannedReason })
1512
+ ] })
1513
+ ] })
1514
+ ] }, g.bannedAt);
1515
+ }) })
1516
+ ] })
1517
+ ] })
1518
+ ] }) });
1519
+ }, fo = (t) => {
1520
+ var r, i, s;
1521
+ return (((r = t == null ? void 0 : t.error) == null ? void 0 : r.code) ?? ((s = (i = t == null ? void 0 : t.data) == null ? void 0 : i.error) == null ? void 0 : s.code) ?? (t == null ? void 0 : t.status)) === 429;
1522
+ }, ct = { display: "flex", alignItems: "center", marginInlineStart: "0.5em", marginInlineEnd: "-2px" }, we = {
1523
+ root: o({
1524
+ boxSizing: "border-box",
1525
+ position: "relative",
1526
+ display: "flex",
1527
+ alignItems: "center",
1528
+ minWidth: "150px",
1529
+ minHeight: "2em",
1530
+ paddingBlock: "2px",
1531
+ paddingInline: "0.5em",
1532
+ border: `1px solid ${e.border}`,
1533
+ borderRadius: e.radiusSm,
1534
+ backgroundColor: e.surfaceVariant,
1535
+ color: e.text,
1536
+ fontFamily: e.fontBody,
1537
+ fontSize: "1em",
1538
+ fontWeight: 400,
1539
+ lineHeight: 1.5,
1540
+ cursor: "pointer",
1541
+ "&:has(:focus-visible)::before": {
1542
+ content: '""',
1543
+ position: "absolute",
1544
+ inset: 0,
1545
+ zIndex: 1,
1546
+ margin: "-1px",
1547
+ borderRadius: "inherit",
1548
+ pointerEvents: "none",
1549
+ boxShadow: `inset 0 0 0 2px ${e.focus}`
1550
+ }
1551
+ }),
1552
+ button: o({
1553
+ display: "flex",
1554
+ alignItems: "center",
1555
+ alignSelf: "stretch",
1556
+ flex: 1,
1557
+ boxSizing: "border-box",
1558
+ margin: 0,
1559
+ padding: 0,
1560
+ border: 0,
1561
+ outline: 0,
1562
+ background: "none",
1563
+ color: "inherit",
1564
+ font: "inherit",
1565
+ lineHeight: "normal",
1566
+ whiteSpace: "nowrap",
1567
+ overflow: "hidden",
1568
+ cursor: "pointer"
1569
+ }),
1570
+ // Joy's icon grey on the svg only; open, it takes the field's colour.
1571
+ indicatorClosed: o({ ...ct, "& svg": { color: e.icon } }),
1572
+ indicatorOpen: o(ct),
1573
+ list: o({
1574
+ position: "fixed",
1575
+ zIndex: 1300,
1576
+ boxSizing: "border-box",
1577
+ display: "flex",
1578
+ flexDirection: "column",
1579
+ minWidth: "max-content",
1580
+ maxHeight: "44vh",
1581
+ overflow: "auto",
1582
+ margin: 0,
1583
+ paddingBlock: "calc(0.25em / 0.875)",
1584
+ paddingInline: 0,
1585
+ listStyle: "none",
1586
+ border: `1px solid ${e.border}`,
1587
+ borderRadius: e.radiusSm,
1588
+ backgroundColor: e.surface,
1589
+ boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1)",
1590
+ color: "var(--fu-ucrc-neutral-outlined-color)",
1591
+ fontFamily: e.fontBody,
1592
+ fontSize: "0.875em",
1593
+ lineHeight: 1.5
1594
+ }),
1595
+ option: o({
1596
+ boxSizing: "border-box",
1597
+ position: "relative",
1598
+ display: "flex",
1599
+ alignItems: "center",
1600
+ flexShrink: 0,
1601
+ gap: "calc(0.5em / 0.875)",
1602
+ minHeight: "calc(2em / 0.875)",
1603
+ paddingBlock: "3px",
1604
+ paddingInline: "calc(0.5em / 0.875)",
1605
+ border: "1px solid transparent",
1606
+ fontSize: "1em",
1607
+ color: e.text,
1608
+ backgroundColor: e.surface,
1609
+ cursor: "pointer",
1610
+ "&:hover, &[aria-selected='true']": { backgroundColor: e.surfaceVariant }
1611
+ })
1612
+ }, go = ({ value: t, options: r, onChange: i }) => {
1613
+ var l;
1614
+ const s = wt(
1615
+ r.map((c) => c.value),
1616
+ t,
1617
+ (c) => i(c)
1618
+ ), u = V(null), a = V(null), m = ht(s.open, s.rootRef, a, "start"), d = (c) => {
1619
+ var f, k, x;
1620
+ const y = c.target;
1621
+ (f = u.current) != null && f.contains(y) || (k = a.current) != null && k.contains(y) || ((x = u.current) == null || x.focus(), s.triggerProps.onClick());
1622
+ };
1623
+ return /* @__PURE__ */ b("div", { ref: s.rootRef, css: we.root, onClick: d, children: [
1624
+ /* @__PURE__ */ n("button", { ref: u, ...s.triggerProps, css: we.button, children: (l = r.find((c) => c.value === t)) == null ? void 0 : l.label }),
1625
+ /* @__PURE__ */ n("span", { css: s.open ? we.indicatorOpen : we.indicatorClosed, children: /* @__PURE__ */ n(jt, {}) }),
1626
+ s.open && /* @__PURE__ */ n("ul", { ref: a, ...s.listboxProps, css: we.list, style: m, children: r.map((c, y) => /* @__PURE__ */ n("li", { ...s.optionProps(y), css: we.option, children: c.label }, c.value)) })
1627
+ ] });
1628
+ }, te = {
1629
+ root: o({ marginInline: "auto", maxHeight: "100%", overflowY: "auto", backgroundColor: e.surface }),
1630
+ header: o({ marginBottom: e.spaceLg }),
1631
+ title: o(z.h3, { marginBottom: e.spaceXs, unicodeBidi: "plaintext" }),
1632
+ count: o(z.bodySm, { color: e.textSecondary }),
1633
+ divider: o({
1634
+ position: "relative",
1635
+ flexShrink: 0,
1636
+ alignSelf: "stretch",
1637
+ height: "1px",
1638
+ marginBlock: e.spaceLg,
1639
+ marginInline: 0,
1640
+ border: "none",
1641
+ backgroundColor: "var(--fu-ucrc-divider)"
1642
+ }),
1643
+ sortRow: o({
1644
+ display: "flex",
1645
+ justifyContent: "space-between",
1646
+ alignItems: "center",
1647
+ marginBottom: e.spaceLg
1648
+ }),
1649
+ listSpinner: o({ paddingBlock: e.spaceXl }),
1650
+ empty: o({ textAlign: "center", paddingBlock: e.spaceXl }),
1651
+ emptyText: o(z.bodyMd, { color: e.textSecondary }),
1652
+ sentinel: o({ height: "1px" }),
1653
+ moreSpinner: o({ paddingBlock: e.spaceMd }),
1654
+ loadMore: o({ display: "flex", justifyContent: "center", marginTop: e.spaceLg })
1655
+ }, ho = ({
1656
+ discussion: t,
1657
+ posts: r,
1658
+ postsHidden: i = !1,
1659
+ sdk: s,
1660
+ userIsLoggedIn: u,
1661
+ onSignInClick: a,
1662
+ showReactions: m,
1663
+ showReplies: d,
1664
+ showReportPost: l,
1665
+ currentSort: c,
1666
+ onSortChange: y,
1667
+ onCreatePost: f,
1668
+ onReact: k,
1669
+ onDeletePost: x,
1670
+ onReportPost: g,
1671
+ onLoadMore: E,
1672
+ hasMore: T,
1673
+ liveRefresh: v = !1,
1674
+ newPostIds: p,
1675
+ onNewPostSeen: D,
1676
+ isLoading: M,
1677
+ isSubmitting: R,
1678
+ infiniteScroll: F = !1,
1679
+ showModeratedPosts: J = !1,
1680
+ ban: K,
1681
+ isBanned: _ = !1,
1682
+ showBanHistory: q = !1
1683
+ }) => {
1684
+ const { t: B } = be(), j = Ve(), oe = V(null), ne = V(null);
1685
+ he(() => {
1686
+ if (!F || !ne.current) return;
1687
+ const P = new IntersectionObserver(
1688
+ (U) => {
1689
+ U[0].isIntersecting && T && !M && E();
1690
+ },
1691
+ { root: oe.current, threshold: 0.1 }
1692
+ );
1693
+ return P.observe(ne.current), () => P.disconnect();
1694
+ }, [F, T, M, E]);
1695
+ const [pe, Q] = I({ open: !1, variant: "success", title: "", message: "" }), de = () => {
1696
+ Q({
1697
+ open: !0,
1698
+ variant: "success",
1699
+ title: "",
1700
+ message: B("discussion.delete.success", "Comment deleted successfully.")
1701
+ });
1702
+ }, re = (P, U) => {
1703
+ pt(P) || Q({
1704
+ open: !0,
1705
+ variant: "error",
1706
+ title: "",
1707
+ message: fo(P) ? B(
1708
+ "discussion.rateLimited",
1709
+ "You're doing that too often. Please wait a moment and try again."
1710
+ ) : U
1711
+ });
1712
+ }, ie = async (P, U) => {
1713
+ try {
1714
+ return await k(P, U);
1715
+ } catch (X) {
1716
+ throw re(
1717
+ X,
1718
+ B("discussion.reactError", "Failed to add reaction. Please try again.")
1719
+ ), X;
1720
+ }
1721
+ }, Z = async (P, U) => {
1722
+ try {
1723
+ await f(P, U);
1724
+ } catch (X) {
1725
+ throw re(
1726
+ X,
1727
+ B("discussion.postError", "Failed to post comment. Please try again.")
1728
+ ), X;
1729
+ }
1730
+ Q({
1731
+ open: !0,
1732
+ variant: "success",
1733
+ title: "",
1734
+ message: B("discussion.postSuccess", "Comment posted successfully.")
1735
+ });
1736
+ }, se = [
1737
+ { value: "LATEST", label: B("discussion.sort.latest", "Latest") },
1738
+ { value: "OLDEST", label: B("discussion.sort.oldest", "Oldest") },
1739
+ { value: "POPULAR", label: B("discussion.sort.popular", "Popular") },
1740
+ {
1741
+ value: "INTERACTED",
1742
+ label: B("discussion.sort.interacted", "Most Interacted")
1743
+ }
1744
+ ];
1745
+ return /* @__PURE__ */ b("div", { ref: oe, css: te.root, style: j, children: [
1746
+ /* @__PURE__ */ b("div", { css: te.header, children: [
1747
+ /* @__PURE__ */ n("h3", { css: te.title, children: t.label || B("discussion.title", "Discussion") }),
1748
+ !i && /* @__PURE__ */ n("p", { css: te.count, children: B("discussion.postsCount", "{{count}} posts", {
1749
+ count: t.postsCount || 0
1750
+ }) })
1751
+ ] }),
1752
+ _ && K && /* @__PURE__ */ n(mo, { ban: K, showBanHistory: q }),
1753
+ /* @__PURE__ */ n(
1754
+ ft,
1755
+ {
1756
+ onSubmit: (P) => Z(P),
1757
+ userIsLoggedIn: u,
1758
+ onSignInClick: a,
1759
+ isSubmitting: R,
1760
+ disabled: _
1761
+ }
1762
+ ),
1763
+ !i && /* @__PURE__ */ b(Re, { children: [
1764
+ /* @__PURE__ */ n("hr", { css: te.divider }),
1765
+ /* @__PURE__ */ b("div", { css: te.sortRow, children: [
1766
+ /* @__PURE__ */ n("p", { css: z.titleMd, children: B("discussion.comments", "Comments") }),
1767
+ /* @__PURE__ */ n(go, { value: c, options: se, onChange: y })
1768
+ ] }),
1769
+ M && r.length === 0 ? /* @__PURE__ */ n("div", { css: te.listSpinner, children: /* @__PURE__ */ n(Oe, { marginBlock: "32px" }) }) : r.length === 0 ? /* @__PURE__ */ n("div", { css: te.empty, children: /* @__PURE__ */ n("p", { css: te.emptyText, children: B(
1770
+ "discussion.noPosts",
1771
+ "No comments yet. Be the first to comment!"
1772
+ ) }) }) : /* @__PURE__ */ b(Re, { children: [
1773
+ /* @__PURE__ */ n("div", { children: r.map((P) => /* @__PURE__ */ n(
1774
+ yt,
1775
+ {
1776
+ post: P,
1777
+ sdk: s,
1778
+ userIsLoggedIn: u,
1779
+ onSignInClick: a,
1780
+ showReactions: m,
1781
+ showReplies: d,
1782
+ showReportPost: l,
1783
+ onReply: (U, X) => Z(X, U),
1784
+ onReact: ie,
1785
+ onDelete: x,
1786
+ onReport: g,
1787
+ isSubmitting: R,
1788
+ showModeratedPosts: J,
1789
+ isBanned: _,
1790
+ highlightable: v,
1791
+ isNew: p == null ? void 0 : p.has(P.id),
1792
+ onNewSeen: D,
1793
+ onDeleteSuccess: de
1794
+ },
1795
+ P.id
1796
+ )) }),
1797
+ F && /* @__PURE__ */ n("div", { ref: ne, css: te.sentinel })
1798
+ ] }),
1799
+ F && M && r.length > 0 && /* @__PURE__ */ n("div", { css: te.moreSpinner, children: /* @__PURE__ */ n(Oe, { marginBlock: "16px" }) }),
1800
+ !F && T && /* @__PURE__ */ n("div", { css: te.loadMore, children: /* @__PURE__ */ n(ue, { look: "outlined", onClick: E, loading: M, children: B("discussion.loadMore", "Load More") }) })
1801
+ ] }),
1802
+ /* @__PURE__ */ n(
1803
+ dt,
1804
+ {
1805
+ notification: pe,
1806
+ onClose: () => Q((P) => ({ ...P, open: !1 }))
1807
+ }
1808
+ )
1809
+ ] });
1810
+ }, yo = (t) => {
1811
+ const {
1812
+ entityId: r,
1813
+ sdk: i,
1814
+ discussionLabel: s,
1815
+ discussionUrl: u = "",
1816
+ defaultSort: a = "LATEST",
1817
+ postsPerPage: m = 20,
1818
+ showReactions: d = !0,
1819
+ showReplies: l = !0,
1820
+ showReportPost: c = !0,
1821
+ infiniteScroll: y = !1,
1822
+ showModeratedPosts: f = !1,
1823
+ userIsLoggedIn: k = !1,
1824
+ showBanHistory: x = !1,
1825
+ refreshInterval: g = 0,
1826
+ onSignInClick: E
1827
+ } = t, { ban: T, isBanned: v, refresh: p } = eo(i, k), {
1828
+ discussion: D,
1829
+ setDiscussion: M,
1830
+ isLoading: R,
1831
+ error: F,
1832
+ isNotFound: J
1833
+ } = Gt(i, r), K = () => ({
1834
+ id: r,
1835
+ label: "",
1836
+ postsCount: 0,
1837
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1838
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1839
+ }), _ = (me) => {
1840
+ M((C) => {
1841
+ const S = C ?? K();
1842
+ return { ...S, postsCount: Math.max(0, S.postsCount + me) };
1843
+ });
1844
+ }, {
1845
+ posts: q,
1846
+ postsHidden: B,
1847
+ isLoading: j,
1848
+ isSubmitting: oe,
1849
+ currentSort: ne,
1850
+ hasMore: pe,
1851
+ newPostIds: Q,
1852
+ markPostSeen: de,
1853
+ handleSortChange: re,
1854
+ handleLoadMore: ie,
1855
+ handleCreatePost: Z,
1856
+ handleReact: se,
1857
+ handleDeletePost: P,
1858
+ handleReportPost: U
1859
+ } = Qt(
1860
+ i,
1861
+ r,
1862
+ s || null,
1863
+ u,
1864
+ a,
1865
+ m,
1866
+ _,
1867
+ f,
1868
+ g
1869
+ ), X = (me) => async (...C) => {
1870
+ try {
1871
+ return await me(...C);
1872
+ } catch (S) {
1873
+ throw pt(S) && p(), S;
1874
+ }
1875
+ };
1876
+ if (R || !D && !J && j)
1877
+ return /* @__PURE__ */ n(Oe, { marginBlock: "160px" });
1878
+ if (F)
1879
+ return /* @__PURE__ */ n("div", { style: { padding: "20px", textAlign: "center" }, children: /* @__PURE__ */ n("p", { children: "Failed to load discussion. Please try again later." }) });
1880
+ const Ee = async (me, C) => {
1881
+ await Z(me, C), s && M((S) => ({ ...S ?? K(), label: s }));
1882
+ };
1883
+ return /* @__PURE__ */ n(
1884
+ ho,
1885
+ {
1886
+ discussion: D ?? K(),
1887
+ posts: q,
1888
+ postsHidden: B,
1889
+ sdk: i,
1890
+ userIsLoggedIn: k,
1891
+ onSignInClick: E,
1892
+ showReactions: d,
1893
+ showReplies: l,
1894
+ showReportPost: c,
1895
+ currentSort: ne,
1896
+ onSortChange: re,
1897
+ onCreatePost: X(Ee),
1898
+ onReact: X(se),
1899
+ onDeletePost: X(P),
1900
+ onReportPost: X(U),
1901
+ onLoadMore: ie,
1902
+ hasMore: pe,
1903
+ liveRefresh: g > 0,
1904
+ newPostIds: Q,
1905
+ onNewPostSeen: de,
1906
+ isLoading: j,
1907
+ isSubmitting: oe,
1908
+ infiniteScroll: y,
1909
+ showModeratedPosts: f,
1910
+ ban: T,
1911
+ isBanned: v,
1912
+ showBanHistory: x
1913
+ }
1914
+ );
1915
+ }, Io = (t) => /* @__PURE__ */ n(
1916
+ Ct,
1917
+ {
1918
+ packageName: "discussion",
1919
+ language: t.language,
1920
+ themeOptions: t.themeOptions,
1921
+ disableCache: t.disableCache,
1922
+ fillHeight: !0,
1923
+ children: /* @__PURE__ */ n(yo, { ...t })
1924
+ }
1925
+ );
1926
+ export {
1927
+ Io as M
1928
+ };