@wexio/messenger-widget-react 1.5.2 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @wexio/messenger-widget-react
2
2
 
3
+ ## 1.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cdbf505: Open-state and navigation props on every embed: `defaultOpen`, controlled `open` and `previewTab` (React props, web-component `default-open` / `open` attributes and `previewTab` property, Vue / Angular / Ember wrappers, and `Wexio('open' | 'close' | 'navigate')` + `wexioSettings.defaultOpen` for the script tag). New integration-level `theme.launcherOffset` (px, clamped 0..200) moves the launcher, peek and panel in all three embeds; a host offset wins. Fixes: a persisted `sending` outbox op is retried after a reload, and Enter that confirms an IME candidate no longer sends the message.
8
+
9
+ ## 1.5.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 3816144: Keep the bundler-ignore comments in the published bundles so Next/Turbopack consumers build
14
+
3
15
  ## 1.5.2
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -97,6 +97,9 @@ Pass a verified `user` to log a known visitor in (a known-user login / boot). Pr
97
97
  | `publicKey` | `string` | Wexio integration public key (`pk_live_...`). Omit to render in demo mode (bundled mock content for landing pages or Storybook). |
98
98
  | `user` | [`VisitorIdentity`](#visitoridentity) | Verified identity. See [Identifying users](#identifying-users). |
99
99
  | `config` | [`InjectableWidgetConfig`](#injectablewidgetconfig) | Pre-resolved widget config. Set this if you already have the config server-rendered or fetched app-wide — skips the bootstrap fetch. |
100
+ | `defaultOpen` | `boolean` | Open the panel on mount (uncontrolled afterwards). |
101
+ | `open` | `boolean` | Controlled open state. Keep it in sync from `onOpen` / `onClose`. Omit for an uncontrolled widget. |
102
+ | `previewTab` | `PreviewTabSignal` | Navigate to a tab (`{ tab, nonce, article? }`) without a remount; opens the panel. A new `nonce` re-issues the request. |
100
103
  | `onResize` | `(size: { width: number; height: number }) => void` | Fired whenever the widget's intended dimensions change (open ↔ closed ↔ expanded). Use for host-side layout sync. |
101
104
  | `onOpen` | `() => void` | Fired when the visitor opens the panel (taps the launcher, peek bubble, etc.). |
102
105
  | `onClose` | `() => void` | Fires on every open to closed transition (header X, launcher, Escape). |
@@ -111,7 +114,18 @@ When the operator enables [Cloudflare Turnstile](https://developers.cloudflare.c
111
114
 
112
115
  ## Methods
113
116
 
114
- The component's open / close lifecycle is driven via the `onOpen` / `onClose` callbacks plus the visitor's tap on the launcher — no host-side imperative call is needed for normal use.
117
+ The component's open / close lifecycle is reported via the `onOpen` / `onClose` callbacks. To drive it from your own state use `open` (keep it in sync from those callbacks) or `defaultOpen`; `previewTab` jumps to a tab or article.
118
+
119
+ ```tsx
120
+ const [open, setOpen] = useState(false);
121
+ <WexioWidget
122
+ publicKey="pk_live_..."
123
+ open={open}
124
+ onOpen={() => setOpen(true)}
125
+ onClose={() => setOpen(false)}
126
+ previewTab={{ tab: "help", nonce }} // bump `nonce` to navigate again
127
+ />;
128
+ ```
115
129
 
116
130
  An imperative `window.WexioWidget` surface (`show`, `hide`, `showSpace`, `setLocale`, `onUnreadCountChange`, …) is on the roadmap to mirror the script loader's API, but doesn't ship in the current React package. For deep-link / programmatic control today, mount the widget conditionally from your own host state.
117
131
 
@@ -1,4 +1,4 @@
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{n as e,r as t}from"./widget-react-FX5W7RyV.js";import{Ct as n,St as r,wt as i}from"./widget-react-YrYT-pD1.js";import*as a from"react";import{jsx as o}from"react/jsx-runtime";var s={},c=function(e){return e.Popular=`POPULAR`,e.Recent=`RECENT`,e}({}),l=i`
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{n as e,r as t}from"./widget-react-FX5W7RyV.js";import{Ct as n,St as r,wt as i}from"./widget-react-CkDSkBH9.js";import*as a from"react";import{jsx as o}from"react/jsx-runtime";var s={},c=function(e){return e.Popular=`POPULAR`,e.Recent=`RECENT`,e}({}),l=i`
2
2
  query VisitorHelpFolders($parentId: ID, $locale: String) {
3
3
  visitorHelpFolders(parentId: $parentId, locale: $locale) {
4
4
  _id
@@ -160,4 +160,4 @@ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){se
160
160
  }
161
161
  }
162
162
  `;function w(e){return n(C,{...s,...e})}function T(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function E(...e){return t=>{let n=!1,r=e.map(e=>{let r=T(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():T(e[t],null)}}}}var D=Symbol.for(`react.lazy`),O=a.use;function k(e){return typeof e==`object`&&!!e&&`then`in e}function A(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===D&&`_payload`in e&&k(e._payload)}function j(e){let t=N(e),n=a.forwardRef((e,n)=>{let{children:r,...i}=e;A(r)&&typeof O==`function`&&(r=O(r._payload));let s=a.Children.toArray(r),c=s.find(F);if(c){let e=c.props.children,r=s.map(t=>t===c?a.Children.count(e)>1?a.Children.only(null):a.isValidElement(e)?e.props.children:null:t);return o(t,{...i,ref:n,children:a.isValidElement(e)?a.cloneElement(e,void 0,r):null})}return o(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var M=j(`Slot`);function N(e){let t=a.forwardRef((e,t)=>{let{children:n,...r}=e;if(A(n)&&typeof O==`function`&&(n=O(n._payload)),a.isValidElement(n)){let e=L(n),i=I(r,n.props);return n.type!==a.Fragment&&(i.ref=t?E(t,e):e),a.cloneElement(n,i)}return a.Children.count(n)>1?a.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var P=Symbol(`radix.slottable`);function F(e){return a.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===P}function I(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function L(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var R=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,z=t,B=((e,t)=>n=>{if(t?.variants==null)return z(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=R(t)||R(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return z(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)})(`inline-flex items-center justify-center gap-2 font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary focus-visible:ring-offset-2 focus-visible:ring-offset-wx-bg disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{solid:`bg-wx-primary text-wx-primary-fg hover:bg-wx-primary-hover`,tonal:`bg-wx-bg-elevated text-wx-fg hover:bg-wx-bg-elevated-2`,ghost:`bg-transparent text-wx-fg-muted hover:bg-wx-bg-elevated hover:text-wx-fg`,outline:`border border-wx-border bg-transparent text-wx-fg hover:bg-wx-bg-elevated`},size:{sm:`h-8 px-3 text-xs rounded-wx-sm whitespace-nowrap`,md:`h-10 px-4 text-sm rounded-wx whitespace-nowrap`,lg:`h-12 px-5 text-sm rounded-wx-lg whitespace-nowrap`,tile:`w-full px-5 py-5 text-base rounded-wx-lg`,icon:`h-9 w-9 rounded-full whitespace-nowrap`}},defaultVariants:{variant:`solid`,size:`md`}}),V=a.forwardRef(({className:t,variant:n,size:r,asChild:i=!1,...a},s)=>o(i?M:`button`,{ref:s,className:e(B({variant:n,size:r,className:t})),...a}));V.displayName=`Button`;export{d as a,g as c,f as d,S as f,l as i,w as l,j as n,b as o,v as p,c as r,m as s,V as t,u};
