(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,32587,e=>{"use strict";e.i(47167);var i=e.i(43476),t=e.i(71645),s=e.i(67290),r=e.i(3551);e.i(23842);var a=e.i(67648),a=a,o=e.i(45832),l=e.i(94884),c=e.i(6359),c=c,n=e.i(78883),n=n,d=e.i(689),d=d,h=e.i(13607),p=e.i(66796),b=e.i(99011);function u({params:e}){let u=(0,s.useMediaQuery)({maxWidth:600});(0,r.default)();let[f,x]=(0,t.useState)(),{playerid:y}=(0,t.use)(e),[m,g]=(0,t.useState)([]),[j,v]=(0,t.useState)([]),[w,T]=(0,t.useState)([]),[E,N]=(0,t.useState)(!0),[S,$]=(0,t.useState)(!1),[B,P]=(0,t.useState)("");async function R(){try{let e=await fetch(`https://localhost:7275/api/player/${y}`),i=await e.json();i.length>0?x(i[0]):($(!0),P("Invalid Player ID - please choose another player from searchbar or a Team roster."))}catch(e){console.error("Error fetching player: ",e),$(!0),P(e)}}function F(e){return 1==e||11==e||12==e}async function C(){if(f?.position!=void 0&&f?.position!=0)try{let e=F(f?.position)?`https://localhost:7275/api/pitcher/${y}`:`https://localhost:7275/api/batter/${y}`,i=await fetch(e),t=await i.json(),s=[],r=[],a=0,o=!1;if(t.forEach((e,i)=>{s.includes(e.yearid)?(o=!0,a=i,r=t.filter(i=>i.yearid===e.yearid)):s.push(e.yearid)}),o){let e=0,i=0,s=0,o=0,l=0,c=0,n=0,d=0,h=0,p=0,b=0,u=0,x=0,y=0,m=0,g=0;r.forEach(t=>{e+=t.g,i+=t.b1,s+=t.b2,o+=t.b3,l+=t.hr,c+=t.so,n+=t.ibb,d+=t.ubb,F(f.position)?(h+=t.gs,p+=t.w,b+=t.l,u+=t.sv,x+=t.outs,y+=t.er):(m+=t.ab,g+=t.hbp)});let j={playerid:0,yearid:"",levelid:0,teamid:0,g:0,gs:0,w:0,l:0,sv:0,outs:0,b1:0,b2:0,b3:0,hr:0,so:0,er:0,ibb:0,ubb:0},v={playerid:0,yearid:"",levelid:0,teamid:0,g:0,ab:0,b1:0,b2:0,b3:0,hr:0,ubb:0,hbp:0,so:0,ci:0,ibb:0,sh:0,sf:0,sb:0,cs:0,pa:0,r:0,rbi:0};F(f.position)?(j.yearid=`${r[0]?.yearid} Total`,j.g=e,j.b1=i,j.b2=s,j.b3=o,j.hr=l,j.so=c,j.ibb=n,j.ubb=d,j.gs=h,j.w=p,j.l=b,j.sv=u,j.outs=x,j.er=y,t.splice(a+1,0,j)):(v.yearid=`${r[0]?.yearid} Total`,v.g=e,v.b1=i,v.b2=s,v.b3=o,v.hr=l,v.so=c,v.ibb=n,v.ubb=d,v.ab=m,v.hbp=g,t.splice(a+1,0,v))}F(f.position)?g(t):v(t)}catch(e){console.error("Error fetching player: ",e)}}async function M(){if(f?.position!=void 0&&f?.position!=0)try{let e=F(f?.position)?`https://localhost:7275/api/metrics/pitcher/${y}`:`https://localhost:7275/api/metrics/batter/${y}`,i=await fetch(e),t=await i.json();T(t),N(!1)}catch(e){console.error("Error fetching player: ",e)}}return(0,t.useEffect)(()=>{R()},[y]),(0,t.useEffect)(()=>{C(),M()},[f]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(o.NavBar,{}),(0,i.jsxs)("div",{className:`min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 ${u?"py-8 px-2":"p-8"} grid content-center`,style:{overflow:"auto"},children:[S?(0,i.jsx)("div",{className:"flex content-center",children:(0,i.jsx)(h.Card,{sx:{maxWidth:345},children:(0,i.jsx)(b.default,{className:"bg-red-100",children:(0,i.jsxs)(p.Typography,{children:[(0,i.jsx)("b",{children:"ERROR:"})," ",B]})})})}):(0,i.jsx)(i.Fragment,{}),S?(0,i.jsx)(i.Fragment,{}):u?(0,i.jsxs)("div",{className:"max-w-sm mx-auto",style:{marginTop:50},children:[(0,i.jsx)(a.default,{player:f}),(0,i.jsxs)("div",{className:"flex flex-col",children:[(0,i.jsx)("div",{style:{paddingTop:15,marginBottom:15},children:F(f?.position)?(0,i.jsx)(c.default,{rows:m}):(0,i.jsx)(n.default,{rows:j})}),(0,i.jsx)("div",{style:{marginBottom:30},children:(0,i.jsx)(d.default,{metrics:w,loadingMetrics:E,isPitcher:F(f?.position)})})]})]}):(0,i.jsxs)("div",{className:"max-w-6xl mx-auto flex",children:[(0,i.jsx)(a.default,{player:f}),(0,i.jsxs)("div",{className:"flex flex-col",children:[(0,i.jsx)("div",{style:{paddingLeft:15},children:F(f?.position)?(0,i.jsx)(c.default,{rows:m}):(0,i.jsx)(n.default,{rows:j})}),(0,i.jsx)("div",{style:{paddingLeft:15,paddingTop:30},children:(0,i.jsx)(d.default,{metrics:w,loadingMetrics:E,isPitcher:F(f?.position)})})]})]})]}),(0,i.jsx)(l.Footer,{})]})}e.s(["default",()=>u],32587)}]);