PageSourceSearch

https://docs.jackofalltrades.vip/assets/EconomicCalendar-B_ZlFMbk.js

js jackofalltrades.vip collected 2026-10-05 23:20:53 UTC 65,992 bytes, 1 lines download raw bytes

1import{a as x,ds as Le,dt as Ie,du as U,dv as R,dw as Be,dx as Te,bt as N,bK as oe,dy as tt,dz as st,dA as rt,dB as at,j as e,c4 as ie,au as H,aB as le,by as nt,ai as de,b1 as ce,b2 as He,X as Ce,bL as ot,bM as re,bX as it,G as Ue,dC as Re,dD as j,h as ae,bs as q,dE as De,dF as lt,dG as $e,aq as dt,dH as ct,bN as mt}from"./react-vendor-BgvAkfnX.js";import{k as ut}from"./query-vendor-DH5fvvGG.js";import{g as Pe,t as xt,T as pt,x as F,y as X,z as G,A as ht,m as me,B as W,c as T,v as p}from"./index-B3VS6zto.js";import{B as gt}from"./badge-DJDNkmCG.js";import{S as ft,b as bt,d as jt,c as Nt,e as yt}from"./sheet-ZREPdRom.js";import{u as wt}from"./use-reduced-motion-DtoDKt3c.js";import"./radix-vendor-BA32w1ww.js";const ue=[.2,.65,.3,.9],St=["high","medium","low"],vt=["US","EU","GB","JP","CN","CA","AU","CH"],kt=["USD","EUR","GBP","JPY","CNY","CAD","AUD","CHF"],Lt=["inflation","employment","central_bank","gdp","pmi","consumer","housing","trade"],K={inflation:"Inflation",employment:"Employment",central_bank:"Central Bank",gdp:"GDP",pmi:"PMI",consumer:"Consumer",housing:"Housing",trade:"Trade",other:"Other"};function xe(t){if(t.actual===null)return null;const s=t.forecast??t.previous;if(s===null)return null;const a=t.actual-s,i=Math.max(.001,Math.abs(s)*5e-4);if(Math.abs(a)<i)return"IN-LINE";const r=new Set(["inflation","central_bank"]),l=/jobless/i.test(t.event),n=/unemployment\s*rate/i.test(t.event);return r.has(t.category)||l||n?a<0?"BEAT":"MISS":a>0?"BEAT":"MISS"}function Oe(t){if(t.actual===null)return null;const s=t.forecast??t.previous;if(s===null)return null;const a=t.actual-s,i=Math.max(.001,Math.abs(s)*5e-4),r=t.currency||"Currency",l=Math.abs(a)<i,n=t.forecast!==null?"forecast":"prior";if(l)return{primaryLabel:r,primary:"NEUTRAL",riskAssets:"NEUTRAL",bonds:"NEUTRAL",gold:"NEUTRAL",reasoning:`In line with ${n} (${s}); muted reaction across asset classes.`};const o=a>0,c=/jobless/i.test(t.event),d=/unemployment\s*rate/i.test(t.event);return t.category==="inflation"?o?{primaryLabel:r,primary:"BULLISH",riskAssets:"BEARISH",bonds:"BEARISH",gold:"BEARISH",reasoning:`Hotter than ${n} → hawkish for ${r}, headwind for risk and bonds.`}:{primaryLabel:r,primary:"BEARISH",riskAssets:"BULLISH",bonds:"BULLISH",gold:"BULLISH",reasoning:`Softer than ${n} → dovish for ${r}, supportive for risk and bonds.`}:t.category==="central_bank"?o?{primaryLabel:r,primary:"BULLISH",riskAssets:"BEARISH",bonds:"BEARISH",gold:"BEARISH",reasoning:`Hawkish surprise vs ${n} → ${r} firmer, risk-off pressure.`}:{primaryLabel:r,primary:"BEARISH",riskAssets:"BULLISH",bonds:"BULLISH",gold:"BULLISH",reasoning:`Dovish surprise vs ${n} → ${r} weaker, risk-on bid.`}:c?o?{primaryLabel:r,primary:"BEARISH",riskAssets:"BEARISH",bonds:"BULLISH",gold:"BULLISH",reasoning:`Higher claims vs ${n} → soft labor, ${r} weaker, bonds bid.`}:{primaryLabel:r,primary:"BULLISH",riskAssets:"BULLISH",bonds:"BEARISH",gold:"BEARISH",reasoning:`Lower claims vs ${n} → tight labor, ${r} firmer, yields up.`}:d?o?{primaryLabel:r,primary:"BEARISH",riskAssets:"BEARISH",bonds:"BULLISH",gold:"BULLISH",reasoning:`Higher unemployment vs ${n} → labor weakness, ${r} weaker.`}:{primaryLabel:r,primary:"BULLISH",riskAssets:"BULLISH",bonds:"BEARISH",gold:"BEARISH",reasoning:`Lower unemployment vs ${n} → tight labor, ${r} firmer.`}:t.category==="employment"?o?{primaryLabel:r,primary:"BULLISH",riskAssets:"BULLISH",bonds:"BEARISH",gold:"BEARISH",reasoning:`Strong jobs print vs ${n} → ${r} firmer, equities supported, yields up.`}:{primaryLabel:r,primary:"BEARISH",riskAssets:"BEARISH",bonds:"BULLISH",gold:"BULLISH",reasoning:`Weak jobs print vs ${n} → ${r} weaker, equities under pressure, bonds bid.`}:t.category==="trade"?o?{primaryLabel:r,primary:"BULLISH",riskAssets:"NEUTRAL",bonds:"NEUTRAL",gold:"NEUTRAL",reasoning:`Better trade balance vs ${n} → ${r} firmer.`}:{primaryLabel:r,primary:"BEARISH",riskAssets:"NEUTRAL",bonds:"NEUTRAL",gold:"NEUTRAL",reasoning:`Worse trade balance vs ${n} → ${r} softer.`}:o?{primaryLabel:r,primary:"BULLISH",riskAssets:"BULLISH",bonds:"BEARISH",gold:"BEARISH",reasoning:`Stronger than ${n} → ${r} firmer, risk-on, yields up.`}:{primaryLabel:r,primary:"BEARISH",riskAssets:"BEARISH",bonds:"BULLISH",gold:"BULLISH",reasoning:`Weaker than ${n} → ${r} softer, defensive bid in bonds and gold.`}}function Fe(t){return t==="high"?10:t==="medium"?6:t==="low"?3:0}function It(t){return t.changePercentage!==null&&!Number.isNaN(t.changePercentage)?Math.min(10,Math.max(1,Math.round(Math.abs(t.changePercentage)/5))):Fe(t.impact)}function L(t){if(t==null||Number.isNaN(t))return"—";const s=Math.abs(t);return s>=1e9?`${(t/1e9).toFixed(2)}B`:s>=1e6?`${(t/1e6).toFixed(2)}M`:s>=1e3?`${(t/1e3).toFixed(2)}K`:s>=100?t.toFixed(1):s>=1?t.toFixed(2):t.toFixed(3)}function At(t,s){if(t.actual===null)return!1;const a=j(t.date);return a<=s&&ct(s,a)<24}function Xe(t){return t==="high"?"bg-red-400":t==="medium"?"bg-amber-400":t==="low"?"bg-zinc-500":"bg-zinc-700"}function ne(t){return t==="high"?"HIGH":t==="medium"?"MED":t==="low"?"LOW":"—"}function Ae(t){const s=j(t.date),a=s.getUTCHours()+s.getUTCMinutes()/60;return a<13.5?"pre":a<20?"regular":"after"}const Et={pre:"Pre-Market",regular:"Regular Hours",after:"After-Hours"},Mt=()=>e.jsxs("div",{className:"flex items-center gap-3 text-[10px] uppercase tracking-wider text-muted-foreground
1/70",children:[e.jsx("span",{className:"font-bold tracking-[0.18em]",children:"Impact"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-red-400"}),"High"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-400"}),"Med"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-500"}),"Low"]})]});function Bt(t){if(t<=0)return"0s";const s=Math.floor(t/1e3),a=Math.floor(s/86400),i=Math.floor(s%86400/3600),r=Math.floor(s%3600/60),l=s%60;return a>0?`${a}d ${i}h ${r}m`:i>0?`${i}h ${r}m ${l.toString().padStart(2,"0")}s`:r>0?`${r}m ${l.toString().padStart(2,"0")}s`:`${l}s`}const Tt=({events:t,globalNext:s,now:a,onSelectEvent:i})=>{const r=x.useMemo(()=>{const o=t.filter(c=>c.impact==="high"&&c.actual===null&&j(c.date).getTime()>a.getTime()).sort((c,d)=>j(c.date).getTime()-j(d.date).getTime());return o[0]?o[0]:s&&j(s.date).getTime()>a.getTime()?s:null},[t,s,a]);if(!r)return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-white/[0.06] bg-white/[0.02] px-3 py-2",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(ae,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"hidden text-[10px] font-bold uppercase tracking-[0.18em] text-muted-foreground sm:inline",children:"Next High-Impact"})]}),e.jsxs("span",{className:"truncate text-[11px] text-muted-foreground/70",children:[e.jsx("span",{className:"hidden sm:inline",children:"None upcoming in this view — "}),"click ▶ for next week"]})]});const l=j(r.date).getTime()-a.getTime(),n=l<60*60*1e3;return e.jsxs("button",{type:"button",onClick:()=>i(r),className:p("group flex w-full items-center justify-between gap-3 rounded-lg border px-3 py-2 text-left transition-all duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500/40",n?"border-orange-500/40 bg-orange-500/[0.06] hover:border-orange-500/60 hover:bg-orange-500/[0.10]":"border-white/[0.06] bg-white/[0.02] hover:border-white/15 hover:bg-white/[0.04]"),children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(ae,{className:p("h-3.5 w-3.5 shrink-0",n?"text-orange-400":"text-muted-foreground")}),e.jsx("span",{className:p("hidden text-[10px] font-bold uppercase tracking-[0.18em] sm:inline",n?"text-orange-300":"text-muted-foreground"),children:"Next High-Impact"})]}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 pl-1 sm:pl-2",children:[e.jsx(J,{code:r.country}),e.jsx("span",{className:"truncate text-[11px] font-medium text-foreground/90 group-hover:text-foreground",children:r.event})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 font-mono",children:[e.jsx("span",{className:p("text-[11px] font-bold tabular-nums",n?"text-orange-300":"text-foreground/80"),children:Bt(l)}),e.jsx(Ue,{className:p("h-3 w-3 transition-transform group-hover:translate-x-0.5",n?"text-orange-400":"text-muted-foreground")})]})]})};function Ht(t,s){const a=t.filter(c=>$e(j(c.date),s)),i=a.filter(c=>c.impact==="high").length,r=a.filter(c=>c.impact==="medium").length,l=new Map;for(const c of a)l.set(c.category,(l.get(c.category)||0)+1);const n=a.filter(c=>c.impact==="high"||c.impact==="medium");let o=null;if(n.length>=2){const c=n.slice().sort((g,u)=>j(g.date).getTime()-j(u.date).getTime());let d=0,f=c[0];for(const g of c){const u=j(g.date).getTime(),m=u+3*60*60*1e3,b=c.filter(y=>{const v=j(y.date).getTime();return v>=u&&v<=m}).length;b>d&&(d=b,f=g)}if(d>=2){const g=j(f.date).getTime();o={startUtc:N(new Date(g),"HH:mm"),endUtc:N(new Date(g+3*60*60*1e3),"HH:mm"),eventCount:d}}}return{total:a.length,high:i,medium:r,byCategory:l,volatilityWindow:o,hasContent:a.length>0}}const Ct=({events:t,anchor:s})=>{const[a,i]=x.useState(!1),r=x.useMemo(()=>Ht(t,s),[t,s]),l=q(s)?"Today":N(s,"EEE, MMM d");if(!r.hasContent)return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-white/[0.06] bg-white/[0.02] px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-3 w-3 text-muted-foreground"}),e.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:[l," · Daily Brief"]})]}
1),e.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"Quiet day — no scheduled releases"})]});const n=Array.from(r.byCategory.entries()).sort((o,c)=>c[1]-o[1]).slice(0,3);return e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-3 py-2",children:[e.jsxs("button",{type:"button",onClick:()=>i(o=>!o),className:"flex w-full items-center justify-between gap-2 text-left","aria-expanded":!a,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-3 w-3 text-orange-400"}),e.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em] text-orange-300/85",children:[l," · Daily Brief"]})]}),e.jsxs("span",{className:"font-mono text-[10px] tabular-nums text-muted-foreground",children:[r.total," events · ",r.high," high · ",r.medium," med"]})]}),!a&&e.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-white/[0.04] pt-2 text-[11px] leading-relaxed text-foreground/75",children:[n.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[10px]",children:[e.jsx("span",{className:"text-muted-foreground",children:"Mix:"}),n.map(([o,c])=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-bold tabular-nums text-foreground/80",children:c}),e.jsx("span",{className:"text-muted-foreground/80",children:K[o].toLowerCase()})]},o))]}),r.volatilityWindow&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx(le,{className:"h-3 w-3 text-orange-400"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Volatility cluster: "}),e.jsxs("span",{className:"font-mono font-bold text-foreground/90",children:[r.volatilityWindow.startUtc,"–",r.volatilityWindow.endUtc," UTC"]})," ",e.jsxs("span",{className:"text-muted-foreground",children:["(",r.volatilityWindow.eventCount," releases in 3h)"]})]})]}),!r.volatilityWindow&&r.high===0&&e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Quiet day — no high-impact prints scheduled."})]})]})},_=({active:t,onClick:s,children:a})=>e.jsx("button",{type:"button",role:"button","aria-pressed":t,onClick:s,className:p("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-[11px] font-medium uppercase tracking-wide transition-all duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40",t?"border-amber-500/40 bg-amber-500/[0.14] text-amber-300":"border-white/10 bg-transparent text-muted-foreground hover:border-white/20 hover:text-foreground"),children:a}),J=({code:t,size:s="sm"})=>{const a=(t||"—").toUpperCase().slice(0,2);return e.jsx("span",{className:p("inline-flex items-center justify-center rounded border border-white/10 bg-white/[0.03] font-mono font-semibold tracking-wide text-foreground/80",s==="sm"?"h-4 min-w-[20px] px-1 text-[9px]":"h-5 min-w-[24px] px-1.5 text-[10px]"),children:a})},Ee=({filled:t,total:s=10,color:a="bg-amber-400"})=>e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:s}).map((i,r)=>e.jsx("div",{className:p("h-1.5 w-1.5 rounded-full transition-colors",r<t?a:"bg-white/[0.06]")},r))}),pe=({result:t,size:s="sm"})=>{if(!t)return null;const a=s==="sm";return t==="BEAT"?e.jsxs("span",{className:p("inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded border border-emerald-500/30 bg-emerald-500/10 font-bold uppercase tracking-wider text-emerald-300",a?"px-1.5 py-0.5 text-[9px]":"px-2 py-1 text-[11px]"),children:[e.jsx(de,{className:a?"h-2.5 w-2.5":"h-3 w-3"}),"BEAT"]}):t==="MISS"?e.jsxs("span",{className:p("inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded border border-red-500/30 bg-red-500/10 font-bold uppercase tracking-wider text-red-300",a?"px-1.5 py-0.5 text-[9px]":"px-2 py-1 text-[11px]"),children:[e.jsx(ce,{className:a?"h-2.5 w-2.5":"h-3 w-3"}),"MISS"]}):e.jsxs("span",{className:p("inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded border border-white/15 bg-white/[0.04] font-bold uppercase tracking-wider text-foreground/70",a?"px-1.5 py-0.5 text-[9px]":"px-2 py-1 text-[11px]"),children:[e.jsx(H,{className:a?"h-2.5 w-2.5":"h-3 w-3"}),"IN-LINE"]})},Ge={BULLISH:{className:"text-emerald-300",Icon:de,label:"BULLISH"},BEARISH:{className:"text-red-300",Icon:ce,label:"BEARISH"}
1,NEUTRAL:{className:"text-foreground/55",Icon:mt,label:"NEUTRAL"}},z=({label:t,direction:s})=>{const a=Ge[s];return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:t}),e.jsxs("span",{className:p("inline-flex items-center gap-1.5 font-mono text-[11px] font-bold tracking-wider",a.className),children:[e.jsx(a.Icon,{className:"h-3 w-3"}),a.label]})]})},Ut=({event:t})=>{const s=x.useMemo(()=>Oe(t),[t]);return s?e.jsxs("div",{className:"mt-3 rounded-lg border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"Market Reaction"}),e.jsx("span",{className:"text-[9px] uppercase tracking-wider text-muted-foreground/60",children:"Directional outlook"})]}),e.jsxs("div",{className:"divide-y divide-white/[0.04]",children:[e.jsx(z,{label:s.primaryLabel,direction:s.primary}),e.jsx(z,{label:"Risk Assets (SPY / BTC)",direction:s.riskAssets}),e.jsx(z,{label:"Treasuries / Bonds",direction:s.bonds}),e.jsx(z,{label:"Gold (XAU)",direction:s.gold})]}),e.jsx("p",{className:"mt-2 border-t border-white/[0.04] pt-2 text-[11px] italic leading-relaxed text-foreground/70",children:s.reasoning})]}):null},Rt=["BIG_BEAT","SMALL_BEAT","INLINE","SMALL_MISS","BIG_MISS"],Dt={BIG_BEAT:{label:"Big Beat",tone:"emerald"},SMALL_BEAT:{label:"Small Beat",tone:"emerald-soft"},INLINE:{label:"In-Line",tone:"zinc"},SMALL_MISS:{label:"Small Miss",tone:"red-soft"},BIG_MISS:{label:"Big Miss",tone:"red"}};function $t(t){if(t.actual===null)return"INLINE";const s=t.forecast??t.previous;if(s===null)return"INLINE";const a=t.actual-s,i=Math.max(.001,Math.abs(s)*5e-4);if(Math.abs(a)<i)return"INLINE";const l=Math.abs(a)/Math.max(Math.abs(s),.001)>.01,n=new Set(["inflation","central_bank"]),o=/jobless/i.test(t.event),c=/unemployment\s*rate/i.test(t.event);return(n.has(t.category)||o||c?a<0:a>0)?l?"BIG_BEAT":"SMALL_BEAT":l?"BIG_MISS":"SMALL_MISS"}function Pt(t){const s=t.currency||"USD";return s==="USD"?"SPX":s==="EUR"?"EUR/USD":s==="GBP"?"GBP/USD":s==="JPY"?"USD/JPY":s==="CAD"?"USD/CAD":s==="AUD"?"AUD/USD":s==="CHF"?"USD/CHF":s==="CNY"?"CNH":"SPX"}function Ot(t,s){const a=t.currency||"USD",i=a==="USD",r=Pt(t);s==="BIG_BEAT"?`${t.event}: large beat — strong directional follow-through`:s==="SMALL_BEAT"?`${t.event}: modest beat — bias to upside, watch for fade`:s==="INLINE"?`${t.event}: in-line — no directional edge, range expected`:s==="SMALL_MISS"?`${t.event}: modest miss — bias to downside, watch for buyers`:`${t.event}: large miss — strong directional reversal`;const l=Oe(t),n=s==="BIG_BEAT"||s==="BIG_MISS"?"1.5:1":s==="INLINE"?"1:1":"1.3:1",o={side:"BULLISH",rr:n,trigger:s==="INLINE"?`Confirmed break above pre-event session high on ${r}`:(l==null?void 0:l.riskAssets)==="BULLISH"?`Follow-through above pre-event high on ${r}`:`Counter-trend rally above session high on ${r}`,entry:`Break above pre-event session high (${r})`,stop:"Pre-event session low — buffer 0.3-0.5%",target:"1.5R from entry, or recent swing high",invalidation:"Failure to hold entry on close, or reversal below mid-range"},c={side:"BEARISH",rr:n,trigger:s==="INLINE"?`Confirmed break below pre-event session low on ${r}`:(l==null?void 0:l.riskAssets)==="BEARISH"?`Follow-through below pre-event low on ${r}`:`Counter-trend fade below session low on ${r}`,entry:`Break below pre-event session low (${r})`,stop:"Pre-event session high — buffer 0.3-0.5%",target:"1.5R from entry, or recent swing low",invalidation:"Reclaim of entry on close, or reversal above mid-range"},d=t.category==="inflation"?i?{onBeat:"SHORT DXY · LONG XAUUSD · LONG SPX",onMiss:"LONG DXY · SHORT XAUUSD · CAUTIOUS SPX"}:{onBeat:`SHORT ${a} · LONG XAUUSD`,onMiss:`LONG ${a} · SHORT XAUUSD`}:t.category==="central_bank"?i?{onBeat:"SHORT DXY · LONG TLT · LONG XAUUSD",onMiss:"LONG DXY · SHORT TLT · SHORT XAUUSD"}:{onBeat:`SHORT ${a} · LONG bond proxy`,onMiss:`LONG ${a} · SHORT bond proxy`}:t.category==="employment"?i?{onBeat:"LONG DXY · LONG SPX · SHORT TLT",onMiss:"SHORT DXY · SHORT SPX · LONG TLT"}:{onBeat:`LONG ${a} · LONG local equities`,onMiss:`SHORT ${a} · LONG safe havens`}:i?{onBeat:"LONG DXY · LONG SPX",onMiss:"SHORT DXY · LONG XAUUSD"}:{onBeat:`LONG ${a} · LONG local equities`,onMiss:`SHORT ${a} · CAUTION on risk`},m=s==="BIG_BEAT"||s==="SMALL_BEAT"?t.category==="inflation"?[{asset:"SPX",verdict:"Initial pop on dovish print",tone:"BULLISH"}
1,{asset:"DXY",verdict:"Weakens on dovish surprise",tone:"BEARISH"},{asset:"XAUUSD",verdict:"Catches bid on softer yields",tone:"BULLISH"}]:t.category==="central_bank"?[{asset:"SPX",verdict:"Risk-on bid on dovish surprise",tone:"BULLISH"},{asset:"DXY",verdict:"Weak on dovish hold",tone:"BEARISH"},{asset:"XAUUSD",verdict:"Bid as yields fall",tone:"BULLISH"}]:t.category==="employment"?[{asset:"SPX",verdict:"Strong jobs supports equities",tone:"BULLISH"},{asset:"DXY",verdict:"Dollar firms on tight labor",tone:"BULLISH"},{asset:"TLT",verdict:"Bonds sell as yields rise",tone:"BEARISH"}]:[{asset:"SPX",verdict:"Risk-on bid on strong print",tone:"BULLISH"},{asset:"DXY",verdict:"Dollar firmer",tone:"BULLISH"},{asset:"XAUUSD",verdict:"Pressured by yields",tone:"BEARISH"}]:s==="BIG_MISS"||s==="SMALL_MISS"?t.category==="inflation"?[{asset:"SPX",verdict:"Pressure on hot print",tone:"BEARISH"},{asset:"DXY",verdict:"Bid on hawkish surprise",tone:"BULLISH"},{asset:"XAUUSD",verdict:"Headwind from rising yields",tone:"BEARISH"}]:t.category==="central_bank"?[{asset:"SPX",verdict:"Risk-off on hawkish hold",tone:"BEARISH"},{asset:"DXY",verdict:"Strong dollar bid",tone:"BULLISH"},{asset:"XAUUSD",verdict:"Yield headwind",tone:"BEARISH"}]:t.category==="employment"?[{asset:"SPX",verdict:"Weak print pressures equities",tone:"BEARISH"},{asset:"DXY",verdict:"Soft dollar on weak labor",tone:"BEARISH"},{asset:"TLT",verdict:"Bonds rally on slowdown",tone:"BULLISH"}]:[{asset:"SPX",verdict:"Risk-off on weak print",tone:"BEARISH"},{asset:"DXY",verdict:"Dollar softer",tone:"BEARISH"},{asset:"XAUUSD",verdict:"Safe-haven bid",tone:"BULLISH"}]:[{asset:"SPX",verdict:"Range-bound, no directional edge",tone:"NEUTRAL"},{asset:"DXY",verdict:"Drift on tape, watch follow-up data",tone:"NEUTRAL"},{asset:"XAUUSD",verdict:"Choppy; key levels intact",tone:"NEUTRAL"}],b=(()=>{const y=s==="BIG_BEAT"?"decisively beats":s==="SMALL_BEAT"?"modestly beats":s==="INLINE"?"prints in line with":s==="SMALL_MISS"?"modestly misses":"decisively misses";return l?`If ${t.event} ${y} ${t.forecast!==null?"the forecast":"prior"}, expect ${l.reasoning.toLowerCase()}`:`Watch the print vs ${t.forecast!==null?"forecast":"previous"} for directional edge on ${r}.`})();return{primaryAsset:r,bullish:o,bearish:c,alternatives:d,implications:m,summary:b}}const Ft=({scenario:t,active:s,onSelect:a})=>{const i=Dt[t],r={emerald:"border-emerald-500/40 text-emerald-300","emerald-soft":"border-emerald-500/25 text-emerald-300/85",zinc:"border-white/15 text-foreground/70","red-soft":"border-red-500/25 text-red-300/85",red:"border-red-500/40 text-red-300"},l={emerald:"bg-emerald-500/[0.12]","emerald-soft":"bg-emerald-500/[0.06]",zinc:"bg-white/[0.04]","red-soft":"bg-red-500/[0.06]",red:"bg-red-500/[0.12]"};return e.jsx("button",{type:"button",onClick:()=>a(t),"aria-pressed":s,className:p("flex-1 rounded-md border px-2 py-1.5 text-center font-mono text-[10px] font-bold uppercase tracking-wider transition-all duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40",r[i.tone],s?l[i.tone]:"bg-transparent hover:"+l[i.tone].replace(/\/\[0\.0?6\]/,"/[0.04]"),s&&"ring-1 ring-inset ring-current/30"),children:i.label})},Me=({setup:t})=>{const s=t.side==="BULLISH";return e.jsxs("div",{className:p("rounded-lg border p-3",s?"border-emerald-500/25 bg-emerald-500/[0.03]":"border-red-500/25 bg-red-500/[0.03]"),children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{className:p("flex items-center gap-1.5 font-mono text-[11px] font-bold tracking-wider",s?"text-emerald-300":"text-red-300"),children:[e.jsx("span",{className:p("h-1.5 w-1.5 rounded-full",s?"bg-emerald-400":"bg-red-400")}),t.side]}),e.jsxs("span",{className:"font-mono text-[10px] tabular-nums text-foreground/60",children:["R/R ",t.rr]})]}),e.jsxs("div",{className:"space-y-1 text-[11px] leading-relaxed text-foreground/80",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Trigger: "}),e.jsx("span",{className:"font-medium",children:t.trigger})]}),e.jsx("p",{className:"flex flex-wrap gap-x-3 gap-y-0.5 font-mono text-[10px] tabular-nums",children:e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Entry: "}),t.entry]})}),e.jsx("p",{className:"flex flex-wrap gap-x-3 gap-y-0.5 font-mono text-[10px] tabular-nums",children:e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Stop: "}),e.jsx("span",{className:"text-red-300/80",children:t.stop})]})}),e.jsx("p",{className:"flex flex-wrap gap-x-3 gap-y-0.5 font-mono text-[10px] tabular-nums",children:e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Target: "}),e.jsx("span",{className:"text-emerald-300/80",children:t.target})]})}),e.jsxs("p",{className:"flex items-start gap-1.5 pt-1 text-[10px] italic text-amber-300/70",children:[e.jsx(H,{className:"mt-[1px] h-2.5 w-2.5 shrink-0"}
1),e.jsx("span",{children:t.invalidation})]})]})]})},Xt=({implication:t})=>{const s=Ge[t.tone];return e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] p-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between pb-1",children:[e.jsx("span",{className:"font-mono text-[10px] font-bold uppercase tracking-wider text-foreground/70",children:t.asset}),e.jsx(s.Icon,{className:p("h-3 w-3",s.className)})]}),e.jsx("p",{className:p("text-[11px] font-medium leading-snug",s.className),children:t.verdict})]})},Gt=({event:t})=>{var r,l;const s=oe({queryKey:["economic-calendar-history",t.event,t.country],queryFn:async()=>{const n=new URLSearchParams({event:t.event,country:t.country||"",limit:"6"}),o=await T(`/api/economic-calendar/history?${n.toString()}`);if(!o.ok)throw new Error(`HTTP ${o.status}`);return await o.json()},staleTime:36e5,retry:1});if(s.isLoading)return e.jsxs("div",{className:"mt-3 rounded-lg border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsx("div",{className:"pb-2",children:e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em] text-orange-300/85",children:"Historical Reaction"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"h-3 animate-pulse rounded bg-white/[0.04]"}),e.jsx("div",{className:"h-3 w-5/6 animate-pulse rounded bg-white/[0.04]"})]})]});const a=((r=s.data)==null?void 0:r.rows)||[],i=(l=s.data)==null?void 0:l.stats;return a.length===0?null:e.jsxs("div",{className:"mt-3 rounded-lg border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em] text-orange-300/85",children:"Historical Reaction"}),e.jsxs("span",{className:"font-mono text-[10px] tabular-nums text-muted-foreground",children:["Last ",a.length," prints"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 pb-2.5",children:[a.slice().reverse().map((n,o)=>{const c=n.result==="BEAT"?"border-emerald-500/40 bg-emerald-500/15 text-emerald-300":n.result==="MISS"?"border-red-500/40 bg-red-500/15 text-red-300":"border-white/15 bg-white/[0.04] text-foreground/60",d=n.result==="BEAT"?"B":n.result==="MISS"?"M":n.result==="IN-LINE"?"—":"?";return e.jsx("span",{className:p("inline-flex h-5 w-5 items-center justify-center rounded border font-mono text-[9px] font-bold",c),title:`${N(j(n.date),"MMM d yyyy")} — ${n.result||"no data"}`,children:d},`${n.date}-${o}`)}),i&&i.total>0&&e.jsxs("span",{className:"ml-auto font-mono text-[10px] tabular-nums text-foreground/70",children:[e.jsxs("span",{className:"text-emerald-300/85",children:[i.beats,"B"]}),e.jsx("span",{className:"px-1 text-muted-foreground/50",children:"·"}),e.jsxs("span",{className:"text-red-300/85",children:[i.misses,"M"]}),i.inLine>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"px-1 text-muted-foreground/50",children:"·"}),e.jsxs("span",{className:"text-foreground/60",children:[i.inLine,"≈"]})]}),e.jsx("span",{className:"px-1.5 text-muted-foreground/50",children:"|"}),e.jsxs("span",{className:p("font-bold",i.beatRate>=50?"text-emerald-300":"text-red-300"),children:[i.beatRate,"%"]}),e.jsx("span",{className:"pl-1 text-muted-foreground/70",children:"beat rate"})]})]}),e.jsxs("div",{className:"rounded border border-white/[0.04] bg-black/20",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-x-3 border-b border-white/[0.04] px-2.5 py-1 font-mono text-[9px] font-bold uppercase tracking-wider text-muted-foreground/60",children:[e.jsx("span",{children:"Date"}),e.jsx("span",{className:"text-right",children:"Prev"}),e.jsx("span",{className:"text-right",children:"Fcst"}),e.jsx("span",{className:"text-right",children:"Actual"})]}),a.map(n=>{const o=n.result==="BEAT",c=n.result==="MISS";return e.jsxs("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-x-3 border-b border-white/[0.03] px-2.5 py-1.5 font-mono text-[10px] tabular-nums last:border-b-0",children:[e.jsxs("span",{className:"text-foreground/70",children:[e.jsx("span",{className:"sm:hidden",children:N(j(n.date),"MMM d")}),e.jsx("span",{className:"hidden sm:inline",children:N(j(n.date),"MMM d, yyyy")})]}
1),e.jsx("span",{className:"text-right text-muted-foreground/70",children:n.previous!==null?L(n.previous):"—"}),e.jsx("span",{className:"text-right text-muted-foreground/70",children:n.forecast!==null?L(n.forecast):"—"}),e.jsx("span",{className:p("text-right font-bold",o&&"text-emerald-300",c&&"text-red-300",!o&&!c&&"text-foreground/80"),children:n.actual!==null?L(n.actual):"—"})]},n.date)})]})]})},_t=({event:t})=>{const s=x.useMemo(()=>$t(t),[t]),[a,i]=x.useState(s);x.useEffect(()=>{i(s)},[s,t.id]);const r=x.useMemo(()=>Ot(t,a),[t,a]),l="text-[10px] font-bold uppercase tracking-[0.18em] text-foreground/55",n="text-[9px] uppercase tracking-wider text-muted-foreground/60";return e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsx("span",{className:l,children:"Scenario Analysis"}),e.jsx("span",{className:n,children:a===s?"Auto-detected":"Custom"})]}),e.jsx("div",{className:"flex gap-1.5",children:Rt.map(o=>e.jsx(Ft,{scenario:o,active:a===o,onSelect:i},o))})]}),e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsx("span",{className:l,children:"Trade Setups"}),e.jsxs("span",{className:n,children:[r.primaryAsset," · directional"]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-1",children:[e.jsx(Me,{setup:r.bullish}),e.jsx(Me,{setup:r.bearish})]})]}),e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsx("div",{className:"pb-2",children:e.jsx("span",{className:l,children:"Alternative Trades"})}),e.jsxs("div",{className:"space-y-1 font-mono text-[11px]",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"shrink-0 text-emerald-300",children:"IF BEAT:"}),e.jsx("span",{className:"text-foreground/80",children:r.alternatives.onBeat})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"shrink-0 text-red-300",children:"IF MISS:"}),e.jsx("span",{className:"text-foreground/80",children:r.alternatives.onMiss})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsx("span",{className:l,children:"Market Implications"}),e.jsx("span",{className:n,children:"Cross-asset impact"})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:r.implications.map(o=>e.jsx(Xt,{implication:o},o.asset))})]}),e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsx("div",{className:"pb-1.5",children:e.jsx("span",{className:l,children:"Summary"})}),e.jsx("p",{className:"text-[11px] leading-relaxed text-foreground/80",children:r.summary})]})]})};function _e(){var c;const t=ot(),s=Pe(),a=!!(s!=null&&s.isAdmin||(s==null?void 0:s.plan)==="Elite"||(s==null?void 0:s.isSubscriber)===!0&&(s==null?void 0:s.plan)!=="Indicators"),i=oe({queryKey:["economic-calendar-watchlist"],queryFn:async()=>{const d=await T("/api/economic-calendar/watch");if(!d.ok)throw new Error(`HTTP ${d.status}`);return await d.json()},staleTime:30*1e3,retry:1,enabled:a}),r=x.useMemo(()=>{var f;const d=new Set;for(const g of((f=i.data)==null?void 0:f.items)||[])d.add(g.event_key);return d},[i.data]),l=re({mutationFn:async d=>{const f=await T("/api/economic-calendar/watch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventKey:d.id,event:d.event,country:d.country,currency:d.currency,date:d.date})});if(!f.ok){const g=await f.text().catch(()=>"");throw new Error(g||`HTTP ${f.status}`)}},onSuccess:()=>t.invalidateQueries({queryKey:["economic-calendar-watchlist"]})}),n=re({mutationFn:async d=>{const f=await T("/api/economic-calendar/watch",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventKey:d})});if(!f.ok)throw new Error(`HTTP ${f.status}`)},onSuccess:()=>
1t.invalidateQueries({queryKey:["economic-calendar-watchlist"]})}),o=x.useCallback(d=>{r.has(d.id)?n.mutate(d.id):l.mutate(d)},[r,l,n]);return{watched:r,toggle:o,isPending:l.isPending||n.isPending,items:((c=i.data)==null?void 0:c.items)||[]}}const ze=({event:t,size:s="sm"})=>{const{watched:a,toggle:i,isPending:r}=_e(),l=a.has(t.id);if(t.actual!==null)return null;const n=s==="sm",o=l?Re:dt;return e.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),r||i(t)},disabled:r,"aria-pressed":l,"aria-label":l?"Remove from watchlist":"Add to watchlist",title:l?"Remove from watchlist (30-min reminder cancelled)":"Add to watchlist (30-min reminder)",className:p("inline-flex items-center justify-center rounded transition-all duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500/40",n?"h-5 w-5 -m-0.5":"h-7 w-7",l?"text-orange-300 hover:text-orange-200":"text-muted-foreground/50 hover:text-foreground/80",r&&"opacity-60"),children:e.jsx(o,{className:n?"h-3 w-3":"h-4 w-4",fill:l?"currentColor":"none"})})},zt=({score:t})=>{if(t==null)return null;const s=Math.max(0,Math.min(5,Math.round(t/2))),a=t>=8;return e.jsxs("span",{className:p("inline-flex shrink-0 items-center gap-0.5 rounded border px-1 py-0.5 font-mono text-[8px] font-bold uppercase tracking-wider",a?"border-orange-500/30 text-orange-300":"border-white/10 text-foreground/55"),title:`Historical volatility: ${t}/10`,"aria-label":`Volatility ${t} out of 10`,children:["VOL",e.jsx("span",{className:"ml-0.5 inline-flex items-center gap-[1px]",children:[0,1,2,3,4].map(i=>e.jsx("span",{className:p("h-1 w-1 rounded-full",i<s?a?"bg-orange-400":"bg-orange-400/55":"bg-white/10")},i))})]})},Ye=({event:t,onClick:s,showStats:a=!1,monthMode:i=!1,now:r,justReleased:l=!1})=>{const n=xe(t),o=N(j(t.date),"HH:mm"),c=r?At(t,r):!1;return e.jsxs("div",{role:"button",tabIndex:0,onClick:s,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),s())},className:p("group flex w-full flex-col gap-1 rounded-md border border-white/[0.06] bg-white/[0.02] p-1.5 text-left transition-all duration-150 cursor-pointer","hover:border-white/15 hover:bg-white/[0.04]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40",c&&"border-amber-500/20 bg-amber-500/[0.025] hover:border-amber-500/35",l&&"ring-2 ring-cyan-400/50 animate-pulse"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:p("h-1.5 w-1.5 shrink-0 rounded-full",Xe(t.impact))}),e.jsx("span",{className:"font-mono text-[9px] tabular-nums text-muted-foreground",children:o}),e.jsx(J,{code:t.country}),n&&!i&&e.jsx("span",{className:"ml-auto",children:e.jsx(pe,{result:n})}),i&&n&&e.jsx("span",{className:p("ml-auto font-mono text-[9px] tabular-nums font-semibold",n==="BEAT"&&"text-emerald-300",n==="MISS"&&"text-red-300",n==="IN-LINE"&&"text-foreground/60"),children:t.actual!==null?L(t.actual):"—"}),t.actual===null&&e.jsx("span",{className:"ml-auto",children:e.jsx(ze,{event:t})})]}),e.jsx("div",{className:p("text-[11px] font-medium leading-tight text-foreground/90 group-hover:text-foreground",i?"line-clamp-1":"line-clamp-2"),children:t.event}),a&&!i&&e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 font-mono text-[9px] tabular-nums text-muted-foreground",children:[e.jsxs("span",{children:["P ",L(t.previous)]}),e.jsx("span",{className:"text-white/20",children:"·"}),e.jsxs("span",{children:["F ",L(t.forecast)]}),e.jsx("span",{className:"text-white/20",children:"·"}),e.jsxs("span",{className:p("font-semibold",n==="BEAT"&&"text-emerald-300",n==="MISS"&&"text-red-300",!n&&"text-foreground/70"),children:["A ",L(t.actual)]}),t.volatility!==null&&t.volatility!==void 0&&t.volatility>=6&&e.jsx("span",{className:"ml-auto",children:e.jsx(zt,{score:t.volatility})})]})]})},Yt=({impactFilter:t,countryFilter:s,currencyFilter:a,categoryFilter:i,starredOnly:r,watchedCount:l,onToggleImpact:n,onToggleCountry:o,onToggleCurrency:c,onToggleCategory:d,onToggleStarredOnly:f,onClear:g})=>{const u=t.size>0||s.size>0||a.size>0||i.size>0||r;return e.jsxs("div",{className:"space-y-2.5 rounded-xl border border-border/40 bg-card/60 p-3 backdrop-blur-2xl sm:p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(He,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground",children:"Filters"}),e.jsxs("button",{type:"button",onClick:f,"aria-pressed":r,className:p("inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide transition-all duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500/40",r?"border-orange-500/40 bg-orange-500/[0.10] text-orange-300":"border-white/10 bg-transparent text-muted-foreground hover:border-white/20 hover:text-foreground"),children:[e.jsx(Re,{className:"h-3 w-3"}),"Starred only",l>0&&e.jsx("span",{className:p("ml-1 font-mono tabular-nums",r?"text-orange-300":"text-foreground
1/60"),children:l})]}),u&&e.jsxs("button",{type:"button",onClick:g,className:"ml-auto inline-flex items-center gap-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(Ce,{className:"h-3 w-3"}),"Clear all"]})]}),e.jsxs("div",{className:"grid gap-2.5 lg:grid-cols-2 xl:grid-cols-4",children:[e.jsx(Y,{label:"Impact",children:St.map(m=>e.jsxs(_,{active:t.has(m),onClick:()=>n(m),children:[e.jsx("span",{className:p("h-1.5 w-1.5 rounded-full",Xe(m))}),m]},m))}),e.jsx(Y,{label:"Country",children:vt.map(m=>e.jsx(_,{active:s.has(m),onClick:()=>o(m),children:m},m))}),e.jsx(Y,{label:"Currency",children:kt.map(m=>e.jsx(_,{active:a.has(m),onClick:()=>c(m),children:m},m))}),e.jsx(Y,{label:"Category",children:Lt.map(m=>e.jsx(_,{active:i.has(m),onClick:()=>d(m),children:K[m]},m))})]})]})},Y=({label:t,children:s})=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-[0.18em] text-muted-foreground/70",children:t}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s})]}),Wt=({view:t,onChange:s})=>{const a=[{key:"today",label:"Today"},{key:"week",label:"Week"},{key:"month",label:"Month"}];return e.jsx("div",{className:"inline-flex items-center gap-1 rounded-lg border border-white/[0.06] bg-white/[0.02] p-1",children:a.map(i=>{const r=t===i.key;return e.jsxs("button",{type:"button",onClick:()=>s(i.key),className:p("relative rounded-md px-3 py-1 text-[11px] font-medium uppercase tracking-wide transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40",r?"text-amber-300":"text-muted-foreground hover:text-foreground"),children:[r&&e.jsx(me.span,{layoutId:"view-tab-underline",className:"absolute inset-0 rounded-md border border-amber-500/30 bg-amber-500/[0.08]",transition:{duration:.25,ease:ue}}),e.jsx("span",{className:"relative",children:i.label})]},i.key)})})},qt=({view:t,anchor:s,onPrev:a,onNext:i,onToday:r})=>{let l="";if(t==="today")l=N(s,"EEE, MMM d");else if(t==="week"){const n=R(s,{weekStartsOn:1}),o=U(s,{weekStartsOn:1});l=`${N(n,"MMM d")} – ${N(o,"MMM d, yyyy")}`}else l=N(s,"MMMM yyyy");return e.jsxs("div",{className:"inline-flex items-center gap-1 rounded-lg border border-white/[0.06] bg-white/[0.02] p-1",children:[e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:a,className:"h-7 w-7 p-0 text-muted-foreground hover:bg-white/[0.04] hover:text-foreground","aria-label":"Previous",children:e.jsx(it,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:r,className:"min-w-[140px] rounded-md px-2.5 py-1 text-[12px] font-semibold tabular-nums text-foreground transition-colors hover:bg-white/[0.04]",children:l}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:i,className:"h-7 w-7 p-0 text-muted-foreground hover:bg-white/[0.04] hover:text-foreground","aria-label":"Next",children:e.jsx(Ue,{className:"h-3.5 w-3.5"})})]})},Kt=({anchor:t,events:s,onSelectEvent:a,loading:i,justReleasedSet:r})=>{const l=Be(t),n=Te(t),o=R(l,{weekStartsOn:1}),c=U(n,{weekStartsOn:1}),d=x.useMemo(()=>De({start:o,end:c}),[o,c]),f=x.useMemo(()=>{const u=new Map;for(const m of s){const b=j(m.date),y=N(b,"yyyy-MM-dd"),v=u.get(y)||[];v.push(m),u.set(y,v)}for(const m of u.values())m.sort((b,y)=>j(b.date).getTime()-j(y.date).getTime());return u},[s]),g=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];return e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border/40 bg-card/60 backdrop-blur-2xl",children:[e.jsx("div",{className:"grid grid-cols-7 border-b border-white/[0.06]",children:g.map(u=>e.jsx("div",{className:"px-2 py-1.5 text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground",children:u},u))}),e.jsx("div",{className:"grid grid-cols-7 auto-rows-[minmax(110px,auto)] sm:auto-rows-[minmax(130px,auto)]",children:d.map((u,m)=>{const b=N(u,"yyyy-MM-dd"),y=f.get(b)||[],v=lt(u,t),M=q(u),B=y.slice(0,4),C=y.length-B.length;return e.jsxs("div",{className:p("group relative flex min-h-0 flex-col gap-1 border-b border-r border-white/[0.04] p-1.5 transition-colors",m%7===6&&"border-r-0",!v&&"bg-black/20",M&&"ring-1 ring-inset ring-amber-500/25"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:p("text-[11px] font-bold tabular-nums",M&&"text-amber-300",!M&&v&&"text-foreground
1/80",!v&&"text-muted-foreground/40"),children:N(u,"d")}),y.length>0&&e.jsx("span",{className:"rounded bg-white/[0.04] px-1 font-mono text-[9px] tabular-nums text-muted-foreground",children:y.length})]}),i&&v&&y.length===0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"h-3 animate-pulse rounded bg-white/[0.04]"}),e.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-white/[0.04]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[B.map(E=>e.jsx(Ye,{event:E,onClick:()=>a(E),justReleased:(r==null?void 0:r.has(E.id))||!1},E.id)),C>0&&e.jsxs("span",{className:"text-center text-[9px] font-medium uppercase tracking-wider text-muted-foreground",children:["+",C," more"]})]})]},b)})})]})},Jt=({anchor:t,events:s,onSelectEvent:a,loading:i,justReleasedSet:r})=>{const l=R(t,{weekStartsOn:1}),n=U(t,{weekStartsOn:1}),o=De({start:l,end:n}),c=x.useMemo(()=>{const d=new Map;for(const f of s){const g=j(f.date),u=N(g,"yyyy-MM-dd"),m=d.get(u)||[];m.push(f),d.set(u,m)}for(const f of d.values())f.sort((g,u)=>j(g.date).getTime()-j(u.date).getTime());return d},[s]);return e.jsx("div",{className:"overflow-hidden rounded-xl border border-border/40 bg-card/60 backdrop-blur-2xl",children:e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-7",children:o.map((d,f)=>{const g=N(d,"yyyy-MM-dd"),u=c.get(g)||[],m=q(d);return e.jsxs("div",{className:p("flex min-h-[260px] flex-col gap-1.5 border-b border-r border-white/[0.04] p-2",f===6&&"lg:border-r-0",m&&"bg-amber-500/[0.025] ring-1 ring-inset ring-amber-500/20"),children:[e.jsxs("div",{className:"flex items-baseline justify-between border-b border-white/[0.04] pb-1.5",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:p("text-[10px] font-bold uppercase tracking-[0.16em]",m?"text-amber-300":"text-muted-foreground"),children:N(d,"EEE")}),e.jsx("span",{className:p("text-base font-bold tabular-nums",m?"text-amber-200":"text-foreground/80"),children:N(d,"d")})]}),u.length>0&&e.jsx("span",{className:"rounded bg-white/[0.04] px-1.5 py-0.5 font-mono text-[9px] tabular-nums text-muted-foreground",children:u.length})]}),i&&u.length===0&&e.jsx("div",{className:"space-y-1.5",children:[0,1,2].map(b=>e.jsx("div",{className:"h-12 animate-pulse rounded-md bg-white/[0.03]"},b))}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.map(b=>e.jsx(Ye,{event:b,onClick:()=>a(b),showStats:!0,justReleased:(r==null?void 0:r.has(b.id))||!1},b.id)),!i&&u.length===0&&e.jsx("div",{className:"flex flex-1 items-center justify-center py-6 text-[10px] uppercase tracking-wider text-muted-foreground/40",children:"no events"})]})]},g)})})})},Vt=({anchor:t,events:s,onSelectEvent:a,loading:i,now:r})=>{const l=x.useMemo(()=>s.filter(o=>$e(j(o.date),t)).sort((o,c)=>j(o.date).getTime()-j(c.date).getTime()),[s,t]),n=q(t);return e.jsxs("div",{className:"rounded-xl border border-border/40 bg-card/60 p-4 backdrop-blur-2xl sm:p-5",children:[i&&l.length===0&&e.jsx("div",{className:"space-y-3",children:[0,1,2,3,4].map(o=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-6 w-16 animate-pulse rounded bg-white/[0.03]"}),e.jsx("div",{className:"h-16 flex-1 animate-pulse rounded-md bg-white/[0.03]"})]},o))}),!i&&l.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center",children:[e.jsx(ie,{className:"h-8 w-8 text-muted-foreground/30"}),e.jsxs("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:["No events scheduled for ",N(t,"MMM d")]})]}),l.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute bottom-0 left-[58px] top-0 w-px bg-white/[0.06]","aria-hidden":!0}),n&&e.jsx(Qt,{now:r,events:l}),e.jsx("div",{className:"flex flex-col",children:l.map((o,c)=>{const d=j(o.date),f=N(d,"HH:mm"),g=xe(o),u=d<=r,m=Ae(o),b=c>0?Ae(l[c-1]):null,y=m!==b;return e.jsxs(x.Fragment,{children:[y&&e.jsxs("div",{className:"flex items-center gap-2 pl-[64px] pt-3 first:pt-0",children:[e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground
1/60",children:Et[m]}),e.jsx("span",{className:"h-px flex-1 bg-white/[0.04]"})]}),e.jsxs(me.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{duration:.3,delay:c*.03,ease:ue},className:"relative flex items-stretch gap-4 py-2",children:[e.jsx("div",{className:"flex w-[50px] shrink-0 flex-col items-end pr-1",children:e.jsx("span",{className:p("font-mono text-base font-bold tabular-nums",u?"text-foreground/80":"text-foreground"),children:f})}),e.jsx("div",{className:"relative",children:e.jsx("span",{className:p("absolute -left-[7px] top-3 h-3 w-3 rounded-full border-2",o.impact==="high"&&"border-red-400 bg-red-500/20",o.impact==="medium"&&"border-amber-400 bg-amber-500/20",o.impact==="low"&&"border-zinc-500 bg-zinc-500/20",!o.impact&&"border-zinc-600 bg-zinc-600/20")})}),e.jsxs("button",{type:"button",onClick:()=>a(o),className:p("group ml-2 flex flex-1 flex-col gap-1.5 rounded-lg border p-3 text-left transition-all duration-200","border-white/[0.06] bg-white/[0.02] hover:border-white/15 hover:bg-white/[0.04]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(J,{code:o.country,size:"md"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:ne(o.impact)}),e.jsxs("span",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground/60",children:["· ",K[o.category]]}),g&&e.jsx("span",{className:"ml-auto",children:e.jsx(pe,{result:g,size:"md"})})]}),e.jsx("div",{className:"text-sm font-semibold text-foreground/90 group-hover:text-foreground",children:o.event}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 font-mono text-[10px] tabular-nums text-muted-foreground",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground/60",children:"PREV "}),L(o.previous)]}),e.jsx("span",{className:"text-white/15",children:"·"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground/60",children:"FCST "}),L(o.forecast)]}),e.jsx("span",{className:"text-white/15",children:"·"}),e.jsxs("span",{className:p("font-bold",g==="BEAT"&&"text-emerald-300",g==="MISS"&&"text-red-300",(!g||g==="IN-LINE")&&"text-foreground/80"),children:[e.jsx("span",{className:"text-muted-foreground/60 font-mono",children:"ACT "}),L(o.actual)]})]})]})]})]},o.id)})})]})]})},Qt=({now:t,events:s})=>{const a=x.useMemo(()=>{if(s.length===0)return 50;const i=s.map(c=>j(c.date).getTime()).sort((c,d)=>c-d),r=i[0],n=i[i.length-1]-r;if(n<=0)return t.getTime()>=r?90:10;const o=(t.getTime()-r)/n;return o<0?0:o>1?100:o*100},[s,t]);return e.jsx("div",{className:"pointer-events-none absolute z-10 -translate-y-1/2 select-none transition-[top] duration-700 ease-out",style:{top:`${a}%`,left:0,width:64},children:e.jsxs("div",{className:"flex items-center justify-end gap-1.5 pr-1",children:[e.jsx("span",{className:"h-1 w-1 rounded-full bg-amber-400/80"}),e.jsx("span",{className:"rounded border border-amber-500/25 bg-amber-500/[0.05] px-1 py-0.5 font-mono text-[8px] font-bold uppercase tracking-[0.16em] text-amber-300/85",children:N(t,"HH:mm")})]})})},se=({label:t,value:s,tone:a="neutral",emphasized:i=!1})=>{const r=a==="positive"?"text-emerald-300":a==="negative"?"text-red-300":"text-foreground";return e.jsxs("div",{className:p("flex flex-col gap-1 rounded-lg border border-white/[0.06] bg-white/[0.02] p-3",i&&a==="positive"&&"border-emerald-500/25 bg-emerald-500/[0.04]",i&&a==="negative"&&"border-red-500/25 bg-red-500/[0.04]"),children:[e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:t}),e.jsx("span",{className:p("text-2xl font-bold tabular-nums sm:text-3xl",r),children:s})]})},Zt=({event:t,onClose:s})=>{const a=x.useRef(new Map),[i,r]=x.useState(null),[l,n]=x.useState(null),o=re({mutationFn:async u=>{const m=await T("/api/economic-calendar/analyze",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:u.id,event:u.event,actual:u.actual,forecast:u.forecast,previous:u.previous,currency:u.currency,country:u.country,impact:u.impact})}),b=await m.json().catch(()=>({}));if(!m.ok){const y=new Error(b.error||`HTTP ${m.status}`);throw y.status=m.status,y}return b},onSuccess:(u,m)=>
1{if(u.analysis){const b=`${m.id}::${m.actual}::${m.forecast}::${m.previous}`;a.current.set(b,u.analysis),r(u.analysis),n(null)}},onError:u=>{const m=u.status;m===501||/gemini_not_configured/.test(u.message)?n("not_configured"):n(m===429?"rate_limited":"transient")}}),c=t?`${t.id}::${t.actual}::${t.forecast}::${t.previous}`:null;if(x.useEffect(()=>{if(!t){r(null),n(null);return}if(t.actual===null){r(null),n(null);return}const u=c||t.id,m=a.current.get(u);if(m){r(m),n(null);return}r(null),n(null),o.mutate(t)},[c]),!t)return null;const d=xe(t),f=j(t.date),g=d==="BEAT"?"positive":d==="MISS"?"negative":"neutral";return e.jsx(ft,{open:!!t,onOpenChange:u=>!u&&s(),children:e.jsxs(bt,{side:"right",className:"w-full overflow-y-auto border-l border-border/40 bg-[#0a0a0a]/95 backdrop-blur-2xl sm:max-w-[480px]","aria-label":`Event details for ${t.event}`,children:[e.jsxs(jt,{className:"space-y-2 pb-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(J,{code:t.country,size:"md"}),t.currency&&e.jsx("span",{className:"rounded border border-white/10 bg-white/[0.03] px-1.5 py-0.5 font-mono text-[10px] font-semibold tracking-wide text-foreground/70",children:t.currency}),e.jsxs(gt,{variant:"outline",className:p("border-white/15 bg-transparent font-mono text-[9px] uppercase tracking-wider",t.impact==="high"&&"border-red-500/30 text-red-300",t.impact==="medium"&&"border-amber-500/30 text-amber-300",t.impact==="low"&&"border-zinc-500/30 text-zinc-300"),children:[ne(t.impact)," IMPACT"]}),e.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:["· ",K[t.category]]})]}),e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Nt,{className:"text-base font-bold leading-snug text-foreground",children:t.event}),e.jsx("span",{className:"shrink-0 pt-0.5",children:e.jsx(ze,{event:t,size:"md"})})]}),e.jsxs(yt,{className:"flex items-center gap-1.5 font-mono text-[11px] text-muted-foreground",children:[e.jsx(ae,{className:"h-3 w-3"}),N(f,"EEE, MMM d yyyy · HH:mm 'UTC'")]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-3",children:[e.jsx(se,{label:"Actual",value:L(t.actual),tone:g,emphasized:!0}),e.jsx(se,{label:"Forecast",value:L(t.forecast)}),e.jsx(se,{label:"Previous",value:L(t.previous)})]}),d&&e.jsx("div",{className:"pt-3",children:e.jsx(pe,{result:d,size:"md"})}),e.jsx(Ut,{event:t}),e.jsx(Gt,{event:t}),e.jsx(_t,{event:t}),t.actual!==null&&i&&e.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-white/[0.06] bg-white/[0.02] p-2.5 motion-safe:animate-in motion-safe:fade-in motion-safe:duration-300",children:[e.jsxs("div",{className:"flex items-center gap-1.5 pb-1",children:[e.jsx(le,{className:"h-2.5 w-2.5 text-foreground/45"}),e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-[0.18em] text-foreground/55",children:"AI Read"})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-foreground/75",children:i})]}),e.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"Urgency"}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-foreground/60",children:ne(t.impact)})]}),e.jsx(Ee,{filled:Fe(t.impact)})]}),e.jsx("div",{className:"h-px bg-white/[0.04]"}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"Market Impact"}),e.jsx("span",{className:"font-mono text-[10px] tabular-nums text-foreground/60",children:t.changePercentage!==null?`${t.changePercentage>0?"+":""}${t.changePercentage.toFixed(2)}%`:"—"})]}),e.jsx(Ee,{filled:It(t)})]})]}),(t.change!==null||t.changePercentage!==null)&&e.jsxs("div",{className:"mt-3 flex items-center justify-between rounded-lg border border-white/[0.06] bg-white/[0.02] px-3 py-2",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"Change vs Forecast"}),e.jsxs("div",{className:"flex items-center gap-3 font-mono text-[12px] tabular-nums",children:[t.change!==null&&e.jsxs("span",{className:p("font-semibold",t.change>
10?"text-emerald-300":t.change<0?"text-red-300":"text-foreground/70"),children:[t.change>0?"+":"",L(t.change)]}),t.changePercentage!==null&&e.jsxs("span",{className:"text-muted-foreground",children:["(",t.changePercentage>0?"+":"",t.changePercentage.toFixed(2),"%)"]})]})]})]})})},es=({children:t,rightLabel:s})=>e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-border/40 bg-card/60 backdrop-blur-2xl",children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-orange-500/35 to-transparent","aria-hidden":!0}),e.jsxs("div",{className:"relative flex h-9 items-center border-b border-white/[0.06] bg-black/30 px-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"block h-2.5 w-2.5 rounded-full bg-red-500/70"}),e.jsx("span",{className:"block h-2.5 w-2.5 rounded-full bg-amber-400/70"}),e.jsx("span",{className:"block h-2.5 w-2.5 rounded-full bg-emerald-500/70"})]}),e.jsxs("div",{className:"pointer-events-none absolute inset-y-0 left-1/2 flex -translate-x-1/2 items-center gap-1.5",children:[e.jsx(ie,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-wider text-foreground/70",children:"Economic Calendar"})]}),e.jsx("div",{className:"ml-auto",children:e.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-foreground/55",children:s||""})})]}),e.jsx("div",{className:"relative p-3 sm:p-4",children:t})]}),ls=()=>{var ye,we,Se,ve;const t=Pe(),s=!!(t!=null&&t.isAdmin||(t==null?void 0:t.plan)==="Elite"||(t==null?void 0:t.isSubscriber)===!0&&(t==null?void 0:t.plan)!=="Indicators"),[a,i]=x.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 639px)").matches?"today":"week"),[r,l]=x.useState(new Date),[n,o]=x.useState(new Date),[c,d]=x.useState(null),[f,g]=x.useState(new Set),[u,m]=x.useState(new Set),[b,y]=x.useState(new Set),[v,M]=x.useState(new Set),[B,C]=x.useState(!1),{watched:E}=_e(),he=wt();x.useEffect(()=>{const h=setInterval(()=>o(new Date),6e4);return()=>clearInterval(h)},[]);const{fromDate:We,toDate:qe}=x.useMemo(()=>{if(a==="today")return{fromDate:Ie(r,1),toDate:Le(r,1)};if(a==="week")return{fromDate:R(r,{weekStartsOn:1}),toDate:U(r,{weekStartsOn:1})};const h=Be(r),w=Te(r);return{fromDate:R(h,{weekStartsOn:1}),toDate:U(w,{weekStartsOn:1})}},[a,r]),ge=N(We,"yyyy-MM-dd"),fe=N(qe,"yyyy-MM-dd"),V=x.useMemo(()=>Array.from(f).sort().join(","),[f]),Q=x.useMemo(()=>Array.from(u).sort().join(","),[u]),Z=x.useMemo(()=>Array.from(b).sort().join(","),[b]),ee=x.useMemo(()=>Array.from(v).sort().join(","),[v]),I=oe({queryKey:["economic-calendar",ge,fe,V,Q,Z,ee],queryFn:async()=>{const h=new URLSearchParams;h.set("from",ge),h.set("to",fe),V&&h.set("impact",V),Q&&h.set("country",Q),Z&&h.set("currency",Z),ee&&h.set("category",ee);const w=await T(`/api/economic-calendar?${h.toString()}`);if(!w.ok){const A=await w.text().catch(()=>"");throw new Error(A||`HTTP ${w.status}`)}return await w.json()},staleTime:60*1e3,refetchInterval:60*1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,retry:1,placeholderData:ut,enabled:s});x.useEffect(()=>{I.isError&&I.error&&xt.error("Failed to load economic calendar",{description:I.error.message})},[I.isError,I.error]);const k=x.useMemo(()=>{var w;const h=((w=I.data)==null?void 0:w.events)??[];return B?E.size===0?[]:h.filter(A=>E.has(A.id)):h},[(ye=I.data)==null?void 0:ye.events,B,E]),D=x.useMemo(()=>{let h=0,w=0;const A=new Set;for(const S of k)S.impact==="high"&&(h+=1),S.actual!==null&&(w+=1),S.country&&A.add(S.country);return{total:k.length,high:h,released:w,regions:A.size}},[k]),be=x.useRef(new Map),$=x.useRef(new Map);x.useEffect(()=>{const h=be.current,w=new Map,A=Date.now();for(const S of k)w.set(S.id,S.actual),h.has(S.id)&&h.get(S.id)===null&&S.actual!==null&&S.actual!==void 0&&$.current.set(S.id,A);be.current=w;for(const[S,ke]of $.current)A-ke>5*60*1e3&&$.current.delete(S)},[k]);const te=x.useMemo(()=>{const h=new Set,w=n.getTime()-3*60*1e3;for(const[A,S]of $.current)S>w&&h.add(A);return h},[n]),Ke=x.useCallback(()=>
1{l(h=>a==="today"?Ie(h,1):a==="week"?tt(h):st(h))},[a]),Je=x.useCallback(()=>{l(h=>a==="today"?Le(h,1):a==="week"?rt(h,1):at(h,1))},[a]),Ve=x.useCallback(()=>{l(new Date)},[]),P=(h,w)=>{h(A=>{const S=new Set(A);return S.has(w)?S.delete(w):S.add(w),S})},je=x.useCallback(()=>{g(new Set),m(new Set),y(new Set),M(new Set),C(!1)},[]),Qe=f.size>0||u.size>0||b.size>0||v.size>0,O=I.isLoading,Ne=I.isError,Ze=!O&&!Ne&&k.length===0,et=N(r,"MMMM yyyy");return e.jsx(pt,{delayDuration:150,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(es,{rightLabel:et,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-orange-500/25 bg-orange-500/[0.07]",children:e.jsx(ie,{className:"h-4 w-4 text-orange-400"})}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("h1",{className:"text-base font-bold tracking-tight",children:"Economic Calendar"}),e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-muted-foreground",children:"Macro events, releases & central bank prints"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Wt,{view:a,onChange:i}),e.jsx(qt,{view:a,anchor:r,onPrev:Ke,onNext:Je,onToday:Ve})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-white/[0.04] bg-white/[0.015] px-3 py-2",children:[e.jsxs(F,{children:[e.jsx(X,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(H,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"font-mono text-[10px] tabular-nums text-foreground/80",children:D.total}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"events"})]})}),e.jsx(G,{side:"bottom",children:"Events in current range"})]}),e.jsx("span",{className:"h-3 w-px bg-white/[0.06]"}),e.jsxs(F,{children:[e.jsx(X,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-red-400"}),e.jsx("span",{className:"font-mono text-[10px] tabular-nums text-foreground/80",children:D.high}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"high"})]})}),e.jsx(G,{side:"bottom",children:"High-impact prints"})]}),e.jsx("span",{className:"h-3 w-px bg-white/[0.06]"}),e.jsxs(F,{children:[e.jsx(X,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(le,{className:"h-3 w-3 text-emerald-400"}),e.jsx("span",{className:"font-mono text-[10px] tabular-nums text-foreground/80",children:D.released}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"released"})]})}),e.jsx(G,{side:"bottom",children:"Events with actual results"})]}),e.jsx("span",{className:"h-3 w-px bg-white/[0.06]"}),e.jsxs(F,{children:[e.jsx(X,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(nt,{className:"h-3 w-3 text-foreground/55"}),e.jsx("span",{className:"font-mono text-[10px] tabular-nums text-foreground/80",children:D.regions}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"regions"})]})}),e.jsx(G,{side:"bottom",children:"Distinct countries"})]}),((we=I.data)==null?void 0:we.cached)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-3 w-px bg-white/[0.06]"}),e.jsx("span",{className:"font-mono text-[9px] uppercase tracking-[0.18em] text-muted-foreground/60",children:"cached"})]})]}),e.jsx(Yt,{impactFilter:f,countryFilter:u,currencyFilter:b,categoryFilter:v,starredOnly:B,watchedCount:E.size,onToggleImpact:h=>P(g,h),onToggleCountry:h=>P(m,h),onToggleCurrency:h=>P(y,h),onToggleCategory:h=>P(M,h),onToggleStarredOnly:()=>C(h=>!h),onClear:je})]})}),k.length>0&&e.jsx(Tt,{events:k,globalNext:((Se=I.data)==null?void 0:Se.nextUpcomingHighImpact)||null,now:n,onSelectEvent:d}),k.length>0&&e.jsx(Ct,{events:k,anchor:r}),a!=="today"&&k.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 px-1",children:[e.jsx(Mt,{}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] uppercase tracking-wider text-muted-foreground
1/70",children:[e.jsx("span",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-emerald-500/30 bg-emerald-500/10 px-1.5 py-0.5 font-bold tracking-wider text-emerald-300",children:[e.jsx(de,{className:"h-2 w-2"}),"Beat"]})}),e.jsx("span",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-red-500/30 bg-red-500/10 px-1.5 py-0.5 font-bold tracking-wider text-red-300",children:[e.jsx(ce,{className:"h-2 w-2"}),"Miss"]})}),e.jsxs("span",{className:"flex items-center gap-1.5 text-foreground/45",children:[e.jsx("span",{className:"font-mono",children:"P"}),"rev /",e.jsx("span",{className:"font-mono",children:"F"}),"cst /",e.jsx("span",{className:"font-mono",children:"A"}),"ct"]})]})]}),e.jsx(ht,{mode:"wait",initial:!1,children:e.jsx(me.div,{initial:he?!1:{opacity:0,y:6},animate:{opacity:1,y:0},exit:he?void 0:{opacity:0,y:-6},transition:{duration:.25,ease:ue},children:Ne?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 rounded-xl border border-red-500/25 bg-red-500/[0.04] py-12 text-center",children:[e.jsx(H,{className:"h-7 w-7 text-red-400/70"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-semibold text-red-200",children:"Failed to load economic calendar"}),e.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:((ve=I.error)==null?void 0:ve.message)||"Unknown error"})]}),e.jsx(W,{type:"button",size:"sm",variant:"outline",onClick:()=>I.refetch(),className:"border-red-500/30 bg-transparent text-red-200 hover:bg-red-500/10",children:"Retry"})]}):Ze?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 rounded-xl border border-border/40 bg-card/60 py-16 text-center backdrop-blur-2xl",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-white/[0.06] bg-white/[0.02]",children:e.jsx(He,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-mono text-[11px] uppercase tracking-[0.18em] text-foreground/80",children:"No events match your filters"}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Try widening the date range or relaxing the filters."})]}),Qe&&e.jsxs(W,{type:"button",size:"sm",variant:"outline",onClick:je,className:"border-white/15 bg-transparent text-foreground/80 hover:bg-white/[0.04]",children:[e.jsx(Ce,{className:"mr-1 h-3 w-3"}),"Clear filters"]})]}):a==="month"?e.jsx(Kt,{anchor:r,events:k,onSelectEvent:d,loading:O,justReleasedSet:te}):a==="week"?e.jsx(Jt,{anchor:r,events:k,onSelectEvent:d,loading:O,justReleasedSet:te}):e.jsx(Vt,{anchor:r,events:k,onSelectEvent:d,loading:O,now:n,justReleasedSet:te})},a)}),e.jsx(Zt,{event:c,onClose:()=>d(null)})]})})};export{ls 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.