@wexio/messenger-widget-react 1.7.5 → 1.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/widget-react-BI1zRae2.js +2 -0
- package/dist/{widget-react-CtHBMV7Z.js → widget-react-BbMhq_D0.js} +21 -20
- package/dist/widget-react-C6zJ0C4y.js +2 -0
- package/dist/{widget-react-B-NKlxTt.js → widget-react-Dul9xHaL.js} +10 -10
- package/dist/widget-react-PNvF_UGi.js +140 -0
- package/dist/widget-react-i3rT0ift.js +2 -0
- package/dist/widget-react.d.ts +18 -1
- package/dist/widget-react.js +30 -30
- package/package.json +1 -1
- package/dist/widget-react-BflWAq27.js +0 -2
- package/dist/widget-react-CfpEYz7V.js +0 -140
- package/dist/widget-react-DGksrvCr.js +0 -2
- package/dist/widget-react-Yd3uIKgg.js +0 -2
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){setTimeout(e,0)},emit:function(){return!1}});import"react";import"react-dom";import"react/jsx-runtime";import"react-dom/client";import{b as e,n as t}from"./widget-react-DIvxQOfe.js";import{$ as n,D as r,Dt as i,O as ee,Pt as a,T as te,Y as ne,c as re,d as o,l as s,m as c,p as l,u,x as d}from"./widget-react-CtHBMV7Z.js";import{i as ie}from"./widget-react-_QsYqFeh.js";import{o as ae,p as oe,s as se,t as ce}from"./widget-react-B-NKlxTt.js";import{t as le}from"./widget-react-BxEMz2N0.js";import{a as f,i as p,n as ue,o as m,r as h,s as g,t as _}from"./widget-react-DGksrvCr.js";import{useEffect as v,useMemo as y,useRef as b,useState as x}from"react";import{jsx as S,jsxs as C}from"react/jsx-runtime";var w=5;function de(e,t,n=w){let r=e.find(e=>e.slug===t),i=new Set((r?.tags??[]).map(e=>e.slug));return e.filter(e=>e.slug!==t).map(e=>({a:e,score:(r&&e.categoryId===r.categoryId?2:0)+e.tags.filter(e=>i.has(e.slug)).length})).sort((e,t)=>t.score-e.score||t.a.publishedAt.localeCompare(e.a.publishedAt)).slice(0,n).map(({a:e})=>({_id:e.id,title:e.title,slug:e.slug,excerpt:e.excerpt||null}))}function fe(e){let t=e=>Array.isArray(e)?e:[];return{id:String(e._id??``),title:typeof e.title==`string`?e.title:``,excerpt:typeof e.excerpt==`string`?e.excerpt:``,content:typeof e.content==`string`?e.content:``,contentFormat:e.contentFormat===f.HTML?f.HTML:f.MARKDOWN,authors:t(e.authors).filter(e=>!!e&&typeof e==`object`).map(e=>({_id:String(e._id??``),name:typeof e.name==`string`?e.name:null,photo:e.photo})),tags:t(e.tags).filter(e=>!!e&&typeof e==`object`).map(e=>({_id:String(e._id??``),slug:typeof e.slug==`string`?e.slug:``,label:typeof e.label==`string`?e.label:``}))}}function T({slug:t,locale:w,isDummy:T,onHandoff:D,onOpenArticle:O,onOpenTranslation:k,onTitleResolved:A}){let j=e(`help`),M=r(),N=u(),P=ne(),{config:F}=d(),I=F.messenger?.showRelatedHelpArticles??!0,L=F.messenger?.showReactionCounts??!0,R=le(),[z,pe]=x(w),B=ee(z,M),V=y(()=>{if(T)return null;let e=P.previewData?.helpArticles;return Array.isArray(e)?e.find(e=>e&&typeof e==`object`&&e.slug===t)??null:null},[P.previewData,T,t]),H=!!V,{data:U,loading:me}=se({variables:{args:{slug:t,locale:w}},skip:T||H}),W=a(),G=W.publicKey,K=s(G&&!T&&!H?n.article(G,t,w):null,U),[q]=ae(),{trackLinkClick:J}=re(),Y=b(null),X=y(()=>T?i(B).find(e=>e.slug===t):null,[T,t,B]),Z=T?X?{id:X.id,title:X.title,excerpt:X.excerpt,content:X.contentMarkdown,contentFormat:f.MARKDOWN,authors:X.authors,tags:X.tags,reactionCounts:null,locale:z,translations:[]}:null:H&&V?{...fe(V),reactionCounts:V.reactionCounts??null,locale:w,translations:[]}:K?.visitorHelpArticle?{id:K.visitorHelpArticle._id,title:K.visitorHelpArticle.title,excerpt:K.visitorHelpArticle.excerpt??``,content:K.visitorHelpArticle.content,contentFormat:K.visitorHelpArticle.contentFormat,authors:K.visitorHelpArticle.authors,tags:K.visitorHelpArticle.tags,reactionCounts:K.visitorHelpArticle.reactionCounts??null,locale:K.visitorHelpArticle.locale,translations:K.visitorHelpArticle.translations}:null,{data:he}=oe({variables:{articleId:Z?.id??``,limit:5,locale:w},skip:T||H||!Z?.id||!I}),ge=y(()=>{if(!H||!Z?.id)return[];let e=(P.previewData?.helpArticles??[]).filter(e=>!!e&&typeof e==`object`),t=new Set((Z.tags??[]).map(e=>typeof e==`object`&&e&&`slug`in e?String(e.slug):null).filter(e=>!!e)),n=(()=>{let e=V;if(!e)return null;let t=e.folderId;if(typeof t==`string`)return t;let n=e.folder;if(n&&typeof n==`object`&&`_id`in n){let e=n._id;return typeof e==`string`?e:null}return null})();return e.filter(e=>String(e._id??``)!==Z.id).map(e=>{let r=typeof e.folderId==`string`?e.folderId:e.folder&&typeof e.folder==`object`&&`_id`in e.folder?String(e.folder._id??``):null,i=Array.isArray(e.tags)?e.tags.map(e=>typeof e==`object`&&e&&`slug`in e?String(e.slug):null).filter(e=>!!e):[];return{raw:e,score:(n&&r===n?2:0)+i.filter(e=>t.has(e)).length}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score).slice(0,5).map(({raw:e})=>({_id:String(e._id??``),title:typeof e.title==`string`?e.title:``,slug:typeof e.slug==`string`?e.slug:``,excerpt:typeof e.excerpt==`string`?e.excerpt:null}))},[H,Z,V,P.previewData]),_e=y(()=>T?de(i(B),t):[],[T,B,t]),Q=T?_e:H?ge:he?.visitorHelpRelated??[],ve=T||H?null:U?.visitorHelpArticle?.viewerReaction??null,ye=!T&&!H&&U?.visitorHelpArticle?[U.visitorHelpArticle._id,...(U.visitorHelpArticle.translations??[]).map(e=>e._id)]:Z?.id?[Z.id]:[];v(()=>{T||!Z?.id||!W.token||q({variables:{articleId:Z.id}}).catch(()=>{})},[Z?.id,T,q,W]),v(()=>{T||H||!Z?.id||Y.current!==Z.id&&(Y.current=Z.id,J({url:`/help/${t}`,targetType:`HELP_ARTICLE`,targetRefId:Z.id}))},[Z?.id,T,H,t,J]),p(Z?.title,A);let be=()=>D();if(!me&&!Z)return S(`div`,{className:`flex flex-1 flex-col items-center justify-center px-6 py-12`,children:S(l,{children:S(c,{className:`py-8 text-center`,children:S(`p`,{className:`text-sm font-semibold text-wx-fg`,children:j(`articleNotFound`)})})})});let xe=w.split(`-`)[0].toLowerCase(),$=Z?Z.locale.split(`-`)[0].toLowerCase():null;return!T&&!H&&!F.contentLocaleFallback&&$!==null&&$!==xe?S(`div`,{className:`flex flex-1 flex-col items-center justify-center px-6 py-12`,children:S(l,{children:S(c,{className:`py-8 text-center`,children:S(`p`,{className:`text-sm font-semibold text-wx-fg`,children:j(`articleNotTranslated`)})})})}):Z?S(o,{followDirection:!0,className:`flex-1`,viewportRef:N,children:C(`div`,{className:`flex flex-col px-5 pt-5 pb-12 [overflow-wrap:anywhere]`,children:[S(`h2`,{className:`text-xl leading-tight font-bold text-wx-fg`,children:Z.title}),Z.authors.length>0&&C(`p`,{className:`mt-2 flex items-center gap-2 text-xs text-wx-fg-muted`,children:[S(`span`,{className:`flex -space-x-1.5`,children:Z.authors.slice(0,3).map(e=>S(`span`,{className:`h-5 w-5 overflow-hidden rounded-full bg-wx-bg-elevated ring-1 ring-wx-bg`,"aria-hidden":`true`,children:e.photo?.url?S(`img`,{src:e.photo.url,alt:``,className:`h-full w-full object-cover`}):S(`span`,{className:`flex h-full w-full items-center justify-center text-[10px] font-semibold uppercase text-wx-fg-muted`,children:(e.name??`?`).charAt(0)})},e._id))}),S(`span`,{children:j(`writtenBy`,{names:Z.authors.map(e=>e.name??``).filter(Boolean).join(`, `)})})]}),Z.tags.length>0&&S(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:Z.tags.map(e=>S(`span`,{className:`rounded-full bg-wx-bg-elevated px-2 py-0.5 text-[11px] font-medium text-wx-fg-muted`,children:e.label},e._id))}),Z.excerpt&&S(`p`,{className:`mt-2 mb-5 text-sm text-wx-fg-muted`,children:Z.excerpt}),S(h,{content:Z.content,isHtml:Z.contentFormat===f.HTML||g(Z.content),markdownMarginClass:`mt-3`}),C(ce,{type:`button`,variant:`solid`,size:`lg`,className:`mt-6 w-full shrink-0 min-h-12`,onClick:be,...R.parentHandlers,children:[S(ie,{ref:R.iconRef,size:16}),S(`span`,{children:j(`unresolvedCta`)})]}),Z.id&&S(_,{surface:m.HELP,itemId:Z.id,reactionCounts:Z.reactionCounts,viewerReaction:ve,groupItemIds:ye,isDummy:T,showCounts:L,className:`mt-4`}),S(ue,{currentLocale:T?z:Z.locale,locales:T?[...te]:Z.translations.map(e=>e.locale),allowedLocales:T?void 0:F.supportedLocales,onSelect:T?e=>pe(e):e=>{let t=Z.translations.find(t=>t.locale===e);t&&k?.(t.slug,t.locale)},className:`mt-6`}),I&&Q.length>0&&C(`section`,{className:`mt-6`,children:[S(`p`,{className:`mb-2 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase`,children:j(`relatedTitle`)}),S(`ul`,{className:`flex flex-col gap-1.5`,children:Q.map(e=>S(`li`,{children:C(`button`,{type:`button`,onClick:()=>O?.(e.slug),className:`flex w-full flex-col items-start gap-0.5 rounded-wx-lg bg-wx-bg-elevated px-3 py-2 text-start transition-colors hover:bg-wx-bg-elevated/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary`,children:[S(`span`,{className:`block truncate text-sm font-medium text-wx-fg`,children:e.title}),e.excerpt&&S(`span`,{className:`line-clamp-1 block text-xs text-wx-fg-muted`,children:e.excerpt})]})},e._id))})]})]})}):S(E,{})}function E(){return S(o,{followDirection:!0,className:`flex-1`,viewportRef:u(),children:C(`div`,{className:`flex flex-col px-5 pt-5 pb-12`,"aria-busy":`true`,"aria-live":`polite`,children:[C(`div`,{className:`animate-pulse space-y-2.5`,children:[S(`div`,{className:`h-5 w-3/4 rounded-md bg-wx-bg-elevated`}),S(`div`,{className:`h-5 w-1/2 rounded-md bg-wx-bg-elevated`})]}),C(`div`,{className:`mt-4 flex items-center gap-2 animate-pulse`,children:[S(`div`,{className:`h-5 w-5 rounded-full bg-wx-bg-elevated`}),S(`div`,{className:`h-3 w-32 rounded-md bg-wx-bg-elevated`})]}),S(`div`,{className:`mt-6 space-y-2.5 animate-pulse`,children:[`w-full`,`w-11/12`,`w-10/12`,`w-full`,`w-9/12`,`w-full`,`w-11/12`,`w-7/12`].map((e,n)=>S(`div`,{className:t(`h-3 rounded-md bg-wx-bg-elevated`,e)},n))})]})})}export{T as HelpArticleView};
|
|
2
|
-
//# sourceMappingURL=widget-react-BflWAq27.js.map
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){setTimeout(e,0)},emit:function(){return!1}});import"react";import"react-dom";import"react/jsx-runtime";import"react-dom/client";import{S as e,b as t,i as n,n as r,t as i}from"./widget-react-DIvxQOfe.js";import{$ as a,Ct as o,D as s,E as c,Pt as l,Y as ee,d as u,en as d,g as f,h as p,l as m,tn as h}from"./widget-react-CtHBMV7Z.js";import{c as g}from"./widget-react-_QsYqFeh.js";import{useCallback as _,useEffect as v,useMemo as y,useRef as b,useState as x}from"react";import{Fragment as te,jsx as S,jsxs as C}from"react/jsx-runtime";var w={},T=h`
|
|
2
|
-
query VisitorNewsList($args: VisitorNewsListArgs) {
|
|
3
|
-
visitorNewsList(args: $args) {
|
|
4
|
-
items {
|
|
5
|
-
_id
|
|
6
|
-
title
|
|
7
|
-
slug
|
|
8
|
-
excerpt
|
|
9
|
-
publishedAt
|
|
10
|
-
upstreamUpdatedAt
|
|
11
|
-
reactionCounts
|
|
12
|
-
coverImageUrl {
|
|
13
|
-
_id
|
|
14
|
-
url
|
|
15
|
-
}
|
|
16
|
-
externalCoverImageUrl
|
|
17
|
-
authors {
|
|
18
|
-
_id
|
|
19
|
-
name
|
|
20
|
-
photo {
|
|
21
|
-
_id
|
|
22
|
-
url
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
categories {
|
|
26
|
-
_id
|
|
27
|
-
slug
|
|
28
|
-
label
|
|
29
|
-
}
|
|
30
|
-
tags {
|
|
31
|
-
_id
|
|
32
|
-
slug
|
|
33
|
-
label
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
meta {
|
|
37
|
-
totalCount
|
|
38
|
-
currentPage
|
|
39
|
-
totalPages
|
|
40
|
-
hasNextPage
|
|
41
|
-
hasPreviousPage
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
`;function ne(e){return d(T,{...w,...e})}var E=h`
|
|
46
|
-
query VisitorNewsPostCard($args: VisitorNewsPostArgs!) {
|
|
47
|
-
visitorNewsPost(args: $args) {
|
|
48
|
-
_id
|
|
49
|
-
title
|
|
50
|
-
excerpt
|
|
51
|
-
coverImageUrl {
|
|
52
|
-
_id
|
|
53
|
-
url
|
|
54
|
-
}
|
|
55
|
-
externalCoverImageUrl
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
`;function D(e){return d(E,{...w,...e})}var O=h`
|
|
59
|
-
query VisitorNewsPost($args: VisitorNewsPostArgs!) {
|
|
60
|
-
visitorNewsPost(args: $args) {
|
|
61
|
-
_id
|
|
62
|
-
title
|
|
63
|
-
slug
|
|
64
|
-
excerpt
|
|
65
|
-
contentMarkdown
|
|
66
|
-
bodyFormat
|
|
67
|
-
locale
|
|
68
|
-
publishedAt
|
|
69
|
-
upstreamUpdatedAt
|
|
70
|
-
viewCount
|
|
71
|
-
reactionCounts
|
|
72
|
-
viewerReaction
|
|
73
|
-
sourceUrl
|
|
74
|
-
coverImageUrl {
|
|
75
|
-
_id
|
|
76
|
-
url
|
|
77
|
-
}
|
|
78
|
-
externalCoverImageUrl
|
|
79
|
-
source {
|
|
80
|
-
_id
|
|
81
|
-
name
|
|
82
|
-
type
|
|
83
|
-
}
|
|
84
|
-
authors {
|
|
85
|
-
_id
|
|
86
|
-
name
|
|
87
|
-
photo {
|
|
88
|
-
_id
|
|
89
|
-
url
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
categories {
|
|
93
|
-
_id
|
|
94
|
-
slug
|
|
95
|
-
label
|
|
96
|
-
}
|
|
97
|
-
tags {
|
|
98
|
-
_id
|
|
99
|
-
slug
|
|
100
|
-
label
|
|
101
|
-
}
|
|
102
|
-
translations {
|
|
103
|
-
_id
|
|
104
|
-
locale
|
|
105
|
-
slug
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
`;function k(e){return d(O,{...w,...e})}var A=h`
|
|
110
|
-
query VisitorNewsRelated($postId: ID!, $limit: Int, $locale: String) {
|
|
111
|
-
visitorNewsRelated(postId: $postId, limit: $limit, locale: $locale) {
|
|
112
|
-
_id
|
|
113
|
-
title
|
|
114
|
-
slug
|
|
115
|
-
excerpt
|
|
116
|
-
publishedAt
|
|
117
|
-
coverImageUrl {
|
|
118
|
-
_id
|
|
119
|
-
url
|
|
120
|
-
}
|
|
121
|
-
externalCoverImageUrl
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
`;function j(e){return d(A,{...w,...e})}h`
|
|
125
|
-
mutation RecordVisitorNewsView($postId: String!) {
|
|
126
|
-
recordVisitorNewsView(postId: $postId) {
|
|
127
|
-
ok
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
`;var M=h`
|
|
131
|
-
query VisitorNewsListSlim($args: VisitorNewsListArgs) {
|
|
132
|
-
visitorNewsList(args: $args) {
|
|
133
|
-
items {
|
|
134
|
-
_id
|
|
135
|
-
title
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
`;function N(e){return d(M,{...w,...e})}var P=i(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),F=i(`megaphone`,[[`path`,{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`,key:`q8bfy3`}],[`path`,{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`,key:`1853fq`}],[`path`,{d:`M8 6v8`,key:`15ugcq`}]]);function I({icon:e,size:t=20,strokeWidth:n=2,className:i,...a}){return S(e,{width:t,height:t,strokeWidth:n,className:r(`shrink-0`,i),...a})}function L({className:e,...t}){return S(`div`,{"data-slot":`skeleton`,className:r(`animate-pulse rounded-wx-sm bg-wx-bg-elevated`,e),...t})}function R(e){if(!Array.isArray(e))return;let t=e.map(e=>{if(!e||typeof e!=`object`)return null;let t=e.name;if(typeof t!=`string`)return null;let n=e._id??e.id,r=e.photo?.url;return{id:String(n??t),name:t,photoUrl:typeof r==`string`?r:null}}).filter(e=>!!e);return t.length>0?t:void 0}function z({authors:e,max:t=3,className:n}){return!e||e.length===0?null:S(`span`,{className:`flex items-center -space-x-1.5 ${n??``}`,children:e.slice(0,t).map(e=>e.photoUrl?S(`img`,{src:e.photoUrl,alt:e.name,title:e.name,className:`h-5 w-5 rounded-full border border-wx-bg object-cover`},e.id):S(`span`,{title:e.name,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`,children:e.name.charAt(0).toUpperCase()},e.id))})}function B({value:e,onChange:t,placeholder:n,className:i}){return C(`div`,{className:r(`sticky top-0 z-10 flex items-center gap-2.5 border-wx-border border-b bg-wx-bg px-4`,i),children:[S(g,{size:16,className:`shrink-0 text-wx-fg-muted`}),S(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:n,className:r(`block w-full min-w-0 flex-1 border-0 bg-transparent py-3 text-sm text-wx-fg`,`placeholder:text-wx-fg-muted focus:outline-none focus:ring-0`,`[&::-webkit-search-cancel-button]:appearance-none`)})]})}var V=new Map;function H(e){let t=b(null);return v(()=>{let n=t.current;if(!n)return;let r=V.get(e)??0,i=!1,a=performance.now(),o=()=>{if(i||!t.current)return;let e=t.current;if(e.scrollHeight-e.clientHeight>=r){e.scrollTop=r;return}if(performance.now()-a>500){e.scrollTop=r;return}requestAnimationFrame(o)};requestAnimationFrame(o);let s=()=>{V.set(e,n.scrollTop)};return n.addEventListener(`scroll`,s,{passive:!0}),()=>{i=!0,n.removeEventListener(`scroll`,s)}},[e]),t}function U(e){if(!e.upstreamUpdatedAt)return!1;let t=Date.parse(e.upstreamUpdatedAt),n=Date.parse(e.publishedAt);return Number.isNaN(t)||Number.isNaN(n)?!1:t>n+6e4}function W(e){let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Date.now()-t,r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:new Date(t).toLocaleDateString()}var G=10,K=240;function q({isDummy:n,onOpenArticle:r}){let i=t(`news`),d=s(),f=e(),p=ee(),[h,g]=x(``),b=Y(h,300),w=b.length>=2,T=p.previewData?.newsPosts,E=!n&&Array.isArray(T)&&T.length>0,[D,O]=x(G),{data:k,error:A,loading:j,fetchMore:M}=ne({variables:{args:{locale:f,limit:G,offset:0,...w?{query:b}:{}}},skip:n||E,notifyOnNetworkStatusChange:!0});v(()=>{O(G)},[b,E]);let N=l().publicKey,P=m(N&&!n&&!w?a.news(N,f):null,k),R=y(()=>(P?.visitorNewsList?.items??[]).filter(e=>!!e).map(J),[P]),z=E?(T??[]).filter(e=>!!e&&typeof e==`object`).map(J):[],V=_(e=>e.title.toLowerCase().includes(b.toLowerCase())||e.excerpt.toLowerCase().includes(b.toLowerCase()),[b]),U=n?w?o(d).filter(V):o(d):E?w?z.filter(V):z:R,W=E||n?U.slice(0,D):U,q=y(()=>n||E?D<U.length:P?.visitorNewsList?.meta?.hasNextPage??!1,[n,E,D,U.length,P]),[Z,Q]=x(!1),$=_(async()=>{if(!(!q||Z)){if(n||E){O(e=>e+G);return}Q(!0);try{await M({variables:{args:{locale:f,limit:G,offset:k?.visitorNewsList?.items?.length??0,...w?{query:b}:{}}},updateQuery:(e,{fetchMoreResult:t})=>{if(!t)return e;let n=new Set,r=[];for(let i of[...e.visitorNewsList?.items??[],...t.visitorNewsList?.items??[]])i&&!n.has(i._id)&&(n.add(i._id),r.push(i));return{...e,visitorNewsList:{...t.visitorNewsList,items:r}}}})}catch(e){console.warn(`[wexio] news load-more failed:`,e)}finally{Q(!1)}}},[q,Z,n,E,w,b,f,M,k]),re=H(`news`),ie=_(e=>{let t=e.currentTarget;t.scrollHeight-t.clientHeight-t.scrollTop<K&&$()},[$]),ae=U.length>0||w,oe=n&&!c(d)||!n&&!E&&j&&W.length===0;return A&&W.length===0?S(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 px-6 py-12 text-center`,children:S(`p`,{className:`text-sm text-wx-fg-muted`,children:i(`emptyTitle`)})}):C(u,{followDirection:!0,className:`flex-1`,viewportRef:re,onScroll:ie,children:[ae&&S(B,{value:h,onChange:g,placeholder:i(`searchPlaceholder`)}),S(`div`,{className:`flex flex-col gap-3 px-4 pt-4 pb-6`,children:oe?Array.from({length:3}).map((e,t)=>C(`div`,{className:`overflow-hidden rounded-wx-lg bg-wx-bg-elevated`,children:[S(L,{className:`aspect-[16/10] w-full rounded-none`}),C(`div`,{className:`space-y-2 px-5 py-4`,children:[S(L,{className:`h-3 w-3/4`}),S(L,{className:`h-3 w-1/2`}),S(L,{className:`mt-1 h-2 w-1/3`})]})]},t)):W.length===0?C(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 px-6 py-12 text-center`,children:[S(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-wx-bg-elevated text-wx-fg-muted`,children:S(I,{icon:F,size:28})}),S(`p`,{className:`text-base font-semibold text-wx-fg`,children:i(w?`noResults`:`emptyTitle`)}),!w&&S(`p`,{className:`text-sm text-wx-fg-muted`,children:i(`emptyBody`)})]}):C(te,{children:[W.map((e,t)=>S(X,{item:e,locale:f,delay:t<G?t*.04:0,onClick:()=>r(e.id)},e.id)),Z&&S(`div`,{className:`flex justify-center py-3`,children:S(L,{className:`h-3 w-24`})})]})})]})}function J(e,t=0){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=>{if(!e||typeof e!=`object`)return null;let t=e.slug,n=e.label;return typeof t!=`string`||typeof n!=`string`?null:{slug:t,label:n}}).filter(e=>!!e):void 0,o=a(e.tags),s=a(e.categories),c=Array.isArray(e.authors)?e.authors.map(e=>{if(!e||typeof e!=`object`)return null;let t=e.name;if(typeof t!=`string`)return null;let n=e._id,r=e.photo?.url;return{_id:String(n??t),name:t,photo:{url:typeof r==`string`?r:``}}}).filter(e=>!!e):void 0;return{id:String(e._id??e.id??`news-${t}`),title:typeof e.title==`string`?e.title:``,excerpt:typeof e.excerpt==`string`?e.excerpt:``,publishedAt:typeof e.publishedAt==`string`?e.publishedAt:new Date().toISOString(),coverGradient:[`#1e1f21`,`#121314`],...i?{coverImageUrl:i}:{},...typeof e.upstreamUpdatedAt==`string`?{upstreamUpdatedAt:e.upstreamUpdatedAt}:{},...o&&o.length>0?{tags:o}:{},...s&&s.length>0?{categories:s}:{},...c&&c.length>0?{authors:c}:{},reactionCounts:e.reactionCounts??null}}function Y(e,t){let[n,r]=x(e);return v(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function X({item:e,locale:i,delay:a,onClick:o}){let s=t(`news`),c=e.categories??(e.category?[e.category]:[]),l=R(e.authors);return C(n.button,{type:`button`,onClick:o,initial:{opacity:0,y:8},animate:{opacity:1,y:0},whileHover:{y:-2},whileTap:{scale:.985},transition:{duration:.2,delay:a},className:r(`block w-full shrink-0 overflow-hidden rounded-wx-lg bg-wx-bg-elevated text-start [overflow-wrap:anywhere]`,`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`),children:[S(`div`,{className:`aspect-[16/10] w-full bg-cover bg-center`,style:e.coverImageUrl?{backgroundImage:`url(${e.coverImageUrl})`}:{background:`linear-gradient(135deg, ${e.coverGradient[0]}, ${e.coverGradient[1]})`},"aria-hidden":`true`}),C(`div`,{className:`px-5 py-4`,children:[(c.length>0||l!=null)&&C(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[S(`div`,{className:`flex min-w-0 flex-wrap gap-1.5`,children:c.slice(0,2).map(e=>S(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-wx-primary`,children:e.label},e.slug))}),S(z,{authors:l,className:`shrink-0`})]}),S(f,{className:`text-sm`,children:e.title}),e.excerpt&&S(p,{className:`mt-1 text-xs`,children:e.excerpt}),C(`p`,{className:`mt-2 flex items-center gap-2 text-xs text-wx-fg-subtle`,children:[S(`span`,{children:new Date(e.publishedAt).toLocaleDateString(i,{month:`short`,day:`numeric`,year:`numeric`})}),U(e)&&e.upstreamUpdatedAt&&S(`span`,{className:`rounded-full bg-wx-bg-elevated px-1.5 py-0.5 text-[10px] font-medium text-wx-fg-muted`,title:new Date(e.upstreamUpdatedAt).toLocaleString(i),children:s(`editedAt`,{when:W(e.upstreamUpdatedAt)})})]}),e.tags&&e.tags.length>0&&S(`div`,{className:`mt-2.5 flex flex-wrap gap-1`,children:e.tags.slice(0,4).map(e=>S(`span`,{className:`rounded-full bg-wx-bg-elevated px-2 py-0.5 text-[10px] font-medium text-wx-fg-muted`,children:e.label},e.slug))})]})]})}export{B as a,L as c,P as d,T as f,j as g,k as h,H as i,I as l,D as m,W as n,z as o,N as p,U as r,R as s,q as t,F as u};
|
|
140
|
-
//# sourceMappingURL=widget-react-CfpEYz7V.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){setTimeout(e,0)},emit:function(){return!1}});import"react";import"react-dom";import"react/jsx-runtime";import"react-dom/client";import{b as e,i as t,n}from"./widget-react-DIvxQOfe.js";import{Pt as r,Q as i,_ as a,a as o,b as s,i as c,n as l,nn as u,nt as d,rt as f,t as p,y as m}from"./widget-react-CtHBMV7Z.js";import{n as h}from"./widget-react-ChDwJoyJ.js";import{useCallback as g,useEffect as _,useMemo as v,useRef as y,useState as b}from"react";import{jsx as x,jsxs as S}from"react/jsx-runtime";function C(e){if(!e)return!1;let t=e.trimStart().slice(0,200);return/^<(?:[a-z!][^>]*|!--)/i.test(t)}var w=function(e){return e.HTML=`HTML`,e.MARKDOWN=`MARKDOWN`,e}({}),T=function(e){return e.HELP=`HELP`,e.NEWS=`NEWS`,e}({});function E(e,t){_(()=>{if(t)return e&&t(e),()=>t(null)},[e,t])}var D=`prose max-w-none text-sm leading-relaxed text-wx-fg [overflow-wrap:anywhere],[&_pre]:[overflow-wrap:normal],[&_p]:my-3 [&_strong]:font-semibold [&_em]:italic,[&_a]:text-wx-primary [&_a]:underline [&_a]:underline-offset-2,[&_a]:transition-opacity [&_a:hover]:opacity-70,[&_code]:rounded-[6px] [&_code]:bg-wx-bg-elevated [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em],[&_pre]:my-4 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:border [&_pre]:border-wx-border,[&_pre]:bg-[#0f1115] [&_pre]:text-zinc-100 [&_pre]:p-4 [&_pre]:text-[12.5px] [&_pre]:leading-relaxed,[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-zinc-100,[&_.hljs-keyword]:text-violet-300 [&_.hljs-built_in]:text-violet-300 [&_.hljs-type]:text-violet-300,[&_.hljs-string]:text-emerald-300,[&_.hljs-number]:text-amber-300 [&_.hljs-literal]:text-amber-300,[&_.hljs-comment]:text-zinc-500 [&_.hljs-comment]:italic,[&_.hljs-attr]:text-sky-300 [&_.hljs-attribute]:text-sky-300,[&_.hljs-title]:text-zinc-100 [&_.hljs-title]:font-medium,[&_.hljs-tag]:text-rose-300 [&_.hljs-name]:text-rose-300,[&_h1]:mt-6 [&_h1]:mb-3 [&_h1]:text-xl [&_h1]:font-semibold [&_h1]:tracking-tight,[&_h2]:mt-5 [&_h2]:mb-2 [&_h2]:text-base [&_h2]:font-semibold [&_h2]:tracking-tight,[&_h3]:mt-4 [&_h3]:mb-1.5 [&_h3]:text-sm [&_h3]:font-semibold,[&_h1]:scroll-mt-16 [&_h2]:scroll-mt-16 [&_h3]:scroll-mt-16,[&_ul]:my-3 [&_ul]:list-disc [&_ul]:pl-5 [&_ul]:marker:text-wx-fg-subtle,[&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_ol]:marker:text-wx-fg-subtle,[&_li]:my-1,[&_ul[data-type=taskList]]:list-none! [&_ul[data-type=taskList]]:pl-0!,[&_ul[data-type=taskList]_li]:my-1.5 [&_ul[data-type=taskList]_li]:flex! [&_ul[data-type=taskList]_li]:items-start [&_ul[data-type=taskList]_li]:gap-2 [&_ul[data-type=taskList]_li]:pl-0,[&_ul[data-type=taskList]_li]:marker:content-none,[&_ul[data-type=taskList]_li>label]:m-0 [&_ul[data-type=taskList]_li>label]:inline-flex [&_ul[data-type=taskList]_li>label]:h-5 [&_ul[data-type=taskList]_li>label]:items-center [&_ul[data-type=taskList]_li>label]:shrink-0 [&_ul[data-type=taskList]_li>label]:select-none,[&_ul[data-type=taskList]_li>label]:pointer-events-none [&_ul[data-type=taskList]_li>label]:cursor-default,[&_ul[data-type=taskList]_input]:accent-wx-primary [&_ul[data-type=taskList]_input]:h-3.5 [&_ul[data-type=taskList]_input]:w-3.5,[&_ul[data-type=taskList]_li>label>span]:hidden,[&_ul[data-type=taskList]_li>div]:min-w-0 [&_ul[data-type=taskList]_li>div]:flex-1,[&_ul[data-type=taskList]_li>div>p]:my-0! [&_ul[data-type=taskList]_li>div>p]:leading-snug,[&_ul[data-type=taskList]_li[data-checked=true]>div]:text-wx-fg-muted [&_ul[data-type=taskList]_li[data-checked=true]>div]:line-through,[&_blockquote]:my-4 [&_blockquote]:border-l-2 [&_blockquote]:border-wx-primary/40,[&_blockquote]:pl-3 [&_blockquote]:italic [&_blockquote]:text-wx-fg-muted,[&_hr]:my-6 [&_hr]:border-wx-border,[&_img]:my-3 [&_img]:mx-auto [&_img]:block [&_img]:max-w-full,[&_figure]:my-5 [&_figure]:flex [&_figure]:flex-col [&_figure]:items-center [&_figure]:text-center,[&_figure_img]:my-0,[&_figcaption]:mt-2 [&_figcaption]:text-xs [&_figcaption]:italic [&_figcaption]:text-wx-fg-muted,[&_table]:my-3 [&_table]:w-full [&_table]:table-fixed [&_table]:border-collapse [&_table]:text-xs,[&_table]:overflow-hidden [&_table]:rounded-lg [&_table]:border [&_table]:border-wx-border,[&_thead]:bg-wx-bg-elevated,[&_th]:px-2.5 [&_th]:py-1.5 [&_th]:text-left [&_th]:font-medium [&_th]:text-wx-fg,[&_th]:border-b [&_th]:border-wx-border,[&_th+th]:border-l [&_th+th]:border-wx-border,[&_td]:px-2.5 [&_td]:py-1.5 [&_td]:text-wx-fg [&_td]:align-top,[&_td+td]:border-l [&_td+td]:border-wx-border,[&_tbody_tr]:border-t [&_tbody_tr]:border-wx-border,[&_tbody_tr:nth-child(odd)]:bg-wx-bg-elevated/40,[&_th_p]:my-0 [&_td_p]:my-0 [&_th_p]:inline [&_td_p]:inline,[&_details]:my-2 [&_details]:overflow-hidden [&_details]:rounded-lg [&_details]:border [&_details]:border-wx-border [&_details]:bg-wx-bg-elevated/40,[&_details+details]:mt-2,[&_summary]:relative [&_summary]:cursor-pointer [&_summary]:list-none [&_summary]:px-4 [&_summary]:py-3,[&_summary]:pr-10 [&_summary]:text-sm [&_summary]:font-medium [&_summary]:text-wx-fg,[&_summary::-webkit-details-marker]:hidden [&_summary::marker]:hidden,[&_summary]:after:absolute [&_summary]:after:right-4 [&_summary]:after:top-1/2,[&_summary]:after:-translate-y-1/2 [&_summary]:after:text-wx-fg-subtle,[&_summary]:after:text-base [&_summary]:after:leading-none,[&_summary]:after:transition-transform [&_summary]:after:content-['\\203A'],[&_details[open]_summary]:after:rotate-90,[&_details[open]_summary]:border-b [&_details[open]_summary]:border-wx-border,[&_details]:[&>:not(summary)]:px-4 [&_details]:[&>:not(summary)]:py-3,[&_details]:[&>:not(summary):first-of-type]:pt-3`.split(`,`).join(` `);function O({content:e,isHtml:t,markdownMarginClass:n}){return t?x(l,{html:e,className:`mt-0 ${D}`}):x(`div`,{className:`${n} ${D}`,children:x(o,{remarkPlugins:[c],children:e})})}function k({currentLocale:r,locales:i,allowedLocales:o,onSelect:c,className:l}){let u=e(`languageSelector`),[d,f]=b(!1),g=y(null);_(()=>{if(!d)return;let e=e=>{g.current&&!e.composedPath().includes(g.current)&&f(!1)},t=e=>{e.key===`Escape`&&f(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[d]);let v=o&&o.length>0?new Set(o.map(e=>e.split(`-`)[0].toLowerCase())):null,C=Array.from(new Set(i.filter(Boolean))).filter(e=>!v||v.has(e.split(`-`)[0].toLowerCase()));if(C.length<=1)return null;let w=r.split(`-`)[0].toLowerCase(),T=C.includes(r);return S(`div`,{ref:g,className:n(`relative`,l),children:[x(`p`,{className:`mb-1.5 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase`,children:u(`title`)}),S(`button`,{type:`button`,onClick:()=>f(e=>!e),"aria-haspopup":`listbox`,"aria-expanded":d,"aria-label":u(`ariaLabel`),className:n(`flex w-full items-center gap-2 rounded-wx-sm border border-wx-border bg-wx-bg px-3 py-2`,`text-sm font-medium text-wx-fg transition-colors hover:bg-wx-bg-elevated`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary`),children:[x(a,{size:15,className:`shrink-0 text-wx-fg-muted`}),x(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:p(r)}),x(m,{size:15,className:n(`shrink-0 text-wx-fg-subtle transition-transform`,d&&`rotate-180`)})]}),x(h,{children:d&&x(t.ul,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.14},className:n(`absolute bottom-full left-0 z-20 mb-1 max-h-56 w-full overflow-auto`,`rounded-wx-sm border border-wx-border bg-wx-bg py-1 shadow-[0_12px_32px_rgba(0,0,0,0.16)]`),role:`listbox`,children:C.map(e=>{let t=T?e===r:e.split(`-`)[0].toLowerCase()===w;return x(`li`,{children:S(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>{c(e),f(!1)},className:n(`flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors`,t?`font-semibold text-wx-primary`:`text-wx-fg hover:bg-wx-bg-elevated`),children:[x(`span`,{className:`min-w-0 flex-1 truncate`,children:p(e)}),t&&x(s,{size:15,className:`shrink-0 text-wx-primary`})]})},e)})})})]})}var A=(e,t)=>`wexio:reaction:${e}:${t}`,j=[{slotIndex:0,emoji:`🎉`},{slotIndex:1,emoji:`❤️`},{slotIndex:2,emoji:`👍`}],M={[T.NEWS]:`NewsPost`,[T.HELP]:`HelpArticle`};function N({surface:a,itemId:o,reactionCounts:s,viewerReaction:c,groupItemIds:l,readonly:p=!1,showCounts:m=!0,isDummy:h=!1,className:y}){let C=e(`reactions`),w=u(),{data:T,loading:E}=f({variables:{surface:a},fetchPolicy:`cache-first`,skip:h}),[D,{loading:O}]=d(),k=i(),N=r().storage,P=v(()=>h?j:T?.visitorReactionSet?.slots??[],[h,T]),F=h?!0:T?.visitorReactionSet?.enabled??!0,I=A(a,o),[L,R]=b(null);_(()=>{if(!h){R(c??null);return}if(typeof window>`u`)return;let e=N.getItem(I);R(e===null?null:Number(e))},[h,I,N,c]);let[z,B]=b({}),V=e=>(s?.[String(e)]??0)+(h?z[e]??0:0),H=g((e,t)=>{let n=M[a],r=l?.length?l:[o];for(let i of r){let r=w.cache.identify({__typename:n,_id:i});r&&w.cache.modify({id:r,fields:{viewerReaction:()=>t,reactionCounts:n=>{let r={...n??{}};return t!==null&&(r[t]=(r[t]??0)+1),e!==null&&(r[e]=Math.max(0,(r[e]??0)-1)),r}}})}},[w,a,l,o]),U=async e=>{if(p||O||L===e)return;let t=L;if(R(e),h){typeof window<`u`&&N.setItem(I,String(e)),B(n=>({...n,[e]:(n[e]??0)+1,...t===null?{}:{[t]:(n[t]??0)-1}}));return}if(H(t,e),k){k.enqueue({op:`reaction`,semantics:`convergence`,convergenceKey:`reaction:${a}:${o}`,payload:{surface:a,itemId:o,slotIndex:e}});return}try{await D({variables:{input:{surface:a,itemId:o,slotIndex:e}}})}catch{H(e,t),R(t)}};return E||!F||P.length===0?null:x(`div`,{className:n(`flex flex-wrap items-center justify-center gap-2`,y),role:`group`,"aria-label":C(`ariaLabel`),children:P.map(e=>{let r=L===e.slotIndex,i=V(e.slotIndex);return S(t.button,{type:`button`,disabled:p||O,onClick:()=>void U(e.slotIndex),whileTap:{scale:.9},whileHover:{scale:1.06},transition:{type:`spring`,stiffness:400,damping:18},className:n(`flex items-center gap-1.5 rounded-full px-3 py-1.5 text-2xl leading-none transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary`,r?`bg-wx-primary/10 ring-1 ring-wx-primary/40`:`hover:bg-wx-bg-elevated`,p&&`cursor-default opacity-70`),"aria-pressed":r,"aria-label":C(`tapAria`,{emoji:e.emoji}),children:[x(`span`,{"aria-hidden":`true`,children:e.emoji}),m&&i>0&&x(`span`,{className:`text-xs font-medium text-wx-fg-muted`,children:i})]},e.slotIndex)})})}export{w as a,E as i,k as n,T as o,O as r,C as s,N as t};
|
|
2
|
-
//# sourceMappingURL=widget-react-DGksrvCr.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){setTimeout(e,0)},emit:function(){return!1}});import"react";import"react-dom";import"react/jsx-runtime";import"react-dom/client";import{S as e,b as t,n}from"./widget-react-DIvxQOfe.js";import{$ as r,Ct as i,D as a,O as o,Pt as s,T as c,Y as l,c as u,d,l as f,u as p,x as ee}from"./widget-react-CtHBMV7Z.js";import{d as te,g as ne,h as m,n as h,r as g}from"./widget-react-CfpEYz7V.js";import{i as _,n as v,o as y,r as b,s as x,t as S}from"./widget-react-DGksrvCr.js";import{useEffect as C,useMemo as w,useRef as re,useState as ie}from"react";import{jsx as T,jsxs as E}from"react/jsx-runtime";var D=3;function ae(e,t,n=D){let r=e.find(e=>e.id===t),i=new Set((r?.tags??[]).map(e=>e.slug)),a=r?.category?.slug;return e.filter(e=>e.id!==t).map(e=>({n:e,score:(a&&e.category?.slug===a?1:0)+(e.tags??[]).filter(e=>i.has(e.slug)).length})).sort((e,t)=>t.score-e.score||t.n.publishedAt.localeCompare(e.n.publishedAt)).slice(0,n).map(({n:e})=>({id:e.id,title:e.title,coverImageUrl:e.coverImageUrl}))}function oe(e){if(!e||typeof e!=`object`)return null;let t=e,n=String(t._id??t.id??``);if(!n)return null;let r=t.coverImageUrl?.url,i=t.externalCoverImageUrl,a=typeof r==`string`?r:typeof i==`string`?i:void 0,o=Array.isArray(t.tags)?t.tags.map(e=>{if(!e||typeof e!=`object`)return null;let t=e.slug,n=e.label;return typeof t!=`string`||typeof n!=`string`?null:{slug:t,label:n}}).filter(e=>!!e):void 0,s=e=>{if(!Array.isArray(e))return;let t=[];for(let n of e)if(n){if(typeof n==`string`)t.push(n);else if(typeof n==`object`){let e=n._id??n.id;typeof e==`string`&&t.push(e)}}return t.length>0?t:void 0},c=Array.isArray(t.translations)?t.translations.map(e=>{if(!e||typeof e!=`object`)return null;let t=String(e._id??e.id??``),n=e.locale;return!t||typeof n!=`string`?null:{id:t,locale:n}}).filter(e=>!!e):void 0,l=Array.isArray(t.authors)?t.authors.map(e=>{if(!e||typeof e!=`object`)return null;let t=e.name;if(typeof t!=`string`)return null;let n=e._id,r=e.photo?.url;return{_id:String(n??t),name:t,photo:{url:typeof r==`string`?r:``}}}).filter(e=>!!e):void 0;return{id:n,title:typeof t.title==`string`?t.title:``,excerpt:typeof t.excerpt==`string`?t.excerpt:``,contentMarkdown:typeof t.contentMarkdown==`string`?t.contentMarkdown:void 0,bodyFormat:typeof t.bodyFormat==`string`?t.bodyFormat:void 0,coverImageUrl:a,publishedAt:typeof t.publishedAt==`string`?t.publishedAt:new Date().toISOString(),upstreamUpdatedAt:typeof t.upstreamUpdatedAt==`string`?t.upstreamUpdatedAt:void 0,sourceUrl:typeof t.sourceUrl==`string`?t.sourceUrl:void 0,reactionCounts:t.reactionCounts??null,viewerReaction:typeof t.viewerReaction==`number`?t.viewerReaction:null,tags:o,authors:l,categoryIds:s(t.categories),tagIds:s(t.tags),locale:typeof t.locale==`string`?t.locale:void 0,translations:c}}function se({currentId:e,currentCategoryIds:n,currentTagIds:r,previewPostsById:i,visitorRelatedRaw:a,isDummy:o,demoItems:s,onOpen:c}){let l=t(`news`),u=(()=>{if(o)return s??[];if(Array.isArray(a)&&a.length>0)return a.filter(e=>!!e&&typeof e==`object`).map(e=>{let t=e.coverImageUrl?.url??e.externalCoverImageUrl;return{id:String(e._id??e.id??``),title:typeof e.title==`string`?e.title:``,coverImageUrl:typeof t==`string`?t:void 0}}).filter(e=>e.id&&e.title);if(i&&Object.keys(i).length>0&&(n.length>0||r.length>0)){let t=new Set(n),a=new Set(r),o=[];for(let[n,r]of Object.entries(i)){if(n===e||!r||typeof r!=`object`)continue;let i=r,s=Array.isArray(i.categories)?i.categories:[],c=Array.isArray(i.tags)?i.tags:[],l=e=>{let t=new Set;for(let n of e)if(n&&typeof n==`object`){let e=n._id??n.id;typeof e==`string`&&t.add(e)}return t},u=l(s),d=l(c),f=0;for(let e of u)t.has(e)&&f++;for(let e of d)a.has(e)&&f++;if(f===0)continue;let p=i.coverImageUrl?.url??i.externalCoverImageUrl;o.push({id:n,title:typeof i.title==`string`?i.title:``,coverImageUrl:typeof p==`string`?p:void 0,overlap:f,publishedAt:typeof i.publishedAt==`string`?i.publishedAt:``})}return o.sort((e,t)=>t.overlap===e.overlap?t.publishedAt.localeCompare(e.publishedAt):t.overlap-e.overlap),o.slice(0,5).map(({id:e,title:t,coverImageUrl:n})=>({id:e,title:t,coverImageUrl:n}))}return[]})();return u.length===0?null:E(`section`,{className:`mt-6`,children:[T(`p`,{className:`mb-2 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase`,children:l(`relatedTitle`)}),T(`ul`,{className:`flex flex-col gap-2`,children:u.map(e=>T(`li`,{children:E(`button`,{type:`button`,onClick:()=>c(e.id),className:`flex w-full items-center gap-3 rounded-wx-lg bg-wx-bg-elevated px-3 py-2 text-start transition-colors hover:bg-wx-bg-elevated/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary`,children:[T(`span`,{className:`aspect-square w-12 shrink-0 rounded-wx-sm bg-cover bg-center`,style:e.coverImageUrl?{backgroundImage:`url(${e.coverImageUrl})`}:{background:`linear-gradient(135deg, #1e1f21, #121314)`},"aria-hidden":`true`}),T(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-wx-fg`,children:e.title})]})},e.id))})]})}function O({id:D,isDummy:O,onOpenRelated:A,onTitleResolved:j}){let M=t(`news`),N=a(),P=p(),F=e(),I=l(),{config:L}=ee(),R=L.messenger?.showRelatedNews??!0,z=L.messenger?.showReactionCounts??!0,{trackLinkClick:B}=u(),V=re(null),H=e=>{A?.(e)},[U,W]=ie(F),G=o(U,N),K=O?null:I.previewData?.newsPostsById?.[D],q=!!K,{data:ce,loading:le}=m({variables:{args:{id:D,locale:F}},skip:O||q||!D}),J=s().publicKey,Y=f(J&&!O&&!q&&D?r.newsPost(J,D,F):null,ce),{data:ue}=ne({variables:{postId:D,limit:5,locale:F},skip:O||q||!D||!R}),X=O?i(G).find(e=>e.id===D)??null:null,de=w(()=>O?ae(i(G),D):void 0,[O,G,D]),Z=X?{id:X.id,title:X.title,excerpt:X.excerpt,contentMarkdown:X.contentMarkdown,bodyFormat:`markdown`,coverImageUrl:X.coverImageUrl,coverGradient:X.coverGradient,publishedAt:X.publishedAt,upstreamUpdatedAt:X.upstreamUpdatedAt,tags:X.tags,authors:X.authors,category:X.category,locale:U}:oe(q?K:Y?.visitorNewsPost);if(_(Z?.title,j),C(()=>{O||q||!Z?.id||V.current!==Z.id&&(V.current=Z.id,B({url:`/news/${Z.id}`,targetType:`NEWS_POST`,targetRefId:Z.id}))},[Z?.id,O,q,B]),!Z)return le?T(k,{}):T(`div`,{className:`flex flex-1 items-center justify-center px-6 py-12 text-center`,children:T(`p`,{className:`text-sm text-wx-fg-muted`,children:M(`articleNotFound`)})});let fe=F.split(`-`)[0].toLowerCase(),Q=Z.locale?Z.locale.split(`-`)[0].toLowerCase():null;if(!O&&!q&&!L.contentLocaleFallback&&Q!==null&&Q!==fe)return T(`div`,{className:`flex flex-1 items-center justify-center px-6 py-12 text-center`,children:T(`p`,{className:`text-sm text-wx-fg-muted`,children:M(`articleNotTranslated`)})});let $=Z.coverGradient??[`#1e1f21`,`#121314`];return T(d,{followDirection:!0,className:`flex-1`,viewportRef:P,children:E(`div`,{className:`flex flex-col`,children:[T(`div`,{className:n(`relative w-full`),style:{aspectRatio:`16 / 9`,background:Z.coverImageUrl?`url(${Z.coverImageUrl}) center/cover`:`linear-gradient(135deg, ${$[0]}, ${$[1]})`},"aria-hidden":`true`}),E(`div`,{className:`flex flex-col gap-3 px-5 pt-5 pb-12 [overflow-wrap:anywhere]`,children:[Z.category&&T(`p`,{className:`text-[11px] font-semibold tracking-[0.14em] text-wx-primary uppercase`,children:Z.category.label}),E(`p`,{className:`flex items-center gap-2 text-xs text-wx-fg-subtle`,children:[T(`span`,{children:new Date(Z.publishedAt).toLocaleDateString(F,{month:`long`,day:`numeric`,year:`numeric`})}),g(Z)&&Z.upstreamUpdatedAt&&T(`span`,{className:`rounded-full bg-wx-bg-elevated px-1.5 py-0.5 text-[10px] font-medium text-wx-fg-muted`,title:new Date(Z.upstreamUpdatedAt).toLocaleString(F),children:M(`editedAt`,{when:h(Z.upstreamUpdatedAt)})})]}),T(`h2`,{className:`text-2xl leading-tight font-bold text-wx-fg`,children:Z.title}),Z.authors&&Z.authors.length>0&&E(`p`,{className:`flex items-center gap-2 text-xs text-wx-fg-muted`,children:[T(`span`,{className:`flex -space-x-1.5`,children:Z.authors.slice(0,3).map(e=>T(`span`,{className:`h-5 w-5 overflow-hidden rounded-full bg-wx-bg-elevated ring-1 ring-wx-bg`,"aria-hidden":`true`,children:T(`img`,{src:e.photo.url,alt:``,className:`h-full w-full object-cover`})},e._id))}),T(`span`,{children:M(`writtenBy`,{names:Z.authors.map(e=>e.name).join(`, `)})})]}),Z.tags&&Z.tags.length>0&&T(`div`,{className:`flex flex-wrap gap-1`,children:Z.tags.map(e=>T(`span`,{className:`rounded-full bg-wx-bg-elevated px-2 py-0.5 text-[11px] font-medium text-wx-fg-muted`,children:e.label},e.slug))}),Z.excerpt&&T(`p`,{className:`text-base leading-relaxed text-wx-fg-muted`,children:Z.excerpt}),Z.contentMarkdown&&T(b,{content:Z.contentMarkdown,isHtml:Z.bodyFormat===`html`||x(Z.contentMarkdown),markdownMarginClass:`mt-3`}),Z.sourceUrl&&E(`a`,{href:Z.sourceUrl,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 flex items-center justify-center gap-1.5 text-xs text-wx-primary underline underline-offset-2 transition-opacity hover:opacity-80`,children:[T(te,{size:12}),T(`span`,{children:M(`readOriginal`)})]}),R&&T(se,{currentId:Z.id,currentCategoryIds:Z.categoryIds??[],currentTagIds:Z.tagIds??[],previewPostsById:O?void 0:I.previewData?.newsPostsById,visitorRelatedRaw:ue?.visitorNewsRelated,isDummy:O,demoItems:de,onOpen:H}),Z.id&&T(S,{surface:y.NEWS,itemId:Z.id,reactionCounts:Z.reactionCounts??null,viewerReaction:Z.viewerReaction??null,groupItemIds:[Z.id,...(Z.translations??[]).map(e=>e.id)],isDummy:O,showCounts:z,className:`mt-6`}),T(v,{currentLocale:O?U:Z.locale??F,locales:O?[...c]:(Z.translations??[]).map(e=>e.locale),allowedLocales:O?void 0:L.supportedLocales,onSelect:O?e=>W(e):e=>{let t=(Z.translations??[]).find(t=>t.locale===e);t&&H(t.id)},className:`mt-6`})]})]})})}function k(){return T(d,{followDirection:!0,className:`flex-1`,viewportRef:p(),children:E(`div`,{className:`flex flex-col`,"aria-busy":`true`,"aria-live":`polite`,children:[T(`div`,{className:`w-full animate-pulse bg-wx-bg-elevated`,style:{aspectRatio:`16 / 9`}}),E(`div`,{className:`px-5 pt-5 pb-12`,children:[E(`div`,{className:`animate-pulse space-y-2.5`,children:[T(`div`,{className:`h-5 w-3/4 rounded-md bg-wx-bg-elevated`}),T(`div`,{className:`h-5 w-1/2 rounded-md bg-wx-bg-elevated`})]}),T(`div`,{className:`mt-4 flex items-center gap-2 animate-pulse`,children:T(`div`,{className:`h-3 w-24 rounded-md bg-wx-bg-elevated`})}),T(`div`,{className:`mt-6 space-y-2.5 animate-pulse`,children:[`w-full`,`w-11/12`,`w-10/12`,`w-full`,`w-9/12`,`w-7/12`].map((e,t)=>T(`div`,{className:n(`h-3 rounded-md bg-wx-bg-elevated`,e)},t))})]})]})})}export{O as NewsArticleView};
|
|
2
|
-
//# sourceMappingURL=widget-react-Yd3uIKgg.js.map
|