@wexio/messenger-widget-react 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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +133 -0
  3. package/dist/widget-react-AgErOR36.js +325 -0
  4. package/dist/widget-react-AgErOR36.js.map +1 -0
  5. package/dist/widget-react-BAOIDvhV.js +4250 -0
  6. package/dist/widget-react-BAOIDvhV.js.map +1 -0
  7. package/dist/widget-react-BfPdgAQ-.js +5767 -0
  8. package/dist/widget-react-BfPdgAQ-.js.map +1 -0
  9. package/dist/widget-react-BxvW64LH.js +4429 -0
  10. package/dist/widget-react-BxvW64LH.js.map +1 -0
  11. package/dist/widget-react-C5COLy3m.js +23847 -0
  12. package/dist/widget-react-C5COLy3m.js.map +1 -0
  13. package/dist/widget-react-CAWxn8I0.js +247 -0
  14. package/dist/widget-react-CAWxn8I0.js.map +1 -0
  15. package/dist/widget-react-CDPzwV1i.js +11685 -0
  16. package/dist/widget-react-CDPzwV1i.js.map +1 -0
  17. package/dist/widget-react-CPYwD6FR.js +498 -0
  18. package/dist/widget-react-CPYwD6FR.js.map +1 -0
  19. package/dist/widget-react-CUBFPjaV.js +23 -0
  20. package/dist/widget-react-CUBFPjaV.js.map +1 -0
  21. package/dist/widget-react-CUuKGDZN.js +355 -0
  22. package/dist/widget-react-CUuKGDZN.js.map +1 -0
  23. package/dist/widget-react-CZs0xRrr.js +1336 -0
  24. package/dist/widget-react-CZs0xRrr.js.map +1 -0
  25. package/dist/widget-react-Cj_zbk_F.js +325 -0
  26. package/dist/widget-react-Cj_zbk_F.js.map +1 -0
  27. package/dist/widget-react-D-QrEVpv.js +125 -0
  28. package/dist/widget-react-D-QrEVpv.js.map +1 -0
  29. package/dist/widget-react-D8TPnM9r.js +26 -0
  30. package/dist/widget-react-D8TPnM9r.js.map +1 -0
  31. package/dist/widget-react-DE7AVrCo.js +5737 -0
  32. package/dist/widget-react-DE7AVrCo.js.map +1 -0
  33. package/dist/widget-react-DOX6j7_Q.js +30 -0
  34. package/dist/widget-react-DOX6j7_Q.js.map +1 -0
  35. package/dist/widget-react-DSw03RG7.js +262 -0
  36. package/dist/widget-react-DSw03RG7.js.map +1 -0
  37. package/dist/widget-react-Dew7YaLU.js +16 -0
  38. package/dist/widget-react-Dew7YaLU.js.map +1 -0
  39. package/dist/widget-react-DtOeNw5z.js +325 -0
  40. package/dist/widget-react-DtOeNw5z.js.map +1 -0
  41. package/dist/widget-react-DwL_rsx_.js +630 -0
  42. package/dist/widget-react-DwL_rsx_.js.map +1 -0
  43. package/dist/widget-react.d.ts +301 -0
  44. package/dist/widget-react.js +22285 -0
  45. package/dist/widget-react.js.map +1 -0
  46. package/package.json +41 -0
