1import{r as e,b as t,j as r,L as s,k as a,N as n}from"./react-vendor-mJE67xr1.js";import{S as l}from"./SEO-5SzjKk1y.js";import{h as i,by as o,bz as d,U as c,R as u,G as m,bA as x,aM as h}from"../assets/index-C0PUTU2T.js";import{collection as b,query as f,limit as p,startAfter as g,orderBy as w,where as j,getDocs as N,getDoc as k,doc as v}from"./firebase-firestore-BXNJosLe.js";import"./firebase-functions-BIkcAD2c.js";import"./marked-vendor-DnXKqpPN.js";import"./chart-vendor-CdNLo97a.js";import{F as y}from"./Footer-E53lKuy5.js";import{u as z}from"./i18n-vendor-peNJPOqg.js";import{L as S,q as C,j as M,S as E,X as A,N as L,a0 as V}from"./ui-vendor-D2aVcy5s.js";import"./helmet-vendor-BxvPnmey.js";import"./firebase-auth-CnGPAdc3.js";import"./firebase-core-ES3oYmR9.js";import"./dndkit-vendor-BC6j4eOO.js";import"./flags-vendor-C6ccH1Xz.js";import"./footerSocialLinks-BexBiAJO.js";function R(e){const t=e.trim();if(!t)return"";try{const e=new URL(t);e.hash="";let r=e.pathname.replace(/\/+$/,"")||"/";return`${e.protocol}//${e.host.toLowerCase()}${r}${e.search}`.toLowerCase()}catch{return t.toLowerCase().replace(/\/+$/,"")}}function $(e){const t=new Map;for(const r of e){const e=R(r.url);if(!e)continue;const s=t.get(e);s?(r.publishedAt?.toMillis?.()??0)>=(s.publishedAt?.toMillis?.()??0)&&t.set(e,r):t.set(e,r)}return[...t.values()].sort((e,t)=>(t.publishedAt?.toMillis?.()??0)-(e.publishedAt?.toMillis?.()??0))}async function F(e){const t=await k(v(i,"marketNewsMeta",e));if(!t.exists())return null;const r=t.data();return{feed:e,lastSyncAt:r.lastSyncAt??null,lastSyncCount:"number"==typeof r.lastSyncCount?r.lastSyncCount:0,lastError:null!=r.lastError?String(r.lastError):null}}async function K(e,t,r=20){const s=b(i,"marketNewsArticles"),a=t?f(s,j("feed","==",e),w("publishedAt","desc"),g(t),p(r+1)):f(s,j("feed","==",e),w("publishedAt","desc"),p(r+1)),n=(await N(a)).docs,l=n.length>r,o=l?n.slice(0,r):n,d=$(o.map(t=>function(e,t){const r=e.data();return{id:e.id,feed:r.feed??t,publisher:String(r.publisher??""),title:String(r.title??""),image:r.image?String(r.image):null,site:String(r.site??""),text:String(r.text??""),url:String(r.url??""),publishedAt:r.publishedAt,syncedAt:r.syncedAt}}(t,e)));return{articles:d,lastDoc:o.length>0?o[o.length-1]:null,hasMore:l}}const D=({feed:s})=>{const{t:a}=z(),n=t(),[l,i]=e.useState(!1),c=e.useRef(null),u=e.useId(),m=(o(s)??d[0]).Icon;return e.useEffect(()=>{if(!l)return;const e=e=>{c.current?.contains(e.target)||i(!1)},t=e=>{"Escape"===e.key&&i(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[l]),r.jsxs("div",{ref:c,className:"relative w-full shrink-0 sm:w-auto sm:min-w-[240px] md:min-w-[260px]",children:[r.jsxs("button",{type:"button",id:"market-news-feed-trigger","aria-haspopup":"listbox","aria-expanded":l,"aria-controls":u,onClick:()=>i(e=>!e),className:"group relative flex w-full items-center gap-3 overflow-hidden rounded-xl border px-3 py-2.5 text-left shadow-lg transition-all duration-200 sm:px-3.5 "+(l?"border-brand/50 bg-gradient-to-br from-zinc-900 via-zinc-900 to-zinc-950 ring-2 ring-brand/30 shadow-brand/10":"border-zinc-700/80 bg-gradient-to-br from-zinc-900/80 via-zinc-900/90 to-zinc-950/95 ring-1 ring-white/[0.06] hover:border-brand/35 hover:shadow-brand/5 hover:ring-brand/20"),children:[r.jsx("span",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-brand/40 to-transparent opacity-0 transition-opacity duration-200 group-hover:opacity-100","aria-hidden":!0}),r.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-gradient-to-br shadow-inner transition-all duration-200 "+(l?"from-brand/25 to-brand/10 ring-1 ring-brand/40":"from-brand/20 to-brand/5 ring-1 ring-brand/25 group-hover:from-brand/25 group-hover:to-brand/10"),children:r.jsx(m,{className:"h-4 w-4 text-brand","aria-hidden":!0})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsxs("span",{className:"flex items-center gap-1.5 text-label-responsive font-bold tracking-widest text-zinc-500",children:[r.jsx(S,{className:"h-3 w-3 text-brand/70","aria-hidden":!0}),a("marketNews.feedNav",{defaultValue:"News category"})]}),r.jsx("span",{className:"mt-0.5 block truncate text-sm font-semibold tracking-tight text-zinc-300",children:a("marketNews.changeFeed",{defaultValue:"Change feed"})})]}),r.jsx(C,{className:"h-4 w-4 shrink-0 text-zinc-400 transition-transform duration-200 "+(l?"rotate-180 text-brand":"group-hover:text-zinc-300"),"aria-hidden":!0})]}),l?r.jsx("div",{className:"absolute right-0 z-50 mt-2 w-full min-w-[260px] sm:min-w-[280px]",children:r.jsxs("ul",{id:u,role:"listbox","aria-labelledby":"market-news-feed-trigger",className:"overflow-hidden rounded-xl border border-zinc-700/90 bg-gradient-to-b from-zinc-900 to-zinc-950 p-1.5 shadow-2xl shadow-black/60 ring-1 ring-white/[0.06] backdrop-blur-xl",children:[r.jsx("li",{className:"pointer-events-none border-b border-zinc-800/80 px-3 pb-2 pt-1.5","aria-hidden":!0,
1children:r.jsx("p",{className:"text-label-responsive font-bold tracking-widest text-zinc-500",children:a("marketNews.switchFeed",{defaultValue:"Switch feed"})})}),d.map(e=>{const t=e.feed===s,d=e.Icon;return r.jsx("li",{role:"presentation",className:"mt-0.5",children:r.jsxs("button",{type:"button",role:"option","aria-selected":t,tabIndex:l?0:-1,onClick:()=>(e=>{const t=o(e);t&&n(t.route),i(!1)})(e.feed),className:"relative flex w-full items-center gap-3 rounded-lg px-2.5 py-2.5 text-left transition-colors duration-150 "+(t?"bg-brand/12 text-white ring-1 ring-brand/25":"text-zinc-300 hover:bg-zinc-800/70 hover:text-white"),children:[t?r.jsx("span",{className:"absolute bottom-2 left-0 top-2 w-0.5 rounded-full bg-brand shadow-[0_0_8px_rgba(125,227,19,0.6)]","aria-hidden":!0}):null,r.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg transition-colors "+(t?"bg-gradient-to-br from-brand/25 to-brand/10 ring-1 ring-brand/35":"bg-zinc-800/90 ring-1 ring-white/[0.04] group-hover:ring-white/[0.08]"),children:r.jsx(d,{className:"h-4 w-4 "+(t?"text-brand":"text-zinc-400"),"aria-hidden":!0})}),r.jsxs("span",{className:"min-w-0 flex-1 pr-1",children:[r.jsx("span",{className:"block truncate text-sm font-semibold "+(t?"text-brand":""),children:a(e.navLabelKey,{defaultValue:e.defaultLabel})}),r.jsx("span",{className:"mt-0.5 line-clamp-1 text-xs text-zinc-500",children:a(e.subtitleKey,{defaultValue:""})})]}),t?r.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-brand/20",children:r.jsx(M,{className:"h-3.5 w-3.5 text-brand","aria-hidden":!0})}):null]})},e.feed)})]})}):null]})},T=({value:e,onChange:t,resultCount:s,totalLoaded:a})=>{const{t:n}=z(),l=e.trim().length>0;return r.jsxs("div",{className:"mb-8",children:[r.jsx("label",{htmlFor:"market-news-search",className:"sr-only",children:n("marketNews.searchLabel",{defaultValue:"Search articles"})}),r.jsxs("div",{className:"relative",children:[r.jsx(E,{className:"pointer-events-none absolute left-0 top-1/2 h-4 w-4 -translate-y-1/2 text-zinc-500","aria-hidden":!0}),r.jsx("input",{id:"market-news-search",type:"search",value:e,onChange:e=>t(e.target.value),placeholder:n("marketNews.searchPlaceholder",{defaultValue:"Search headlines and summariesâ¦"}),autoComplete:"off",className:"w-full rounded-none border-0 border-b border-zinc-700/80 bg-transparent py-2.5 pl-7 pr-10 text-sm text-white shadow-none placeholder:text-zinc-500 transition-colors focus:border-b-brand focus:bg-transparent focus:outline-none focus:ring-0"}),l?r.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-lg text-zinc-400 transition-colors hover:bg-zinc-800 hover:text-white","aria-label":n("marketNews.searchClear",{defaultValue:"Clear search"}),children:r.jsx(A,{className:"h-4 w-4","aria-hidden":!0})}):null]}),l&&"number"==typeof s&&"number"==typeof a?r.jsx("p",{className:"mt-2 text-xs text-zinc-500",children:0===s?n("marketNews.searchNoResults",{defaultValue:"No articles match your search."}):n("marketNews.searchResults",{defaultValue:"{{count}} of {{total}} loaded articles",count:s,total:a})}):null]})},_=({publisher:e,site:t})=>{const s=e.trim()||"Unknown",a=t?.trim();return r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[r.jsx("span",{className:"inline-flex items-center rounded-full bg-brand/15 px-2 py-0.5 text-label-responsive font-bold tracking-wide text-brand",children:s}),a?r.jsx("span",{className:"text-label-responsive font-medium tracking-wide text-slate-500 dark:text-zinc-500",children:a}):null]})},I=({article:t})=>{const{t:s}=z(),[a,n]=e.useState(!1),l=t.image&&!a,i=function(e){try{const t=e.publishedAt.toDate(),r=Date.now()-t.getTime(),s=Math.floor(r/6e4);if(s<1)return"Just now";if(s<60)return`${s}m ago`;const a=Math.floor(s/60);return a<48?`${a}h ago`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}).format(t)}catch{return""}}(t);return r.jsxs("article",{className:"group flex h-full flex-col overflow-hidden rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm transition-all hover:border-brand/40 hover:shadow-md dark:border-zinc-800 dark:bg-zinc-900/50 dark:hover:border-brand/30",children:[r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"relative block aspect-[16/10] w-full overflow-hidden bg-slate-100 dar
1k:bg-zinc-800/80","aria-label":t.title,children:l?r.jsx("img",{src:t.image,alt:"",loading:"lazy",className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]",onError:()=>n(!0)}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-slate-400 dark:text-zinc-600",children:r.jsx(L,{className:"h-12 w-12 opacity-40","aria-hidden":!0})})}),r.jsxs("div",{className:"flex flex-1 flex-col gap-3 p-4 sm:p-5",children:[r.jsx(_,{publisher:t.publisher,site:t.site}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"block focus:outline-none focus-visible:ring-2 focus-visible:ring-brand rounded-sm",children:r.jsx("h2",{className:"text-lg font-bold leading-snug text-slate-900 line-clamp-2 transition-colors group-hover:text-brand dark:text-white",children:t.title})}),t.text?r.jsx("p",{className:"text-sm leading-relaxed text-slate-600 line-clamp-3 dark:text-zinc-400",children:t.text}):null,r.jsxs("div",{className:"mt-auto flex flex-wrap items-center justify-between gap-2 pt-1",children:[i?r.jsx("time",{className:"text-xs text-slate-500 dark:text-zinc-500",dateTime:t.publishedAt.toDate?.()?.toISOString?.(),children:i}):r.jsx("span",{}),r.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs font-semibold text-brand hover:underline",children:[s("marketNews.readArticle",{defaultValue:"Read article"}),r.jsx(V,{className:"h-3.5 w-3.5","aria-hidden":!0})]})]})]})]})},H=()=>r.jsxs("div",{className:"animate-pulse overflow-hidden rounded-2xl border border-slate-200/80 bg-white/90 dark:border-zinc-800 dark:bg-zinc-900/50",children:[r.jsx("div",{className:"aspect-[16/10] bg-slate-200 dark:bg-zinc-800"}),r.jsxs("div",{className:"space-y-3 p-5",children:[r.jsx("div",{className:"h-4 w-24 rounded bg-slate-200 dark:bg-zinc-800"}),r.jsx("div",{className:"h-5 w-full rounded bg-slate-200 dark:bg-zinc-800"}),r.jsx("div",{className:"h-5 w-4/5 rounded bg-slate-200 dark:bg-zinc-800"}),r.jsx("div",{className:"h-12 w-full rounded bg-slate-200 dark:bg-zinc-800"})]})]}),O=({feed:t})=>{const{t:a}=z(),n=o(t),l=n?.labelKey??"marketNews.general.title",i=n?.subtitleKey??"marketNews.general.subtitle",d=n?.defaultLabel??"Market news",{articles:x,meta:h,loading:b,loadingMore:f,error:p,hasMore:g,loadMore:w,retry:j}=function(t){const[r,s]=e.useState([]),[a,n]=e.useState(null),[l,i]=e.useState(!0),[o,d]=e.useState(!1),[c,u]=e.useState(null),[m,x]=e.useState(!0),h=e.useRef(null),b=e.useRef(!1),f=e.useRef(0),p=e.useCallback(async()=>{const e=++f.current;h.current=null,i(!0),u(null),x(!0);try{const[{articles:r,lastDoc:a,hasMore:l},i]=await Promise.all([K(t,null),F(t)]);if(e!==f.current)return;s($(r)),h.current=a,x(l),n(i)}catch(r){if(e!==f.current)return;u(r instanceof Error?r.message:"Failed to load news"),s([]),x(!1)}finally{e===f.current&&i(!1)}},[t]),g=e.useCallback(async()=>{if(b.current||!m||o)return;const e=h.current;if(!e)return;b.current=!0,d(!0);const r=f.current;try{const{articles:a,lastDoc:n,hasMore:l}=await K(t,e);if(r!==f.current)return;s(e=>$([...e,...a])),h.current=n,x(l)}catch(a){if(r!==f.current)return;u(a instanceof Error?a.message:"Failed to load more")}finally{b.current=!1,d(!1)}},[t,m,o]);return e.useEffect(()=>(p(),()=>{f.current++}),[p]),{articles:r,meta:a,loading:l,loadingMore:o,error:c,hasMore:m,loadMore:g,retry:p,pageSize:20}}(t),[N,k]=e.useState(""),v=e.useRef(null);e.useEffect(()=>{k("")},[t]);const y=e.useMemo(()=>function(e,t){const r=t.trim();return r?e.filter(e=>function(e,t){const r=t.trim().toLowerCase();return!r||e.title.toLowerCase().includes(r)||e.text.toLowerCase().includes(r)}(e,r)):e}(x,N),[x,N]),S=N.trim().length>0;e.useEffect(()=>{const e=v.current;if(!e||!g||b||f)return;const t=new IntersectionObserver(e=>{e[0]?.isIntersecting&&w()},{rootMargin:"200px"});return t.observe(e),()=>t.disconnect()},[g,b,f,w]);const C=`${c}${n?.route??u.MARKET_NEWS}`;return r.jsxs("main",{className:"pt-24 sm:pt-28 pb-20",children:[r.jsxs("div",{className:"page-shell-inner",children:[r.jsxs("nav",{className:"mb-6 flex flex-wrap items-center gap-2 text-sm text-slate-500 dark:text-zinc-400",children:[r.jsx(s,{to:u.HOME,className:"transition-colors hover:text-brand",children:"Home"}),r.jsx("span",{children:"/"}),r.jsx("span",{className:"text-slate-800 dark:text-zinc-200",children:a(l,{defaultValue:d})})]}),r.jsxs("div",{className:"mb-6 flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-y-2 sm:flex-row sm:items-baseline sm:gap-x-4 lg:gap-x-6",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(L,{className:"h-8 w-8 shrink-0 text-brand","aria-hidden":!0}),r.jsx("h1",{className:"text-3xl font-black text-slate-900 dark:text-white sm:text-4xl",children:a(l,{defaultValue:d})})]}
1),r.jsx("p",{className:"min-w-0 flex-1 text-slate-600 dark:text-zinc-400 sm:text-base lg:whitespace-nowrap",children:a(i,{defaultValue:""})})]}),r.jsx(D,{feed:t})]}),!b&&!p&&x.length>0?r.jsx(T,{value:N,onChange:k,resultCount:y.length,totalLoaded:x.length}):null,b?r.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3",children:Array.from({length:6}).map((e,t)=>r.jsx(H,{},t))}):p?r.jsxs("div",{className:"rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-800 dark:border-rose-900/50 dark:bg-rose-950/30 dark:text-rose-300",children:[r.jsx("p",{className:"font-medium",children:p}),r.jsx("button",{type:"button",onClick:()=>{j()},className:"mt-2 text-xs font-semibold underline hover:no-underline",children:a("marketMap.retry",{defaultValue:"Retry"})})]}):0===x.length?r.jsxs("div",{className:"flex flex-col items-center py-20 text-center",children:[r.jsx(L,{className:"mb-4 h-12 w-12 text-slate-300 dark:text-zinc-600","aria-hidden":!0}),r.jsx("p",{className:"max-w-md text-slate-600 dark:text-zinc-400",children:h?.lastError?a("marketNews.emptySyncError",{error:h.lastError}):a(h?.lastSyncAt?"marketNews.emptyAfterSync":"marketNews.emptyNotSynced")}),h?.lastSyncAt?null:r.jsx("p",{className:"mt-3 max-w-lg text-xs text-slate-500 dark:text-zinc-500",children:a("marketNews.emptyHint")}),r.jsx("button",{type:"button",onClick:()=>{j()},className:"mt-4 rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm font-semibold text-slate-800 shadow-sm hover:border-brand hover:text-brand dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200",children:a("marketMap.retry",{defaultValue:"Retry"})})]}):0===y.length&&S?r.jsxs("div",{className:"flex flex-col items-center py-16 text-center",children:[r.jsx(E,{className:"mb-4 h-10 w-10 text-zinc-600","aria-hidden":!0}),r.jsx("p",{className:"max-w-md text-zinc-400",children:a("marketNews.searchNoResults",{defaultValue:"No articles match your search."})}),r.jsx("button",{type:"button",onClick:()=>k(""),className:"mt-4 rounded-lg border border-zinc-700 bg-zinc-900 px-4 py-2 text-sm font-semibold text-zinc-200 hover:border-brand hover:text-brand",children:a("marketNews.searchClear",{defaultValue:"Clear search"})}),g?r.jsx("p",{className:"mt-3 max-w-md text-xs text-zinc-500",children:a("marketNews.searchLoadMoreHint",{defaultValue:"Try loading more articles, then search again."})}):null]}):r.jsxs(r.Fragment,{children:[r.jsx(U,{articles:y}),r.jsx("div",{ref:v,className:"h-4 w-full","aria-hidden":!0}),f?r.jsx("div",{className:"mt-8 flex justify-center",children:r.jsx(m,{size:"sm"})}):null,g&&!f?r.jsx("div",{className:"mt-8 flex justify-center",children:r.jsx("button",{type:"button",onClick:()=>{w()},className:"rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm font-semibold text-slate-800 shadow-sm hover:border-brand hover:text-brand dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200",children:a("marketNews.loadMore")})}):null]})]}),r.jsx("span",{className:"sr-only",children:C})]})};function U({articles:e}){return r.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3",children:e.map(e=>r.jsx(I,{article:e},`${e.id}:${e.url}`))})}const W=()=>{const{t:e}=z(),{feedSlug:t}=a(),s=x(t);if(t&&null===s)return r.jsx(n,{to:u.MARKET_NEWS,replace:!0});const i=s??"general",d=o(i),m=`${c}${d?.route??u.MARKET_NEWS}`;return r.jsxs(r.Fragment,{children:[r.jsxs(h,{className:"min-h-screen bg-gradient-to-b from-zinc-950 via-[#080a0f] to-zinc-950 text-slate-100",children:[r.jsx(l,{title:e(d?.seoTitleKey??"marketNews.general.seoTitle"),description:e(d?.seoDescriptionKey??"marketNews.general.seoDescription"),url:m,keywords:e("marketNews.seoKeywords"),noindex:!0}),r.jsx(O,{feed:i})]}),r.jsx(y,{})]})};export{W as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.