PageSourceSearch

https://stonksup.io/assets/SeasonalityPopup-CDxh2pfC.js

js stonksup.io collected 2026-09-24 15:03:53 UTC 8,556 bytes, 1 lines download raw bytes

1import{z as H,r as u,T as Z,j as r,C as q,E as K,U as O,D as I,R as V,V as G}from"./index-Tvz-Tq9B.js";const Q=["SPX","NDX","DJI","RUT"],T={SPX:"标普500",NDX:"纳指100",DJI:"道指",RUT:"罗素2000"};function ee(e,l){return e(`dashboard.seasonality.index.${l}`,T[l]??l)}const ne=["current_year","overall","midterm_year","election_year","post_election_year","pre_election_year"],te={overall:"#EAC051",midterm_year:"#47AFD2",election_year:"#9752F7",post_election_year:"#CB8AB5",pre_election_year:"#874D2B"},L=440,X=1180,N=400,y=20,oe=76,_=22,re=44,C=X-y-oe,R=N-_-re,F=["01-01","03-01","05-01","07-01","09-01","11-01","12-01"];function B(e,l,i=!1){return i||l==="current_year"?e.fg1:te[l]??e.fg4}function U(e,l=2){if(e==null)return"—";const i=e*100;return`${i>=0?"+":""}${i.toFixed(l)}%`}function ie(e){const l=Math.round(e*100);return`${l>=0?"+":""}${l}%`}function le(e,l=!1){const[i,d]=e.split("/"),s=parseInt(i,10),f=parseInt(d,10);return!s||!f?e:l?`${s}月${f}日`:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s-1]??i} ${f}`}function se({T:e,value:l,onChange:i}){const{t:d}=H(),[s,f]=u.useState(null);return r.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,alignSelf:"flex-start",maxWidth:"100%",overflowX:"auto",boxSizing:"border-box"},children:[r.jsx("span",{style:{color:e.fg5,fontSize:12,flex:"0 0 auto",lineHeight:"26px"},children:d("dashboard.seasonality.indexLabel","Index")}),Q.map(x=>{const t=x===l;return r.jsx("button",{onClick:()=>i(x),onMouseEnter:()=>f(x),onMouseLeave:()=>f(null),style:{height:26,flex:"0 0 auto",padding:"0 10px",border:"none",borderRadius:V.xs,background:t||s===x?e.bgControl:"transparent",color:t?e.fg1:e.fg4,boxShadow:"none",outline:"none",fontSize:13,fontFamily:"inherit",letterSpacing:0,cursor:"pointer",transition:"background .15s, color .15s"},children:ee(d,x)},x)})]})}function ae({T:e,series:l,dateIndex:i,visible:d,onToggle:s}){const{t:f}=H(),x=ne.map(t=>l.find(h=>h.name===t)).filter(t=>!!t);return r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:7},children:x.map(t=>{const h=d.has(t.name),a=B(e,t.name,t.isCurrent),S=i>=0&&i<t.values.length?t.values[i]:null;return r.jsxs("button",{onClick:()=>s(t.name),style:{display:"grid",gridTemplateColumns:"18px minmax(0, 1fr) auto",alignItems:"center",gap:8,width:"100%",minHeight:26,padding:"2px 0",border:"none",background:"transparent",outline:"none",color:h?e.fg1:e.fg5,cursor:"pointer",fontFamily:"inherit",fontWeight:400,lineHeight:1.3,textAlign:"left"},children:[r.jsx("span",{style:{width:12,height:12,borderRadius:3,border:`1px solid ${a}`,background:h?a:"transparent",display:"inline-flex",alignItems:"center",justifyContent:"center",color:t.isCurrent?e.bgPage:"#fff",fontSize:8.5,lineHeight:"12px",boxSizing:"border-box"},children:h?"✓":""}),r.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13,lineHeight:1.3,color:h?e.fg1:e.fg5},children:G(f,t.name,t.label)}),r.jsx("span",{style:{fontSize:13,lineHeight:1.3,color:h?e.fg1:e.fg5,textAlign:"right",...I},children:U(S)})]},t.name)})})}function ce({T:e,dates:l,series:i,visible:d,currentLastIndex:s}){const{t:f}=H(),x=u.useRef(null),[t,h]=u.useState(null),a=l.length,S=u.useMemo(()=>{const n=i.filter(o=>d.has(o.name));return n.length>0?n:i},[i,d]),{yMin:w,yMax:k,gridLines:$}=u.useMemo(()=>{let n=null,o=null;for(const M of S){const Y=M.isCurrent?Math.max(0,s+1):M.values.length;for(let W=0;W<Y;W++){const E=M.values[W];E!=null&&(n=n==null?E:Math.min(n,E),o=o==null?E:Math.max(o,E))}}(n==null||o==null)&&(n=-.05,o=.05);const c=.05,g=Math.floor(n/c)*c,p=Math.ceil(o/c)*c,j=g===p?g-c:g,z=g===p?p+c:p,J=[];for(let M=j;M<=z+c/2;M+=c)J.push(Number(M.toFixed(4)));return{yMin:j,yMax:z,gridLines:J}},[S,s]),v=u.useCallback(n=>a<=1?y:y+n/(a-1)*C,[a]),b=u.useCallback(n=>{const o=k-w||1;return _+R-(n-w)/o*R},[w,k]),m=u.useMemo(()=>[...i.filter(o=>!o.isCurrent&&d.has(o.name)),...i.filter(o=>o.isCurrent&&d.has(o.name))].map(o=>{const c=o.isCurrent?Math.max(0,s+1):o.values.length,g=[];let p=!1;for(let j=0;j<c&&j<a;j++){const z=o.values[j];if(z==null){p=!1;continue}g.push(`${p?"L":"M"}${v(j).toFixed(1)},${b(z).toFixed(1)}`),p=!0}return{name:o.name,isCurrent:o.isCurrent,d:g.join(" "),color:B(e,o.name,o.isCurrent)}}),[e,i,d,s,a,v,b]),A=u.useMemo(()=>
1{if(s<0||s>=a||!d.has("current_year"))return null;const n=i.find(c=>c.isCurrent),o=n==null?void 0:n.values[s];return o==null?null:{x:v(s),y:b(o)}},[s,a,i,d,v,b]),P=u.useCallback(n=>{const o=x.current;if(!o||a===0)return;const c=o.getBoundingClientRect(),g=(n.clientX-c.left)/c.width*X;if(g<y||g>y+C){h(null);return}const p=Math.round((g-y)/C*(a-1));h(Math.max(0,Math.min(a-1,p)))},[a]),D=u.useMemo(()=>t==null?[]:i.filter(n=>d.has(n.name)).map(n=>{const o=n.isCurrent?Math.max(0,s+1):n.values.length,c=t<o?n.values[t]:null;return{...n,value:c}}),[i,d,t,s]);return a<2?r.jsx(O,{T:e,style:{height:L,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",color:e.fg5,fontSize:13},children:f("dashboard.seasonality.insufficientData","Insufficient data")}):r.jsx(O,{T:e,style:{height:L,boxSizing:"border-box",padding:"12px 14px 10px",borderColor:e.hairline,display:"flex",flexDirection:"column"},children:r.jsxs("div",{style:{position:"relative",flex:1,minHeight:0},children:[r.jsxs("svg",{ref:x,viewBox:`0 0 ${X} ${N}`,style:{width:"100%",height:"100%",display:"block",overflow:"visible"},onMouseMove:P,onMouseLeave:()=>h(null),children:[$.map(n=>{const o=Math.abs(n)<1e-4;return r.jsxs("g",{children:[r.jsx("line",{x1:y,y1:b(n),x2:y+C,y2:b(n),stroke:o?e.gain:e.borderWeak,strokeWidth:o?1.6:1,strokeDasharray:"5,5"}),r.jsx("text",{x:y+C+8,y:b(n)+4,fontSize:10,fill:o?e.gain:e.fg4,style:I,children:ie(n)})]},n)}),m.map(n=>r.jsx("path",{d:n.d,fill:"none",stroke:n.color,strokeWidth:n.isCurrent?2.4:2,strokeLinecap:"round",strokeLinejoin:"round"},n.name)),A&&r.jsx("circle",{cx:A.x,cy:A.y,r:5,fill:e.fg1}),r.jsx("line",{x1:y,y1:_+R,x2:y+C,y2:_+R,stroke:e.fg4,strokeWidth:1.2}),F.map((n,o)=>{const c=y+o/(F.length-1)*C,g=o===0?"start":o===F.length-1?"end":"middle";return r.jsx("text",{x:c,y:N-8,fontSize:10,fill:e.fg4,textAnchor:g,children:n},n)}),t!=null&&r.jsx("line",{x1:v(t),y1:_,x2:v(t),y2:_+R,stroke:e.fg5,strokeWidth:1.2,strokeDasharray:"3,4"})]}),t!=null&&r.jsxs("div",{style:{position:"absolute",top:8,left:t<a/2?void 0:12,right:t<a/2?12:void 0,minWidth:160,padding:"8px 10px",borderRadius:V.xs,border:`1px solid ${e.border}`,background:e.bgCard,boxShadow:e.shadow,pointerEvents:"none",zIndex:2},children:[r.jsx("div",{style:{fontSize:12,color:e.fg1,marginBottom:6,...I},children:l[t]}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:D.map(n=>r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",gap:10,alignItems:"center"},children:[r.jsx("span",{style:{minWidth:0,color:B(e,n.name,n.isCurrent),fontSize:11.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:G(f,n.name,n.label)}),r.jsx("span",{style:{color:e.fg2,fontSize:11.5,...I},children:U(n.value)})]},n.name))})]})]})})}function ue({T:e,onSelectSymbol:l}){const{t:i,i18n:d}=H(),s=d.language.startsWith("zh"),[f,x]=u.useState("SPX"),{data:t,isLoading:h,error:a}=Z(f),[S,w]=u.useState(null),k=u.useMemo(()=>S??(t?new Set(t.series.map(m=>m.name)):new Set),[S,t]),$=u.useMemo(()=>{if(!t)return-1;if(t.currentMaxDate){const m=t.dates.indexOf(t.currentMaxDate);if(m>=0)return m}return t.currentLastIndex},[t]),v=u.useCallback(m=>{w(A=>{const P=A??(t?new Set(t.series.map(n=>n.name)):new Set),D=new Set(P);return D.has(m)?D.delete(m):D.add(m),D})},[t]),b=u.useCallback(m=>{x(m)},[]);return h?r.jsx(q,{T:e,rows:5}):a||!t?r.jsx(K,{T:e,msg:a?i("dashboard.seasonality.loadFailed","Failed to load - {{error}}").replace("{{error}}",a.message):i("dashboard.seasonality.noData","No data available")}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[r.jsx(se,{T:e,value:f,onChange:b}),r.jsxs("div",{style:{display:"flex",gap:12,alignItems:"stretch"},children:[r.jsxs(O,{T:e,style:{width:260,height:L,boxSizing:"border-box",flexShrink:0,display:"flex",flexDirection:"column",gap:12},children:[t.currentMaxDate&&r.jsx("div",{style:{fontSize:13.5,lineHeight:1.3,color:e.fg4,...I},children:le(t.currentMaxDate,s)}),r.jsx(ae,{T:e,series:t.series,dateIndex:$,visible:k,onToggle:v})]}),r.jsx("div",{style:{flex:"1 1 0",minWidth:0,height:L},children:r.jsx(ce,{T:e,dates:t.dates,series:t.series,visible:k,currentLastIndex:t.currentLastIndex})})]})]})}export{ue as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.