@@ -0,0 +1,630 @@
1
+ import "react";
2
+ import "react-dom";
3
+ import "react/jsx-runtime";
4
+ import "react-dom/client";
5
+ import { c as e, d as t } from "./widget-react-DE7AVrCo.js";
6
+ import { C as n, E as r, P as i, R as a, m as o, n as s, p as c } from "./widget-react-BfPdgAQ-.js";
7
+ import { i as l, n as u, o as d, t as f } from "./widget-react-BxvW64LH.js";
8
+ import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
9
+ import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
10
+ //#region dummy/news.ts
11
+ var x = [
12
+ {
13
+ id: "demo-news-1",
14
+ publishedAt: "2026-04-30T10:00:00.000Z",
15
+ coverGradient: ["#1e1f21", "#121314"],
16
+ coverImageUrl: "https://picsum.photos/seed/wexio-pioneer/960/600",
17
+ authorIds: ["maya", "sam"],
18
+ categorySlug: "company",
19
+ tagSlugs: ["events", "product"]
20
+ },
21
+ {
22
+ id: "demo-news-2",
23
+ publishedAt: "2026-04-15T10:00:00.000Z",
24
+ coverGradient: ["#1e3a8a", "#0c1e4a"],
25
+ coverImageUrl: "https://picsum.photos/seed/wexio-april/960/600",
26
+ authorIds: ["leo"],
27
+ categorySlug: "product",
28
+ tagSlugs: ["product", "release"]
29
+ },
30
+ {
31
+ id: "demo-news-3",
32
+ publishedAt: "2026-03-22T10:00:00.000Z",
33
+ coverGradient: ["#0f766e", "#042f2e"],
34
+ coverImageUrl: "https://picsum.photos/seed/wexio-langs/960/600",
35
+ authorIds: ["ira", "leo"],
36
+ categorySlug: "product",
37
+ tagSlugs: ["ai", "languages"]
38
+ },
39
+ {
40
+ id: "demo-news-4",
41
+ publishedAt: "2026-03-08T10:00:00.000Z",
42
+ coverGradient: ["#7c3aed", "#2e1065"],
43
+ authorIds: ["leo"],
44
+ categorySlug: "engineering",
45
+ tagSlugs: ["integrations", "slack"]
46
+ },
47
+ {
48
+ id: "demo-news-5",
49
+ publishedAt: "2026-02-18T10:00:00.000Z",
50
+ coverGradient: ["#b45309", "#451a03"],
51
+ coverImageUrl: "https://picsum.photos/seed/wexio-inbox2/960/600",
52
+ authorIds: ["maya"],
53
+ categorySlug: "product",
54
+ tagSlugs: ["inbox", "product"]
55
+ },
56
+ {
57
+ id: "demo-news-6",
58
+ publishedAt: "2026-02-02T10:00:00.000Z",
59
+ coverGradient: ["#155e75", "#083344"],
60
+ authorIds: ["sam"],
61
+ categorySlug: "engineering",
62
+ tagSlugs: ["privacy", "security"]
63
+ },
64
+ {
65
+ id: "demo-news-7",
66
+ publishedAt: "2026-01-20T10:00:00.000Z",
67
+ coverGradient: ["#be185d", "#500724"],
68
+ coverImageUrl: "https://picsum.photos/seed/wexio-mobile/960/600",
69
+ authorIds: ["ira"],
70
+ categorySlug: "product",
71
+ tagSlugs: ["mobile", "beta"]
72
+ },
73
+ {
74
+ id: "demo-news-8",
75
+ publishedAt: "2026-01-05T10:00:00.000Z",
76
+ coverGradient: ["#15803d", "#052e16"],
77
+ authorIds: ["maya", "leo"],
78
+ categorySlug: "engineering",
79
+ tagSlugs: ["ai", "analytics"]
80
+ }
81
+ ];
82
+ function S(e) {
83
+ return x.map(({ tagSlugs: t, authorIds: r, categorySlug: i, ...a }) => ({
84
+ ...a,
85
+ title: e.raw(`news.${a.id}.title`),
86
+ excerpt: e.raw(`news.${a.id}.excerpt`),
87
+ contentMarkdown: e.raw(`news.${a.id}.body`),
88
+ authors: n(r),
89
+ category: {
90
+ slug: i,
91
+ label: e.raw(`news.categories.${i}`)
92
+ },
93
+ tags: t.map((t) => ({
94
+ slug: t,
95
+ label: e.raw(`news.tags.${t}`)
96
+ }))
97
+ }));
98
+ }
99
+ var C = f("megaphone", [
100
+ ["path", {
101
+ d: "M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",
102
+ key: "q8bfy3"
103
+ }],
104
+ ["path", {
105
+ d: "M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",
106
+ key: "1853fq"
107
+ }],
108
+ ["path", {
109
+ d: "M8 6v8",
110
+ key: "15ugcq"
111
+ }]
112
+ ]);
113
+ //#endregion
114
+ //#region components/ui/icon.tsx
115
+ function w({ icon: e, size: t = 20, strokeWidth: n = 2, className: r, ...i }) {
116
+ return /* @__PURE__ */ y(e, {
117
+ width: t,
118
+ height: t,
119
+ strokeWidth: n,
120
+ className: u("shrink-0", r),
121
+ ...i
122
+ });
123
+ }
124
+ //#endregion
125
+ //#region components/ui/skeleton.tsx
126
+ function T({ className: e, ...t }) {
127
+ return /* @__PURE__ */ y("div", {
128
+ "data-slot": "skeleton",
129
+ className: u("animate-pulse rounded-wx-sm bg-wx-bg-elevated", e),
130
+ ...t
131
+ });
132
+ }
133
+ //#endregion
134
+ //#region components/widget/author-avatars.tsx
135
+ function E(e) {
136
+ if (!Array.isArray(e)) return;
137
+ let t = e.map((e) => {
138
+ if (!e || typeof e != "object") return null;
139
+ let t = e.name;
140
+ if (typeof t != "string") return null;
141
+ let n = e._id ?? e.id, r = e.photo?.url;
142
+ return {
143
+ id: String(n ?? t),
144
+ name: t,
145
+ photoUrl: typeof r == "string" ? r : null
146
+ };
147
+ }).filter((e) => !!e);
148
+ return t.length > 0 ? t : void 0;
149
+ }
150
+ function D({ authors: e, max: t = 3, className: n }) {
151
+ return !e || e.length === 0 ? null : /* @__PURE__ */ y("span", {
152
+ className: `flex items-center -space-x-1.5 ${n ?? ""}`,
153
+ children: e.slice(0, t).map((e) => e.photoUrl ? /* @__PURE__ */ y("img", {
154
+ src: e.photoUrl,
155
+ alt: e.name,
156
+ title: e.name,
157
+ className: "h-5 w-5 rounded-full border border-wx-bg object-cover"
158
+ }, e.id) : /* @__PURE__ */ y("span", {
159
+ title: e.name,
160
+ className: "flex h-5 w-5 items-center justify-center rounded-full border border-wx-bg bg-wx-bg-elevated-2 text-[9px] font-semibold text-wx-fg-muted",
161
+ children: e.name.charAt(0).toUpperCase()
162
+ }, e.id))
163
+ });
164
+ }
165
+ //#endregion
166
+ //#region components/widget/sticky-search-header.tsx
167
+ function O({ value: t, onChange: n, placeholder: r, className: i }) {
168
+ return /* @__PURE__ */ b("div", {
169
+ className: u("sticky top-0 z-10 border-wx-border border-b bg-wx-bg", i),
170
+ children: [/* @__PURE__ */ y("span", {
171
+ className: "-translate-y-1/2 pointer-events-none absolute top-1/2 left-4 text-wx-fg-muted",
172
+ children: /* @__PURE__ */ y(e, { size: 16 })
173
+ }), /* @__PURE__ */ y("input", {
174
+ type: "search",
175
+ value: t,
176
+ onChange: (e) => n(e.target.value),
177
+ placeholder: r,
178
+ className: u("block w-full border-0 bg-transparent px-4 py-3 pl-10 text-sm text-wx-fg", "placeholder:text-wx-fg-muted focus:outline-none focus:ring-0", "[&::-webkit-search-cancel-button]:appearance-none")
179
+ })]
180
+ });
181
+ }
182
+ //#endregion
183
+ //#region lib/use-scroll-restore.ts
184
+ var k = /* @__PURE__ */ new Map();
185
+ function A(e) {
186
+ let t = g(null);
187
+ return m(() => {
188
+ let n = t.current;
189
+ if (!n) return;
190
+ let r = k.get(e) ?? 0, i = !1, a = performance.now(), o = () => {
191
+ if (i || !t.current) return;
192
+ let e = t.current;
193
+ if (e.scrollHeight - e.clientHeight >= r) {
194
+ e.scrollTop = r;
195
+ return;
196
+ }
197
+ if (performance.now() - a > 500) {
198
+ e.scrollTop = r;
199
+ return;
200
+ }
201
+ requestAnimationFrame(o);
202
+ };
203
+ requestAnimationFrame(o);
204
+ let s = () => {
205
+ k.set(e, n.scrollTop);
206
+ };
207
+ return n.addEventListener("scroll", s, { passive: !0 }), () => {
208
+ i = !0, n.removeEventListener("scroll", s);
209
+ };
210
+ }, [e]), t;
211
+ }
212
+ //#endregion
213
+ //#region lib/graphql/queries/generated/news.generated.tsx
214
+ var j = {}, M = a`
215
+ query VisitorNewsList($args: VisitorNewsListArgs) {
216
+ visitorNewsList(args: $args) {
217
+ items {
218
+ _id
219
+ title
220
+ slug
221
+ excerpt
222
+ publishedAt
223
+ upstreamUpdatedAt
224
+ reactionCounts
225
+ coverImageUrl {
226
+ _id
227
+ url
228
+ }
229
+ externalCoverImageUrl
230
+ authors {
231
+ _id
232
+ name
233
+ photo {
234
+ _id
235
+ url
236
+ }
237
+ }
238
+ categories {
239
+ _id
240
+ slug
241
+ label
242
+ }
243
+ tags {
244
+ _id
245
+ slug
246
+ label
247
+ }
248
+ }
249
+ meta {
250
+ totalCount
251
+ currentPage
252
+ totalPages
253
+ hasNextPage
254
+ hasPreviousPage
255
+ }
256
+ }
257
+ }
258
+ `;
259
+ function N(e) {
260
+ return i(M, {
261
+ ...j,
262
+ ...e
263
+ });
264
+ }
265
+ var P = a`
266
+ query VisitorNewsPostCard($args: VisitorNewsPostArgs!) {
267
+ visitorNewsPost(args: $args) {
268
+ _id
269
+ title
270
+ excerpt
271
+ coverImageUrl {
272
+ _id
273
+ url
274
+ }
275
+ externalCoverImageUrl
276
+ }
277
+ }
278
+ `;
279
+ function F(e) {
280
+ return i(P, {
281
+ ...j,
282
+ ...e
283
+ });
284
+ }
285
+ var I = a`
286
+ query VisitorNewsPost($args: VisitorNewsPostArgs!) {
287
+ visitorNewsPost(args: $args) {
288
+ _id
289
+ title
290
+ slug
291
+ excerpt
292
+ contentMarkdown
293
+ bodyFormat
294
+ locale
295
+ publishedAt
296
+ upstreamUpdatedAt
297
+ viewCount
298
+ reactionCounts
299
+ viewerReaction
300
+ sourceUrl
301
+ coverImageUrl {
302
+ _id
303
+ url
304
+ }
305
+ externalCoverImageUrl
306
+ source {
307
+ _id
308
+ name
309
+ type
310
+ }
311
+ authors {
312
+ _id
313
+ name
314
+ photo {
315
+ _id
316
+ url
317
+ }
318
+ }
319
+ categories {
320
+ _id
321
+ slug
322
+ label
323
+ }
324
+ tags {
325
+ _id
326
+ slug
327
+ label
328
+ }
329
+ translations {
330
+ _id
331
+ locale
332
+ slug
333
+ }
334
+ }
335
+ }
336
+ `;
337
+ function L(e) {
338
+ return i(I, {
339
+ ...j,
340
+ ...e
341
+ });
342
+ }
343
+ var R = a`
344
+ query VisitorNewsRelated($postId: ID!, $limit: Int, $locale: String) {
345
+ visitorNewsRelated(postId: $postId, limit: $limit, locale: $locale) {
346
+ _id
347
+ title
348
+ slug
349
+ excerpt
350
+ publishedAt
351
+ coverImageUrl {
352
+ _id
353
+ url
354
+ }
355
+ externalCoverImageUrl
356
+ }
357
+ }
358
+ `;
359
+ function z(e) {
360
+ return i(R, {
361
+ ...j,
362
+ ...e
363
+ });
364
+ }
365
+ a`
366
+ mutation RecordVisitorNewsView($postId: String!) {
367
+ recordVisitorNewsView(postId: $postId) {
368
+ ok
369
+ }
370
+ }
371
+ `;
372
+ //#endregion
373
+ //#region components/widget/tabs/news-tab/helpers.ts
374
+ function B(e) {
375
+ if (!e.upstreamUpdatedAt) return !1;
376
+ let t = Date.parse(e.upstreamUpdatedAt), n = Date.parse(e.publishedAt);
377
+ return Number.isNaN(t) || Number.isNaN(n) ? !1 : t > n + 6e4;
378
+ }
379
+ function V(e) {
380
+ let t = Date.parse(e);
381
+ if (Number.isNaN(t)) return "";
382
+ let n = Date.now() - t, r = Math.floor(n / 6e4);
383
+ if (r < 1) return "just now";
384
+ if (r < 60) return `${r}m ago`;
385
+ let i = Math.floor(r / 60);
386
+ if (i < 24) return `${i}h ago`;
387
+ let a = Math.floor(i / 24);
388
+ return a < 7 ? `${a}d ago` : new Date(t).toLocaleDateString();
389
+ }
390
+ //#endregion
391
+ //#region components/widget/tabs/news-tab/index.tsx
392
+ var H = 10, U = 240;
393
+ function W({ isDummy: e, onOpenArticle: t }) {
394
+ let n = l("news"), i = l("demo"), a = d(), o = r(), [c, u] = _(""), f = K(c, 300), g = f.length >= 2, x = o.previewData?.newsPosts, E = !e && Array.isArray(x) && x.length > 0, [D, k] = _(H), { data: j, error: M, loading: P, fetchMore: F } = N({
395
+ variables: { args: {
396
+ locale: a,
397
+ limit: H,
398
+ offset: 0,
399
+ ...g ? { query: f } : {}
400
+ } },
401
+ skip: e || E,
402
+ notifyOnNetworkStatusChange: !0
403
+ });
404
+ m(() => {
405
+ k(H);
406
+ }, [f, E]);
407
+ let I = h(() => (j?.visitorNewsList.items ?? []).filter((e) => !!e).map(G), [j]), L = E ? (x ?? []).filter((e) => !!e && typeof e == "object").map(G) : [], R = p((e) => e.title.toLowerCase().includes(f.toLowerCase()) || e.excerpt.toLowerCase().includes(f.toLowerCase()), [f]), z = e ? g ? S(i).filter(R) : S(i) : E ? g ? L.filter(R) : L : I, B = E || e ? z.slice(0, D) : z, V = h(() => e || E ? D < z.length : j?.visitorNewsList.meta.hasNextPage ?? !1, [
408
+ e,
409
+ E,
410
+ D,
411
+ z.length,
412
+ j
413
+ ]), [W, J] = _(!1), Y = p(async () => {
414
+ if (!(!V || W)) {
415
+ if (e || E) {
416
+ k((e) => e + H);
417
+ return;
418
+ }
419
+ J(!0);
420
+ try {
421
+ await F({
422
+ variables: { args: {
423
+ locale: a,
424
+ limit: H,
425
+ offset: j?.visitorNewsList.items.length ?? 0,
426
+ ...g ? { query: f } : {}
427
+ } },
428
+ updateQuery: (e, { fetchMoreResult: t }) => {
429
+ if (!t) return e;
430
+ let n = /* @__PURE__ */ new Set(), r = [];
431
+ for (let i of [...e.visitorNewsList.items, ...t.visitorNewsList.items]) i && !n.has(i._id) && (n.add(i._id), r.push(i));
432
+ return {
433
+ ...e,
434
+ visitorNewsList: {
435
+ ...t.visitorNewsList,
436
+ items: r
437
+ }
438
+ };
439
+ }
440
+ });
441
+ } finally {
442
+ J(!1);
443
+ }
444
+ }
445
+ }, [
446
+ V,
447
+ W,
448
+ e,
449
+ E,
450
+ g,
451
+ f,
452
+ a,
453
+ F,
454
+ j
455
+ ]), X = A("news"), Z = p((e) => {
456
+ let t = e.currentTarget;
457
+ t.scrollHeight - t.clientHeight - t.scrollTop < U && Y();
458
+ }, [Y]), Q = z.length > 0 || g, $ = !e && !E && P && B.length === 0;
459
+ return M && B.length === 0 ? /* @__PURE__ */ y("div", {
460
+ className: "flex flex-1 flex-col items-center justify-center gap-3 px-6 py-12 text-center",
461
+ children: /* @__PURE__ */ y("p", {
462
+ className: "text-sm text-wx-fg-muted",
463
+ children: n("emptyTitle")
464
+ })
465
+ }) : /* @__PURE__ */ b(s, {
466
+ className: "flex-1",
467
+ viewportRef: X,
468
+ onScroll: Z,
469
+ children: [Q && /* @__PURE__ */ y(O, {
470
+ value: c,
471
+ onChange: u,
472
+ placeholder: n("searchPlaceholder")
473
+ }), /* @__PURE__ */ y("div", {
474
+ className: "flex flex-col gap-3 px-4 pt-4 pb-6",
475
+ children: $ ? Array.from({ length: 3 }).map((e, t) => /* @__PURE__ */ b("div", {
476
+ className: "overflow-hidden rounded-wx-lg bg-wx-bg-elevated",
477
+ children: [/* @__PURE__ */ y(T, { className: "aspect-[16/10] w-full rounded-none" }), /* @__PURE__ */ b("div", {
478
+ className: "space-y-2 px-5 py-4",
479
+ children: [
480
+ /* @__PURE__ */ y(T, { className: "h-3 w-3/4" }),
481
+ /* @__PURE__ */ y(T, { className: "h-3 w-1/2" }),
482
+ /* @__PURE__ */ y(T, { className: "mt-1 h-2 w-1/3" })
483
+ ]
484
+ })]
485
+ }, t)) : B.length === 0 ? /* @__PURE__ */ b("div", {
486
+ className: "flex flex-1 flex-col items-center justify-center gap-3 px-6 py-12 text-center",
487
+ children: [
488
+ /* @__PURE__ */ y("div", {
489
+ className: "flex h-14 w-14 items-center justify-center rounded-full bg-wx-bg-elevated text-wx-fg-muted",
490
+ children: /* @__PURE__ */ y(w, {
491
+ icon: C,
492
+ size: 28
493
+ })
494
+ }),
495
+ /* @__PURE__ */ y("p", {
496
+ className: "text-base font-semibold text-wx-fg",
497
+ children: n(g ? "noResults" : "emptyTitle")
498
+ }),
499
+ !g && /* @__PURE__ */ y("p", {
500
+ className: "text-sm text-wx-fg-muted",
501
+ children: n("emptyBody")
502
+ })
503
+ ]
504
+ }) : /* @__PURE__ */ b(v, { children: [B.map((e, n) => /* @__PURE__ */ y(q, {
505
+ item: e,
506
+ locale: a,
507
+ delay: n < H ? n * .04 : 0,
508
+ onClick: () => t(e.id)
509
+ }, e.id)), W && /* @__PURE__ */ y("div", {
510
+ className: "flex justify-center py-3",
511
+ children: /* @__PURE__ */ y(T, { className: "h-3 w-24" })
512
+ })] })
513
+ })]
514
+ });
515
+ }
516
+ function G(e, t = 0) {
517
+ let n = e.coverImageUrl?.url, r = e.externalCoverImageUrl, i = typeof n == "string" ? n : typeof r == "string" ? r : null, a = (e) => Array.isArray(e) ? e.map((e) => {
518
+ if (!e || typeof e != "object") return null;
519
+ let t = e.slug, n = e.label;
520
+ return typeof t != "string" || typeof n != "string" ? null : {
521
+ slug: t,
522
+ label: n
523
+ };
524
+ }).filter((e) => !!e) : void 0, o = a(e.tags), s = a(e.categories), c = Array.isArray(e.authors) ? e.authors.map((e) => {
525
+ if (!e || typeof e != "object") return null;
526
+ let t = e.name;
527
+ if (typeof t != "string") return null;
528
+ let n = e._id, r = e.photo?.url;
529
+ return {
530
+ _id: String(n ?? t),
531
+ name: t,
532
+ photo: { url: typeof r == "string" ? r : "" }
533
+ };
534
+ }).filter((e) => !!e) : void 0;
535
+ return {
536
+ id: String(e._id ?? e.id ?? `news-${t}`),
537
+ title: typeof e.title == "string" ? e.title : "",
538
+ excerpt: typeof e.excerpt == "string" ? e.excerpt : "",
539
+ publishedAt: typeof e.publishedAt == "string" ? e.publishedAt : (/* @__PURE__ */ new Date()).toISOString(),
540
+ coverGradient: ["#1e1f21", "#121314"],
541
+ ...i ? { coverImageUrl: i } : {},
542
+ ...typeof e.upstreamUpdatedAt == "string" ? { upstreamUpdatedAt: e.upstreamUpdatedAt } : {},
543
+ ...o && o.length > 0 ? { tags: o } : {},
544
+ ...s && s.length > 0 ? { categories: s } : {},
545
+ ...c && c.length > 0 ? { authors: c } : {},
546
+ reactionCounts: e.reactionCounts ?? null
547
+ };
548
+ }
549
+ function K(e, t) {
550
+ let [n, r] = _(e);
551
+ return m(() => {
552
+ let n = setTimeout(() => r(e), t);
553
+ return () => clearTimeout(n);
554
+ }, [e, t]), n;
555
+ }
556
+ function q({ item: e, locale: n, delay: r, onClick: i }) {
557
+ let a = l("news"), s = e.categories ?? (e.category ? [e.category] : []), d = E(e.authors);
558
+ return /* @__PURE__ */ b(t.button, {
559
+ type: "button",
560
+ onClick: i,
561
+ initial: {
562
+ opacity: 0,
563
+ y: 8
564
+ },
565
+ animate: {
566
+ opacity: 1,
567
+ y: 0
568
+ },
569
+ whileHover: { y: -2 },
570
+ whileTap: { scale: .985 },
571
+ transition: {
572
+ duration: .2,
573
+ delay: r
574
+ },
575
+ className: u("block w-full shrink-0 overflow-hidden rounded-wx-lg bg-wx-bg-elevated text-left", "transition-colors hover:bg-wx-bg-elevated-2", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary focus-visible:ring-offset-2 focus-visible:ring-offset-wx-bg"),
576
+ children: [/* @__PURE__ */ y("div", {
577
+ className: "aspect-[16/10] w-full bg-cover bg-center",
578
+ style: e.coverImageUrl ? { backgroundImage: `url(${e.coverImageUrl})` } : { background: `linear-gradient(135deg, ${e.coverGradient[0]}, ${e.coverGradient[1]})` },
579
+ "aria-hidden": "true"
580
+ }), /* @__PURE__ */ b("div", {
581
+ className: "px-5 py-4",
582
+ children: [
583
+ (s.length > 0 || d != null) && /* @__PURE__ */ b("div", {
584
+ className: "mb-1.5 flex items-center justify-between gap-2",
585
+ children: [/* @__PURE__ */ y("div", {
586
+ className: "flex min-w-0 flex-wrap gap-1.5",
587
+ children: s.slice(0, 2).map((e) => /* @__PURE__ */ y("span", {
588
+ className: "text-[10px] font-semibold uppercase tracking-wide text-wx-primary",
589
+ children: e.label
590
+ }, e.slug))
591
+ }), /* @__PURE__ */ y(D, {
592
+ authors: d,
593
+ className: "shrink-0"
594
+ })]
595
+ }),
596
+ /* @__PURE__ */ y(o, {
597
+ className: "text-sm",
598
+ children: e.title
599
+ }),
600
+ e.excerpt && /* @__PURE__ */ y(c, {
601
+ className: "mt-1 text-xs",
602
+ children: e.excerpt
603
+ }),
604
+ /* @__PURE__ */ b("p", {
605
+ className: "mt-2 flex items-center gap-2 text-xs text-wx-fg-subtle",
606
+ children: [/* @__PURE__ */ y("span", { children: new Date(e.publishedAt).toLocaleDateString(n, {
607
+ month: "short",
608
+ day: "numeric",
609
+ year: "numeric"
610
+ }) }), B(e) && e.upstreamUpdatedAt && /* @__PURE__ */ y("span", {
611
+ className: "rounded-full bg-wx-bg-elevated px-1.5 py-0.5 text-[10px] font-medium text-wx-fg-muted",
612
+ title: new Date(e.upstreamUpdatedAt).toLocaleString(n),
613
+ children: a("editedAt", { when: V(e.upstreamUpdatedAt) })
614
+ })]
615
+ }),
616
+ e.tags && e.tags.length > 0 && /* @__PURE__ */ y("div", {
617
+ className: "mt-2.5 flex flex-wrap gap-1",
618
+ children: e.tags.slice(0, 4).map((e) => /* @__PURE__ */ y("span", {
619
+ className: "rounded-full bg-wx-bg-elevated px-2 py-0.5 text-[10px] font-medium text-wx-fg-muted",
620
+ children: e.label
621
+ }, e.slug))
622
+ })
623
+ ]
624
+ })]
625
+ });
626
+ }
627
+ //#endregion
628
+ export { F as a, A as c, E as d, T as f, S as h, N as i, O as l, C as m, V as n, L as o, w as p, B as r, z as s, W as t, D as u };
629
+
630
+ //# sourceMappingURL=widget-react-DwL_rsx_.js.map