1import{r as o,j as e}from"./vendor-react-De8d9Dk4.js";import{C as Ln}from"./types-CmBOMJqm.js";import{M as C,X as ne,G as ce,y as Me,Y as de,Z as En,B as zn,c as br,a as we,T as pe,b as Y,C as je,L as Ur}from"./theme-DIhREQJg.js";import{R as q,d as Ce,B as ye,h as De,c as mt,A as at,g as _e,b as ie,X as Q,Y as X,a as J,T as Z,L as ve,e as le,i as Hr,C as Wt,S as sa,k as Bt}from"./vendor-recharts-Bt9L8PVH.js";import{C as L,u as dr,f as Ja}from"./useIsMobile-DQZKvWKr.js";import{ao as oa,a8 as U,a0 as Za,ak as rt,K as Ne,m as Pn,n as hr,aa as Te,ab as We,ah as xr,ap as en,a9 as Oe,S as ot,d as it,C as Ie,al as ur,ad as ia,g as Bn,h as In,k as On,ac as Yn}from"./vendor-d3-CbE7iob_.js";import{I as Vn,a as Kn,b as Un,F as Hn}from"./FxRateChart-BPL3Ql4K.js";import{C as la}from"./chartExport-CSasmfEA.js";import{I as tn}from"./IndicatorLineChart-CSEoH74J.js";const rn=6048e5,qn=864e5,an=6e4,nn=36e5,ca=Symbol.for("constructDateFrom");function Re(t,r){return typeof t=="function"?t(r):t&&typeof t=="object"&&ca in t?t[ca](r):t instanceof Date?new t.constructor(r):new Date(r)}function fe(t,r){return Re(r||t,t)}function qr(t,r,a){const s=fe(t,a?.in);return isNaN(r)?Re(t,NaN):(r&&s.setDate(s.getDate()+r),s)}function da(t,r,a){const s=fe(t,a?.in);if(isNaN(r))return Re(t,NaN);if(!r)return s;const n=s.getDate(),i=Re(t,s.getTime());i.setMonth(s.getMonth()+r+1,0);const l=i.getDate();return n>=l?i:(s.setFullYear(i.getFullYear(),i.getMonth(),n),s)}let Xn={};function Et(){return Xn}function Be(t,r){const a=Et(),s=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,n=fe(t,r?.in),i=n.getDay(),l=(i<s?7:0)+i-s;return n.setDate(n.getDate()-l),n.setHours(0,0,0,0),n}function ar(t,r){return Be(t,{...r,weekStartsOn:1})}function sn(t,r){const a=fe(t,r?.in),s=a.getFullYear(),n=Re(a,0);n.setFullYear(s+1,0,4),n.setHours(0,0,0,0);const i=ar(n),l=Re(a,0);l.setFullYear(s,0,4),l.setHours(0,0,0,0);const d=ar(l);return a.getTime()>=i.getTime()?s+1:a.getTime()>=d.getTime()?s:s-1}function ha(t){const r=fe(t),a=new Date(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds()));return a.setUTCFullYear(r.getFullYear()),+t-+a}function Xr(t,...r){const a=Re.bind(null,r.find(s=>typeof s=="object"));return r.map(a)}function nr(t,r){const a=fe(t,r?.in);return a.setHours(0,0,0,0),a}function Gn(t,r,a){const[s,n]=Xr(a?.in,t,r),i=nr(s),l=nr(n),d=+i-ha(i),c=+l-ha(l);return Math.round((d-c)/qn)}function Qn(t,r){const a=sn(t,r),s=Re(t,0);return s.setFullYear(a,0,4),s.setHours(0,0,0,0),ar(s)}function xa(t,r,a){return qr(t,r*7,a)}function Jn(t){return Re(t,Date.now())}function Gr(t,r,a){const[s,n]=Xr(a?.in,t,r);return+nr(s)==+nr(n)}function Zn(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function es(t){return!(!Zn(t)&&typeof t!="number"||isNaN(+fe(t)))}function Br(t,r){const a=fe(t,r?.in);return a.setDate(1),a.setHours(0,0,0,0),a}function ts(t,r){const a=fe(t,r?.in);return a.setFullYear(a.getFullYear(),0,1),a.setHours(0,0,0,0),a}function rs(t,r){const a=Et(),s=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,n=fe(t,r?.in),i=n.getDay(),l=(i<s?-7:0)+6-(i-s);return n.setDate(n.getDate()+l),n.setHours(23,59,59,999),n}const as={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ns=(t,r,a)=>{let s;const n=as[t];return typeof n=="string"?s=n:r===1?s=n.one:s=n.other.replace("{{count}}",r.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+s:s+" ago":s};function jr(t){return(r={})=>{const a=r.width?String(r.width):t.defaultWidth;return t.formats[a]||t.formats[t.defaultWidth]}}const ss={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},os={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},is={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ls={date:jr({formats:ss,defaultWidth:"full"}),time:jr({formats:os,defaultWidth:"full"}),dateTime:jr({formats:is,defaultWidth:"full"})},cs={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ds=(t,r,a,s)=>cs[t];function yt(t){return(r,a)=>{const s=a?.context?String(a.context):"standalone";let n;if(s==="formatting"&&t.formattingValues){const l=t.defaultFormattingWidth||t.defaultWidth,d=a?.width?String(a.width):l;n=t.formattingValues[d]||t.formattingValues[l]}else{const l=t.defaultWidth,d=a?.width?String(a.width):t.defaultWidth;n=t.values[d]||t.values[l]}const i=t.argumentCallback?t.argumentCallback(r):r;return n[i]}}const hs={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},xs={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},us={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},ps={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Frid
1ay","Saturday"]},fs={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},ms={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},gs=(t,r)=>{const a=Number(t),s=a%100;if(s>20||s<10)switch(s%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},ys={ordinalNumber:gs,era:yt({values:hs,defaultWidth:"wide"}),quarter:yt({values:xs,defaultWidth:"wide",argumentCallback:t=>t-1}),month:yt({values:us,defaultWidth:"wide"}),day:yt({values:ps,defaultWidth:"wide"}),dayPeriod:yt({values:fs,defaultWidth:"wide",formattingValues:ms,defaultFormattingWidth:"wide"})};function bt(t){return(r,a={})=>{const s=a.width,n=s&&t.matchPatterns[s]||t.matchPatterns[t.defaultMatchWidth],i=r.match(n);if(!i)return null;const l=i[0],d=s&&t.parsePatterns[s]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(d)?js(d,p=>p.test(l)):bs(d,p=>p.test(l));let u;u=t.valueCallback?t.valueCallback(c):c,u=a.valueCallback?a.valueCallback(u):u;const x=r.slice(l.length);return{value:u,rest:x}}}function bs(t,r){for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)&&r(t[a]))return a}function js(t,r){for(let a=0;a<t.length;a++)if(r(t[a]))return a}function vs(t){return(r,a={})=>{const s=r.match(t.matchPattern);if(!s)return null;const n=s[0],i=r.match(t.parsePattern);if(!i)return null;let l=t.valueCallback?t.valueCallback(i[0]):i[0];l=a.valueCallback?a.valueCallback(l):l;const d=r.slice(n.length);return{value:l,rest:d}}}const ks=/^(\d+)(th|st|nd|rd)?/i,Ss=/\d+/i,ws={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Ns={any:[/^b/i,/^(a|c)/i]},Rs={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},As={any:[/1/i,/2/i,/3/i,/4/i]},Ms={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},$s={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Cs={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Ds={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},_s={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Fs={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ts={ordinalNumber:vs({matchPattern:ks,parsePattern:Ss,valueCallback:t=>parseInt(t,10)}),era:bt({matchPatterns:ws,defaultMatchWidth:"wide",parsePatterns:Ns,defaultParseWidth:"any"}),quarter:bt({matchPatterns:Rs,defaultMatchWidth:"wide",parsePatterns:As,defaultParseWidth:"any",valueCallback:t=>t+1}),month:bt({matchPatterns:Ms,defaultMatchWidth:"wide",parsePatterns:$s,defaultParseWidth:"any"}),day:bt({matchPatterns:Cs,defaultMatchWidth:"wide",parsePatterns:Ds,defaultParseWidth:"any"}),dayPeriod:bt({matchPatterns:_s,defaultMatchWidth:"any",parsePatterns:Fs,defaultParseWidth:"any"})},Ws={code:"en-US",formatDistance:ns,formatLong:ls,formatRelative:ds,localize:ys,match:Ts,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Ls(t,r){const a=fe(t,r?.in);return Gn(a,ts(a))+1}function Es(t,r){const a=fe(t,r?.in),s=+ar(a)-+Qn(a);return Math.round(s/rn)+1}function on(t,r){const a=fe(t,r?.in),s=a.getFullYear(),n=Et(),i=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,l=Re(r?.in||t,0);l.setFullYear(s+1,0,i),l.setHours(0,0,0,0);const d=Be(l,r),c=Re(r?.in||t,0);c.setFullYear(s,0,i),c.setHours(0,0,0,0);const u=Be(c,r);return+a>=+d?s+1:+a>=+u?s:s-1}function zs(t,r){const a=Et(),s=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,n=on(t,r),i=Re(r?.in||t,0);return i.setFullYear(n,0,s),i.setHours(0,0,0,0),Be(i,r)}function Ps(t,r){const a=fe(t,r?.in),s=+Be(a,r)-+zs(a,r);return Math.round(s/rn)+1}function ae(t,r){const a=t<0?"-":"",s=Math.abs(t).toString().padStart(r,"0");return a+s}const Ye={y(t,r){const a=t.getFullYear(),s=a>0?a:1-a;return ae(r==="yy"?s%100:s,r.length)},M(t,r){const a=t.getMonth();return r==="M"?String(a+1):ae(a+1,2)},d(t,r){return ae(t.getDate(),r.length)},a(t,r){const a=t.getHours()/12>=1?"pm":"am";switch(r){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];case"aaaa":default:return a==="am"?"a.m.":"p.m."}},h(t,r){return ae(t.getHours()%12||12,r.length)},H(t,r){return ae(t.getHours(),r.length)},m(t,r){return ae(t.getMinutes(),r.length)},s(t,r){return ae(t.getSeconds(),r.length)},S(t,r){const a=r.length,s=t.getMilliseconds(),n=Math.trunc(s*Math.pow(10,a-3));return ae(n,r.length)}},lt={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},ua={G:function(t,r,a){const s=t.getFullYear()>0?1:0;switch(r){case"G":case"GG":case"GGG":return a.era(s,{width:"abbreviated"});case"GGGGG":return a.era(s,{width:"narrow"});case"GGGG":default:return a.era(s,{width:"wide"})}},y:function(t,r,a){if(r==="yo"){const s=t.getFullYear(),n=s>0?s:1-s;return a.ordinalNumber(n,{unit:"year"})}return Ye.y(t,r)},Y:function(t,r,a,s){const n=on(t,s),i=n>0?n:1-n;if(r==="YY"){const l=i%100;return ae(l,2)}return r==="Yo"?a.ordinalNumber(i,{unit:"year"}):ae(i,r.length)},R:function(t,r){const a=sn(t);return ae(a,r.length)},u:function(t,r){const a=t.getFullYear();return ae(a,r.length)},Q:function(t,r,a){const s=Math.ceil((t.getMonth()+1)/3);switch(r){case"Q":return String(s);case"QQ":return ae(s,2);case"Qo":return a.ordinalNumber(s,{unit:"quarter"});case"QQQ":return a.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return a.quarter(s,{width:"narrow",context:"formatting"});case"QQQQ":default:return a.quarter(s,{width:"wide",context:"formatting"})}},q:function(t,r,a){const s=Math.ceil((t.getMonth()+1)/3);switch(r){case"q":return String(s);case"qq":return ae(s,2);case"qo":return a.ordinalNumber(s,{unit:"quarter"});case"qqq":return a.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return a.quarter(s,{width:"narrow",context:"standalone"});case"qqqq":default:return a.quarter(s,{width:"wide",context:"standalone"})}},M:function(t,r,a){const s=t.getMonth();switch(r){case"M":case"MM":return Ye.M(t,r);case"Mo":return a.ordinalNumber(s+1,{unit:"month"});case"MMM":return a.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return a.month(s,{width:"narrow",context:"formatting"});case"MMMM":default:return a.month(s,{width:"wide",context:"formatting"})}},L:function(t,r,a){const s=t.getMonth();switch(r){case"L":return String(s+1);case"LL":return ae(s+1,2);case"Lo":return a.ordinalNumber(s+1,{unit:"month"});case"LLL":return a.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return a.month(s,{width:"narrow",context:"standalone"});case"LLLL":default:return a.month(s,{width:"wide",context:"standalone"})}},w:function(t,r,a,s){const n=Ps(t,s);return r==="wo"?a.ordinalNumber(n,{unit:"week"}):ae(n,r.length)},I:function(t,r,a){const s=Es(t);return r==="Io"?a.ordinalNumber(s,{unit:"week"}):ae(s,r.length)},d:function(t,r,a){return r==="do"?a.ordinalNumber(t.getDate(),{unit:"date"}):Ye.d(t,r)},D:function(t,r,a){const s=Ls(t);return r==="Do"?a.ordinalNumber(s,{unit:"dayOfYear"}):ae(s,r.length)},E:function(t,r,a){const s=t.getDay();switch(r){case"E":case"EE":case"EEE":return a.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return a.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(s,{width:"short",context:"formatting"});case"EEEE":default:return a.day(s,{width:"wide",context:"formatting"})}},e:function(t,r,a,s){const n=t.getDay(),i=(n-s.weekStartsOn+8)%7||7;switch(r){case"e":return String(i);case"ee":return ae(i,2);case"eo":return a.ordinalNumber(i,{unit:"day"});case"eee":return a.day(n,{width:"abbreviated",context:"formatting"});case"eeeee":return a.day(n,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(n,{width:"short",context:"formatting"});case"eeee":default:return a.day(n,{width:"wide",context:"formatting"})}},c:function(t,r,a,s){const n=t.getDay(),i=(n-s.weekStartsOn+8)%7||7;switch(r){case"c":return String(i);case"cc":return ae(i,r.length);case"co":return a.ordinalNumber(i,{unit:"day"});case"ccc":return a.day(n,{width:"abbreviated",context:"standalone"});case"ccccc":return a.day(n,{width:"narrow",context:"standalone"});case"cccccc":return a.day(n,{width:"short",context:"standalone"});case"cccc":default:return a.day(n,{width:"wide",context:"standalone"})}},i:function(t,r,a){const s=t.getDay(),n=s===0?7:s;switch(r){case"i":return String(n);case"ii":return ae(n,r.length);case"io":return a.ordinalNumber(n,{unit:"day"});case"iii":return a.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return a.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return a.day(s,{width:"short",context:"formatting"});case"iiii":default:return a.day(s,{width:"wide",context:"formatting"})}},a:function(t,r,a){const n=t.getHours()/12>=1?"pm":"am";switch(r){case"a":case"aa":return a.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaa":return a.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return a.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaa":default:return a.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(t,r,a){const s=t.getHours();let n;switch(s===12?n=lt.noon:s===0?n=lt.midnight:n=s/12>
vendor: 4,159 bytes, line 1
1=1?"pm":"am",r){case"b":case"bb":return a.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"bbb":return a.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return a.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbb":default:return a.dayPeriod(n,{width:"wide",context:"formatting"})}},B:function(t,r,a){const s=t.getHours();let n;switch(s>=17?n=lt.evening:s>=12?n=lt.afternoon:s>=4?n=lt.morning:n=lt.night,r){case"B":case"BB":case"BBB":return a.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"BBBBB":return a.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBB":default:return a.dayPeriod(n,{width:"wide",context:"formatting"})}},h:function(t,r,a){if(r==="ho"){let s=t.getHours()%12;return s===0&&(s=12),a.ordinalNumber(s,{unit:"hour"})}return Ye.h(t,r)},H:function(t,r,a){return r==="Ho"?a.ordinalNumber(t.getHours(),{unit:"hour"}):Ye.H(t,r)},K:function(t,r,a){const s=t.getHours()%12;return r==="Ko"?a.ordinalNumber(s,{unit:"hour"}):ae(s,r.length)},k:function(t,r,a){let s=t.getHours();return s===0&&(s=24),r==="ko"?a.ordinalNumber(s,{unit:"hour"}):ae(s,r.length)},m:function(t,r,a){return r==="mo"?a.ordinalNumber(t.getMinutes(),{unit:"minute"}):Ye.m(t,r)},s:function(t,r,a){return r==="so"?a.ordinalNumber(t.getSeconds(),{unit:"second"}):Ye.s(t,r)},S:function(t,r){return Ye.S(t,r)},X:function(t,r,a){const s=t.getTimezoneOffset();if(s===0)return"Z";switch(r){case"X":return fa(s);case"XXXX":case"XX":return Je(s);case"XXXXX":case"XXX":default:return Je(s,":")}},x:function(t,r,a){const s=t.getTimezoneOffset();switch(r){case"x":return fa(s);case"xxxx":case"xx":return Je(s);case"xxxxx":case"xxx":default:return Je(s,":")}},O:function(t,r,a){const s=t.getTimezoneOffset();switch(r){case"O":case"OO":case"OOO":return"GMT"+pa(s,":");case"OOOO":default:return"GMT"+Je(s,":")}},z:function(t,r,a){const s=t.getTimezoneOffset();switch(r){case"z":case"zz":case"zzz":return"GMT"+pa(s,":");case"zzzz":default:return"GMT"+Je(s,":")}},t:function(t,r,a){const s=Math.trunc(+t/1e3);return ae(s,r.length)},T:function(t,r,a){return ae(+t,r.length)}};function pa(t,r=""){const a=t>0?"-":"+",s=Math.abs(t),n=Math.trunc(s/60),i=s%60;return i===0?a+String(n):a+String(n)+r+ae(i,2)}function fa(t,r){return t%60===0?(t>0?"-":"+")+ae(Math.abs(t)/60,2):Je(t,r)}function Je(t,r=""){const a=t>0?"-":"+",s=Math.abs(t),n=ae(Math.trunc(s/60),2),i=ae(s%60,2);return a+n+r+i}const ma=(t,r)=>{switch(t){case"P":return r.date({width:"short"});case"PP":return r.date({width:"medium"});case"PPP":return r.date({width:"long"});case"PPPP":default:return r.date({width:"full"})}},ln=(t,r)=>{switch(t){case"p":return r.time({width:"short"});case"pp":return r.time({width:"medium"});case"ppp":return r.time({width:"long"});case"pppp":default:return r.time({width:"full"})}},Bs=(t,r)=>{const a=t.match(/(P+)(p+)?/)||[],s=a[1],n=a[2];if(!n)return ma(t,r);let i;switch(s){case"P":i=r.dateTime({width:"short"});break;case"PP":i=r.dateTime({width:"medium"});break;case"PPP":i=r.dateTime({width:"long"});break;case"PPPP":default:i=r.dateTime({width:"full"});break}return i.replace("{{date}}",ma(s,r)).replace("{{time}}",ln(n,r))},Is={p:ln,P:Bs},Os=/^D+$/,Ys=/^Y+$/,Vs=["D","DD","YY","YYYY"];function Ks(t){return Os.test(t)}function Us(t){return Ys.test(t)}function Hs(t,r,a){const s=qs(t,r,a);if(console.warn(s),Vs.includes(t))throw new RangeError(s)}function qs(t,r,a){const s=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${r}\`) for formatting ${s} to the input \`${a}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Xs=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Gs=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Qs=/^'([^]*?)'?$/,Js=/''/g,Zs=/[a-zA-Z]/;function ge(t,r,a){const s=Et(),n=s.locale??Ws,i=s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,l=s.weekStartsOn??s.locale?.options?.weekStartsOn??0,d=fe(t,a?.in);if(!es(d))throw new RangeError("Invalid time value");let c=r.match(Gs).map(x=>{const p=x[0];if(p==="p"||p==="P"){const h=Is[p];return h(x,n.formatLong)}return x}).join("").match(Xs).map(x=>
1{if(x==="''")return{isToken:!1,value:"'"};const p=x[0];if(p==="'")return{isToken:!1,value:eo(x)};if(ua[p])return{isToken:!0,value:x};if(p.match(Zs))throw new RangeError("Format string contains an unescaped latin alphabet character `"+p+"`");return{isToken:!1,value:x}});n.localize.preprocessor&&(c=n.localize.preprocessor(d,c));const u={firstWeekContainsDate:i,weekStartsOn:l,locale:n};return c.map(x=>{if(!x.isToken)return x.value;const p=x.value;(Us(p)||Ks(p))&&Hs(p,r,String(t));const h=ua[p[0]];return h(d,p,n.localize,u)}).join("")}function eo(t){const r=t.match(Qs);return r?r[1].replace(Js,"'"):t}function cn(t,r,a){const[s,n]=Xr(a?.in,t,r);return s.getFullYear()===n.getFullYear()&&s.getMonth()===n.getMonth()}function dn(t,r){return Gr(Re(t,t),Jn(t))}function ut(t,r){const a=()=>Re(r?.in,NaN),n=no(t);let i;if(n.date){const u=so(n.date,2);i=oo(u.restDateString,u.year)}if(!i||isNaN(+i))return a();const l=+i;let d=0,c;if(n.time&&(d=io(n.time),isNaN(d)))return a();if(n.timezone){if(c=lo(n.timezone),isNaN(c))return a()}else{const u=new Date(l+d),x=fe(0,r?.in);return x.setFullYear(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate()),x.setHours(u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds()),x}return fe(l+d+c,r?.in)}const It={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},to=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,ro=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,ao=/^([+-])(\d{2})(?::?(\d{2}))?$/;function no(t){const r={},a=t.split(It.dateTimeDelimiter);let s;if(a.length>2)return r;if(/:/.test(a[0])?s=a[0]:(r.date=a[0],s=a[1],It.timeZoneDelimiter.test(r.date)&&(r.date=t.split(It.timeZoneDelimiter)[0],s=t.substr(r.date.length,t.length))),s){const n=It.timezone.exec(s);n?(r.time=s.replace(n[1],""),r.timezone=n[1]):r.time=s}return r}function so(t,r){const a=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+r)+"})|(\\d{2}|[+-]\\d{"+(2+r)+"})$)"),s=t.match(a);if(!s)return{year:NaN,restDateString:""};const n=s[1]?parseInt(s[1]):null,i=s[2]?parseInt(s[2]):null;return{year:i===null?n:i*100,restDateString:t.slice((s[1]||s[2]).length)}}function oo(t,r){if(r===null)return new Date(NaN);const a=t.match(to);if(!a)return new Date(NaN);const s=!!a[4],n=jt(a[1]),i=jt(a[2])-1,l=jt(a[3]),d=jt(a[4]),c=jt(a[5])-1;if(s)return po(r,d,c)?co(r,d,c):new Date(NaN);{const u=new Date(0);return!xo(r,i,l)||!uo(r,n)?new Date(NaN):(u.setUTCFullYear(r,i,Math.max(n,l)),u)}}function jt(t){return t?parseInt(t):1}function io(t){const r=t.match(ro);if(!r)return NaN;const a=vr(r[1]),s=vr(r[2]),n=vr(r[3]);return fo(a,s,n)?a*nn+s*an+n*1e3:NaN}function vr(t){return t&&parseFloat(t.replace(",","."))||0}function lo(t){if(t==="Z")return 0;const r=t.match(ao);if(!r)return 0;const a=r[1]==="+"?-1:1,s=parseInt(r[2]),n=r[3]&&parseInt(r[3])||0;return mo(s,n)?a*(s*nn+n*an):NaN}function co(t,r,a){const s=new Date(0);s.setUTCFullYear(t,0,4);const n=s.getUTCDay()||7,i=(r-1)*7+a+1-n;return s.setUTCDate(s.getUTCDate()+i),s}const ho=[31,null,31,30,31,30,31,31,30,31,30,31];function hn(t){return t%400===0||t%4===0&&t%100!==0}function xo(t,r,a){return r>=0&&r<=11&&a>=1&&a<=(ho[r]||(hn(t)?29:28))}function uo(t,r){return r>=1&&r<=(hn(t)?366:365)}function po(t,r,a){return r>=1&&r<=53&&a>=0&&a<=6}function fo(t,r,a){return t===24?r===0&&a===0:a>=0&&a<60&&r>=0&&r<60&&t>=0&&t<25}function mo(t,r){return r>=0&&r<=59}const ga=["#3f6b59","#2f63d6","#cb6d10","#7047f5","#2b7a8c","#a33a3a"];function ya(t){return new Date(t.length===7?`${t}-01`:t)}function go(t,r){let a=-1/0;for(const i of t)for(const l of i.data){const d=ya(String(l.x)).getTime();d>a&&(a=d)}if(!Number.isFinite(a))return t;const s=new Date(a);s.setMonth(s.getMonth()-r);const n=s.getTime();return t.map(i=>({...i,data:i.data.filter(l=>ya(String(l.x)).getTime()>=n)}))}const yo={background:"#fbfaf7",border:`1px solid ${C.cardBorder}`,borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},bo={fontSize:11,fill:C.muted};function jo(t){return Math.abs(t)>=1e6?`${(t/1e6).toFixed(1)}M`:Math.abs(t)>=1e3?`${(t/1e3).toFixed(t>=1e4?0:1)}k`:Number.isInteger(t)?String(t):t.toFixed(1)}
1function vo(t){return t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}function ko(t){if(!t.length)return;const r=t.map(n=>String(n.x)),a=/^\d{4}-\d{2}$/;if(!r.every(n=>a.test(n)))return;const s=r.filter(n=>{const i=n.slice(5,7);return i==="03"||i==="06"||i==="09"||i==="12"});if(s.length){if(s.length>16){const n=Math.ceil(s.length/16);return s.filter((i,l)=>l%n===0)}return s}}function te({data:t,chartType:r="line",height:a=300,colorBySign:s=!1,yAxisLabel:n,formatY:i=jo,formatTooltipValue:l=vo,monthsBack:d}){if(!t?.length)return null;const{rows:c,safeKeys:u,labels:x,colors:p}=o.useMemo(()=>{const w=d?go(t,d):t,j=w.map((M,$)=>`s${$}`),R=w.map(M=>M.id),N=w.map((M,$)=>ga[$%ga.length]),D=new Map;for(let M=0;M<w.length;M++)for(const $ of w[M].data){const T=String($.x);D.has(T)||D.set(T,{x:T}),D.get(T)[j[M]]=$.y??0}return{rows:Array.from(D.values()),safeKeys:j,labels:R,colors:N}},[t,d]),h=o.useMemo(()=>{const w={};for(let j=0;j<u.length;j++)w[u[j]]=x[j];return w},[u,x]),f=u.length>1,g={top:8,right:12,left:8,bottom:40},m=o.useMemo(()=>ko(c),[c]),y=e.jsx(Q,{dataKey:"x",...ne,...m?{ticks:m,interval:0}:{interval:"preserveStartEnd"}}),b=e.jsx(X,{tick:bo,tickFormatter:i,tickLine:!1,axisLine:!1,width:64,label:n?{value:n,angle:-90,position:"insideLeft",offset:-2,style:{fontSize:11,fill:"#767972",textAnchor:"middle"}}:void 0}),S=e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),k=e.jsx(Z,{contentStyle:yo,formatter:(w,j)=>[l(w),h[j]??j],labelFormatter:w=>String(w)}),v=f?e.jsx(ve,{verticalAlign:"top",height:32,formatter:w=>h[w]??w,wrapperStyle:{fontSize:12,color:"#28313f"}}):null;return r==="bar"?e.jsx(q,{width:"100%",height:a,children:e.jsxs(Ce,{data:c,margin:g,children:[S,y,b,k,v,u.map((w,j)=>e.jsx(ye,{dataKey:w,fill:p[j],radius:[3,3,0,0],name:w,isAnimationActive:!1,children:s&&c.map((R,N)=>{const D=Number(R[w]??0);return e.jsx(De,{fill:D>=0?C.positive:C.negative},N)})},w))]})}):r==="area"?e.jsx(q,{width:"100%",height:a,children:e.jsxs(mt,{data:c,margin:g,children:[e.jsx("defs",{children:u.map((w,j)=>e.jsxs("linearGradient",{id:`grad-${w}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:p[j],stopOpacity:.12}),e.jsx("stop",{offset:"95%",stopColor:p[j],stopOpacity:0})]},w))}),S,y,b,k,v,u.map((w,j)=>e.jsx(at,{type:"monotone",dataKey:w,stroke:p[j],strokeWidth:2,fill:`url(#grad-${w})`,name:w,isAnimationActive:!1},w))]})}):e.jsx(q,{width:"100%",height:a,children:e.jsxs(_e,{data:c,margin:g,children:[S,y,b,k,v,u.map((w,j)=>e.jsx(ie,{type:"monotone",dataKey:w,stroke:p[j],strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:w,isAnimationActive:!1},w))]})})}function So({data:t}){const r=o.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"gdp-components"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"bar",yAxisLabel:"% Change"})})]})}function wo({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"unemployment-wages"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line"})})]})}function No({data:t}){const r=o.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"fed-funds-rate"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"area",yAxisLabel:"Rate %"})})]})}function Ro({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"federal-deficit"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line"})})]})}function Ao({data:t}){const r=o.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"consumer-sentiment"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"Index"})})]})}function Mo({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"treasury-yield-curve"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"bar",yAxisLabel:"Yield %"})})]})}function $o({data:t}){const r=o.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"yield-curve-shape"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"area",yAxisLabel:"Spread %"})})]})}function ba({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"equity-chart"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line"})})]})}function kr({data:t}){return e.jsx(te,{data:t,chartType:"bar",colorBySign:!0})}function Sr({data:t}){return e.jsx(te,{data:t,chartType:"line"})}const xn=["Jan.","Feb.","Mar.","Apr.","May","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."];function Co(t){return`${xn[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`}function Do({data:t}){const r=t[0],a=o.useRef(null),s=o.useRef(null),n=o.useMemo(()=>r?r.__annotations??[]:[],[r]),{chartData:i,annotations:l}=o.useMemo(()=>
1{if(!r?.data?.length)return{chartData:[],annotations:[]};const d=oa("%Y-%m"),c=oa("%Y-%m-%d"),u=r.data.map(p=>{const h=String(p.x),f=d(h)||c(h.slice(0,10));return f?{date:f,value:p.y??0}:null}).filter(p=>p!==null),x=[];for(const p of n){const h=u.find(f=>`${f.date.getFullYear()}-${String(f.date.getMonth()+1).padStart(2,"0")}`===p.date_prefix);h&&x.push({label:p.label,pe:p.pe??"â",divYield:p.div_yield??"â",treasury10yr:p.treasury_10y??"â",date:h.date,value:h.value,indexLevel:Math.round(h.value).toLocaleString()})}return{chartData:u,annotations:x}},[r,n]);return o.useEffect(()=>{if(!a.current||!i.length)return;const d=a.current,c=()=>{U(d).selectAll("*").remove();const x=d.clientWidth,p=420,h={top:20,right:24,left:56,bottom:50},f=x-h.left-h.right,g=p-h.top-h.bottom;if(f<=0||g<=0)return;const m=U(d).append("svg").attr("width",x).attr("height",p),b=m.append("defs").append("linearGradient").attr("id","grad-sp500-d3").attr("x1","0").attr("y1","0").attr("x2","0").attr("y2","1");b.append("stop").attr("offset","5%").attr("stop-color","#111722").attr("stop-opacity",.08),b.append("stop").attr("offset","95%").attr("stop-color","#111722").attr("stop-opacity",0);const S=m.append("g").attr("transform",`translate(${h.left},${h.top})`),k=Za().domain(rt(i,A=>A.date)).range([0,f]),v=Ne().domain(rt(i,A=>A.value)).nice().range([g,0]);S.append("g").attr("class","grid").selectAll("line").data(v.ticks(6)).enter().append("line").attr("x1",0).attr("x2",f).attr("y1",A=>v(A)).attr("y2",A=>v(A)).attr("stroke","rgba(0,0,0,0.06)").attr("stroke-dasharray","3 3");const w=Pn().x(A=>k(A.date)).y0(g).y1(A=>v(A.value));S.append("path").datum(i).attr("d",w).attr("fill","url(#grad-sp500-d3)");const j=hr().x(A=>k(A.date)).y(A=>v(A.value));S.append("path").datum(i).attr("d",j).attr("fill","none").attr("stroke","#111722").attr("stroke-width",1.5);const R=new Set([2,5,8,11]),N=i.filter(A=>R.has(A.date.getMonth())).map(A=>A.date),D=Math.floor(f/80);let M=N;if(M.length>D&&D>0){const A=Math.ceil(M.length/D);M=M.filter((B,_)=>_%A===0)}S.append("g").attr("transform",`translate(0,${g})`).call(Te(k).tickValues(M).tickFormat(A=>{const B=A;return`${xn[B.getMonth()]} '${String(B.getFullYear()).slice(2)}`})).call(A=>A.select(".domain").attr("stroke","rgba(0,0,0,0.08)")).call(A=>A.selectAll(".tick line").attr("stroke","rgba(0,0,0,0.08)")).selectAll("text").attr("fill","#767972").attr("font-size","11px").attr("transform","rotate(-35)").attr("text-anchor","end"),S.append("g").call(We(v).ticks(6).tickFormat(A=>{const B=A;return B>=1e3?`${(B/1e3).toFixed(1)}k`:String(B)})).call(A=>A.select(".domain").remove()).call(A=>A.selectAll(".tick line").remove()).selectAll("text").attr("fill","#767972").attr("font-size","11px");for(const A of l){const B=k(A.date)+h.left,_=v(A.value)+h.top;m.append("circle").attr("cx",B).attr("cy",_).attr("r",4).attr("fill","#111722").attr("stroke","#fbfaf7").attr("stroke-width",1.5)}const $=U(d.parentElement).selectAll(".sp500-tooltip").data([0]).join("div").attr("class","sp500-tooltip").style("position","absolute").style("pointer-events","none").style("opacity","0").style("z-index","20").style("white-space","nowrap").style("background","#fbfaf7").style("border","1px solid #c9c5bb").style("border-radius","8px").style("padding","6px 10px").style("font-size","12px").style("color","#111722").style("box-shadow","0 2px 8px rgba(0,0,0,0.08)"),T=S.append("line").style("stroke","#767972").style("stroke-width","1px").style("stroke-dasharray","3,3").style("opacity","0");S.append("rect").attr("width",f).attr("height",g).attr("fill","none").style("pointer-events","all").on("mousemove",function(A){const[B]=xr(A),_=k.invert(B),E=en(Ae=>Ae.date.getTime()).left,V=E(i,_.getTime()),W=i[V-1],K=i[V];if(!W&&!K)return;const re=W?K?Math.abs(W.date.getTime()-_.getTime())<Math.abs(K.date.getTime()-_.getTime())?W:K:W:K,se=k(re.date);T.attr("x1",se).attr("x2",se).attr("y1",0).attr("y2",g).style("opacity","1"),$.html(`<strong>${Co(re.date)}</strong><br/>Index: ${re.value.toLocaleString(void 0,{maximumFractionDigits:0})}`).style("opacity","1");const Fe=m.node().getBoundingClientRect(),he=d.parentElement.getBoundingClientRect(),qe=Fe.left-he.left+se+h.left+12,Le=Fe.top-he.top+v(re.value)+h.top-10;$.style("left",`${qe}px`).style("top",`${Le}px`)}).on("mouseleave",function(){T.style("opacity","0"),$.style("opacity","0")})};c();const u=new ResizeObserver(()=>c());return u.observe(d),()=>u.disconnect()},[i,l]),i.length?e.jsxs("div",{children:[e.jsx(L,{exportRef:s,exportFilename:"sp500-index"}),e.jsxs("div",{ref:s,style:{position:"relative"},children:[l.length>0&&e.jsxs("table",{style:{position:"absolute",top:8,left:64,background:"#fbfaf7",border:"1px solid #c9c5bb",borderCollapse:"collapse",fontSize:10,fontFamily:"system-ui, sans-serif",color:"#28313f",zIndex:5,pointerEvents:"none"},className:"sp500-summary-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{textAlign:"left",fontWeight:700,textDecoration:"underline",padding:"3px 8px",borderBottom:"1px solid #c9c5bb",whiteSpace:"nowrap"},children:"Characteristic"}),l.map(d=>e.jsx("th",{style:{fontWeight:700,padding:"3px 8px",borderBottom:"1px solid #c9c5bb",textAlign:"right",whiteSpace:"nowrap"},children:d.label},d.label))]})}),e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"2px 8px",whiteSpace:"nowrap"},children:"Index level"}),l.map(d=>e.jsx("td",{style:{padding:"2px 8px",textAlign:"right",fontFamily:"ui-monospace, monospace"},children:d.indexLevel},d.label))]}),e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"2px 8px",whiteSpace:"nowrap"},children:"P/E"}),l.map(d=>e.jsx("td",{style:{padding:"2px 8px",textAlign:"right",fontFamily:"ui-monospace, monospace"},children:d.pe},d.label))]}),e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"2px 8px",whiteSpace:"nowrap"},children:"Dividend yield"}),l.map(d=>e.jsx("td",{style:{padding:"2px 8px",textAlign:"right",fontFamily:"ui-monospace, monospace"},children:d.divYield},d.label))]}),e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"2px 8px",whiteSpace:"nowrap"},children:"10yr Treasury"}),l.map(d=>e.jsx("td",{style:{padding:"2px 8px",textAlign:"right",fontFamily:"ui-monospace, monospace"},children:d.treasury10yr},d.label))]})]})]}),e.jsx("style",{children:` 2 @media (max-width: 600px) { 3 .sp500-summary-table { display: none !important; } 4 } 5 `}),e.jsx("div",{ref:a,style:{width:"100%",height:420}})]})]}):null}const ct=[{color:"#111722",width:2.5,dash:""},{color:"#ea580c",width:2,dash:"6 3"}];function _o({data:t}){const r=o.useRef(null),a=o.useRef(null),s=o.useMemo(()=>t.map(n=>({id:n.id,points:n.data.map(i=>({year:Number(i.x),value:i.y??0})).filter(i=>!isNaN(i.year))})),[t]);return o.useEffect(()=>{if(!r.current||!s.length)return;const n=r.current,i=()=>{U(n).selectAll("*").remove();
5const d=n.clientWidth,c=380,u={top:12,right:20,left:48,bottom:50},x=d-u.left-u.right,p=c-u.top-u.bottom;if(x<=0||p<=0)return;const h=U(n).append("svg").attr("width",d).attr("height",c),f=h.append("g").attr("transform",`translate(${u.left},${u.top})`),g=s.flatMap(N=>N.points),m=rt(g,N=>N.year),y=Oe(g,N=>N.value)??50,b=Ne().domain(m).range([0,x]),S=Ne().domain([0,Math.ceil(y/5)*5]).nice().range([p,0]);f.selectAll(".grid").data(S.ticks(6)).enter().append("line").attr("x1",0).attr("x2",x).attr("y1",N=>S(N)).attr("y2",N=>S(N)).attr("stroke","rgba(0,0,0,0.06)").attr("stroke-dasharray","3 3");const k=Math.floor(x/60);f.append("g").attr("transform",`translate(0,${p})`).call(Te(b).ticks(Math.min(k,15)).tickFormat(N=>String(N))).call(N=>N.select(".domain").attr("stroke","rgba(0,0,0,0.08)")).call(N=>N.selectAll(".tick line").attr("stroke","rgba(0,0,0,0.08)")).selectAll("text").attr("fill","#767972").attr("font-size","11px").attr("transform","rotate(-35)").attr("text-anchor","end"),f.append("g").call(We(S).ticks(6).tickFormat(N=>`${N}x`)).call(N=>N.select(".domain").remove()).call(N=>N.selectAll(".tick line").remove()).selectAll("text").attr("fill","#767972").attr("font-size","11px");for(let N=0;N<s.length;N++){const D=s[N],M=ct[N%ct.length],$=hr().x(A=>b(A.year)).y(A=>S(A.value)),T=f.append("path").datum(D.points).attr("d",$).attr("fill","none").attr("stroke",M.color).attr("stroke-width",M.width);M.dash&&T.attr("stroke-dasharray",M.dash)}const v=6;let w=x-240;for(let N=0;N<s.length;N++){const D=s[N],M=ct[N%ct.length];f.append("line").attr("x1",w).attr("x2",w+24).attr("y1",v).attr("y2",v).attr("stroke",M.color).attr("stroke-width",M.width).attr("stroke-dasharray",M.dash),f.append("text").attr("x",w+30).attr("y",v+4).attr("font-size","11px").attr("fill","#28313f").text(D.id),w+=30+D.id.length*6.5+16}const j=U(n.parentElement).selectAll(".shiller-tooltip").data([0]).join("div").attr("class","shiller-tooltip").style("position","absolute").style("pointer-events","none").style("opacity","0").style("z-index","20").style("white-space","nowrap").style("background","#fbfaf7").style("border","1px solid #c9c5bb").style("border-radius","8px").style("padding","6px 10px").style("font-size","12px").style("color","#111722").style("box-shadow","0 2px 8px rgba(0,0,0,0.08)"),R=f.append("line").style("stroke","#767972").style("stroke-width","1px").style("stroke-dasharray","3,3").style("opacity","0");f.append("rect").attr("width",x).attr("height",p).attr("fill","none").style("pointer-events","all").on("mousemove",function(N){const[D]=xr(N),M=Math.round(b.invert(D)),$=[`<strong>${M}</strong>`];for(let B=0;B<s.length;B++){const _=s[B].points.find(E=>E.year===M);if(_){const E=ct[B%ct.length];$.push(`<span style="color:${E.color}">${s[B].id}: ${_.value.toFixed(1)}x</span>`)}}R.attr("x1",b(M)).attr("x2",b(M)).attr("y1",0).attr("y2",p).style("opacity","1"),j.html($.join("<br/>")).style("opacity","1");const T=h.node().getBoundingClientRect(),A=n.parentElement.getBoundingClientRect();j.style("left",`${T.left-A.left+b(M)+u.left+12}px`).style("top",`${T.top-A.top+u.top+20}px`)}).on("mouseleave",function(){R.style("opacity","0"),j.style("opacity","0")})};i();const l=new ResizeObserver(()=>i());return l.observe(n),()=>l.disconnect()},[s]),s.length?e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:a,exportFilename:"shiller-pe"}),e.jsx("div",{ref:a,style:{position:"relative"},children:e.jsx("div",{ref:r,style:{width:"100%",height:380}})})]}):null}function un(t){const r=t.length;if(r<2)return{slope:0,intercept:0,r2:0};let a=0,s=0,n=0,i=0;for(const h of t)a+=h.pe,s+=h.ret,n+=h.pe*h.pe,i+=h.pe*h.ret;const l=(r*i-a*s)/(r*n-a*a),d=(s-l*a)/r,c=s/r;let u=0,x=0;for(const h of t)u+=(h.ret-c)**2,x+=(h.ret-(l*h.pe+d))**2;const p=u>0?1-x/u:0;return{slope:l,intercept:d,r2:p}}function ja(t,r,a,s,n){if(U(t).selectAll("*").remove(),!r.length)return;const i=t.clientWidth,l=420,d={top:50,right:24,left:56,bottom:56},c=i-d.left-d.right,u=l-d.top-d.bottom;if(c<=0||u<=0)return;const x=U(t).append("svg").attr("width",i).attr("height",l),p=x.append("g").attr("transform",`translate(${d.left},${d.top}
5)`),h=rt(r,W=>W.pe),f=rt(r,W=>W.ret),g=Math.floor(h[0]/3)*3,m=Math.ceil(h[1]/3)*3,y=5,b=Math.floor((f[0]-y)/10)*10,S=Math.ceil((f[1]+y)/10)*10,k=Ne().domain([g,m]).range([0,c]),v=Ne().domain([b,S]).range([u,0]);x.append("text").attr("x",d.left).attr("y",18).attr("font-size","14px").attr("font-weight","700").attr("fill","#111722").text(a),x.append("text").attr("x",d.left).attr("y",34).attr("font-size","11px").attr("fill","#6d716e").text(s),p.selectAll(".grid-y").data(v.ticks(6)).enter().append("line").attr("x1",0).attr("x2",c).attr("y1",W=>v(W)).attr("y2",W=>v(W)).attr("stroke","rgba(0,0,0,0.08)").attr("stroke-dasharray","2 2"),b<0&&S>0&&p.append("line").attr("x1",0).attr("x2",c).attr("y1",v(0)).attr("y2",v(0)).attr("stroke","#111722").attr("stroke-width",1),p.append("g").attr("transform",`translate(0,${u})`).call(Te(k).ticks(6).tickFormat(W=>`${W}x`)).call(W=>W.select(".domain").attr("stroke","#111722")).call(W=>W.selectAll(".tick line").attr("stroke","rgba(0,0,0,0.1)")).selectAll("text").attr("fill","#6d716e").attr("font-size","11px"),p.append("g").call(We(v).ticks(6).tickFormat(W=>`${W}%`)).call(W=>W.select(".domain").remove()).call(W=>W.selectAll(".tick line").remove()).selectAll("text").attr("fill","#6d716e").attr("font-size","11px");const w=U(t).selectAll(".scatter-tooltip").data([0]).join("div").attr("class","scatter-tooltip").style("position","absolute").style("pointer-events","none").style("opacity","0").style("z-index","20").style("white-space","nowrap").style("background","#fbfaf7").style("border","1px solid #c9c5bb").style("border-radius","8px").style("padding","8px 12px").style("font-size","12px").style("color","#111722").style("box-shadow","0 2px 8px rgba(0,0,0,0.12)"),j=r.find(W=>W.label===n),R=r.filter(W=>W.label!==n);p.selectAll(".dot").data(R).enter().append("path").attr("d",ot().type(it).size(40)).attr("transform",W=>`translate(${k(W.pe)},${v(W.ret)})`).attr("fill","#6d716e").attr("opacity",.6).style("cursor","pointer").on("mouseenter",function(W,K){U(this).attr("d",ot().type(it).size(100)()).attr("opacity",1),w.html(`<strong>${K.label??"â"}</strong><br/>P/E: ${K.pe.toFixed(1)}x<br/>Return: ${K.ret.toFixed(1)}%`).style("opacity","1");const re=k(K.pe)+d.left,se=v(K.ret)+d.top;w.style("left",`${re+14}px`).style("top",`${se-10}px`)}).on("mouseleave",function(){U(this).attr("d",ot().type(it).size(40)()).attr("opacity",.6),w.style("opacity","0")});const N=un(r),D=g,M=m,$=N.slope*D+N.intercept,T=N.slope*M+N.intercept;p.append("line").attr("x1",k(D)).attr("y1",v(Math.max(b,Math.min(S,$)))).attr("x2",k(M)).attr("y2",v(Math.max(b,Math.min(S,T)))).attr("stroke","#ea580c").attr("stroke-width",2.5);const A=Math.round(N.r2*100),B=80,_=24,E=c-B-4,V=u-_-4;if(p.append("rect").attr("x",E).attr("y",V).attr("width",B).attr("height",_).attr("fill","#fbfaf7").attr("stroke","#111722").attr("stroke-width",1),p.append("text").attr("x",E+B/2).attr("y",V+_/2+4).attr("text-anchor","middle").attr("font-size","12px").attr("font-weight","700").attr("fill","#111722").text(`R² = ${A}%`),j){const W=k(j.pe),K=v(j.ret);p.append("path").attr("d",ot().type(it).size(120)).attr("transform",`translate(${W},${K})`).attr("fill","#a33a3a").style("cursor","pointer").on("mouseenter",function(){U(this).attr("d",ot().type(it).size(200)()),w.html(`<strong>Dec 31, 2025</strong><br/>P/E: ${j.pe.toFixed(1)}x<br/>Return: ${j.ret.toFixed(1)}%`).style("opacity","1").style("left",`${W+d.left+14}px`).style("top",`${K+d.top-10}px`)}).on("mouseleave",function(){U(this).attr("d",ot().type(it).size(120)()),w.style("opacity","0")});const se=K-60;p.append("line").attr("x1",W).attr("y1",se).attr("x2",W).attr("y2",K-10).attr("stroke","#111722").attr("stroke-width",1),p.append("path").attr("d",`M${W-4},${K-14} L${W},${K-8} L${W+4},${K-14}`).attr("fill","#111722"),p.append("text").attr("x",W).attr("y",se-6).attr("text-anchor","middle").attr("font-size","11px").attr("font-weight","700").attr("fill","#111722").text(`Dec 31, 2025: ${j.pe.toFixed(1)}x`)}}function Fo({data:t}){const r=o.useRef(null),a=o.useRef(null),s=o.useRef(null),[n,i]=o.useState("chart"),l=[],d=[];for(const g of t){const m=g.id==="pe_1yr"?l:g.id==="pe_5yr"?d:null;if(m)for(const y of g.data)m.push({pe:Number(y.x),ret:Number(y.y),label:y.label})}if(!d.some(g=>g.label==="2025")&&d.length>0){const g=l.find(m=>m.label==="2025")?.pe;if(g!=null){const m=un(d);d.push({pe:g,ret:Math.round((m.slope*g+m.intercept)*10)/10,label:"2025"})}}if(o.useEffect(()=>{if(n!=="chart"||!r.current||!a.current)return;const g=()=>{ja(r.current,l,"P/E and subsequent 1-year returns","S&P 500 Total Return Index","2025"),ja(a.current,d,"P/E and subsequent 5-year annualized returns","S&P 500 Total Return Index","2025")};g();const m=new ResizeObserver(()=>g());return m.observe(r.current),m.observe(a.current),()=>m.disconnect()},[t,n]),!l.length&&!d.length)return null;const u=new Map,x=new Map,p=new Map;for(const g of l)g.label&&(u.set(g.label,g.pe),x.set(g.label,g.ret));for(const g of d)g.label&&(u.set(g.label,g.pe),p.set(g.label,g.ret));const h=Array.from(u.keys()).sort((g,m)=>m.localeCompare(g)),f=g=>g==null?"â":`${g>0?"+":""}${g.toFixed(1)}%`;return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:s,exportFilename:"pe-vs-returns",view:n,viewOptions:[{value:"chart",label:"Chart"},{value:"table",label:"Table"}],onView:g=>i(g)}),e.jsx("div",{className:"pe-vs-returns-wrapper",ref:s,style:{width:"100%"},children:n==="chart"?e.jsxs("div",{style:{display:"flex",gap:16,width:"100%"},children:[e.jsx("div",{style:{flex:1,minWidth:0,background:"var(--markets-parchment)",border:"1px solid var(--markets-rule-soft)",borderRadius:4,overflow:"hidden"}
5,children:e.jsx("div",{ref:r,style:{height:420,position:"relative"}})}),e.jsx("div",{style:{flex:1,minWidth:0,background:"var(--markets-parchment)",border:"1px solid var(--markets-rule-soft)",borderRadius:4,overflow:"hidden"},children:e.jsx("div",{ref:a,style:{height:420,position:"relative"}})})]}):e.jsx("div",{style:{background:"var(--markets-parchment)",border:"1px solid var(--markets-rule-soft)",borderRadius:4,overflow:"auto",maxHeight:460},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsx("tr",{children:["Year","Trailing P/E","Subsequent 1Y Return","Subsequent 5Y Ann. Return"].map((g,m)=>e.jsx("th",{style:{textAlign:m===0?"left":"right",padding:"10px 16px",position:"sticky",top:0,background:"var(--markets-card-bg)",borderBottom:"1px solid var(--markets-card-border)",color:"var(--markets-text-muted, #6d716e)",fontWeight:600,whiteSpace:"nowrap"},children:g},g))})}),e.jsx("tbody",{children:h.map(g=>{const m=x.get(g),y=p.get(g);return e.jsxs("tr",{style:{borderBottom:"1px solid var(--markets-card-border)"},children:[e.jsxs("td",{style:{textAlign:"left",padding:"8px 16px",fontWeight:g==="2025"?700:400},children:[g,g==="2025"?" (current)":""]}),e.jsxs("td",{style:{textAlign:"right",padding:"8px 16px",fontVariantNumeric:"tabular-nums"},children:[u.get(g)?.toFixed(1),"x"]}),e.jsx("td",{style:{textAlign:"right",padding:"8px 16px",fontVariantNumeric:"tabular-nums",color:m==null?"inherit":m>=0?"#1a8b66":"#a33a3a"},children:f(m)}),e.jsx("td",{style:{textAlign:"right",padding:"8px 16px",fontVariantNumeric:"tabular-nums",color:y==null?"inherit":y>=0?"#1a8b66":"#a33a3a"},children:f(y)})]},g)})})]})})})]})}function To(t,r){if(U(t).selectAll("*").remove(),!r.length)return;const a=t.clientWidth,s=420,n={top:50,right:24,left:52,bottom:40},i=a-n.left-n.right,l=s-n.top-n.bottom;if(i<=0||l<=0)return;const d=U(t).append("svg").attr("width",a).attr("height",s),c=d.append("g").attr("transform",`translate(${n.left},${n.top})`);d.append("text").attr("x",n.left).attr("y",18).attr("font-size","13px").attr("font-weight","700").attr("fill","#111722").text("Weight of Top 10 Companies"),d.append("text").attr("x",n.left).attr("y",34).attr("font-size","11px").attr("fill","#6d716e").text("% of total market cap and earnings");const u=["#111722","#2f63d6"],x=["","6 3"],p=r.map(w=>w.id.replace("wt__","")),h=r.flatMap(w=>w.data.map(j=>({year:Number(j.x),value:Number(j.y)}))),f=rt(h,w=>w.year),g=Oe(h,w=>w.value)??40,m=Ne().domain(f).range([0,i]),y=Ne().domain([0,Math.ceil(g/5)*5]).nice().range([l,0]);c.selectAll(".grid").data(y.ticks(6)).enter().append("line").attr("x1",0).attr("x2",i).attr("y1",w=>y(w)).attr("y2",w=>y(w)).attr("stroke","rgba(0,0,0,0.06)").attr("stroke-dasharray","3 3"),c.append("g").attr("transform",`translate(0,${l})`).call(Te(m).ticks(6).tickFormat(w=>String(w))).call(w=>w.select(".domain").attr("stroke","rgba(0,0,0,0.08)")).call(w=>w.selectAll(".tick line").attr("stroke","rgba(0,0,0,0.08)")).selectAll("text").attr("fill","#767972").attr("font-size","11px"),c.append("g").call(We(y).ticks(6).tickFormat(w=>`${w}%`)).call(w=>w.select(".domain").remove()).call(w=>w.selectAll(".tick line").remove()).selectAll("text").attr("fill","#767972").attr("font-size","11px");for(let w=0;w<r.length;w++){const j=r[w].data.map(D=>({year:Number(D.x),value:Number(D.y)})).filter(D=>!isNaN(D.year)),R=hr().x(D=>m(D.year)).y(D=>y(D.value)),N=c.append("path").datum(j).attr("d",R).attr("fill","none").attr("stroke",u[w]).attr("stroke-width",2.5);x[w]&&N.attr("stroke-dasharray",x[w])}let b=i-240;const S=6;for(let w=0;w<p.length;w++)c.append("line").attr("x1",b).attr("x2",b+24).attr("y1",S).attr("y2",S).attr("stroke",u[w]).attr("stroke-width",2.5).attr("stroke-dasharray",x[w]),c.append("text").attr("x",b+30).attr("y",S+4).attr("font-size","11px").attr("fill","#28313f").text(p[w]),b+=30+p[w].length*6.5+16;const k=U(t).selectAll(".wt-tooltip").data([0]).join("div").attr("class","wt-tooltip").style("position","absolute").style("pointer-events","none").style("opacity","0").style("z-index","20").style("white-space","nowrap").style("background","#fbfaf7").style("border","1p
5x solid #c9c5bb").style("border-radius","8px").style("padding","6px 10px").style("font-size","12px").style("color","#111722").style("box-shadow","0 2px 8px rgba(0,0,0,0.08)"),v=c.append("line").style("stroke","#767972").style("stroke-width","1px").style("stroke-dasharray","3,3").style("opacity","0");c.append("rect").attr("width",i).attr("height",l).attr("fill","none").style("pointer-events","all").on("mousemove",function(w){const[j]=xr(w),R=Math.round(m.invert(j)),N=[`<strong>${R}</strong>`];for(let M=0;M<r.length;M++){const $=r[M].data.find(T=>Number(T.x)===R);$&&N.push(`<span style="color:${u[M]}">${p[M]}: ${Number($.y).toFixed(1)}%</span>`)}v.attr("x1",m(R)).attr("x2",m(R)).attr("y1",0).attr("y2",l).style("opacity","1"),k.html(N.join("<br/>")).style("opacity","1");const D=m(R)+n.left;k.style("left",`${D+12}px`).style("top",`${n.top+20}px`)}).on("mouseleave",function(){v.style("opacity","0"),k.style("opacity","0")})}function Wo(t,r){if(U(t).selectAll("*").remove(),!r.length)return;const a=t.clientWidth,s=420,n={top:50,right:24,left:52,bottom:40},i=a-n.left-n.right,l=s-n.top-n.bottom;if(i<=0||l<=0)return;const d=U(t).append("svg").attr("width",a).attr("height",s),c=d.append("g").attr("transform",`translate(${n.left},${n.top})`);d.append("text").attr("x",n.left).attr("y",18).attr("font-size","13px").attr("font-weight","700").attr("fill","#111722").text("P/E: Top 10 vs. Remaining"),d.append("text").attr("x",n.left).attr("y",34).attr("font-size","11px").attr("fill","#6d716e").text("Aggregate trailing P/E by group");const u=["#111722","#767972"],x=r.map(j=>j.id.replace("pe__","")),p=r[0].data.map(j=>String(j.x)),h=Ie().domain(p).range([0,i]).padding(.25),f=Ie().domain(["0","1"]).range([0,h.bandwidth()]).padding(.08),g=r.flatMap(j=>j.data.map(R=>Number(R.y))),m=Math.ceil((Oe(g)??40)/10)*10,y=Ne().domain([0,m]).nice().range([l,0]);c.selectAll(".grid").data(y.ticks(6)).enter().append("line").attr("x1",0).attr("x2",i).attr("y1",j=>y(j)).attr("y2",j=>y(j)).attr("stroke","rgba(0,0,0,0.06)").attr("stroke-dasharray","3 3");const b=Math.max(1,Math.floor(p.length/8)),S=p.filter((j,R)=>R%b===0||R===p.length-1);c.append("g").attr("transform",`translate(0,${l})`).call(Te(h).tickValues(S)).call(j=>j.select(".domain").attr("stroke","rgba(0,0,0,0.08)")).call(j=>j.selectAll(".tick line").attr("stroke","rgba(0,0,0,0.08)")).selectAll("text").attr("fill","#767972").attr("font-size","11px"),c.append("g").call(We(y).ticks(6).tickFormat(j=>`${j}x`)).call(j=>j.select(".domain").remove()).call(j=>j.selectAll(".tick line").remove()).selectAll("text").attr("fill","#767972").attr("font-size","11px");const k=U(t).selectAll(".pe-tooltip").data([0]).join("div").attr("class","pe-tooltip").style("position","absolute").style("pointer-events","none").style("opacity","0").style("z-index","20").style("white-space","nowrap").style("background","#fbfaf7").style("border","1px solid #c9c5bb").style("border-radius","8px").style("padding","6px 10px").style("font-size","12px").style("color","#111722").style("box-shadow","0 2px 8px rgba(0,0,0,0.08)");for(let j=0;j<r.length;j++)c.selectAll(`.bar-${j}`).data(r[j].data).enter().append("rect").attr("x",R=>(h(String(R.x))??0)+(f(String(j))??0)).attr("y",R=>y(Number(R.y))).attr("width",f.bandwidth()).attr("height",R=>l-y(Number(R.y))).attr("fill",u[j]).attr("rx",2).style("cursor","pointer").on("mouseenter",function(R,N){U(this).attr("opacity",.7),k.html(`<strong>${N.x}</strong><br/>${x[j]}: ${Number(N.y).toFixed(1)}x`).style("opacity","1");const D=this.getBoundingClientRect(),M=t.getBoundingClientRect();k.style("left",`${D.left-M.left+D.width/2}px`).style("top",`${D.top-M.top-40}px`)}).on("mouseleave",function(){U(this).attr("opacity",1),k.style("opacity","0")});let v=i-280;const w=6;for(let j=0;j<x.length;j++)c.append("rect").attr("x",v).attr("y",w-5).attr("width",12).attr("height",12).attr("fill",u[j]).attr("rx",2),c.append("text").attr("x",v+18).attr("y",w+4).attr("font-size","11px").attr("fill","#28313f").text(x[j]),v+=18+x[j].length*6.5+16}function Lo({data:t}){const r=o.useRef(null),a=o.useRef(null),s=o.useRef(null),n=t.filter(l=>l.id.startsWith("wt__")),i=t.filter(l=>l.id.startsWith("pe__"));return o.useEffect(()=>{if(!a.current||!s.current)return;const l=()=>{To(a.current,n),Wo(s.current,i)};l();const d=new ResizeObserver(()=>l());return d.observe(a.current),d.observe(s.current),()=>d.disconnect()},[t]),!n.length&&!i.length?null:e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"top-10-weight-and-pe"}),e.jsxs("div",{ref:r,className:"multi-card-wrapper",style:{display:"flex",gap:16,width:"100%"},children:[e.jsx("div",{style:{flex:1,minWidth:0,background:"var(--markets-parchment)",border:"1px solid var(--markets-rule-soft)",borderRadius:4,overflow:"hidden"},children:e.jsx("div",{ref:a,style:{height:420,position:"relative"}}
5)}),e.jsx("div",{style:{flex:1,minWidth:0,background:"var(--markets-parchment)",border:"1px solid var(--markets-rule-soft)",borderRadius:4,overflow:"hidden"},children:e.jsx("div",{ref:s,style:{height:420,position:"relative"}})})]})]})}const rr={AAPL:"#111722",MSFT:"#2f63d6",AMZN:"#ea580c",NVDA:"#1a8b66",GOOGL:"#a33a3a",META:"#7c3aed",TSLA:"#d97706"},va={"Mag 7":"#6b8e23","S&P 493":"#4a90d9"};function Eo(t){const r=[];for(const a of t){const s=a.id.replace("perf__",""),n=a.data.map(l=>({date:String(l.x),value:Number(l.y)})).sort((l,d)=>l.date.localeCompare(d.date)),i={};for(const l of n){const d=parseInt(l.date.slice(0,4),10);i[d]=l.value}for(const l of[2023,2024,2025]){const d=l===2021?100:i[l-1],c=i[l];d!=null&&c!=null&&d>0&&r.push({ticker:s,year:l,ret:Math.round((c/d-1)*1e3)/10})}}return r}function zo(t,r){if(U(t).selectAll("*").remove(),!r.length)return;const a=t.clientWidth,s=340,n={top:46,right:20,left:48,bottom:36},i=a-n.left-n.right,l=s-n.top-n.bottom;if(i<=0||l<=0)return;const d=U(t).append("svg").attr("width",a).attr("height",s),c=d.append("g").attr("transform",`translate(${n.left},${n.top})`);d.append("text").attr("x",n.left).attr("y",16).attr("font-size","13px").attr("font-weight","700").attr("fill","#111722").text("Magnificent 7 performance in the S&P 500"),d.append("text").attr("x",n.left).attr("y",32).attr("font-size","10px").attr("fill","#6d716e").text("Indexed to 100 on 1/1/2021, price return");const u=r.map(k=>
5({ticker:k.id.replace("perf__",""),pts:k.data.map(v=>({date:new Date(String(v.x)),value:Number(v.y)})).sort((v,w)=>v.date.getTime()-w.date.getTime())})),x=u.flatMap(k=>k.pts),p=rt(x,k=>k.date),h=Oe(x,k=>k.value)??300,f=ur(x,k=>k.value)??0,g=Za().domain(p).range([0,i]),m=Ne().domain([Math.floor(f/50)*50,Math.ceil(h/50)*50]).nice().range([l,0]);c.selectAll(".grid").data(m.ticks(5)).enter().append("line").attr("x1",0).attr("x2",i).attr("y1",k=>m(k)).attr("y2",k=>m(k)).attr("stroke","rgba(0,0,0,0.06)").attr("stroke-dasharray","3 3"),c.append("g").attr("transform",`translate(0,${l})`).call(Te(g).ticks(5).tickFormat(k=>`'${String(ia("%y")(k))}`)).call(k=>k.select(".domain").attr("stroke","rgba(0,0,0,0.08)")).selectAll("text").attr("fill","#767972").attr("font-size","10px"),c.append("g").call(We(m).ticks(5)).call(k=>k.select(".domain").remove()).call(k=>k.selectAll(".tick line").remove()).selectAll("text").attr("fill","#767972").attr("font-size","10px");const y=hr().x(k=>g(k.date)).y(k=>m(k.value));for(const k of u){const v=rr[k.ticker]??"#6d716e";c.append("path").datum(k.pts).attr("d",y).attr("fill","none").attr("stroke",v).attr("stroke-width",1.8).attr("opacity",.85)}for(const k of u){const v=k.pts[k.pts.length-1];if(!v)continue;const w=rr[k.ticker]??"#6d716e";c.append("text").attr("x",g(v.date)+4).attr("y",m(v.value)+3).attr("font-size","9px").attr("font-weight","600").attr("fill",w).text(k.ticker)}const b=U(t).selectAll(".perf-tooltip").data([0]).join("div").attr("class","perf-tooltip").style("position","absolute").style("pointer-events","none").style("opacity","0").style("z-index","20").style("white-space","nowrap").style("background","#fbfaf7").style("border","1px solid #c9c5bb").style("border-radius","8px").style("padding","6px 10px").style("font-size","11px").style("color","#111722").style("box-shadow","0 2px 8px rgba(0,0,0,0.08)"),S=c.append("line").style("stroke","#767972").style("stroke-width","1px").style("stroke-dasharray","3,3").style("opacity","0");c.append("rect").attr("width",i).attr("height",l).attr("fill","none").style("pointer-events","all").on("mousemove",function(k){const[v]=xr(k),w=g.invert(v),j=[`<strong>${ia("%b %Y")(w)}</strong>`];for(const M of u){const $=en(B=>B.date).left,T=$(M.pts,w),A=M.pts[Math.min(T,M.pts.length-1)];if(A){const B=rr[M.ticker]??"#6d716e";j.push(`<span style="color:${B}">${M.ticker}: ${A.value.toFixed(0)}</span>`)}}S.attr("x1",v).attr("x2",v).attr("y1",0).attr("y2",l).style("opacity","1"),b.html(j.join("<br/>")).style("opacity","1");const R=b.node()?.offsetWidth??160,N=t.clientWidth;let D=v+n.left+14;D+R>N-4&&(D=v+n.left-R-14),D=Math.max(4,Math.min(D,N-R-4)),b.style("left",`${D}px`).style("top",`${n.top+20}px`)}).on("mouseleave",function(){S.style("opacity","0"),b.style("opacity","0")})}function Po(t,r){if(U(t).selectAll("*").remove(),!r.length)return;const a=t.clientWidth,s=260,n={top:40,right:20,left:48,bottom:30},i=a-n.left-n.right,l=s-n.top-n.bottom;if(i<=0||l<=0)return;const d=U(t).append("svg").attr("width",a).attr("height",s),c=d.append("g").attr("transform",`translate(${n.left},${n.top})`);d.append("text").attr("x",n.left).attr("y",16).attr("font-size","13px").attr("font-weight","700").attr("fill","#111722").text("Year-over-year earnings growth");const u=r.map(v=>v.id.replace("earn__","")),x=r[0].data.map(v=>String(v.x)),p=Ie().domain(x).range([0,i]).padding(.3),h=Ie().domain(r.map((v,w)=>String(w))).range([0,p.bandwidth()]).padding(.1),f=r.flatMap(v=>v.data.map(w=>Number(w.y))),g=Math.floor((ur(f)??-20)/10)*10,m=Math.ceil((Oe(f)??60)/10)*10,y=Ne().domain([g,m]).nice().range([l,0]);c.selectAll(".grid").data(y.ticks(5)).enter().append("line").attr("x1",0).attr("x2",i).attr("y1",v=>y(v)).attr("y2",v=>y(v)).attr("stroke","rgba(0,0,0,0.06)").attr("stroke-dasharray","3 3"),g<0&&c.append("line").attr("x1",0).attr("x2",i).attr("y1",y(0)).attr("y2",y(0)).attr("stroke","#111722").attr("stroke-width",1),c.append("g").attr("transform",`translate(0,${l})`).call(Te(p).tickFormat(v=>`'${v.slice(2)}`)).call(v=>v.select(".domain").attr("stroke","rgba(0,0,0,0.08)")).selectAll("text").attr("fill","#767972").attr("font-size","10px"),c.append("g").call(We(y).ticks(5).tickFormat(v=>`${v}%`)).call(v=>
5v.select(".domain").remove()).call(v=>v.selectAll(".tick line").remove()).selectAll("text").attr("fill","#767972").attr("font-size","10px");const b=U(t).selectAll(".earn-tooltip").data([0]).join("div").attr("class","earn-tooltip").style("position","absolute").style("pointer-events","none").style("opacity","0").style("z-index","20").style("white-space","nowrap").style("background","#fbfaf7").style("border","1px solid #c9c5bb").style("border-radius","8px").style("padding","6px 10px").style("font-size","11px").style("color","#111722").style("box-shadow","0 2px 8px rgba(0,0,0,0.08)");for(let v=0;v<r.length;v++){const w=u[v],j=va[w]??(v===0?"#6b8e23":"#4a90d9");c.selectAll(`.earn-bar-${v}`).data(r[v].data).enter().append("rect").attr("x",R=>(p(String(R.x))??0)+(h(String(v))??0)).attr("y",R=>Number(R.y)>=0?y(Number(R.y)):y(0)).attr("width",h.bandwidth()).attr("height",R=>Math.abs(y(Number(R.y))-y(0))).attr("fill",j).attr("rx",2).style("cursor","pointer").on("mouseenter",function(R,N){U(this).attr("opacity",.7),b.html(`<strong>${N.x}</strong><br/><span style="color:${j}">${w}: ${Number(N.y).toFixed(1)}%</span>`).style("opacity","1");const D=this.getBoundingClientRect(),M=t.getBoundingClientRect(),$=b.node()?.offsetWidth??120,T=D.left-M.left+D.width/2,A=Math.max(4,Math.min(T-$/2,t.clientWidth-$-4));b.style("left",`${A}px`).style("top",`${D.top-M.top-36}px`)}).on("mouseleave",function(){U(this).attr("opacity",1),b.style("opacity","0")}),c.selectAll(`.earn-label-${v}`).data(r[v].data).enter().append("text").attr("x",R=>(p(String(R.x))??0)+(h(String(v))??0)+h.bandwidth()/2).attr("y",R=>Number(R.y)>=0?y(Number(R.y))-4:y(Number(R.y))+12).attr("text-anchor","middle").attr("font-size","9px").attr("font-weight","600").attr("fill",j).text(R=>`${Math.round(Number(R.y))}%`)}let S=i-200;const k=-20;for(let v=0;v<u.length;v++){const w=va[u[v]]??(v===0?"#6b8e23":"#4a90d9");c.append("rect").attr("x",S).attr("y",k-5).attr("width",10).attr("height",10).attr("fill",w).attr("rx",2),c.append("text").attr("x",S+14).attr("y",k+4).attr("font-size","10px").attr("fill","#28313f").text(u[v]),S+=14+u[v].length*6+14}}function Bo(t,r){if(U(t).selectAll("*").remove(),!r.length)return;const a=t.clientWidth,s=600,n={top:46,right:16,left:48,bottom:30},i=a-n.left-n.right,l=s-n.top-n.bottom;if(i<=0||l<=0)return;const d=U(t).append("svg").attr("width",a).attr("height",s),c=d.append("g").attr("transform",`translate(${n.left},${n.top})`);d.append("text").attr("x",n.left).attr("y",16).attr("font-size","13px").attr("font-weight","700").attr("fill","#111722").text("Magnificent 7 performance dispersion"),d.append("text").attr("x",n.left).attr("y",32).attr("font-size","10px").attr("fill","#6d716e").text("Price return");const u=[...new Set(r.map(b=>b.year))].sort(),x=[...new Set(r.map(b=>b.ticker))],p=Math.ceil((Oe(r,b=>b.ret)??100)/25)*25,h=Math.min(0,Math.floor((ur(r,b=>b.ret)??0)/25)*25),f=Ne().domain([h,p]).nice().range([l,0]),g=Ie().domain(u.map(String)).range([0,i]).padding(.15),m=Ie().domain(x).range([0,g.bandwidth()]).padding(.08);c.selectAll(".grid").data(f.ticks(6)).enter().append("line").attr("x1",0).attr("x2",i).attr("y1",b=>f(b)).attr("y2",b=>f(b)).attr("stroke","rgba(0,0,0,0.06)").attr("stroke-dasharray","3 3"),c.append("line").attr("x1",0).attr("x2",i).attr("y1",f(0)).attr("y2",f(0)).attr("stroke","#111722").attr("stroke-width",1),c.append("g").call(We(f).ticks(6).tickFormat(b=>`${b}%`)).call(b=>b.select(".domain").remove()).call(b=>b.selectAll(".tick line").remove()).selectAll("text").attr("fill","#767972").attr("font-size","10px"),c.append("g").attr("transform",`translate(0,${l})`).call(Te(g).tickFormat(b=>`'${b.slice(2)}`)).call(b=>b.select(".domain").attr("stroke","rgba(0,0,0,0.08)")).selectAll("text").attr("fill","#767972").attr("font-size","11px");const y=U(t).selectAll(".disp-tooltip").data([0]).join("div").attr("class","disp-tooltip").style("position","absolute").style("pointer-events","none").style("opacity","0").style("z-index","20").style("white-space","nowrap").style("background","#fbfaf7").style("border","1px solid #c9c5bb").style("border-radius","8px").style("padding","6px 10px").style("font-size","11px").style("color","#111722").style("box-shadow","0 2px 8px rgba(0,0,0,0.08)");for(const b of r){const S=(g(String(b.year))??0)+(m(b.ticker)??0),k=m.bandwidth(),v=rr[b.ticker]??"#6d716e",w=b.ret>=0?f(b.ret):f(0),j=Math.abs(f(b.ret)-f(0));c.append("rect").attr("x",S).attr("y",w).attr("width",k).attr("height",Math.max(j,1)).attr("fill",v).attr("rx",2).attr("opacity",.85).style("cursor","pointer").on("mouseenter",function(){U(this).attr("opacity",1),y.html(`<strong>${b.ticker} (${b.year})</strong><br/>Return: ${b.ret.toFixed(1)}%`).style("opacity","1");const R=this.getBoundingClientRect(),N=t.getBoundingClientRect(),D=y.node()?.offsetWidth??120,M=R.left-N.left+R.width/2,$=Math.max(4,Math.min(M-D/2,t.clientWidth-D-4));y.style("left",`${$}px`).style("top",`${R.top-N.top-36}px`)}
5).on("mouseleave",function(){U(this).attr("opacity",.85),y.style("opacity","0")}),c.append("text").attr("x",S+k/2).attr("y",b.ret>=0?w-4:w+j+10).attr("text-anchor","middle").attr("font-size","8px").attr("font-weight","600").attr("fill",v).text(b.ticker)}}function Io({data:t}){const r=o.useRef(null),a=o.useRef(null),s=o.useRef(null),n=o.useRef(null),i=t.filter(c=>c.id.startsWith("perf__")),l=t.filter(c=>c.id.startsWith("earn__")),d=o.useMemo(()=>Eo(i),[t]);return o.useEffect(()=>{if(!a.current||!s.current||!n.current)return;const c=()=>{zo(a.current,i),Po(s.current,l),Bo(n.current,d)};c();const u=new ResizeObserver(()=>c());return u.observe(a.current),u.observe(s.current),u.observe(n.current),()=>u.disconnect()},[t,d]),!i.length&&!l.length?null:e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"magnificent-7-combined"}),e.jsxs("div",{ref:r,className:"multi-card-wrapper",style:{display:"flex",gap:16,width:"100%"},children:[e.jsxs("div",{style:{flex:"0 0 55%",display:"flex",flexDirection:"column",gap:16},children:[e.jsx("div",{style:{background:"var(--markets-parchment)",border:"1px solid var(--markets-rule-soft)",borderRadius:4,overflow:"hidden"},children:e.jsx("div",{ref:a,style:{height:340,position:"relative"}})}),e.jsx("div",{style:{background:"var(--markets-parchment)",border:"1px solid var(--markets-rule-soft)",borderRadius:4,overflow:"hidden"},children:e.jsx("div",{ref:s,style:{height:260,position:"relative"}})})]}),e.jsx("div",{style:{flex:1,minWidth:0,background:"var(--markets-parchment)",border:"1px solid var(--markets-rule-soft)",borderRadius:4,overflow:"hidden"},children:e.jsx("div",{ref:n,style:{height:600,position:"relative"}})})]})]})}function Oo({data:t}){const r=o.useRef(null),a=t.find(n=>n.id==="annual_return"),s=t.find(n=>n.id==="max_drawdown");return o.useEffect(()=>{if(!r.current||!a)return;const n=r.current,i=()=>{U(n).selectAll("*").remove();const d=n.clientWidth,c=420,u={top:12,right:20,left:48,bottom:50},x=d-u.left-u.right,p=c-u.top-u.bottom;if(x<=0||p<=0)return;const f=U(n).append("svg").attr("width",d).attr("height",c).append("g").attr("transform",`translate(${u.left},${u.top})`),g=a.data.map(M=>String(M.x)),m=a.data.map(M=>Number(M.y)),y=s?s.data.map(M=>Number(M.y)):[],b=Ie().domain(g).range([0,x]).padding(.2),S=[...m,...y],k=Math.floor((ur(S)??-40)/10)*10,v=Math.ceil((Oe(S)??40)/10)*10,w=Ne().domain([k,v]).nice().range([p,0]);f.selectAll(".grid").data(w.ticks(8)).enter().append("line").attr("x1",0).attr("x2",x).attr("y1",M=>w(M)).attr("y2",M=>w(M)).attr("stroke","rgba(0,0,0,0.06)").attr("stroke-dasharray","3 3"),f.append("line").attr("x1",0).attr("x2",x).attr("y1",w(0)).attr("y2",w(0)).attr("stroke","#111722").attr("stroke-width",1);const j=g.filter(M=>Number(M)%5===0);f.append("g").attr("transform",`translate(0,${p})`).call(Te(b).tickValues(j)).call(M=>M.select(".domain").attr("stroke","rgba(0,0,0,0.08)")).call(M=>M.selectAll(".tick line").attr("stroke","rgba(0,0,0,0.08)")).selectAll("text").attr("fill","#767972").attr("font-size","11px").attr("transform","rotate(-35)").attr("text-anchor","end"),f.append("g").call(We(w).ticks(8).tickFormat(M=>`${M}%`)).call(M=>M.select(".domain").remove()).call(M=>M.selectAll(".tick line").remove()).selectAll("text").attr("fill","#767972").attr("font-size","11px");const R=U(n).selectAll(".ar-tooltip").data([0]).join("div").attr("class","ar-tooltip").style("position","absolute").style("pointer-events","none").style("opacity","0").style("z-index","20").style("white-space","nowrap").style("background","#fbfaf7").style("border","1px solid #c9c5bb").style("border-radius","8px").style("padding","6px 10px").style("font-size","12px").style("color","#111722").style("box-shadow","0 2px 8px rgba(0,0,0,0.08)");f.selectAll(".return-bar").data(a.data).enter().append("rect").attr("x",M=>b(String(M.x))??0).attr("y",M=>Number(M.y)>=0?w(Number(M.y)):w(0)).attr("width",b.bandwidth()).attr("height",M=>Math.abs(w(Number(M.y))-w(0))).attr("fill",M=>(Number(M.y)>=0,"#6d716e")).attr("rx",1).style("cursor","pointer").on("mouseenter",function(M,$){U(this).attr("opacity",.7);const T=String($.x),A=s?.data.find(V=>String(V.x)===T);let B=`<strong>${T}</strong><br/>Return: <span style="color:${Number($.y)>=0?"#1a8b66":"#a33a3a"}">${Number($.y).toFixed(1)}%</span>`;A&&(B+=`<br/>
5Max Drawdown: <span style="color:#a33a3a">${Number(A.y).toFixed(1)}%</span>`),R.html(B).style("opacity","1");const _=this.getBoundingClientRect(),E=n.getBoundingClientRect();R.style("left",`${_.left-E.left+_.width/2}px`).style("top",`${_.top-E.top-50}px`)}).on("mouseleave",function(){U(this).attr("opacity",1),R.style("opacity","0")}),s&&f.selectAll(".dd-dot").data(s.data).enter().append("circle").attr("cx",M=>(b(String(M.x))??0)+b.bandwidth()/2).attr("cy",M=>w(Number(M.y))).attr("r",3.5).attr("fill","#a33a3a").style("cursor","pointer").on("mouseenter",function(M,$){U(this).attr("r",5);const T=String($.x),A=a.data.find(V=>String(V.x)===T);let B=`<strong>${T}</strong>`;A&&(B+=`<br/>Return: <span style="color:${Number(A.y)>=0?"#1a8b66":"#a33a3a"}">${Number(A.y).toFixed(1)}%</span>`),B+=`<br/>Max Drawdown: <span style="color:#a33a3a">${Number($.y).toFixed(1)}%</span>`,R.html(B).style("opacity","1");const _=(b(T)??0)+b.bandwidth()/2+u.left,E=w(Number($.y))+u.top;R.style("left",`${_+10}px`).style("top",`${E-20}px`)}).on("mouseleave",function(){U(this).attr("r",3.5),R.style("opacity","0")});const N=8;let D=x-280;f.append("rect").attr("x",D).attr("y",N-5).attr("width",14).attr("height",14).attr("fill","#6d716e").attr("rx",2),f.append("text").attr("x",D+20).attr("y",N+5).attr("font-size","11px").attr("fill","#28313f").text("Calendar Year Return"),D+=160,f.append("circle").attr("cx",D+5).attr("cy",N+2).attr("r",4).attr("fill","#a33a3a"),f.append("text").attr("x",D+14).attr("y",N+5).attr("font-size","11px").attr("fill","#28313f").text("Intra-Year Max Drawdown")};i();const l=new ResizeObserver(()=>i());return l.observe(n),()=>l.disconnect()},[t]),a?e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"annual-returns"}),e.jsx("div",{ref:r,style:{width:"100%",height:420,position:"relative"}})]}):null}const wr=["#111722","#2f63d6","#1a8b66","#d97706","#a33a3a","#7c3aed","#0891b2","#be185d","#65a30d","#6366f1"];function Yo({data:t}){const r=o.useRef(null),a=o.useRef(null);let s=null;try{t?.length&&t[0]?.data?.[0]?.x&&(s=JSON.parse(String(t[0].data[0].x)))}catch{}return o.useEffect(()=>{if(!r.current||!s)return;const n=r.current,i=()=>{U(n).selectAll("*").remove();const d=Object.keys(s).sort();if(!d.length)return;const c=n.clientWidth,u=500,x={top:16,right:24,left:64,bottom:40},p=c-x.left-x.right,h=u-x.top-x.bottom;if(p<=0||h<=0)return;const f=U(n).append("svg").attr("width",c).attr("height",u),g=f.append("g").attr("transform",`translate(${x.left},${x.top})`),m=d.map(N=>{const D={decade:N},M=s[N]??[];for(let $=0;$<10;$++)D[`r${$}`]=M[$]?.mktcap_b??0;return D}),y=Array.from({length:10},(N,D)=>`r${D}`),S=Bn().keys(y).order(In).offset(On)(m),k=Ie().domain(d).range([0,p]).padding(.3),v=Oe(S[S.length-1],N=>N[1])??1e3,w=Ne().domain([0,Math.ceil(v/500)*500]).nice().range([h,0]);g.selectAll(".grid").data(w.ticks(6)).enter().append("line").attr("x1",0).attr("x2",p).attr("y1",N=>w(N)).attr("y2",N=>w(N)).attr("stroke","rgba(0,0,0,0.06)").attr("stroke-dasharray","3 3"),g.append("g").attr("transform",`translate(0,${h})`).call(Te(k)).call(N=>N.select(".domain").attr("stroke","rgba(0,0,0,0.08)")).selectAll("text").attr("fill","#111722").attr("font-size","12px").attr("font-weight","600"),g.append("g").call(We(w).ticks(6).tickFormat(N=>`$${Yn(",")(Number(N))}B`)).call(N=>N.select(".domain").remove()).call(N=>N.selectAll(".tick line").remove()).selectAll("text").attr("fill","#767972").attr("font-size","11px");const j=U(n).selectAll(".decade-tooltip").data([0]).join("div").attr("class","decade-tooltip").style("position","absolute").style("pointer-events","none").style("opacity","0").style("z-index","20").style("white-space","nowrap").style("background","#fbfaf7").style("border","1px solid #c9c5bb").style("border-radius","8px").style("padding","6px 10px").style("font-size","11px").style("color","#111722").style("box-shadow","0 2px 8px rgba(0,0,0,0.08)");for(let N=0;N<S.length;N++){const D=S[N],M=wr[N%wr.length],$=N+1;g.selectAll(`.bar-r${N}`).data(D).enter().append("rect").attr("x",T=>k(String(T.data.decade))??0).attr("y",T=>w(T[1])).attr("width",k.bandwidth()).attr("height",T=>Math.max(0,w(T[0])-w(T[1]))).attr("fill",M).style("cursor","pointer").on("mouseenter",function(T,A){const B=String(A.data.decade),E=(s[B]??[])[N];if(!E)return;U(this).attr("opacity",.75),j.html(`<strong>#${$} â ${E.ticker||E.company}</strong><br/>
5${E.company}<br/>Market Cap: $${E.mktcap_b.toFixed(1)}B`).style("opacity","1");const V=this.getBoundingClientRect(),W=n.getBoundingClientRect();j.style("left",`${V.left-W.left+V.width+8}px`).style("top",`${V.top-W.top+V.height/2-20}px`)}).on("mouseleave",function(){U(this).attr("opacity",1),j.style("opacity","0")}),g.selectAll(`.label-r${N}`).data(D).enter().append("text").attr("x",T=>(k(String(T.data.decade))??0)+k.bandwidth()/2).attr("y",T=>{const A=w(T[0])-w(T[1]);return w(T[1])+A/2+3}).attr("text-anchor","middle").attr("font-size",T=>w(T[0])-w(T[1])>18?"9px":"0px").attr("font-weight","600").attr("fill","#fbfaf7").text(T=>{const A=String(T.data.decade);return(s[A]??[])[N]?.ticker??""})}const R=f.append("g").attr("transform",`translate(${x.left+p+4}, ${x.top})`);for(let N=0;N<10;N++){const D=N*18;R.append("rect").attr("x",0).attr("y",D).attr("width",10).attr("height",10).attr("fill",wr[N]).attr("rx",2),R.append("text").attr("x",14).attr("y",D+9).attr("font-size","9px").attr("fill","#6d716e").text(`#${N+1}`)}};i();const l=new ResizeObserver(()=>i());return l.observe(n),()=>l.disconnect()},[s]),s?e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:a,exportFilename:"top-companies-by-decade"}),e.jsx("div",{ref:a,children:e.jsx("div",{ref:r,style:{width:"100%",height:500,position:"relative"}})})]}):null}const zt={padding:"6px 8px",textAlign:"center",fontVariantNumeric:"tabular-nums",fontSize:12,borderBottom:"1px solid #c9c5bb",borderRight:"1px solid #c9c5bb"},$e={...zt,fontWeight:600,fontSize:11,color:"#6d716e",background:"#f6f3ec"},Qr={...zt,fontWeight:700,fontSize:12,color:"#111722",writingMode:"vertical-rl",textOrientation:"mixed",transform:"rotate(180deg)",textAlign:"center",width:28,padding:"8px 4px",background:"#ece8df"};function pn(t,r="%"){return t==null?"â":`${t.toFixed(1)}${r}`}function Ot({title:t,sections:r,field:a,titleColor:s}){return e.jsx("div",{style:{flex:1,minWidth:0},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",border:"1px solid #c9c5bb"},children:[e.jsxs("thead",{children:[e.jsx("tr",{children:e.jsx("th",{colSpan:4,style:{padding:"6px 8px",textAlign:"center",fontSize:12,fontWeight:700,color:s??"#111722",borderBottom:"2px solid #c9c5bb",background:"#f6f3ec"},children:t})}),e.jsxs("tr",{children:[e.jsx("th",{style:{...$e,width:28}}),e.jsx("th",{style:$e,children:"Value"}),e.jsx("th",{style:$e,children:"Blend"}),e.jsx("th",{style:{...$e,borderRight:"none"},children:"Growth"})]})]}),e.jsx("tbody",{children:r.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:Qr,children:n.label.replace(" Cap","")}),n.rows.map((i,l)=>e.jsx("td",{style:{...zt,fontWeight:600,color:"#111722",...l===n.rows.length-1?{borderRight:"none"}:{}},children:pn(i[a])},i.bucket))]},n.label))})]})})}function Vo({sections:t}){return e.jsx("div",{style:{flex:1,minWidth:0},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",border:"1px solid #c9c5bb"},children:[e.jsxs("thead",{children:[e.jsx("tr",{children:e.jsx("th",{colSpan:4,style:{padding:"6px 8px",textAlign:"center",fontSize:13,fontWeight:700,color:"#111722",borderBottom:"2px solid #c9c5bb",background:"#f6f3ec"},children:"P/E vs. 20-year avg. P/E"})}),e.jsxs("tr",{children:[e.jsx("th",{style:{...$e,width:28}}),e.jsx("th",{style:$e,children:"Value"}),e.jsx("th",{style:$e,children:"Blend"}),e.jsx("th",{style:{...$e,borderRight:"none"},children:"Growth"})]})]}),e.jsx("tbody",{children:t.map(r=>e.jsxs("tr",{children:[e.jsx("td",{style:Qr,children:r.label.replace(" Cap","")}),r.rows.map((a,s)=>{const n=a.current_pe,i=a.avg_pe_20y;return e.jsxs("td",{style:{...zt,position:"relative",height:56,...s===r.rows.length-1?{borderRight:"none"}:{}},children:[e.jsx("div",{style:{position:"absolute",top:6,left:8,fontSize:13,fontWeight:600,color:"#111722"},children:n!=null?n.toFixed(1):"â"}),e.jsx("div",{style:{position:"absolute",top:4,left:4,right:4,bottom:4,borderBottom:"1px solid #767972"}}),e.jsx("div",{style:{position:"absolute",bottom:6,right:8,fontSize:13,fontWeight:600,color:"#111722"},children:i!=null?i.toFixed(1):"â"})]},a.bucket)})]},r.label))})]})})}function Ko({sections:t}){return e.jsx("div",{style:{flex:1,minWidth:0},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",border:"1px solid #c9c5bb"},children:[e.jsxs("thead",{children:[e.jsx("tr",{children:e.jsx("th",{colSpan:4,style:{padding:"6px 8px",textAlign:"center",fontSize:13,fontWeight:700,color:"#111722",borderBottom:"2px s
5olid #c9c5bb",background:"#f6f3ec"},children:"P/E as % of 20-year avg. P/E"})}),e.jsxs("tr",{children:[e.jsx("th",{style:{...$e,width:28}}),e.jsx("th",{style:$e,children:"Value"}),e.jsx("th",{style:$e,children:"Blend"}),e.jsx("th",{style:{...$e,borderRight:"none"},children:"Growth"})]})]}),e.jsx("tbody",{children:t.map(r=>e.jsxs("tr",{children:[e.jsx("td",{style:Qr,children:r.label.replace(" Cap","")}),r.rows.map((a,s)=>e.jsx("td",{style:{...zt,fontWeight:600,color:"#111722",...s===r.rows.length-1?{borderRight:"none"}:{}},children:pn(a.pe_pct_of_avg)},a.bucket))]},r.label))})]})})}function Uo({data:t}){const r=o.useRef(null);if(!t?.length||!t[0]?.data?.[0]?.x)return null;let a;try{a=JSON.parse(String(t[0].data[0].x))}catch{return null}return a?.sections?.length?e.jsxs("div",{style:{width:"100%",overflowX:"auto"},children:[e.jsx(L,{exportRef:r,exportFilename:"style-returns"}),e.jsxs("div",{ref:r,children:[e.jsxs("div",{className:"multi-card-wrapper",style:{display:"flex",gap:8,marginBottom:12},children:[e.jsx(Ot,{title:"10-yr ann.",sections:a.sections,field:"return_10y"}),e.jsx(Ot,{title:"2025",sections:a.sections,field:"return_2025",titleColor:"#6b8e23"}),e.jsx(Ot,{title:"Since peak (Jan '22)",sections:a.sections,field:"return_since_peak"}),e.jsx(Ot,{title:"Since low (Oct '22)",sections:a.sections,field:"return_since_low",titleColor:"#6b8e23"})]}),e.jsxs("div",{className:"multi-card-wrapper",style:{display:"flex",gap:8},children:[e.jsx(Vo,{sections:a.sections}),e.jsx(Ko,{sections:a.sections})]})]})]}):null}function Ho({data:t}){const r=o.useRef(null);if(!t?.length||!t[0]?.data?.[0]?.x)return null;let a;try{a=JSON.parse(String(t[0].data[0].x))}catch{return null}const s=a.data??[];return s.length?e.jsxs("div",{children:[e.jsx(L,{exportRef:r,exportFilename:"sector-overview"}),e.jsxs("div",{ref:r,style:{width:"100%",overflowX:"auto"},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{color:C.muted,borderBottom:`2px solid ${C.text}`},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",fontWeight:600},children:"Sector"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600},children:"Weight %"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600},children:"P/E"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600},children:"Margin %"})]})}),e.jsx("tbody",{children:s.map(n=>e.jsxs("tr",{style:{borderBottom:"1px solid rgba(0,0,0,0.06)",color:C.text},children:[e.jsx("td",{style:{padding:"8px 12px",fontWeight:500},children:n.sector}),e.jsx("td",{style:{padding:"8px 12px",textAlign:"right",fontVariantNumeric:"tabular-nums"},children:n.weight.toFixed(1)}),e.jsx("td",{style:{padding:"8px 12px",textAlign:"right",fontVariantNumeric:"tabular-nums",color:n.pe==null?C.muted:void 0},children:n.pe!=null?n.pe.toFixed(1):"--"}),e.jsx("td",{style:{padding:"8px 12px",textAlign:"right",fontVariantNumeric:"tabular-nums",color:n.margin==null?C.muted:void 0},children:n.margin!=null?n.margin.toFixed(1):"--"})]},n.sector))})]}),a.year&&e.jsxs("p",{style:{fontSize:11,color:C.muted,marginTop:8,textAlign:"right"},children:["Fiscal year ",a.year]})]})]}):null}const qo=[{value:"all",label:"All Stocks"},{value:"large-caps",label:"US Large Caps"}],Xo=[{value:"1d",label:"1D"},{value:"ytd",label:"YTD"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"}],Qe="px-2 py-1.5 font-data text-[10px] font-medium uppercase tracking-[0.06em] text-ink-muted",Ve="px-2 py-1.5",vt="text-right tabular-nums";function Nr({onMouseDown:t}){return e.jsx("span",{onMouseDown:t,onClick:r=>r.stopPropagation(),role:"separator","aria-orientation":"vertical",title:"Drag to resize column",style:{position:"absolute",top:0,right:-3,width:8,height:"100%",cursor:"col-resize",userSelect:"none",zIndex:1}})}function Go({pinned:t}){const[r,a]=o.useState("1d"),[s,n]=o.useState(t?.date??""),[i,l]=o.useState([]),[d,c]=o.useState(!0),[u,x]=o.useState(!1),[p,h]=o.useState(null),[f,g]=o.useState("all"),m=o.useRef(!1),y=o.useRef(null),b=o.useRef(null),S=dr(),[k,v]=o.useState({symbol:220,type:90,industry:220}),w=o.useRef(null),j=o.useCallback((A,B)=>{B.preventDefault(),B.stopPropagation(),w.current={key:A,startX:B.clientX,startW:k[A]};const _=V=>{const W=w.current;if(!W)return;const K=Math.max(60,W.startW+(V.clientX-W.startX));v(re=>({...re,[W.key]:K}))},E=()=>{w.current=null,window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",E)};window.addEventListener("mousemove",_),window.addEventListener("mouseup",E)},[k]),R=o.useCallback(async(A,B)=>{y.current?.abort();const _=new AbortController;y.current=_,c(!0),x(!1);const E=(B??f)==="large-caps"?"&universe=large-caps":"";try{const V=A?`&date=${A}`:"",K=await(await fetch(`/api/markets/daily?chart=top-gainers-losers${V}${E}`,{signal:_.signal})).json();if(_.signal.aborted)return;K.ok?(l(K.data),K.meta?.availableRange&&h(K.meta.availableRange),K.meta?.date&&n(String(K.meta.date).slice(0,10))):x(!0)}catch(V){if(V.name==="AbortError")return;console.error("TopGainersLosers fetch error:",V),x(!0)}finally{_.signal.aborted||c(!1)}},[f]),N=o.useCallback(async(A,B)=>{c(!0);const _=(B??f)==="large-caps"?"&universe=large-caps":"";try{const V=await(await fetch(`/api/markets/daily?chart=top-gainers-losers-period&interval=${A}${_}`)).json();V.ok&&l(V.data)}catch(E){console.error("TopGainersLosers period fetch error:",E)}finally{c(!1)}},[f]);o.useEffect(()=>{m.current||(m.current=!0,R(t?.date))},[R]);const D=o.useCallback(A=>{a(A),A==="1d"?R(s||void 0):N(A)},[s,R,N]),M=o.useCallback(A=>{g(A),r==="1d"?R(s||void 0,A):N(r,A)},[s,r,R,N]),$=r!=="1d",T=o.useMemo(()=>
5{if(!i.length)return[];const A=i.slice(0,5).sort((_,E)=>Number(E.pct_change)-Number(_.pct_change)),B=i.slice(5).sort((_,E)=>Number(_.pct_change)-Number(E.pct_change));return[...A,...B].map(_=>({name:_.symbol,value:Number(Number(_.pct_change).toFixed(2)),industry:_.industry||"â"}))},[i]);return d&&!i.length?e.jsxs("div",{className:"w-full",children:[e.jsx("div",{className:"markets-skeleton mb-3 h-6 w-1/2"}),e.jsx("div",{className:"markets-skeleton h-[300px]"})]}):e.jsxs("div",{className:"w-full",children:[e.jsx(L,{interval:r,intervalOptions:Xo,onInterval:D,startDate:$?void 0:s,minDate:p?.min?.slice(0,10),maxDate:p?.max?.slice(0,10),onStartDate:$?void 0:A=>{n(A),R(A)},loading:d,pills:qo,pillValue:f,onPill:A=>M(A),exportRef:b,exportFilename:"top-gainers-losers",children:u&&!d&&e.jsx("span",{className:"font-data text-[11px] text-market-red",children:"Failed to load data. Try another date."})}),T.length>0?e.jsx("div",{ref:b,className:"bg-parchment",children:e.jsx(q,{width:"100%",height:420,children:e.jsxs(Ce,{data:T,margin:{top:20,right:12,left:8,bottom:24},children:[e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"name",...ne}),e.jsx(X,{...de,label:Me("% change")}),e.jsx(le,{y:0,...En}),e.jsx(Z,{content:({active:A,payload:B})=>{if(!A||!B?.length)return null;const _=B[0].payload;return e.jsxs("div",{className:"rounded-[4px] border border-rule bg-paper-raised px-3 py-2 text-xs shadow-[0_2px_8px_rgba(17,23,34,0.08)]",children:[e.jsx("div",{className:"font-semibold text-ink",children:_.name}),e.jsx("div",{className:"mt-0.5 mb-1 text-[11px] text-ink-soft",children:_.industry}),e.jsxs("div",{className:_.value>=0?"font-semibold tabular-nums text-market-green-deep":"font-semibold tabular-nums text-market-red-deep",children:[_.value>0?"+":"",_.value.toFixed(2),"%"]})]})}}),e.jsx(ye,{dataKey:"value",radius:zn,isAnimationActive:!1,label:({x:A,y:B,width:_,height:E,value:V})=>{const W=Number(V),K=Number(A)+Number(_)/2,re=Number(B)+Number(E)/2+4,se=`${W>0?"+":""}${W.toFixed(1)}%`;return e.jsx("text",{x:K,y:re,textAnchor:"middle",fontSize:10,fontWeight:600,fill:br.paperRaised,transform:S?`rotate(-90 ${K} ${re})`:void 0,children:se})},children:T.map((A,B)=>e.jsx(De,{fill:A.value>=0?br.positive:br.negative},B))})]})})}):e.jsxs("div",{className:"p-10 text-center text-sm text-ink-muted",children:["No data available for the selected ",$?"period":"date","."]}),e.jsx("p",{className:"markets-exhibit-note",children:$?"% change is calculated from the first close to the last close of the selected period.":"% change is calculated close-to-close (previous day's closing price to current day's closing price)."}),i.length>0&&e.jsxs("div",{className:"mt-4 overflow-x-auto",children:[e.jsxs("table",{className:"w-full table-fixed border-collapse text-[13px]",style:{minWidth:k.symbol+k.type+k.industry+($?274:374)},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:k.symbol}}),e.jsx("col",{style:{width:k.type}}),e.jsx("col",{style:{width:k.industry}}),e.jsx("col",{style:{width:92}}),e.jsx("col",{style:{width:90}}),e.jsx("col",{style:{width:90}}),!$&&e.jsx("col",{style:{width:100}})]}),e.jsx("thead",{children:e.jsxs("tr",{className:"border-b-2 border-evergreen",children:[e.jsxs("th",{className:`${Qe} relative text-left`,children:["Symbol",e.jsx(Nr,{onMouseDown:A=>j("symbol",A)})]}),e.jsxs("th",{className:`${Qe} relative text-left`,children:["Type",e.jsx(Nr,{onMouseDown:A=>j("type",A)})]}),e.jsxs("th",{className:`${Qe} relative text-left`,children:["Industry",e.jsx(Nr,{onMouseDown:A=>j("industry",A)})]}),e.jsx("th",{className:`${Qe} text-right`,children:"Change"}),e.jsx("th",{className:`${Qe} text-right`,children:$?"Period Open":"Open"}),e.jsx("th",{className:`${Qe}
5 text-right`,children:$?"Period Close":"Close"}),!$&&e.jsx("th",{className:`${Qe} text-right`,children:"Volume"})]})}),e.jsx("tbody",{children:[...i.slice(0,5).sort((A,B)=>Number(B.pct_change)-Number(A.pct_change)),...i.slice(5).sort((A,B)=>Number(A.pct_change)-Number(B.pct_change))].map(A=>{const B=Number(A.pct_change);return e.jsxs("tr",{className:"border-b border-rule-soft hover:bg-[rgba(119,132,114,0.055)]",children:[e.jsxs("td",{className:`${Ve} truncate text-ink`,title:A.company_name?`${A.symbol} â ${A.company_name}`:A.symbol,children:[e.jsx("span",{className:"font-semibold",children:A.symbol}),A.company_name&&e.jsx("span",{className:"ml-1.5 text-xs text-ink-soft",children:A.company_name})]}),e.jsx("td",{className:`${Ve} font-data text-[11px] text-ink-soft`,children:A.security_type||"â"}),e.jsx("td",{className:`${Ve} truncate text-xs text-ink-soft`,title:A.industry||void 0,children:A.industry||"â"}),e.jsxs("td",{className:B>=0?`${Ve} ${vt} font-semibold text-market-green-deep`:`${Ve} ${vt} font-semibold text-market-red-deep`,children:[B>0?"+":"",B.toFixed(2),"%"]}),e.jsxs("td",{className:`${Ve} ${vt} text-ink`,children:["$",Number(A.day_open).toFixed(2)]}),e.jsxs("td",{className:`${Ve} ${vt} text-ink`,children:["$",Number(A.day_close).toFixed(2)]}),!$&&e.jsx("td",{className:`${Ve} ${vt} text-ink`,children:Number(A.day_volume).toLocaleString()})]},A.symbol)})})]}),e.jsxs("div",{className:"mt-2.5 flex flex-wrap gap-x-3 gap-y-1 font-data text-[10px] text-ink-muted",children:[e.jsx("span",{className:"uppercase tracking-[0.06em]",children:"Type:"}),e.jsxs("span",{children:[e.jsx("strong",{children:"CS"})," Common Stock"]}),e.jsxs("span",{children:[e.jsx("strong",{children:"ETF"})," Exchange-Traded Fund"]}),e.jsxs("span",{children:[e.jsx("strong",{children:"ADRC"})," ADR Common"]}),e.jsxs("span",{children:[e.jsx("strong",{children:"PFD"})," Preferred"]}),e.jsxs("span",{children:[e.jsx("strong",{children:"WARRANT"})," Warrant"]}),e.jsxs("span",{children:[e.jsx("strong",{children:"RIGHT"})," Right"]}),e.jsxs("span",{children:[e.jsx("strong",{children:"ETN"})," Exchange-Traded Note"]}),e.jsxs("span",{children:[e.jsx("strong",{children:"UNIT"})," Unit"]}),e.jsxs("span",{children:[e.jsx("strong",{children:"FUND"})," Fund"]}),e.jsxs("span",{children:[e.jsx("strong",{children:"SP"})," Structured Product"]})]})]})]})}function fn(t){if(t==null||!Number.isFinite(t))return"";const r=Math.abs(t);return r>=1e9?`${(t/1e9).toFixed(1)}B`:r>=1e6?`${(t/1e6).toFixed(1)}M`:r>=1e3?`${(t/1e3).toFixed(0)}K`:String(Math.round(t))}const Qo="#a7a49c",Jo=96;function Zo(t){const r=t.height??Jo,a=t.mode==="categorical"&&t.signed===!0,s=t.mode==="categorical"&&t.format?t.format:fn;return e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"mb-1 pl-2 text-[11px] font-medium uppercase tracking-wide text-gray-400",children:t.title??"Volume"}),e.jsx(q,{width:"100%",height:r,children:e.jsxs(Ce,{data:t.data,margin:{...we,top:4,bottom:4},barCategoryGap:t.mode==="timeseries"?"10%":"20%",children:[e.jsx(J,{...ce,vertical:!1}),t.mode==="categorical"?e.jsx(Q,{dataKey:"name",tick:{fontSize:11,fill:"#6d716e"},tickLine:!1,axisLine:{stroke:"rgba(0,0,0,0.08)"},interval:0}):e.jsx(Q,{dataKey:t.xKey??"date",...ne}),e.jsx(X,{...de,tickFormatter:n=>s(n)}),e.jsx(Z,{contentStyle:pe,cursor:{fill:"rgba(0,0,0,0.03)"},formatter:(n,i)=>[s(Number(n)),i]}),a&&e.jsx(le,{y:0,stroke:"#767972"}),t.mode==="categorical"?e.jsx(ye,{dataKey:"volume",name:t.title??"Volume",radius:[3,3,0,0],children:t.data.map((n,i)=>e.jsx(De,{fill:a?(n.volume??0)>=0?Y.green:Y.red:t.color??Qo},i))}):t.series.map(n=>e.jsx(ye,{dataKey:n.key,name:n.label,fill:n.color,radius:[2,2,0,0]},n.key))]})})]})}function Jr(t=r=>`${r.toFixed(1)}%`){return function(a){const{x:s,y:n,width:i,height:l,value:d}=a;if(d==null||d==="")return null;const c=Number(d);if(Number.isNaN(c))return null;const u=Number(s)+Number(i)/2,x=Number(n)+Number(l)/2+4;return e.jsx("text",{x:u,y:x,textAnchor:"middle",fontSize:9,fontWeight:600,fill:"#fbfaf7",transform:`rotate(-90 ${u} ${x})`,children:t(c)})}}const ei=[{value:"line",label:"Line"},{value:"area",label:"Area"},{value:"candle",label:"Candlestick"}],ti=[{value:"1y",label:"1Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"}];function be(t){const r=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${r}-${a}-${s}`}function ka(t,r){const a=r?new Date(`${r}T00:00:00`):new Date,s=be(a);switch(t){case"1d":return{start:s,end:s};case"this-week":{const n=new Date(a);return n.setDate(a.getDate()-(a.getDay()+6)%7),{start:be(n),end:s}}case"last-week":{const n=new Date(a);n.setDate(a.getDate()-(a.getDay()+6)%7);const i=new Date(n);i.setDate(n.getDate()-7);const l=new Date(n);return l.setDate(n.getDate()-1),{start:be(i),end:be(l)}}case"this-month":return{start:be(new Date(a.getFullYear(),a.getMonth(),1)),end:s};case"last-month":{const n=new Date(a.getFullYear(),a.getMonth(),0),i=new Date(n.getFullYear(),n.getMonth(),1);return{start:be(i),end:be(n)}}case"ytd":return{start:be(new Date(a.getFullYear(),0,1)),end:s};case"1m":{const n=new Date(a);return n.setMonth(a.getMonth()-1),{start:be(n),end:s}}case"3m":{const n=new Date(a);return n.setMonth(a.getMonth()-3),{start:be(n),end:s}}case"6m":{const n=new Date(a);return n.setMonth(a.getMonth()-6),{start:be(n),end:s}}case"1y":{const n=new Date(a);return n.setFullYear(a.getFullYear()-1),{start:be(n),end:s}}default:return{start:be(new Date(a.getFullYear(),a.getMonth(),1)),end:s}}}const ri=[{key:"1d",label:"Today"},{key:"this-week",label:"This week"},{key:"last-week",label:"Last week"},{key:"this-month",label:"This month"},{key:"last-month",label:"Last month"},{key:"ytd",label:"YTD"},{key:"1m",label:"1M"},{key:"3m",label:"3M"},{key:"6m",label:"6M"},{key:"1y",label:"1Y"}],Sa="1d",kt={padding:"6px 12px",borderRadius:6,border:"1px solid #c9c5bb",fontSize:14,color:"#111722",background:"#fbfaf7"},Rr=[{symbol:"XLE",label:"Energy"},{symbol:"XLP",label:"Consumer Staples"},{symbol:"XLV",label:"Health Care"},{symbol:"XLC",label:"Communication Services"},{symbol:"XLK",label:"Information Technology"},{symbol:"XLF",label:"Financials"},{symbol:"XLI",label:"Industrials"},{symbol:"XLU",label:"Utilities"},{symbol:"XLB",label:"Materials"},{symbol:"XLRE",label:"Real Estate"},{symbol:"XLY",label:"Consumer Discretionary"}],mn=10,gn=6,ai=13,ni=gn+mn+12;function si(t){if(t==null||Number.isNaN(t))return"#ece8df";const r=Math.max(-1,Math.min(1,t));if(r>=0){const l=r,d=Math.round(255+-218*l),c=Math.round(255+-156*l),u=Math.round(255+-20*l);return`rgb(${d},${c},${u})`}const a=-r,s=Math.round(255+-70*a),n=Math.round(255+-227*a),i=Math.round(255+-227*a);return`rgb(${s},${n},${i})`}function oi({pinned:t}){const r=dr(),[a,s]=o.useState("bar"),[n,i]=o.useState(!1),l=o.useRef(null),d=o.useRef(null),[c,u]=o.useState(""),[x,p]=o.use
5State(""),[h,f]=o.useState(Sa),[g,m]=o.useState([]),[y,b]=o.useState(null),[S,k]=o.useState(!0),[v,w]=o.useState(!0),[j,R]=o.useState(""),[N,D]=o.useState(null),[M,$]=o.useState("XLK"),[T,A]=o.useState(""),[B,_]=o.useState("line"),[E,V]=o.useState("3y"),[W,K]=o.useState(null),[re,se]=o.useState(!1),[Fe,he]=o.useState(()=>new Set(["sma50","sma200"])),qe=o.useCallback(z=>{he(I=>{const ee=new Set(I);return ee.has(z)?ee.delete(z):ee.add(z),ee})},[]),Le=o.useMemo(()=>Vn.filter(z=>Fe.has(z.key)).map(z=>z.key),[Fe]),[Ae,nt]=o.useState(null),[Xe,O]=o.useState(!1),F=o.useCallback(async(z,I)=>{if(!(!z||!I)){k(!0);try{const oe=await(await fetch(`/api/markets/daily?chart=sector-performance&start=${z}&end=${I}`)).json();if(oe.ok){m(oe.data),b(oe.meta?.benchmark?.pct_change??null),w(oe.meta?.dataAvailable??!0),R(oe.meta?.dataStartDate??""),oe.meta?.availableRange&&D(oe.meta.availableRange);const xe=String(oe.meta?.start??"").slice(0,10),ke=String(oe.meta?.end??"").slice(0,10);xe&&u(xe),ke&&p(ke)}}catch(ee){console.error("SectorPerformance fetch error:",ee)}finally{k(!1)}}},[]),P=o.useCallback(async()=>{se(!0);try{const z=T?`&compare=${T}`:"",ee=await(await fetch(`/api/markets/daily?chart=stock-candles&symbol=${M}&interval=${E}${z}`)).json();if(ee.ok){const oe=(ee.data?.rows??[]).map(ue=>({time:Date.parse(ue.date),open:ue.open,high:ue.high,low:ue.low,close:ue.close,volume:ue.volume})),xe=ee.data?.compare,ke=xe?{label:xe.symbol,data:(xe.rows??[]).map(ue=>({time:Date.parse(ue.date),close:ue.close})),color:"#6366f1"}:null;K({rows:oe,compare:ke,visibleFrom:ee.meta?.visibleFrom?Date.parse(ee.meta.visibleFrom):void 0})}}catch(z){console.error("StockCandles fetch error:",z)}finally{se(!1)}},[M,T,E]),G=o.useCallback(async()=>{O(!0);try{const I=await(await fetch("/api/markets/daily?chart=sector-correlations")).json();I.ok&&nt(I.data??null)}catch(z){console.error("SectorCorrelations fetch error:",z)}finally{O(!1)}},[]);o.useEffect(()=>{if(g.length)return;const z=t?{start:t.date,end:t.date}:ka(Sa,be(new Date));u(z.start),p(z.end),F(z.start,z.end)},[F]),o.useEffect(()=>{a==="sma"&&P()},[a,P]),o.useEffect(()=>{a==="corr"&&Ae===null&&!Xe&&G()},[a,Ae,Xe,G]);const H=o.useCallback(z=>{const I=ka(z,be(new Date));u(I.start),p(I.end),f(z),F(I.start,I.end)},[F]),me=o.useCallback(z=>{const I=z.target.value;u(I),f(null),I&&x&&F(I,x)},[x,F]),Ge=o.useCallback(z=>{const I=z.target.value;p(I),f(null),c&&I&&F(c,I)},[c,F]),Ee=o.useMemo(()=>g.length?g.map(z=>({name:z.symbol,label:z.label,axisLabel:`${z.symbol} - ${z.label}`,value:Number(Number(z.pct_change).toFixed(2)),volumeChange:z.volume_change_pct==null?null:Number(z.volume_change_pct)})):[],[g]),Dn=o.useCallback(z=>{const{x:I,y:ee,width:oe,height:xe,value:ke}=z;if(ke==null||ke==="")return null;const ue=Number(ke);if(Number.isNaN(ue))return null;const Pt=Number(I),st=Number(ee),Fn=Number(oe),mr=Number(xe),Tn=Pt+Fn/2,gr=ue>=0,ea=Math.min(st,st+mr),ta=Math.max(st,st+mr);let yr=gr?ea-gn:ta+ai;const Wn=gr?ta:ea,ra=ue!==0?Math.abs(mr)/Math.abs(ue):null,aa=11;if(gr&&y!=null&&ra!=null){const na=Wn-y*ra;Math.abs(yr-na)<aa&&(yr=na-aa)}return e.jsx("text",{x:Tn,y:yr,textAnchor:"middle",fontSize:mn,fontWeight:500,fill:"#6d716e",children:`${ue.toFixed(1)}%`})},[y]),_n=[{value:"bar",label:"Sector Performance"},{value:"sma",label:"Price & Indicators"},{value:"corr",label:"Correlations"}],pr={padding:"4px 8px",borderRadius:6,border:"1px solid #c9c5bb",fontSize:12,color:"#6d716e",background:"transparent"},fr=()=>e.jsxs("div",{style:{marginBottom:16,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("select",{value:a,onChange:z=>s(z.target.value),style:{...kt,fontWeight:600,cursor:"pointer"},children:_n.map(z=>e.jsx("option",{value:z.value,children:z.label},z.value))}),a==="bar"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date","aria-label":"From date",value:c,onChange:me,min:N?.min?.slice(0,10),max:x||N?.max?.slice(0,10),style:pr}),e.jsx("span",{style:{color:"#767972",fontSize:12},children:"â"}),e.jsx("input",{type:"date","aria-label":"To date",value:x,onChange:Ge,min:c||N?.min?.slice(0,10),max:N?.max?.slice(0,10),style:pr}),e.jsxs("select",{"aria-label":"Quick range",value:h??"",onChange:z=>{z.target.value&&H(z.target.value)},style:{...pr,cursor:"pointer"},children:[h===null&&e.jsx("option",{value:"",children:"Custom"}),ri.map(z=>e.jsx("option",{value:z.key,children:z.label},z.key))]}),S&&e.jsx("span",{style:{fontSize:12,color:"#767972"},children:"Loadingâ¦"}),e.jsxs("button",{type:"button",role:"switch","aria-checked":n,"aria-label":"Toggle volume",onClick:()=>i(z=>!z),className:`inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs font-medium transition-colors ${n?"border-transparent bg-gray-800 text-white":"border-gray-200 bg-transparent text-gray-500 hover:bg-gray-50"}
5`,children:[e.jsx("span",{"aria-hidden":!0,className:"text-[13px] leading-none tracking-tighter",children:"âââ"}),"Volume"]}),e.jsx(la,{targetRef:l,filename:"sector-performance",className:"ml-auto"})]})]});if(a==="corr"){const z=Ae?.symbols??Rr.map(ee=>ee.symbol),I=Ae?.matrix;return e.jsxs("div",{style:{width:"100%"},children:[fr(),e.jsxs("div",{style:{marginBottom:12,fontSize:13,color:"#6d716e"},children:["Pearson correlation of ",e.jsx("strong",{children:"daily returns"})," over the last 5 years across the 11 US sector ETFs."]}),Xe&&!Ae?e.jsx("div",{className:"markets-skeleton",style:{height:420}}):I?e.jsxs("div",{style:{overflowX:"auto"},children:[e.jsxs("table",{style:{borderCollapse:"separate",borderSpacing:2,fontSize:12},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{padding:4}}),z.map(ee=>e.jsx("th",{style:{padding:"4px 6px",color:"#28313f",fontWeight:600},children:ee},ee))]})}),e.jsx("tbody",{children:z.map(ee=>e.jsxs("tr",{children:[e.jsxs("th",{style:{textAlign:"right",padding:"4px 8px",color:"#28313f",fontWeight:600,whiteSpace:"nowrap"},children:[ee,e.jsx("span",{style:{color:"#767972",fontWeight:400,marginLeft:6},children:Ae?.labels?.[ee]})]}),z.map(oe=>{const xe=I[ee]?.[oe],ke=ee===oe,ue=ke?"#c9c5bb":si(xe),Pt=xe==null?"â":xe.toFixed(2),st=!ke&&xe!=null&&Math.abs(xe)>.55?"#fbfaf7":"#111722";return e.jsx("td",{title:`${ee} vs ${oe}: ${Pt}`,style:{width:52,height:32,textAlign:"center",background:ue,color:st,borderRadius:4,fontVariantNumeric:"tabular-nums"},children:Pt},oe)})]},ee))})]}),e.jsxs("div",{style:{marginTop:12,display:"flex",alignItems:"center",gap:12,fontSize:12,color:"#6d716e"},children:[e.jsx("span",{children:"â1.0"}),e.jsx("div",{style:{width:220,height:10,borderRadius:5,background:"linear-gradient(to right, rgb(185,28,28), #fbfaf7, rgb(37,99,235))",border:"1px solid #c9c5bb"}}),e.jsx("span",{children:"+1.0"})]})]}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No correlation data available."})]})}if(a==="sma"){const z=!!W&&W.rows.length>0;return e.jsxs("div",{style:{width:"100%"},children:[fr(),e.jsxs("div",{style:{marginBottom:12,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("select",{"aria-label":"Symbol",value:M,onChange:I=>$(I.target.value),style:{...kt,fontWeight:600,minWidth:220},children:Rr.map(I=>e.jsxs("option",{value:I.symbol,children:[I.symbol," · ",I.label]},I.symbol))}),e.jsxs("select",{"aria-label":"Compare with",value:T,onChange:I=>A(I.target.value),style:{...kt},children:[e.jsx("option",{value:"",children:"Compareâ¦"}),["SPY","QQQ","DIA","IWM"].map(I=>e.jsxs("option",{value:I,disabled:I===M,children:["vs ",I]},I)),Rr.filter(I=>I.symbol!==M).map(I=>e.jsxs("option",{value:I.symbol,children:["vs ",I.symbol]},I.symbol))]}),e.jsx("select",{"aria-label":"Chart type",value:B,onChange:I=>_(I.target.value),style:{...kt},children:ei.map(I=>e.jsx("option",{value:I.value,children:I.label},I.value))}),e.jsx("select",{"aria-label":"Interval",value:E,onChange:I=>V(I.target.value),style:{...kt},children:ti.map(I=>e.jsx("option",{value:I.value,children:I.label},I.value))}),e.jsx(Kn,{value:Fe,onToggle:qe}),re&&e.jsx("span",{style:{fontSize:12,color:"#767972"},children:"Loadingâ¦"}),e.jsx(la,{targetRef:d,filename:`${M}-chart`,className:"ml-auto"})]}),re&&!W?e.jsx("div",{className:"markets-skeleton",style:{height:380}}):z?e.jsxs("div",{ref:d,className:"w-full min-w-0",children:[e.jsx(Un,{data:W.rows,chartType:B,indicators:Le,compare:W.compare,visibleFrom:W.visibleFrom,height:420,symbolLabel:M,formatValue:I=>`$${Number(I).toFixed(I>=100?0:2)}`}),e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"#6d716e"},children:["Split/dividend-adjusted prices. Indicators use ~1yr of warm-up history so long averages (SMA 200) are correct from the first bar",W.compare?`; ${W.compare.label} plotted on the right axis`:"","."]})]}):e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:["No history available for ",M,"."]})]})}return e.jsxs("div",{style:{width:"100%"},children:[fr(),!S&&!v?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#767972",border:"1px dashed #c9c5bb",borderRadius:8},children:[e.jsx("p",{style:{fontSize:15,marginBottom:8},children:"Not enough data available for this time range."}),e.jsxs("p",{style:{fontSize:13},children:["Data collection started ",j||"Feb 10, 2026","."]})]}):S&&!g.length?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]}):Ee.length>0?e.jsxs("div",{className:"markets-appendix-chart",ref:l,style:{height:"auto"},children:[e.jsx(q,{width:"100%",height:440,children:e.jsxs(Ce,{data:Ee,margin:{top:ni,right:12,left:8,bottom:8},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"axisLabel",tick:{fontSize:10,fill:"#28313f"}
5,tickLine:!1,axisLine:{stroke:"rgba(0,0,0,0.08)"},angle:-45,textAnchor:"end",height:150,interval:0}),e.jsx(X,{tick:{fontSize:11,fill:"#6d716e"},tickLine:!1,axisLine:!1,width:64,label:{value:"% Change",angle:-90,position:"insideLeft",offset:-2,style:{fontSize:11,fill:"#767972",textAnchor:"middle"}}}),e.jsx(Z,{contentStyle:{background:"#fbfaf7",border:"1px solid #c9c5bb",borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},formatter:z=>[`${z.toFixed(2)}%`,"% Change"],labelFormatter:z=>z}),e.jsxs(ye,{dataKey:"value",radius:[4,4,0,0],children:[e.jsx(Hr,{dataKey:"value",content:r?Jr():Dn}),Ee.map((z,I)=>e.jsx(De,{fill:z.value>=0?"#1a8b66":"#a33a3a"},I))]}),y!=null&&e.jsx(le,{y,stroke:"#fbfaf7",strokeWidth:6,ifOverflow:"extendDomain"}),y!=null&&e.jsx(le,{y,stroke:"#2f63d6",strokeWidth:2.5,strokeDasharray:"7 4",ifOverflow:"extendDomain",label:z=>{const I=z.viewBox??{},ee=`SPY ${y>=0?"+":""}${y.toFixed(2)}%`,oe=ee.length*6.6+12,xe=(I.x??0)+(I.width??0)-oe-4,ke=(I.y??0)-9;return e.jsxs("g",{children:[e.jsx("rect",{x:xe,y:ke,width:oe,height:18,rx:4,fill:"#fbfaf7",stroke:"#2f63d6",strokeWidth:1}),e.jsx("text",{x:xe+oe/2,y:ke+13,textAnchor:"middle",fill:"#2f63d6",fontSize:11,fontWeight:700,children:ee})]})}})]})}),n&&e.jsx(Zo,{mode:"categorical",title:"Volume change vs. prior period",signed:!0,format:z=>`${z>=0?"+":""}${z.toFixed(0)}%`,data:Ee.map(z=>({name:z.name,label:z.label,volume:z.volumeChange??0}))})]}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No sector data available."})]})}function Pe({loading:t,hasData:r,height:a=300,children:s}){return t&&!r?e.jsx("div",{className:"markets-skeleton",style:{height:a}}):e.jsxs("div",{className:"markets-chart-loading-wrap","aria-busy":t||void 0,children:[s,t&&e.jsxs("div",{className:"markets-chart-loading-overlay",role:"status",children:[e.jsx("span",{className:"markets-chart-spinner","aria-hidden":!0}),"Loadingâ¦"]})]})}function ii({tickers:t,onChange:r,max:a=12,minKeep:s=1}){const n=o.useId(),[i,l]=o.useState([]),[d,c]=o.useState(""),u=o.useRef(!1);o.useEffect(()=>{if(u.current)return;u.current=!0;let h=!1;return fetch("/api/markets/symbols").then(f=>f.json()).then(f=>{!h&&f?.ok&&Array.isArray(f.symbols)&&l(f.symbols)}).catch(()=>{}),()=>{h=!0}},[]);const x=h=>{const f=h.toUpperCase().trim();if(/^[A-Z][A-Z0-9.\-]{0,9}$/.test(f)){if(t.includes(f)||t.length>=a){c("");return}r([...t,f]),c("")}},p=h=>{t.length<=s||r(t.filter(f=>f!==h))};return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("input",{list:n,value:d,placeholder:"Add tickerâ¦","aria-label":"Add ticker",onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),x(d))},style:{padding:"4px 8px",borderRadius:6,border:"1px solid #c9c5bb",fontSize:12,color:"#28313f",width:130}}),e.jsx("datalist",{id:n,children:i.slice(0,4e3).map(h=>e.jsx("option",{value:h},h))}),e.jsx("button",{type:"button",onClick:()=>x(d),disabled:!d.trim()||t.length>=a,style:{padding:"4px 10px",borderRadius:6,border:"1px solid #c9c5bb",background:"#fbfaf7",fontSize:12,fontWeight:600,color:"#28313f",cursor:d.trim()&&t.length<a?"pointer":"not-allowed",opacity:d.trim()&&t.length<a?1:.5},children:"Add"}),e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:t.map(h=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px 2px 8px",borderRadius:12,background:"#ece8df",fontSize:11.5,fontWeight:600,color:"#28313f"},children:[h,t.length>s&&e.jsx("button",{type:"button","aria-label":`Remove ${h}`,onClick:()=>p(h),style:{border:"none",background:"none",cursor:"pointer",color:"#a7a49c",fontSize:13,lineHeight:1,padding:0},children:"Ã"})]},h))})]})}function tt(){const[t,r]=o.useState([]),[a,s]=o.useState(null),[n,i]=o.useState(!0),l=o.useRef(new Map),d=o.useRef(null),c=o.useCallback(x=>{const p=l.current.get(x);if(p){r(p.data),s(p.meta),i(!1);return}d.current?.abort();const h=new AbortController;d.current=h,i(!0),fetch(x,{signal:h.signal}).then(f=>f.json()).then(f=>{if(f.ok){const g={data:f.data,meta:f.meta??null};l.current.set(x,g),r(g.data),s(g.meta)}}).catch(f=>{f instanceof DOMException&&f.name==="AbortError"||console.error("Chart fetch error:",f)}).finally(()=>i(!1))},[]),u=o.useCallback((x,p,h)=>{l.current.set(x,{data:p,meta:h}),r(p),s(h),i(!1)},[]);return{data:t,meta:a,loading:n,fetchChart:c,seedCache:u}}function Se(t){const r=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${r}-${a}-${s}`}function li(t,r){const a=r?new Date(`${r}T00:00:00`):new Date,s=Se(a);switch(t){case"1d":return{start:s,end:s};case"this-week":{const n=new Date(a);return n.setDate(a.getDate()-(a.getDay()+6)%7),{start:Se(n),end:s}}case"last-week":{const n=new Date(a);n.setDate(a.getDate()-(a.getDay()+6)%7);const i=new Date(n);i.setDate(n.getDate()-7);const l=new Date(n);return l.setDate(n.getDate()-1),{start:Se(i),end:Se(l)}}case"this-month":return{start:Se(new Date(a.getFullYear(),a.getMonth(),1)),end:s};case"last-month":{const n=new Date(a.getFullYear(),a.getMonth(),0),i=new Date(n.getFullYear(),n.getMonth(),1);return{start:Se(i),end:Se(n)}}case"ytd":return{start:Se(new Date(a.getFullYear(),0,1)),end:s};case"1m":{const n=new Date(a);return n.setMonth(a.getMonth()-1),{start:Se(n),end:s}}case"3m":{const n=new Date(a);return n.setMonth(a.getMonth()-3),{start:Se(n),end:s}}case"6m":{const n=new Date(a);return n.setMonth(a.getMonth()-6),{start:Se(n),end:s}}case"1y":{const n=new Date(a);return n.setFullYear(a.getFullYear()-1),{start:Se(n),end:s}}default:return{start:Se(new Date(a.getFullYear(),a.getMonth(),1)),end:s}}}const ci=[{key:"1d",label:"1D"},{key:"this-week",label:"This week"},{key:"last-week",label:"Last week"},{key:"this-month",label:"This month"},{key:"last-month",label:"Last month"},{key:"ytd",label:"YTD"},{key:"1m",label:"1M"},{key:"3m",label:"3M"},{key:"6m",label:"6M"},{key:"1y",label:"1Y"}],di=ci.map(t=>({value:t.key,label:t.label}));function Ke(t,r,a){if(t==null||Number.isNaN(t))return"â";const s=a&&t>=0?"+":"";return r==="bps"?`${s}${Math.round(t)}
5 bps`:r==="pts"?`${s}${t.toFixed(1)}`:r==="volume"?fn(t):`${s}${t.toFixed(2)}%`}function Ar(t,r){for(const a of[" - "," · "])if(r.startsWith(t+a))return r.slice(t.length+a.length);return r===t?"":r}function hi(t,r,a=3){if(!t)return[];const s=[];let n="";for(const i of t.split(/\s+/))n?(n+" "+i).length<=r?n+=" "+i:(s.push(n),n=i):n=i;if(n&&s.push(n),s.length>a){const i=s.slice(0,a-1),l=s.slice(a-1).join(" ");return i.push(l.length>r?l.slice(0,r-1)+"â¦":l),i}return s}function xi(t,r,a=6){const n=(r-t||1)/Math.max(1,a-1),i=Math.pow(10,Math.floor(Math.log10(n))),l=n/i,d=(l<=1?1:l<=2?2:l<=5?5:10)*i,c=Math.floor(t/d)*d,u=Math.ceil(r/d)*d,x=[];for(let p=c;p<=u+d*1e-6;p+=d)x.push(Math.round(p*1e6)/1e6);return{domain:[c,u],ticks:x}}function Zr({chart:t,exportFilename:r,yLabel:a,defaultShortcut:s="ytd",searchable:n=!1,defaultTickers:i=[],axisLabel:l=!1,stackedLabels:d=!1,pinned:c}){const u=dr(),x=o.useRef(null),[p]=o.useState(()=>Se(new Date)),[h,f]=o.useState(s),[g,m]=o.useState(c??null),[y,b]=o.useState(i),{data:S,meta:k,loading:v,fetchChart:w}=tt(),j=o.useMemo(()=>g??li(h??s,p),[g,h,s,p]);o.useEffect(()=>{if(!j.start||!j.end)return;const F=n&&y.length?`&symbols=${y.join(",")}`:"";w(`/api/markets/daily?chart=${t}&start=${j.start}&end=${j.end}${F}`)},[t,j.start,j.end,n,y,w]);const R=k?.start??j.start,N=k?.end??j.end,D=k?.unit??"pct",M=k?.absUnit??"pct",$=o.useMemo(()=>S.map(F=>({name:F.key,label:F.label,value:F.value==null?null:Number(F.value),abs:F.abs??null})),[S]),T=o.useMemo(()=>{const F={};for(const P of S)F[P.key]=P.abs??null;return F},[S]),A=S.some(F=>F.abs!=null),B=-50,_=24,E=(F,P)=>F.length>P?F.slice(0,P-1)+"â¦":F,V=F=>{if(l)return E(Ar(F,S.find(G=>G.key===F)?.label??F),_);const P=T[F];return P!=null?Ke(P,M,!1):""},W=o.useMemo(()=>{let F=0;for(const P of S){const G=l?E(Ar(P.key,P.label??P.key),_):P.abs!=null?Ke(P.abs,M,!1):"";F=Math.max(F,P.key.length+(G?G.length+3:0))}return Math.min(150,16+Math.round(F*5.5*.77))},[S,l,M]),K=F=>{const P=Number(F.x??0),G=Number(F.y??0),H=F.payload?.value??"",me=V(H);return e.jsx("g",{transform:`translate(${P},${G}) rotate(${B})`,children:e.jsxs("text",{x:-6,y:6,textAnchor:"end",fontSize:10.5,fill:"#28313f",children:[e.jsx("tspan",{fontWeight:700,children:H}),me&&e.jsxs("tspan",{fill:"#767972",children:[" · ",me]})]})})},re=S.length<=5?18:S.length<=7?14:11,se=o.useMemo(()=>{const F={};for(const P of S)F[P.key]=hi(Ar(P.key,P.label??P.key),re,3);return F},[S,re]),he=18+o.useMemo(()=>Object.values(se).reduce((F,P)=>Math.max(F,P.length),0),[se])*13,qe=F=>{const P=Number(F.x??0),G=Number(F.y??0),H=F.payload?.value??"",me=se[H]??[];return e.jsxs("g",{transform:`translate(${P},${G})`,children:[e.jsx("text",{x:0,y:0,dy:13,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"#28313f",children:H}),me.map((Ge,Ee)=>e.jsx("text",{x:0,y:0,dy:27+Ee*13,textAnchor:"middle",fontSize:10.5,fill:"#767972",children:Ge},Ee))]})},Le=l&&d&&!u,Ae=!Le&&(u||l),nt=o.useMemo(()=>{const F=$.map(Ee=>Number(Ee.value??0)),P=Math.max(0,...F),G=Math.min(0,...F),H=Math.max(1,P-G)*.12,me=G<0?G-H:0,Ge=P>0?P+H:1;return xi(me,Ge,7)},[$]),Xe=F=>{if(F.value==null||F.value==="")return null;const P=Number(F.value);if(Number.isNaN(P))return null;const G=Number(F.y),H=G+Number(F.height),me=Number(F.x)+Number(F.width)/2,Ge=P>=0?Math.min(G,H)-6:Math.max(G,H)+15;return e.jsx("text",{x:me,y:Ge,textAnchor:"middle",fontSize:11,fontWeight:600,fill:"#28313f",children:Ke(P,D,!0)})},O=F=>{const P=Number(F.x??0),G=Number(F.y??0),H=F.payload?.value??"",me=T[H];return e.jsxs("g",{transform:`translate(${P},${G})`,children:[e.jsx("text",{x:0,y:0,dy:13,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"#28313f",children:H}),me!=null&&e.jsx("text",{x:0,y:0,dy:28,textAnchor:"middle",fontSize:10.5,fill:"#767972",children:Ke(me,M,!1)})]})};return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{shortcut:g?null:h,shortcutOptions:di,onShortcut:F=>{m(null),f(F)},startDate:R,endDate:N,onStartDate:F=>F&&m({start:F,end:N}),onEndDate:F=>F&&m({start:R,end:F}),rangeLabel:Ja(k),loading:v,exportRef:x,exportFilename:r}),n&&e.jsx("div",{style:{marginBottom:12},children:e.jsx(ii,{tickers:y,onChange:b,max:12,minKeep:1})}),e.jsx(Pe,{loading:v,hasData:S.length>0,height:340,children:S.length>0?e.jsx("div",{className:"markets-appendix-chart",ref:x,children:e.jsx(q,{width:"100%",height:je,children:e.jsxs(Ce,{data:$,margin:{...we,bottom:l?8:A?20:8},children:[e.jsx(J,{...ce}
5),e.jsx(Q,{dataKey:"name",interval:0,tickLine:!1,axisLine:{stroke:"rgba(0,0,0,0.08)"},height:Le?he:Ae?W:A?44:28,tick:Le?qe:Ae?K:O}),e.jsx(X,{...de,domain:nt.domain,ticks:nt.ticks,label:Me(a),tickFormatter:F=>Ke(F,D,!0)}),e.jsx(Z,{contentStyle:pe,cursor:{fill:"rgba(0,0,0,0.03)"},formatter:(F,P,G)=>{const H=G?.payload,me=[Ke(Number(F),D,!0)];return H?.abs!=null&&me.push(`(${Ke(H.abs,M,!1)})`),[me.join(" "),H?.label??P]},labelFormatter:()=>""}),e.jsx(le,{y:0,stroke:"#767972"}),e.jsxs(ye,{dataKey:"value",radius:[4,4,0,0],children:[e.jsx(Hr,{dataKey:"value",content:u?Jr(F=>Ke(F,D,!0)):Xe}),$.map((F,P)=>e.jsx(De,{fill:(F.value??0)>=0?Y.green:Y.red},P))]})]})})}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available for this window."})})]})}function ui({pinned:t}){return e.jsx(Zr,{chart:"index-comparison",exportFilename:"index-comparison",yLabel:"Return (%)",defaultShortcut:"1d",axisLabel:!0,stackedLabels:!0,pinned:t&&{start:t.date,end:t.date}})}const pi=[{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"},{value:"10y",label:"10Y"}];function fi(t,r){return t==null||Number.isNaN(t)?"â":r==="bps"?`${Math.round(t)} bps`:r==="ratio"?t.toFixed(2):`${t.toFixed(2)}%`}function mi(t,r){return r==="bps"?String(Math.round(t)):r==="ratio"?t.toFixed(2):`${t.toFixed(1)}%`}function gt({chart:t,series:r,yLabel:a,exportFilename:s,unit:n="%",defaultInterval:i="3m",zeroLine:l=!1,refLine:d,refLabel:c}){const[u,x]=o.useState(i),[p,h]=o.useState([]),[f,g]=o.useState(!0),[m,y]=o.useState(!0),[b,S]=o.useState({}),k=o.useRef(null),v=o.useCallback(N=>{S(D=>({...D,[N]:!D[N]}))},[]),w=o.useCallback(async N=>{g(!0);try{const M=await(await fetch(`/api/markets/daily?chart=${t}&interval=${N}`)).json();M.ok&&(h(M.data??[]),y(M.meta?.dataAvailable??!0))}catch(D){console.error(`${t} fetch error:`,D)}finally{g(!1)}},[t]);o.useEffect(()=>{w(u)},[u,w]);const j=o.useMemo(()=>p.length?p.map(N=>{const D={date:String(N.date).slice(0,10)};for(const M of r){const $=N[M.key];D[M.key]=$==null?null:Number($)}return D}):[],[p,r]),R=j.length?Ja({start:String(j[0].date),end:String(j[j.length-1].date)}):void 0;return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{interval:u,intervalOptions:pi,onInterval:x,rangeLabel:R,loading:f,exportRef:k,exportFilename:s}),!f&&!m?e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",border:"1px dashed #c9c5bb",borderRadius:8},children:e.jsx("p",{style:{fontSize:15},children:"Not enough data available for this time range."})}):f&&!p.length?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]}):j.length>0?e.jsx("div",{className:"markets-appendix-chart",ref:k,children:e.jsx(q,{width:"100%",height:je,children:e.jsxs(_e,{data:j,margin:we,children:[e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"date",...ne}),e.jsx(X,{...de,domain:["auto","auto"],tickFormatter:N=>mi(Number(N),n),label:Me(a)}),e.jsx(Z,{contentStyle:pe,formatter:(N,D)=>[fi(Number(N),n),D],labelFormatter:N=>String(N)}),r.length>1&&e.jsx(ve,{...Ur,onClick:N=>{N?.dataKey!=null&&v(String(N.dataKey))},formatter:(N,D)=>{const M=D?.dataKey!=null&&b[String(D.dataKey)];return e.jsx("span",{style:{cursor:"pointer",opacity:M?.4:1,textDecoration:M?"line-through":"none"},children:N})}}),l&&e.jsx(le,{y:0,stroke:"#767972",strokeDasharray:"4 4"}),d!=null&&e.jsx(le,{y:d,stroke:"#767972",strokeDasharray:"4 4",label:c?{value:c,position:"insideTopRight",fill:"#767972",fontSize:11}:void 0}),r.map(N=>e.jsx(ie,{type:"monotone",dataKey:N.key,name:N.label,stroke:N.color,strokeWidth:2,strokeDasharray:N.dashed?"5 4":void 0,dot:!1,connectNulls:!0,hide:!!b[N.key],isAnimationActive:!1},N.key))]})})}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."})]})}const Mr={DGS3MO:{label:"3M",order:0},DGS2:{label:"2Y",order:1},DGS5:{label:"5Y",order:2},DGS10:{label:"10Y",order:3},DGS30:{label:"30Y",order:4}};function gi(){const[t,r]=o.useState([]),[a,s]=o.useState(!0),n=o.useRef(null);o.useEffect(()=>{let l=!1;return(async()=>{s(!0);try{const c=await(await fetch("/api/markets/daily?chart=rates-yield-curve")).json();!l&&c.ok&&r(c.data??[])}catch(d){console.error("rates-yield-curve fetch error:",d)}finally{l||s(!1)}})(),()=>{l=!0}},[]);const i=o.useMemo(()=>t.filter(l=>Mr[l.series_id]).map(l=>
5({tenor:Mr[l.series_id].label,order:Mr[l.series_id].order,current:l.current==null?null:Number(l.current),monthAgo:l.month_ago==null?null:Number(l.month_ago),yearAgo:l.year_ago==null?null:Number(l.year_ago)})).sort((l,d)=>l.order-d.order),[t]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:n,exportFilename:"treasury-yield-curve",loading:a}),a&&!t.length?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]}):i.length>0?e.jsx("div",{className:"markets-appendix-chart",ref:n,children:e.jsx(q,{width:"100%",height:je,children:e.jsxs(_e,{data:i,margin:we,children:[e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"tenor",...ne,angle:0,height:30}),e.jsx(X,{...de,domain:["auto","auto"],tickFormatter:l=>`${Number(l).toFixed(1)}%`,label:Me("Yield (%)")}),e.jsx(Z,{contentStyle:pe,formatter:(l,d)=>[l==null?"â":`${Number(l).toFixed(2)}%`,d],labelFormatter:l=>`${l} Treasury`}),e.jsx(ve,{...Ur}),e.jsx(ie,{type:"monotone",dataKey:"current",name:"Today",stroke:"#2f63d6",strokeWidth:2.5,dot:{r:3},connectNulls:!0,isAnimationActive:!1}),e.jsx(ie,{type:"monotone",dataKey:"monthAgo",name:"1 Month Ago",stroke:"#d97706",strokeWidth:2,strokeDasharray:"5 4",dot:{r:2},connectNulls:!0,isAnimationActive:!1}),e.jsx(ie,{type:"monotone",dataKey:"yearAgo",name:"1 Year Ago",stroke:"#a7a49c",strokeWidth:2,strokeDasharray:"5 4",dot:{r:2},connectNulls:!0,isAnimationActive:!1})]})})}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."})]})}function yi(){const[t,r]=o.useState([]),[a,s]=o.useState(!0),n=o.useRef(null);o.useEffect(()=>{let d=!1;return(async()=>{s(!0);try{const u=await(await fetch("/api/markets/daily?chart=treasury-curve-yoy")).json();!d&&u.ok&&r(u.data??[])}catch(c){console.error("treasury-yield-curve fetch error:",c)}finally{d||s(!1)}})(),()=>{d=!0}},[]);const i=t.length?String(t[0].as_of).slice(0,10):"",l=o.useMemo(()=>[...t].sort((d,c)=>d.tenor_months-c.tenor_months).map(d=>({tenor:d.tenor,current:d.current==null?null:Number(d.current),monthAgo:d.month_ago==null?null:Number(d.month_ago),yearAgo:d.year_ago==null?null:Number(d.year_ago)})),[t]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:n,exportFilename:"treasury-yield-curve-yoy",loading:a}),a&&!t.length?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]}):l.length>0?e.jsx("div",{className:"markets-appendix-chart",ref:n,children:e.jsx(q,{width:"100%",height:je,children:e.jsxs(_e,{data:l,margin:we,children:[e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"tenor",...ne,angle:0,height:30}),e.jsx(X,{...de,domain:["auto","auto"],tickFormatter:d=>`${Number(d).toFixed(1)}%`,label:Me("Yield (%)")}),e.jsx(Z,{contentStyle:pe,formatter:(d,c)=>[d==null?"â":`${Number(d).toFixed(2)}%`,c],labelFormatter:d=>`${d} Treasury`}),e.jsx(ve,{...Ur}),e.jsx(ie,{type:"monotone",dataKey:"current",name:`Today${i?` (${i})`:""}`,stroke:"#2f63d6",strokeWidth:2.5,dot:{r:3},connectNulls:!0,isAnimationActive:!1}),e.jsx(ie,{type:"monotone",dataKey:"monthAgo",name:"1 Month Ago",stroke:"#d97706",strokeWidth:2,strokeDasharray:"5 4",dot:{r:2},connectNulls:!0,isAnimationActive:!1}),e.jsx(ie,{type:"monotone",dataKey:"yearAgo",name:"1 Year Ago",stroke:"#a7a49c",strokeWidth:2,strokeDasharray:"5 4",dot:{r:2},connectNulls:!0,isAnimationActive:!1})]})})}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."})]})}function bi(){const[t,r]=o.useState([]),[a,s]=o.useState(!0),n=o.useRef(null);o.useEffect(()=>{let u=!1;return(async()=>{s(!0);try{const p=await(await fetch("/api/markets/daily?chart=treasury-changes")).json();!u&&p.ok&&r(p.data??[])}catch(x){console.error("treasury-changes fetch error:",x)}finally{u||s(!1)}})(),()=>{u=!0}},[]);const i=t.length?String(t[0].as_of).slice(0,10):"",l=o.useMemo(()=>[...t].sort((u,x)=>u.tenor_months-x.tenor_months),[t]),d=u=>{if(u==null||u==="")return e.jsx("span",{style:{color:"#767972"},children:"â"});const x=Number(u),p=x>0?"#a33a3a":x<0?"#1a8b66":"#6d716e",h=x>0?"+":"";return e.jsx("span",{style:{color:p,fontVariantNumeric:"tabular-nums"},children:`${h}${x.toFixed(1)}`})},c=[{key:"chg_1d_bps",label:"vs Yesterday"},{key:"chg_1w_bps",label:"Week"},{key:"chg_1m_bps",label:"Month"},{key:"chg_1y_bps",label:"Year"}];return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:n,exportFilename:"treasury-yield-changes",loading:a}),a&&!t.length?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:220}})]}):l.length>0?e.jsxs("div",{className:"markets-appendix-chart",ref:n,children:[e.jsxs("div",{style:{fontSize:12,color:"#6d716e",marginBottom:8},children:["Change in yield, basis points",i?` · as of ${i}`:""]}),e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:14},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"1px solid #c9c5bb",textAlign:"right",color:"#6d716e",fontSize:12},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 10px"},children:"Tenor"}),e.jsx("th",{style:{padding:"8px 10px"},children:"Yield"}),c.map(u=>e.jsx("th",{style:{padding:"8px 10px"},children:u.label},u.key))]})}),e.jsx("tbody",{children:l.map(u=>e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df",textAlign:"right"},children:[e.jsx("td",{style:{textAlign:"left",padding:"8px 10px",fontWeight:600},children:u.tenor}),e.jsx("td",{style:{padding:"8px 10px",fontVariantNumeric:"tabular-nums"},children:u.current==null?"â":`${Number(u.current).toFixed(3)}%`}),c.map(x=>e.jsx("td",{style:{padding:"8px 10px"},children:d(u[x.key])},x.key))]},u.tenor))})]})]}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."})]})}function ji(){return e.jsx(gt,{chart:"rates-2s10s",exportFilename:"yield-curve-slope",yLabel:"Spread (%)",zeroLine:!0,series:[{key:"t10y2y",label:"10Y â 2Y",color:"#2f63d6"},{key:"t10y3m",label:"10Y â 3M",color:"#d97706"}]})}function vi(){return e.jsx(gt,{chart:"rates-credit-spreads",exportFilename:"credit-spreads",yLabel:"OAS (bps)",unit:"bps",series:[{key:"hy",label:"US High Yield OAS",color:"#a33a3a"},{key:"ig",label:"US Investment Grade OAS",color:"#2f63d6"}]})}function ki(){return e.jsx(gt,{chart:"rates-breakevens",exportFilename:"inflation-breakevens",yLabel:"Breakeven (%)",series:[{key:"be10",label:"10Y Breakeven",color:"#2f63d6"},{key:"be5",label:"5Y Breakeven",color:"#1a8b66"},{key:"fwd5y5y",label:"5y5y Forward",color:"#7c3aed"}]})}function Si(){return e.jsx(gt,{chart:"rates-real-yield",exportFilename:"real-vs-nominal-yield",yLabel:"Yield (%)",series:[{key:"nominal",label:"10Y Nominal",color:"#111722"},{key:"real",label:"10Y Real (TIPS)",color:"#2f63d6"},{key:"breakeven",label:"Implied Breakeven",color:"#1a8b66",dashed:!0}]})}function wi(){return e.jsx(gt,{chart:"rates-policy",exportFilename:"policy-rate",yLabel:"Rate (%)",series:[{key:"target",label:"Fed Funds Target (Upper)",color:"#111722",dashed:!0},{key:"ff",label:"Effective Fed Funds",color:"#2f63d6"},{key:"sofr",label:"SOFR",color:"#d97706"}]})}function Ni({pinned:t}){return e.jsx(Zr,{chart:"rates-snapshot",exportFilename:"rates-snapshot",yLabel:"Change (bps)",defaultShortcut:"1d",pinned:t&&{start:t.date,end:t.date}})}function Ri(){return e.jsx(gt,{chart:"put-call-ratio",series:[{key:"total",label:"Total",color:"#2f63d6"},{key:"equity",label:"Equity",color:"#1a8b66"},{key:"index",label:"Index",color:"#d97706"}],yLabel:"Put/Call Ratio",exportFilename:"cboe-put-call-ratio",unit:"ratio",defaultInterval:"1y",refLine:1,refLabel:"Neutral (1.0)"})}const Ai=[{value:"1d",label:"1D"},{value:"1w",label:"1W"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"},{value:"10y",label:"10Y"}];function Mi(){const[t,r]=o.useState("3m"),a=o.useRef(null),{data:s,meta:n,loading:i,fetchChart:l}=tt(),d=n?.dataAvailable??!0,c=n?.dataStartDate??"";o.useEffect(()=>{l(`/api/markets/daily?chart=rsp-spy-ratio&interval=${t}`)},[t,l]);const u=o.useMemo(()=>s.length?s.map(x=>({date:String(x.trade_date).slice(0,10),ratio:Number(Number(x.ratio).toFixed(4))})):[],[s]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{interval:t,intervalOptions:Ai,onInterval:r,loading:i,exportRef:a,exportFilename:"equal-vs-cap-weight"}),!i&&!d?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#767972",border:"1px dashed #c9c5bb",borderRadius:8},children:[e.jsx("p",{style:{fontSize:15,marginBottom:8},children:"Not enough data available for this time range."}),e.jsxs("p",{style:{fontSize:13},children:["Data collection started ",c||"Feb 10, 2026","."]})]}):e.jsx(Pe,{loading:i,hasData:u.length>0,height:je,children:u.length>0?e.jsx("div",{className:"markets-appendix-chart",ref:a,children:e.jsx(q,{width:"100%",height:je,children:e.jsxs(mt,{data:u,margin:we,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"grad-ratio",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",
5stopColor:Y.primary,stopOpacity:.12}),e.jsx("stop",{offset:"95%",stopColor:Y.primary,stopOpacity:0})]}),e.jsx("filter",{id:"shadow-ratio",x:"-2%",y:"-10%",width:"104%",height:"130%",children:e.jsx("feDropShadow",{dx:"0",dy:"2",stdDeviation:"3",floodColor:Y.primary,floodOpacity:"0.15"})})]}),e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"date",...ne}),e.jsx(X,{...de,label:Me("RSP / SPY")}),e.jsx(Z,{contentStyle:pe,labelFormatter:x=>String(x)}),e.jsx(at,{type:"monotone",dataKey:"ratio",stroke:Y.primary,strokeWidth:2,fill:"url(#grad-ratio)",style:{filter:"url(#shadow-ratio)"}})]})})}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."})})]})}const $i=[{value:"1d",label:"1D"},{value:"1w",label:"1W"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"},{value:"10y",label:"10Y"}];function Ci({pinned:t}){const[r,a]=o.useState("1y"),[s,n]=o.useState([]),[i,l]=o.useState(!0),[d,c]=o.useState(!0),[u,x]=o.useState(""),p=o.useRef(null),h=o.useCallback(async g=>{l(!0);try{const m=t?`&end=${t.date}`:"",b=await(await fetch(`/api/markets/daily?chart=10yr-treasury&interval=${g}${m}`)).json();b.ok&&(n(b.data),c(b.meta?.dataAvailable??!0),x(b.meta?.dataStartDate??""))}catch(m){console.error("TreasuryYield10Y fetch error:",m)}finally{l(!1)}},[]);o.useEffect(()=>{h(r)}
5,[r,h]);const f=o.useMemo(()=>s.length?s.map(g=>({date:String(g.date).slice(0,10),yield:Number(Number(g.yield).toFixed(2))})):[],[s]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{interval:r,intervalOptions:$i,onInterval:a,loading:i,exportRef:p,exportFilename:"10-year-treasury-yield"}),!i&&!d?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#767972",border:"1px dashed #c9c5bb",borderRadius:8},children:[e.jsx("p",{style:{fontSize:15,marginBottom:8},children:"Not enough data available for this time range."}),e.jsxs("p",{style:{fontSize:13},children:["Data collection started ",u||"Feb 10, 2026","."]})]}):i&&!s.length?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]}):f.length>0?e.jsx("div",{className:"markets-appendix-chart",ref:p,children:e.jsx(q,{width:"100%",height:je,children:e.jsxs(mt,{data:f,margin:we,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"grad-yield",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:Y.primary,stopOpacity:.12}),e.jsx("stop",{offset:"95%",stopColor:Y.primary,stopOpacity:0})]}),e.jsx("filter",{id:"shadow-yield",x:"-2%",y:"-10%",width:"104%",height:"130%",children:e.jsx("feDropShadow",{dx:"0",dy:"2",stdDeviation:"3",floodColor:Y.primary,floodOpacity:"0.15"})})]}),e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"date",...ne}),e.jsx(X,{...de,label:Me("Yield (%)")}),e.jsx(Z,{contentStyle:pe,labelFormatter:g=>String(g)}),e.jsx(at,{type:"monotone",dataKey:"yield",stroke:Y.primary,strokeWidth:2,fill:"url(#grad-yield)",style:{filter:"url(#shadow-yield)"}})]})})}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."})]})}const Di=[{value:"1d",label:"1D"},{value:"1w",label:"1W"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"},{value:"10y",label:"10Y"}];function _i({interval:t,controlled:r=!1,pinnedDate:a}={}){const[s,n]=o.useState("1d"),i=r?t??"1d":s,l=o.useRef(null),d=dr(),[c,u]=o.useState([]),[x,p]=o.useState(!0),[h,f]=o.useState(!0),[g,m]=o.useState(""),y=o.useCallback(async S=>{p(!0);try{const k=a?`&end=${a}`:"",w=await(await fetch(`/api/markets/daily?chart=g10-currency-strength&interval=${S}${k}`)).json();w.ok&&(u(w.data),f(w.meta?.dataAvailable??!0),m(w.meta?.dataStartDate??""))}catch(k){console.error("G10CurrencyStrength fetch error:",k)}finally{p(!1)}},[a]);o.useEffect(()=>{y(i)},[i,y]);const b=o.useMemo(()=>c.length?c.map(S=>({name:S.pair,value:Number(Number(S.pct_change).toFixed(2))})):[],[c]);return e.jsxs("div",{style:{width:"100%"},children:[!r&&e.jsx(L,{interval:i,intervalOptions:Di,onInterval:n,loading:x,exportRef:l,exportFilename:"g10-currency-strength"}),!x&&!h?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#767972",border:"1px dashed #c9c5bb",borderRadius:8},children:[e.jsx("p",{style:{fontSize:15,marginBottom:8},children:"Not enough data available for this time range."}),e.jsxs("p",{style:{fontSize:13},children:["Data collection started ",g||"Feb 10, 2026","."]})]}):x&&!c.length?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]}):b.length>0?e.jsx("div",{className:"markets-appendix-chart",ref:l,children:e.jsx(q,{width:"100%",height:300,children:e.jsxs(Ce,{data:b,margin:{top:8,right:12,left:8,bottom:8},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"name",...ne}),e.jsx(X,{tick:{fontSize:11,fill:"#6d716e"},tickLine:!1,axisLine:!1,width:64,label:{value:"% Change vs USD",angle:-90,position:"insideLeft",offset:-2,style:{fontSize:11,fill:"#767972",textAnchor:"middle"}}}),e.jsx(Z,{contentStyle:{background:"#fbfaf7",border:"1px solid #c9c5bb",borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},formatter:S=>[`${S.toFixed(2)}%`,"% Change vs USD"]}),e.jsxs(ye,{dataKey:"value",radius:[4,4,0,0],children:[e.jsx(Hr,{dataKey:"value",...d?{content:Jr()}:{position:"top",style:{fontSize:10,fill:"#6d716e"},formatter:S=>`${Number(S).toFixed(1)}%`}}),b.map((S,k)=>e.jsx(De,{fill:S.value>=0?"#1a8b66":"#a33a3a"},k))]})]})})}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No currency data available."})]})}const Fi=[{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"},{value:"10y",label:"10Y"}];function Ti(){const[t,r]=o.useState("1m"),[a,s]=o.useState([]),[n,i]=o.useState(!0),[l,d]=o.use
5State(!0),[c,u]=o.useState(""),x=o.useRef(null),p=o.useCallback(async f=>{i(!0);try{const m=await(await fetch(`/api/markets/daily?chart=usd-sp500-correlation&interval=${f}`)).json();m.ok&&(s(m.data),d(m.meta?.dataAvailable??!0),u(m.meta?.dataStartDate??""))}catch(g){console.error("UsdSp500Correlation fetch error:",g)}finally{i(!1)}},[]);o.useEffect(()=>{p(t)},[t,p]);const h=o.useMemo(()=>a.length?a.map(f=>({date:String(f.trade_date).slice(0,10),correlation:Number(Number(f.correlation_10d).toFixed(4))})):[],[a]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{interval:t,intervalOptions:Fi,onInterval:r,loading:n,exportRef:x,exportFilename:"usd-sp500-correlation"}),!n&&!l?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#767972",border:"1px dashed #c9c5bb",borderRadius:8},children:[e.jsx("p",{style:{fontSize:15,marginBottom:8},children:"Not enough overlapping data for USD and S&P 500."}),e.jsxs("p",{style:{fontSize:13},children:["This chart requires at least 10 trading days of overlapping FX and equity data. Data collection started ",c||"Feb 10, 2026","."]})]}):n&&!a.length?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]}):h.length>0?e.jsx("div",{className:"markets-appendix-chart",ref:x,children:e.jsx(q,{width:"100%",height:je,children:e.jsxs(mt,{data:h,margin:we,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"grad-correlation",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:Y.primary,stopOpacity:.12}),e.jsx("stop",{offset:"95%",stopColor:Y.primary,stopOpacity:0})]}),e.jsx("filter",{id:"shadow-correlation",x:"-2%",y:"-10%",width:"104%",height:"130%",children:e.jsx("feDropShadow",{dx:"0",dy:"2",stdDeviation:"3",floodColor:Y.primary,floodOpacity:"0.15"})})]}),e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"date",...ne}),e.jsx(X,{...de,label:Me("Correlation")}),e.jsx(Z,{contentStyle:pe,labelFormatter:f=>String(f)}),e.jsx(at,{type:"monotone",dataKey:"correlation",stroke:Y.primary,strokeWidth:2,fill:"url(#grad-correlation)",style:{filter:"url(#shadow-correlation)"}})]})})}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available. Requires at least 20 trading days."})]})}const Wi=[{value:"1d",label:"1D"},{value:"1w",label:"1W"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"},{value:"10y",label:"10Y"}];function Li({interval:t,controlled:r=!1,pinnedDate:a}={}){const[s,n]=o.useState("3m"),i=r?t??"3m":s,[l,d]=o.useState([]),[c,u]=o.useState(!0),[x,p]=o.useState(!0),[h,f]=o.useState(""),g=o.useRef(null),m=o.useCallback(async k=>{u(!0);try{const v=a?`&end=${a}`:"",j=await(await fetch(`/api/markets/daily?chart=dxy-index&interval=${k}${v}`)).json();j.ok&&(d(j.data),p(j.meta?.dataAvailable??!0),f(j.meta?.dataStartDate??""))}catch(v){console.error("DxyIndex fetch error:",v)}finally{u(!1)}},[a]);o.useEffect(()=>{m(i)},[i,m]);const y=o.useMemo(()=>l.length?l.map(k=>({date:String(k.trade_date).slice(0,10),dxy:Number(Number(k.dxy).toFixed(2))})):[],[l]),[b,S]=o.useMemo(()=>{if(!y.length)return[0,100];const k=y.map(R=>R.dxy),v=Math.min(...k),w=Math.max(...k),j=(w-v)*.05||1;return[Math.floor((v-j)*100)/100,Math.ceil((w+j)*100)/100]},[y]);return e.jsxs("div",{style:{width:"100%"},children:[!r&&e.jsx(L,{interval:i,intervalOptions:Wi,onInterval:n,loading:c,exportRef:g,exportFilename:"dxy-index"}),!c&&!x?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#767972",border:"1px dashed #c9c5bb",borderRadius:8},children:[e.jsx("p",{style:{fontSize:15,marginBottom:8},children:"Not enough data available for this time range."}),e.jsxs("p",{style:{fontSize:13},children:["Data collection started ",h||"Feb 10, 2026","."]})]}):c&&!l.length?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]}):y.length>0?e.jsx("div",{className:"markets-appendix-chart",ref:g,children:e.jsx(q,{width:"100%",height:je,children:e.jsxs(mt,{data:y,margin:we,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"grad-dxy",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",
5stopColor:Y.primary,stopOpacity:.12}),e.jsx("stop",{offset:"95%",stopColor:Y.primary,stopOpacity:0})]}),e.jsx("filter",{id:"shadow-dxy",x:"-2%",y:"-10%",width:"104%",height:"130%",children:e.jsx("feDropShadow",{dx:"0",dy:"2",stdDeviation:"3",floodColor:Y.primary,floodOpacity:"0.15"})})]}),e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"date",...ne}),e.jsx(X,{...de,domain:[b,S],label:Me("DXY Index")}),e.jsx(Z,{contentStyle:pe,labelFormatter:k=>String(k)}),e.jsx(at,{type:"monotone",dataKey:"dxy",stroke:Y.primary,strokeWidth:2,fill:"url(#grad-dxy)",style:{filter:"url(#shadow-dxy)"}})]})})}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."})]})}const Ei=[{value:"1w",label:"1W"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"},{value:"10y",label:"10Y"}];function zi({pinned:t}){const[r,a]=o.useState("1m"),s=o.useRef(null),{data:n,meta:i,loading:l,fetchChart:d}=tt(),c=i?.dataAvailable??!0,u=i?.dataStartDate??"",x=t?`&end=${t.date}`:"";o.useEffect(()=>{d(`/api/markets/daily?chart=advance-decline&interval=${r}${x}`)},[r,x,d]);const p=o.useMemo(()=>n.length?n.map(h=>({date:String(h.trade_date).slice(0,10),adLine:Number(h.ad_line),net:Number(h.net_advance),advancers:Number(h.advancers),decliners:-Number(h.decliners)})):[],[n]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{interval:r,intervalOptions:Ei,onInterval:a,loading:l,exportRef:s,exportFilename:"advance-decline-line"}),!l&&!c?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#767972",border:"1px dashed #c9c5bb",borderRadius:8},children:[e.jsx("p",{style:{fontSize:15,marginBottom:8},children:"Not enough data available for this time range."}),e.jsxs("p",{style:{fontSize:13},children:["Data collection started ",u||"Feb 10, 2026","."]})]}):e.jsx(Pe,{loading:l,hasData:p.length>0,height:340,children:p.length>0?e.jsxs("div",{className:"markets-appendix-chart",style:{height:"auto"},ref:s,children:[e.jsx("p",{style:{fontSize:12,fontWeight:600,color:"#28313f",margin:"0 0 4px"},children:"Cumulative A/D Line"}),e.jsx("p",{style:{fontSize:11,color:"#6d716e",margin:"0 0 8px"},children:"Running total of (advancers â decliners) across the period â the bars below show each day's contribution."}),e.jsx(q,{width:"100%",height:200,children:e.jsxs(Wt,{data:p,margin:we,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"grad-ad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:Y.primary,stopOpacity:.15}),e.jsx("stop",{offset:"95%",stopColor:Y.primary,stopOpacity:0})]}),e.jsx("filter",{id:"shadow-ad",x:"-2%",y:"-10%",width:"104%",height:"130%",children:e.jsx("feDropShadow",{dx:"0",dy:"2",stdDeviation:"3",floodColor:Y.primary,floodOpacity:"0.15"})})]}),e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"date",...ne}),e.jsx(X,{...de}),e.jsx(Z,{contentStyle:pe,formatter:(h,f)=>f==="adLine"?[h.toLocaleString(),"Cumulative A/D"]:[h,f],labelFormatter:h=>String(h)}),e.jsx(at,{type:"monotone",dataKey:"adLine",stroke:Y.primary,strokeWidth:2,fill:"url(#grad-ad)",name:"adLine",style:{filter:"url(#shadow-ad)"}})]})}),e.jsx("p",{style:{fontSize:12,fontWeight:600,color:"#28313f",margin:"16px 0 4px"},children:"Daily Net Advances"}),e.jsx(q,{width:"100%",height:120,children:e.jsxs(Wt,{data:p,margin:{top:4,right:12,left:0,bottom:8},children:[e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"date",...ne}),e.jsx(X,{...de}),e.jsx(Z,{contentStyle:pe,formatter:h=>[h.toLocaleString(),"Net Advances"],labelFormatter:h=>String(h)}),e.jsx(ye,{dataKey:"net",name:"Net Advances",radius:[2,2,0,0],children:p.map((h,f)=>e.jsx(De,{fill:h.net>=0?Y.green:Y.red},f))})]})})]}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."})})]})}const Pi=[{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"},{value:"10y",label:"10Y"}],Bi=[10,20,30,40],Ii=[30,60,90,180,252],Oi=[10,20,30,60],Yi=Bi.map(t=>({value:String(t),label:`${t}D`})),Vi=Ii.map(t=>({value:String(t),label:`${t}D`})),Ki=Oi.map(t=>({value:String(t),label:`${t}D`}));function wa(t){const r=t.length;if(r<2)return{slope:1,intercept:0};let a=0,s=0,n=0,i=0;for(const d of t)a+=d.x,s+=d.y,n+=d.x*d.y,i+=d.x*d.x;const l=r*i-a*a;return l===0?{slope:0,intercept:s/r}:{slope:(r*n-a*s)/l,intercept:(s*i-a*n)/l}}
5const St={background:"var(--markets-card-bg, #fbfaf7)",border:"1px solid var(--markets-card-border, #c9c5bb)",borderRadius:12,padding:16,overflow:"hidden"},Yt={fontSize:11,fill:"#6d716e"},wt=e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."}),Na=t=>e.jsx("circle",{cx:t.cx,cy:t.cy,r:2,fill:t.fill,fillOpacity:.45}),Ra=t=>e.jsxs("g",{children:[e.jsx("circle",{cx:t.cx,cy:t.cy,r:6.5,fill:"#a33a3a",fillOpacity:.18}),e.jsx("circle",{cx:t.cx,cy:t.cy,r:4.5,fill:"#a33a3a",stroke:"#fbfaf7",strokeWidth:1.5})]});function Aa(t){if(t.length===0)return{rest:[],latest:[]};let r=t[0].date;for(const n of t)n.date>r&&(r=n.date);const a=[],s=[];for(const n of t)(n.date===r?s:a).push(n);return{rest:a,latest:s}}const Ui=t=>{const{x:r,y:a,width:s,height:n,payload:i}=t;if(!i||!n||i.p25===i.p75)return null;const{p10:l,p25:d,p50:c,p75:u,p90:x}=i,p=n/(u-d),h=g=>a+(u-g)*p,f=r+s/2;return e.jsxs("g",{children:[e.jsx("line",{x1:f,y1:h(x),x2:f,y2:h(l),stroke:"#6d716e",strokeWidth:1}),e.jsx("line",{x1:f-5,y1:h(x),x2:f+5,y2:h(x),stroke:"#6d716e",strokeWidth:1}),e.jsx("line",{x1:f-5,y1:h(l),x2:f+5,y2:h(l),stroke:"#6d716e",strokeWidth:1}),e.jsx("rect",{x:r+1,y:a,width:s-2,height:n,fill:"#2f63d6",fillOpacity:.7,rx:2}),e.jsx("line",{x1:r+1,y1:h(c),x2:r+s-1,y2:h(c),stroke:"#fbfaf7",strokeWidth:2})]})};function Hi({pinned:t}){const r=o.useRef(null),a=o.useRef(null),s=o.useRef(null),n=o.useRef(null),i=o.useRef(null),[l,d]=o.useState("1y"),[c,u]=o.useState(()=>{if(!t)return null;const[O,F]=[t.date.slice(0,4),t.date.slice(4)];return{start:`${Number(O)-1}${F}`.replace(/-02-29$/,"-02-28"),end:t.date}}),x=tt(),[p,h]=o.useState(20),f=tt(),[g,m]=o.useState(252),y=tt(),[b,S]=o.useState([]),[k,v]=o.useState(!0),[w,j]=o.useState(null),[R,N]=o.useState([]),[D,M]=o.use
5State(!0),[$,T]=o.useState(30),[A,B]=o.useState(!1);o.useEffect(()=>{t||fetch("/api/markets/daily?chart=vix-bundle").then(O=>O.json()).then(O=>{O.ok&&(y.seedCache("/api/markets/daily?chart=vix-spy-correlation&window=252",O.data.correlation,O.meta?.correlationMeta??null),S(O.data.spyScatter),O.meta?.spyScatterMeta&&j(O.meta.spyScatterMeta),v(!1),N(O.data.decileReturns),M(!1),B(!0))}).catch(O=>{console.error("VIX bundle fetch error:",O),v(!1),M(!1)})},[]),o.useEffect(()=>{const O=c?`chart=vix&start=${c.start}&end=${c.end}`:`chart=vix&interval=${l}`;x.fetchChart(`/api/markets/daily?${O}`)},[l,c,x.fetchChart]),o.useEffect(()=>{t||f.fetchChart(`/api/markets/daily?chart=vix-scatter&days=${p}`)},[p,f.fetchChart]),o.useEffect(()=>{t||!A&&g===252||y.fetchChart(`/api/markets/daily?chart=vix-spy-correlation&window=${g}`)},[g,A,y.fetchChart]);const _=x.meta?.dataAvailable??!0,E=x.meta?.dataStartDate??"",V=f.meta,W=y.meta,K=o.useMemo(()=>x.data.length?x.data.map(O=>({date:String(O.date).slice(0,10),vix:Number(Number(O.vix).toFixed(2))})):[],[x.data]),re=o.useMemo(()=>{if(f.data.length<2)return null;const O=f.data.map(H=>({x:H.recent_vol,y:H.vix})),{slope:F,intercept:P}=wa(O),G=f.data.map(H=>H.recent_vol);return{slope:F,intercept:P,xMin:Math.min(...G),xMax:Math.max(...G)}},[f.data]),se=o.useMemo(()=>{const O=`d${$}`;return R.map(F=>{const P=F[O];return{label:F.label,n:F.n,range:[P.p25,P.p75],...P}})},[R,$]),Fe=o.useMemo(()=>{if(!se.length)return[-10,15];const O=se.map(P=>P.p10),F=se.map(P=>P.p90);return[Math.floor(Math.min(...O)-1),Math.ceil(Math.max(...F)+1)]},[se]),he=o.useMemo(()=>{if(b.length<2)return null;const O=b.map(H=>({x:H.vix_pct,y:H.spy_pct})),{slope:F,intercept:P}=wa(O),G=b.map(H=>H.vix_pct);return{slope:F,intercept:P,xMin:Math.min(...G),xMax:Math.max(...G)}},[b]),qe=o.useMemo(()=>e.jsx(q,{width:"100%",height:je,children:e.jsxs(mt,{data:K,margin:we,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"grad-vix",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:Y.red,stopOpacity:.12}),e.jsx("stop",{offset:"95%",stopColor:Y.red,stopOpacity:0})]}),e.jsx("filter",{id:"shadow-vix",x:"-2%",y:"-10%",width:"104%",height:"130%",children:e.jsx("feDropShadow",{dx:"0",dy:"2",stdDeviation:"3",floodColor:Y.red,floodOpacity:"0.15"})})]}),e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"date",...ne}),e.jsx(X,{...de,label:Me("VIX Level")}),e.jsx(Z,{contentStyle:pe,formatter:O=>[O.toFixed(2),"VIX"],labelFormatter:O=>String(O)}),e.jsx(at,{type:"monotone",dataKey:"vix",stroke:Y.red,strokeWidth:2,fill:"url(#grad-vix)",style:{filter:"url(#shadow-vix)"},isAnimationActive:!1})]})}),[K]),Le=o.useMemo(()=>{const{rest:O,latest:F}=Aa(f.data);return e.jsx(q,{width:"100%",height:360,children:e.jsxs(sa,{margin:{top:8,right:12,left:4,bottom:24},children:[e.jsx(J,{...ce}),e.jsx(Q,{type:"number",dataKey:"recent_vol",name:"Recent Vol",tick:Yt,tickLine:!1,axisLine:{stroke:"rgba(0,0,0,0.08)"},label:{value:"Recent Volatility (%)",position:"bottom",offset:4,style:{fontSize:11,fill:Y.secondary}}}),e.jsx(X,{type:"number",dataKey:"vix",name:"VIX",tick:Yt,tickLine:!1,axisLine:!1,width:40}),e.jsx(Z,{content:({active:P,payload:G})=>{if(!P||!G?.[0])return null;const H=G[0].payload;return e.jsxs("div",{style:{...pe,padding:"8px 12px"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:2},children:H.date}),e.jsxs("div",{children:["Recent Vol: ",H.recent_vol.toFixed(1),"%"]}),e.jsxs("div",{children:["VIX: ",H.vix.toFixed(1)]})]})}}),e.jsx(Bt,{data:O,fill:"#4a90d9",shape:Na,isAnimationActive:!1}),e.jsx(Bt,{data:F,fill:"#a33a3a",shape:Ra,isAnimationActive:!1}),re&&e.jsx(le,{ifOverflow:"extendDomain",segment:[{x:re.xMin,y:re.slope*re.xMin+re.intercept},{x:re.xMax,y:re.slope*re.xMax+re.intercept}],stroke:Y.primary,strokeWidth:3})]})})},[f.data,re]),Ae=o.useMemo(()=>e.jsx(q,{width:"100%",height:"100%",children:e.jsxs(_e,{data:y.data,margin:we,children:[e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"date",...ne}),e.jsx(X,{...de,domain:[-1,0],label:Me("Correlation")}),e.jsx(Z,{contentStyle:pe,formatter:O=>[O.toFixed(4),"Correlation"],labelFormatter:O=>String(O)}),e.jsx(le,{y:-.75,stroke:Y.tertiary,strokeDasharray:"3 3"}),e.jsx(ie,{type:"monotone",dataKey:"correlation",stroke:Y.red,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})}),[y.data]),nt=o.useMemo(()=>{const{rest:O,latest:F}=Aa(b);return e.jsx(q,{width:"100%",height:"100%",children:e.jsxs(sa,{margin:{top:8,right:12,left:4,bottom:24},children:[e.jsx(J,{...ce}),e.jsx(Q,{type:"number",dataKey:"vix_pct",name:"VIX % Change",tick:Yt,tickLine:!1,axisLine
5:{stroke:"rgba(0,0,0,0.08)"},label:{value:"VIX % Change",position:"bottom",offset:4,style:{fontSize:11,fill:Y.secondary}},tickFormatter:P=>`${P}%`}),e.jsx(X,{type:"number",dataKey:"spy_pct",name:"SPY % Return",tick:Yt,tickLine:!1,axisLine:!1,width:50,tickFormatter:P=>`${P}%`}),e.jsx(Z,{content:({active:P,payload:G})=>{if(!P||!G?.[0])return null;const H=G[0].payload;return e.jsxs("div",{style:{...pe,padding:"8px 12px"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:2},children:H.date}),e.jsxs("div",{children:["VIX Change: ",H.vix_pct.toFixed(2),"%"]}),e.jsxs("div",{children:["SPY Return: ",H.spy_pct.toFixed(2),"%"]})]})}}),e.jsx(le,{y:0,stroke:Y.tertiary,strokeDasharray:"3 3"}),e.jsx(le,{x:0,stroke:Y.tertiary,strokeDasharray:"3 3"}),e.jsx(Bt,{data:O,fill:"#4a90d9",shape:Na,isAnimationActive:!1}),e.jsx(Bt,{data:F,fill:"#a33a3a",shape:Ra,isAnimationActive:!1}),he&&e.jsx(le,{ifOverflow:"extendDomain",segment:[{x:he.xMin,y:he.slope*he.xMin+he.intercept},{x:he.xMax,y:he.slope*he.xMax+he.intercept}],stroke:Y.primary,strokeWidth:3})]})})},[b,he]),Xe=o.useMemo(()=>e.jsx(q,{width:"100%",height:je,children:e.jsxs(Ce,{data:se,margin:{...we,bottom:8},children:[e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"label",tick:{fontSize:10,fill:"#6d716e"},tickLine:!1,axisLine:{stroke:"rgba(0,0,0,0.08)"},angle:-35,textAnchor:"end",height:50,interval:0}),e.jsx(X,{...de,tickFormatter:O=>`${O}%`,label:Me("Return (%)"),domain:Fe}),e.jsx(Z,{content:({active:O,payload:F})=>{if(!O||!F?.[0])return null;const P=F[0].payload;return e.jsxs("div",{style:{...pe,padding:"8px 12px"},children:[e.jsxs("div",{style:{fontWeight:600,marginBottom:4},children:["VIX: ",P.label]}),e.jsxs("div",{children:["p90: ",P.p90.toFixed(2),"%"]}),e.jsxs("div",{children:["p75: ",P.p75.toFixed(2),"%"]}),e.jsxs("div",{style:{fontWeight:600},children:["Median: ",P.p50.toFixed(2),"%"]}),e.jsxs("div",{children:["p25: ",P.p25.toFixed(2),"%"]}),e.jsxs("div",{children:["p10: ",P.p10.toFixed(2),"%"]}),e.jsxs("div",{style:{fontSize:10,color:"#767972",marginTop:4},children:["n = ",P.n]})]})}}),e.jsx(le,{y:0,stroke:Y.tertiary,strokeDasharray:"3 3"}),e.jsx(ye,{dataKey:"range",shape:e.jsx(Ui,{}),isAnimationActive:!1})]})}),[se,Fe]);return e.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{className:"markets-split",style:St,children:[e.jsx(L,{interval:l,intervalOptions:Pi,onInterval:O=>{u(null),d(O)},startDate:c?.start??x.meta?.start??"",endDate:c?.end??x.meta?.end??"",onStartDate:O=>O&&u({start:O,end:c?.end??x.meta?.end??O}),onEndDate:O=>O&&u({start:c?.start??x.meta?.start??O,end:O}),loading:x.loading,exportRef:r,exportFilename:"vix"}),e.jsx("div",{ref:r,children:!x.loading&&!_?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#767972",border:"1px dashed #c9c5bb",borderRadius:8},children:[e.jsx("p",{style:{fontSize:15,marginBottom:8},children:"Not enough data for this range."}),e.jsxs("p",{style:{fontSize:13},children:["Data starts ",E||"Jan 2, 2004"," (FRED VIXCLS)."]})]}):e.jsx(Pe,{loading:x.loading,hasData:K.length>0,height:je,children:K.length>0?qe:wt})})]}),!t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"markets-split",style:St,children:[e.jsx("h3",{style:{fontSize:13,fontWeight:700,color:Y.primary,margin:"0 0 4px"},children:"SPY Realized Volatility vs VIX"}),e.jsxs("p",{style:{fontSize:11,color:Y.secondary,margin:"0 0 8px"},children:["S&P 500 trailing ",p,"-day realized vol vs VIX closing level"]}),e.jsx(L,{interval:String(p),intervalOptions:Yi,onInterval:O=>h(Number(O)),loading:f.loading,exportRef:a,exportFilename:"spy-realized-volatility-vs-vix"}),e.jsx("div",{ref:a,children:e.jsx(Pe,{loading:f.loading,hasData:f.data.length>0,height:360,children:f.data.length>0?e.jsxs(e.Fragment,{children:[Le,V&&e.jsxs("p",{style:{fontSize:10,color:Y.tertiary,margin:"8px 0 0",textAlign:"right"},children:["Data from ",V.minDate," to ",V.maxDate]})]}):wt})})]}),e.jsxs("div",{style:{display:"flex",gap:16,width:"100%",alignItems:"stretch"},children:[e.jsxs("div",{className:"markets-split",style:{...St,flex:1,minWidth:0,display:"flex",flexDirection:"column"},children:[e.jsx("h3",{style:{fontSize:13,fontWeight:700,color:Y.primary,margin:"0 0 4px"},children:"S&P 500 / VIX Rolling Correlation"}),e.jsxs("p",{style:{fontSize:11,color:Y.secondary,margin:"0 0 8px"},children:[g,"-day rolling correlation between S&P 500 daily % changes and VIX point changes"]}),e.jsx(L,{interval:String(g),intervalOptions:Vi,onInterval:O=>m(Number(O)),loading:y.loading,exportRef:s,exportFilename:"spy-vix-rolling-correlation"}),e.jsx("div",{ref:s,style:{flex:1,minHeight:300},children:e.jsx(Pe,{loading:y.loading,hasData:y.data.length>0,height:"100%",children:y.data.length>0?Ae:wt})}
5),W&&e.jsxs("p",{style:{fontSize:10,color:Y.tertiary,margin:"8px 0 0",textAlign:"right"},children:["Data from ",W.minDate," to ",W.maxDate]})]}),e.jsxs("div",{className:"markets-split",style:{...St,flex:1,minWidth:0,display:"flex",flexDirection:"column"},children:[e.jsx("h3",{style:{fontSize:13,fontWeight:700,color:Y.primary,margin:"0 0 4px"},children:"VIX % Change vs SPY % Return (Same Day)"}),e.jsx("p",{style:{fontSize:11,color:Y.secondary,margin:"0 0 12px"},children:"Contemporaneous daily VIX % change vs S&P 500 return (not lagged)"}),e.jsx(L,{loading:k,exportRef:n,exportFilename:"vix-pct-change-vs-spy-return"}),e.jsx("div",{ref:n,style:{flex:1,minHeight:300},children:e.jsx(Pe,{loading:k,hasData:b.length>0,height:"100%",children:b.length>0?nt:wt})}),w&&e.jsxs("p",{style:{fontSize:10,color:Y.tertiary,margin:"8px 0 0",textAlign:"right"},children:["Data from ",w.minDate," to ",w.maxDate]})]})]}),e.jsxs("div",{className:"markets-split",style:St,children:[e.jsx("h3",{style:{fontSize:13,fontWeight:700,color:Y.primary,margin:"0 0 4px"},children:"SPY Forward Return Distribution by VIX Decile"}),e.jsxs("p",{style:{fontSize:11,color:Y.secondary,margin:"0 0 8px"},children:[$,"-day forward S&P 500 return spread (p10-p90) grouped by VIX level decile"]}),e.jsx(L,{interval:String($),intervalOptions:Ki,onInterval:O=>T(Number(O)),loading:D,exportRef:i,exportFilename:"spy-forward-return-by-vix-decile"}),e.jsx("div",{ref:i,children:e.jsx(Pe,{loading:D,hasData:se.length>0,height:je,children:se.length>0?Xe:wt})})]})]})]})}function qi(){const[t,r]=o.useState([]),[a,s]=o.useState(!0),[n,i]=o.useState({}),l=o.useRef(null),d=o.useCallback(async()=>{s(!0);try{const p=await(await fetch("/api/markets/daily?chart=top50-by-sector")).json();p.ok&&(r(p.data),i(p.meta??{}))}catch(x){console.error("Top50BySector fetch error:",x)}finally{s(!1)}},[]);if(o.useEffect(()=>{d()},[d]),a&&!t.length)return e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:400}})]});if(!t.length)return e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."});const c=n.startDate?String(n.startDate).slice(0,10):"",u=n.endDate?String(n.endDate).slice(0,10):"";return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:l,exportFilename:"top-50-by-sector"}),e.jsxs("div",{ref:l,children:[c&&u&&e.jsxs("p",{style:{fontSize:12,color:"#6d716e",marginBottom:8},children:["Period: ",c," to ",u]}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px solid #111722"},children:[e.jsx("th",{style:{textAlign:"left",padding:"6px 10px",fontWeight:600,color:"#6d716e",width:30},children:"#"}),e.jsx("th",{style:{textAlign:"left",padding:"6px 10px",fontWeight:600,color:"#6d716e"},children:"Symbol"}),e.jsx("th",{style:{textAlign:"left",padding:"6px 10px",fontWeight:600,color:"#6d716e"},children:"Name"}),e.jsx("th",{style:{textAlign:"left",padding:"6px 10px",fontWeight:600,color:"#6d716e"},children:"Sector"}),e.jsx("th",{style:{textAlign:"right",padding:"6px 10px",fontWeight:600,color:"#6d716e"},children:"Return %"}),e.jsx("th",{style:{textAlign:"right",padding:"6px 10px",fontWeight:600,color:"#6d716e"},children:"Mkt Cap ($B)"})]})}),e.jsx("tbody",{children:t.map((x,p)=>e.jsxs("tr",{style:{borderBottom:"1px solid rgba(0,0,0,0.06)"},children:[e.jsx("td",{style:{padding:"5px 10px",color:"#767972",fontSize:12},children:p+1}),e.jsx("td",{style:{padding:"5px 10px",fontWeight:600,color:"#111722"},children:x.symbol}),e.jsx("td",{style:{padding:"5px 10px",color:"#28313f",maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.name}),e.jsx("td",{style:{padding:"5px 10px",color:"#6d716e",fontSize:12},children:x.sector}),e.jsxs("td",{style:{padding:"5px 10px",textAlign:"right",fontWeight:600,fontVariantNumeric:"tabular-nums",color:Number(x.pct_return)>=0?"#1a8b66":"#a33a3a"},children:[Number(x.pct_return)>0?"+":"",Number(x.pct_return).toFixed(1),"%"]}),e.jsx("td",{style:{padding:"5px 10px",textAlign:"right",fontVariantNumeric:"tabular-nums",color:"#28313f"},children:Number(x.mkt_cap_b).toFixed(1)})]},x.symbol))})]})})]})]})}const Ze={padding:"10px 16px",textAlign:"center",fontVariantNumeric:"tabular-nums",fontSize:14,borderBottom:"1px solid #c9c5bb"},dt={...Ze,fontWeight:600,fontSize:12,color:"#6d716e",background:"#f6f3ec",borderBottom:"2px s
5olid #c9c5bb"};function Vt(t,r=""){return t==null?"â":`${t.toFixed(1)}${r}`}function Xi(){const[t,r]=o.useState([]),[a,s]=o.useState(!0),n=o.useRef(null),i=o.useCallback(async()=>{s(!0);try{const d=await(await fetch("/api/markets/daily?chart=valuations-by-cap")).json();d.ok&&r(d.data)}catch(l){console.error("ValuationsByCap fetch error:",l)}finally{s(!1)}},[]);return o.useEffect(()=>{i()},[i]),a&&!t.length?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:200}})]}):t.length?e.jsxs("div",{children:[e.jsx(L,{exportRef:n,exportFilename:"valuations-by-cap",loading:a}),e.jsx("div",{ref:n,style:{width:"100%",display:"flex",justifyContent:"center"},children:e.jsxs("table",{style:{borderCollapse:"collapse",border:"1px solid #c9c5bb",minWidth:500},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{...dt,textAlign:"left"},children:"Cap Size"}),e.jsx("th",{style:dt,children:"Companies"}),e.jsx("th",{style:dt,children:"Trailing P/E"}),e.jsx("th",{style:dt,children:"Interest Coverage"}),e.jsx("th",{style:dt,children:"% Unprofitable"}),e.jsx("th",{style:dt,children:"Earnings Yield"})]})}),e.jsx("tbody",{children:t.map(l=>e.jsxs("tr",{children:[e.jsxs("td",{style:{...Ze,textAlign:"left",fontWeight:600,color:"#111722"},children:[l.cap_size," Cap"]}),e.jsx("td",{style:{...Ze,color:"#28313f"},children:Number(l.n_companies).toLocaleString()}),e.jsx("td",{style:{...Ze,fontWeight:600,color:"#111722"},children:Vt(l.median_pe,"x")}),e.jsx("td",{style:{...Ze,fontWeight:600,color:"#111722"},children:Vt(l.median_interest_coverage,"x")}),e.jsx("td",{style:{...Ze,fontWeight:600,color:l.pct_unprofitable!=null&&l.pct_unprofitable>30?"#a33a3a":"#111722"},children:Vt(l.pct_unprofitable,"%")}),e.jsx("td",{style:{...Ze,fontWeight:600,color:"#111722"},children:Vt(l.avg_earnings_yield,"%")})]},l.cap_size))})]})})]}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."})}const Ma=-2e3,$a=5e3;function Gi(t){const r=/^\d{4}-\d{2}$/;if(!t.length||!t.every(s=>r.test(s)))return;const a=t.filter(s=>{const n=s.slice(5,7);return n==="03"||n==="06"||n==="09"||n==="12"});if(a.length){if(a.length>16){const s=Math.ceil(a.length/16);return a.filter((n,i)=>i%s===0)}return a}}function Qi({data:t}){const r=o.useRef(null),a=o.useMemo(()=>t?.[0]?.data?t[0].data.map(n=>({x:String(n.x),value:Math.max(Ma,Math.min($a,Number(n.y))),raw:Number(n.y)})):[],[t]),s=o.useMemo(()=>Gi(a.map(n=>n.x)),[a]);return a.length?e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"nonfarm-payrolls"}),e.jsx("div",{ref:r,children:e.jsx(q,{width:"100%",height:300,children:e.jsxs(Ce,{data:a,margin:{top:8,right:12,left:8,bottom:40},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"x",...ne,...s?{ticks:s,interval:0}:{interval:"preserveStartEnd"}}),e.jsx(X,{domain:[Ma,$a],tick:{fontSize:11,fill:C.muted},tickLine:!1,axisLine:!1,width:64,label:{value:"Thousands",angle:-90,position:"insideLeft",offset:-2,style:{fontSize:11,fill:"#767972",textAnchor:"middle"}}}),e.jsx(le,{y:0,stroke:"rgba(0,0,0,0.2)"}),e.jsx(Z,{contentStyle:{background:"#fbfaf7",border:`1px solid ${C.cardBorder}`,borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},formatter:(n,i,l)=>[l.payload.raw.toLocaleString(),"MoM Change"]}),e.jsx(ye,{dataKey:"value",radius:[3,3,0,0],children:a.map((n,i)=>e.jsx(De,{fill:n.raw>=0?C.positive:C.negative},i))})]})})})]}):null}function yn({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"jolts-openings"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"Thousands"})})]})}function bn({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"jolts-hires"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"Thousands"})})]})}function jn({data:t}){const r=o.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"jolts-layoffs"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"Thousands"})})]})}function Ji({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"labor-participation"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"%"})})]})}function Zi({data:t}){const r=o.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"labor-force-growth"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"bar",colorBySign:!0,yAxisLabel:"Millions"})})]})}function el({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"inflation-components"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"YoY %",monthsBack:12})})]})}function tl({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"us-dollar"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"Index"})})]})}function rl({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"trade-balance"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"area",yAxisLabel:"Billions $"})})]})}function al({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"dm-rate-differentials"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"pp"})})]})}function nl({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"household-debt-service"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"%"})})]})}function sl({data:t}){const r=o.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"delinquencies"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"% Delinquent"})})]})}function ol({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"federal-debt"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"area",yAxisLabel:"% of GDP"})})]})}function il({data:t}){const r=o.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"federal-budget"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"% of GDP"})})]})}function ll({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"treasury-yields-nominal-real"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"Yield %"})})]})}function cl({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"credit-spreads"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"OAS (bps)",monthsBack:12})})]})}function dl({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"debt-levels"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line"})})]})}function hl({data:t}){const r=o.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"policy-rates"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"%"})})]})}function xl({data:t}){const r=o.useRef(null);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:r,exportFilename:"global-pmi"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"Index"})})]})}function ul({data:t}){const r=o.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"bank-lending"}),e.jsx("div",{ref:r,children:e.jsx(te,{data:t,chartType:"line",yAxisLabel:"$B"})})]})}const pl=[{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"}];function Kt(t){if(t==null)return"#ece8df";if(t===1)return"#dbeafe";const r=Math.min(Math.abs(t),1);if(t>0){const n=Math.round(220-r*100),i=Math.round(255-r*30);return`rgb(${Math.round(220-r*120)}, ${n}, ${i})`}const a=Math.round(255-r*30),s=Math.round(220-r*100);return`rgb(${a}, ${s}, ${Math.round(220-r*120)})`}function fl(t){return t==null?"#767972":Math.abs(t)>.6?"#111722":"#28313f"}function ml(){const[t,r]=o.useState("3m"),[a,s]=o.useState(null),[n,i]=o.useState(!0),l=o.useRef(null),d=o.useCallback(async x=>{i(!0);try{const h=await(await fetch(`/api/markets/daily?chart=fx-correlations&interval=${x}`)).json();h.ok&&s(h.data)}catch(p){console.error("CurrencyCorrelations fetch error:",p)}finally{i(!1)}},[]);o.useEffect(()=>{d(t)},[t,d]);const c=a?.labels??[],u=a?.matrix??[];return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{interval:t,intervalOptions:pl,onInterval:r,loading:n,exportRef:l,exportFilename:"currency-correlations"}),e.jsx("div",{ref:l,children:n&&!a?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:340}})]}):a&&c.length>0?e.jsxs("div",{style:{overflowX:"auto"},children:[e.jsxs("table",{style:{borderCollapse:"collapse",border:"1px solid #c9c5bb",width:"100%",maxWidth:700,margin:"0 auto"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{padding:"10px 14px",fontSize:12,fontWeight:700,color:"#6d716e",background:"#f6f3ec",borderBottom:"2px s
5olid #c9c5bb",borderRight:"1px solid #c9c5bb",textAlign:"left"},children:"vs USD"}),c.map(x=>e.jsx("th",{style:{padding:"10px 8px",fontSize:12,fontWeight:700,color:"#111722",background:"#f6f3ec",borderBottom:"2px solid #c9c5bb",borderRight:"1px solid #c9c5bb",textAlign:"center",minWidth:54},children:x},x))]})}),e.jsx("tbody",{children:u.map(x=>e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"10px 14px",fontSize:12,fontWeight:700,color:"#111722",background:"#f6f3ec",borderBottom:"1px solid #c9c5bb",borderRight:"1px solid #c9c5bb"},children:x.row}),c.map(p=>{const h=x.cols[p],f=x.row===p;return e.jsx("td",{style:{padding:"8px 6px",textAlign:"center",fontSize:12,fontWeight:f?400:600,fontVariantNumeric:"tabular-nums",color:f?"#767972":fl(h),background:Kt(h),borderBottom:"1px solid #c9c5bb",borderRight:"1px solid #c9c5bb"},children:h!=null?f?"â":h.toFixed(2):"â"},p)})]},x.row))})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,marginTop:16,fontSize:11,color:"#6d716e"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("div",{style:{width:16,height:12,background:Kt(-.8),borderRadius:2,border:"1px solid #c9c5bb"}}),e.jsx("span",{children:"Negative"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("div",{style:{width:16,height:12,background:Kt(0),borderRadius:2,border:"1px solid #c9c5bb"}}),e.jsx("span",{children:"Neutral"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("div",{style:{width:16,height:12,background:Kt(.8),borderRadius:2,border:"1px solid #c9c5bb"}}),e.jsx("span",{children:"Positive"})]})]})]}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No correlation data available."})})]})}function ht(t){return t==="above"?"#a33a3a":t==="below"?"#1a8b66":"#6d716e"}function gl(t){return t==="above"?"Above Upper Band":t==="below"?"Below Lower Band":"Within Bands"}function yl(){const[t,r]=o.useState([]),[a,s]=o.useState(!0),n=o.useRef(null),i=o.useRef(null),l=o.useCallback(async()=>{s(!0);try{const u=await(await fetch("/api/markets/daily?chart=fx-bollinger-movers")).json();u.ok&&r(u.data)}catch(c){console.error("CurrencyMovers fetch error:",c)}finally{s(!1)}},[]);o.useEffect(()=>{l()},[l]),o.useEffect(()=>{if(!n.current||!t.length)return;const c={top:20,right:80,left:70,bottom:30},u=600,p=c.top+c.bottom+t.length*36,h=U(n.current);h.selectAll("*").remove(),h.attr("viewBox",`0 0 ${u} ${p}`);const f=Math.max(3,Oe(t,y=>Math.abs(y.z_score))??3),g=Ne().domain([-f,f]).range([c.left,u-c.right]),m=Ie().domain(t.map(y=>y.pair)).range([c.top,p-c.bottom]).padding(.25);h.append("rect").attr("x",g(-2)).attr("y",c.top).attr("width",g(2)-g(-2)).attr("height",p-c.top-c.bottom).attr("fill","#f0fdf4").attr("opacity",.5),h.append("rect").attr("x",g(2)).attr("y",c.top).attr("width",g(f)-g(2)).attr("height",p-c.top-c.bottom).attr("fill","#fef2f2").attr("opacity",.5),h.append("rect").attr("x",g(-f)).attr("y",c.top).attr("width",g(-2)-g(-f)).attr("height",p-c.top-c.bottom).attr("fill","#f0fdf4").attr("opacity",.5),[2,-2].forEach(y=>{h.append("line").attr("x1",g(y)).attr("x2",g(y)).attr("y1",c.top).attr("y2",p-c.bottom).attr("stroke","#c9c5bb").attr("stroke-dasharray","4,3").attr("stroke-width",1)}),h.append("line").attr("x1",g(0)).attr("x2",g(0)).attr("y1",c.top).attr("y2",p-c.bottom).attr("stroke","#767972").attr("stroke-width",1),h.selectAll(".bb-bar").data(t).join("rect").attr("class","bb-bar").attr("x",y=>y.z_score>=0?g(0):g(y.z_score)).attr("y",y=>m(y.pair)).attr("width",y=>Math.abs(g(y.z_score)-g(0))).attr("height",m.bandwidth()).attr("fill",y=>ht(y.band_position)).attr("rx",3).attr("opacity",.85),h.selectAll(".z-label").data(t).join("text").attr("class","z-label").attr("x",y=>y.z_score>=0?g(y.z_score)+6:g(y.z_score)-6).attr("y",y=>m(y.pair)+m.bandwidth()/2).attr("dy","0.35em").attr("text-anchor",y=>y.z_score>=0?"start":"end").attr("font-size",11).attr("font-weight",600).attr("fill",y=>ht(y.band_position)).text(y=>`${y.z_score>0?"+":""}${y.z_score.toFixed(1)}Ï`),h.selectAll(".pair-label").data(t).join("text").attr("class","pair-label").attr("x",c.left-8).attr("y",y=>m(y.pair)+m.bandwidth()/2).attr("dy","0.35em").attr("text-anchor","end").attr("font-size",12).attr("font-weight",600).attr("fill","#111722").text(y=>y.pair),h.append("text").attr("x",(g(-2)+g(-f))/2).attr("y",c.top-6).attr("text-anchor","middle").attr("font-size",9).attr("fill","#1a8b66").text("Oversold"),h.append("text").attr("x",(g(2)+g(-2))/2).attr("y",c.top-6).attr("text-anchor","middle").attr("font-size",9).attr("fill","#767972").text("Within Bands"),h.append("text").attr("x",(g(2)+g(f))/2).attr("y",c.top-6).attr("text-anchor","middle").attr("font-size",9).attr("fill","#a33a3a").text("Overbought")},[t]);const d=t.filter(c=>c.band_position!=="within");return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{loading:a,exportRef:i,exportFilename:"currency-movers"}),a&&!t.length?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:340}})]}):t.length>0?e.jsxs("div",{ref:i,children:[d.length>0?e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:16},children:d.map(c=>e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:20,background:c.band_position==="above"?"#fef2f2":"#f0fdf4",border:`1px solid ${c.band_position==="above"?"#fecaca":"#bbf7d0"}`,fontSize:12,fontWeight:600},children:[e.jsx("span",{style:{color:ht(c.band_position)},children:c.band_position==="above"?"â²":"â¼"}),e.jsx("span",{style:{color:"#111722"},children:c.pair}),e.jsxs("span",{style:{color:ht(c.band_position)},children:[c.z_score>0?"+":"",c.z_score.toFixed(1),"Ï"]})]},c.pair))}):e.jsx("div",{style:{padding:"10px 16px",marginBottom:16,borderRadius:8,background:"#f0fdf4",border:"1px solid #bbf7d0",fontSize:13,color:"#166b50"},children:"All G10 pairs are currently trading within their 20-day Bollinger Bands."}),e.jsx("div",{style:{width:"100%",maxWidth:650},children:e.jsx("svg",{ref:n,style:{width:"100%",height:"auto"}})}),e.jsx("div",{style:{overflowX:"auto",marginTop:20},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",border:"1px solid #c9c5bb",fontSize:12},children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:"#f6f3ec"},children:["Pair","Close","SMA(20)","Lower","Upper","Z-Score","Status"].map(c=>e.jsx("th",{style:{padding:"8px 10px",fontWeight:600,color:"#6d716e",borderBottom:"2px s
5olid #c9c5bb",borderRight:"1px solid #c9c5bb",textAlign:c==="Pair"||c==="Status"?"left":"right"},children:c},c))})}),e.jsx("tbody",{children:t.map(c=>e.jsxs("tr",{style:{background:c.band_position!=="within"?c.band_position==="above"?"#fef2f2":"#f0fdf4":void 0},children:[e.jsx("td",{style:{padding:"8px 10px",fontWeight:600,color:"#111722",borderBottom:"1px solid #c9c5bb",borderRight:"1px solid #c9c5bb"},children:c.pair}),e.jsx("td",{style:{padding:"8px 10px",textAlign:"right",fontVariantNumeric:"tabular-nums",borderBottom:"1px solid #c9c5bb",borderRight:"1px solid #c9c5bb",color:"#111722"},children:c.current_close}),e.jsx("td",{style:{padding:"8px 10px",textAlign:"right",fontVariantNumeric:"tabular-nums",borderBottom:"1px solid #c9c5bb",borderRight:"1px solid #c9c5bb",color:"#6d716e"},children:c.sma}),e.jsx("td",{style:{padding:"8px 10px",textAlign:"right",fontVariantNumeric:"tabular-nums",borderBottom:"1px solid #c9c5bb",borderRight:"1px solid #c9c5bb",color:"#1a8b66"},children:c.lower_band}),e.jsx("td",{style:{padding:"8px 10px",textAlign:"right",fontVariantNumeric:"tabular-nums",borderBottom:"1px solid #c9c5bb",borderRight:"1px solid #c9c5bb",color:"#a33a3a"},children:c.upper_band}),e.jsxs("td",{style:{padding:"8px 10px",textAlign:"right",fontVariantNumeric:"tabular-nums",fontWeight:600,color:ht(c.band_position),borderBottom:"1px solid #c9c5bb",borderRight:"1px solid #c9c5bb"},children:[c.z_score>0?"+":"",c.z_score.toFixed(2)]}),e.jsx("td",{style:{padding:"8px 10px",fontWeight:500,color:ht(c.band_position),borderBottom:"1px solid #c9c5bb"},children:gl(c.band_position)})]},c.pair))})]})})]}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No Bollinger Band data available."})]})}const bl={Amazon:"#ff9900",Alphabet:"#4285f4",Microsoft:"#00a4ef",Meta:"#0668e1",Apple:"#a2aaad",Oracle:"#f80000",Tesla:"#cc0000"},Ca=["#2f63d6","#d97706","#1a8b66","#7c3aed","#0891b2","#a33a3a","#db2777","#65a30d"],jl={background:"#fbfaf7",border:`1px solid ${C.cardBorder}`,borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},vl={fontSize:11,fill:C.muted};function kl({data:t}){const r=o.useRef(null),{rows:a,seriesInfo:s}=o.useMemo(()=>{if(!t?.length)return{rows:[],seriesInfo:[]};const i=t.map((c,u)=>`s${u}`),l=t.map((c,u)=>({key:i[u],label:c.id,color:bl[c.id]??Ca[u%Ca.length]})),d=new Map;for(let c=0;c<t.length;c++)for(const u of t[c].data){const x=String(u.x);d.has(x)||d.set(x,{x}),d.get(x)[i[c]]=u.y??0}return{rows:Array.from(d.values()),seriesInfo:l}},[t]);if(!a.length)return null;const n={};for(const i of s)n[i.key]=i.label;return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"hyperscaler-capex"}),e.jsx("div",{ref:r,children:e.jsx(q,{width:"100%",height:360,children:e.jsxs(Ce,{data:a,margin:{top:8,right:12,left:0,bottom:40},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"x",...ne}),e.jsx(X,{tick:vl,tickFormatter:i=>`$${i}B`,tickLine:!1,axisLine:!1,width:56}),e.jsx(Z,{contentStyle:jl,formatter:(i,l)=>[`$${i.toFixed(1)}B`,n[l]??l],labelFormatter:i=>String(i)}),e.jsx(ve,{verticalAlign:"top",height:32,formatter:i=>n[i]??i,wrapperStyle:{fontSize:12,color:"#28313f"}}),s.map(i=>e.jsx(ye,{dataKey:i.key,fill:i.color,radius:[3,3,0,0],name:i.key},i.key))]})})})]})}const Sl={"Operating CF / Sales":"#2f63d6","Capex / Sales":"#a33a3a","Free CF / Sales":"#1a8b66"},Da=["#2f63d6","#a33a3a","#1a8b66","#d97706","#7c3aed","#0891b2"],wl={background:"#fbfaf7",border:`1px solid ${C.cardBorder}`,borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},Nl={fontSize:11,fill:C.muted};function Rl({data:t}){const r=o.useRef(null),{rows:a,seriesInfo:s,labelMap:n}=o.useMemo(()=>{if(!t?.length)return{rows:[],seriesInfo:[],labelMap:{}};const i=t.map((u,x)=>`s${x}`),l=t.map((u,x)=>({key:i[x],label:u.id,color:Sl[u.id]??Da[x%Da.length]})),d=new Map;for(let u=0;u<t.length;u++)for(const x of t[u].data){const p=String(x.x);d.has(p)||d.set(p,{x:p}),d.get(p)[i[u]]=x.y??0}const c={};for(const u of l)c[u.key]=u.label;return{rows:Array.from(d.values()),seriesInfo:l,labelMap:c}},[t]);return a.length?e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"hyperscaler-cashflow"}),e.jsx("div",{ref:r,children:e.jsx(q,{width:"100%",height:360,children:e.jsxs(_e,{data:a,margin:{top:8,right:12,left:0,bottom:40},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"x",...ne,interval:"preserveStartEnd"}),e.jsx(X,{tick:Nl,tickFormatter:i=>`${i}
5%`,tickLine:!1,axisLine:!1,width:48}),e.jsx(Z,{contentStyle:wl,formatter:(i,l)=>[`${i.toFixed(1)}%`,n[l]??l],labelFormatter:i=>String(i)}),e.jsx(ve,{verticalAlign:"top",height:32,formatter:i=>n[i]??i,wrapperStyle:{fontSize:12,color:"#28313f"}}),s.map(i=>e.jsx(ie,{type:"monotone",dataKey:i.key,stroke:i.color,strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:i.key},i.key))]})})})]}):null}const Al={"Total Assets":"#2f63d6","Total Liabilities":"#a33a3a","Net Worth":"#1a8b66"},_a=["#2f63d6","#a33a3a","#1a8b66","#d97706","#7c3aed","#0891b2"],Ml={background:"#fbfaf7",border:`1px solid ${C.cardBorder}`,borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},$l={fontSize:11,fill:C.muted},Dt={padding:"6px 12px",fontSize:13,borderBottom:"1px solid #c9c5bb"},Ut={...Dt,fontWeight:600,fontSize:12,color:"#6d716e",background:"#f6f3ec",borderBottom:"2px solid #c9c5bb"};function Ht(t){return`$${t.toFixed(1)}T`}function Cl(){const[t,r]=o.useState(null),[a,s]=o.useState(!0),n=o.useRef(null),i=o.useCallback(async()=>{s(!0);try{const S=await(await fetch("/api/markets/daily?chart=consumer-balance")).json();S.ok&&r(S.data)}catch(b){console.error("ConsumerBalance fetch error:",b)}finally{s(!1)}},[]);if(o.useEffect(()=>{i()},[i]),a&&!t)return e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:400}})]});if(!t)return e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."});const l=t.data,d=t.series,c=l?.assets?[{label:"Real Estate",value_t:l.assets.real_estate},{label:"Other Assets",value_t:l.assets.other},{label:"Total Assets",value_t:l.assets.total}]:[],u=l?.liabilities?[{label:"Consumer Credit",value_t:l.liabilities.consumer_credit},{label:"Other Liabilities",value_t:l.liabilities.other},{label:"Total Liabilities",value_t:l.liabilities.total}]:[],x=d??[],p=x.map((b,S)=>`s${S}`),h=x.map(b=>b.label??b.id),f=h.map((b,S)=>Al[b]??_a[S%_a.length]),g={};p.forEach((b,S)=>{g[b]=h[S]});const m=new Map;for(let b=0;b<x.length;b++)for(const S of x[b].data){const k=String(S.x??S.date??"");m.has(k)||m.set(k,{x:k}),m.get(k)[p[b]]=S.y??S.value??0}const y=Array.from(m.values());return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{loading:a,exportRef:n,exportFilename:"consumer-balance-sheet"}),e.jsxs("div",{ref:n,children:[l&&e.jsxs("div",{style:{display:"flex",gap:24,marginBottom:20,flexWrap:"wrap"},children:[c.length>0&&e.jsx("div",{children:e.jsxs("table",{style:{borderCollapse:"collapse",border:"1px solid #c9c5bb",minWidth:220},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{...Ut,textAlign:"left"},children:"Assets"}),e.jsx("th",{style:{...Ut,textAlign:"right"},children:"Value"})]})}),e.jsx("tbody",{children:c.map(b=>e.jsxs("tr",{children:[e.jsx("td",{style:{...Dt,color:"#28313f"},children:b.label}),e.jsx("td",{style:{...Dt,textAlign:"right",fontWeight:600,fontVariantNumeric:"tabular-nums",color:"#111722"},children:Ht(b.value_t)})]},b.label))})]})}),u.length>0&&e.jsx("div",{children:e.jsxs("table",{style:{borderCollapse:"collapse",border:"1px solid #c9c5bb",minWidth:220},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{...Ut,textAlign:"left"},children:"Liabilities"}),e.jsx("th",{style:{...Ut,textAlign:"right"},children:"Value"})]})}),e.jsx("tbody",{children:u.map(b=>e.jsxs("tr",{children:[e.jsx("td",{style:{...Dt,color:"#28313f"},children:b.label}),e.jsx("td",{style:{...Dt,textAlign:"right",fontWeight:600,fontVariantNumeric:"tabular-nums",color:"#a33a3a"},children:Ht(b.value_t)})]},b.label))})]})}),l.net_worth!=null&&e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 20px",background:"#f0fdf4",borderRadius:8,border:"1px solid #bbf7d0"},children:e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:12,color:"#6d716e",fontWeight:600},children:["Net Worth",l.as_of?` (${l.as_of})`:""]}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:"#1a8b66",fontVariantNumeric:"tabular-nums"},children:Ht(l.net_worth)})]})})]}),y.length>0&&e.jsx(q,{width:"100%",height:320,children:e.jsxs(_e,{data:y,margin:{top:8,right:12,left:0,bottom:40},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"x",...ne,interval:"preserveStartEnd"}),e.jsx(X,{tick:$l,tickFormatter:b=>`$${b.toFixed(0)}
5T`,tickLine:!1,axisLine:!1,width:56}),e.jsx(Z,{contentStyle:Ml,formatter:(b,S)=>[Ht(b),g[S]??S],labelFormatter:b=>String(b)}),e.jsx(ve,{verticalAlign:"top",height:32,formatter:b=>g[b]??b,wrapperStyle:{fontSize:12,color:"#28313f"}}),p.map((b,S)=>e.jsx(ie,{type:"monotone",dataKey:b,stroke:f[S],strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:b},b))]})})]})]})}const Dl={background:"#fbfaf7",border:`1px solid ${C.cardBorder}`,borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},qt={display:"flex",flexDirection:"column",alignItems:"center",padding:"10px 18px",borderRadius:8,border:"1px solid #c9c5bb",background:"#f6f3ec",minWidth:120};function _l(){const[t,r]=o.useState(null),[a,s]=o.useState(!0),n=o.useRef(null),i=o.useCallback(async()=>{s(!0);try{const f=await(await fetch("/api/markets/daily?chart=expansions-recessions")).json();f.ok&&r(f.data)}catch(h){console.error("ExpansionsRecessions fetch error:",h)}finally{s(!1)}},[]);if(o.useEffect(()=>{i()},[i]),a&&!t)return e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:400}})]});if(!t)return e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."});const l=t.data??{},d=l.recessions??[],c=l.expansions??[],u=l.summary,x=[];for(const h of d)parseInt(h.start.slice(0,4),10)>=1929&&x.push({label:h.label||`${h.start}`,duration:h.duration_months,type:"recession",start:h.start,end:h.end});for(const h of c)parseInt(h.start.slice(0,4),10)>=1929&&x.push({label:h.label||`${h.start}`,duration:h.duration_months,type:"expansion",start:h.start,end:h.end});x.sort((h,f)=>h.start.localeCompare(f.start));const p=x.map(h=>({label:h.label,duration:h.duration,type:h.type,start:h.start,end:h.end}));return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{loading:a,exportRef:n,exportFilename:"expansions-recessions"}),e.jsxs("div",{ref:n,children:[u&&e.jsxs("div",{style:{display:"flex",gap:16,marginBottom:20,flexWrap:"wrap"},children:[u.avg_expansion_months!=null&&e.jsxs("div",{style:qt,children:[e.jsx("div",{style:{fontSize:11,color:"#6d716e",fontWeight:600,marginBottom:4},children:"Avg Expansion"}),e.jsxs("div",{style:{fontSize:20,fontWeight:700,color:C.positive},children:[u.avg_expansion_months.toFixed(0)," mo"]})]}),u.avg_recession_months!=null&&e.jsxs("div",{style:qt,children:[e.jsx("div",{style:{fontSize:11,color:"#6d716e",fontWeight:600,marginBottom:4},children:"Avg Recession"}),e.jsxs("div",{style:{fontSize:20,fontWeight:700,color:C.negative},children:[u.avg_recession_months.toFixed(0)," mo"]})]}),u.longest_expansion&&e.jsxs("div",{style:qt,children:[e.jsx("div",{style:{fontSize:11,color:"#6d716e",fontWeight:600,marginBottom:4},children:"Longest Expansion"}),e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#111722"},children:u.longest_expansion.label}),e.jsxs("div",{style:{fontSize:12,color:C.positive},children:[u.longest_expansion.months," mo"]})]}),u.longest_recession&&e.jsxs("div",{style:qt,children:[e.jsx("div",{style:{fontSize:11,color:"#6d716e",fontWeight:600,marginBottom:4},children:"Longest Recession"}),e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#111722"},children:u.longest_recession.label}),e.jsxs("div",{style:{fontSize:12,color:C.negative},children:[u.longest_recession.months," mo"]})]})]}),p.length>0&&e.jsx(q,{width:"100%",height:Math.max(400,p.length*28+60),children:e.jsxs(Ce,{data:p,layout:"vertical",margin:{top:8,right:24,left:80,bottom:8},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)",horizontal:!1}),e.jsx(Q,{type:"number",...ne,label:{value:"Duration (months)",position:"insideBottom",offset:-4,style:{fontSize:11,fill:"#767972"}}}),e.jsx(X,{type:"category",dataKey:"label",tick:{fontSize:10,fill:C.muted},tickLine:!1,axisLine:!1,width:75}),e.jsx(Z,{contentStyle:Dl,formatter:(h,f,g)=>{const m=g.payload,y=m?.type==="recession"?"Recession":"Expansion";return[`${h} months (${y})`,`${m?.start??""} to ${m?.end??""}`]},labelFormatter:h=>String(h)}),e.jsx(ve,{verticalAlign:"top",height:32,wrapperStyle:{fontSize:12,color:"#28313f"},payload:[{value:"Expansion",type:"square",color:C.positive},{value:"Recession",type:"square",color:C.negative}]}),e.jsx(ye,{dataKey:"duration",radius:[0,3,3,0],name:"duration",children:p.map((h,f)=>e.jsx(De,{fill:h.type==="recession"?C.negative:C.positive},f))})]})})]})]})}const et={padding:"6px 10px",fontSize:13,borderBottom:"1px solid #c9c5bb",whiteSpace:"nowrap"},xt={...et,fontWeight:600,fontSize:12,color:"#6d716e",background:"#f6f3ec",borderBottom:"2px s
5olid #c9c5bb"},Fa={display:"flex",flexDirection:"column",alignItems:"center",padding:"10px 18px",borderRadius:8,border:"1px solid #c9c5bb",background:"#f6f3ec",minWidth:120};function Fl(){const[t,r]=o.useState(null),[a,s]=o.useState(!0),n=o.useRef(null),i=o.useCallback(async()=>{s(!0);try{const h=await(await fetch("/api/markets/daily?chart=bear-bull-markets")).json();h.ok&&r(h.data)}catch(p){console.error("BearBullMarkets fetch error:",p)}finally{s(!1)}},[]);if(o.useEffect(()=>{i()},[i]),a&&!t)return e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:400}})]});if(!t)return e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."});const l=t.data??{},d=l.bears??[],c=l.bulls??[],u=l.summary,x=[...d.map(p=>({label:p.label,start:p.peak_date,end:p.trough_date,duration_months:p.duration_months,magnitude_pct:p.decline_pct,type:"bear"})),...c.map(p=>({label:p.label,start:p.start_date,end:p.end_date,duration_months:p.duration_months,magnitude_pct:p.gain_pct,type:"bull"}))].sort((p,h)=>p.start.localeCompare(h.start));return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:n,exportFilename:"bear-bull-markets"}),e.jsxs("div",{ref:n,children:[u&&e.jsxs("div",{style:{display:"flex",gap:16,marginBottom:20,flexWrap:"wrap"},children:[u.avg_bull_months!=null&&e.jsxs("div",{style:Fa,children:[e.jsx("div",{style:{fontSize:11,color:"#6d716e",fontWeight:600,marginBottom:4},children:"Avg Bull Market"}),e.jsxs("div",{style:{fontSize:20,fontWeight:700,color:C.positive},children:[u.avg_bull_months.toFixed(0)," mo"]}),u.avg_bull_gain!=null&&e.jsxs("div",{style:{fontSize:12,color:C.positive},children:["+",u.avg_bull_gain.toFixed(0),"%"]})]}),u.avg_bear_months!=null&&e.jsxs("div",{style:Fa,children:[e.jsx("div",{style:{fontSize:11,color:"#6d716e",fontWeight:600,marginBottom:4},children:"Avg Bear Market"}),e.jsxs("div",{style:{fontSize:20,fontWeight:700,color:C.negative},children:[u.avg_bear_months.toFixed(0)," mo"]}),u.avg_bear_decline!=null&&e.jsxs("div",{style:{fontSize:12,color:C.negative},children:[u.avg_bear_decline.toFixed(0),"%"]})]})]}),x.length>0&&e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",border:"1px solid #c9c5bb"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{...xt,textAlign:"left"},children:"Type"}),e.jsx("th",{style:{...xt,textAlign:"left"},children:"Period"}),e.jsx("th",{style:{...xt,textAlign:"left"},children:"Start"}),e.jsx("th",{style:{...xt,textAlign:"left"},children:"End"}),e.jsx("th",{style:{...xt,textAlign:"right"},children:"Duration"}),e.jsx("th",{style:{...xt,textAlign:"right"},children:"Return"})]})}),e.jsx("tbody",{children:x.map((p,h)=>{const f=p.type==="bear",g=f?"rgba(185, 28, 28, 0.04)":"rgba(5, 150, 105, 0.04)";return e.jsxs("tr",{style:{background:g},children:[e.jsx("td",{style:{...et,fontWeight:600,color:f?C.negative:C.positive},children:f?"Bear":"Bull"}),e.jsx("td",{style:{...et,color:"#28313f",fontWeight:500},children:p.label}),e.jsx("td",{style:{...et,color:"#6d716e",fontVariantNumeric:"tabular-nums"},children:p.start}),e.jsx("td",{style:{...et,color:"#6d716e",fontVariantNumeric:"tabular-nums"},children:p.end}),e.jsxs("td",{style:{...et,textAlign:"right",fontVariantNumeric:"tabular-nums",color:"#28313f"},children:[p.duration_months," mo"]}),e.jsxs("td",{style:{...et,textAlign:"right",fontWeight:600,fontVariantNumeric:"tabular-nums",color:p.magnitude_pct>=0?C.positive:C.negative},children:[p.magnitude_pct>=0?"+":"",p.magnitude_pct.toFixed(1),"%"]})]},h)})})]})})]})]})}const Tl={background:"#fbfaf7",border:`1px solid ${C.cardBorder}`,borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},Ta={fontSize:11,fill:C.muted},$r="#2f63d6",Cr="#d97706";function Wl({data:t}){const r=o.useRef(null),{rows:a,leftSeries:s,rightSeries:n,labelMap:i}=o.useMemo(()=>{if(!t?.length)return{rows:[],leftSeries:null,rightSeries:null,labelMap:{}};const d=t[0]??null,c=t[1]??null,u=new Map;if(d)for(const p of d.data){const h=String(p.x);u.has(h)||u.set(h,{x:h}),u.get(h).s0=p.y??0}if(c)for(const p of c.data){const h=String(p.x);u.has(h)||u.set(h,{x:h}),u.get(h).s1=p.y??0}const x={};return d&&(x.s0=d.id),c&&(x.s1=c.id),{rows:Array.from(u.values()),leftSeries:d?{key:"s0",label:d.id}:null,rightSeries:c?{key:"s1",label:c.id}:null,labelMap:x}},[t]);if(!a.length)return null;const l=s&&n;return e.jsxs(e.Fragment,{children:[e.jsx(L,{exportRef:r,exportFilename:"listed-companies"}),e.jsx("div",{ref:r,children:e.jsx(q,{width:"100%",height:360,children:e.jsxs(_e,{data:a,margin:{top:8,right:l?56:12,left:0,bottom:40},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"x",...ne,interval:"preserveStartEnd"}),e.jsx(X,{yAxisId:"left",tick:{...Ta,fill:$r},tickFormatter:d=>d>=1e3?`${(d/1e3).toFixed(1)}
5k`:String(d),tickLine:!1,axisLine:!1,width:52,label:s?{value:s.label,angle:-90,position:"insideLeft",offset:10,style:{fontSize:10,fill:$r}}:void 0}),l&&e.jsx(X,{yAxisId:"right",orientation:"right",tick:{...Ta,fill:Cr},tickFormatter:d=>`$${d.toFixed(0)}T`,tickLine:!1,axisLine:!1,width:52,label:n?{value:n.label,angle:90,position:"insideRight",offset:10,style:{fontSize:10,fill:Cr}}:void 0}),e.jsx(Z,{contentStyle:Tl,formatter:(d,c)=>{const u=i[c]??c;return c==="s1"?[`$${d.toFixed(1)}T`,u]:[d.toLocaleString(),u]},labelFormatter:d=>String(d)}),e.jsx(ve,{verticalAlign:"top",height:32,formatter:d=>i[d]??d,wrapperStyle:{fontSize:12,color:"#28313f"}}),s&&e.jsx(ie,{yAxisId:"left",type:"monotone",dataKey:s.key,stroke:$r,strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:s.key}),n&&e.jsx(ie,{yAxisId:l?"right":"left",type:"monotone",dataKey:n.key,stroke:Cr,strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:n.key})]})})})]})}const Ll={background:"var(--markets-card-bg, #fbfaf7)",border:"1px solid var(--markets-card-border, #c9c5bb)",borderRadius:12,padding:16,overflow:"hidden"},El={width:"100%",borderCollapse:"collapse",border:"1px solid var(--markets-card-border, #c9c5bb)",fontSize:13},Nt={padding:"12px 14px",textAlign:"left",fontWeight:700,color:Y.primary,borderBottom:"1px solid var(--markets-card-border, #c9c5bb)",background:"rgba(63, 107, 89, 0.04)"},Rt={padding:"12px 14px",borderBottom:"1px solid var(--markets-card-border, #c9c5bb)",color:Y.primary,verticalAlign:"top"},Xt=t=>`${t>=0?"+":""}${(t*100).toFixed(1)}%`,zl=t=>t==="crsp-sp500-total-return"?"CRSP S&P 500 total return":t==="spy-total-return"?"SPY total return":t==="spy-close-to-close"?"SPY close-to-close":"Unavailable";function Pl(){const[t,r]=o.useState([]),[a,s]=o.useState(!0),[n,i]=o.useState(null),l=o.useRef(null),d=o.useCallback(async()=>{s(!0);try{const u=await(await fetch("/api/markets/daily?chart=top-10-days")).json();u.ok&&(r(u.data),u.meta&&i(u.meta))}catch(c){console.error("Top 10 Days fetch error:",c)}finally{s(!1)}},[]);return o.useEffect(()=>{d()},[d]),e.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:16},children:[e.jsx(L,{loading:a,exportRef:l,exportFilename:"impact-of-missing-best-and-worst-days"}),e.jsxs("div",{style:Ll,ref:l,children:[e.jsx("h3",{style:{fontSize:13,fontWeight:700,color:Y.primary,margin:"0 0 4px"},children:"Impact of Missing the Best and Worst Days"}),e.jsx("p",{style:{fontSize:11,color:Y.secondary,margin:"0 0 12px"},children:"Full calendar-year return comparison for the past 20 years under four scenarios."}),a?e.jsx("div",{className:"markets-skeleton",style:{height:220}}):t.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:El,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Nt,children:"Year"}),e.jsx("th",{style:Nt,children:"S&P 500"}),e.jsx("th",{style:Nt,children:"Miss 10 Worst"}),e.jsx("th",{style:Nt,children:"Miss 10 Best"}),e.jsx("th",{style:Nt,children:"Miss Both"})]})}),e.jsx("tbody",{children:t.map(c=>e.jsxs("tr",{children:[e.jsx("td",{style:Rt,children:c.year}),e.jsx("td",{style:{...Rt,color:c.all_return>=0?Y.green:Y.red},children:Xt(c.all_return)}),e.jsx("td",{style:{...Rt,color:c.no_worst_return>=0?Y.green:Y.red},children:Xt(c.no_worst_return)}),e.jsx("td",{style:{...Rt,color:c.no_best_return>=0?Y.green:Y.red},children:Xt(c.no_best_return)}),e.jsx("td",{style:{...Rt,color:c.no_both_return>=0?Y.green:Y.red},children:Xt(c.no_both_return)})]},c.year))})]})}),n&&e.jsxs("p",{style:{fontSize:10,color:Y.tertiary,margin:"10px 0 0"},children:["Window: ",n.startYear," to ",n.endYear,". Source: ",zl(n.source),"."]})]}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."})]})]})}const Dr={mkt_rf:"#2f63d6",smb:"#1a8b66",hml:"#a33a3a"};function Bl(t){return t==null?"â":`${Number(t)>=0?"+":""}${Number(t).toFixed(2)}%`}function ze(t,r=2){return t==null?"â":Number(t).toFixed(r)}const Il=[60,126,252,504];function vn(){const[t,r]=o.useState("AAPL"),[a,s]=o.useState("AAPL"),[n,i]=o.useState(252),[l,d]=o.use
5State(null),[c,u]=o.useState(null),[x,p]=o.useState(!1),h=o.useCallback(async(m,y)=>{if(m){p(!0),u(null);try{const S=await(await fetch(`/api/markets/daily?chart=ff-loadings&ticker=${encodeURIComponent(m)}&window=${y}`)).json();S.ok?"error"in S.data?(u(S.data.error),d(null)):d(S.data):(u("Failed to fetch loadings."),d(null))}catch(b){u(b instanceof Error?b.message:"Unknown error"),d(null)}finally{p(!1)}}},[]);o.useEffect(()=>{h(a,n)},[h,a,n]);const f=m=>{m.preventDefault();const y=t.trim().toUpperCase();y&&s(y)},g=m=>{const y=Math.abs(m);return y>=2.58?"#1a8b66":y>=1.96?"#65a30d":"#767972"};return e.jsxs("div",{style:{marginTop:40},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#28313f",marginBottom:8},children:"Factor Loadings (regression of ticker excess returns on FF3 factors)"}),e.jsxs("form",{onSubmit:f,style:{display:"flex",gap:12,alignItems:"center",marginBottom:12},children:[e.jsxs("label",{style:{fontSize:12,color:"#6d716e"},children:["Ticker: ",e.jsx("input",{type:"text",value:t,onChange:m=>r(m.target.value),style:{padding:"4px 8px",fontSize:12,border:"1px solid #c9c5bb",borderRadius:4,width:80,fontFamily:"system-ui, -apple-system, sans-serif",textTransform:"uppercase"}})]}),e.jsxs("label",{style:{fontSize:12,color:"#6d716e"},children:["Window: ",e.jsx("select",{value:n,onChange:m=>i(Number(m.target.value)),style:{padding:"4px 8px",fontSize:12,border:"1px solid #c9c5bb",borderRadius:4},children:Il.map(m=>e.jsxs("option",{value:m,children:[m," days"]},m))})]}),e.jsx("button",{type:"submit",style:{padding:"4px 12px",fontSize:12,background:"#2f63d6",color:"white",border:0,borderRadius:4,cursor:"pointer"},children:"Run"}),x&&e.jsx("span",{style:{fontSize:12,color:"#767972"},children:"Runningâ¦"})]}),c&&e.jsx("div",{style:{fontSize:12,color:"#a33a3a",marginBottom:12},children:c}),l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12,fontFamily:"system-ui, -apple-system, sans-serif"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px solid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"6px 8px",fontWeight:600,color:"#28313f"},children:"Coefficient"}),e.jsx("th",{style:{textAlign:"right",padding:"6px 8px",fontWeight:600,color:"#28313f"},children:"Estimate"}),e.jsx("th",{style:{textAlign:"right",padding:"6px 8px",fontWeight:600,color:"#28313f"},children:"Std Error"}),e.jsx("th",{style:{textAlign:"right",padding:"6px 8px",fontWeight:600,color:"#28313f"},children:"t-stat"})]})}),e.jsxs("tbody",{children:[e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsxs("td",{style:{padding:"6px 8px",color:"#28313f"},children:["α (daily)",e.jsxs("span",{style:{color:"#767972",fontSize:11},children:[" · ann ",Bl(l.alpha.annPct)]})]}),e.jsx("td",{style:{textAlign:"right",padding:"6px 8px",fontVariantNumeric:"tabular-nums"},children:ze(l.alpha.estimate,5)}),e.jsx("td",{style:{textAlign:"right",padding:"6px 8px",fontVariantNumeric:"tabular-nums"},children:ze(l.alpha.se,5)}),e.jsx("td",{style:{textAlign:"right",padding:"6px 8px",fontVariantNumeric:"tabular-nums",color:g(l.alpha.t)},children:ze(l.alpha.t,2)})]}),["betaMkt","betaSmb","betaHml"].map(m=>{const y=l[m],b={betaMkt:"β Mkt-RF",betaSmb:"β SMB",betaHml:"β HML"},S={betaMkt:Dr.mkt_rf,betaSmb:Dr.smb,betaHml:Dr.hml};return e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"6px 8px",fontWeight:600,color:S[m]},children:b[m]}),e.jsx("td",{style:{textAlign:"right",padding:"6px 8px",fontVariantNumeric:"tabular-nums"},children:ze(y.estimate,3)}),e.jsx("td",{style:{textAlign:"right",padding:"6px 8px",fontVariantNumeric:"tabular-nums"},children:ze(y.se,3)}),e.jsx("td",{style:{textAlign:"right",padding:"6px 8px",fontVariantNumeric:"tabular-nums",color:g(y.t)},children:ze(y.t,2)})]},m)})]})]})}),e.jsxs("div",{style:{fontSize:11,color:"#767972",marginTop:6,paddingLeft:8,display:"flex",gap:16,flexWrap:"wrap"},children:[e.jsxs("span",{children:["R² ",ze(l.r2,3)]}),e.jsxs("span",{children:["Adj R² ",ze(l.adjR2,3)]}),e.jsxs("span",{children:["Residual Ï ",ze(l.rse,5)]}),e.jsxs("span",{children:["n = ",l.n]}),e.jsxs("span",{children:[l.startDate," â ",l.endDate]}),e.jsx("span",{children:"|t|â¥1.96 = sig (5%), |t|â¥2.58 = sig (1%)"})]})]})]})}const Ol={fontSize:11,fill:C.muted},_r={mkt_rf:"#2f63d6",smb:"#1a8b66",hml:"#a33a3a"},Gt={mkt_rf:"Mkt-RF",smb:"SMB",hml:"HML"},Yl={background:"#fbfaf7",border:`1px solid ${C.cardBorder}`,borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"};function Wa(t){return t==null?"â":`${Number(t)>=0?"+":""}${Number(t).toFixed(2)}%`}function La(t,r=2){return t==null?"â":Number(t).toFixed(r)}function Vl(){const[t,r]=o.useState(null),[a,s]=o.useState(!0),n=o.useRef(null),i=o.useCallback(async()=>{s(!0);try{const p=await(await fetch("/api/markets/daily?chart=ff-factors")).json();p.ok&&r(p.data)}catch(x){console.error("FF Factors fetch error:",x)}finally{s(!1)}},[]);if(o.useEffect(()=>{i()},[i]),a&&!t)return e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:400}})]});if(!t)return e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."});const{stats:l,cumulative:d,recent:c}=t,u=["mkt_rf","smb","hml"];return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{loading:a,exportRef:n,exportFilename:"fama-french-factors"}),e.jsxs("div",{ref:n,children:[e.jsxs("div",{style:{overflowX:"auto",marginBottom:40},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13,fontFamily:"system-ui, -apple-system, sans-serif"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px s
5olid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Factor"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Ann. Return"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Ann. Vol"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Sharpe"})]})}),e.jsxs("tbody",{children:[u.map(x=>{const p=l[`${x}_ann_ret`],h=l[`${x}_ann_vol`],f=l[`${x}_sharpe`];return e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"6px 12px",fontWeight:600,color:_r[x]},children:Gt[x]}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums",color:p>=0?"#1a8b66":"#a33a3a"},children:Wa(p)}),e.jsxs("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums"},children:[La(h),"%"]}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums"},children:La(f)})]},x)}),e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"6px 12px",fontWeight:600,color:"#6d716e"},children:"RF"}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums"},children:Wa(l.rf_ann_ret)}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",color:"#767972"},children:"â"}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",color:"#767972"},children:"â"})]})]})]}),e.jsxs("div",{style:{fontSize:11,color:"#767972",marginTop:4,paddingLeft:12},children:["ETF proxies: Mkt-RF = SPY â Rf · SMB = IWM â IWB · HML = IWD â IWF  | ",l.n_days," trading days (",l.start_date?.slice(0,10)," to ",l.end_date?.slice(0,10),")"]})]}),e.jsxs("div",{style:{marginBottom:40},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#28313f",marginBottom:8},children:"Cumulative Growth of $100"}),e.jsx(q,{width:"100%",height:320,children:e.jsxs(_e,{data:d,margin:{top:8,right:12,left:0,bottom:40},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"date",...ne,interval:Math.floor(d.length/10)}),e.jsx(X,{tick:Ol,tickLine:!1,axisLine:!1,width:60,scale:"log",domain:["auto","auto"],tickFormatter:x=>x>=1e3?`$${(x/1e3).toFixed(0)}k`:`$${x}`}),e.jsx(Z,{contentStyle:Yl,formatter:(x,p)=>[`$${x.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0})}`,Gt[p]??p]}),e.jsx(ve,{verticalAlign:"top",height:28,formatter:x=>Gt[x]??x,wrapperStyle:{fontSize:12,color:"#28313f"}}),u.map(x=>e.jsx(ie,{type:"monotone",dataKey:x,stroke:_r[x],strokeWidth:x==="mkt_rf"?2:1.5,dot:!1,activeDot:{r:3,strokeWidth:0}},x))]})})]}),e.jsxs("div",{style:{marginTop:16},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#28313f",marginBottom:8},children:"Recent Daily Returns (%)"}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12,fontFamily:"system-ui, -apple-system, sans-serif"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px solid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"6px 8px",fontWeight:600,color:"#28313f"},children:"Date"}),u.map(x=>e.jsx("th",{style:{textAlign:"right",padding:"6px 8px",fontWeight:600,color:_r[x]},children:Gt[x]},x)),e.jsx("th",{style:{textAlign:"right",padding:"6px 8px",fontWeight:600,color:"#6d716e"},children:"RF"})]})}),e.jsx("tbody",{children:c.map(x=>e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"4px 8px",color:"#6d716e",fontVariantNumeric:"tabular-nums"},children:x.date}),u.map(p=>{const h=x[p];return e.jsxs("td",{style:{textAlign:"right",padding:"4px 8px",fontVariantNumeric:"tabular-nums",color:h>=0?"#1a8b66":"#a33a3a"},children:[h>=0?"+":"",h.toFixed(2)]},p)}),e.jsx("td",{style:{textAlign:"right",padding:"4px 8px",fontVariantNumeric:"tabular-nums",color:"#6d716e"},children:Number(x.rf).toFixed(2)})]},x.date))})]})})]})]}),e.jsx(vn,{})]})}function Kl(t){return t==null?"â":`${Number(t)>=0?"+":""}${Number(t).toFixed(2)}%`}function Ea(t,r=2){return t==null?"â":Number(t).toFixed(r)}const Ul=["Summary Stats","Historical Data"],Hl=[{key:"daily",label:"Daily"},{key:"weekly",label:"Weekly"},{key:"monthly",label:"Monthly"}],ql=[{key:"3",label:"3 Factor"},{key:"5",label:"5 Factor"}];function kn({active:t,onClick:r,children:a}){return e.jsx("button",{onClick:r,style:{padding:"6px 16px",fontSize:13,fontWeight:t?600:400,color:t?"#fbfaf7":"#28313f",background:t?"#2f63d6":"#ece8df",border:"none",borderRadius:9999,cursor:"pointer",transition:"all 0.15s"},children:a})}function za({data:t}){return e.jsxs("div",{style:{flex:1,minWidth:280},children:[e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"#111722"},children:t.label}),e.jsx("div",{style:{fontSize:11,color:"#767972"},children:t.subtitle})]}),e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13,fontFamily:"system-ui, -apple-system, sans-serif"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px s
5olid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 10px",fontWeight:600,color:"#28313f"},children:"Factor"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 10px",fontWeight:600,color:"#28313f"},children:"Ann. Return"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 10px",fontWeight:600,color:"#28313f"},children:"Ann. Vol"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 10px",fontWeight:600,color:"#28313f"},children:"Sharpe"})]})}),e.jsx("tbody",{children:t.factors.map(r=>e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"6px 10px",fontWeight:600,color:"#28313f"},children:r.factor}),e.jsx("td",{style:{textAlign:"right",padding:"6px 10px",fontVariantNumeric:"tabular-nums",color:r.ann_ret>=0?"#1a8b66":"#a33a3a"},children:Kl(r.ann_ret)}),e.jsx("td",{style:{textAlign:"right",padding:"6px 10px",fontVariantNumeric:"tabular-nums"},children:r.ann_vol!=null?`${Ea(r.ann_vol)}%`:"â"}),e.jsx("td",{style:{textAlign:"right",padding:"6px 10px",fontVariantNumeric:"tabular-nums"},children:Ea(r.sharpe)})]},r.factor))})]})]})}function Xl({freq:t}){const[r,a]=o.useState("3"),[s,n]=o.useState(1),[i,l]=o.useState(!1),[d,c]=o.useState(null),u=o.useRef({}),x=o.useCallback(async(f,g,m)=>{const y=`${f}_${g}_${m}`;if(u.current[y]){c(u.current[y]);return}l(!0);try{const S=await(await fetch(`/api/markets/daily?chart=ff-benchmark&view=history&source=${f}&freq=${g}&page=${m}`)).json();S.ok&&(u.current[y]=S.data,c(S.data))}catch(b){console.error("FF Benchmark history fetch error:",b)}finally{l(!1)}},[]);o.useEffect(()=>{x(r,t,s)},[r,t,s,x]),o.useEffect(()=>{n(1)},[t]);const p=f=>{a(f),n(1)},h=d?Math.ceil(d.total_months/d.per_page):1;return e.jsxs("div",{children:[e.jsx("div",{style:{display:"flex",gap:8,marginBottom:16,flexWrap:"wrap"},children:ql.map(f=>e.jsx(kn,{active:r===f.key,onClick:()=>p(f.key),children:f.label},f.key))}),i&&!d&&e.jsx("div",{className:"markets-skeleton",style:{height:300}}),d&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"#111722",marginBottom:4},children:d.label}),e.jsxs("div",{style:{fontSize:11,color:"#767972",marginBottom:12},children:[d.total_months.toLocaleString()," ",d.period_unit," total · values in %"]}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13,fontFamily:"system-ui, -apple-system, sans-serif",opacity:i?.5:1,transition:"opacity 0.15s"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"2px solid #c9c5bb"},children:d.columns.map(f=>e.jsx("th",{style:{textAlign:f==="Date"?"left":"right",padding:"8px 10px",fontWeight:600,color:"#28313f",whiteSpace:"nowrap"},children:f},f))})}),e.jsx("tbody",{children:d.rows.map((f,g)=>e.jsx("tr",{style:{borderBottom:"1px solid #ece8df"},children:d.columns.map(m=>{const y=m==="Date"?"date":m.toLowerCase().replace("-","_"),b=f[y];if(m==="Date")return e.jsx("td",{style:{padding:"6px 10px",fontWeight:600,color:"#28313f"},children:b},m);const S=typeof b=="number"?b:null;return e.jsx("td",{style:{textAlign:"right",padding:"6px 10px",fontVariantNumeric:"tabular-nums",color:S!=null?S>=0?"#1a8b66":"#a33a3a":"#6d716e"},children:S!=null?`${S>=0?"+":""}${S.toFixed(4)}%`:"â"},m)})},g))})]})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,marginTop:16,fontSize:13},children:[e.jsx("button",{disabled:s<=1,onClick:()=>n(s-1),style:{padding:"6px 14px",border:"1px solid #c9c5bb",borderRadius:6,background:s<=1?"#f6f3ec":"#fbfaf7",color:s<=1?"#c9c5bb":"#28313f",cursor:s<=1?"default":"pointer",fontSize:13},children:"Prev"}),e.jsxs("span",{style:{color:"#6d716e"},children:["Page ",s," of ",h]}),e.jsx("button",{disabled:s>=h,onClick:()=>n(s+1),style:{padding:"6px 14px",border:"1px solid #c9c5bb",borderRadius:6,background:s>=h?"#f6f3ec":"#fbfaf7",color:s>=h?"#c9c5bb":"#28313f",cursor:s>=h?"default":"pointer",fontSize:13},children:"Next"})]})]})]})}function Gl(){const[t,r]=o.useState("Summary Stats"),[a,s]=o.useState("daily"),[n,i]=o.useState(null),[l,d]=o.useState(!0),c=o.useRef(null),u=o.useCallback(async x=>{d(!0);try{const h=await(await fetch(`/api/markets/daily?chart=ff-benchmark&freq=${x}`)).json();h.ok&&i(h.data)}catch(p){console.error("FF Benchmark fetch error:",p)}finally{d(!1)}},[]);return o.useEffect(()=>{u(a)},[a,u]),l&&!n?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:400}})]}
5):n?e.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:24},children:[e.jsx(L,{view:t,viewOptions:Ul.map(x=>({value:x,label:x})),onView:x=>r(x),loading:l,exportRef:c,exportFilename:"fama-french-factors"}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:Hl.map(x=>e.jsx(kn,{active:a===x.key,onClick:()=>s(x.key),children:x.label},x.key))}),e.jsxs("div",{ref:c,style:{display:"flex",flexDirection:"column",gap:24},children:[t==="Summary Stats"&&e.jsxs("div",{style:{display:"flex",gap:24,flexWrap:"wrap"},children:[e.jsx(za,{data:n.factors3}),e.jsx(za,{data:n.factors5})]}),t==="Historical Data"&&e.jsx(Xl,{freq:a}),e.jsx(Ql,{})]})]}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."})}function Ql(){const t={fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"#28313f"};return e.jsxs("div",{style:{marginTop:8,paddingTop:16,borderTop:"1px solid #c9c5bb",fontSize:12,color:"#6d716e",lineHeight:1.6},children:[e.jsx("div",{style:{fontWeight:700,color:"#28313f",marginBottom:6},children:"Methodology"}),e.jsx("div",{style:{marginBottom:6},children:"Akyla-computed Fama-French factors, built from daily total returns (dividend- & split-adjusted), in percent. Weekly and monthly views geometrically compound the daily factors."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,marginBottom:8},children:[e.jsxs("span",{children:[e.jsx("span",{style:t,children:"Mkt-RF = SPY â RF"}),"  â market over the risk-free rate"]}),e.jsxs("span",{children:[e.jsx("span",{style:t,children:"SMB = IWM â SPY"}),"  â small-cap (Russell 2000) minus large-cap (S&P 500)"]}),e.jsxs("span",{children:[e.jsx("span",{style:t,children:"HML = IWD â IWF"}),"  â value minus growth (Russell 1000 Value vs Growth)"]}),e.jsxs("span",{children:[e.jsx("span",{style:t,children:"RMW = QUAL â SPY"}),"  â quality (profitability) minus market"]}),e.jsxs("span",{children:[e.jsx("span",{style:t,children:"CMA = COWZ â SPY"}),"  â cash-cows (conservative investment) minus market"]}),e.jsxs("span",{children:[e.jsx("span",{style:t,children:"RF = FRED 1-month Treasury (DGS1MO) ÷ 252"}),"  â annualized yield â daily rate, carried forward when not yet published"]})]}),e.jsxs("div",{children:["These are liquid-ETF ",e.jsx("em",{children:"proxies"})," for the Fama-French factors, not replications. The 5-factor series (RMW, CMA) begin once their ETFs list (QUAL 2013, COWZ 2016), so they carry less history than the 3-factor series."]})]})}const Ir={fontSize:11,fill:C.muted},Jl={mkt_rf:"#2f63d6",smb:"#1a8b66",hml:"#a33a3a"},Qt={mkt_rf:"Mkt-RF",smb:"SMB",hml:"HML"},Zl={n10:"Top 10",n20:"Top 20",n30:"Top 30",n50:"Top 50",n100:"Top 100",n0:"SPY",spy:"SPY"},Or={background:"#fbfaf7",border:`1px solid ${C.cardBorder}`,borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},ec=["Factor Returns","Attribution","Factor Regression"],At=[{key:"market",label:"Market",color:"#2f63d6"},{key:"size",label:"Size (SMB)",color:"#1a8b66"},{key:"value",label:"Value (HML)",color:"#a33a3a"},{key:"momentum",label:"Momentum (UMD)",color:"#9333ea"},{key:"idio",label:"Idiosyncratic",color:"#6d716e"}],tc=["SPY","QQQ","IWM"];function ft(t){return t==null?"â":`${Number(t)>=0?"+":""}${Number(t).toFixed(2)}%`}function He(t,r=2){return t==null?"â":Number(t).toFixed(r)}const rc=["daily","weekly","monthly"],ac={Date:"date","Mkt-RF":"mkt_rf",SMB:"smb",HML:"hml",RMW:"rmw",CMA:"cma",RF:"rf"};function nc(){const[t,r]=o.useState("daily"),[a,s]=o.useState("5"),[n,i]=o.useState(1),[l,d]=o.useState(null),[c,u]=o.useState(null);o.useEffect(()=>i(1),[t,a]),o.useEffect(()=>{let h=!1;return fetch(`/api/markets/daily?chart=ff-benchmark&freq=${t}`).then(f=>f.json()).then(f=>!h&&f.ok&&d(f.data)).catch(()=>{}),()=>{h=!0}},[t]),o.useEffect(()=>{let h=!1;return fetch(`/api/markets/daily?chart=ff-benchmark&view=history&freq=${t}&source=${a}&page=${n}`).then(f=>f.json()).then(f=>!h&&f.ok&&u(f.data)).catch(()=>{}),()=>{h=!0}},[t,a,n]);const x=l?.factors5.factors??[],p=c?Math.max(1,Math.ceil(c.total_months/c.per_page)):1;return e.jsxs("div",{style:{marginTop:40},children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-[13px] font-semibold text-gray-700",children:"Fama-French 5-Factor (annualized)"}),rc.map(h=>e.jsx("button",{onClick:()=>r(h),className:`rounded-md border px-2.5 py-0.5 text-xs capitalize ${t===h?"border-gray-800 bg-gray-800 text-white":"border-gray-300 bg-white text-gray-600 hover:bg-gray-50"}`,children:h},h)),l&&e.jsx("span",{className:"text-[11px] text-gray-400",children:l.factors5.subtitle})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b-2 border-gray-200",children:[e.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700",children:"Factor"}),e.jsx("th",{className:"px-3 py-2 text-right font-semibold text-gray-700",children:"Ann. Return"}),e.jsx("th",{className:"px-3 py-2 text-right font-semibold text-gray-700",children:"Ann. Vol"}),e.jsx("th",{className:"px-3 py-2 text-right font-semibold text-gray-700",children:"Sharpe"})]})}),e.jsx("tbody",{children:x.map(h=>e.jsxs("tr",{className:"border-b border-gray-100",children:[e.jsx("td",{className:"px-3 py-1.5 font-semibold text-gray-700",children:h.factor}),e.jsx("td",{className:`px-3 py-1.5 text-right tabular-nums ${h.ann_ret>=0?"text-green-600":"text-red-600"}`,children:ft(h.ann_ret)}),e.jsx("td",{className:"px-3 py-1.5 text-right tabular-nums",children:h.ann_vol==null?"â":`${He(h.ann_vol)}%`}),e.jsx("td",{className:"px-3 py-1.5 text-right tabular-nums",children:h.sharpe==null?"â":He(h.sharpe)})]},h.factor))})]})}),c&&c.rows.length>0&&e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-[13px] font-semibold text-gray-700",children:"Factor Returns History (%)"}),["3","5"].map(h=>e.jsxs("button",{onClick:()=>s(h),className:`rounded-md border px-2.5 py-0.5 text-xs ${a===h?"border-gray-800 bg-gray-800 text-white":"border-gray-300 bg-white text-gray-600 hover:bg-gray-50"}`,children:[h,"-Factor"]},h))]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse text-xs",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b-2 border-gray-200",children:c.columns.map((h,f)=>e.jsx("th",{className:`px-3 py-2 font-semibold text-gray-700 ${f===0?"text-left":"text-right"}`,children:h},h))})}),e.jsx("tbody",{children:c.rows.map(h=>e.jsx("tr",{className:"border-b border-gray-100",children:c.columns.map((f,g)=>{const m=ac[f]??f.toLowerCase(),y=h[m];if(g===0)return e.jsx("td",{className:"px-3 py-1 tabular-nums text-gray-500",children:y},f);const b=typeof y=="number"?y:Number(y);return e.jsx("td",{className:`px-3 py-1 text-right tabular-nums ${f==="RF"?"text-gray-500":b>=0?"text-green-600":"text-red-600"}`,children:y==null||Number.isNaN(b)?"â":`${b>=0&&f!=="RF"?"+":""}${b.toFixed(3)}`},f)})},h.date))})]})}),e.jsxs("div",{className:"mt-2 flex items-center gap-3 text-[11px] text-gray-500",children:[e.jsx("button",{onClick:()=>i(h=>Math.max(1,h-1)),disabled:n<=1,className:"rounded border border-gray-300 px-2 py-0.5 disabled:opacity-40",children:"â Prev"}),e.jsxs("span",{children:["Page ",n," / ",p," · ",c.total_months.toLocaleStr
5ing()," ",c.period_unit]}),e.jsx("button",{onClick:()=>i(h=>Math.min(p,h+1)),disabled:n>=p,className:"rounded border border-gray-300 px-2 py-0.5 disabled:opacity-40",children:"Next â"})]})]})]})}function sc({label:t,children:r}){const[a,s]=o.useState(!1),n=o.useRef(null);return o.useEffect(()=>{if(!a)return;const i=l=>{n.current&&!n.current.contains(l.target)&&s(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[a]),e.jsxs("span",{ref:n,style:{position:"relative",display:"inline-flex",verticalAlign:"middle"},children:[e.jsx("button",{type:"button","aria-label":t,"aria-expanded":a,onClick:()=>s(i=>!i),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:15,height:15,borderRadius:"50%",border:"1px solid #cbd5e1",background:a?"#2f63d6":"#fbfaf7",color:a?"#fbfaf7":"#6d716e",fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer",padding:0,fontStyle:"italic",fontFamily:"Georgia, serif"},children:"i"}),a&&e.jsx("div",{role:"dialog",style:{position:"absolute",zIndex:30,top:22,left:-8,width:340,maxWidth:"80vw",background:"#fbfaf7",border:"1px solid #c9c5bb",borderRadius:10,boxShadow:"0 10px 30px rgba(0,0,0,0.12)",padding:"14px 16px",fontSize:12,lineHeight:1.55,color:"#28313f",textAlign:"left",fontWeight:400,whiteSpace:"normal"},children:r})]})}function oc(){const t=(r,a)=>e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:4},children:[e.jsx("span",{style:{minWidth:52,fontWeight:700,color:"#111722"},children:r}),e.jsx("span",{children:a})]});return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:700,color:"#111722",marginBottom:8},children:"How these factors are built"}),e.jsx("div",{style:{marginBottom:10},children:"Fama-French factors are approximated from four liquid ETFs, so they track the academic series while staying investable and daily-fresh:"}),t("Mkt-RF",e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"SPY"})," (S&P 500) total return â risk-free rate"]})),t("SMB",e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"IWM"})," (Russell 2000, small-cap) â ",e.jsx("b",{children:"SPY"})," (large-cap)"]})),t("HML",e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"IWD"})," (Russell 1000 Value) â ",e.jsx("b",{children:"IWF"})," (Russell 1000 Growth)"]})),t("Rf",e.jsx(e.Fragment,{children:"Ken French daily risk-free (1-month T-bill)"})),e.jsx("div",{style:{borderTop:"1px solid #ece8df",margin:"10px 0 8px"}}),e.jsx("div",{style:{fontWeight:700,color:"#111722",marginBottom:6},children:"Cumulative Growth of $100"}),e.jsxs("div",{children:["Each factor compounds $100 forward by its daily return â"," ","V",e.jsx("sub",{children:"t"})," = 100 · â(1 + r",e.jsx("sub",{children:"t"}),") â so the line is the payoff of a $100 bet on that factor. Drawn on a ",e.jsx("b",{children:"log scale"})," (equal % moves look equal) and downsampled to ~monthly points. RMW/CMA (the 5-factor additions) appear in the table below."]})]})}function ic({data:t}){const{stats:r,cumulative:a,recent:s}=t,n=["mkt_rf","smb","hml"];return e.jsxs("div",{style:{width:"100%"},children:[e.jsxs("div",{style:{overflowX:"auto",marginBottom:40},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13,fontFamily:"system-ui, -apple-system, sans-serif"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px solid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Factor"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Ann. Return"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Ann. Vol"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Sharpe"})]})}),e.jsxs("tbody",{children:[n.map(i=>{const l=r[`${i}_ann_ret`],d=r[`${i}_ann_vol`],c=r[`${i}_sharpe`];return e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"6px 12px",fontWeight:600,color:"#28313f"},children:Qt[i]}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums",color:l>=0?"#1a8b66":"#a33a3a"},children:ft(l)}),e.jsxs("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums"},children:[He(d),"%"]}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums"},children:He(c)})]},i)}),e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"6px 12px",fontWeight:600,color:"#6d716e"},children:"RF"}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums"},children:ft(r.rf_ann_ret)}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",color:"#767972"},children:"â"}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",color:"#767972"},children:"â"})]})]})]}),e.jsxs("div",{style:{fontSize:11,color:"#767972",marginTop:4,paddingLeft:12},children:["ETF proxies: Mkt-RF = SPY â Rf · SMB = IWM â SPY · HML = IWD â IWF  | ",r.n_days," trading days (",r.start_date?.slice(0,10)," to ",r.end_date?.slice(0,10),")"]})]}),e.jsxs("div",{style:{marginBottom:40},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"#28313f"},children:"Cumulative Growth of $100"}),e.jsx(sc,{label:"Cumulative Growth methodology",children:e.jsx(oc,{})})]}),e.jsx(q,{width:"100%",height:320,children:e.jsxs(_e,{data:a,margin:{top:8,right:12,left:0,bottom:40},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"date",...ne,interval:Math.floor(a.length/10)}
5),e.jsx(X,{tick:Ir,tickLine:!1,axisLine:!1,width:60,scale:"log",domain:["auto","auto"],tickFormatter:i=>i>=1e3?`$${(i/1e3).toFixed(0)}k`:`$${i}`}),e.jsx(Z,{contentStyle:Or,formatter:(i,l)=>[`$${i.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0})}`,Qt[l]??l]}),e.jsx(ve,{verticalAlign:"top",height:28,formatter:i=>Qt[i]??i,wrapperStyle:{fontSize:12,color:"#28313f"}}),n.map(i=>e.jsx(ie,{type:"monotone",dataKey:i,stroke:Jl[i],strokeWidth:i==="mkt_rf"?2:1.5,dot:!1,activeDot:{r:3,strokeWidth:0}},i))]})})]}),e.jsxs("div",{style:{marginTop:16},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#28313f",marginBottom:8},children:"Recent Daily Returns (%)"}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12,fontFamily:"system-ui, -apple-system, sans-serif"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px solid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"6px 8px",fontWeight:600,color:"#28313f"},children:"Date"}),n.map(i=>e.jsx("th",{style:{textAlign:"right",padding:"6px 8px",fontWeight:600,color:"#28313f"},children:Qt[i]},i)),e.jsx("th",{style:{textAlign:"right",padding:"6px 8px",fontWeight:600,color:"#6d716e"},children:"RF"})]})}),e.jsx("tbody",{children:s.map(i=>e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"4px 8px",color:"#6d716e",fontVariantNumeric:"tabular-nums"},children:i.date}),n.map(l=>{const d=i[l];return e.jsxs("td",{style:{textAlign:"right",padding:"4px 8px",fontVariantNumeric:"tabular-nums",color:d>=0?"#1a8b66":"#a33a3a"},children:[d>=0?"+":"",d.toFixed(2)]},l)}),e.jsx("td",{style:{textAlign:"right",padding:"4px 8px",fontVariantNumeric:"tabular-nums",color:"#6d716e"},children:Number(i.rf).toFixed(2)})]},i.date))})]})})]}),e.jsx(nc,{}),e.jsx(vn,{})]})}function lc({data:t}){const r=a=>Math.abs(a)>=1.96;return e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:{overflowX:"auto",marginBottom:16},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13,fontFamily:"system-ui, -apple-system, sans-serif"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px solid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Portfolio"}),e.jsxs("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:["α"," (ann.%)"]}),e.jsxs("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:["β"," Mkt-RF"]}),e.jsxs("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:["β"," SMB"]}),e.jsxs("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:["β"," HML"]}),e.jsxs("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:["R","²"]}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Obs"})]})}),e.jsx("tbody",{children:t.map(a=>e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"6px 12px",fontWeight:600,color:"#28313f"},children:Zl[`n${a.n_stocks}`]??`Top ${a.n_stocks}`}),e.jsxs("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums",color:a.alpha_annual>=0?"#1a8b66":"#a33a3a",fontWeight:r(a.t_alpha)?700:400},children:[a.alpha_annual>=0?"+":"",a.alpha_annual.toFixed(2)]}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums",fontWeight:r(a.t_mkt)?700:400},children:a.beta_mkt.toFixed(4)}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums",fontWeight:r(a.t_smb)?700:400},children:a.beta_smb.toFixed(4)}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums",fontWeight:r(a.t_hml)?700:400},children:a.beta_hml.toFixed(4)}),e.jsxs("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums"},children:[(a.r_squared*100).toFixed(1),"%"]}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums",color:"#6d716e"},children:a.n_obs})]},a.n_stocks))})]})}),e.jsxs("div",{style:{fontSize:11,color:"#767972",marginTop:6,paddingLeft:12},children:["Bold = statistically significant at 5% (|t| ","â¥"," 1.96) · Model: R",e.jsx("sub",{children:"p"})," - R",e.jsx("sub",{children:"f"})," = ","α"," + ","β",e.jsx("sub",{children:"1"}),"Mkt-RF + ","β",e.jsx("sub",{children:"2"}),"SMB + ","β",e.jsx("sub",{children:"3"}),"HML + ","ε"]})]})}function cc(){const[t,r]=o.useState("SPY"),[a,s]=o.useState("SPY"),[n,i]=o.useState(252),[l,d]=o.use
5State(null),[c,u]=o.useState(null),[x,p]=o.useState(!0);o.useEffect(()=>{let m=!1;return p(!0),u(null),fetch(`/api/markets/daily?chart=factor-attribution&ticker=${encodeURIComponent(t)}&window=${n}`).then(y=>y.json()).then(y=>{m||(y.ok&&y.data&&!y.data.error?d(y.data):u(y.data?.error??"Failed to load attribution."))}).catch(()=>!m&&u("Failed to load attribution.")).finally(()=>!m&&p(!1)),()=>{m=!0}},[t,n]);const h=()=>{const m=a.trim().toUpperCase();m&&m!==t&&r(m)},f=l?.latest,g=f?[...At.map(m=>({name:m.label,value:f[m.key],color:m.color})),{name:"Total",value:f.total,color:"#111722"}]:[];return e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[tc.map(m=>e.jsx("button",{onClick:()=>{s(m),r(m)},className:`rounded-md border px-2.5 py-1 text-xs font-semibold ${t===m?"border-blue-600 bg-blue-600 text-white":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,children:m},m)),e.jsx("input",{value:a,onChange:m=>s(m.target.value.toUpperCase()),onKeyDown:m=>m.key==="Enter"&&h(),onBlur:h,placeholder:"Ticker",className:"w-24 rounded-md border border-gray-300 px-2 py-1 text-xs font-semibold uppercase text-gray-800 focus:border-blue-500 focus:outline-none"}),e.jsx("span",{className:"ml-2 text-xs text-gray-400",children:"Beta window:"}),[126,252,504].map(m=>e.jsxs("button",{onClick:()=>i(m),className:`rounded-md border px-2.5 py-1 text-xs ${n===m?"border-gray-800 bg-gray-800 text-white":"border-gray-300 bg-white text-gray-600 hover:bg-gray-50"}`,children:[m,"d"]},m)),x&&e.jsx("span",{className:"text-xs text-gray-400",children:"Loadingâ¦"})]}),c&&e.jsx("div",{className:"py-10 text-center text-sm text-gray-400",children:c}),l&&f&&!c&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-5 rounded-lg border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsxs("div",{className:"text-sm text-gray-800",children:[e.jsx("span",{className:"font-bold",children:l.ticker})," returned"," ",e.jsx("span",{className:`font-bold ${f.total>=0?"text-green-600":"text-red-600"}`,children:ft(f.total)})," ","on ",f.date]}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-x-4 gap-y-1 text-xs",children:At.map(m=>{const y=f[m.key];return e.jsxs("span",{className:"whitespace-nowrap",children:[e.jsx("span",{className:"mr-1 inline-block h-2 w-2 rounded-full align-middle",style:{backgroundColor:m.color}}),e.jsx("span",{className:"text-gray-500",children:m.label})," ",e.jsx("span",{className:`font-semibold tabular-nums ${y>=0?"text-green-600":"text-red-600"}`,children:ft(y)})]},m.key)})})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"mb-2 text-[13px] font-semibold text-gray-700",children:["Return Decomposition â ",f.date," (pp of daily return)"]}),e.jsx(q,{width:"100%",height:240,children:e.jsxs(Ce,{data:g,margin:{top:8,right:12,left:0,bottom:4},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"name",tick:{fontSize:11,fill:C.muted},tickLine:!1,axisLine:!1}),e.jsx(X,{tick:Ir,tickLine:!1,axisLine:!1,width:48,tickFormatter:m=>`${m.toFixed(2)}%`}),e.jsx(Z,{contentStyle:Or,formatter:m=>[`${m>=0?"+":""}${m.toFixed(3)}%`,"Contribution"]}),e.jsx(le,{y:0,stroke:"#767972"}),e.jsx(ye,{dataKey:"value",radius:[3,3,0,0],children:g.map(m=>e.jsx(De,{fill:m.color},m.name))})]})})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"mb-2 text-[13px] font-semibold text-gray-700",children:["Daily Factor Contributions â last ",l.days," sessions"]}),e.jsx(q,{width:"100%",height:300,children:e.jsxs(Wt,{data:l.history,margin:{top:8,right:12,left:0,bottom:40},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"date",...ne,interval:Math.floor(l.history.length/8)}),e.jsx(X,{tick:Ir,tickLine:!1,axisLine:!1,width:48,tickFormatter:m=>`${m.toFixed(1)}%`}),e.jsx(Z,{contentStyle:Or,formatter:(m,y)=>[`${m>=0?"+":""}${m.toFixed(3)}%`,At.find(b=>b.key===y)?.label??(y==="total"?"Total return":y)]}),e.jsx(ve,{verticalAlign:"top",height:28,formatter:m=>At.find(y=>y.key===m)?.label??(m==="total"?"Total return":m),wrapperStyle:{fontSize:12,color:"#28313f"}}),e.jsx(le,{y:0,stroke:"#767972"}),At.map(m=>
5e.jsx(ye,{dataKey:m.key,stackId:"attr",fill:m.color},m.key)),e.jsx(ie,{type:"monotone",dataKey:"total",stroke:"#111722",strokeWidth:1.5,dot:!1})]})})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse text-xs",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b-2 border-gray-200",children:["β Mkt-RF","β SMB","β HML","β UMD","α (ann. %)","R²","Obs"].map(m=>e.jsx("th",{className:"px-3 py-2 text-right font-semibold text-gray-700 first:text-left",children:m},m))})}),e.jsx("tbody",{children:e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-1.5 text-left tabular-nums",children:He(l.betas.mkt,3)}),e.jsx("td",{className:"px-3 py-1.5 text-right tabular-nums",children:He(l.betas.smb,3)}),e.jsx("td",{className:"px-3 py-1.5 text-right tabular-nums",children:He(l.betas.hml,3)}),e.jsx("td",{className:"px-3 py-1.5 text-right tabular-nums",children:He(l.betas.umd,3)}),e.jsx("td",{className:`px-3 py-1.5 text-right tabular-nums ${l.betas.alphaAnnPct>=0?"text-green-600":"text-red-600"}`,children:ft(l.betas.alphaAnnPct)}),e.jsxs("td",{className:"px-3 py-1.5 text-right tabular-nums",children:[(l.betas.r2*100).toFixed(1),"%"]}),e.jsx("td",{className:"px-3 py-1.5 text-right tabular-nums text-gray-500",children:l.betas.n})]})})]})}),e.jsxs("div",{className:"mt-3 pl-1 text-[11px] leading-relaxed text-gray-400",children:["Betas from a rolling ",l.window,"-day regression on Akyla ETF-proxy factors (Mkt-RF, SMB, HML, UMD), fit strictly before each attributed day. Contribution = β à factor return that day; idiosyncratic is the unexplained residual (incl. the day's α and risk-free carry). Contributions are signed and sum to the total return â on mixed days individual factors can exceed the total."]})]})]})}function dc(){const[t,r]=o.useState("Factor Returns"),a=o.useRef(null),[s,n]=o.useState(null),[i,l]=o.useState(null),[d,c]=o.useState(null),[u,x]=o.useState(!0),p=o.useCallback(async()=>{x(!0);try{const[h,f,g]=await Promise.all([fetch("/api/markets/daily?chart=ff-factors"),fetch("/api/markets/daily?chart=gmv-portfolios"),fetch("/api/markets/daily?chart=gmv-regression")]),[m,y,b]=await Promise.all([h.json(),f.json(),g.json()]);m.ok&&n(m.data),y.ok&&l(y.data),b.ok&&c(b.data)}catch(h){console.error("Equity Factors fetch error:",h)}finally{x(!1)}},[]);return o.useEffect(()=>{p()},[p]),u&&!s&&!i?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:400}})]}):e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{view:t,viewOptions:ec.map(h=>({value:h,label:h})),onView:h=>r(h),loading:u,exportRef:a,exportFilename:"equity-factors"}),e.jsxs("div",{ref:a,children:[t==="Factor Returns"&&s&&e.jsx(ic,{data:s}),t==="Factor Returns"&&!s&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No factor data available."}),t==="Attribution"&&e.jsx(cc,{}),t==="Factor Regression"&&d&&e.jsx(lc,{data:d}),t==="Factor Regression"&&!d&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No regression data available."})]})]})}const hc={fontSize:11,fill:C.muted},Mt={EUR:"#2f63d6",GBP:"#a33a3a",JPY:"#1a8b66",CHF:"#9333ea",AUD:"#ea580c",CAD:"#0891b2",NZD:"#65a30d",SEK:"#be185d"},xc={background:"#fbfaf7",border:`1px solid ${C.cardBorder}`,borderRadius:8,fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"};function Pa(t){return t==null?"â":`${Number(t)>=0?"+":""}${Number(t).toFixed(2)}%`}function Ba(t,r=2){return t==null?"â":Number(t).toFixed(r)}const uc=[{value:"all",label:"All Panels"},{value:"growth",label:"Growth Chart"},{value:"stats",label:"Statistics"},{value:"recent",label:"Recent Returns"}],Ia=[{value:"1M",label:"1 Month"},{value:"3M",label:"3 Months"},{value:"6M",label:"6 Months"},{value:"1Y",label:"1 Year"},{value:"ALL",label:"All Time"}],pc={"1M":22,"3M":66,"6M":132,"1Y":252,ALL:null};function fc(){const[t,r]=o.useState(null),[a,s]=o.useState(!0),[n,i]=o.useState("all"),[l,d]=o.useState("ALL"),[c,u]=o.useState(new Set),x=o.useRef(null),p=o.useCallback(async()=>{s(!0);try{const T=await(await fetch("/api/markets/daily?chart=fx-factors")).json();T.ok&&r(T.data)}catch($){console.error("FX Factors fetch error:",$)}finally{s(!1)}},[]);if(o.useEffect(()=>{p()},[p]),a&&!t)return e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:400}})]});if(!t||!t.stats.length)return e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No data available."});const{stats:h,cumulative:f,recent:g}=t,m=h.map($=>$.currency),y=m.filter($=>!c.has($)),b=h[0],S=$=>{u(T=>{const A=new Set(T);return A.has($)?A.delete($):m.length-A.size>1&&A.add($),A})},k=pc[l],v=k==null?f:f.slice(-k),w={};for(const $ of y){const T=v.find(A=>A[$]!=null);T&&(w[$]=Number(T[$]))}const j=v.map($=>{const T={date:$.date};for(const A of y)$[A]!=null&&w[A]&&(T[A]=Number($[A])/w[A]*100);return T}),R=n==="all"||n==="growth",N=n==="all"||n==="stats",D=n==="all"||n==="recent",M=e.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:m.map($=>{const T=!c.has($);return e.jsx("button",{type:"button",onClick:()=>S($),"aria-pressed":T,title:T?`Hide ${$}`:`Show ${$}`,style:{padding:"3px 8px",borderRadius:6,fontSize:12,fontWeight:600,cursor:"pointer",border:`1px solid ${T?Mt[$]??"#6d716e":"#c9c5bb"}`,background:T?Mt[$]??"#6d716e":"transparent",color:T?"#fbfaf7":"#767972"},children:$},$)})});return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{exportRef:x,exportFilename:"currency-factors",view:n,viewOptions:uc,onView:$=>i($),interval:l,intervalOptions:R?Ia:void 0,onInterval:d,children:M}),e.jsxs("div",{ref:x,children:[N&&e.jsxs("div",{style:{overflowX:"auto",marginBottom:24},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13,fontFamily:"system-ui, -apple-system, sans-serif"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px s
5olid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Currency"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Total Return"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Ann. Return"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Ann. Vol"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",fontWeight:600,color:"#28313f"},children:"Sharpe"})]})}),e.jsx("tbody",{children:h.filter($=>!c.has($.currency)).map($=>e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"6px 12px",fontWeight:600,color:Mt[$.currency]??"#28313f"},children:$.currency}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums",color:$.total_ret>=0?"#1a8b66":"#a33a3a"},children:Pa($.total_ret)}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums",color:$.ann_ret>=0?"#1a8b66":"#a33a3a"},children:Pa($.ann_ret)}),e.jsxs("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums"},children:[Ba($.ann_vol),"%"]}),e.jsx("td",{style:{textAlign:"right",padding:"6px 12px",fontVariantNumeric:"tabular-nums"},children:Ba($.sharpe)})]},$.currency))})]}),e.jsxs("div",{style:{fontSize:11,color:"#767972",marginTop:4,paddingLeft:12},children:[b.n_days," trading days (",b.start_date?.slice(0,10)," to ",b.end_date?.slice(0,10),") | Returns vs USD"]})]}),R&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"#28313f",marginBottom:8},children:["Cumulative Growth of $100",l!=="ALL"?` (last ${Ia.find($=>$.value===l)?.label.toLowerCase()})`:""]}),e.jsx(q,{width:"100%",height:320,children:e.jsxs(_e,{data:j,margin:{top:8,right:12,left:0,bottom:40},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"date",...ne,interval:Math.max(1,Math.floor(j.length/10))}),e.jsx(X,{tick:hc,tickLine:!1,axisLine:!1,width:50,domain:["auto","auto"],tickFormatter:$=>`$${$}`}),e.jsx(Z,{contentStyle:xc,formatter:($,T)=>[`$${$.toFixed(2)}`,T]}),e.jsx(ve,{verticalAlign:"top",height:28,wrapperStyle:{fontSize:12,color:"#28313f"}}),y.map($=>e.jsx(ie,{type:"monotone",dataKey:$,stroke:Mt[$]??"#6d716e",strokeWidth:1.5,dot:!1,activeDot:{r:3,strokeWidth:0}},$))]})})]}),D&&e.jsxs("div",{style:{marginTop:16},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#28313f",marginBottom:8},children:"Recent Daily Returns (%)"}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12,fontFamily:"system-ui, -apple-system, sans-serif"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px solid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"6px 8px",fontWeight:600,color:"#28313f"},children:"Date"}),y.map($=>e.jsx("th",{style:{textAlign:"right",padding:"6px 8px",fontWeight:600,color:Mt[$]??"#28313f"},children:$},$))]})}),e.jsx("tbody",{children:g.map($=>e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"4px 8px",color:"#6d716e",fontVariantNumeric:"tabular-nums"},children:$.date}),y.map(T=>{const A=$[T];return A==null?e.jsx("td",{style:{textAlign:"right",padding:"4px 8px",color:"#767972"},children:"â"},T):e.jsxs("td",{style:{textAlign:"right",padding:"4px 8px",fontVariantNumeric:"tabular-nums",color:A>=0?"#1a8b66":"#a33a3a"},children:[A>=0?"+":"",A.toFixed(3)]},T)})]},$.date))})]})})]})]})]})}const Yr=[{value:"summary",label:"Summary"},{value:"search",label:"Search"}],Vr=[{value:"1w",label:"1W"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"}];function mc(t){return`https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK=${encodeURIComponent(t)}&type=4&dateb=&owner=include&count=40`}function gc(t,r){if(!t||!r)return null;const a=parseInt(String(t),10);if(!Number.isFinite(a))return null;const s=String(r).replace(/-/g,"");return`https://www.sec.gov/Archives/edgar/data/${a}/${s}/${r}-index.htm`}function Ue(t){if(t==null)return"â";const r=Math.abs(t);return r>=1e9?`${t<0?"-":""}$${(r/1e9).toFixed(1)}B`:r>=1e6?`${t<0?"-":""}$${(r/1e6).toFixed(1)}M`:r>=1e3?`${t<0?"-":""}$${(r/1e3).toFixed(0)}K`:`${t<0?"-":""}$${r.toFixed(0)}`}
5function yc(t){return t==null?"â":`$${Number(t).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`}const Fr={padding:"4px 8px",borderRadius:5,border:"1px solid #c9c5bb",fontSize:12,background:"#fbfaf7",color:"#28313f",outline:"none"},bc={fontWeight:600,color:C.accent,textDecoration:"none"},jc={color:"#6d716e",fontSize:12,cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted",background:"none",border:"none",padding:0,textAlign:"left",maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function Sn({ticker:t}){return t?e.jsx("a",{href:mc(t),target:"_blank",rel:"noopener noreferrer",style:bc,title:`View ${t} insider (Form 4) filings on SEC EDGAR`,children:t}):e.jsx("span",{children:"â"})}function vc({mainView:t,onMainView:r,onSelectCompany:a}){const[s,n]=o.useState([]),[i,l]=o.useState(!0),[d,c]=o.useState("1m"),u=o.useRef(null);o.useEffect(()=>{let f=!1;return l(!0),(async()=>{try{const m=await(await fetch(`/api/markets/daily?chart=insider-purchases-summary&interval=${d}`)).json();!f&&m.ok&&n(m.data.topBuyers??[])}catch(g){console.error("Insider summary fetch error:",g)}finally{f||l(!1)}})(),()=>{f=!0}},[d]);const x=s.map(f=>({name:f.issuer_ticker,value:Number(f.total_value),company:f.issuer_name,insiders:f.unique_insiders,txns:f.txn_count})),p=(f,g,m)=>e.jsxs("div",{children:[e.jsx("h3",{style:{fontSize:14,fontWeight:600,color:"#111722",margin:"0 0 8px"},children:m}),f.length===0?e.jsx("div",{style:{padding:24,textAlign:"center",color:"#767972",fontSize:13},children:"No data"}):e.jsx(q,{width:"100%",height:300,children:e.jsxs(Ce,{data:f,margin:{top:16,right:12,left:0,bottom:24},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"rgba(0,0,0,0.06)"}),e.jsx(Q,{dataKey:"name",...ne}),e.jsx(X,{tick:{fontSize:11,fill:"#6d716e"},tickLine:!1,axisLine:!1,width:64,tickFormatter:y=>Ue(y)}),e.jsx(Z,{content:({active:y,payload:b})=>{if(!y||!b?.length)return null;const S=b[0].payload;return e.jsxs("div",{style:{background:"#fbfaf7",border:"1px solid #c9c5bb",borderRadius:8,padding:"8px 12px",fontSize:12,boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:2},children:S.name}),e.jsx("div",{style:{color:"#6d716e",marginBottom:4,fontSize:11},children:S.company}),e.jsx("div",{style:{color:g,fontWeight:600},children:Ue(S.value)}),e.jsxs("div",{style:{color:"#6d716e",fontSize:11,marginTop:2},children:[S.insiders," insider",S.insiders!==1?"s":"",", ",S.txns," txn",S.txns!==1?"s":""]})]})}}),e.jsx(ye,{dataKey:"value",radius:[4,4,0,0],children:f.map((y,b)=>e.jsx(De,{fill:g},b))})]})})]}),h=f=>e.jsx("div",{style:{overflowY:"auto",maxHeight:"40vh",marginTop:8},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px solid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",color:"#6d716e",fontWeight:500},children:"Ticker"}),e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",color:"#6d716e",fontWeight:500},children:"Company"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:"#6d716e",fontWeight:500},children:"Total Value"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:"#6d716e",fontWeight:500},children:"Shares"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:"#6d716e",fontWeight:500},children:"Insiders"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:"#6d716e",fontWeight:500},children:"Txns"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:"#6d716e",fontWeight:500},children:"Latest"})]})}),e.jsx("tbody",{children:f.map(g=>e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"6px 12px"},children:e.jsx(Sn,{ticker:g.issuer_ticker})}),e.jsx("td",{style:{padding:"6px 12px"},children:e.jsx("button",{type:"button",onClick:()=>a(g.issuer_ticker),style:jc,title:`View ${g.issuer_ticker} insider purchases`,children:g.issuer_name})}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",fontWeight:600,color:C.positive},children:Ue(Number(g.total_value))}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:"#111722"}
5,children:Number(g.total_shares).toLocaleString()}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:"#111722"},children:g.unique_insiders}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:"#111722"},children:g.txn_count}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:"#6d716e",fontSize:12},children:g.latest_date})]},g.issuer_ticker))})]})});return i&&s.length===0?e.jsxs("div",{children:[e.jsx(L,{view:t,viewOptions:Yr,onView:f=>r(f),interval:d,intervalOptions:Vr,onInterval:c,loading:!0}),e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]}):e.jsxs("div",{children:[e.jsx(L,{view:t,viewOptions:Yr,onView:f=>r(f),interval:d,intervalOptions:Vr,onInterval:c,loading:i,exportRef:u,exportFilename:"insider-purchases-summary"}),e.jsx("p",{style:{fontSize:12,color:"#6d716e",marginBottom:16},children:"Top 10 companies by total open-market insider purchase value (SEC Form 4, code P). Tap a ticker for its SEC filings, or a company to drill into its transactions."}),e.jsxs("div",{ref:u,children:[p(x,C.positive,"Top 10 Insider Buys"),h(s)]})]})}function kc({mainView:t,onMainView:r,initialTicker:a}){const[s,n]=o.useState(null),[i,l]=o.useState(!0),[d,c]=o.useState(a?"1y":"1m"),u=o.useRef(null),[x,p]=o.useState({ticker:a??"",insider:"",minValue:"",largeOnly:!1}),h=o.useRef(null),f=o.useCallback((R,N)=>{const D=new URLSearchParams({chart:"insider-purchases",interval:R});return N.ticker&&D.set("ticker",N.ticker),N.insider&&D.set("insider",N.insider),N.minValue&&D.set("minValue",N.minValue),N.largeOnly&&D.set("largeOnly","true"),`/api/markets/daily?${D.toString()}`},[]),g=o.useCallback(async(R,N)=>{l(!0);try{const M=await(await fetch(f(R,N))).json();M.ok&&n(M.data)}catch(D){console.error("InsiderPurchases fetch error:",D)}finally{l(!1)}},[f]);o.useEffect(()=>{g(d,x)},[g,d]);const m=o.useCallback(R=>{c(R)},[]),y=o.useCallback((R,N)=>{p(D=>{const M={...D,[R]:N};return typeof N=="boolean"?g(d,M):(h.current&&clearTimeout(h.current),h.current=setTimeout(()=>g(d,M),400)),M})},[g,d]),b=o.useCallback(()=>{const R={ticker:"",insider:"",minValue:"",largeOnly:!1};p(R),g(d,R)},[g,d]),S=x.ticker||x.insider||x.minValue||x.largeOnly;if(i&&!s)return e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]});const k=s?.summary??{total_purchases:0,total_purchase_value:0,large_purchases:0,large_purchase_value:0,total_count:0},v=s?.transactions??[],j=v.filter(R=>R.is_large_purchase).slice(0,3);return e.jsxs("div",{children:[e.jsxs(L,{view:t,viewOptions:Yr,onView:R=>r(R),interval:d,intervalOptions:Vr,onInterval:m,loading:i,exportRef:u,exportFilename:"insider-purchases-search",children:[e.jsx("input",{type:"text",placeholder:"Ticker",value:x.ticker,onChange:R=>y("ticker",R.target.value.toUpperCase()),style:{...Fr,width:80}}),e.jsx("input",{type:"text",placeholder:"Insider name",value:x.insider,onChange:R=>y("insider",R.target.value),style:{...Fr,width:140}}),e.jsx("input",{type:"number",placeholder:"Min value ($)",value:x.minValue,onChange:R=>y("minValue",R.target.value),style:{...Fr,width:110}}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"#28313f",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:x.largeOnly,onChange:R=>y("largeOnly",R.target.checked)}),"Large only"]}),S&&e.jsx("button",{onClick:b,style:{padding:"3px 10px",borderRadius:5,border:"1px solid #c9c5bb",background:"#fbfaf7",color:"#6d716e",fontSize:12,cursor:"pointer"},children:"Clear filters"}),e.jsx("span",{style:{fontSize:11,color:"#767972"},children:Number(k.total_count)>v.length?`Showing ${v.length.toLocaleString()} most recent of ${Number(k.total_count).toLocaleString()} â filter by ticker or insider to narrow`:`${v.length.toLocaleString()} purchase${v.length!==1?"s":""}`})]}),e.jsxs("div",{ref:u,children:[Number(k.large_purchases)>0&&e.jsxs("div",{style:{background:"#FEF3C7",border:"1px solid #F59E0B",borderRadius:8,padding:"12px 16px",marginBottom:16},children:[e.jsxs("div",{style:{fontWeight:600,fontSize:14,color:"#92400E",marginBottom:j.length>0?8:0},children:[Number(k.large_purchases)," Notable Insider Purchase",
5Number(k.large_purchases)!==1?"s":""," â ",Ue(Number(k.large_purchase_value))," in high-conviction buying"]}),j.length>0&&e.jsx("ul",{style:{margin:0,paddingLeft:20,fontSize:13,color:"#78350F"},children:j.map((R,N)=>e.jsxs("li",{style:{marginBottom:2},children:[R.issuer_ticker,": ",R.owner_name," bought ",Ue(Number(R.total_value))]},N))})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:16},children:[{label:"Total Purchases",value:Number(k.total_purchases).toLocaleString(),color:C.positive},{label:"Purchase Value",value:Ue(Number(k.total_purchase_value)),color:C.positive},{label:"Large Purchases",value:Number(k.large_purchases).toLocaleString(),color:"#D97706"},{label:"Large Purchase Value",value:Ue(Number(k.large_purchase_value)),color:"#D97706"}].map(R=>e.jsxs("div",{style:{background:C.cardBg,border:`1px solid ${C.cardBorder}`,borderRadius:8,padding:"12px 16px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:12,color:C.muted,marginBottom:4},children:R.label}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:R.color},children:R.value})]},R.label))}),v.length===0?e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No open-market purchases match the current filters"}):e.jsx("div",{style:{overflowY:"auto",maxHeight:"60vh"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px solid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Date"}),e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Ticker"}),e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Insider"}),e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Title"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Shares"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Price"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Value"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Post-Txn Shares"}),e.jsx("th",{style:{textAlign:"center",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Filing"})]})}),e.jsx("tbody",{children:v.map((R,N)=>{const D=R.is_large_purchase,M=gc(R.issuer_cik,R.accession_number);return e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df",borderLeft:D?"3px solid #F59E0B":"3px solid transparent"},children:[e.jsx("td",{style:{padding:"6px 12px",color:C.text},children:R.transaction_date}),e.jsx("td",{style:{padding:"6px 12px"},children:e.jsx(Sn,{ticker:R.issuer_ticker})}),e.jsx("td",{style:{padding:"6px 12px",color:C.text},children:R.owner_name}),e.jsx("td",{style:{padding:"6px 12px",color:C.muted,fontSize:12},children:R.owner_title}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:C.text},children:Number(R.shares).toLocaleString()}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:C.text},children:yc(Number(R.price_per_share))}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",fontWeight:600,color:C.positive},children:Ue(Number(R.total_value))}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:C.text},children:Number(R.shares_owned_after).toLocaleString()}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"center"},children:M?e.jsxs("a",{href:M,target:"_blank",rel:"noopener noreferrer",style:{color:C.accent,textDecoration:"none",fontSize:12},title:"View this Form 4 on SEC EDGAR",children:[D?"â¡ ":"","Form 4 ","â"]}):e.jsx("span",{children:D?"â¡":""})})]},N)})})]})})]})]})}function Sc(){const[t,r]=o.useState("summary"),[a,s]=o.useState(""),n=o.useCallback(l=>{s(l),r("search")},[]),i=o.useCallback(l=>{l!=="search"&&s(""),r(l)},[]);return e.jsx("div",{style:{width:"100%",fontFamily:"system-ui, -apple-system, sans-serif"},children:t==="summary"?e.jsx(vc,{mainView:t,onMainView:i,onSelectCompany:n}):e.jsx(kc,{mainView:t,onMainView:i,initialTicker:a})})}const wc=[{value:"1w",label:"1W"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"}];function Nc(){const[t,r]=o.useState("SPY"),[a,s]=o.useState(null),[n,i]=o.useState("1m"),[l,d]=o.use
5State([]),[c,u]=o.useState(null),[x,p]=o.useState(!1),[h,f]=o.useState(null),g=o.useRef(null),m=o.useRef(null),y=o.useCallback(async(v,w)=>{p(!0),f(null);try{const R=await(await fetch(`/api/markets/daily?chart=eq-correlations&symbol=${encodeURIComponent(v)}&interval=${w}`)).json();if(R.ok){const N=R.data.sort((D,M)=>D.correlation-M.correlation);d(N),u(R.meta??null)}else d([]),u(null),f(R.error??"Failed to fetch correlations")}catch(j){console.error("EquityCorrelations fetch error:",j),d([]),u(null),f("Network error fetching correlations")}finally{p(!1)}},[]);o.useEffect(()=>{s("SPY"),y("SPY",n)},[]),o.useEffect(()=>{a&&y(a,n)},[n,a,y]);const b=()=>{const v=t.trim().toUpperCase();v&&(r(v),s(v))},S=v=>{v.key==="Enter"&&b()},k=l.slice(0,100);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{interval:n,intervalOptions:wc,onInterval:i,loading:x,exportRef:m,exportFilename:"equity-correlations",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:0},children:[e.jsx("input",{ref:g,type:"text",value:t,onChange:v=>r(v.target.value.toUpperCase()),onKeyDown:S,placeholder:"Enter symbol (e.g. AAPL)",style:{padding:"7px 12px",borderRadius:"6px 0 0 6px",border:"1px solid #c9c5bb",borderRight:"none",fontSize:13,fontFamily:"system-ui, -apple-system, sans-serif",outline:"none",width:160}}),e.jsx("button",{onClick:b,style:{padding:"7px 16px",borderRadius:"0 6px 6px 0",border:"1px solid #2f63d6",background:"#2f63d6",color:"#fbfaf7",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s"},children:"Search"})]})}),e.jsx("div",{ref:m,children:a?x&&l.length===0?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:340}})]}):h?e.jsx("div",{style:{padding:40,textAlign:"center",color:"#a33a3a",fontSize:14},children:h}):k.length===0?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:["No results found for ",a,"."]}):e.jsxs("div",{style:{overflowX:"auto"},children:[c&&e.jsxs("div",{style:{fontSize:11,color:"#767972",marginBottom:8},children:["Showing correlations for ",e.jsx("strong",{style:{color:"#28313f"},children:c.symbol})," ","over ",c.interval,c.dataStartDate&&` (data from ${c.dataStartDate})`]}),e.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",maxWidth:640,fontFamily:"system-ui, -apple-system, sans-serif"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{padding:"8px 10px",fontSize:12,fontWeight:600,color:"#28313f",borderBottom:"2px solid #c9c5bb",textAlign:"right",width:36},children:"#"}),e.jsx("th",{style:{padding:"8px 10px",fontSize:12,fontWeight:600,color:"#28313f",borderBottom:"2px solid #c9c5bb",textAlign:"left"},children:"Symbol"}),e.jsx("th",{style:{padding:"8px 10px",fontSize:12,fontWeight:600,color:"#28313f",borderBottom:"2px solid #c9c5bb",textAlign:"right"},children:"Correlation"}),e.jsx("th",{style:{padding:"8px 10px",fontSize:12,fontWeight:600,color:"#28313f",borderBottom:"2px solid #c9c5bb",textAlign:"center",width:140},children:"Visual"}),e.jsx("th",{style:{padding:"8px 10px",fontSize:12,fontWeight:600,color:"#28313f",borderBottom:"2px solid #c9c5bb",textAlign:"right"},children:"Days"})]})}),e.jsx("tbody",{children:k.map((v,w)=>{const j=v.correlation<0,N=Math.min(Math.abs(v.correlation),1)*50;return e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"6px 10px",fontSize:12,color:"#767972",borderBottom:"1px solid #ece8df",textAlign:"right",fontVariantNumeric:"tabular-nums"},children:w+1}),e.jsx("td",{style:{padding:"6px 10px",fontSize:13,fontWeight:600,color:"#111722",borderBottom:"1px solid #ece8df"},children:v.symbol}),e.jsx("td",{style:{padding:"6px 10px",fontSize:13,fontWeight:600,fontVariantNumeric:"tabular-nums",color:j?"#a33a3a":"#3b82f6",borderBottom:"1px solid #ece8df",textAlign:"right"},children:v.correlation.toFixed(3)}),e.jsx("td",{style:{padding:"6px 10px",borderBottom:"1px solid #ece8df"},children:e.jsxs("div",{style:{width:120,height:14,background:"#ece8df",borderRadius:2,position:"relative",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",top:0,height:"100%",borderRadius:1,background:j?"#a33a3a":"#3b82f6",...j?{right:"50%",width:`${N}%`}:{left:"50%",width:`${N}%`}}}),e.jsx("div",{style:{position:"absolute",left:"50%",top:0,width:1,height:"100%",background:"#c9c5bb"}})]})}),e.jsx("td",{style:{padding:"6px 10px",fontSize:12,color:"#767972",borderBottom:"1px solid #ece8df",textAlign:"right",fontVariantNumeric:"tabular-nums"},children:v.n_days})]},v.symbol)})})]}),l.length>100&&e.jsxs("div",{style:{fontSize:11,color:"#767972",marginTop:8},children:["Showing top 100 of ",l.length," results"]})]}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"Enter a symbol to see correlations"})})]})}const Rc=[{value:"1w",label:"1W"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"}];function Ac({interval:t,controlled:r=!1}={}){const[a,s]=o.useState(""),[n,i]=o.useState("3m"),l=r?t??"3m":n,[d,c]=o.useState([]),[u,x]=o.use
5State(!0),p=o.useRef(null),h=o.useCallback(async g=>{x(!0);try{const y=await(await fetch(`/api/markets/daily?chart=fx-pair-correlations&interval=${g}`)).json();if(y.ok){const b=[...y.data].sort((S,k)=>S.correlation-k.correlation);c(b)}}catch(m){console.error("FxPairCorrelations fetch error:",m)}finally{x(!1)}},[]);o.useEffect(()=>{h(l)},[l,h]);const f=o.useMemo(()=>{if(!a.trim())return d;const g=a.trim().toUpperCase();return d.filter(m=>m.pair1.toUpperCase().includes(g)||m.pair2.toUpperCase().includes(g))},[d,a]);return e.jsxs("div",{style:{width:"100%"},children:[r?e.jsx("div",{style:{marginBottom:12},children:e.jsx("input",{type:"text",value:a,onChange:g=>s(g.target.value),placeholder:"Filter pairs (e.g., EUR, GBP/USD)...",style:{width:"100%",maxWidth:320,padding:"8px 12px",borderRadius:6,border:"1px solid #c9c5bb",fontSize:13,outline:"none",boxSizing:"border-box"}})}):e.jsx(L,{interval:l,intervalOptions:Rc,onInterval:i,loading:u,exportRef:p,exportFilename:"fx-pair-correlations",children:e.jsx("input",{type:"text",value:a,onChange:g=>s(g.target.value),placeholder:"Filter pairs (e.g., EUR, GBP/USD)...",style:{flex:1,minWidth:200,padding:"8px 12px",borderRadius:6,border:"1px solid #c9c5bb",fontSize:13,outline:"none",boxSizing:"border-box"}})}),e.jsxs("div",{ref:p,children:[!u&&d.length>0&&e.jsxs("div",{style:{marginBottom:10,fontSize:12,color:"#6d716e"},children:["Showing ",f.length," of ",d.length," pairs"]}),u&&d.length===0?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"40%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:400}})]}):d.length>0?e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"#28313f",borderBottom:"2px solid #c9c5bb",fontSize:12,width:40},children:"#"}),e.jsx("th",{style:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"#28313f",borderBottom:"2px solid #c9c5bb",fontSize:12},children:"Pair 1"}),e.jsx("th",{style:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"#28313f",borderBottom:"2px solid #c9c5bb",fontSize:12},children:"Pair 2"}),e.jsx("th",{style:{padding:"8px 10px",textAlign:"right",fontWeight:600,color:"#28313f",borderBottom:"2px solid #c9c5bb",fontSize:12,width:90},children:"Correlation"}),e.jsx("th",{style:{padding:"8px 10px",textAlign:"center",fontWeight:600,color:"#28313f",borderBottom:"2px solid #c9c5bb",fontSize:12,width:140},children:"Visual"})]})}),e.jsx("tbody",{children:f.map((g,m)=>{const y=g.correlation<0,b=Math.abs(g.correlation)*50;return e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"6px 10px",fontSize:12,color:"#767972",borderBottom:"1px solid #ece8df"},children:m+1}),e.jsx("td",{style:{padding:"6px 10px",fontWeight:600,borderBottom:"1px solid #ece8df"},children:g.pair1}),e.jsx("td",{style:{padding:"6px 10px",fontWeight:600,borderBottom:"1px solid #ece8df"},children:g.pair2}),e.jsx("td",{style:{padding:"6px 10px",textAlign:"right",fontVariantNumeric:"tabular-nums",fontWeight:600,color:y?"#a33a3a":"#3b82f6",borderBottom:"1px solid #ece8df"},children:g.correlation.toFixed(2)}),e.jsx("td",{style:{padding:"6px 10px",borderBottom:"1px solid #ece8df"},children:e.jsxs("div",{style:{position:"relative",width:120,height:14,background:"#ece8df",borderRadius:2,margin:"0 auto",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",left:"50%",top:0,bottom:0,width:1,background:"#c9c5bb",zIndex:2}}),e.jsx("div",{style:{position:"absolute",top:0,bottom:0,...y?{right:"50%",width:`${b}%`}:{left:"50%",width:`${b}%`},background:y?"#a33a3a":"#3b82f6",borderRadius:1,zIndex:1}})]})})]},`${g.pair1}-${g.pair2}`)})})]})}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:"No correlation data available."})]})]})}const Mc=[{value:"dxy",label:"Dollar Index"},{value:"g10",label:"G10 Strength"},{value:"correlations",label:"Pair Correlations"}],$c={dxy:[{value:"1d",label:"1D"},{value:"1w",label:"1W"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"},{value:"10y",label:"10Y"}],g10:[{value:"1d",label:"1D"},{value:"1w",label:"1W"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"},{value:"10y",label:"10Y"}],correlations:[{value:"1w",label:"1W"},{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"}]};function Cc({pinned:t}={}
5){const[r,a]=o.useState("dxy"),[s,n]=o.useState({dxy:"3m",g10:"1d",correlations:"3m"}),i=o.useRef(null),l=d=>n(c=>({...c,[r]:d}));return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{view:r,viewOptions:Mc,onView:d=>a(d),interval:s[r],intervalOptions:$c[r],onInterval:l,exportRef:i,exportFilename:`fx-${r}`}),e.jsxs("div",{ref:i,children:[r==="dxy"&&e.jsx(Li,{interval:s.dxy,controlled:!0,pinnedDate:t?.date}),r==="g10"&&e.jsx(_i,{interval:s.g10,controlled:!0,pinnedDate:t?.date}),r==="correlations"&&e.jsx(Ac,{interval:s.correlations,controlled:!0})]})]})}const Dc=["jolts-openings","jolts-hires","jolts-layoffs"];function _c(){const[t,r]=o.useState({}),[a,s]=o.useState(!0);return o.useEffect(()=>{const n=new AbortController;return fetch(`/api/markets/data?ids=${Dc.join(",")}`,{signal:n.signal}).then(i=>i.json()).then(i=>{i.ok&&r(i.data??{})}).catch(i=>{i instanceof DOMException&&i.name}).finally(()=>s(!1)),()=>n.abort()},[]),a?e.jsx("div",{className:"markets-jolts-stack",children:[0,1,2].map(n=>e.jsxs("div",{className:"markets-jolts-panel",children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"40%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:240}})]},n))}):e.jsxs("div",{className:"markets-jolts-stack",children:[e.jsxs("div",{className:"markets-jolts-panel",children:[e.jsx("h3",{className:"markets-jolts-panel-title",children:"Job Openings"}),e.jsx(yn,{data:t["jolts-openings"]??[]})]}),e.jsxs("div",{className:"markets-jolts-panel",children:[e.jsx("h3",{className:"markets-jolts-panel-title",children:"Hires"}),e.jsx(bn,{data:t["jolts-hires"]??[]})]}),e.jsxs("div",{className:"markets-jolts-panel",children:[e.jsx("h3",{className:"markets-jolts-panel-title",children:"Layoffs & Discharges"}),e.jsx(jn,{data:t["jolts-layoffs"]??[]})]})]})}const Oa=[{key:"sma20",label:"SMA 20",cfg:{type:"sma",period:20}},{key:"sma50",label:"SMA 50",cfg:{type:"sma",period:50}},{key:"ema20",label:"EMA 20",cfg:{type:"ema",period:20}},{key:"bb20",label:"Bollinger 20",cfg:{type:"bollinger",period:20,stdDev:2}}],Tr="__none__";function Ya(t){return t>=1e9?`${(t/1e9).toFixed(1)}B`:t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function Va(t){const[r,a]=o.useState(null),[s,n]=o.useState(t!==null);return o.useEffect(()=>{if(t===null){a(null),n(!1);return}const i=new AbortController;return n(!0),fetch(`/api/markets/daily?chart=sector-etf-volume&symbol=${t}`,{signal:i.signal}).then(l=>l.json()).then(l=>{l&&l.data&&a(l)}).catch(l=>{l instanceof DOMException&&l.name}).finally(()=>n(!1)),()=>i.abort()},[t]),{resp:r,loading:s}}const Jt={display:"block",fontSize:11,fontWeight:600,color:"#6d716e",marginBottom:4,textTransform:"uppercase",letterSpacing:.4},Wr={padding:"6px 10px",borderRadius:6,border:"1px solid #c9c5bb",fontSize:13};function Fc(){const[t,r]=o.useState("SPY"),[a,s]=o.useState(Tr),[n,i]=o.useState(0),[l,d]=o.useState(()=>new Set(["sma20"])),c=o.useRef(null),u=Va(t),x=a===Tr,p=Va(x?null:a),h=o.useMemo(()=>(u.resp?.data??[]).map(v=>({date:v.date,value:v.volume})),[u.resp]),f=o.useMemo(()=>x?[]:(p.resp?.data??[]).map(v=>({date:v.date,value:v.volume})),[p.resp,x]),g=o.useMemo(()=>Oa.filter(v=>l.has(v.key)).map(v=>v.cfg),[l]),m=o.useMemo(()=>{const v=[{label:`${t} Volume`,data:h,color:"#2f63d6",indicators:g}];return x||v.push({label:`${a} Volume`,data:f,color:"#f59e0b",lagDays:n||void 0,indicators:g}),v},[t,a,h,f,x,n,g]),y=v=>{d(w=>{const j=new Set(w);return j.has(v)?j.delete(v):j.add(v),j})},b=u.resp?.meta.symbols??["SPY"],S=u.resp?.meta.labels??{SPY:"S&P 500"},k=u.loading||!x&&p.loading;return e.jsxs("div",{style:{width:"100%"},children:[e.jsxs(L,{loading:k,exportRef:c,exportFilename:"sector-etf-volume",children:[e.jsxs("div",{children:[e.jsx("label",{style:Jt,children:"Primary"}),e.jsx("select",{value:t,onChange:v=>r(v.target.value),style:Wr,children:b.map(v=>e.jsxs("option",{value:v,children:[v," â ",S[v]??v]},v))})]}),e.jsxs("div",{children:[e.jsx("label",{style:Jt,children:"Compare to"}),e.jsxs("select",{value:a,onChange:v=>s(v.target.value),style:Wr,children:[e.jsx("option",{value:Tr,children:"â None â"}),b.filter(v=>
5v!==t).map(v=>e.jsxs("option",{value:v,children:[v," â ",S[v]??v]},v))]})]}),e.jsxs("div",{children:[e.jsx("label",{style:Jt,children:"Lag (days)"}),e.jsx("input",{type:"number",value:n,disabled:x,onChange:v=>i(Number(v.target.value)||0),placeholder:"0",style:{...Wr,opacity:x?.5:1}})]}),e.jsxs("div",{children:[e.jsx("label",{style:Jt,children:"Indicators"}),e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:Oa.map(v=>{const w=l.has(v.key);return e.jsx("button",{onClick:()=>y(v.key),style:{padding:"5px 10px",borderRadius:6,border:w?"1px solid #2f63d6":"1px solid #c9c5bb",background:w?"#2f63d6":"#fbfaf7",color:w?"#fbfaf7":"#28313f",fontSize:12,fontWeight:600,cursor:"pointer"},children:v.label},v.key)})})]})]}),e.jsx("div",{ref:c,children:k&&h.length===0?e.jsx("div",{className:"markets-skeleton",style:{height:360}}):h.length===0?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#6d716e",fontSize:14},children:["No volume data available for ",t,"."]}):e.jsx(tn,{series:m,formatY:Ya,formatTooltipValue:Ya,height:400})})]})}function Tc(){return e.jsx(Fc,{})}const Ka=[{key:"sma20",label:"SMA 20",cfg:{type:"sma",period:20}},{key:"sma50",label:"SMA 50",cfg:{type:"sma",period:50}},{key:"ema20",label:"EMA 20",cfg:{type:"ema",period:20}},{key:"bb20",label:"Bollinger 20",cfg:{type:"bollinger",period:20,stdDev:2}}],Wc=/^[A-Z][A-Z0-9.\-]{0,9}$/;function Ua(t){return t>=1e9?`${(t/1e9).toFixed(1)}B`:t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function Ha(t){const[r,a]=o.useState(null),[s,n]=o.useState(t!==null),[i,l]=o.useState(null);return o.useEffect(()=>{if(t===null){a(null),n(!1),l(null);return}if(!Wc.test(t)){l("Invalid ticker format."),a(null),n(!1);return}const d=new AbortController;return n(!0),l(null),fetch(`/api/markets/daily?chart=stock-volume&symbol=${encodeURIComponent(t)}`,{signal:d.signal}).then(c=>c.json()).then(c=>{c&&c.data?a(c):c?.error&&l(String(c.error))}).catch(c=>{c instanceof DOMException&&c.name==="AbortError"||l(c instanceof Error?c.message:String(c))}).finally(()=>n(!1)),()=>d.abort()},[t]),{resp:r,loading:s,error:i}}const Zt={display:"block",fontSize:11,fontWeight:600,color:"#6d716e",marginBottom:4,textTransform:"uppercase",letterSpacing:.4},Lr={padding:"6px 10px",borderRadius:6,border:"1px solid #c9c5bb",fontSize:13};function Lc(){const[t,r]=o.useState("AAPL"),[a,s]=o.useState(""),[n,i]=o.useState("AAPL"),[l,d]=o.useState(null),[c,u]=o.useState(0),[x,p]=o.useState(()=>new Set(["sma20"])),h=o.useRef(null),f=Ha(n),g=Ha(l),m=o.useMemo(()=>(f.resp?.data??[]).map(j=>({date:j.date,value:j.volume})),[f.resp]),y=o.useMemo(()=>(g.resp?.data??[]).map(j=>({date:j.date,value:j.volume})),[g.resp]),b=o.useMemo(()=>Ka.filter(j=>x.has(j.key)).map(j=>j.cfg),[x]),S=o.useMemo(()=>{const j=[{label:`${n} Volume`,data:m,color:"#2f63d6",indicators:b}];return l&&j.push({label:`${l} Volume`,data:y,color:"#f59e0b",lagDays:c||void 0,indicators:b}),j},[n,l,m,y,c,b]),k=()=>{const j=t.toUpperCase().trim();j&&j!==n&&i(j),r(j)},v=()=>{const j=a.toUpperCase().trim();d(j||null),s(j)},w=j=>{p(R=>{const N=new Set(R);return N.has(j)?N.delete(j):N.add(j),N})};return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{loading:f.loading||g.loading,exportRef:h,exportFilename:"stock-volume",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",gap:12,flex:1},children:[e.jsxs("div",{children:[e.jsx("label",{style:Zt,children:"Primary ticker"}),e.jsx("input",{value:t,onChange:j=>r(j.target.value.toUpperCase()),onBlur:k,onKeyDown:j=>{j.key==="Enter"&&j.currentTarget.blur()},placeholder:"AAPL",style:{...Lr,width:110}})]}),e.jsxs("div",{children:[e.jsx("label",{style:Zt,children:"Compare to"}),e.jsx("input",{value:a,onChange:j=>s(j.target.value.toUpperCase()),onBlur:v,onKeyDown:j=>{j.key==="Enter"&&j.currentTarget.blur()},placeholder:"Optional",style:{...Lr,width:110}})]}),e.jsxs("div",{children:[e.jsx("label",{style:Zt,children:"Lag (days)"}),e.jsx("input",{type:"number",value:c,disabled:!l,onChange:j=>u(Number(j.target.value)||0),placeholder:"0",style:{...Lr,width:80,opacity:l?1:.5}})]}),e.jsxs("div",{children:[e.jsx("label",{style:Zt,children:"Indicators"}),e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:Ka.map(j=>{const R=x.has(j.key);return e.jsx("button",{onClick:()=>w(j.key),style:{padding:"5px 10px",borderRadius:6,border:R?"1px solid #2f63d6":"1px solid #c9c5bb",background:R?"#2f63d6":"#fbfaf7",color:R?"#fbfaf7":"#28313f",fontSize:12,fontWeight:600,cursor:"pointer"},children:j.label},j.key)})})]})]})}),e.jsxs("div",{ref:h,children:[f.error||g.error?e.jsx("div",{style:{padding:12,border:"1px solid #fecaca",borderRadius:6,background:"#fef2f2",color:"#8c3434",fontSize:13,marginBottom:12},children:f.error||g.error}):null,f.loading&&m.length===0?e.jsx("div",{className:"markets-skeleton",style:{height:400}}):m.length===0?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"#6d716e",fontSize:14},children:["No volume data available for ",n,"."]}):e.jsx(tn,{series:S,formatY:Ua,formatTooltipValue:Ua,height:400})]})]})}const Ec=["XLK","XLF","XLV","XLY","XLP","XLE","XLI","XLB","XLRE","XLU","XLC"];function zc({pinned:t}){return e.jsx(Zr,{chart:"ticker-volume",exportFilename:"volume-trends",yLabel:"Volume change (%)",defaultShortcut:"1d",searchable:!0,defaultTickers:Ec,axisLabel:!0,pinned:t&&{start:t.date,end:t.date}})}const wn=[{key:"revenue",name:"Revenue",color:"#2f63d6"},{key:"opMargin",name:"Operating margin",color:"#1a8b66"},{key:"netToOp",name:"Tax / interest / other",color:"#d97706"},{key:"shares",name:"Buybacks (shares)",color:"#7c3aed"}],Pc=[{value:"ytd",label:"YTD"},{value:"1y",label:"1Y"},{value:"2y",label:"2Y"},{value:"3y",label:"3Y"},{value:"5y",label:"5Y"},{value:"max",label:"Max"}],Bc={"1y":4,"2y":8,"3y":12,"5y":20},er={padding:"4px 8px",borderRadius:6,border:"1px solid #c9c5bb",fontSize:12,color:"#28313f",background:"#fbfaf7"};function sr(t){return t==null||Number.isNaN(t)?"â":`${t>=0?"+":""}${t.toFixed(1)}%`}function Er(t){if(t==null||Number.isNaN(t))return"â";const r=Math.abs(t),a=t<0?"-":"";return r>=1e12?`${a}$${(r/1e12).toFixed(2)}T`:r>=1e9?`${a}$${(r/1e9).toFixed(2)}B`:r>=1e6?`${a}$${(r/1e6).toFixed(1)}M`:`${a}$${r.toFixed(0)}`}function Ic(t){if(t==null||Number.isNaN(t))return"â";const r=Math.abs(t);return r>=1e9?`${(t/1e9).toFixed(2)}B`:r>=1e6?`${(t/1e6).toFixed(1)}M`:t.toFixed(0)}function Oc(t){return t==null||Number.isNaN(t)?"â":`$${t.toFixed(2)}`}function Yc(t,r){return r?`/api/sec/statement?cik=${encodeURIComponent(t)}&accn=${encodeURIComponent(r)}&stmt=income_stmt`:null}function $t({text:t,url:r}){return r?e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",title:"Open this
5statement in the SEC filing",style:{color:"#274f9f",textDecoration:"none",fontVariantNumeric:"tabular-nums"},children:[t,e.jsx("span",{"aria-hidden":!0,style:{fontSize:10,marginLeft:2,opacity:.7},children:"â"})]}):e.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:t})}function Vc({active:t,payload:r}){if(!t||!r?.length)return null;const a=r[0]?.payload;if(!a)return null;const s=(n,i,l)=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[e.jsx("span",{style:{color:i},children:n}),e.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:sr(l)})]});return e.jsxs("div",{style:{...pe,padding:"8px 10px",minWidth:200},children:[e.jsxs("div",{style:{fontWeight:700,marginBottom:4},children:[a.label,a.constituentCount!=null&&e.jsxs("span",{style:{fontWeight:400,color:"#767972"},children:[" · ",a.constituentCount," cos"]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16,fontWeight:700},children:[e.jsx("span",{children:"EPS growth"}),e.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:sr(a.epsGrowth)})]}),e.jsx("div",{style:{height:1,background:"#eef2f7",margin:"4px 0"}}),wn.map(n=>s(n.name,n.color,a.contributions[n.key]))]})}function Kc(){const t=o.useRef(null),[r,a]=o.useState("sector"),[s,n]=o.useState("major"),[i,l]=o.useState("73"),[d,c]=o.useState("AAPL"),[u,x]=o.useState("AAPL"),[p,h]=o.useState("2y"),[f,g]=o.useState([]),{data:m,meta:y,loading:b,fetchChart:S}=tt();o.useEffect(()=>{if(r!=="sector")return;let j=!1;return fetch(`/api/markets/daily?chart=eps-growth-groups&level=${s}`).then(R=>R.json()).then(R=>{if(j||!R?.ok)return;const N=R.data;g(N),l(D=>N.some(M=>M.code===D)?D:R.meta?.default??N[0]?.code??D)}).catch(()=>{}),()=>{j=!0}},[r,s]),o.useEffect(()=>{const j=r==="company"?`/api/markets/daily?chart=eps-growth&mode=company&symbol=${encodeURIComponent(d)}`:`/api/markets/daily?chart=eps-growth&mode=sector&level=${s}&group=${encodeURIComponent(i)}`;S(j)},[r,s,i,d,S]);const k=o.useMemo(()=>{if(!m.length)return[];if(p==="ytd"){const R=m[m.length-1].quarterEnd.slice(0,4);return m.filter(N=>N.quarterEnd.slice(0,4)===R)}const j=Bc[p];return j?m.slice(-j):m},[m,p]),v=k.length?k[k.length-1]:null,w=r==="company"?`${y?.ticker??d}${y?.companyName?` â ${y.companyName}`:""}`:f.find(j=>j.code===i)?.label??i;return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(L,{view:r,viewOptions:[{value:"sector",label:"By sector"},{value:"company",label:"By company"}],onView:j=>a(j),interval:p,intervalOptions:Pc,onInterval:h,rangeLabel:k.length?`${k[0].label} â ${k[k.length-1].label}`:void 0,loading:b,exportRef:t,exportFilename:"eps-growth",children:r==="sector"?e.jsxs(e.Fragment,{children:[e.jsxs("select",{"aria-label":"SIC level",value:s,onChange:j=>n(j.target.value),style:{...er,cursor:"pointer"},children:[e.jsx("option",{value:"major",children:"Major group"}),e.jsx("option",{value:"industry",children:"Industry"})]}),e.jsx("select",{"aria-label":"Sector",value:i,onChange:j=>l(j.target.value),style:{...er,cursor:"pointer",maxWidth:320},children:f.map(j=>e.jsxs("option",{value:j.code,children:[j.label," (",j.count.toLocaleString(),")"]},j.code))})]}):e.jsxs("form",{onSubmit:j=>{j.preventDefault();const R=u.toUpperCase().trim();/^[A-Z][A-Z0-9.\-]{0,9}$/.test(R)&&c(R)},style:{display:"inline-flex",gap:6,alignItems:"center"},children:[e.jsx("input",{value:u,onChange:j=>x(j.target.value),placeholder:"Tickerâ¦","aria-label":"Company ticker",style:{...er,width:110}}),e.jsx("button",{type:"submit",style:{...er,cursor:"pointer",fontWeight:600},children:"Go"})]})}),e.jsxs("div",{style:{fontSize:13,color:"#6d716e",margin:"0 0 8px 2px"},children:["Year-over-year EPS growth for ",e.jsx("strong",{style:{color:"#28313f"},children:w}),", decomposed into revenue, operating-margin, tax/interest, and share-count (buyback) contributions."]}),e.jsx(Pe,{loading:b,hasData:k.length>0,height:je,children:k.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"markets-appendix-chart",ref:t,children:e.jsx(q,{width:"100%",height:je,children:e.jsxs(Wt,{data:k,margin:{top:8,right:16,left:8,bottom:8},children:[e.jsx(J,{...ce}),e.jsx(Q,{dataKey:"label",tick:{fontSize:11,fill:"#6d716e"},tickLine:!1,interval:"preserveStartEnd"}),e.jsx(X,{...de,tickFormatter:j=>`${j>0?"+":""}${j}%`,label:Me("YoY EPS growth")}),e.jsx(Z,{content:e.jsx(Vc,{}),cursor:{fill:"rgba(0,0,0,0.03)"}}),e.jsx(ve,{wrapperStyle:{fontSize:12,color:"#28313f"}}),e.jsx(le,{y:0,stroke:"#767972"}),wn.map(j=>e.jsx(ye,{dataKey:`contributions.${j.key}`,name:j.name,stackId:"c",fill:j.color,maxBarSize:48},j.key)),e.jsx(ie,{type:"monotone",dataKey:"epsGrowth",name:"EPS growth",stroke:"#111722",strokeWidth:2,dot:{r:2.5},activeDot:{r:4}})]})})}),r==="company"?e.jsx(Uc,{rows:k,cik:y?.cik??v?.source?.cik??""}):e.jsx(Hc,{latest:v,onPick:j=>{a("company"),c(j),x(j)}})]}):e.jsx("div",{style:{padding:40,textAlign:"center",color:"#767972",fontSize:14},children:y?.error??"No quarterly EPS data available for this selection."})})]})}function Uc({rows:t,cik:r}){const a={textAlign:"right",padding:"6px 10px",color:"#6d716e",fontWeight:600,whiteSpace:"nowrap"},s={textAlign:"right",padding:"6px 10px",whiteSpace:"nowrap"},n=[...t].reverse();return e.jsxs("div",{style:{marginTop:16,overflowX:"auto"},children:[e.jsx("div",{style:{fontSize:12,color:"#6d716e",marginBottom:6},children:"As reported â click any figure to open its source 10-Q/10-K income statement."}),e.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12.5,width:"100%",minWidth:640},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"1px solid #c9c5bb"},children:[e.jsx("th",{style:{...a,textAlign:"left"},children:"Quarter"}),e.jsx("th",{style:a,children:"Revenue"}),e.jsx("th",{style:a,children:"Operating income"}),e.jsx("th",{style:a,children:"Net income"}),e.jsx("th",{style:a,children:"Diluted shares"}),e.jsx("th",{style:a,children:"Diluted EPS"}),e.jsx("th",{style:a,children:"EPS YoY"})]})}),e.jsx("tbody",{children:n.map(i=>{const l=Yc(i.source?.cik??r,i.source?.accession??null);return e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsxs("td",{style:{...s,textAlign:"left",color:"#28313f",fontWeight:600},children:[i.label,i.source?.derived&&e.jsx("span",{title:"Q4 derived as FY â first three quarters; links to the 10-K",style:{color:"#767972",fontWeight:400},children:" · derived"})]}),e.jsx("td",{style:s,children:e.jsx($t,{text:Er(i.figures.rev),url:l})}),e.jsx("td",{style:s,children:e.jsx($t,{text:Er(i.figures.opInc),url:l})}),e.jsx("td",{style:s,children:e.jsx($t,{text:Er(i.figures.ni),url:l})}),e.jsx("td",{style:s,children:e.jsx($t,{text:Ic(i.figures.shares),url:l})}),e.jsx("td",{style:s,children:e.jsx($t,{text:Oc(i.figures.eps),url:l})}),e.jsx("td",{style:{...s,color:(i.epsGrowth??0)>=0?"#1a8b66":"#a33a3a",fontWeight:600},children:sr(i.epsGrowth)})]},i.quarterEnd)})})]})]})}function Hc({latest:t,onPick:r}){return t?.constituents?.length?e.jsxs("div",{style:{marginTop:16},children:[e.jsxs("div",{style:{fontSize:12,color:"#6d716e",marginBottom:6},children:["Largest constituents by net income â ",t.label," · ",t.constituentCount," companies. Select one to drill into
5its filings."]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:t.constituents.map(a=>e.jsxs("button",{type:"button",onClick:()=>r(a.ticker),title:a.name??a.ticker,style:{display:"inline-flex",alignItems:"baseline",gap:6,padding:"4px 10px",borderRadius:8,border:"1px solid #c9c5bb",background:"#fbfaf7",cursor:"pointer",fontSize:12},children:[e.jsx("strong",{style:{color:"#28313f"},children:a.ticker}),e.jsx("span",{style:{color:(a.epsGrowth??0)>=0?"#1a8b66":"#a33a3a",fontVariantNumeric:"tabular-nums"},children:sr(a.epsGrowth)})]},a.ticker))})]}):null}function Ct(t){if(t>=1440){const r=Math.floor(t/1440),a=Math.floor(t%1440/60);return`${r}d ${a}h`}if(t>=60){const r=Math.floor(t/60),a=t%60;return`${r}h ${a}m`}return`${t}m`}function qa(t){if(!t)return"â";const r=t.slice(0,10).split("-");return new Date(Number(r[0]),Number(r[1])-1,Number(r[2])).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function tr(t){return t<=0?"#a33a3a":t<50?"#D97706":t<90?"#2f63d6":C.positive}function zr(t){if(t==="equities_us_candles")return"Equities US";const r=t.match(/^fx_(\w{3})_(\w{3})_candles$/);return r?`${r[1].toUpperCase()}/${r[2].toUpperCase()}`:t}const qc={padding:"5px 10px",borderRadius:5,border:"1px solid #c9c5bb",fontSize:13,background:"#fbfaf7",color:"#28313f",outline:"none",cursor:"pointer",minWidth:180},Xc={fontSize:12,color:C.muted,lineHeight:1.6,padding:"10px 14px",background:"#f6f3ec",border:"1px solid #c9c5bb",borderRadius:6,marginBottom:16};function Gc(){const[t,r]=o.useState(null),[a,s]=o.useState(!0),[n,i]=o.useState(""),l=o.useRef(null),d=o.useCallback(async S=>{s(!0);try{const k=new URLSearchParams({chart:"data-gap-analysis"});S&&k.set("table",S);const w=await(await fetch(`/api/markets/daily?${k.toString()}`)).json();w.ok&&r(w.data)}catch(k){console.error("DataGapAnalysis fetch error:",k)}finally{s(!1)}},[]);if(o.useEffect(()=>{d(n)},[d,n]),a&&!t)return e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]});const c=t?.summary??[],u=t?.gaps??[],x=t?.tables??[],p=x.filter(S=>S.startsWith("fx_")).sort(),h=x.filter(S=>!S.startsWith("fx_")).sort();n.startsWith("fx_");const f=n==="equities_us_candles",g=c.reduce((S,k)=>S+Number(k.total_missing_minutes),0),m=c.reduce((S,k)=>S+Number(k.days_with_gaps),0),y=c.length>0?c.reduce((S,k)=>Number(k.min_coverage_pct)<S?Number(k.min_coverage_pct):S,100):100,b=[...u].sort((S,k)=>Number(S.coverage_pct)-Number(k.coverage_pct));return e.jsxs("div",{style:{width:"100%",fontFamily:"system-ui, -apple-system, sans-serif"},children:[e.jsxs(L,{loading:a,exportRef:l,exportFilename:"data-gap-analysis",children:[e.jsxs("select",{value:n,onChange:S=>i(S.target.value),style:qc,children:[e.jsx("option",{value:"",children:"All tables (summary)"}),e.jsx("optgroup",{label:"Equities",children:h.map(S=>e.jsx("option",{value:S,children:zr(S)},S))}),e.jsx("optgroup",{label:"FX Pairs",children:p.map(S=>e.jsx("option",{value:S,children:zr(S)},S))})]}),n&&e.jsx("span",{style:{fontSize:11,color:C.muted},children:f?"Times in EST (9:30 AM â 4:00 PM)":"Times in UTC (24h)"})]}),e.jsxs("div",{ref:l,children:[e.jsxs("div",{style:Xc,children:[e.jsx("strong",{children:"Coverage"})," = actual minutes with data / expected minutes."," ","FX expects 1,440 min/day (24h, Mon\\u2013Fri UTC). Equities expects 390 min/day (9:30 AM\\u20134:00 PM EST).",e.jsx("br",{}),e.jsx("strong",{children:"Days with Gaps"})," = any weekday where coverage < 100%. Weekends are excluded."]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:16},children:[{label:"Days with Gaps",value:m.toLocaleString(),color:m>0?C.negative:C.positive},{label:"Total Missing",value:Ct(g),color:g>1440?C.negative:C.text},{label:"Worst Day Coverage",value:`${y}%`,color:tr(y)},{label:n?"Days Analyzed":"Tables",value:String(n?u.length:c.length),color:C.text}].map(S=>e.jsxs("div",{style:{background:C.cardBg,border:`1px solid ${C.cardBorder}`,borderRadius:8,padding:"12px 16px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:12,color:C.muted,marginBottom:4},children:S.label}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:S.color},children:S.value})]},S.label))}),!n&&e.jsx("div",{style:{overflowY:"auto",maxHeight:"60vh"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px s
5olid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Table"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Days w/ Gaps"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Avg Coverage"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Worst Day"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Total Missing"}),e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Worst Date"})]})}),e.jsx("tbody",{children:[...c].sort((S,k)=>Number(S.min_coverage_pct)-Number(k.min_coverage_pct)).map(S=>e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df",cursor:"pointer"},onClick:()=>i(S.table_name),children:[e.jsx("td",{style:{padding:"6px 12px",fontWeight:600,color:C.accent,fontSize:13},children:S.label}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:C.text},children:Number(S.days_with_gaps)}),e.jsxs("td",{style:{padding:"6px 12px",textAlign:"right",color:tr(Number(S.avg_coverage_pct))},children:[Number(S.avg_coverage_pct),"%"]}),e.jsxs("td",{style:{padding:"6px 12px",textAlign:"right",fontWeight:600,color:tr(Number(S.min_coverage_pct))},children:[Number(S.min_coverage_pct),"%"]}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:C.text},children:Ct(Number(S.total_missing_minutes))}),e.jsx("td",{style:{padding:"6px 12px",color:C.muted,fontSize:12},children:qa(S.worst_date)})]},S.table_name))})]})}),n&&e.jsx("div",{style:{overflowY:"auto",maxHeight:"60vh"},children:b.length===0?e.jsxs("div",{style:{padding:40,textAlign:"center",color:C.positive,fontSize:14,fontWeight:600},children:["No gaps found for ",zr(n)]}):e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"2px solid #c9c5bb"},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Date"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Coverage"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Actual"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Expected"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 12px",color:C.muted,fontWeight:500},children:"Missing"})]})}),e.jsx("tbody",{children:b.map((S,k)=>e.jsxs("tr",{style:{borderBottom:"1px solid #ece8df"},children:[e.jsx("td",{style:{padding:"6px 12px",fontWeight:500,color:C.text},children:qa(S.gap_date)}),e.jsxs("td",{style:{padding:"6px 12px",textAlign:"right",fontWeight:600,color:tr(Number(S.coverage_pct))},children:[Number(S.coverage_pct),"%"]}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:C.text},children:Ct(Number(S.actual_minutes))}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:C.muted},children:Ct(Number(S.expected_minutes))}),e.jsx("td",{style:{padding:"6px 12px",textAlign:"right",color:C.text},children:Ct(Number(S.missing_minutes))})]},k))})]})})]})]})}function Pr(t){return t==null?"â":`$${Number(t).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function Qc(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Jc(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Xa(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Zc(t){return`${t>=0?"+":""}${t.toFixed(0)}%`}function ed(){const[t,r]=o.useState([]),[a,s]=o.useState(""),[n,i]=o.useState([]),[l,d]=o.useState(!0),[c,u]=o.useTransition(),x=o.useRef(null);o.useEffect(()=>{(async()=>{try{const y=await(await fetch("/api/markets/daily?chart=meme-stocks")).json();y.ok&&(i(y.data),y.meta?.events&&y.meta.events.length>0&&(r(y.meta.events),s(y.meta.events[0])))}catch(m){console.error("Meme stocks fetch error:",m)}finally{d(!1)}})()},[]);function p(m){u(()=>{s(m)})}const h=o.useMemo(()=>{const m=n.filter(b=>b.event_name===a),y=720*60*60*1e3;return m.map((b,S)=>{const k=b.inside_market_hours_volume!=null?Number(b.inside_market_hours_volume):null,v=b.outside_market_hours_volume!=null?Number(b.outside_market_hours_volume):null,j=new Date(b.bucket_start).getTime()-y;let R=null,N=null;if(b.is_inside_market_hours&&k!=null){let D=0,M=0;for(let $=S;$>=0;$--){const T=m[$];if(new Date(T.bucket_start).getTime()<j)break;if(!T.is_inside_market_hours)continue;const A=Number(T.inside_market_hours_volume);A==null||isNaN(A)||(M++,A<=k&&D++)}M>1&&(R=D/M*100)}if(!b.is_inside_market_hours&&v!=null){let D=0,M=0;for(let $=S;$>=0;$--){const T=m[$];if(new Date(T.bucket_start).getTime()<j)break;if(T.is_inside_market_hours)continue;const A=Number(T.outside_market_hours_volume);A==null||isNaN(A)||(M++,A<=v&&D++)}M>1&&(N=D/M*100)}return{...b,high_in_bucket:Number(b.high_in_bucket),bucket_volume:Number(b.bu
5cket_volume),inside_market_hours_volume:k,outside_market_hours_volume:v,volume_95pct_7d:b.volume_95pct_7d!=null?Number(b.volume_95pct_7d):null,price_95pct_7d:b.price_95pct_7d!=null?Number(b.price_95pct_7d):null,rth_pct:R,eth_pct:N}})},[n,a]),f=o.useMemo(()=>{if(h.length===0)return null;const m=h.filter(v=>v.high_in_bucket>0);if(m.length===0)return null;let y=m[0];for(const v of m)v.high_in_bucket>y.high_in_bucket&&(y=v);const b=m.filter(v=>v.bucket_start<=y.bucket_start);let S=b[0];for(const v of b)v.high_in_bucket<S.high_in_bucket&&(S=v);if(S.high_in_bucket<=0)return null;const k=(y.high_in_bucket-S.high_in_bucket)/S.high_in_bucket*100;return{lowRow:S,highRow:y,gain:k}},[h]),g=l||c;return e.jsxs("div",{children:[e.jsxs(L,{loading:g,exportRef:x,exportFilename:"meme-stocks",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("label",{style:{fontSize:13,color:C.muted,fontWeight:500},children:"Event"}),e.jsx("select",{value:a,onChange:m=>p(m.target.value),style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${C.cardBorder}`,fontSize:13,background:C.bg,color:C.text,cursor:"pointer"},children:t.map(m=>e.jsx("option",{value:m,children:m},m))})]}),f&&!g&&e.jsxs("span",{style:{fontSize:13,fontWeight:600,color:C.positive,background:"rgba(5, 150, 105, 0.08)",padding:"3px 10px",borderRadius:4},children:["Max Gain: ",Zc(f.gain)]})]}),f&&!g&&e.jsxs("div",{style:{fontSize:12,color:C.muted,marginBottom:12,display:"flex",gap:24,flexWrap:"wrap"},children:[e.jsxs("span",{children:["Low: ",e.jsx("strong",{style:{color:C.text},children:Pr(f.lowRow.high_in_bucket)})," on ",Xa(f.lowRow.bucket_start)]}),e.jsxs("span",{children:["Peak: ",e.jsx("strong",{style:{color:C.negative},children:Pr(f.highRow.high_in_bucket)})," on ",Xa(f.highRow.bucket_start)]})]}),g?e.jsx("div",{style:{height:450,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{style:{color:C.muted},children:l?"Loading...":"Updating chart..."})}):h.length===0?e.jsx("div",{style:{height:450,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{style:{color:C.muted},children:"No data available for this event"})}):e.jsxs("div",{ref:x,children:[e.jsx(q,{width:"100%",height:450,children:e.jsxs(Wt,{data:h,margin:{...we,right:60},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:C.grid}),e.jsx(Q,{dataKey:"bucket_start",...ne,tickFormatter:Qc}),e.jsx(X,{yAxisId:"price",orientation:"left",...de,tickFormatter:m=>`$${m.toLocaleString()}`,label:{value:"Price",angle:-90,position:"insideLeft",offset:-2,style:{fontSize:11,fill:C.muted,textAnchor:"middle"}}}),e.jsx(X,{yAxisId:"pct",orientation:"right",...de,domain:[0,100],tickFormatter:m=>`${m.toFixed(0)}%`,label:{value:"Percentile",angle:90,position:"insideRight",offset:-2,style:{fontSize:11,fill:C.muted,textAnchor:"middle"}}}),e.jsx(Z,{content:({active:m,payload:y})=>{if(!m||!y?.length)return null;const b=y[0]?.payload;return e.jsxs("div",{style:{background:C.bg,border:`1px solid ${C.cardBorder}`,borderRadius:8,padding:"10px 14px",fontSize:12,lineHeight:1.6,boxShadow:"0 2px 8px rgba(0,0,0,0.12)"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:Jc(b.bucket_start)}
5),e.jsxs("div",{children:["Price: ",e.jsx("strong",{children:Pr(b.high_in_bucket)})]}),b.rth_pct!=null&&e.jsxs("div",{style:{color:"#93c5fd"},children:["RTH Volume Percentile: ",e.jsxs("strong",{children:[b.rth_pct.toFixed(0),"%"]})]}),b.eth_pct!=null&&e.jsxs("div",{style:{color:"#1e40af"},children:["ETH Volume Percentile: ",e.jsxs("strong",{children:[b.eth_pct.toFixed(0),"%"]})]})]})}}),e.jsx(ve,{wrapperStyle:{fontSize:12,paddingTop:8},payload:[{value:"Price (High)",type:"line",color:"#1a8b66"},{value:"RTH Volume Percentile",type:"line",color:"#93c5fd"},{value:"ETH Volume Percentile",type:"line",color:"#1e40af"}]}),e.jsx(le,{yAxisId:"pct",y:100,stroke:C.muted,strokeDasharray:"6 3",strokeOpacity:.5}),e.jsx(ie,{yAxisId:"price",type:"monotone",dataKey:"high_in_bucket",name:"Price (High)",stroke:"#1a8b66",strokeWidth:2,dot:!1,activeDot:{r:4,fill:"#1a8b66"},legendType:"none"}),e.jsx(ie,{yAxisId:"pct",type:"monotone",dataKey:"rth_pct",name:"RTH Volume Percentile",stroke:"#93c5fd",strokeWidth:1,dot:!1,connectNulls:!1,legendType:"none",strokeDasharray:"4 3",opacity:.35}),e.jsx(ie,{yAxisId:"pct",type:"monotone",dataKey:"eth_pct",name:"ETH Volume Percentile",stroke:"#1e40af",strokeWidth:1,dot:!1,connectNulls:!1,legendType:"none",strokeDasharray:"4 3",opacity:.35})]})}),e.jsx("div",{style:{fontSize:11,color:C.muted,marginTop:8,fontStyle:"italic"},children:"Prices are split-adjusted and may not match raw prices shown on other charts or sources."})]})]})}const td=["MSFT","NVDA","AAPL","GOOGL","META","AMZN","TSLA"],rd=[{value:"1m",label:"1M"},{value:"3m",label:"3M"},{value:"6m",label:"6M"},{value:"1y",label:"1Y"},{value:"3y",label:"3Y"}],Ga=["#2f63d6","#d97706","#1a8b66","#7c3aed","#0891b2","#a33a3a"];function ad(t){return t===null||!Number.isFinite(t)?"â":`${t>=0?"":"-"}${Math.abs(t).toFixed(2)}%`}function nd(){const[t,r]=o.useState(td),[a,s]=o.useState("1y"),[n,i]=o.useState(""),[l,d]=o.useState([]),[c,u]=o.useState(!0),x=o.useRef(null),p=o.useCallback(async(k,v)=>{if(k.length===0){d([]),u(!1);return}u(!0);try{const j=await(await fetch(`/api/markets/daily?chart=eq-fcf-yield&tickers=${encodeURIComponent(k.join(","))}&interval=${v}`)).json();j.ok&&d(j.data?.series??[])}catch(w){console.error("FcfYieldComparison fetch error:",w)}finally{u(!1)}},[]);o.useEffect(()=>{p(t,a)},[t,a,p]);const h=()=>{const k=n.trim().toUpperCase();k&&!t.includes(k)&&t.length<10&&r([...t,k]),i("")},f=k=>r(t.filter(v=>v!==k)),g=k=>{const v=l.findIndex(w=>w.id===k);return v>=0?Ga[v%Ga.length]:C.muted},m=k=>{const v=l.find(w=>w.id===k);return v?v.latest:null},y=o.useMemo(()=>l.map(k=>({id:k.id,data:k.data})),[l]),b=k=>`${k.toFixed(1)}%`,S=k=>`${k.toFixed(2)}%`;return e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:12},children:t.map(k=>{const v=g(k),w=m(k);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"3px 8px",borderRadius:6,border:`1px solid ${C.cardBorder}`,fontSize:12,background:C.bg},children:[e.jsx("span",{style:{width:10,height:10,borderRadius:2,background:v,flexShrink:0}}),e.jsx("strong",{style:{color:C.text},children:k}),e.jsx("span",{style:{color:C.muted},children:ad(w)}),e.jsx("button",{type:"button",onClick:()=>f(k),"aria-label":`Remove ${k}`,style:{border:"none",background:"transparent",color:C.muted,cursor:"pointer",fontSize:14,lineHeight:1,padding:0},children:"Ã"})]},k)})}),e.jsx(L,{interval:a,intervalOptions:rd,onInterval:s,loading:c,exportRef:x,exportFilename:"fcf-yield-comparison",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("input",{value:n,onChange:k=>i(k.target.value.toUpperCase()),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),h())},placeholder:"Add ticker",maxLength:6,style:{padding:"6px 10px",borderRadius:6,border:`1px solid ${C.cardBorder}`,fontSize:13,width:120,background:C.bg,color:C.text}}),e.jsx("button",{type:"button",onClick:h,disabled:t.length>=10,style:{padding:"6px 12px",borderRadius:6,border:"1px solid #2f63d6",background:"#2f63d6",color:"#fbfaf7",fontSize:13,fontWeight:500,cursor:t.length>=10?"not-allowed":"pointer",opacity:t.length>=10?.5:1},children:"Add"})]})}),c&&y.length===0?e.jsxs("div",{children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:320}})]}):y.length>0?e.jsx("div",{className:"markets-appendix-chart",ref:x,children:e.jsx(te,{data:y,chartType:"line",height:420,yAxisLabel:"FCF Yield (LTM)",formatY:b,formatTooltipValue:S})}):e.jsx("div",{style:{padding:40,textAlign:"center",color:C.muted,fontSize:14},children:t.length===0?"Add one or more tickers to compare FCF yield.":"No FCF / price data available for the selected tickers."}),e.jsx("div",{style:{fontSize:11,color:C.muted,marginTop:8,fontStyle:"italic"},children:"FCF Yield = trailing-twelve-month free cash flow ÷ market cap. FCF is held at its latest reported value; market cap is scaled daily by price."})]})}const _t={weekStartsOn:1}
5,Kr=[{key:"economic",label:"Economic"},{key:"earnings",label:"Earnings"},{key:"dividend",label:"Dividends"},{key:"ipo",label:"IPO"},{key:"revenue",label:"Revenue"}],or=Object.fromEntries(Kr.map(t=>[t.key,t.label])),Nn={bmo:"Before open",amc:"After close",na:"Time TBD"},ir=t=>t==="bmo"||t==="amc"?t:"na",sd={bmo:"bg-orange-50 text-orange-700 border-orange-200",amc:"bg-indigo-50 text-indigo-700 border-indigo-200",na:"bg-gray-100 text-gray-500 border-gray-200"},Rn={0:"One-time",1:"Annual",2:"Semi-annual",4:"Quarterly",12:"Monthly",24:"Semi-monthly",26:"Biweekly",52:"Weekly"},od={yahoo:"Yahoo Finance",investing:"Investing.com"};function Lt(t){if(t==null||!isFinite(t))return"";const r=Math.abs(t);return r>=1e12?`$${(t/1e12).toFixed(2)}T`:r>=1e9?`$${(t/1e9).toFixed(2)}B`:r>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${Math.round(t).toLocaleString()}`}function An(t,r="USD"){return t==null||!isFinite(t)?"":`${r==="USD"?"$":""}${t.toFixed(2)}${r!=="USD"?` ${r}`:""}`}function pt(t){return ge(t,"yyyy-MM-dd")}function lr(t){if(t==null||!isFinite(t))return"â";const r=Math.abs(t);return r>=1e6?`${(t/1e6).toFixed(2)}M`:r>=1e4?`${(t/1e3).toFixed(1)}K`:Number.isInteger(t)?t.toLocaleString():t.toFixed(r<10?2:1)}const Qa={1:"Low",2:"Medium",3:"High"};function id(t){return t.cik?`https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK=${t.cik.replace(/\D/g,"").padStart(10,"0")}&type=8-K&dateb=&owner=include&count=40`:`https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&company=${encodeURIComponent(t.ticker)}&type=8-K&dateb=&owner=include&count=40`}function ld(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M16 2v4M8 2v4M3 10h18"})]})}function cr({dir:t}){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:t==="left"?"M15 18l-6-6 6-6":"M9 18l6-6-6-6"})})}function cd(){const[t,r]=o.useState(()=>Be(new Date,_t)),[a,s]=o.useState(()=>new Date),[n,i]=o.useState("earnings"),[l,d]=o.useState([]),[c,u]=o.useState(null),[x,p]=o.useState(!0),[h,f]=o.useState(null),[g,m]=o.useState(!1),[y,b]=o.useState(()=>Br(new Date)),[S,k]=o.useState(null),v=o.useRef(null),w=o.useRef(null),j=o.useMemo(()=>rs(t,_t),[t]),R=o.useMemo(()=>Array.from({length:7},(_,E)=>qr(t,E)),[t]);o.useEffect(()=>{v.current?.abort();const _=new AbortController;return v.current=_,p(!0),f(null),k(null),fetch(`/api/markets/daily?chart=market-calendar&from=${pt(t)}&to=${pt(j)}`,{signal:_.signal}).then(E=>E.json()).then(E=>{_.signal.aborted||(E.ok?(d(E.data||[]),u(E.meta||null)):f(E.error||"Failed to load calendar."))}).catch(E=>{E instanceof DOMException&&E.name==="AbortError"||f(E instanceof Error?E.message:String(E))}).finally(()=>{_.signal.aborted||p(!1)}),()=>_.abort()},[t,j]),o.useEffect(()=>{(a<t||a>j)&&s(t)},[t,j,a]),o.useEffect(()=>{if(!g)return;const _=V=>{w.current&&!w.current.contains(V.target)&&m(!1)},E=V=>{V.key==="Escape"&&m(!1)};return window.addEventListener("mousedown",_),window.addEventListener("keydown",E),()=>{window.removeEventListener("mousedown",_),window.removeEventListener("keydown",E)}},[g]),o.useEffect(()=>{if(!S)return;const _=E=>E.key==="Escape"&&k(null);return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[S]);const N=c?.counts??{},D=(_,E)=>N[pt(_)]?.[E]??0,M=o.useMemo(()=>Kr.filter(_=>R.some(E=>D(E,_.key)>0)),[R,N]),$=o.useMemo(()=>{const _=pt(a),E=l.filter(V=>V.date===_&&V.category===n);if(n==="earnings"){const V={bmo:0,amc:1,na:2};E.sort((W,K)=>(K.marketCap??-1)-(W.marketCap??-1)||V[ir(W.time)]-V[ir(K.time)]||W.ticker.localeCompare(K.ticker))}else n==="economic"?E.sort((V,W)=>(W.importance??0)-(V.importance??0)||(V.name||"").localeCompare(W.name||"")):n==="ipo"?E.sort((V,W)=>(W.dealSize??-1)-(V.dealSize??-1)||(V.ticker||"").localeCompare(W.ticker||"")):n==="revenue"?E.sort((V,W)=>
5(W.yoyPct??-1/0)-(V.yoyPct??-1/0)||(V.ticker||"").localeCompare(W.ticker||"")):E.sort((V,W)=>(W.marketCap??-1)-(V.marketCap??-1)||V.ticker.localeCompare(W.ticker));return E},[l,a,n]),T=()=>{const _=new Date;r(Be(_,_t)),s(_)},A=_=>{r(Be(_,_t)),s(_),m(!1)},B=cn(t,j)?`${ge(t,"MMM d")} â ${ge(j,"d, yyyy")}`:`${ge(t,"MMM d")} â ${ge(j,"MMM d, yyyy")}`;return e.jsxs("div",{className:"text-gray-800 text-[13px]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsx("h2",{className:"text-lg font-bold m-0",children:"Calendar"}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:T,className:"px-3 py-1.5 rounded-md border border-gray-200 bg-white text-[12px] font-semibold text-gray-700 hover:bg-gray-50",children:"Today"}),e.jsxs("div",{className:"relative",ref:w,children:[e.jsx("button",{type:"button",onClick:()=>{b(Br(a)),m(_=>!_)},"aria-label":"Pick a date",className:"p-1.5 rounded-md border border-gray-200 bg-white text-gray-600 hover:bg-gray-50",children:e.jsx(ld,{})}),g&&e.jsx(gd,{month:y,selected:a,onMonth:_=>b(_),onPick:A})]}),e.jsx("button",{type:"button",onClick:()=>r(_=>xa(_,-1)),"aria-label":"Previous week",className:"p-1.5 rounded-md border border-gray-200 bg-white text-gray-600 hover:bg-gray-50",children:e.jsx(cr,{dir:"left"})}),e.jsx("button",{type:"button",onClick:()=>r(_=>xa(_,1)),"aria-label":"Next week",className:"p-1.5 rounded-md border border-gray-200 bg-white text-gray-600 hover:bg-gray-50",children:e.jsx(cr,{dir:"right"})}),e.jsx("span",{className:"text-[13px] font-semibold text-gray-700 min-w-[150px] text-right",children:B})]})]}),e.jsx("div",{className:"overflow-x-auto pb-1",children:e.jsx("div",{className:"grid grid-cols-7 gap-2 min-w-[760px]",children:R.map(_=>{const E=Gr(_,a),V=dn(_);return e.jsxs("button",{type:"button",onClick:()=>s(_),className:["text-left rounded-lg border bg-white px-3 py-2 transition-colors",E?"border-indigo-500 ring-1 ring-indigo-500":"border-gray-200 hover:border-gray-300"].join(" "),children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[e.jsx("span",{className:"text-[12px] font-bold text-gray-700",children:ge(_,"EEE d")}),V&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide text-indigo-700 bg-indigo-50 border border-indigo-200 rounded-full px-1.5 py-px",children:"Today"})]}),M.length===0?e.jsx("div",{className:"text-[11px] text-gray-300",children:"â"}):e.jsx("div",{className:"space-y-0.5",children:M.map(W=>{const K=D(_,W.key);return e.jsxs("div",{className:"flex items-center justify-between text-[11px] leading-tight",children:[e.jsx("span",{className:K>0?"text-gray-500":"text-gray-300",children:W.label}),e.jsx("span",{className:K>0?"font-semibold text-gray-700":"text-gray-300",children:K})]},W.key)})})]},pt(_))})})}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-4 mb-3",children:Kr.map(_=>{const E=n===_.key,V=R.reduce((W,K)=>W+D(K,_.key),0);return e.jsxs("button",{type:"button",onClick:()=>i(_.key),className:["px-3 py-1.5 rounded-full text-[12px] font-semibold border transition-colors",E?"bg-gray-900 text-white border-gray-900":"bg-white text-gray-600 border-gray-200 hover:bg-gray-50"].join(" "),children:[_.label,V>0&&e.jsx("span",{className:E?"ml-1.5 text-gray-300":"ml-1.5 text-gray-400",children:V})]},_.key)})}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 bg-gray-50 border-b border-gray-100",children:[e.jsx("span",{className:"text-[13px] font-bold text-gray-700",children:ge(a,"EEEE, MMMM d")}),e.jsx("span",{className:"text-[11px] font-semibold text-indigo-700 bg-indigo-50 rounded-full px-2 py-px",children:or[n]}),!x&&e.jsxs("span",{className:"ml-auto text-[11px] text-gray-400",children:[$.length," events"]})]}),x?e.jsx("div",{className:"px-4 py-12 text-center text-gray-500",children:"Loading calendarâ¦"}):h?e.jsx("div",{className:"px-4 py-12 text-center text-red-600",children:h}):$.length===0?e.jsxs("div",{className:"px-4 py-12 text-center text-gray-500",children:["No ",or[n].toLowerCase()," events for ",ge(a,"MMMM d"),"."]}):n==="earnings"?e.jsx(dd,{rows:$,onSelect:k}):n==="dividend"?e.jsx(hd,{rows:$,onSelect:k}):n==="economic"?e.jsx(xd,{rows:$,onSelect:k}):n==="ipo"?e.jsx(pd,{rows:$,onSelect:k}):n==="revenue"?e.jsx(fd,{rows:$,onSelect:k}):e.jsx(md,{rows:$,onSelect:k})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-3 text-[11px] text-gray-400",children:[e.jsx("span",{children:"Earnings: Yah
5oo Finance / Investing.com · Dividends: massive.com · Economic: FRED · IPO: Nasdaq · Revenue: TWSE MOPS"}),c?.capped&&e.jsx("span",{className:"text-amber-600",children:"Showing top results by market cap (large week)."})]}),S&&e.jsx(yd,{event:S,onClose:()=>k(null)})]})}function dd({rows:t,onSelect:r}){return e.jsx("div",{className:"max-h-[62vh] overflow-y-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{className:"sticky top-0 bg-white",children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-gray-400 border-b border-gray-100",children:[e.jsx("th",{className:"text-left font-semibold px-4 py-2",children:"When"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Ticker"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Company"}),e.jsx("th",{className:"text-right font-semibold px-2 py-2",children:"Est. EPS"}),e.jsx("th",{className:"text-right font-semibold px-4 py-2",children:"Market cap"}),e.jsx("th",{className:"text-right font-semibold px-4 py-2",children:"Status"})]})}),e.jsx("tbody",{children:t.map(a=>{const s=ir(a.time);return e.jsxs("tr",{onClick:()=>r(a),className:"border-b border-gray-50 last:border-0 hover:bg-indigo-50/40 cursor-pointer",children:[e.jsx("td",{className:"px-4 py-2",children:e.jsx("span",{className:`inline-block text-[10.5px] font-semibold px-1.5 py-px rounded border ${sd[s]}`,children:Nn[s]})}),e.jsx("td",{className:"px-2 py-2 font-bold text-indigo-700",children:a.ticker}),e.jsx("td",{className:"px-2 py-2 max-w-[280px] truncate text-gray-700",children:a.name||"â"}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums text-gray-700",children:a.estimate!=null?a.estimate:"â"}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-gray-600",children:Lt(a.marketCap)||"â"}),e.jsx("td",{className:"px-4 py-2 text-right",children:e.jsx("span",{className:["text-[10px] font-bold uppercase tracking-wide rounded-full px-2 py-px border",a.reported?"text-emerald-700 bg-emerald-50 border-emerald-200":"text-gray-500 bg-gray-50 border-gray-200"].join(" "),children:a.reported?"Reported":"Scheduled"})})]},`${a.ticker}-${a.date}`)})})]})})}function hd({rows:t,onSelect:r}){return e.jsx("div",{className:"max-h-[62vh] overflow-y-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{className:"sticky top-0 bg-white",children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-gray-400 border-b border-gray-100",children:[e.jsx("th",{className:"text-left font-semibold px-4 py-2",children:"Ticker"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Company"}),e.jsx("th",{className:"text-right font-semibold px-2 py-2",children:"Amount"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Frequency"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Pay date"}),e.jsx("th",{className:"text-right font-semibold px-4 py-2",children:"Market cap"})]})}),e.jsx("tbody",{children:t.map(a=>e.jsxs("tr",{onClick:()=>r(a),className:"border-b border-gray-50 last:border-0 hover:bg-indigo-50/40 cursor-pointer",children:[e.jsx("td",{className:"px-4 py-2 font-bold text-indigo-700",children:a.ticker}),e.jsx("td",{className:"px-2 py-2 max-w-[260px] truncate text-gray-700",children:a.name||"â"}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums text-gray-700",children:An(a.amount,a.currency)||"â"}),e.jsx("td",{className:"px-2 py-2 text-gray-600",children:a.frequency!=null?Rn[a.frequency]??`${a.frequency}Ã/yr`:"â"}),e.jsx("td",{className:"px-2 py-2 text-gray-600",children:a.payDate?ge(ut(a.payDate),"MMM d, yyyy"):"â"}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-gray-600",children:Lt(a.marketCap)||"â"})]},`${a.ticker}-${a.date}`))})]})})}function Mn({level:t}){const r=t??0;return e.jsx("span",{className:"inline-flex items-center gap-0.5",title:Qa[r]||"â","aria-label":`Importance ${Qa[r]||"unknown"}`,children:[1,2,3].map(a=>e.jsx("span",{className:["inline-block w-1.5 h-1.5 rounded-full",a<=r?r>=3?"bg-red-500":r===2?"bg-amber-500":"bg-gray-400":"bg-gray-200"].join(" ")},a))})}function xd({rows:t,onSelect:r}){return e.jsx("div",{className:"max-h-[62vh] overflow-y-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{className:"sticky top-0 bg-white",children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-gray-400 border-b border-gray-100",children:[e.jsx("th",{className:"text-left font-semibold px-4 py-2",children:"Impact"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Event"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Country"}),e.jsx("th",{className:"text-right font-semibold px-2 py-2",children:"Actual"}),e.jsx("th",{className:"text-right font-semibold px-2 py-2",children:"Prior"}),e.jsx("th",{className:"text-left font-semibold px-4 py-2",children:"Unit"})]})}),e.jsx("tbody",{children:t.map((a,s)=>e.jsxs("tr",{onClick:()=>r(a),className:"border-b border-gray-50 last:border-0 hover:bg-indigo-50/40 cursor-pointer",children:[e.jsx("td",{className:"px-4 py-2",children:e.jsx(Mn,{level:a.importance})}),e.jsx("td",{className:"px-2 py-2 font-semibold text-gray-800",children:a.name||"â"}),e.jsx("td",{className:"px-2 py-2 text-gray-500",children:a.country||"US"}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums font-semibold text-gray-800",children:a.actual!=null?lr(a.actual):"â"}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums text-gray-500",children:lr(a.prior)}),e.jsx("td",{className:"px-4 py-2 text-gray-400 text-[11px]",children:a.unit||""})]},`${a.name}-${a.date}-${s}`))})]})})}function $n(t){return t.priceOffered!=null?`$${t.priceOffered.toFixed(2)}`:t.priceLow!=null&&t.priceHigh!=null?`$${t.priceLow.toFixed(2)}â$${t.priceHigh.toFixed(2)}`:t.priceLow!=null?`$${t.priceLow.toFixed(2)}`:"â"}const ud={priced:"text-emerald-700 bg-emerald-50 border-emerald-200",upcoming:"text-amber-700 bg-amber-50 border-amber-200"};function pd({rows:t,onSelect:r}){return e.jsx("div",{className:"max-h-[62vh] overflow-y-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{className:"sticky top-0 bg-white",children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-gray-400 border-b border-gray-100",children:[e.jsx("th",{className:"text-left font-semibold px-4 py-2",children:"Ticker"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Company"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Exchange"}),e.jsx("th",{className:"text-right font-semibold px-2 py-2",children:"Price"}),e.jsx("th",{className:"text-right font-semibold px-2 py-2",children:"Deal size"}),e.jsx("th",{className:"text-right font-semibold px-4 py-2",children:"Status"})]})}),e.jsx("tbody",{children:t.map((a,s)=>e.jsxs("tr",{onClick:()=>r(a),className:"border-b border-gray-50 last:border-0 hover:bg-indigo-50/40 cursor-pointer",children:[e.jsx("td",{className:"px-4 py-2 font-bold text-indigo-700",children:a.ticker||"â"}),e.jsx("td",{className:"px-2 py-2 max-w-[240px] truncate text-gray-700",children:a.name||"â"}),e.jsx("td",{className:"px-2 py-2 text-gray-500 text-[11px]",children:a.exch
5ange||"â"}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums text-gray-700",children:$n(a)}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums text-gray-600",children:Lt(a.dealSize)||"â"}),e.jsx("td",{className:"px-4 py-2 text-right",children:e.jsx("span",{className:["text-[10px] font-bold uppercase tracking-wide rounded-full px-2 py-px border",ud[a.status||""]||"text-gray-500 bg-gray-50 border-gray-200"].join(" "),children:a.status||"â"})})]},`${a.ticker}-${a.date}-${s}`))})]})})}function Ft(t){return t==null||!isFinite(t)?"â":`${t>0?"+":""}${t.toFixed(1)}%`}function Tt(t){return t==null?"text-gray-400":t>0?"text-emerald-600":t<0?"text-red-600":"text-gray-500"}function Cn(t){if(t==null||!isFinite(t))return"â";const r=t*1e3;return r>=1e12?`NT$${(r/1e12).toFixed(2)}T`:r>=1e9?`NT$${(r/1e9).toFixed(1)}B`:r>=1e6?`NT$${(r/1e6).toFixed(0)}M`:`NT$${r.toLocaleString()}`}function fd({rows:t,onSelect:r}){return e.jsx("div",{className:"max-h-[62vh] overflow-y-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{className:"sticky top-0 bg-white",children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-gray-400 border-b border-gray-100",children:[e.jsx("th",{className:"text-left font-semibold px-4 py-2",children:"Ticker"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Company"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Month"}),e.jsx("th",{className:"text-right font-semibold px-2 py-2",children:"Revenue"}),e.jsx("th",{className:"text-right font-semibold px-2 py-2",children:"MoM"}),e.jsx("th",{className:"text-right font-semibold px-4 py-2",children:"YoY"})]})}),e.jsx("tbody",{children:t.map((a,s)=>e.jsxs("tr",{onClick:()=>r(a),className:"border-b border-gray-50 last:border-0 hover:bg-indigo-50/40 cursor-pointer",children:[e.jsx("td",{className:"px-4 py-2 font-bold text-indigo-700",children:a.ticker||"â"}),e.jsx("td",{className:"px-2 py-2 max-w-[220px] truncate text-gray-700",children:a.name||"â"}),e.jsx("td",{className:"px-2 py-2 text-gray-500 text-[11px]",children:a.period||"â"}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums text-gray-700",children:Cn(a.revenue)}),e.jsx("td",{className:`px-2 py-2 text-right tabular-nums ${Tt(a.momPct)}`,children:Ft(a.momPct)}),e.jsx("td",{className:`px-4 py-2 text-right tabular-nums font-semibold ${Tt(a.yoyPct)}`,children:Ft(a.yoyPct)})]},`${a.ticker}-${a.date}-${s}`))})]})})}function md({rows:t,onSelect:r}){return e.jsx("div",{className:"max-h-[62vh] overflow-y-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{className:"sticky top-0 bg-white",children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-gray-400 border-b border-gray-100",children:[e.jsx("th",{className:"text-left font-semibold px-4 py-2",children:"Ticker"}),e.jsx("th",{className:"text-left font-semibold px-2 py-2",children:"Name"}),e.jsx("th",{className:"text-left font-semibold px-4 py-2",children:"Country"})]})}),e.jsx("tbody",{children:t.map((a,s)=>e.jsxs("tr",{onClick:()=>r(a),className:"border-b border-gray-50 last:border-0 hover:bg-indigo-50/40 cursor-pointer",children:[e.jsx("td",{className:"px-4 py-2 font-bold text-indigo-700",children:a.ticker}),e.jsx("td",{className:"px-2 py-2 truncate text-gray-700",children:a.name||"â"}),e.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.country||"â"})]},`${a.ticker}-${a.date}-${s}`))})]})})}function gd({month:t,selected:r,onMonth:a,onPick:s}){const n=Be(Br(t),_t),i=Array.from({length:42},(l,d)=>qr(n,d));return e.jsxs("div",{className:"absolute right-0 z-50 mt-2 w-64 rounded-lg border border-gray-200 bg-white p-3 shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("button",{type:"button",onClick:()=>a(da(t,-1)),"aria-label":"Previous month",className:"p-1 rounded text-gray-500 hover:bg-gray-100",children:e.jsx(cr,{dir:"left"})}),e.jsx("span",{className:"text-[12px] font-bold text-gray-700",children:ge(t,"MMMM yyyy")}),e.jsx("button",{type:"button",onClick:()=>a(da(t,1)),"aria-label":"Next month",className:"p-1 rounded text-gray-500 hover:bg-gray-100",children:e.jsx(cr,{dir:"right"})})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-0.5 text-center",children:[["M","T","W","T","F","S","S"].map((l,d)=>e.jsx("div",{className:"text-[9px] font-bold uppercase text-gray-400 py-1",children:l}
5,d)),i.map(l=>{const d=cn(l,t),c=Gr(l,r),u=dn(l);return e.jsx("button",{type:"button",onClick:()=>s(l),className:["text-[11.5px] rounded py-1 transition-colors",c?"bg-indigo-600 text-white font-bold":u?"text-indigo-700 font-bold hover:bg-indigo-50":d?"text-gray-700 hover:bg-gray-100":"text-gray-300 hover:bg-gray-50"].join(" "),children:ge(l,"d")},pt(l))})]})]})}function yd({event:t,onClose:r}){const a=[];if(a.push(["Date",ge(ut(t.date),"EEEE, MMMM d, yyyy")]),a.push(["Category",or[t.category]]),t.category==="earnings"){const s=ir(t.time);a.push(["Reporting time",Nn[s]]),a.push(["Consensus EPS",t.estimate!=null?String(t.estimate):"Not available"]),a.push(["Status",t.reported?"Reported":"Scheduled"]),t.sources&&a.push(["Sources",t.sources.split("+").map(n=>od[n.trim()]||n.trim()).join(", ")])}else t.category==="dividend"?(a.push(["Cash amount",An(t.amount,t.currency)||"â"]),a.push(["Frequency",t.frequency!=null?Rn[t.frequency]??`${t.frequency}Ã/yr`:"â"]),a.push(["Ex-dividend date",ge(ut(t.date),"MMM d, yyyy")]),t.recordDate&&a.push(["Record date",ge(ut(t.recordDate),"MMM d, yyyy")]),t.payDate&&a.push(["Pay date",ge(ut(t.payDate),"MMM d, yyyy")]),t.declarationDate&&a.push(["Declared",ge(ut(t.declarationDate),"MMM d, yyyy")])):t.category==="economic"?(a.push(["Impact",e.jsx(Mn,{level:t.importance})]),a.push(["Actual",t.actual!=null?lr(t.actual):"Not yet released"]),a.push(["Prior",lr(t.prior)]),t.unit&&a.push(["Unit",t.unit]),a.push(["Region",t.country||"US"])):t.category==="ipo"?(a.push(["Status",t.status||"â"]),t.exchange&&a.push(["Exchange",t.exchange]),a.push(["Offer price",$n(t)]),t.shares!=null&&a.push(["Shares offered",t.shares.toLocaleString()]),t.dealSize!=null&&a.push(["Deal size",Lt(t.dealSize)])):t.category==="revenue"&&(t.period&&a.push(["Month",t.period]),a.push(["Revenue",Cn(t.revenue)]),a.push(["MoM",e.jsx("span",{className:Tt(t.momPct),children:Ft(t.momPct)})]),a.push(["YoY",e.jsx("span",{className:Tt(t.yoyPct),children:Ft(t.yoyPct)})]),t.cumulativeYoyPct!=null&&a.push(["YTD YoY",e.jsx("span",{className:Tt(t.cumulativeYoyPct),children:Ft(t.cumulativeYoyPct)})]),a.push(["Region","Taiwan"]),t.note&&a.push(["Note",t.note]));return t.sicDescription&&a.push(["Industry",`${t.sicDescription}${t.sicCode?` · SIC ${t.sicCode}`:""}`]),t.marketCap!=null&&a.push(["Market cap",Lt(t.marketCap)]),e.jsx("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center bg-gray-900/45 p-4",onClick:r,children:e.jsxs("div",{className:"w-full max-w-md max-h-[85vh] flex flex-col rounded-xl border border-gray-200 bg-white shadow-2xl overflow-hidden",role:"dialog","aria-modal":"true","aria-label":`${t.ticker} details`,onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3.5 border-b border-gray-100",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xl font-extrabold tracking-tight text-gray-900",children:t.ticker||t.name||"â"}),e.jsx("div",{className:"text-[12px] text-gray-500",children:t.ticker?t.name||"â":or[t.category]})]}),e.jsx("button",{className:"text-2xl leading-none text-gray-400 hover:text-gray-600","aria-label":"Close",onClick:r,children:"Ã"})]}),e.jsxs("div",{className:"px-4 py-3 overflow-y-auto",children:[e.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2.5",children:a.map(([s,n],i)=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-[11px] font-bold uppercase tracking-wide text-gray-400 pt-0.5",children:s}),e.jsx("dd",{className:"text-[13px] text-gray-800 m-0",children:n})]},i))}),(t.category==="earnings"||t.category==="dividend")&&e.jsxs("a",{className:"inline-block mt-4 text-[12.5px] font-semibold text-indigo-700 hover:underline",href:id(t),target:"_blank",rel:"noopener noreferrer",children:["View ",t.ticker," filings on SEC EDGAR â"]})]})]})})}function bd({table:t,hidden:r=!1}){return e.jsxs("section",{className:`markets-slide-data${r?" markets-view-hidden":""}`,"aria-label":"Chart data",inert:r||void 0,children:[e.jsx("div",{className:"markets-data-scroll",children:e.jsxs("table",{className:"markets-data-table",children:[e.jsx("caption",{className:"markets-data-caption",children:t.caption}),e.jsx("thead",{children:e.jsx("tr",{children:t.columns.map(a=>e.jsx("th",{scope:"col",children:a},a))})}),e.jsx("tbody",{children:t.rows.map((a,s)=>e.jsx("tr",{children:a.map((n,i)=>e.jsx("td",{children:n},i))}
5,s))})]})}),e.jsx("p",{className:"markets-data-source",children:t.source})]})}const jd={"gdp-components":So,"unemployment-wages":wo,"fed-funds-rate":No,"federal-deficit":Ro,"consumer-sentiment":Ao,"treasury-yield-curve":Mo,"yield-curve-shape":$o,"eq-sp500-index":Do,"eq-shiller-pe":_o,"eq-pe-vs-returns":Fo,"eq-eps-growth":kr,"eq-growth-metrics":Sr,"eq-top10-combined":Lo,"eq-mag7-combined":Io,"eq-earnings-sector":kr,"eq-valuation-dispersion":ba,"eq-annual-returns":Oo,"eq-style-returns":Uo,"eq-top10-decade":Yo,"eq-returns-sector":Ho,"nonfarm-payrolls":Qi,"jolts-openings":yn,"jolts-hires":bn,"jolts-layoffs":jn,"labor-participation":Ji,"labor-force-growth":Zi,"inflation-components":el,"us-dollar":tl,"trade-balance":rl,"dm-rate-differentials":al,"household-debt-service":nl,delinquencies:sl,"federal-debt":ol,"federal-budget":il,"treasury-yields-nominal-real":ll,"credit-spreads":cl,"debt-levels":dl,"policy-rates":hl,"global-pmi":xl,"bank-lending":ul,"econ-tariffs":ba,"econ-net-worth-cohort":Sr,"econ-income-spending":Sr,"econ-tax-refunds":kr,"econ-hyperscaler-capex":kl,"econ-hyperscaler-cashflow":Rl,"ip-listed-companies":Wl},_d=new Set(["top-gainers-losers","sector-performance","index-comparison","put-call-ratio","rsp-spy-ratio","10yr-treasury","usd-sp500-correlation","advance-decline","vix","top50-by-sector","valuations-by-cap","fx-correlations","fx-bollinger-movers","consumer-balance","expansions-recessions","bear-bull-markets","top-10-days","ff-factors","fx-factors","insider-purchases","eq-correlations","equity-factors","ff-benchmark","data-gap-analysis","fx-dashboard","fx-candles","meme-stocks","eq-fcf-yield","jolts-combined","eq-mktcap-sector","stock-volume","ticker-volume","eps-growth","earnings-calendar","rates-2s10s","rates-yield-curve","rates-credit-spreads","rates-breakevens","rates-real-yield","rates-policy","rates-snapshot","treasury-curve-yoy","treasury-changes"]),vd={"top-gainers-losers":Go,"sector-performance":oi,"index-comparison":ui,"put-call-ratio":Ri,"rsp-spy-ratio":Mi,"10yr-treasury":Ci,"usd-sp500-correlation":Ti,"advance-decline":zi,vix:Hi,"top50-by-sector":qi,"valuations-by-cap":Xi,"fx-dashboard":Cc,"fx-candles":Hn,"fx-correlations":ml,"fx-bollinger-movers":yl,"consumer-balance":Cl,"expansions-recessions":_l,"bear-bull-markets":Fl,"top-10-days":Pl,"ff-factors":Vl,"ff-benchmark":Gl,"equity-factors":dc,"fx-factors":fc,"insider-purchases":Sc,"eq-correlations":Nc,"data-gap-analysis":Gc,"meme-stocks":ed,"eq-fcf-yield":nd,"jolts-combined":_c,"eq-mktcap-sector":Tc,"stock-volume":Lc,"ticker-volume":zc,"eps-growth":Kc,"earnings-calendar":cd,"rates-2s10s":ji,"rates-yield-curve":gi,"rates-credit-spreads":vi,"rates-breakevens":ki,"rates-real-yield":Si,"rates-policy":wi,"rates-snapshot":Ni,"treasury-curve-yoy":yi,"treasury-changes":bi};function kd(t){const r=new Date(t);return Number.isNaN(r.getTime())?null:r.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Fd({chart:t,chartIndex:r,totalCharts:a,data:s,ssrTable:n,freshness:i,loading:l,onPrev:d,onNext:c}){const u=t.queryId?vd[t.queryId]:null,x=t.queryId?jd[t.queryId]:null,p=t.queryId?s[t.queryId]??[]:[],h=t.commentary?.trim(),f=!!(h&&h!=="To be updated."),g=t.queryId?i?.[t.queryId]:void 0,m=g?kd(g):null,y=t.category==="daily-recap",b=!!(t.available&&n),[S,k]=o.useState("chart"),v=b&&S==="table";return e.jsxs("div",{className:"markets-slide",children:[e.jsxs("div",{className:"markets-slide-header",children:[e.jsxs("div",{className:"markets-slide-kicker",children:[e.jsx("span",{children:`Markets / ${Ln[t.category]??t.category}`}),t.available&&m&&e.jsx("span",{className:"markets-slide-asof",children:`As of ${m}`})]}),e.jsx("h1",{className:"markets-slide-title",children:t.title}),!y&&e.jsx("p",{className:"markets-slide-description",children:t.description})]}),b&&e.jsxs("div",{className:"markets-view-toggle",role:"group","aria-label":"Chart or data table",children:[e.jsx("button",{type:"button",className:`markets-view-toggle-btn${v?"":" is-active"}`,"aria-pressed":!v,onClick:()=>k("chart"),children:"Chart"}),e.jsx("button",{type:"button",className:`markets-view-toggle-btn${v?" is-active":""}`,"aria-pressed":v,onClick:()=>k("table"),children:"Table"})]}),e.jsx("div",{className:`markets-slide-chart${v?" markets-view-hidden":""}`,inert:v||void 0,children:t.available&&u?e.jsx("div",{style:{width:"100%"},children:e.jsx(u,{})}):t.available&&x&&p.length>0?e.jsx("div",{style:{width:"100%"},children:e.jsx(x,{data:p})}):l||t.available&&x&&p.length===0?e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{className:"markets-skeleton",style:{height:24,width:"50%",marginBottom:12}}),e.jsx("div",{className:"markets-skeleton",style:{height:300}})]}):e.jsxs("div",{className:"markets-coming-soon",children:[e.jsx("div",{className:"markets-coming-soon-icon",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[e.jsx("rect",{x:"4",y:"8",width:"40",height:"32",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M4 16h40",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M12 24l8 8 6-4 10 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsx("span",{className:"markets-coming-soon-label",children:"Coming Soon"}),e.jsx("span",{className:"markets-coming-soon-hint",children:"This chart requires additional data sources not yet available in our pipeline."})]})}),y&&t.description&&e.jsx("div",{className:"markets-slide-description-below",children:e.jsx("p",{className:"markets-slide-description",children:t.description})}),b&&n&&e.jsx(bd,{table:n,hidden:!v}),f&&e.jsxs("div",{className:"markets-slide-commentary",children:[e.jsx("h3",{className:"markets-slide-commentary-heading",children:"Commentary"}),e.jsx("p",{className:"markets-slide-commentary-text",children:h})]}),e.jsxs("div",{className:"markets-slide-footer",children:[e.jsx("span",{children:"Akyla / Markets"}),t.source&&e.jsx("span",{className:"markets-slide-source",children:`Source: ${t.source}`})]})]})}export{jd as C,Gc as D,vd as I,ci as S,_d as a,Fd as b,da as c,qr as d,xa as e,ge as f,ut as p,li as s,fe as t,Se as y};
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.