1import{r as e,j as a,R as s,k as t,c as l}from"./vendor-react-DbsVTsKS.js";import{d as r,V as n,I as i,w as o,W as c,X as d,Y as x,A as m,B as p}from"./index-Dirtnqiz.js";import{u as y}from"./vendor-i18n-DiTKF2NC.js";import{aN as g,bh as h,bj as u,aM as v,a7 as b,bx as j,aP as f,by as N}from"./app-constants-D3ojol5R.js";import{u as _}from"./useSwipeNavigation-DHzmazcw.js";import{z as w}from"./vendor-ui-B_XW8Pya.js";import"./vendor-charts-CG7l663-.js";import"./vendor-otel-B3hnpEUX.js";import"./vendor-virtuoso-CT6D0QVj.js";import"./vendor-markdown-CiT-VfZw.js";const k=()=>{var s;const{t:t}=y(),{isDarkMode:l}=r(),{playerData:n}=e.useContext(L),[i,o]=e.useState(!1);if(!n)return null;const{player:c,team:d,league:x}=n,m=c.image?g(c.image):null;return a.jsxs("div",{className:"mb-1 sm:mb-2 overflow-hidden rounded-lg relative shadow-sm "+(l?"bg-gray-800":"bg-gray-50"),children:[a.jsx("div",{className:"absolute inset-0 bg-gradient-to-b opacity-30 "+(l?"from-green-900 via-green-950 to-transparent":"from-green-100 via-green-50 to-transparent")}),a.jsxs("div",{className:"p-2 sm:p-3 text-center relative z-10",children:[a.jsxs("div",{className:"mb-1 text-xs font-medium "+(l?"text-gray-300":"text-gray-700"),children:[(null==d?void 0:d.name)||t("player.team","Team"),(null==x?void 0:x.leagueName)&&` ⢠${x.leagueName}`]}),a.jsxs("div",{className:"flex flex-col items-center mb-2",children:[a.jsx("div",{className:"w-12 h-12 sm:w-14 sm:h-14 mb-1 flex items-center justify-center",children:m&&!i?a.jsx("img",{src:m,alt:`${c.name} photo`,className:"w-full h-full object-cover rounded-full border-2 "+(l?"border-green-800":"border-green-200"),loading:"lazy",decoding:"async",onError:()=>o(!0)}):a.jsx("div",{className:"w-full h-full bg-green-600 rounded-full flex items-center justify-center border-2 "+(l?"border-green-800":"border-green-200"),children:a.jsx("span",{className:"text-white text-sm font-bold",children:(null==(s=c.name)?void 0:s.charAt(0))||"P"})})}),a.jsx("h1",{className:"font-medium mb-0.5 "+(l?"text-gray-100":"text-gray-800"),style:{fontSize:"6px"},children:c.name}),c.cleanName&&c.cleanName!==c.name&&a.jsx("p",{className:"text-xs "+(l?"text-gray-400":"text-gray-600"),children:c.cleanName})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center mb-2",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-sm sm:text-base font-semibold "+(l?"text-gray-100":"text-gray-800"),children:c.position||t("player.notAvailable","N/A")}),a.jsx("div",{className:"text-xs "+(l?"text-gray-400":"text-gray-600"),children:t("player.position","Position")})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-sm sm:text-base font-semibold "+(l?"text-gray-100":"text-gray-800"),children:c.age||c.birthDate?c.age||(new Date).getFullYear()-new Date(c.birthDate).getFullYear():t("player.notAvailable","N/A")}),a.jsx("div",{className:"text-xs "+(l?"text-gray-400":"text-gray-600"),children:t("player.age","Age")})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-sm sm:text-base font-semibold "+(l?"text-gray-100":"text-gray-800"),children:c.shirtNumber||t("player.notAvailable","N/A")}),a.jsx("div",{className:"text-xs "+(l?"text-gray-400":"text-gray-600"),children:t("player.number","Number")})]})]}),(c.height||c.weight||c.nationality)&&a.jsxs("div",{className:"flex justify-center items-center space-x-4 text-xs "+(l?"text-gray-400":"text-gray-600"),children:[c.height&&a.jsxs("span",{children:[c.height,"cm"]}),c.weight&&a.jsxs("span",{children:[c.weight,"kg"]}),c.nationality&&a.jsxs("span",{className:"flex items-center",children:[c.flag&&a.jsx("img",{src:h(c.flag),alt:c.nationality,className:"w-3 h-2 mr-1 object-cover",loading:"lazy",decoding:"async"}),c.nationality]})]})]})]})},S=({value:e,label:s,colorClass:t})=>{const{isDarkMode:l}=r();return a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:`text-2xl font-bold ${t}`,children:e??0}),a.jsx("div",{className:"text-xs "+(l?"text-gray-400":"text-gray-600"),children:s})]})},A=({label:e,value:s})=>{const{isDarkMode:t}=r();return a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx("span",{className:t?"text-gray-400":"text-gray-600",children:e}),a.jsx("span",{className:"font-semibold "+(t?"text-gray-100":"text-gray-800"),children:s})]})},C=()=>{const{t:s}=y(),{isDarkMode:t}=r(),{selectedCompetition:l,loading:n,error:i}=e.useContext(M);if(n)return a.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((e,s)=>a.jsx("div",{className:"h-40 rounded-lg animate-pulse "+(t?"bg-gray-800":"bg-gray-200")},s))});if(i)return a.jsx("p",{className:"text-center text-sm text-red-500 py-8",children:i});if(!l)return a.jsx("div",{className:"text-center py-8 text-sm "+(t?"text-gray-400":"text-gray-500"),children:s("player.noStatsData","No stats available for this player")});const o=l,c="rounded-lg shadow-sm border p-4 "+(t?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),d="text-lg font-semibold mb-3 "+(t?"text-gray-100":"text-gray-800"),x=t?"border-gray-700":"border-gray-200";return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:c,children:[a.jsx("h3",{className:d,children:s("player.seasonStats","Season Statistics")}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(S,{value:o.appearances_overall,label:s("player.appearances","Appearances"),colorClass:"text-green-500"}),a.jsx(S,{value:o.goals_overall,label:s("player.goals","Goals"),colorClass:"text-blue-500"}),a.jsx(S,{value:o.assists_overall,label:s("player.assists","Assists"),colorClass:"text-purple-500"}),a.jsx(S,{value:o.clean_sheets_overall,label:s("player.cleanSheets","Clean Sheets"),colorClass:"text-teal-500"}),a.jsx(S,{value:o.yellow_cards_overall,label:s("player.yellowCards","Yellow Cards"),colorClass:"text-yellow-500"}),a.jsx(S,{value:o.red_cards_overall,label:s("player.redCards","Red Cards"),colorClass:"text-red-500"})]}),a.jsx("div",{className:`mt-4 pt-4 border-t ${x}`,children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-xl font-semibold "+(t?"text-gray-200":"text-gray-700"),children:o.minutes_played_overall??0}),a.jsx("div",{className:"text-xs "+(t?"text-gray-400":"text-gray-600"),children:s("player.minutesPlayed","Minutes Played")})]})})]}),a.jsxs("div",{className:c,children:[a.jsx("h3",{className:d,children:s("player.homeAwaySplit","Home / Away Split")}
1),a.jsxs("div",{className:"space-y-3",children:[a.jsx(A,{label:s("player.appearancesHomeAway","Appearances (H / A)"),value:`${o.appearances_home??0} / ${o.appearances_away??0}`}),a.jsx(A,{label:s("player.goalsHomeAway","Goals (H / A)"),value:`${o.goals_home??0} / ${o.goals_away??0}`}),a.jsx(A,{label:s("player.assistsHomeAway","Assists (H / A)"),value:`${o.assists_home??0} / ${o.assists_away??0}`}),a.jsx(A,{label:s("player.minutesHomeAway","Minutes (H / A)"),value:`${o.minutes_played_home??0} / ${o.minutes_played_away??0}`})]})]}),a.jsxs("div",{className:c,children:[a.jsx("h3",{className:d,children:s("player.per90Stats","Per-90 & Rankings")}),a.jsxs("div",{className:"space-y-3",children:[a.jsx(A,{label:s("player.goalsPer90","Goals per 90"),value:o.goals_per_90_overall??0}),a.jsx(A,{label:s("player.assistsPer90","Assists per 90"),value:o.assists_per_90_overall??0}),a.jsx(A,{label:s("player.cardsPer90","Cards per 90"),value:o.cards_per_90_overall??0}),o.rank_in_league_top_attackers>0&&a.jsx(A,{label:s("player.rankAttackers","Rank â Top Attackers"),value:`#${o.rank_in_league_top_attackers}`}),o.rank_in_league_top_midfielders>0&&a.jsx(A,{label:s("player.rankMidfielders","Rank â Top Midfielders"),value:`#${o.rank_in_league_top_midfielders}`}),o.rank_in_league_top_defenders>0&&a.jsx(A,{label:s("player.rankDefenders","Rank â Top Defenders"),value:`#${o.rank_in_league_top_defenders}`})]})]}),a.jsxs("div",{className:c,children:[a.jsx("h3",{className:d,children:s("player.discipline","Discipline & Penalties")}),a.jsxs("div",{className:"space-y-3",children:[a.jsx(A,{label:s("player.totalCards","Total Cards"),value:o.cards_overall??0}),a.jsx(A,{label:s("player.penaltyGoals","Penalty Goals"),value:o.penalty_goals??0}),a.jsx(A,{label:s("player.penaltyMisses","Penalty Misses"),value:o.penalty_misses??0}),a.jsx(A,{label:s("player.conceded","Conceded"),value:o.conceded_overall??0})]})]})]})},$=()=>{var s;const{t:t}=y(),{isDarkMode:l}=r(),{playerData:o}=e.useContext(L),{selectedCompetition:c}=e.useContext(M),[d,x]=e.useState([]),[m,p]=e.useState(!0),[g,h]=e.useState(null),[v,b]=e.useState("Recent"),j={Recent:t("player.tabRecent","Recent"),Upcoming:t("player.tabUpcoming","Upcoming")},f=null==(s=null==o?void 0:o.player)?void 0:s.id,N=(null==c?void 0:c.competition_id)??null,_=e.useCallback(async()=>{if(f)try{p(!0),h(null);const e=await n(f,{leagueId:N,page:0,size:20});x(Array.isArray(e)?e:[])}catch(e){h(t("errors.player.matchesLoadFailed","Failed to load matches"))}finally{p(!1)}},[f,N,t]);e.useEffect(()=>{_()},[_]);if(!o)return a.jsx("div",{className:"text-center py-8 "+(l?"text-gray-400":"text-gray-500"),children:t("player.dataNotAvailable","Player data not available")});if(m)return a.jsxs("div",{className:"text-center py-8",children:[a.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-t-transparent rounded-full mx-auto mb-2 "+(l?"border-green-400":"border-green-500")}),a.jsx("p",{className:l?"text-gray-400":"text-gray-500",children:t("player.loadingMatches","Loading matches...")})]});if(g)return a.jsx("p",{className:"text-center text-sm text-red-500 py-8",children:g});const w=(()=>{switch(v){case"Recent":return d.filter(e=>u(e));case"Upcoming":return d.filter(e=>!u(e));default:return d}})();return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"flex overflow-x-auto space-x-1 rounded-lg p-1 "+(l?"bg-gray-800":"bg-gray-100"),children:["Recent","Upcoming"].map(e=>a.jsx("button",{className:"flex-shrink-0 px-3 py-2 text-sm font-medium rounded-md transition-colors "+(v===e?l?"bg-gray-700 text-green-400 shadow-sm":"bg-white text-green-600 shadow-sm":l?"text-gray-400 hover:text-gray-200":"text-gray-600 hover:text-gray-800"),onClick:()=>b(e),children:j[e]||e},e))}),w.length>0?a.jsx("div",{className:"space-y-2",children:w.map(e=>a.jsx(i,{match:e},e.id))}):a.jsxs("div",{className:"text-center py-8 "+(l?"text-gray-400":"text-gray-500"),children:["Recent"===v&&t("player.noRecentMatches","No recent matches available"),"Upcoming"===v&&t("player.noUpcomingMatches","No upcoming matches scheduled")]})]})},D=()=>{var s;const{playerData:t}=e.useContext(L),l=null==(s=null==t?void 0:t.player)?void 0:s.id;return a.jsx(o,{context:"player",entityId:l})},P=()=>{var s;const{t:t}=y(),{isDarkMode:l}
1=r(),{playerData:n}=e.useContext(L),{selectedCompetition:i,loading:o,error:d}=e.useContext(M);if(o)return a.jsx("div",{className:"space-y-3",children:Array.from({length:2}).map((e,s)=>a.jsx("div",{className:"h-32 rounded-lg animate-pulse "+(l?"bg-gray-800":"bg-gray-200")},s))});if(d)return a.jsx("p",{className:"text-center text-sm text-red-500 py-8",children:d});if(!i)return a.jsx("div",{className:"text-center py-8 text-sm "+(l?"text-gray-400":"text-gray-500"),children:t("player.noProfileData","No profile data available for this player")});const x=i,m=v(x.known_as||x.full_name||`${x.first_name||""} ${x.last_name||""}`.trim()||(null==(s=null==n?void 0:n.player)?void 0:s.name)||"Player"),p=x.age??(x.birthday?Math.floor((Date.now()/1e3-x.birthday)/31557600):null),g=x.birthday?new Date(1e3*x.birthday).toLocaleDateString():null,h=x.nationality?c(x.nationality):null,u="rounded-lg shadow-sm border p-4 "+(l?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),b=l?"text-gray-400":"text-gray-600",j="font-medium "+(l?"text-gray-100":"text-gray-800"),f="text-lg font-semibold mb-3 "+(l?"text-gray-100":"text-gray-800");return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:u,children:[a.jsx("h3",{className:f,children:t("player.personalInfo","Personal Information")}),a.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.jsxs("div",{children:[a.jsxs("span",{className:b,children:[t("player.fullName","Full Name"),":"]}),a.jsx("p",{className:j,children:m})]}),null!=p&&a.jsxs("div",{children:[a.jsxs("span",{className:b,children:[t("player.age","Age"),":"]}),a.jsx("p",{className:j,children:p})]}),g&&a.jsxs("div",{children:[a.jsxs("span",{className:b,children:[t("player.dateOfBirth","Date of Birth"),":"]}),a.jsx("p",{className:j,children:g})]}),x.nationality&&a.jsxs("div",{children:[a.jsxs("span",{className:b,children:[t("player.nationality","Nationality"),":"]}),a.jsxs("p",{className:j,children:[h?`${h} `:"",x.nationality]})]}),!!x.height&&a.jsxs("div",{children:[a.jsxs("span",{className:b,children:[t("player.height","Height"),":"]}),a.jsxs("p",{className:j,children:[x.height," cm"]})]}),!!x.weight&&a.jsxs("div",{children:[a.jsxs("span",{className:b,children:[t("player.weight","Weight"),":"]}),a.jsxs("p",{className:j,children:[x.weight," kg"]})]})]})]}),a.jsxs("div",{className:u,children:[a.jsx("h3",{className:f,children:t("player.competitionInfo","Competition Information")}),a.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.jsxs("div",{children:[a.jsxs("span",{className:b,children:[t("player.league","League"),":"]}),a.jsx("p",{className:j,children:x.league||"Unknown"})]}),a.jsxs("div",{children:[a.jsxs("span",{className:b,children:[t("player.season","Season"),":"]}),a.jsx("p",{className:j,children:x.season||"N/A"})]}),a.jsxs("div",{children:[a.jsxs("span",{className:b,children:[t("player.position","Position"),":"]}),a.jsx("p",{className:j,children:x.position||"N/A"})]}),a.jsxs("div",{children:[a.jsxs("span",{className:b,children:[t("player.competitionType","Type"),":"]}),a.jsx("p",{className:j,children:x.league_type||"N/A"})]})]})]}),a.jsxs("div",{className:u,children:[a.jsx("h3",{className:f,children:t("player.highlights","Highlights (this competition)")}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-green-500",children:x.goals_overall??0}),a.jsx("div",{className:`text-xs ${b}`,children:t("player.goals","Goals")})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-blue-500",children:x.assists_overall??0}),a.jsx("div",{className:`text-xs ${b}`,children:t("player.assists","Assists")})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold "+(l?"text-gray-300":"text-gray-600"),children:x.appearances_overall??0}),a.jsx("div",{className:`text-xs ${b}`,children:t("player.appearances","Appearances")})]})]})]})]})},M=e.createContext({competitions:[],selectedCompetition:null,selectedKey:null,setSelectedKey:()=>{},loading:!0,error:null}),R=e=>{if(!e)return"";const a=e.league||"Unknown League",s=e.season||(e.starting_year?String(e.starting_year):"");return s?`${a} ${s}`:a},H=({competitions:t,selectedKey:l,onSelect:n})=>{const{t:i}=y(),{isDarkMode:o}=r(),[c,d]=e.useState(!1),x=s.useRef(null);e.useEffect(()=>{if(!c)return;const e=e=>{x.current&&!x.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[c]);const m=t.find(e=>e._key===l);return t.length?a.jsxs("div",{className:"relative mb-3",ref:x,children:[a.jsxs("button",{onClick:()=>d(e=>!e),className:"w-full flex items-center justify-between gap-2 px-3 py-2 rounded-lg border text-sm font-medium transition-colors "+(o?"bg-gray-800 border-gray-700 text-gray-100 hover:bg-gray-700":"bg-white border-gray-200 text-gray-800 hover:bg-gray-50 shadow-sm"),"aria-label":i("player.selectLeague","Select league & season"),
1children:[a.jsx("span",{className:"truncate",children:m?R(m):i("player.selectLeague","Select league & season")}),a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",className:"flex-shrink-0 transition-transform "+(c?"rotate-180":""),children:a.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"})})]}),c&&a.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 max-h-64 overflow-y-auto rounded-lg shadow-lg border z-30 "+(o?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),children:t.map(e=>{const s=e._key===l;return a.jsxs("button",{onClick:()=>{n(e._key),d(!1)},className:"w-full text-left px-3 py-2 text-sm transition-colors flex items-center justify-between gap-2 "+(s?o?"bg-blue-900/60 text-blue-200":"bg-blue-50 text-blue-700":o?"text-gray-200 hover:bg-gray-700":"text-gray-700 hover:bg-gray-50"),children:[a.jsx("span",{className:"truncate",children:R(e)}),s&&a.jsx("span",{children:"â"})]},e._key)})})]}):null},I=()=>{var t,l;const{t:n}=y(),{isDarkMode:i}=r(),{playerData:o}=e.useContext(L),[c,x]=e.useState("Profile"),[m,p]=e.useState([]),[g,h]=e.useState(null),[u,v]=e.useState(!0),[j,f]=e.useState(null),N=null==(t=null==o?void 0:o.player)?void 0:t.id,w=null==(l=null==o?void 0:o.league)?void 0:l.id,k=e.useCallback(async()=>{var e;if(N)try{v(!0),f(null);const a=await d(N),s=[...Array.isArray(null==a?void 0:a.competitions)?a.competitions:[]].sort((e,a)=>{const s=e.starting_year||0,t=a.starting_year||0;return s!==t?t-s:(a.last_match_timestamp||0)-(e.last_match_timestamp||0)}).map((e,a)=>({...e,_key:`${e.competition_id}_${a}`}));p(s);const t=s.find(e=>e.competition_id===w);h(t?t._key:(null==(e=s[0])?void 0:e._key)??null)}catch(a){f(n("errors.player.loadFailed","Failed to load player stats"))}finally{v(!1)}},[N,w]);e.useEffect(()=>{k()},[k]);const S=e.useMemo(()=>m.find(e=>e._key===g)||null,[m,g]),A=["Profile","Stats","Matches",...b?["News"]:[]],R={Profile:n("player.tabs.profile","Profile"),Stats:n("player.tabs.stats","Stats"),Matches:n("player.tabs.matches","Matches"),News:n("player.tabs.news","News")},I=A.indexOf(c),{swipeHandlers:z,isSwiping:F}=_(A,I,e=>{x(A[e])},{threshold:50,velocity:.3,preventScroll:!0,enableHapticFeedback:!0});s.useEffect(()=>{(()=>{const e=document.querySelector(".tab-navigation"),a=document.querySelector(`[data-tab="${c}"]`);if(e&&a){const s=e.getBoundingClientRect(),t=a.getBoundingClientRect();(t.left<s.left||t.right>s.right)&&a.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"})}})()},[c]);const G=e.useMemo(()=>({competitions:m,selectedCompetition:S,selectedKey:g,setSelectedKey:h,loading:u,error:j}),[m,S,g,u,j]);return a.jsx(M.Provider,{value:G,children:a.jsxs("div",{className:"flex flex-col w-full",children:[a.jsx("div",{className:"px-4 mt-2",children:u?a.jsx("div",{className:"h-9 rounded-lg animate-pulse mb-3 "+(i?"bg-gray-800":"bg-gray-200")}):j?a.jsx("p",{className:"text-center text-sm text-red-500 mb-3",children:j}):a.jsx(H,{competitions:m,selectedKey:g,onSelect:h})}),a.jsx("div",{className:"tab-navigation flex overflow-x-auto border-b mx-4 mt-0 mb-6 scrollbar-hide "+(i?"border-gray-700":"border-gray-300"),children:A.map(e=>a.jsxs("button",{"data-tab":e,className:"flex-shrink-0 py-3 px-4 text-center text-sm font-medium border-b-2 transition-all duration-200 "+(c===e?"border-green-500 text-green-500 scale-105":i?"border-transparent text-gray-400 hover:text-gray-200 hover:border-gray-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"),onClick:()=>x(e),children:[R[e]||e,a.jsx("div",{className:"flex justify-center mt-1",children:a.jsx("div",{className:"w-1 h-1 rounded-full transition-colors duration-200 "+(c===e?"bg-green-500":"bg-transparent")})})]},e))}),a.jsx("div",{className:"px-4 transition-all duration-200 ease-out "+(F?"scale-98 opacity-90":"scale-100 opacity-100"),...z,style:{touchAction:"pan-y",transform:F?"translateY(-2px)":"translateY(0px)"},children:a.jsxs("div",{className:"transition-opacity duration-150 "+(F?"opacity-70":"opacity-100"),children:["Profile"===c&&a.jsx(P,{}),"Stats"===c&&a.jsx(C,{}),"Matches"===c&&a.jsx($,{}),"News"===c&&a.jsx(D,{})]})})]})})},L=e.createContext({playerData:null,setPlayerData:()=>{}}),z=()=>{var s;const{t:n}=y(),{isDarkMode:i}
1=r(),{playerId:o}=t(),c=l(),[g,h]=e.useState(null),[u,v]=e.useState(!0),[b,_]=e.useState(null),S=e.useRef(!1);e.useEffect(()=>{if(S.current)return;S.current=!0;o?(async()=>{try{v(!0),_(null);const e=j(o);if(e)return h(e),void v(!1);const a=await d(o),s=Array.isArray(null==a?void 0:a.competitions)?a.competitions:[];if(0===s.length)return _(n("errors.player.missingInfo")),void v(!1);const t=[...s].sort((e,a)=>(a.last_match_timestamp||0)-(e.last_match_timestamp||0))[0],l={id:t.id,name:t.known_as||`${t.first_name||""} ${t.last_name||""}`.trim(),cleanName:t.known_as,image:t.url,position:t.position,age:t.age,nationality:t.nationality},r={id:t.club_team_id??null,name:null,image:null},i={id:t.competition_id,leagueName:t.league,season:t.season},c=f(l,r,i);N(o,c),h(c),v(!1)}catch(e){_(n("errors.player.loadFailed")),v(!1)}})():(_(n("errors.player.idRequired")),v(!1))},[o]);const A=()=>{c(-1)};if(u)return a.jsx("div",{className:"flex flex-col items-center justify-center w-full h-screen "+(i?"bg-gray-900":"bg-gray-100"),children:a.jsxs("div",{className:"p-4 rounded-lg shadow-md text-center "+(i?"bg-gray-800":"bg-white"),children:[a.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-t-transparent rounded-full mx-auto mb-4 "+(i?"border-blue-400":"border-blue-500")}),a.jsx("p",{className:i?"text-gray-300":"text-gray-700",children:n("player.loadingInfo","Loa
1ding player information...")})]})});if(b)return a.jsx("div",{className:"flex flex-col items-center justify-center w-full h-screen "+(i?"bg-gray-900":"bg-gray-100"),children:a.jsxs("div",{className:"p-4 rounded-lg shadow-md text-center "+(i?"bg-gray-800":"bg-white"),children:[a.jsx("div",{className:"text-red-500 mb-2",children:"â ï¸"}),a.jsx("p",{className:i?"text-gray-300":"text-gray-700",children:b}),a.jsx("button",{className:"mt-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",onClick:A,children:n("common.goBack","Go Back")})]})});const C=(null==g?void 0:g.name)||n("player.defaultName","Player"),$=`${C} - Player Profile & Stats | SokaPal AI`,D=`View ${C} player profile, statistics, performance metrics, and match history. Get detailed analytics and insights.`,P=g?x({id:o,name:C,photo:g.photo,team:null==(s=g.team)?void 0:s.name}):null,M=m([{name:"Home",url:"https://sokapal.ai"},{name:"Players",url:"https://sokapal.ai"},{name:C,url:`https://sokapal.ai/player/${o}`}]);return a.jsxs(L.Provider,{value:{playerData:g,setPlayerData:h},children:[a.jsx(p,{title:$,description:D,keywords:`${C}, player stats, soccer player, football player, player profile, player analysis`,url:`https://sokapal.ai/player/${o}`,image:(null==g?void 0:g.photo)||"https://sokapal.ai/og-image.png",structuredData:{"@context":"https://schema.org","@graph":[P,M]}}),a.jsx("div",{className:"flex flex-col items-center w-full min-h-screen "+(i?"bg-gray-900":"bg-gray-100"),children:a.jsxs("div",{className:"w-full rounded-lg shadow-md relative "+(i?"bg-gray-800":"bg-white"),children:[a.jsx("div",{className:"absolute top-2 left-2 z-50",children:a.jsx("button",{className:"p-2 rounded-full shadow transition-colors "+(i?"bg-gray-700 bg-opacity-70 hover:bg-opacity-100 text-gray-200":"bg-white bg-opacity-70 hover:bg-opacity-100 text-gray-700"),onClick:A,"aria-label":"Go back",children:a.jsx(w,{className:"w-5 h-5"})})}),a.jsx(k,{}),a.jsx(I,{})]})})]})};export{L as PlayerContext,z 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.