163
- //# sourceMappingURL=widget-react-DBqY7BEB.js.map
163
+ //# sourceMappingURL=widget-react-9oF1qdlF.js.map
@@ -1,2 +1,2 @@
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{_ as e,i as t,n}from"./widget-react-FX5W7RyV.js";import{B as r,F as i,Tt as a,_ as o,a as s,b as c,i as l,n as u,t as d,y as f,z as p}from"./widget-react-YrYT-pD1.js";import{n as m}from"./widget-react-DUnaBOfT.js";import{useCallback as h,useEffect as g,useMemo as _,useRef as v,useState as y}from"react";import{jsx as b,jsxs as x}from"react/jsx-runtime";function S(e){if(!e)return!1;let t=e.trimStart().slice(0,200);return/^<(?:[a-z!][^>]*|!--)/i.test(t)}var C=function(e){return e.HTML=`HTML`,e.MARKDOWN=`MARKDOWN`,e}({}),w=function(e){return e.HELP=`HELP`,e.NEWS=`NEWS`,e}({});function T(e,t){g(()=>{if(t)return e&&t(e),()=>t(null)},[e,t])}var E=`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 D({content:e,isHtml:t,markdownMarginClass:n}){return t?b(u,{html:e,className:`mt-0 ${E}`}):b(`div`,{className:`${n} ${E}`,children:b(s,{remarkPlugins:[l],children:e})})}function O({currentLocale:r,locales:i,allowedLocales:a,onSelect:s,className:l}){let u=e(`languageSelector`),[p,h]=y(!1),_=v(null);g(()=>{if(!p)return;let e=e=>{_.current&&!e.composedPath().includes(_.current)&&h(!1)},t=e=>{e.key===`Escape`&&h(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[p]);let S=a&&a.length>0?new Set(a.map(e=>e.split(`-`)[0].toLowerCase())):null,C=Array.from(new Set(i.filter(Boolean))).filter(e=>!S||S.has(e.split(`-`)[0].toLowerCase()));if(C.length<=1)return null;let w=r.split(`-`)[0].toLowerCase(),T=C.includes(r);return x(`div`,{ref:_,className:n(`relative`,l),children:[b(`p`,{className:`mb-1.5 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase`,children:u(`title`)}),x(`button`,{type:`button`,onClick:()=>h(e=>!e),"aria-haspopup":`listbox`,"aria-expanded":p,"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:[b(o,{size:15,className:`shrink-0 text-wx-fg-muted`}),b(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:d(r)}),b(f,{size:15,className:n(`shrink-0 text-wx-fg-subtle transition-transform`,p&&`rotate-180`)})]}),b(m,{children:p&&b(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 b(`li`,{children:x(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>{s(e),h(!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:[b(`span`,{className:`min-w-0 flex-1 truncate`,children:d(e)}),t&&b(c,{size:15,className:`shrink-0 text-wx-primary`})]})},e)})})})]})}var k=(e,t)=>`wexio:reaction:${e}:${t}`,A=[{slotIndex:0,emoji:`🎉`},{slotIndex:1,emoji:`❤️`},{slotIndex:2,emoji:`👍`}],j={[w.NEWS]:`NewsPost`,[w.HELP]:`HelpArticle`};function M({surface:o,itemId:s,reactionCounts:c,viewerReaction:l,groupItemIds:u,readonly:d=!1,showCounts:f=!0,isDummy:m=!1,className:v}){let S=e(`reactions`),C=a(),{data:w,loading:T}=r({variables:{surface:o},fetchPolicy:`cache-first`,skip:m}),[E,{loading:D}]=p(),O=i(),M=_(()=>m?A:w?.visitorReactionSet?.slots??[],[m,w]),N=m?!0:w?.visitorReactionSet?.enabled??!0,P=k(o,s),[F,I]=y(null);g(()=>{if(!m){I(l??null);return}if(typeof window>`u`)return;let e=window.localStorage.getItem(P);I(e===null?null:Number(e))},[m,P,l]);let[L,R]=y({}),z=e=>(c?.[String(e)]??0)+(m?L[e]??0:0),B=h((e,t)=>{let n=j[o],r=u?.length?u:[s];for(let i of r){let r=C.cache.identify({__typename:n,_id:i});r&&C.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}}})}},[C,o,u,s]),V=async e=>{if(d||D||F===e)return;let t=F;if(I(e),m){typeof window<`u`&&window.localStorage.setItem(P,String(e)),R(n=>({...n,[e]:(n[e]??0)+1,...t===null?{}:{[t]:(n[t]??0)-1}}));return}if(B(t,e),O){O.enqueue({op:`reaction`,semantics:`convergence`,convergenceKey:`reaction:${o}:${s}`,payload:{surface:o,itemId:s,slotIndex:e}});return}try{await E({variables:{input:{surface:o,itemId:s,slotIndex:e}}})}catch{B(e,t),I(t)}};return T||!N||M.length===0?null:b(`div`,{className:n(`flex flex-wrap items-center justify-center gap-2`,v),role:`group`,"aria-label":S(`ariaLabel`),children:M.map(e=>{let r=F===e.slotIndex,i=z(e.slotIndex);return x(t.button,{type:`button`,disabled:d||D,onClick:()=>void V(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`,d&&`cursor-default opacity-70`),"aria-pressed":r,"aria-label":S(`tapAria`,{emoji:e.emoji}),children:[b(`span`,{"aria-hidden":`true`,children:e.emoji}),f&&i>0&&b(`span`,{className:`text-xs font-medium text-wx-fg-muted`,children:i})]},e.slotIndex)})})}export{C as a,T as i,O as n,w as o,D as r,S as s,M as t};
2
- //# sourceMappingURL=widget-react-DleQcmXy.js.map
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{_ as e,i as t,n}from"./widget-react-FX5W7RyV.js";import{B as r,F as i,Tt as a,_ as o,a as s,b as c,i as l,n as u,t as d,y as f,z as p}from"./widget-react-CkDSkBH9.js";import{n as m}from"./widget-react-DUnaBOfT.js";import{useCallback as h,useEffect as g,useMemo as _,useRef as v,useState as y}from"react";import{jsx as b,jsxs as x}from"react/jsx-runtime";function S(e){if(!e)return!1;let t=e.trimStart().slice(0,200);return/^<(?:[a-z!][^>]*|!--)/i.test(t)}var C=function(e){return e.HTML=`HTML`,e.MARKDOWN=`MARKDOWN`,e}({}),w=function(e){return e.HELP=`HELP`,e.NEWS=`NEWS`,e}({});function T(e,t){g(()=>{if(t)return e&&t(e),()=>t(null)},[e,t])}var E=`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 D({content:e,isHtml:t,markdownMarginClass:n}){return t?b(u,{html:e,className:`mt-0 ${E}`}):b(`div`,{className:`${n} ${E}`,children:b(s,{remarkPlugins:[l],children:e})})}function O({currentLocale:r,locales:i,allowedLocales:a,onSelect:s,className:l}){let u=e(`languageSelector`),[p,h]=y(!1),_=v(null);g(()=>{if(!p)return;let e=e=>{_.current&&!e.composedPath().includes(_.current)&&h(!1)},t=e=>{e.key===`Escape`&&h(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[p]);let S=a&&a.length>0?new Set(a.map(e=>e.split(`-`)[0].toLowerCase())):null,C=Array.from(new Set(i.filter(Boolean))).filter(e=>!S||S.has(e.split(`-`)[0].toLowerCase()));if(C.length<=1)return null;let w=r.split(`-`)[0].toLowerCase(),T=C.includes(r);return x(`div`,{ref:_,className:n(`relative`,l),children:[b(`p`,{className:`mb-1.5 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase`,children:u(`title`)}),x(`button`,{type:`button`,onClick:()=>h(e=>!e),"aria-haspopup":`listbox`,"aria-expanded":p,"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:[b(o,{size:15,className:`shrink-0 text-wx-fg-muted`}),b(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:d(r)}),b(f,{size:15,className:n(`shrink-0 text-wx-fg-subtle transition-transform`,p&&`rotate-180`)})]}),b(m,{children:p&&b(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 b(`li`,{children:x(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>{s(e),h(!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:[b(`span`,{className:`min-w-0 flex-1 truncate`,children:d(e)}),t&&b(c,{size:15,className:`shrink-0 text-wx-primary`})]})},e)})})})]})}var k=(e,t)=>`wexio:reaction:${e}:${t}`,A=[{slotIndex:0,emoji:`🎉`},{slotIndex:1,emoji:`❤️`},{slotIndex:2,emoji:`👍`}],j={[w.NEWS]:`NewsPost`,[w.HELP]:`HelpArticle`};function M({surface:o,itemId:s,reactionCounts:c,viewerReaction:l,groupItemIds:u,readonly:d=!1,showCounts:f=!0,isDummy:m=!1,className:v}){let S=e(`reactions`),C=a(),{data:w,loading:T}=r({variables:{surface:o},fetchPolicy:`cache-first`,skip:m}),[E,{loading:D}]=p(),O=i(),M=_(()=>m?A:w?.visitorReactionSet?.slots??[],[m,w]),N=m?!0:w?.visitorReactionSet?.enabled??!0,P=k(o,s),[F,I]=y(null);g(()=>{if(!m){I(l??null);return}if(typeof window>`u`)return;let e=window.localStorage.getItem(P);I(e===null?null:Number(e))},[m,P,l]);let[L,R]=y({}),z=e=>(c?.[String(e)]??0)+(m?L[e]??0:0),B=h((e,t)=>{let n=j[o],r=u?.length?u:[s];for(let i of r){let r=C.cache.identify({__typename:n,_id:i});r&&C.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}}})}},[C,o,u,s]),V=async e=>{if(d||D||F===e)return;let t=F;if(I(e),m){typeof window<`u`&&window.localStorage.setItem(P,String(e)),R(n=>({...n,[e]:(n[e]??0)+1,...t===null?{}:{[t]:(n[t]??0)-1}}));return}if(B(t,e),O){O.enqueue({op:`reaction`,semantics:`convergence`,convergenceKey:`reaction:${o}:${s}`,payload:{surface:o,itemId:s,slotIndex:e}});return}try{await E({variables:{input:{surface:o,itemId:s,slotIndex:e}}})}catch{B(e,t),I(t)}};return T||!N||M.length===0?null:b(`div`,{className:n(`flex flex-wrap items-center justify-center gap-2`,v),role:`group`,"aria-label":S(`ariaLabel`),children:M.map(e=>{let r=F===e.slotIndex,i=z(e.slotIndex);return x(t.button,{type:`button`,disabled:d||D,onClick:()=>void V(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`,d&&`cursor-default opacity-70`),"aria-pressed":r,"aria-label":S(`tapAria`,{emoji:e.emoji}),children:[b(`span`,{"aria-hidden":`true`,children:e.emoji}),f&&i>0&&b(`span`,{className:`text-xs font-medium text-wx-fg-muted`,children:i})]},e.slotIndex)})})}export{C as a,T as i,O as n,w as o,D as r,S as s,M as t};
2
+ //# sourceMappingURL=widget-react-B3jj01Xc.js.map
@@ -1,2 +1,2 @@
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{_ as e,n as t,y as n}from"./widget-react-FX5W7RyV.js";import{A as r,D as i,E as a,I as o,at as s,c,d as l,gt as u,k as d,l as f,u as p,x as ee}from"./widget-react-YrYT-pD1.js";import{d as te,g as ne,h as m,n as h,r as g}from"./widget-react-COAvUm8D.js";import{i as _,n as v,o as y,r as b,s as x,t as S}from"./widget-react-DleQcmXy.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:t,currentCategoryIds:n,currentTagIds:r,previewPostsById:i,visitorRelatedRaw:a,isDummy:o,demoItems:s,onOpen:c}){let l=e(`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 e=new Set(n),a=new Set(r),o=[];for(let[n,r]of Object.entries(i)){if(n===t||!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 t of u)e.has(t)&&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=e(`news`),N=d(),P=p(),F=n(),I=a(),{config:L}=ee(),R=L.messenger?.showRelatedNews??!0,z=L.messenger?.showReactionCounts??!0,{trackLinkClick:B}=c(),V=re(null),H=e=>{A?.(e)},[U,W]=ie(F),G=r(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=u().publicKey,Y=f(J&&!O&&!q&&D?o.newsPost(J,D,F):null,ce),{data:ue}=ne({variables:{postId:D,limit:5,locale:F},skip:O||q||!D||!R}),X=O?s(G).find(e=>e.id===D)??null:null,de=w(()=>O?ae(s(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(l,{followDirection:!0,className:`flex-1`,viewportRef:P,children:E(`div`,{className:`flex flex-col`,children:[T(`div`,{className:t(`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?[...i]:(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(l,{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,n)=>T(`div`,{className:t(`h-3 rounded-md bg-wx-bg-elevated`,e)},n))})]})]})})}export{O as NewsArticleView};
2
- //# sourceMappingURL=widget-react-Cv42XaBB.js.map
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{_ as e,n as t,y as n}from"./widget-react-FX5W7RyV.js";import{A as r,D as i,E as a,I as o,at as s,c,d as l,gt as u,k as d,l as f,u as p,x as ee}from"./widget-react-CkDSkBH9.js";import{d as te,g as ne,h as m,n as h,r as g}from"./widget-react-DFbFMJOG.js";import{i as _,n as v,o as y,r as b,s as x,t as S}from"./widget-react-B3jj01Xc.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:t,currentCategoryIds:n,currentTagIds:r,previewPostsById:i,visitorRelatedRaw:a,isDummy:o,demoItems:s,onOpen:c}){let l=e(`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 e=new Set(n),a=new Set(r),o=[];for(let[n,r]of Object.entries(i)){if(n===t||!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 t of u)e.has(t)&&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=e(`news`),N=d(),P=p(),F=n(),I=a(),{config:L}=ee(),R=L.messenger?.showRelatedNews??!0,z=L.messenger?.showReactionCounts??!0,{trackLinkClick:B}=c(),V=re(null),H=e=>{A?.(e)},[U,W]=ie(F),G=r(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=u().publicKey,Y=f(J&&!O&&!q&&D?o.newsPost(J,D,F):null,ce),{data:ue}=ne({variables:{postId:D,limit:5,locale:F},skip:O||q||!D||!R}),X=O?s(G).find(e=>e.id===D)??null:null,de=w(()=>O?ae(s(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(l,{followDirection:!0,className:`flex-1`,viewportRef:P,children:E(`div`,{className:`flex flex-col`,children:[T(`div`,{className:t(`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?[...i]:(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(l,{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,n)=>T(`div`,{className:t(`h-3 rounded-md bg-wx-bg-elevated`,e)},n))})]})]})})}export{O as NewsArticleView};
2
+ //# sourceMappingURL=widget-react-BqKcbGFN.js.map