PageSourceSearch

https://betting-insight-ai--guybostonvideo.replit.app/assets/mlb-matchup-analyzer-BpG6B2ds.js

js betting-insight-ai--guybostonvideo.replit.app collected 2026-10-03 03:50:24 UTC 51,753 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-DVg5vlja.js";import{L as Ve,A as qe,h as Be,v as _e}from"./layout-G0LJ2LXm.js";import{u as U}from"./vendor-query-DdcG7b8d.js";import{r as p}from"./vendor-charts-0WqoWmMF.js";import{s as We,X as ke,k as $}from"./index-BNgjLe9x.js";import{a as $e,k as Ie,b as De,e as Ae,w as ze}from"./stat-colors-E6McqK7h.js";import{aj as Xe}from"./api-KerIgBCD.js";import{P as Ye}from"./Paywall-B7-n_Y6z.js";import{M as Je}from"./ballpark-weather-BLC3-sxY.js";import{P as He}from"./player-link-BKjIUlGg.js";import{g as re}from"./eastern-time-DFIOOphU.js";import{L as ve}from"./input-Czw0F4nb.js";import"./vendor-react-BzrpNAyj.js";import"./lock-D_2SkQQO.js";import"./sparkles-DqgMBXP8.js";import"./chevron-up-nwO4_gQL.js";import"./wind-DkY3JS8O.js";import"./eye-CIkMmiSg.js";import"./format-xtqViEWm.js";import"./differenceInCalendarDays-CrzntjZV.js";const v={avg:{min:.175,max:.345},slg:{min:.3,max:.63},k:{min:9,max:40},xwoba:{min:.245,max:.435},barrel:{min:.5,max:21},iso:{min:.04,max:.295},fip:{min:2,max:6},ops:{min:.5,max:.98},wrc:{min:60,max:160},hrPer9:{min:.4,max:2.2},blast:{min:5,max:25}};function I(t,r,s){return Math.min(100,Math.max(0,(t-r)/(s-r)*100))}function me(t){return t.length===0?null:t.reduce((r,s)=>r+s,0)/t.length}function Q(t,r){return Math.max(-1,Math.min(1,t/r))}function Qe(t){const r=[];return t.avg!=null&&r.push(I(t.avg,v.avg.min,v.avg.max)),t.ops!=null&&r.push(I(t.ops,v.ops.min,v.ops.max)),t.kPct!=null&&r.push(100-I(t.kPct,v.k.min,v.k.max)),me(r)}function Ze(t){const r=[];t.avg!=null&&r.push(100-I(t.avg,v.avg.min,v.avg.max));const s=t.xwoba??t.woba??null;return s!=null&&r.push(100-I(s,v.xwoba.min,v.xwoba.max)),t.kRate!=null&&r.push(I(t.kRate,v.k.min,v.k.max)),t.whiffPct!=null&&r.push(I(t.whiffPct,15,40)),me(r)}function et(t){const r=[];return t.wrcPlus!=null&&r.push(I(t.wrcPlus,v.wrc.min,v.wrc.max)),t.slg!=null&&r.push(I(t.slg,v.slg.min,v.slg.max)),t.iso!=null&&r.push(I(t.iso,v.iso.min,v.iso.max)),t.ops!=null&&r.push(I(t.ops,v.ops.min,v.ops.max)),t.blastPct!=null&&r.push(I(t.blastPct,v.blast.min,v.blast.max)),me(r)}function tt(t){const r=[];t.barrelRate!=null&&r.push(100-I(t.barrelRate,v.barrel.min,v.barrel.max)),t.hrPer9!=null&&r.push(100-I(t.hrPer9,v.hrPer9.min,v.hrPer9.max));const s=t.xera??t.fip??null;return s!=null&&r.push(100-I(s,v.fip.min,v.fip.max)),me(r)}function Oe(t,r,s,u){const f=[];if(t.avg!=null&&r.avg!=null){const j=(r.avg-.244)*100-(.244-t.avg)*100;f.push(Q(j,15))}if(t.obp!=null&&r.obp!=null){const j=(r.obp-.315)*100-(.315-t.obp)*100;f.push(Q(j,15))}if(t.kRate!=null&&r.kPct!=null){const j=22.5-r.kPct-(t.kRate-22.5);f.push(Q(j,10))}if(t.bbRate!=null&&r.bbPct!=null){const j=r.bbPct-8.5-(8.5-t.bbRate);f.push(Q(j,8))}const L=Qe(r),N=Ze(t);L!=null&&N!=null&&f.push(Q(L-N,25));const P=et(r),w=tt(t);if(P!=null&&w!=null&&f.push(Q(P-w,25)),f.length===0)return 50;const C=50+f.reduce((j,k)=>j+k,0)/f.length*25,R=r.wrcPlus!=null?Math.max(-8,Math.min(8,(r.wrcPlus-100)/10*1.4)):0,S=t.era!=null&&t.fip!=null?t.era*.6+t.fip*.4:t.era??t.fip??null,D=S!=null?Math.max(-8,Math.min(8,-(4.25-S)*2)):0;return Math.round(Math.max(10,Math.min(90,C+R+D+0)))}function ie({mlbamId:t,name:r,size:s=52}){const[u,f]=p.useState(!1),L=r.split(" ").map(B=>B[0]).join("").slice(0,2).toUpperCase(),N=["bg-blue-600","bg-purple-600","bg-green-700","bg-orange-600","bg-teal-600","bg-rose-600"],P=r.charCodeAt(0)%N.length,w={width:s,height:s,fontSize:s*.34};return!t||u?e.jsx("div",{className:$("rounded-full flex items-center justify-center text-white font-bold shrink-0 border-2 border-border",N[P]),style:w,children:L||"?"}):e.jsx("div",{className:"rounded-full overflow-hidden border-2 border-border shrink-0 bg-muted",style:w,children:e.jsx("img",{src:`/api/mlb/headshot/${t}`,alt:r,className:"w-full h-full object-cover object-top",onError:()=>f(!0)})})}const rt={ARI:{primary:"#A71930",secondary:"#E3D4AD"},ATL:{primary:"#CE1141",secondary:"#13274F"},BAL:{primary:"#DF4601",secondary:"#000000"},BOS:{primary:"#BD3039",secondary:"#0C2340"},CHC:{primary:"#0E3386",secondary:"#0a2351"},CHW:{primary:"#27251F",secondary:"#C4CED4"},CWS:{primary:"#27251F",secondary:"#C4CED4"},CIN:{primary:"#C6011F",secondary:"#000000"},CLE:{primary:"#00385D",secondary:"#E50022"},COL:{primary:"#333366",secondary:"#131413"},DET:{primary:"#0C2340",secondary:"#FA4616"},HOU:{primary:"#002D62",secondary:"#EB6E1F"},KC:{primary:"#004687",secondary:"#BD9B60"},LAA:{primary:"#BA0021",secondary:"#003263"},LAD:{primary:"#005A9C",secondary:"#002F6C"},MIA:{primary:"#00A3E0",secondary:"#EF3340"},MIL:{primary:"#12284B",secondary:"#B6922E"},MIN:{primary:"#002B5C",secondary:"#D31145"},NYM:{primary:"#002D72",secondary:"#FF5910"},NYY:{primary:"#003087",secondary:"#C4CED4"},OAK:{primary:"#003831",secondary:"#EFB21E"},ATH:{primary:"#003831",secondary:"#EFB21E"},PHI:{primary:"#E81828",secondary:"#002D72"},PIT:{primary:"#27251F",secondary:"#FDB827"},SD:{primary:"#2F241D",secondary:"#FFC425"},SF:{primary:"#FD5A1E",secondary:"#27251F"},SEA:{primary:"#0C2C56",secondary:"#005C5C"},STL:{primary:"#C41E3A",secondary:"#0C2340"},TB:{primary:"#092C5C",secondary:"#8FBCE6"},TEX:{primary:"#003278",secondary:"#C0111F"},TOR:{primary:"#134A8E",secondary:"#1D2D5C"},WSH:{primary:"#AB0003",secondary:"#14225A"}};function Te(t){return rt[(t||"").toUpperCase()]||{primary:"#334155",secondary:"#1e293b"}}const x={avg:{min:.175,max:.345},obp:{min:.26,max:.43}
1,slg:{min:.3,max:.63},bb:{min:3,max:16.5},k:{min:9,max:40},xwoba:{min:.245,max:.435},barrel:{min:.5,max:21},xslg:{min:.27,max:.6},iso:{min:.04,max:.295},hardHit:{min:20,max:58},exitVelo:{min:82.5,max:96},era:{min:1.8,max:6.5},ops:{min:.5,max:.98},wrc:{min:60,max:160},hrPer9:{min:.4,max:2.2},blast:{min:5,max:25}};function T(t,r,s){return Math.min(100,Math.max(0,(t-r)/(s-r)*100))}function ce(t){if(!t)return"";const r=t.trim().split(/\s+/),s=new Set(["jr","jr.","sr","sr.","ii","iii","iv","v"]);return r.length>1&&s.has(r[r.length-1].toLowerCase())?r.slice(-2).join(" "):r[r.length-1]}const at=t=>t<.3?"text-green-400":t<.34?"text-foreground":"text-red-400",st=t=>t>.275?"text-green-400":t>.24?"text-foreground":"text-red-400",nt=t=>t>.35?"text-green-400":t>.31?"text-foreground":"text-red-400",ot=t=>t<16?"text-green-400":t<22?"text-foreground":"text-red-400",lt=t=>t>9?"text-green-400":t>6?"text-foreground":"text-red-400",de=t=>t>=60?"text-green-400":t>=40?"text-foreground":"text-red-400";function ue(t){return t.length===0?null:t.reduce((r,s)=>r+s,0)/t.length}function it(t,r){const s=[];t.avg!=null&&s.push(T(t.avg,x.avg.min,x.avg.max));const u=r?.xwoba??null;return u!=null&&s.push(T(u,x.xwoba.min,x.xwoba.max)),t.ops!=null&&s.push(T(t.ops,x.ops.min,x.ops.max)),t.kPct!=null&&s.push(100-T(t.kPct,x.k.min,x.k.max)),ue(s)}function ct(t){const r=[];t.avg!=null&&r.push(100-T(t.avg,x.avg.min,x.avg.max));const s=t.woba??t.xwoba??null;return s!=null&&r.push(100-T(s,x.xwoba.min,x.xwoba.max)),t.kRate!=null&&r.push(T(t.kRate,x.k.min,x.k.max)),ue(r)}function dt(t,r){const s=[];return t.wrcPlus!=null&&s.push(T(t.wrcPlus,x.wrc.min,x.wrc.max)),t.slg!=null&&s.push(T(t.slg,x.slg.min,x.slg.max)),t.iso!=null&&s.push(T(t.iso,x.iso.min,x.iso.max)),t.ops!=null&&s.push(T(t.ops,x.ops.min,x.ops.max)),r?.barrelPct!=null&&s.push(T(r.barrelPct,x.barrel.min,x.barrel.max)),t.blastPct!=null&&s.push(T(t.blastPct,x.blast.min,x.blast.max)),ue(s)}function mt(t){const r=[];t.barrelRate!=null&&r.push(100-T(t.barrelRate,x.barrel.min,x.barrel.max)),t.hrPer9!=null&&r.push(100-T(t.hrPer9,x.hrPer9.min,x.hrPer9.max));const s=t.xera??t.fip??null;return s!=null&&r.push(100-T(s,x.era.min,x.era.max)),ue(r)}const ut=[{key:"ba",label:"AVG",pitcherGet:t=>t.avg,batterGet:(t,r)=>t.avg,range:x.avg,fmtP:t=>t.toFixed(3).replace(/^0/,""),fmtB:t=>t.toFixed(3).replace(/^0/,""),colorP:$e,colorB:st,batterFavoredHigh:!0,pitcherFavoredLow:!0,customEdgeDiff:(t,r)=>{const u=(r-.244)*100,f=(.244-t)*100;return u-f}},{key:"obp",label:"OBP",pitcherGet:t=>t.obp,batterGet:(t,r)=>t.obp,range:x.obp,fmtP:t=>t.toFixed(3).replace(/^0/,""),fmtB:t=>t.toFixed(3).replace(/^0/,""),colorP:at,colorB:nt,batterFavoredHigh:!0,pitcherFavoredLow:!0,customEdgeDiff:(t,r)=>{const u=(r-.315)*100,f=(.315-t)*100;return u-f}},{key:"k",label:"K%",pitcherGet:t=>t.kRate,batterGet:(t,r)=>t.kPct,range:x.k,fmtP:t=>t.toFixed(1)+"%",fmtB:t=>t.toFixed(1)+"%",colorP:Ie,colorB:ot,batterFavoredHigh:!1,pitcherFavoredLow:!1,customEdgeDiff:(t,r)=>{const u=22.5-r,f=t-22.5;return u-f}},{key:"bb",label:"BB%",pitcherGet:t=>t.bbRate,batterGet:(t,r)=>t.bbPct,range:x.bb,fmtP:t=>t.toFixed(1)+"%",fmtB:t=>t.toFixed(1)+"%",colorP:De,colorB:lt,batterFavoredHigh:!0,pitcherFavoredLow:!0,customEdgeDiff:(t,r)=>{const u=r-8.5,f=8.5-t;return u-f}},{key:"contact",label:"Contact",pitcherGet:t=>ct(t),batterGet:(t,r)=>it(t,r),range:{min:0,max:100},fmtP:t=>Math.round(t).toString(),fmtB:t=>Math.round(t).toString(),colorP:de,colorB:de,batterFavoredHigh:!0,pitcherFavoredLow:!1},{key:"power",label:"Power",pitcherGet:t=>mt(t),batterGet:(t,r)=>dt(t,r),range:{min:0,max:100},fmtP:t=>Math.round(t).toString(),fmtB:t=>Math.round(t).toString(),colorP:de,colorB:de,batterFavoredHigh:!0,pitcherFavoredLow:!1}];function xt(t,r,s,u){return Oe(t,r)}const Re=[{key:"barrel",label:"Barrel%",get:(t,r)=>r?.barrelPct??null,range:x.barrel,fmt:t=>t.toFixed(1)+"%"},{key:"hardHit",label:"HardHit%",get:(t,r)=>r?.hardHitPct??null,range:x.hardHit,fmt:t=>t.toFixed(1)+"%"},{key:"xslg",label:"xSLG",get:(t,r)=>r?.xslg??null,range:x.xslg,fmt:t=>t.toFixed(3).replace(/^0/,"")},{key:"ev",label:"Avg EV",get:(t,r)=>r?.exitVelo??null,range:x.exitVelo,fmt:t=>t.toFixed(1)+" mph"}];function Le({label:t,pVal:r,bVal:s,range:u,fmtP:f,fmtB:L,batterFavoredHigh:N,customEdgeDiff:P}){const w=r!=null?T(r,u.min,u.max):null,B=s!=null?T(s,u.min,u.max):null;let C=!1,R=!1;if(r!=null&&s!=null){let j;if(P)j=P(r,s);
1else{const k=(B??0)-(w??0);j=N?k:-k}j>5?C=!0:j<-5&&(R=!0)}const S=R?"bg-green-500/70":C?"bg-red-500/50":"bg-slate-500/50",D=w==null&&B!=null?"bg-blue-500/55":C?"bg-green-500/70":R?"bg-red-500/50":"bg-slate-500/50";return e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[e.jsx("div",{className:"w-[60px] text-right text-xs font-mono text-muted-foreground",children:r!=null?f(r):e.jsx("span",{className:"text-muted-foreground/40",children:"—"})}),e.jsx("div",{className:"flex-1 flex justify-end h-4 bg-muted/20 rounded-l overflow-hidden",children:w!=null&&e.jsx("div",{className:$("h-full rounded-l transition-all duration-300",S),style:{width:`${w}%`}})}),e.jsx("div",{className:"w-[58px] shrink-0 text-center text-[11px] font-semibold text-muted-foreground tracking-wide",children:t}),e.jsx("div",{className:"flex-1 h-4 bg-muted/20 rounded-r overflow-hidden",children:B!=null&&e.jsx("div",{className:$("h-full rounded-r transition-all duration-300",D),style:{width:`${B}%`}})}),e.jsx("div",{className:"w-[60px] text-left text-xs font-mono text-muted-foreground",children:s!=null?L(s):e.jsx("span",{className:"text-muted-foreground/40",children:"—"})})]})}function ht({score:t}){const r=t>=60?"text-green-400":t<=40?"text-red-400":"text-muted-foreground";return e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("div",{className:"relative flex-1 h-2 rounded-full bg-gradient-to-r from-red-500/30 via-muted/30 to-green-500/30",children:e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 w-0.5 h-4 bg-white/75 rounded-full shadow-sm",style:{left:`calc(${t}% - 1px)`}})}),e.jsx("span",{className:$("text-xs font-mono font-semibold w-6 text-right shrink-0",r),children:t})]})}function pt({data:t,split:r}){if(!t||!r)return null;const s=(m,j=2)=>m==null||isNaN(m)?"—":m.toFixed(j),u=m=>m==null||isNaN(m)?"—":m.toFixed(3).replace(/^0/,""),f=m=>m==null||isNaN(m)?"—":m.toFixed(1)+"%",L=m=>m?m<3.5?"text-green-400":m<4.5?"text-foreground":"text-red-400":"text-muted-foreground",N=m=>m?m<.3?"text-green-400":m<.34?"text-foreground":"text-red-400":"text-muted-foreground",P=m=>m?m<.29?"text-green-400":m<.33?"text-foreground":"text-red-400":"text-muted-foreground",w=m=>m?m<5?"text-green-400":m<10?"text-foreground":"text-red-400":"text-muted-foreground",B=m=>m?m<.8?"text-green-400":m<1.3?"text-foreground":"text-red-400":"text-muted-foreground",C=m=>m?m>50?"text-green-400":m>43?"text-foreground":"text-red-400":"text-muted-foreground",R=m=>m?m<13?"text-green-400":m<16?"text-foreground":"text-red-400":"text-muted-foreground",S=r.era??t.overall?.era??null,D=[{label:"ERA",value:s(S),color:Ae(S)},{label:"WHIP",value:s(r.whip),color:ze(r.whip)},{label:"FIP",value:s(r.fip),color:L(r.fip)},{label:"K%",value:f(r.kRate),color:Ie(r.kRate)},{label:"BB%",value:f(r.bbRate),color:De(r.bbRate)},{label:"BAA",value:u(r.avg),color:$e(r.avg)},{label:"OBP-Against",value:u(r.obp),color:N(r.obp)},{label:"wOBA-Against",value:u(r.woba),color:P(r.woba)},{label:"xwOBA",value:u(r.xwoba),color:P(r.xwoba)},{label:"xERA",value:s(r.xera),color:Ae(r.xera)},{label:"Barrel%",value:f(r.barrelRate),color:w(r.barrelRate)},{label:"HR/9",value:s(r.hrPer9),color:B(r.hrPer9)},{label:"GB%",value:f(r.gbPct),color:C(r.gbPct)},{label:"Blast%",value:f(r.blastContactPct),color:R(r.blastContactPct)}];return e.jsx("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1 mt-3",children:D.map(m=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:m.label}),e.jsx("span",{className:$("font-mono font-medium",m.color),children:m.value})]},m.label))})}function ft({profile:t,split:r,savant:s}){if(!t||!r)return null;const u=n=>n==null||isNaN(n)?"—":n.toFixed(3).replace(/^0/,""),f=n=>n==null||isNaN(n)?"—":n.toFixed(1)+"%",L=(n,_=1)=>n==null||isNaN(n)?"—":n.toFixed(_),N=n=>n?n>.275?"text-green-400":n>.24?"text-foreground":"text-red-400":"text-muted-foreground",P=n=>n?n>.35?"text-green-400":n>.31?"text-foreground":"text-red-400":"text-muted-foreground",w=n=>n?n>.45?"text-green-400":n>.38?"text-foreground":"text-red-400":"text-muted-foreground",B=n=>n?n>.8?"text-green-400":n>.7?"text-foreground":"text-red-400":"text-muted-foreground",C=n=>n?n>.18?"text-green-400":n>.12?"text-foreground":"text-red-400":"text-muted-foreground",R=n=>n?n<16?"text-green-400":n<22?"text-foreground":"text-red-400":"text-muted-foreground",S=n=>n?n>9?"text-green-400":n>6?"text-foreground":"text-red-400":"text-muted-foreground",D=n=>n?n>115?"text-green-400":n>90?"text-foreground":"text-red-400":"text-muted-foreground",m=n=>n?n>.34?"text-green-400":n>.3?"text-foreground":"text-red-400":"text-muted-foreground",j=n=>n?n>10?"text-green-400":n>6?"text-foreground":"text-red-400":"text-muted-foreground",k=n=>n?n>45?"text-green-400":n>38?"text-foreground":"text-red-400":"text-muted-foreground",q=n=>n?n>91?"text-green-400":n>87?"text-foreground":"text-red-400":"text-muted-foreground",g=[{label:"AVG",value:u(r.avg),color:N(r.avg)},{label:"OBP",value:u(r.obp),color:P(r.obp)},{label:"SLG",value:u(r.slg),color:w(r.slg)},{label:"OPS",value:u(r.ops),color:B(r.ops)},{label:"ISO",value:u(r.iso),color:C(r.iso)},{label:"K%",value:f(r.kPct),color:R(r.kPct)},{label:"BB%",value:f(r.bbPct),color:S(r.bbPct)},{label:"wRC+",value:r.wrcPlus!=null?Math.round(r.wrcPlus).toString():"—",color:D(r.wrcPlus)},{label:"xwOBA",value:s?.xwoba!=null?u(s.xwoba):"—",color:m(s?.xwoba)},{label:"xSLG",value:s?.xslg!=null?u(s.xslg):"—",color:w(s?.xslg)},{label:"Barrel%",value:s?.barrelPct!=null?f(s.barrelPct):"—",color:j(s?.barrelPct)},{label:"Blast%",value:r.blastPct!=null?f(r.blastPct):"—",color:r.blastPct?r.blastPct>20?"text-green-400":r.blastPct>15?"text-foreground":"text-red-400":"text-muted-foreground"},{label:"HardHit%",value:s?.hardHitPct!=null?f(s.hardHitPct):"—",color:k(s?.hardHitPct)},{label:"Avg EV",value:s?.exitVelo!=null?L(s.exitVelo)+" mph":"—",color:q(s?.exitVelo)}].filter(n=>n.value!=="—");return e.jsx("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1 mt-3",children:g.map(n=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:n.label}),e.jsx("span",{className:$("font-mono font-medium",n.color),children:n.value})]},n.label))})}function Ee({label:t,value:r,onChange:s,onSelect:u,loading:f,placeholder:L,type:N}){const[P,w]=p.useState([]),[B,C]=p.useState(!1),[R,S]=p.useState(-1),[D,m]=p.useState(!1),j=p.useRef(null),k=p.useRef(null);p.useEffect(()=>{if(k.current&&clearTimeout(k.current),r.trim().length<2){w([]),C(!1);return}return k.current=setTimeout(async()=>{m(!0);try{const g=N?`&type=${N}`:"",_=await(await fetch(`/api/mlb/player-suggest?q=${encodeURIComponent(r.trim())}${g}`)).json();w(_||[]),C((_||[]).length>0),S(-1)}catch{w([]),C(!1)}finally{m(!1)}},280),()=>{k.current&&clearTimeout(k.current)}},[r]),p.useEffect(()=>{const g=n=>{j.current&&!j.current.contains(n.target)&&C(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const q=p.useCallback(g=>{s(g.name),u(g),C(!1),w([])},[s,u]),Z=g=>{B&&(g.key==="ArrowDown"?(g.preventDefault(),S(n=>
1Math.min(n+1,P.length-1))):g.key==="ArrowUp"?(g.preventDefault(),S(n=>Math.max(n-1,0))):g.key==="Enter"&&R>=0?(g.preventDefault(),q(P[R])):g.key==="Escape"&&C(!1))};return e.jsxs("div",{className:"flex flex-col gap-1",ref:j,children:[e.jsx("span",{className:"text-xs text-muted-foreground font-medium uppercase tracking-wide",children:t}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(_e,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"}),(D||f)&&e.jsx(ve,{className:"absolute right-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground animate-spin pointer-events-none"}),e.jsx("input",{className:"w-full bg-card border border-border rounded-md pl-8 pr-8 py-2 text-sm outline-none focus:border-primary transition-colors placeholder:text-muted-foreground/50",placeholder:L,value:r,onChange:g=>{s(g.target.value)},onKeyDown:Z,onFocus:()=>{P.length>0&&C(!0)},autoComplete:"off"})]}),B&&P.length>0&&e.jsx("div",{className:"absolute z-50 top-full left-0 right-0 mt-1 bg-popover border border-border rounded-md shadow-lg overflow-hidden",children:P.map((g,n)=>e.jsxs("button",{className:$("w-full flex items-center gap-3 px-3 py-2 text-left text-sm hover:bg-muted transition-colors",n===R&&"bg-muted"),onMouseDown:_=>{_.preventDefault(),q(g)},onMouseEnter:()=>S(n),children:[e.jsx("span",{className:"font-medium flex-1 truncate",children:g.name}),e.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:g.team}),e.jsx("span",{className:"text-[10px] text-muted-foreground/60 shrink-0 min-w-[28px] text-right",children:g.position})]},g.id))})]})]})}function Me({options:t,active:r,onChange:s}){return e.jsx("div",{className:"flex gap-1",children:t.map(u=>e.jsx("button",{onClick:()=>s(u.value),className:$("px-2.5 py-1 rounded text-xs font-medium border transition-colors",r===u.value?"bg-primary/20 border-primary text-primary":"bg-card border-border text-muted-foreground hover:bg-muted"),children:u.label},u.value))})}function It(){We();const[t,r]=p.useState(""),[s,u]=p.useState(""),[f,L]=p.useState(""),[N,P]=p.useState(""),[w,B]=p.useState("overall"),[C,R]=p.useState("overall"),[S,D]=p.useState(null),[m,j]=p.useState(null),[k,q]=p.useState(null),[Z,g]=p.useState(""),[n,_]=p.useState(""),[je,X]=p.useState(!1),[ee,ye]=p.useState(!1),xe=p.useCallback(async a=>{u(a),P(a),X(!1);try{const o=await(await fetch(`/api/mlb/player-suggest?q=${encodeURIComponent(a)}`)).json(),l=o.find(i=>i.name.toLowerCase()===a.toLowerCase())??o[0];l&&(P(l.name),u(l.name),l.id&&j(l.id),l.team&&q(l.team),l.bats&&g(l.bats))}catch{}window.scrollTo({top:0,behavior:"smooth"})},[]),{data:b,isFetching:he}=U({queryKey:["pitcher-profile-matchup-3splits",f],queryFn:async()=>{const a=`/api/mlb/pitcher-profile/${encodeURIComponent(f)}?season=2026&blend=false`,[d,o,l]=await Promise.all([fetch(`${a}&split=all`).then(i=>i.ok?i.json():null),fetch(`${a}&split=vs_lhh`).then(i=>i.ok?i.json():null),fetch(`${a}&split=vs_rhh`).then(i=>i.ok?i.json():null)]);if(!d?.name)throw new Error("Pitcher not found");return{name:d.name,teamAbbrev:d.team||"",pitchHand:d.throws||"R",overall:d,vsLHH:o?.name?o:null,vsRHH:l?.name?l:null}},enabled:!!f,staleTime:1800*1e3}),{data:A,isFetching:pe}=U({queryKey:["batter-profile-matchup",N],queryFn:async()=>{const a=await fetch(`/api/mlb/batter-profile/${encodeURIComponent(N)}`);if(!a.ok)throw new Error("Failed");return a.json()},enabled:!!N,staleTime:1800*1e3}),{data:ae}=U({queryKey:["batter-savant-matchup",N],queryFn:async()=>{const a=await fetch(`/api/mlb/batter-savant-stats/${encodeURIComponent(N)}`);if(!a.ok)throw new Error("Failed");return a.json()},enabled:!!N,staleTime:3600*1e3}),{data:fe}=U({queryKey:["all-pitcher-pitch-mix",2026],queryFn:async()=>{const a=await fetch("/api/mlb/all-pitcher-pitch-mix?season=2026");if(!a.ok)throw new Error("Failed");return a.json()},staleTime:360*60*1e3}),O=p.useMemo(()=>!S||!fe?.data?null:fe.data[String(S)]?.pitches??null,[S,fe]),{data:W}=U({queryKey:["batter-pitch-stats-matchup",N],queryFn:async()=>{const a=await fetch(`/api/mlb/batter-pitch-stats?player_name=${encodeURIComponent(N)}&season=2026`);if(!a.ok)throw new Error("Failed");return a.json()},enabled:!!N,staleTime:3600*1e3}
1),se=b?.teamAbbrev?.toUpperCase()??null,ne=k?.toUpperCase()??null,{data:be}=U({queryKey:["mlb-game-home-team",se,ne],queryFn:async()=>{const a=re(),d=await fetch(`/api/mlb/starting-pitchers?startDate=${a}&endDate=${a}`);if(!d.ok)return null;const l=(await d.json())?.pitchers??{};for(const i of Object.keys(l)){const h=i.split(":"),c=h[1]?.toUpperCase(),y=h[2]?.toUpperCase();if(!c||!y)continue;const F=[c,y];if(se&&ne&&F.includes(se)&&F.includes(ne))return{homeTeam:c,gameTime:l[i]?.gameTime??null}}return null},enabled:!!se&&!!ne,staleTime:300*1e3}),{data:E}=U({queryKey:["mlb-h2h",m,S],queryFn:async()=>{const a=await fetch(`/api/mlb/h2h?batterId=${m}&pitcherId=${S}`);if(!a.ok)throw new Error("Failed");return a.json()},enabled:!!(m&&S),staleTime:3600*1e3}),we=p.useMemo(()=>re(),[]),{data:te,isFetching:oe}=U({queryKey:["mlb-lineups-vs-lineup",we],queryFn:async()=>{const a=await fetch(`/api/mlb/lineups?date=${we}`);if(!a.ok)throw new Error("Failed");return a.json()},enabled:!!b&&ee,staleTime:300*1e3}),H=p.useMemo(()=>{if(!te||!b)return null;const a=Array.isArray(te)?te:te.data??[],d=b.teamAbbrev.toUpperCase();for(const o of a){const l=(o.homeTeam?.abbreviation??"").toUpperCase(),i=(o.awayTeam?.abbreviation??"").toUpperCase();if(l===d)return{teamAbbr:i,teamName:o.awayTeam?.team??i,batters:o.awayTeam?.batters??[]};if(i===d)return{teamAbbr:l,teamName:o.homeTeam?.team??l,batters:o.homeTeam?.batters??[]}}return null},[te,b]),{data:Ne,isFetching:le}=U({queryKey:["lineup-batter-profiles",H?.batters.map(a=>a.name)],queryFn:async()=>{const a=H.batters;return Promise.all(a.map(d=>fetch(`/api/mlb/batter-profile/${encodeURIComponent(d.name)}`).then(o=>o.ok?o.json():null).catch(()=>null)))},enabled:!!H&&H.batters.length>0&&ee,staleTime:1800*1e3}),{data:bt}=U({queryKey:["lineup-pitch-stats",H?.batters.map(a=>a.name)],queryFn:async()=>{const a=H.batters;return Promise.all(a.map(d=>fetch(`/api/mlb/batter-pitch-stats?player_name=${encodeURIComponent(d.name)}&season=2026`).then(o=>o.ok?o.json():null).catch(()=>null)))},enabled:!!H&&H.batters.length>0&&ee,staleTime:3600*1e3}),K=p.useMemo(()=>b?w==="vsLHH"?b.vsLHH||b.overall:w==="vsRHH"&&b.vsRHH||b.overall:null,[b,w]),Pe=re(),{data:Ce}=U({queryKey:["matchup-scores",Pe],queryFn:()=>Xe(Pe),staleTime:120*1e3,refetchInterval:180*1e3}),Y=p.useMemo(()=>Ce?.scoresByPlayer??{},[Ce?.scoresByPlayer]),z=p.useMemo(()=>{const a=Object.entries(Y).map(([i,h])=>({name:i,score:h}));if(a.length===0)return null;const d=i=>i.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),o=new Map;for(const i of a){const h=d(i.name),c=o.get(h);(!c||i.score>c.score)&&o.set(h,i)}const l=[...o.values()].sort((i,h)=>h.score-i.score);return{top:l.slice(0,5),bottom:l.slice(-5).reverse()}},[Y]),[Se,Ue]=p.useState({});p.useEffect(()=>{if(!z)return;const a=[...z.top,...z.bottom].map(o=>o.name),d=re();Promise.all([Promise.all(a.map(o=>fetch(`/api/mlb/player-suggest?q=${encodeURIComponent(o)}`).then(l=>l.json()).then(l=>{const i=l.find(h=>h.name.toLowerCase()===o.toLowerCase())??l[0];return{name:o,id:i?.id??null,team:i?.team??null}}).catch(()=>({name:o,id:null,team:null})))),fetch(`/api/mlb/starting-pitchers?startDate=${d}&endDate=${d}`).then(o=>o.json()).catch(()=>({}))]).then(([o,l])=>{const i=l?.pitchers??{},h={};for(const[y,F]of Object.entries(i)){const V=y.split(":"),M=(V[1]??"").toUpperCase(),Ge=(V[2]??"").toUpperCase();F.homePitcher?.name&&(h[Ge]={name:F.homePitcher.name,id:F.homePitcher.id}),F.awayPitcher?.name&&(h[M]={name:F.awayPitcher.name,id:F.awayPitcher.id})}const c={};for(const{name:y,id:F,team:V}of o){const M=V?h[V.toUpperCase()]:null;c[y]={id:F,team:V,oppPitcher:M?.name??null,oppPitcherId:M?.id??null}}Ue(c)})},[z]);const Fe=p.useMemo(()=>{if(!H)return null;const d=(b?.pitchHand??"R").toUpperCase()==="L"?"vsLHP":"vsRHP";return H.batters.map((o,l)=>{const i=Ne?.[l],h=Y[o.name];if(h!=null)return{name:o.name,position:o.position,bats:i?.bats||o.bats||"",score:h,splitKey:d};if(!K||!i)return null;const c=(d==="vsLHP"?i.vsLHP:i.vsRHP)??i.overall;return c?{name:o.name,position:o.position,bats:i.bats||o.bats||"",score:xt(K,c),splitKey:d}:null})},[K,Ne,H,b,Y]),G=p.useMemo(()=>A?C==="vsLHP"?A.vsLHP||A.overall:C==="vsRHP"&&A.vsRHP||A.overall:null,[A,C]),J=p.useMemo(()=>{const a=s?Y[s]:null;return a??(K&&G?Oe(K,G):null)},[s,Y,K,G]);p.useMemo(()=>
1{if(!O||!W?.pitchStats)return null;let a=0,d=0;for(const i of O.filter(h=>h.usage>2)){const h=W.pitchStats.find(y=>y.pitchType===i.pitchType||i.pitchType==="SV"&&y.pitchType==="ST"||i.pitchType==="ST"&&y.pitchType==="SV");if(!h)continue;const c=i.usage/100;a+=c*h.runValuePer100,d+=c}if(d<=.3)return null;const o=a/d,l=Math.max(-20,Math.min(20,o*5));return Math.round(Math.max(10,Math.min(90,50+l)))},[O,W]);const ge=p.useMemo(()=>{if(!O||!W?.pitchStats)return null;let a=0,d=0,o=0;for(const l of O.filter(i=>i.usage>2&&i.ba>0)){const i=W.pitchStats.find(c=>c.pitchType===l.pitchType||l.pitchType==="SV"&&c.pitchType==="ST"||l.pitchType==="ST"&&c.pitchType==="SV");if(!i||i.avg==null)continue;const h=l.usage/100;a+=h*l.ba,d+=h*i.avg,o+=h}return o<.3?null:{pitcher:a/o,batter:d/o}},[O,W]);p.useEffect(()=>{const a=(A?.bats||Z).toUpperCase();if(a){if(a==="L")B("vsLHH");else if(a==="R")B("vsRHH");else if(a==="S"||a==="B"){const d=(b?.pitchHand||n).toUpperCase();d==="R"?B("vsLHH"):d==="L"&&B("vsRHH")}}},[A?.bats,Z,b?.pitchHand,n]),p.useEffect(()=>{const a=(b?.pitchHand||n).toUpperCase();a&&(a==="L"?R("vsLHP"):a==="R"&&R("vsRHP"))},[b?.pitchHand,n]),p.useEffect(()=>{if(!k||je)return;const a=re(),d=k.toUpperCase(),o=(l,i)=>{r(l),L(l),i&&D(i)};fetch(`/api/mlb/starting-pitchers?startDate=${a}&endDate=${a}`).then(l=>l.json()).then(l=>{const i=l?.pitchers??{};for(const[h,c]of Object.entries(i)){const y=h.split(":"),F=(y[1]??"").toUpperCase(),V=(y[2]??"").toUpperCase();let M=null;if(F===d&&c.awayPitcher?M=c.awayPitcher:V===d&&c.homePitcher&&(M=c.homePitcher),M?.name){o(M.name,M.id);return}}return fetch(`/api/mlb/lineups?date=${a}`).then(h=>h.json()).then(h=>{const c=Array.isArray(h)?h:h?.data??h?.games??[];for(const y of c){const F=(y.awayTeam?.abbreviation??"").toUpperCase(),V=(y.homeTeam?.abbreviation??"").toUpperCase();let M=null;if(V===d?M=y.awayTeam?.pitcher:F===d&&(M=y.homeTeam?.pitcher),M?.name){o(M.name);return}}})}).catch(()=>{})},[k,je]);const Ke=!!(b&&A&&K&&G);return e.jsx(Ve,{children:e.jsxs("div",{className:"p-4 max-w-7xl mx-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:"Matchup Analyzer"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Side-by-side pitcher vs batter comparison"})]}),(t||s)&&e.jsxs("button",{onClick:()=>{r(""),L(""),D(null),X(!1),_(""),u(""),P(""),j(null),q(null),g("")},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/60 border border-border/50 transition-colors",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),"Reset"]})]}),e.jsxs(Ye,{feature:"Matchup Analyzer",children:[e.jsx("div",{className:"bg-card border border-border rounded-lg p-4",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_auto_1fr] gap-4 items-end",children:[e.jsx(Ee,{label:"Pitcher",value:t,onChange:a=>{r(a),a||(D(null),X(!1))},onSelect:a=>{L(a.name),D(a.id),X(!0),a.throws&&_(a.throws)},loading:he,placeholder:"e.g. Zack Wheeler",type:"pitcher"}),e.jsx("div",{className:"flex items-center justify-center pb-1",children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground font-semibold",children:[e.jsx(qe,{className:"h-4 w-4"}),e.jsx("span",{children:"VS"})]})}),e.jsx(Ee,{label:"Batter",value:s,onChange:a=>{u(a),a||(j(null),q(null),X(!1))},onSelect:a=>{P(a.name),j(a.id),q(a.team),a.bats&&g(a.bats),X(!1)},loading:pe,placeholder:"e.g. Aaron Judge",type:"batter"})]})}),(he||pe)&&e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground gap-2",children:[e.jsx(ve,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading player data…"})]}),!he&&!pe&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 2xl:grid-cols-[310px_1fr_310px] gap-4 items-start",children:[e.jsx("div",{className:"bg-card border border-border rounded-lg p-4 2xl:sticky 2xl:top-4 overflow-hidden",style:b?(()=>{const a=Te(b.teamAbbrev);return{background:`linear-gradient(135deg, ${a.primary}22 0%, ${a.secondary}12 100%)`,borderColor:`${a.primary}55`}})():void 0,children:b?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ie,{mlbamId:S,name:b.name,size:52}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-sm leading-tight",children:e.jsx(He,{name:b.name})}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:[b.teamAbbrev," · ",b.pitchHand==="L"?"LHP":"RHP"]})]})]}),e.jsxs("button",{onClick:()=>ye(a=>!a),className:$("mt-3 w-full flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border text-xs font-medium transition-colors",ee?"bg-primary/20 border-primary text-primary":"bg-muted/30 border-border text-muted-foreground hover:text-foreground hover:bg-muted"),children:[e.jsx(Be,{className:"h-3 w-3"}),"vs Rest of Lineup"]}),e.jsx("div",{className:"mt-3",children:e.jsx(Me,{options:[{label:"Overall",value:"overall"},{label:"vs LHB",value:"vsLHH"},{label:"vs RHB",value:"vsRHH"}],active:w,onChange:a=>B(a)})}),e.jsx(pt,{data:b,split:K}),O&&O.length>0&&(()=>{const a={FF:"#ef4444",SI:"#f97316",FC:"#eab308",SL:"#22c55e",CU:"#3b82f6",CH:"#a855f7",FS:"#ec4899",KC:"#06b6d4",ST:"#14b8a6",SV:"#14b8a6"},d={FF:"4-Seam FB",SI:"Sinker",FC:"Cutter",SL:"Slider",CU:"Curveball",CH:"Changeup",FS:"Splitter",KC:"Knuckle-Curve",ST:"Sweeper",SV:"Sweeper"},o=O.filter(l=>l.usage>2).slice(0,7);return e.jsxs("div",{className:"mt-4 pt-3 border-t border-border/30",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide font-medium mb-2",children:"Pitch Mix"}),e.jsxs("div",{className:"flex items-center justify-between text-[9px] text-muted-foreground
1/60 mb-1 px-0.5",children:[e.jsx("span",{className:"w-[90px]",children:"Pitch"}),e.jsx("span",{className:"w-[44px] text-right",children:"Usage"}),e.jsx("span",{className:"w-[36px] text-right",children:"BA"}),e.jsx("span",{className:"w-[36px] text-right",children:"Whiff%"})]}),o.map(l=>{const i=a[l.pitchType]||"#888",h=d[l.pitchType]||l.pitchName||l.pitchType;return e.jsxs("div",{className:"flex items-center justify-between py-1 border-b border-border/10 last:border-0 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5 w-[90px]",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:i}}),e.jsx("span",{className:"text-[11px] truncate",children:h})]}),e.jsxs("div",{className:"w-[44px] flex items-center justify-end gap-1",children:[e.jsx("div",{className:"h-1.5 rounded-full bg-muted/30 w-[22px] overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.min(100,l.usage)}%`,backgroundColor:i+"99"}})}),e.jsxs("span",{className:"font-mono text-[11px] text-muted-foreground",children:[l.usage.toFixed(0),"%"]})]}),e.jsx("span",{className:$("font-mono text-[11px] w-[36px] text-right",l.ba>0?l.ba<=.215?"text-green-400":l.ba>=.28?"text-red-400":"text-muted-foreground":"text-muted-foreground/40"),children:l.ba>0?l.ba.toFixed(3).replace(/^0/,""):"—"}),e.jsx("span",{className:$("font-mono text-[11px] w-[36px] text-right",l.whiff>0?l.whiff>=30?"text-green-400":l.whiff<=18?"text-red-400":"text-muted-foreground":"text-muted-foreground/40"),children:l.whiff>0?l.whiff.toFixed(1)+"%":"—"})]},l.pitchType)})]})})()]}):e.jsxs("div",{className:"opacity-40 pointer-events-none select-none",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-[52px] h-[52px] rounded-full bg-muted shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("div",{className:"h-3 w-28 rounded bg-muted"}),e.jsx("div",{className:"h-2.5 w-16 rounded bg-muted/70"})]})]}),e.jsx("div",{className:"flex gap-1 mb-3",children:["Overall","vs LHB","vs RHB"].map(a=>e.jsx("div",{className:"px-2.5 py-1 rounded border border-border text-[11px] text-muted-foreground bg-card",children:a},a))}),[["ERA","—"],["WHIP","—"],["FIP","—"],["K%","—"],["BB%","—"],["BAA","—"],["OBP-Against","—"],["wOBA-Against","—"],["xwOBA","—"],["xERA","—"],["Barrel%","—"],["HR/9","—"],["GB%","—"]].map(([a])=>e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-border/20 text-xs",children:[e.jsx("span",{className:"text-muted-foreground w-16",children:a}),e.jsx("div",{className:"h-2 w-16 rounded bg-muted/50"})]},a)),e.jsx("p",{className:"text-[10px] text-muted-foreground/60 text-center mt-3",children:"Search a pitcher above"})]})}),e.jsx("div",{className:"bg-card border border-border rounded-lg p-4",children:Ke?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2",children:[e.jsxs("div",{className:"flex justify-between items-center text-[10px] text-muted-foreground mb-1 font-medium",children:[e.jsx("span",{className:"text-red-400",children:"Pitcher Friendly"}),J!=null&&e.jsxs("span",{className:`text-xs font-bold tabular-nums ${J>=60?"text-green-400":J<=40?"text-red-400":"text-muted-foreground"}`,children:["Batter Score: ",J]}),e.jsx("span",{className:"text-green-400",children:"Batter Friendly"})]}),e.jsx("div",{className:"relative h-3 rounded-full overflow-hidden bg-gradient-to-r from-red-500/30 via-muted/30 to-green-500/30",children:J!=null&&e.jsx("div",{className:"absolute top-0 h-full w-1.5 bg-white rounded-full shadow-sm transition-all duration-500",style:{left:`calc(${J}% - 3px)`}})}),e.jsxs("div",{className:"flex justify-between text-[10px] mt-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"← Pitcher Edge"}),e.jsx("span",{className:"text-muted-foreground",children:"Batter Edge →"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-border/30",children:[e.jsx("div",{className:"w-[60px] text-right text-[10px] text-red-400/70 font-medium uppercase tracking-wide",children:ce(b?.name)}),e.jsx("div",{className:"flex-1 text-right text-[10px] text-muted-foreground
1/50",children:"Pitcher allowed"}),e.jsx("div",{className:"w-[58px]"}),e.jsx("div",{className:"flex-1 text-[10px] text-muted-foreground/50",children:"Batter produced"}),e.jsx("div",{className:"w-[60px] text-[10px] text-green-400/70 font-medium uppercase tracking-wide",children:ce(A?.name)})]}),e.jsx("div",{className:"divide-y divide-border/20",children:ut.map(a=>e.jsx(Le,{label:a.label,pVal:K?a.pitcherGet(K)??null:null,bVal:G?a.batterGet(G,ae??null)??null:null,range:a.range,fmtP:a.fmtP,fmtB:a.fmtB,colorP:a.colorP,colorB:a.colorB,batterFavoredHigh:a.batterFavoredHigh,pitcherFavoredLow:a.pitcherFavoredLow,customEdgeDiff:a.customEdgeDiff},a.key))}),ge!=null&&e.jsx("div",{className:"border-t border-border/20",children:e.jsx(Le,{label:"Pitch Mix",pVal:ge.pitcher,bVal:ge.batter,range:x.avg,fmtP:a=>a.toFixed(3).replace(/^0/,""),fmtB:a=>a.toFixed(3).replace(/^0/,""),colorP:()=>"",colorB:()=>"",batterFavoredHigh:!0,pitcherFavoredLow:!0})}),G&&Re.some(a=>a.get(G,ae??null)!=null)&&e.jsxs("div",{className:"mt-4 pt-3 border-t border-border/30",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide font-medium mb-2",children:"Advanced Metrics"}),e.jsx("div",{className:"divide-y divide-border/20",children:Re.map(a=>{const d=a.get(G,ae??null)??null;if(d==null)return null;const o=T(d,a.range.min,a.range.max);return e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[e.jsx("div",{className:"w-[60px]"}),e.jsx("div",{className:"flex-1 flex justify-end h-4 bg-muted/20 rounded-l overflow-hidden",children:e.jsx("div",{className:"h-full"})}),e.jsx("div",{className:"w-[58px] shrink-0 text-center text-[11px] font-semibold text-muted-foreground tracking-wide",children:a.label}),e.jsx("div",{className:"flex-1 h-4 bg-muted/20 rounded-r overflow-hidden",children:e.jsx("div",{className:"h-full rounded-r bg-blue-500/50 transition-all duration-300",style:{width:`${o}%`}})}),e.jsx("div",{className:"w-[60px] text-left text-xs font-mono text-muted-foreground",children:a.fmt(d)})]},a.key)})})]}),E&&e.jsxs("div",{className:"mt-4 pt-3 border-t border-border/30",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide font-medium mb-2",children:"Head to Head (Career)"}),E.ab===0?e.jsx("p",{className:"text-[11px] text-muted-foreground/60 text-center py-1",children:"No career matchup history found"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex justify-center gap-4 mb-2",children:[{label:"PA",value:E.ab.toString()},{label:"H",value:E.h.toString()},{label:"HR",value:E.hr.toString()},{label:"BB",value:E.bb.toString()},{label:"K",value:E.so.toString()}].map(a=>e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:a.label}),e.jsx("span",{className:"text-sm font-bold font-mono",children:a.value})]},a.label))}),E.ab>=5&&E.avg!=null&&e.jsxs("div",{className:"flex justify-center gap-4 text-xs font-mono text-muted-foreground",children:[e.jsxs("span",{children:["AVG ",E.avg.toFixed(3).replace(/^0/,"")]}),E.obp!=null&&e.jsxs("span",{children:["OBP ",E.obp.toFixed(3).replace(/^0/,"")]}),E.slg!=null&&e.jsxs("span",{children:["SLG ",E.slg.toFixed(3).replace(/^0/,"")]})]}),E.ab<5&&e.jsxs("p",{className:"text-[10px] text-muted-foreground/50 text-center",children:["Small sample — ",E.ab," AB career"]})]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/40 text-center mt-4",children:"Bars show percentile position within MLB. Green = batter-favorable. Red = pitcher-favorable."}),(be?.homeTeam||k)&&e.jsx(Je,{homeTeamAbbr:be?.homeTeam??k,gameTime:be?.gameTime??void 0})]}):!s&&z?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-semibold text-green-400 uppercase tracking-wide mb-2",children:"Best Matchups Today"}),z.top.map(({name:a,score:d})=>{const o=Se[a];return e.jsxs("button",{onClick:()=>xe(a),className:"w-full flex items-center gap-2.5 py-2 px-2 rounded-lg hover:bg-muted/30 transition-colors text-left group",children:[e.jsx(ie,{mlbamId:o?.id??null,name:a,size:32}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[13px] font-medium leading-tight truncate group-hover:text-foreground",children:a}),o?.oppPitcher?e.jsxs("div",{className:"text-[10px] text-muted-foreground
1/60 truncate",children:["vs ",o.oppPitcher]}):e.jsx("div",{className:"text-[10px] text-muted-foreground/30",children:"loading…"})]}),e.jsx("div",{className:"relative w-14 h-2 rounded-full overflow-hidden bg-gradient-to-r from-red-500/20 via-muted/20 to-green-500/20 shrink-0",children:e.jsx("div",{className:"absolute top-0 h-full w-1 bg-white/70 rounded-full transition-all",style:{left:`calc(${d}% - 2px)`}})}),e.jsx("span",{className:$("font-mono text-sm font-bold w-6 text-right shrink-0",d>=60?"text-green-400":"text-muted-foreground"),children:d})]},a)}),e.jsx("div",{className:"border-t border-border/30 my-3"}),e.jsx("p",{className:"text-[10px] font-semibold text-red-400 uppercase tracking-wide mb-2",children:"Toughest Matchups Today"}),z.bottom.map(({name:a,score:d})=>{const o=Se[a];return e.jsxs("button",{onClick:()=>xe(a),className:"w-full flex items-center gap-2.5 py-2 px-2 rounded-lg hover:bg-muted/30 transition-colors text-left group",children:[e.jsx(ie,{mlbamId:o?.id??null,name:a,size:32}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[13px] font-medium leading-tight truncate group-hover:text-foreground",children:a}),o?.oppPitcher?e.jsxs("div",{className:"text-[10px] text-muted-foreground/60 truncate",children:["vs ",o.oppPitcher]}):e.jsx("div",{className:"text-[10px] text-muted-foreground/30",children:"loading…"})]}),e.jsx("div",{className:"relative w-14 h-2 rounded-full overflow-hidden bg-gradient-to-r from-red-500/20 via-muted/20 to-green-500/20 shrink-0",children:e.jsx("div",{className:"absolute top-0 h-full w-1 bg-white/70 rounded-full transition-all",style:{left:`calc(${d}% - 2px)`}})}),e.jsx("span",{className:$("font-mono text-sm font-bold w-6 text-right shrink-0",d<=40?"text-red-400":"text-muted-foreground"),children:d})]},a)})]}):e.jsxs("div",{className:"opacity-35 pointer-events-none select-none",children:[e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"flex justify-between text-[10px] font-medium mb-1",children:[e.jsx("span",{className:"text-red-400/70",children:"Pitcher Friendly"}),e.jsx("span",{className:"text-green-400/70",children:"Batter Friendly"})]}),e.jsx("div",{className:"relative h-3 rounded-full overflow-hidden bg-gradient-to-r from-red-500/20 via-muted/20 to-green-500/20",children:e.jsx("div",{className:"absolute top-0 h-full w-1.5 bg-white/30 rounded-full",style:{left:"50%"}})}),e.jsxs("div",{className:"flex justify-between text-[10px] mt-1 text-muted-foreground/50",children:[e.jsx("span",{children:"← Pitcher Edge"}),e.jsx("span",{children:"Batter Edge →"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-border/20",children:[e.jsx("div",{className:"w-[60px] h-2 rounded bg-muted/40"}),e.jsx("div",{className:"flex-1 h-2 rounded bg-muted/30"}),e.jsx("div",{className:"w-[58px]"}),e.jsx("div",{className:"flex-1 h-2 rounded bg-muted/30"}),e.jsx("div",{className:"w-[60px] h-2 rounded bg-muted/40"})]}),["AVG","OBP","K%","BB%","Contact","Power"].map(a=>e.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-border/10",children:[e.jsx("div",{className:"w-[60px] h-2 rounded bg-muted/30"}),e.jsx("div",{className:"flex-1 h-3 rounded bg-muted/20"}),e.jsx("div",{className:"w-[58px] text-center text-[10px] text-muted-foreground/40 font-semibold tracking-wide",children:a}),e.jsx("div",{className:"flex-1 h-3 rounded bg-muted/20"}),e.jsx("div",{className:"w-[60px] h-2 rounded bg-muted/30"})]},a)),e.jsxs("p",{className:"text-[10px] text-muted-foreground/50 text-center mt-4 leading-relaxed",children:["Compares pitcher-allowed stats",e.jsx("br",{}),"vs batter-produced stats side by side"]})]})}),e.jsx("div",{className:"bg-card border border-border rounded-lg p-4 2xl:sticky 2xl:top-4 overflow-hidden",style:A?(()=>{const a=Te(k);return{background:`linear-gradient(135deg, ${a.primary}22 0%, ${a.secondary}12 100%)`,borderColor:`${a.primary}55`}})():void 0,children:A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ie,{mlbamId:m,name:A.name,size:52}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-sm leading-tight",children:e.jsx(He,{name:A.name})}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:A.bats?`Bats: ${A.bats==="L"?"LHB":A.bats==="R"?"RHB":"Switch"}`:"Batter"})]})]}),e.jsx("div",{className:"mt-3",children:e.jsx(Me,{options:[{label:"Overall",value:"overall"},{label:"vs LHP",value:"vsLHP"},{label:"vs RHP",value:"vsRHP"}],active:C,onChange:a=>R(a)})}),e.jsx(ft,{profile:A,split:G,savant:ae??null}),O&&O.length>0&&W?.pitchStats&&(()=>{const a={FF:"#ef4444",SI:"#f97316",FC:"#eab308",SL:"#22c55e",CU:"#3b82f6",CH:"#a855f7",FS:"#ec4899",KC:"#06b6d4",ST:"#14b8a6",SV:"#14b8a6"},d={FF:"4-Seam FB",SI:"Sinker",FC:"Cutter",SL:"Slider",CU:"Curveball",CH:"Changeup",FS:"Splitter",KC:"Knuckle-Curve",ST:"Sweeper",SV:"Sweeper"},o=O.filter(c=>c.usage>2).slice(0,7).map(c=>{const y=W.pitchStats.find(F=>F.pitchType===c.pitchType||c.pitchType==="SV"&&F.pitchType==="ST"||c.pitchType==="ST"&&F.pitchType==="SV");return{...c,bAvg:y?.avg??null,bRv:y?.runValuePer100??null,bWhiff:y?.whiff??null,bPitches:y?.pitches??0}}).filter(c=>c.bAvg!==null);if(o.length===0)return null;const l=c=>c>=1.5?"text-green-400":c<=-1.5?"text-red-400":"text-muted-foreground",i=(c,y)=>y<5?"text-muted-foreground":c>=.28?"text-green-400":c<=.215?"text-red-400":"text-muted-foreground",h=ce(A?.name)||"Batter";return e.jsxs("div",{className:"mt-4 pt-3 border-t border-border/30",children:[e.jsxs("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide font-medium mb-2",children:[h," vs Pitch Mix"]}),e.jsxs("div",{className:"flex items-center justify-between text-[9px] text-muted-foreground
1/50 mb-1 px-0.5",children:[e.jsx("span",{className:"flex-1",children:"Pitch"}),e.jsx("span",{className:"w-[38px] text-center",children:"P.Usage"}),e.jsx("span",{className:"w-[36px] text-right",children:"AVG"}),e.jsx("span",{className:"w-[40px] text-right",children:"RV/100"}),e.jsx("span",{className:"w-[38px] text-right",children:"Whiff"})]}),o.map(c=>{const y=a[c.pitchType]||"#888",F=d[c.pitchType]||c.pitchName||c.pitchType;return e.jsxs("div",{className:"flex items-center justify-between py-1 border-b border-border/10 last:border-0 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:y}}),e.jsx("span",{className:"text-[11px] truncate",children:F})]}),e.jsxs("span",{className:"w-[38px] text-center font-mono text-[10px] text-muted-foreground",children:[c.usage.toFixed(0),"%"]}),e.jsx("span",{className:`w-[36px] text-right font-mono text-[11px] font-medium ${i(c.bAvg,c.bPitches)}`,children:c.bAvg!=null&&c.bAvg>0?c.bAvg.toFixed(3).replace(/^0/,""):"—"}),e.jsx("span",{className:`w-[40px] text-right font-mono text-[11px] font-medium ${c.bRv!=null?l(c.bRv):"text-muted-foreground"}`,children:c.bRv!=null?(c.bRv>0?"+":"")+c.bRv.toFixed(1):"—"}),e.jsx("span",{className:$("w-[38px] text-right font-mono text-[10px]",c.bWhiff!=null?c.bWhiff>=30?"text-red-400":c.bWhiff<=18?"text-green-400":"text-muted-foreground":"text-muted-foreground/40"),children:c.bWhiff!=null?c.bWhiff.toFixed(1)+"%":"—"})]},c.pitchType)}),e.jsx("p",{className:"text-[9px] text-muted-foreground/40 mt-1.5 text-right",children:"RV/100 >0 = batter-favorable"})]})})()]}):e.jsxs("div",{className:"opacity-40 pointer-events-none select-none",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-[52px] h-[52px] rounded-full bg-muted shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("div",{className:"h-3 w-28 rounded bg-muted"}),e.jsx("div",{className:"h-2.5 w-16 rounded bg-muted/70"})]})]}),e.jsx("div",{className:"flex gap-1 mb-3",children:["Overall","vs LHP","vs RHP"].map(a=>e.jsx("div",{className:"px-2.5 py-1 rounded border border-border text-[11px] text-muted-foreground bg-card",children:a},a))}),["AVG","OBP","SLG","OPS","K%","BB%","ISO","wRC+"].map(a=>e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-border/20 text-xs",children:[e.jsx("span",{className:"text-muted-foreground w-16",children:a}),e.jsx("div",{className:"h-2 w-16 rounded bg-muted/50"})]},a)),e.jsx("p",{className:"text-[10px] text-muted-foreground/60 text-center mt-3",children:"Search a batter above"})]})})]}),ee&&b&&e.jsxs("div",{className:"bg-card border border-border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-semibold text-sm",children:[ce(b.name),e.jsx("span",{className:"text-muted-foreground font-normal",children:" vs "}),H?e.jsxs(e.Fragment,{children:[H.teamName," Lineup"]}):"Opposing Lineup"]}),H&&e.jsxs("span",{className:"text-[10px] text-muted-foreground/60 bg-muted/40 px-1.5 py-0.5 rounded",children:["using ",b.pitchHand==="L"?"vs LHP":"vs RHP"," splits"]})]}),e.jsx("button",{onClick:()=>ye(!1),className:"text-muted-foreground hover:text-foreground transition-colors p-1 rounded hover:bg-muted",children:e.jsx(ke,{className:"h-4 w-4"})})]}),(oe||le)&&e.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[e.jsx(ve,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:oe?"Loading lineup…":"Loading batter profiles…"})]}),!oe&&!le&&!H&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No lineup found for today. The lineup may not be posted yet."}),!oe&&!le&&H&&Fe&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-muted-foreground/50 uppercase tracking-wide mb-1 px-1",children:[e.jsx("span",{className:"w-5 text-center shrink-0",children:"#"}),e.jsx("span",{className:"w-8 shrink-0",children:"Pos"}),e.jsx("span",{className:"w-32 shrink-0",children:"Batter"}),e.jsx("span",{className:"w-8 shrink-0",children:"Bats"}),e.jsx("span",{className:"flex-1 text-center",children:"← Pitcher Edge · · · Batter Edge →"}),e.jsx("span",{className:"w-8 text-right shrink-0",children:"Scr"})]}
1),e.jsx("div",{className:"divide-y divide-border/15",children:H.batters.map((a,d)=>{const o=Fe[d],l=a.bats?a.bats==="L"?"L":a.bats==="R"?"R":"S":"—",i=a.bats?a.bats==="L"?"text-blue-400/80":a.bats==="R"?"text-orange-400/80":"text-purple-400/80":"text-muted-foreground/30";return e.jsxs("div",{className:"flex items-center gap-3 py-2 px-1",children:[e.jsx("span",{className:"w-5 text-center text-xs text-muted-foreground font-mono shrink-0",children:d+1}),e.jsx("span",{className:"w-8 text-[10px] text-muted-foreground/60 font-medium shrink-0",children:a.position||"—"}),e.jsx("button",{className:"w-32 text-sm font-medium truncate shrink-0 text-left hover:text-primary transition-colors cursor-pointer",onClick:()=>{xe(a.name),window.scrollTo({top:0,behavior:"smooth"})},children:a.name}),e.jsx("span",{className:$("w-8 text-[11px] font-semibold shrink-0",i),children:l}),o?e.jsx(ht,{score:o.score}):le?e.jsx("div",{className:"flex-1 h-2 rounded-full bg-muted/20 animate-pulse"}):e.jsx("span",{className:"flex-1 text-xs text-muted-foreground/40 text-center",children:"No data"})]},`${a.name}-${d}`)})}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-border/20 flex items-center justify-between",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground/40",children:"Score: 10 = pitcher dominant · 50 = even · 90 = batter dominant"}),H.batters.length<9&&e.jsxs("p",{className:"text-[10px] text-amber-400/60",children:["Partial lineup (",H.batters.length,"/9 batters confirmed)"]})]})]})]})]})]})]})})}export{It 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.