PageSourceSearch

https://pblfg.com/assets/HeadToHeadComparison-BNqS2j4b.js

js pblfg.com collected 2026-10-02 01:39:09 UTC 47,034 bytes, 1 lines download raw bytes

1import{r as l,j as e}from"./react-vendor-Q2BSRknM.js";import{s as ve,aI as Rs,aJ as As,c as P,aK as Es,af as Ts,e1 as $s,cO as Fs,bB as Bs,cw as Hs,cV as Gt,bO as Ot,b5 as Is,e2 as Yt,bM as zs,J as Oe,K as Ye,L as Kt,N as Ke,O as N,B as qt,b1 as te,c0 as Jt,cN as Vt,cR as Gs,R as Os,a8 as H,dE as Ys,e3 as Ks,C as qs,b as Js,d as Vs,e as Xs,e4 as Xt,b8 as Us}from"./index-BgCZMvjj.js";import{u as Ut}from"./query-BLOP9k_M.js";import{C as Qs}from"./calendar-BbcGg_8U.js";import{e as ns,S as Qt,X as Se,d as Zt,w as Zs,f as en,Y as tn,o as es}from"./lucide-Ckh7y__x.js";import{f as ts}from"./date-utils-DaNoSKVa.js";import{C as sn}from"./capacitor-DSpR9wll.js";import"./ui-radix-DzQ_orwq.js";import"./supabase-DoZmW4Yf.js";const nn=m=>{const x=(m||"").toUpperCase();return x.startsWith("DB")?"DreamBreaker":x.includes("MX")?"Mixed Doubles":x.startsWith("WD")?"Women's Doubles":x.startsWith("MD")||x.startsWith("M1")||x.startsWith("M2")?"Men's Doubles":"MLP"},an=(m,x)=>{var W;const g=(m||"").toUpperCase();if(!g)return`G${x+1}`;if(g.startsWith("DB"))return"DB";if(g.startsWith("WD"))return"WD";if(g.startsWith("MX")||g.startsWith("MXD")){const k=(W=g.match(/([12])/))==null?void 0:W[1];return k?`MXD ${k==="1"?"A":"B"}`:"MXD"}return g.startsWith("MD")||g.startsWith("M1")||g.startsWith("M2")?"MD":g},mt=m=>(m||"").replace(/\b(premier|challenger)\b/gi,"").replace(/\s{2,}/g," ").trim(),ke=m=>String(m||"").trim().toLowerCase();function rn(m,x,g){if(!m.length||!x||!g)return null;const W=[...m].sort((r,b)=>(r.sequence_number??0)-(b.sequence_number??0));let k=0,v=0,M=0,a=0,q=!1;for(const r of W){const b=Number(r.team_one_score??k),J=Number(r.team_two_score??v),se=Math.max(0,b-k),I=Math.max(0,J-v);if(k=Math.max(k,b),v=Math.max(v,J),se===0&&I===0)continue;const ae=[ke(r.team_one_player_one_uuid),ke(r.team_one_player_two_uuid)].filter(Boolean),fe=[ke(r.team_two_player_one_uuid),ke(r.team_two_player_two_uuid)].filter(Boolean),ce=ke(x),he=ke(g);ae.includes(ce)&&fe.includes(he)?(M+=se,a+=I,q=!0):fe.includes(ce)&&ae.includes(he)&&(M+=I,a+=se,q=!0)}return q?{for:M,against:a}:null}function on(m,x){const[g,W]=l.useState([]),[k,v]=l.useState(!1),[M,a]=l.useState(""),q=`${m.trim().toLowerCase()}|${x.trim().toLowerCase()}`;return l.useEffect(()=>{if(W([]),a(""),!(m!=null&&m.trim())||!(x!=null&&x.trim())){v(!1);return}let r=!1;return(async()=>{v(!0);try{const{data:b,error:J}=await ve.from("mlp_player_matches").select("matchup_uuid, match_uuid, game_index, match_format, is_tie_breaker, player_name, player_uuid, partner_name, opponent_names, opponent_uuids, points_for, points_against, played_at, season_label, tournament_uuid, tournament_title, player_team_name, opponent_team_name, status").ilike("player_name",m.trim()).order("played_at",{ascending:!1}).limit(1500);if(r)return;if(J){console.error("[MLP H2H] fetch failed",J),v(!1);return}const se=x.trim().toLowerCase(),I=(b||[]).filter(j=>(j.opponent_names||[]).some(y=>(y||"").toLowerCase()===se)),ae=Array.from(new Set(I.map(j=>j.tournament_uuid).filter(Boolean))),fe=new Map;if(ae.length){const{data:j}=await ve.from("mlp_event_meta").select("mlp_tournament_uuid, tournament:tournaments(name)").in("mlp_tournament_uuid",ae);(j||[]).forEach(y=>{var z;y.mlp_tournament_uuid&&((z=y.tournament)!=null&&z.name)&&fe.set(y.mlp_tournament_uuid,y.tournament.name)})}const ce=Array.from(new Set(I.filter(j=>j.is_tie_breaker).map(j=>j.matchup_uuid).filter(Boolean))),he=new Map;if(ce.length){const{data:j}=await ve.from("mlp_event_matchups").select("lineup_matchup_uuid, details").in("lineup_matchup_uuid",ce);(j||[]).forEach(y=>{var Ne;const z=Array.isArray((Ne=y.details)==null?void 0:Ne.games)?y.details.games:[],Y=new Map;z.filter(R=>(R==null?void 0:R.is_tie_breaker)===!0).forEach(R=>{const Ce=Array.isArray(R.tie_breaker_sequences)?R.tie_breaker_sequences:[];Y.set(String(R.match_uuid||"db"),Ce)}),y.lineup_matchup_uuid&&he.set(y.lineup_matchup_uuid,Y)})}const ye=new Map;I.forEach(j=>{const y=ye.get(j.matchup_uuid)||[];y.push(j),ye.set(j.matchup_uuid,y)});const O=Array.from(ye.entries()).map(([j,y])=>{const z=[...y].sort((h,Z)=>(h.game_index??0)-(Z.game_index??0)),Y=z[0],Ne=Array.from(new Set(z.flatMap(h=>
1[h.player_name,h.partner_name].filter(Boolean)))),R=Array.from(new Set(z.flatMap(h=>h.opponent_names||[]))),Ce=z.reduce((h,Z)=>Z.played_at&&(!h||Date.parse(Z.played_at)>Date.parse(h))?Z.played_at:h,null);let K="";for(const h of z){const Z=h.opponent_names||[],L=h.opponent_uuids||[],ue=Z.findIndex(S=>(S||"").toLowerCase()===se);if(ue>=0&&L[ue]){K=L[ue];break}}const de=[];z.forEach((h,Z)=>{if(h.is_tie_breaker){const L=he.get(j),ue=(L==null?void 0:L.get(String(h.match_uuid||"db")))||(L?Array.from(L.values())[0]:void 0),S=ue?rn(ue,h.player_uuid,K):null;if(!S||S.for+S.against===0)return;de.push({score:{team1Score:S.for,team2Score:S.against},label:"DB",format:h.match_format});return}de.push({score:{team1Score:h.points_for??0,team2Score:h.points_against??0},label:an(h.match_format,Z),format:h.match_format})});const ne=Array.from(new Set(de.map(h=>nn(h.format)))),qe=mt(fe.get(Y.tournament_uuid))||mt(Y.tournament_title)||[mt(Y.season_label),"MLP"].filter(Boolean).join(" ")||"MLP";return{id:`mlp:${j}`,tournament:qe,round:Y.opponent_team_name?`vs ${Y.opponent_team_name}`:"MLP",event:ne.length===1?ne[0]:"MLP",team1:Ne,team2:R,games:de.map(h=>h.score),gameLabels:de.map(h=>h.label),status:"completed",time:Ce,source:"mlp",matchup_uuid:j}});W(O),a(q)}catch(b){r||console.error("[MLP H2H] fetch failed",b)}finally{r||v(!1)}})(),()=>{r=!0}},[m,x,q]),{mlpMatches:g,loadingMlp:k,mlpReady:M===q}}const ln=m=>{if(m.mode==="all")return"All-Time";if(m.mode==="year")return m.year;const x=m.from.getFullYear()===m.to.getFullYear();return`${ts(m.from,"MMM d")} – ${ts(m.to,x?"MMM d":"MMM d, yyyy")}`},xt=(m,x)=>{if(x.mode==="all")return!0;const g=m?new Date(m):null;if(!g||isNaN(g.getTime()))return!1;if(x.mode==="year")return g.getUTCFullYear()===Number(x.year);const W=new Date(x.from);W.setHours(0,0,0,0);const k=new Date(x.to);return k.setHours(23,59,59,999),g>=W&&g<=k},cn=m=>{if(m.mode==="all")return null;if(m.mode==="year")return[m.year];const x=[];for(let g=m.from.getFullYear();g<=m.to.getFullYear();g++)x.push(String(g));return x};function ss({years:m,scope:x,onChange:g,className:W}){const[k,v]=l.useState(!1),[M,a]=l.useState(x.mode==="custom"?{from:x.from,to:x.to}:void 0),q=b=>{a(b),b!=null&&b.from&&(b!=null&&b.to)&&(g({mode:"custom",from:b.from,to:b.to}),v(!1))},r=b=>{a(void 0),g(b),v(!1)};return e.jsxs(Rs,{open:k,onOpenChange:v,children:[e.jsx(As,{asChild:!0,children:e.jsxs("button",{type:"button",className:P("h-7 shrink-0 max-w-[46%] flex items-center justify-between gap-1 rounded-lg border border-border/40 bg-muted/50 px-2 text-[11px] font-sans font-semibold uppercase tracking-wide text-muted-foreground",W),children:[e.jsx("span",{className:"truncate",children:ln(x)}),e.jsx(ns,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),e.jsxs(Es,{align:"end",collisionPadding:12,className:"w-[min(19rem,calc(100vw-1.5rem))] max-w-[calc(100vw-1.5rem)] p-2 space-y-2",children:[e.jsx("button",{type:"button",onClick:()=>r({mode:"all"}),className:P("w-full rounded-md px-2 py-1.5 text-[11px] font-sans font-semibold uppercase tracking-wide border border-border/40",x.mode==="all"?"bg-primary/15 text-foreground":"text-muted-foreground hover:text-foreground"),children:"All-Time"}),e.jsx("div",{className:"max-h-40 overflow-y-auto overscroll-contain grid grid-cols-4 gap-1 pr-0.5",children:m.map(b=>e.jsx("button",{type:"button",onClick:()=>r({mode:"year",year:b}),className:P("rounded-md px-1 py-1.5 text-[11px] font-sans font-semibold uppercase tracking-wide border border-border/40",x.mode==="year"&&x.year===b?"bg-primary/15 text-foreground":"text-muted-foreground hover:text-foreground"),children:b},b))}),e.jsxs("div",{className:"border-t border-border/40 pt-2",children:[e.jsx("p",{className:"px-1 pb-1 text-[10px] font-sans uppercase tracking-wide text-muted-foreground",children:"Custom range"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(Qs,{mode:"range",selected:M,onSelect:q,defaultMonth:M==null?void 0:M.from,numberOfMonths:1,className:P("p-0 pointer-events-auto [--cell-size:2rem]")})})]})]})]})}const dn=()=>{const m=sn.getPlatform();
1return!!(m==="ios"||m==="android"||typeof navigator<"u"&&/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))},Mn=({initialPlayer1:m,initialPlayer2:x,onClose:g,onBack:W,showTitle:k=!1,onClearA:v,onClearB:M})=>{const[a,q]=l.useState(m||""),[r,b]=l.useState(x||""),[J,se]=l.useState(""),[I,ae]=l.useState(""),[fe,ce]=l.useState(!m),[he,ye]=l.useState(!x),[O,j]=l.useState(null),[y,z]=l.useState(null),[Y,Ne]=l.useState(!1),[R,Ce]=l.useState({mode:"all"}),[K,de]=l.useState("all"),[ne,qe]=l.useState("all"),[h,Z]=l.useState("all"),[L,ue]=l.useState({mode:"all"}),[S,as]=l.useState("all"),Je=L.mode==="all",[rs,os]=l.useState(null),[Te,ls]=l.useState("all"),[pe,ft]=l.useState([]),[Ve,ht]=l.useState(!1),[$e,pt]=l.useState([]),[is,Xe]=l.useState(!1),[cs,gt]=l.useState(""),ds=l.useRef(null),us=l.useRef(null);l.useRef(null),l.useRef(null);const{isLightTheme:me}=Ts(),{leftColor:Ue,rightColor:Qe}=$s(),{allPlayers:Ze,loading:ms}=Fs({defer:!0,listenToGlobalTrigger:!0}),xs=dn();Bs(xs);const[un,mn]=l.useState(null),[xn,fn]=l.useState(null),bt=Ze.length,Fe=l.useMemo(()=>new Hs(Ze,{threshold:.3,minMatchCharLength:2}),[bt>0?Math.floor(bt/10):0]),fs=l.useMemo(()=>!J||J.length<2?[]:Fe.search(Gt(J)).slice(0,10).map(t=>t.item).filter(t=>t!==r).slice(0,8),[Fe,J,r]),hs=l.useMemo(()=>!I||I.length<2?[]:Fe.search(Gt(I)).slice(0,10).map(t=>t.item).filter(t=>t!==a).slice(0,8),[Fe,I,a]),[De,wt]=l.useState(!1);l.useEffect(()=>{if(a&&r){const t=setTimeout(()=>wt(!0),100);return()=>clearTimeout(t)}else wt(!1)},[a,r]);const{stats:ps,loading:gs}=Ot(De&&a?[a]:[]),{stats:bs,loading:ws}=Ot(De&&r?[r]:[]),ge=a?ps[a]:void 0,be=r?bs[r]:void 0,{matches:et,loadingFullHistory:hn}=Is(),jt=l.useCallback(async()=>{if(!(!a||pe.length>0)){ht(!0);try{const t=Array.from(new Set([a,r].filter(Boolean))),s=await Promise.all(t.map(o=>ve.rpc("get_player_all_completed_matches",{_player:o,_limit:8e3}))),n=new Map;s.forEach(({data:o,error:d})=>{if(d){console.error("[H2H] Error fetching all-time data:",d);return}for(const c of o||[])n.set(c.id,{...c,time:c.match_time})}),console.log("[H2H] Fetched all-time data:",n.size,"matches"),ft(Array.from(n.values()))}catch(t){console.error("[H2H] Failed to fetch all-time data:",t)}finally{ht(!1)}}},[a,r,pe.length]);l.useEffect(()=>{a&&pe.length===0&&!Ve&&jt()},[a,pe.length,Ve,jt]),l.useEffect(()=>{ft([])},[a,r]);const tt=l.useMemo(()=>`${a.trim().toLowerCase()}|${r.trim().toLowerCase()}`,[a,r]),{mlpMatches:_e,mlpReady:we}=on(a,r);l.useEffect(()=>{if(pt([]),gt(""),!a||!r){Xe(!1);return}Xe(!0);let t=!1;return(async()=>{try{const{data:s,error:n}=await ve.rpc("get_player_h2h_history",{_player1:a,_player2:r});if(t)return;if(n){console.error("[H2H] Failed to fetch direct history:",n);return}pt((s||[]).map(o=>({...o,time:o.match_time}))),gt(tt)}catch(s){t||console.error("[H2H] Failed to fetch direct history:",s)}finally{t||Xe(!1)}})(),()=>{t=!0}},[a,r,tt]);const vt=cs===tt,st=l.useMemo(()=>et.filter(t=>t.status==="completed"),[et]),Be=l.useMemo(()=>{const t=pe.length>0?Array.from(new Map([...pe,...st].map(o=>[o.id,o])).values()):st;if(Te==="all")return t;const s=parseInt(Te,10),n=Date.now()-s*24*60*60*1e3;return t.filter(o=>{if(!o.time)return!0;const d=Date.parse(o.time);return!Number.isFinite(d)||d>=n})},[Te,pe,st]),ee=l.useMemo(()=>{if(!a)return[];const t=a.toLowerCase();return Be.filter(s=>s.team1.some(n=>n.toLowerCase()===t)||s.team2.some(n=>n.toLowerCase()===t))},[a,Be]),je=l.useMemo(()=>{if(!r)return[];const t=r.toLowerCase();return Be.filter(s=>s.team1.some(n=>n.toLowerCase()===t)||s.team2.some(n=>n.toLowerCase()===t))},[r,Be]),yt=l.useMemo(()=>{var s;if(!((s=ge==null?void 0:ge.recentMatches)!=null&&s.length))return[];const t=new Map;return ge.recentMatches.forEach(n=>{(n.team1.some(c=>c.toLowerCase()===a.toLowerCase())?n.team2:n.team1).forEach(c=>{c!=="TBD"&&c.toLowerCase()!==a.toLowerCase()&&t.set(c,(t.get(c)||0)+1)})}),Array.from(t.entries()).sort((n,o)=>o[1]-n[1]||n[0].localeCompare(o[0])).slice(0,6).map(([n])=>n)},[ge==null?void 0:ge.recentMatches,a]),Nt=l.useMemo(()=>{var s;if(!((s=be==null?void 0:be.recentMatches)!=null&&s.length))return[];const t=new Map;
1return be.recentMatches.forEach(n=>{(n.team1.some(c=>c.toLowerCase()===r.toLowerCase())?n.team2:n.team1).forEach(c=>{c!=="TBD"&&c.toLowerCase()!==r.toLowerCase()&&t.set(c,(t.get(c)||0)+1)})}),Array.from(t.entries()).sort((n,o)=>o[1]-n[1]||n[0].localeCompare(o[0])).slice(0,6).map(([n])=>n)},[be==null?void 0:be.recentMatches,r]),_t=(t,s)=>{if(s==="all")return!0;const n=(t||"").toLowerCase(),o=n.includes("women"),d=n.includes("mixed"),c=n.includes("doubles"),p=n.includes("singles");switch(s){case"mens-doubles":return c&&!o&&!d;case"womens-doubles":return c&&o&&!d;case"mixed-doubles":return d;case"mens-singles":return p&&!o&&!d;case"womens-singles":return p&&o&&!d;default:return!0}},Mt=(t,s)=>{if(!t||!(s!=null&&s.length))return null;const n=t.toLowerCase();let o=0,d=0,c=0;s.forEach(C=>{const _=C.team1.some(E=>E.toLowerCase()===n),D=C.games||[];let le=0,B=0;D.forEach(E=>{d+=_?E.team1Score:E.team2Score,c+=_?E.team2Score:E.team1Score,E.team1Score>E.team2Score?le++:E.team2Score>E.team1Score&&B++}),(_?le>B:B>le)&&o++});const p=s.length,i=p>0?o/p*100:0,f=d-c,u=d+c,w=u>0?d/u*100:50;return{totalMatches:p,wins:o,winRate:i,pointDiff:f,pointsWonPercent:w}},js=t=>{if(!t)return null;const s=new Date(t);return isNaN(s.getTime())?null:s.getUTCFullYear()},Pt=t=>{let s=t||[];return L.mode!=="all"&&(s=s.filter(n=>xt(n.time,L))),S!=="all"&&(s=s.filter(n=>_t(n.event,S))),s},Me=l.useMemo(()=>Mt(a,Pt(ee)),[a,ee,L,S]),Pe=l.useMemo(()=>Mt(r,Pt(je)),[r,je,L,S]),St=l.useMemo(()=>{const t=new Set;return[...ee||[],...je||[]].forEach(s=>{const n=js(s.time);n&&t.add(n)}),t},[ee,je]),{clutchStats:nt}=Yt(De&&a?a:"",90),{clutchStats:at}=Yt(De&&r?r:"",90),He=(t,s)=>{const n=Math.min(100,Math.max(0,(s+200)/400*100));return Math.round(t*.5+n*.5)};Me&&He(Me.winRate,Me.pointDiff),Pe&&He(Pe.winRate,Pe.pointDiff);const rt=t=>(t||"").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z\s]/g,"").trim(),Ie=t=>rt(t).split(/\s+/).pop()||"",kt=De&&!!a&&!!r,{data:Le}=Ut({queryKey:["h2h-mlp-season-totals",a,r],enabled:kt,staleTime:5*60*1e3,queryFn:async()=>{const{data:t,error:s}=await ve.from("mlp_player_season_totals").select("first_name, last_name, season_key, standing, reg_wins, reg_losses, tb_wins, tb_losses, points_earned, points_against, points_diff").or(`last_name.ilike.${Ie(a)},last_name.ilike.${Ie(r)}`);return s?[]:t||[]}}),{data:ot}=Ut({queryKey:["h2h-mlp-db-stats",a,r],enabled:kt,staleTime:5*60*1e3,queryFn:async()=>{const{data:t,error:s}=await ve.from("mlp_dreambreaker_player_stats").select("player_name, season, db_matches, points_won, points_lost").or(`player_name.ilike.%${Ie(a)}%,player_name.ilike.%${Ie(r)}%`);return s?[]:t||[]}}),ze=(t,s)=>{const n=rt(s),o=rt(t);if(!n||!o)return!1;if(o===n)return!0;const d=n.split(/\s+/),c=o.split(/\s+/);return c[c.length-1]===d[d.length-1]&&!!d[0]&&c[0].startsWith(d[0])},Ct=l.useMemo(()=>{const t=new Set;return(Le||[]).forEach(s=>{s.season_key&&(ze(`${s.first_name||""} ${s.last_name||""}`,a)||ze(`${s.first_name||""} ${s.last_name||""}`,r))&&t.add(String(s.season_key))}),t},[Le,a,r]),vs=l.useMemo(()=>{const t=new Set;return St.forEach(s=>t.add(String(s))),Ct.forEach(s=>t.add(String(s))),Array.from(t).sort((s,n)=>Number(n)-Number(s))},[St,Ct]),xe=l.useMemo(()=>cn(L),[L]),Dt=t=>{const s=(Le||[]).filter(u=>ze(`${u.first_name||""} ${u.last_name||""}`,t)&&(!xe||xe.includes(String(u.season_key))));if(!s.length)return null;let n=0,o=0,d=0,c=0,p=0;s.forEach(u=>{n+=(u.reg_wins||0)+(u.tb_wins||0),o+=(u.reg_losses||0)+(u.tb_losses||0),d+=u.points_earned||0,c+=u.points_against||0,p+=u.points_diff??(u.points_earned||0)-(u.points_against||0)});const i=n+o,f=d+c;return{standing:s.length===1&&s[0].standing||void 0,totalMatches:i,wins:n,winRate:i>0?n/i*100:0,pointDiff:p,pointsWonPercent:f>0?d/f*100:50}},Lt=t=>{const s=(ot||[]).filter(p=>ze(p.player_name||"",t)&&(!xe||xe.includes(String(p.season))));if(!s.length)return null;const n=s.reduce((p,i)=>p+(i.db_matches||0),0),o=s.reduce((p,i)=>p+(i.points_won||0),0),d=s.reduce((p,i)=>p+(i.points_lost||0),0),c=o+d;return{db_matches:n,points_won:o,points_lost:d,win_pct:c>0?o/c*100:0}},re=l.useMemo(()=>a?Dt(a):null,[Le,a,xe]),oe=l.useMemo(()=>r?Dt(r):null,[Le,r,xe]),V=l.useMemo(()=>a?Lt(a):null,[ot,a,xe]),X=l.useMemo(()=>r?Lt(r):null,[ot,r,xe]),Wt=(t,s)=>{if(!t&&!s)return null;const n=((t==null?void 0:t.totalMatches)||0)+((s==null?void 0:s.totalMatches)||0),o=((t==null?void 0:t.wins)||0)+((s==null?void 0:s.wins)||0),d=(t?t.pointsWonPercent*t.totalMatches:0)+(s?s.pointsWonPercent*s.totalMatches:0);return{totalMatches:n,wins:o,winRate:n>0?o/n*100:0,pointDiff:((t==null?void 0:t.pointDiff)||0)+((s==null?void 0:s.pointDiff)||0),pointsWonPercent:n>0?d/n:50}},ys=l.useMemo(()=>Wt(Me,re),[Me,re]),Ns=l.useMemo(()=>
1Wt(Pe,oe),[Pe,oe]),$=h==="ppa"?Me:h==="mlp"?re:ys,F=h==="ppa"?Pe:h==="mlp"?oe:Ns,_s=$?He($.winRate,$.pointDiff):void 0,Ms=F?He(F.winRate,F.pointDiff):void 0,Ps=h!=="ppa",lt=h!=="mlp"&&S==="all",Ss=!!(V!=null&&V.db_matches||X!=null&&X.db_matches),{getRating:Rt}=zs(),At=a?Rt(a):void 0,Et=r?Rt(r):void 0,Tt=t=>{if(!t)return;const s=[];if(t.ppaRankDoubles&&s.push({rank:t.ppaRankDoubles,priority:0}),t.ppaRankSingles&&s.push({rank:t.ppaRankSingles,priority:1}),s.length!==0)return s.sort((n,o)=>n.rank-o.rank||n.priority-o.priority),s[0].rank},$t=t=>{if(!t)return;const s=[];if(t.ppaPointsDoubles&&t.ppaRankDoubles&&s.push({points:t.ppaPointsDoubles,rank:t.ppaRankDoubles,priority:0}),t.ppaPointsSingles&&t.ppaRankSingles&&s.push({points:t.ppaPointsSingles,rank:t.ppaRankSingles,priority:1}),s.length!==0)return s.sort((n,o)=>n.rank-o.rank||n.priority-o.priority),Math.round(s[0].points)},Ft=Tt(At),Bt=Tt(Et),Ht=$t(At),It=$t(Et),it=t=>_t(t,K),Ge=l.useMemo(()=>{if(!a||!r)return[];const t=vt?$e:ee,s=a.toLowerCase(),n=r.toLowerCase(),o=(t||[]).filter(i=>{if(i.status!=="completed"||!it(i.event)||![...i.team1,...i.team2].map(_=>_.toLowerCase()).includes(n))return!1;const u=i.team1.map(_=>_.toLowerCase());i.team2.map(_=>_.toLowerCase());const w=u.includes(s),C=u.includes(n);return w!==C}),d=new Map;for(const i of o){const f=String(i.id),u=d.get(f);if(!u){d.set(f,{...i,source:"ppa"});continue}const w=(i.games||[]).length,C=(u.games||[]).length;if(w>C)d.set(f,{...i,source:"ppa"});else if(w===C){const _=i.updated_at?Date.parse(i.updated_at):0,D=u.updated_at?Date.parse(u.updated_at):0;_>D&&d.set(f,{...i,source:"ppa"})}}const c=ne==="mlp"?[]:Array.from(d.values()),p=ne==="ppa"?[]:(we?_e:[]).filter(i=>it(i.event)&&i.games.length>0);return[...c,...p]},[a,r,ee,$e,vt,K,ne,_e,we]),U=l.useMemo(()=>{var i;if(!a||!r||Ge.length===0)return null;let t=0,s=0;const n=[],o=a.toLowerCase(),d=r.toLowerCase();for(const f of Ge){const u=f.team1.map(T=>T.toLowerCase());f.team2.map(T=>T.toLowerCase());const w=u.includes(o);u.includes(d);const C=f.games||[];let _=0,D=0;C.forEach(T=>{T.team1Score>T.team2Score?_++:T.team2Score>T.team1Score&&D++});const B=_>D?w?a:r:w?r:a;B===a?t++:s++;const ie=C.map(T=>`${T.team1Score}-${T.team2Score}`).join(", "),E=C.reduce((T,Ee)=>T+(Ee.team1Score||0),0),Ae=C.reduce((T,Ee)=>T+(Ee.team2Score||0),0);n.push({id:f.id,tournament:f.tournament,round:f.round||"",event:f.event,winner:B,score:ie,time:f.time,source:f.source==="mlp"?"mlp":"ppa",p1Games:w?_:D,p2Games:w?D:_,p1Points:w?E:Ae,p2Points:w?Ae:E,gameLabels:f.gameLabels})}if(n.length===0)return null;n.sort((f,u)=>!f.time||!u.time?0:new Date(u.time).getTime()-new Date(f.time).getTime());const c=n.filter(f=>f.time),p=c.length>0?c.reduce((f,u)=>u.time&&(!f||new Date(u.time)<new Date(f))?u.time:f,((i=c[0])==null?void 0:i.time)||null):null;return{player1Wins:t,player2Wins:s,totalMatches:n.length,earliestMatchDate:p,matches:n}},[a,r,Ge]),ks=l.useMemo(()=>{const t=new Set,s=n=>{const o=n?new Date(n):null;o&&!isNaN(o.getTime())&&t.add(o.getUTCFullYear())};return((U==null?void 0:U.matches)||[]).forEach(n=>s(n.time)),(ee||[]).forEach(n=>s(n.time)),($e||[]).forEach(n=>
1s(n.time)),(we?_e:[]).forEach(n=>s(n.time)),Array.from(t).sort((n,o)=>o-n)},[U,ee,$e,_e,we]),G=l.useMemo(()=>U?R.mode==="all"?U.matches:U.matches.filter(t=>xt(t.time,R)):[],[U,R]),We=l.useMemo(()=>G.filter(t=>t.winner===a).length,[G,a]),Re=l.useMemo(()=>G.filter(t=>t.winner===r).length,[G,r]),A=l.useMemo(()=>{if(!G.length)return null;let t=0,s=0,n=0,o=0;G.forEach(u=>{t+=u.p1Games||0,s+=u.p2Games||0,n+=u.p1Points||0,o+=u.p2Points||0});let d=0,c=0,p=0;if(ne!=="ppa"&&we){const u=a.toLowerCase();_e.forEach(w=>{if(!xt(w.time,R)||!it(w.event))return;const C=w.team1.some(D=>D.toLowerCase()===u);let _=!1;w.games.forEach((D,le)=>{var B;(((B=w.gameLabels)==null?void 0:B[le])||"")==="DB"&&(d+=C?D.team1Score:D.team2Score,c+=C?D.team2Score:D.team1Score,_=!0)}),_&&p++})}const i=n+o,f=d+c;return{p1Games:t,p2Games:s,p1Points:n,p2Points:o,p1PointDiff:n-o,p1PointsWonPct:i>0?n/i*100:50,p2PointsWonPct:i>0?o/i*100:50,dbP1:d,dbP2:c,dbMeetings:p,dbP1Pct:f>0?d/f*100:0,dbP2Pct:f>0?c/f*100:0}},[G,_e,we,ne,R,K,a]),zt=()=>{j(null),se(""),ae("")},Cs=t=>{q(t),ce(!1),zt()},Ds=t=>{b(t),ye(!1),zt()},ct=()=>{q(""),ce(!0),v==null||v()},dt=()=>{b(""),ye(!0),M==null||M()},ut=a&&r,Ls=gs||ws||Ve;return ut&&U&&U.totalMatches>0&&(Oe,Ye,Kt,Ke,N,N,N,N,N,Oe,Ye,Kt,Ke,N,N,N,N,N,N),e.jsxs("div",{className:"w-full max-w-full min-w-0 overflow-x-hidden space-y-4",children:[k&&e.jsxs("div",{className:"flex items-center gap-2 text-scalable-sm font-semibold -mt-1",children:[e.jsx(Qt,{className:"h-4 w-4 text-primary"}),"Compare Players"]}),!ut&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2 max-w-[340px] mx-auto",children:[a&&!fe?e.jsxs("div",{className:P("relative flex w-full flex-col items-center justify-center gap-1.5 rounded-xl border p-4 aspect-[5/4]",me?"bg-white border-border":"bg-muted/30 border-border"),children:[e.jsx(qt,{variant:"ghost",size:"icon",onClick:ct,className:"absolute top-1 right-1 h-5 w-5",children:e.jsx(Se,{className:"h-3 w-3"})}),e.jsx(te,{name:a,className:"h-16 w-16"}),e.jsx("p",{className:"font-player text-[13px] font-[500] text-center truncate w-full uppercase tracking-wide",children:Jt(a)})]}):e.jsxs("button",{type:"button",className:P("flex w-full flex-col items-center justify-center gap-1 rounded-xl border border-dashed p-4 transition-colors aspect-[5/4]",me?"bg-white/50 border-border hover:bg-accent/30":"bg-muted/10 border-border/50 hover:bg-muted/20"),onClick:()=>{Vt(),j(1)},children:[e.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full border-2 border-dashed border-muted-foreground/40 bg-muted/40",children:e.jsx(Zt,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground -mb-0.5",children:"Choose"}),e.jsx("p",{className:"font-player text-[13px] font-[500] text-muted-foreground uppercase tracking-wide leading-tight",children:"Player 1"})]}),r&&!he?e.jsxs("div",{className:P("relative flex w-full flex-col items-center justify-center gap-1.5 rounded-xl border p-4 aspect-[5/4]",me?"bg-white border-border":"bg-muted/30 border-border"),children:[e.jsx(qt,{variant:"ghost",size:"icon",onClick:dt,className:"absolute top-1 right-1 h-5 w-5",children:e.jsx(Se,{className:"h-3 w-3"})}),e.jsx(te,{name:r,className:"h-16 w-16"}),e.jsx("p",{className:"font-player text-[13px] font-[500] text-center truncate w-full uppercase tracking-wide",children:Jt(r)})]}):e.jsxs("button",{type:"button",className:P("flex w-full flex-col items-center justify-center gap-1 rounded-xl border border-dashed p-4 transition-colors aspect-[5/4]",me?"bg-white/50 border-border hover:bg-accent/30":"bg-muted/10 border-border/50 hover:bg-muted/20"),onClick:()=>{Vt(),j(2)},children:[e.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full border-2 border-dashed border-muted-foreground/40 bg-muted/40",children:e.jsx(Zt,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground -mb-0.5",children:"Choose"}),e.jsx("p",{className:"font-player text-[13px] font-[500] text-muted-foreground uppercase tracking-wide leading-tight",children:"Player 2"})]})]}),e.jsxs(Gs,{open:O!==null,onOpenChange:t=>{t||(j(null),se(""),ae(""))},title:"Search player",desktopClassName:"sm:max-w-md px-4 pb-6 flex flex-col h-[85vh]",mobileClassName:"px-4 pb-6 flex flex-col h-[85dvh]",children:[e.jsx("div",{className:"pb-3 pt-2 shrink-0",children:e.jsxs("h2",{className:"text-base font-semibold",children:["Search ",O===1?"Player 
11":"Player 2"]})}),e.jsxs("div",{className:"relative mb-4 shrink-0",children:[e.jsx(Zs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Os,{ref:O===1?ds:us,value:O===1?J:I,onChange:t=>O===1?se(t.target.value):ae(t.target.value),placeholder:"Search player name...",className:"pl-9",autoFocus:!1})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto -mx-1 pr-1",children:(()=>{const t=O===1?J:I,s=O===1?fs:hs,n=O===1?Cs:Ds;if(ms&&t&&t.length>=2)return e.jsxs("div",{className:"space-y-2 px-1",children:[e.jsx(H,{className:"h-12 w-full rounded-lg"}),e.jsx(H,{className:"h-12 w-full rounded-lg"})]});if(t&&t.length>=2&&s.length>0)return e.jsx("div",{children:s.map(i=>e.jsxs("button",{type:"button",onClick:()=>n(i),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left rounded-lg transition-colors hover:bg-accent/50",children:[e.jsx(te,{name:i,className:"h-9 w-9"}),e.jsx("span",{className:"text-scalable-sm font-medium truncate",children:i})]},i))});if(t&&t.length>=2&&s.length===0&&Ze.length>0)return e.jsx("p",{className:"text-scalable-sm text-muted-foreground text-center py-4",children:"No players found"});const o=O===1?r:a,c=(O===2&&a&&yt.length>0?yt:O===1&&r&&Nt.length>0?Nt:[]).filter(i=>i!==o),p=["Ben Johns","Anna Leigh Waters","Federico Staksrud","JW Johnson","Catherine Parenteau","Anna Bright","Tyson McGuffin","Riley Newman","Lea Jansen","Dylan Frazier","Jorja Johnson","Julian Arnold"].filter(i=>i!==o);return e.jsxs("div",{className:"space-y-4",children:[c.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-scalable-xs text-muted-foreground font-medium mb-2",children:"Recent Opponents"}),e.jsx("div",{className:"space-y-0.5",children:c.map(i=>e.jsxs("button",{type:"button",onClick:()=>n(i),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left rounded-lg transition-colors hover:bg-accent/50",children:[e.jsx(te,{name:i,className:"h-9 w-9"}),e.jsx("span",{className:"text-scalable-sm font-medium truncate",children:i})]},i))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-scalable-xs text-muted-foreground font-medium mb-2",children:c.length>0?"Pro Players":"Suggested Players"}),e.jsx("div",{className:"space-y-0.5",children:p.map(i=>e.jsxs("button",{type:"button",onClick:()=>n(i),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left rounded-lg transition-colors hover:bg-accent/50",children:[e.jsx(te,{name:i,className:"h-9 w-9"}),e.jsx("span",{className:"text-scalable-sm font-medium truncate",children:i})]},i))})]})]})})()})]})]}),ut&&e.jsxs("div",{className:"w-full max-w-full min-w-0 overflow-x-hidden space-y-4",children:[is||!we?e.jsxs("div",{children:[e.jsx("div",{className:"pt-1 pb-0",children:e.jsxs("div",{className:"flex items-center justify-between px-2",children:[e.jsxs("div",{className:"text-center flex-1",children:[e.jsx(H,{className:"h-14 w-14 rounded-full mx-auto mb-1.5"}),e.jsx(H,{className:"h-4 w-16 mx-auto"}),e.jsx(H,{className:"h-6 w-8 mx-auto mt-1.5"})]}),e.jsx("div",{className:"relative flex items-center justify-center",children:e.jsx(H,{className:"h-[110px] w-[110px] rounded-full"})}),e.jsxs("div",{className:"text-center flex-1",children:[e.jsx(H,{className:"h-14 w-14 rounded-full mx-auto mb-1.5"}),e.jsx(H,{className:"h-4 w-16 mx-auto"}),e.jsx(H,{className:"h-6 w-8 mx-auto mt-1.5"})]})]})}),e.jsxs("div",{className:"space-y-1.5 mt-4",children:[e.jsx(H,{className:"h-[66px] w-full rounded-xl"}),e.jsx(H,{className:"h-[66px] w-full rounded-xl"}),e.jsx(H,{className:"h-[66px] w-full rounded-xl"})]})]}):U&&U.totalMatches>0?e.jsxs("div",{children:[(()=>{const c=G.length,p=c>0?We/c:0,i=c>0?Re/c:0,f=We>0,u=Re>0,w=f&&u,C=Math.max(0,360*i),_=Math.max(0,360*p),D=B=>{const ie=(B-90)*Math.PI/180;return{x:45+40*Math.cos(ie),y:45+40*Math.sin(ie)}},le=(B,ie)=>{const E=D(B),Ae=D(ie),Ee=Math.abs(ie-B)>180?1:0,Ws=ie>B?1:0;return`M ${E.x} ${E.y} A 40 40 0 ${Ee} ${Ws} ${Ae.x} ${Ae.y}`};return e.jsx("div",{className:"pt-1 pb-0",children:e.jsxs("div",{className:"flex items-center justify-between px-4",children:[e.jsxs("div",{className:"text-center flex-1",children:[e.jsxs("div",{className:"relative inline-block mb-1",children:[e.jsx(te,{name:a,className:"h-10 w-10 mx-auto"}),e.jsx("button",{onClick:ct,className:"absolute -top-0.5 -right-0.5 bg-muted border border-border rounded-full w-4 h-4 flex items-center justify-center cursor-pointer shadow-sm",children:e.jsx(Se,{className:"h-2.5 w-2.5 text-foreground"})})]}),e.jsx("p",{className:"font-score text-scalable-sm uppercase truncate max-w-28 mx-auto",children:a.split(" ").pop()}),e.jsx("p",{className:"text-2xl font-score mt-0.5 leading-tight",style:{color:Ue,opacity:We>0?1:.4},children:We})]}),e.jsxs("div",{className:"relative flex items-center justify-center shrink-0",children:[e.jsxs("svg",{width:90,height:90,viewB
1ox:"0 0 90 90",children:[!f&&!u&&e.jsx("circle",{cx:45,cy:45,r:40,fill:"none",stroke:"hsl(var(--muted-foreground) / 0.15)",strokeWidth:10}),u&&C>0&&e.jsx("path",{d:le(0,w?C:359.999),fill:"none",stroke:Qe,strokeOpacity:.85,strokeWidth:10,strokeLinecap:"butt"}),f&&_>0&&e.jsx("path",{d:le(0,-(w?_:359.999)),fill:"none",stroke:Ue,strokeWidth:10,strokeLinecap:"butt",className:"transition-all duration-700 ease-out"})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-xl font-score font-bold leading-none",children:c}),e.jsx("span",{className:"text-[10px] font-score text-muted-foreground leading-tight mt-0.5 tracking-wider",children:"MATCHES"})]})]}),e.jsxs("div",{className:"text-center flex-1",children:[e.jsxs("div",{className:"relative inline-block mb-1",children:[e.jsx(te,{name:r,className:"h-10 w-10 mx-auto"}),e.jsx("button",{onClick:dt,className:"absolute -top-0.5 -right-0.5 bg-muted border border-border rounded-full w-4 h-4 flex items-center justify-center cursor-pointer shadow-sm",children:e.jsx(Se,{className:"h-2.5 w-2.5 text-foreground"})})]}),e.jsx("p",{className:"font-score text-scalable-sm uppercase truncate max-w-28 mx-auto",children:r.split(" ").pop()}),e.jsx("p",{className:"text-2xl font-score mt-0.5 leading-tight",style:{color:Qe,opacity:Re>0?1:.4},children:Re})]})]})})})(),e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"flex-1 min-w-0 flex items-center gap-0.5 rounded-lg bg-muted/50 p-0.5 border border-border/40",children:[{key:"all",label:"All"},{key:"ppa",label:"PPA"},{key:"mlp",label:"MLP"}].map(t=>e.jsx("button",{type:"button",onClick:()=>qe(t.key),className:P("flex-1 rounded-md px-1 py-1 text-center text-[10px] font-sans font-semibold uppercase tracking-wide transition-colors",ne===t.key?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:t.label},t.key))}),ne!=="mlp"&&e.jsxs(Oe,{value:K,onValueChange:t=>de(t),children:[e.jsx(Ye,{className:"h-7 flex-1 min-w-0 justify-between gap-1 rounded-lg border border-border/40 bg-muted/50 px-2 text-[10px] font-sans font-semibold uppercase tracking-wide focus:ring-0 focus:ring-offset-0",children:e.jsx("span",{className:"truncate",children:K==="all"?"Events":K==="mens-doubles"?"MD":K==="womens-doubles"?"WD":K==="mixed-doubles"?"MXD":K==="mens-singles"?"MS":"WS"})}),e.jsxs(Ke,{className:"max-w-[calc(100vw-2rem)]",children:[e.jsx(N,{value:"all",className:"font-sans text-xs",children:"All Events"}),e.jsx(N,{value:"mens-doubles",className:"font-sans text-xs",children:"Men's Doubles"}),e.jsx(N,{value:"womens-doubles",className:"font-sans text-xs",children:"Women's Doubles"}),e.jsx(N,{value:"mixed-doubles",className:"font-sans text-xs",children:"Mixed Doubles"}),e.jsx(N,{value:"mens-singles",className:"font-sans text-xs",children:"Men's Singles"}),e.jsx(N,{value:"womens-singles",className:"font-sans text-xs",children:"Women's Singles"})]})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(ss,{years:ks.map(String),scope:R,onChange:Ce,className:"w-full max-w-none px-1.5 text-[10px]"})})]})}),A&&e.jsxs("div",{className:"mt-3 rounded-lg border border-border/40 bg-muted/20 p-2.5 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-sans uppercase tracking-wide text-muted-foreground text-center",children:"Against each other"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 text-center font-score text-base",children:We}),e.jsx("div",{className:"w-24 text-center text-[10px] font-sans uppercase tracking-wide text-muted-foreground",children:"Matches Won"}),e.jsx("div",{className:"flex-1 text-center font-score text-base",children:Re})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 text-center font-score text-base",children:A.p1Games}),e.jsx("div",{className:"w-24 text-center text-[10px] font-sans uppercase tracking-wide text-muted-foreground",children:"Games"}),e.jsx("div",{className:"flex-1 text-center font-score text-base",children:A.p2Games})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 text-center font-score text-base",children:A.p1Points}),e.jsx("div",{className:"w-24 text-center text-[10px] font-sans uppercase tracking-wide text-muted-foreground",children:"Points"}),e.jsx("div",{className:"flex-1 text-center font-score text-base",children:A.p2Points})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 text-center font-score text-base",children:[A.p1PointDiff>0?"+":"",A.p1PointDiff]}),e.jsx("div",{className:"w-24 text-center text-[10px] font-sans uppercase tracking-wide text-muted-foreground",children:"Point Diff"}),e.jsxs("div",{className:"flex-1 text-center font-score text-base",children:[-A.p1PointDiff>0?"+":"",-A.p1PointDiff]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 text-center font-score text-base",children:[A.p1PointsWonPct.toFixed(0),"%"]}),e.jsx("div",{className:"w-24 text-center text-[10px] font-sans uppercase tracking-wide text-muted-foreground",children:"Pts Won"}),e.jsxs("div",{className:"flex-1 text-center font-score text-base",children:[A.p2PointsWonPct.toFixed(0),"%"]})]}),A.dbMeetings>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 text-center font-score text-base",children:[A.dbP1," ",e.jsxs("span",{className:"font-sans text-[10px] text-muted-foreground",children:["(",A.dbP1Pct.toFixed(0),"%)"]})]}),e.jsx("div",{className:"w-24 text-center text-[10px] font-sans uppercase tracking-wide text-muted-foreground",children:"DB Pts"}),e.jsxs("div",{className:"flex-1 text-center font-score text-base",children:[A.dbP2," ",e.jsxs("span",{className:"font-sans text-[10px] text-muted-foreground",children:["(",A.dbP2Pct.toFixed(0),"%)"]})]})]})]}),G.length>0&&e.jsxs("div",{className:"space-y-1.5 mt-4",children:[e.jsx("div",{className:"flex items-center justify-between px-1",children:e.jsxs("p",{className:"text-scalable-xs font-medium text-muted-foreground flex items-center gap-1",children:[e.jsx(Qt,{className:"w-3 h-3"}),"Match History"]})}),e.jsx("div",{className:P("w-full max-w-full min-w-0 space-y-1.5 overflow-x-hidden",Y&&G.length>5&&"max-h-[300px] overflow-y-auto pr-1"),children:(Y?G:G.slice(0,3)).map(t=>{const s=t.winner===a,n=s?Ue:Qe,o=s?"left":"right",d=s?a.split(" ").pop():r.split(" ").pop(),c=Ys(t.round)||t.round||"",p=rs===t.id,i=t.score?t.score.split(", "):[];return e.jsxs("div",{className:P("min-w-0",p&&P("rounded-xl overflow-hidden mb-1.5 border [&>button]:rounded-none [&>button]:border-0 [&>
1button]:active:scale-100",me?"border-foreground/10":"border-white/10")),children:[e.jsx(Ks,{match:{id:t.id,tournament:t.tournament,round:t.round,event:t.event,score:t.score},winnerSide:o,winnerName:d,winnerColor:n,isLightTheme:me,scoreMode:"chips",roundLabel:c,onClick:()=>os(p?null:t.id)}),p&&e.jsxs("div",{className:P("relative border-t border-dashed p-2.5 space-y-2",me?"bg-foreground/[0.05] border-foreground/15":"bg-white/[0.06] border-white/15"),children:[e.jsx("div",{className:P("absolute top-0 bottom-0 w-[3px]",o==="left"?"left-0":"right-0"),style:{backgroundColor:n,opacity:.85}}),e.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground truncate",children:t.source==="mlp"?"MLP · shared games only":"PPA"}),t.source==="ppa"&&e.jsx("button",{onClick:()=>z(t.id),className:"text-[10px] font-medium text-primary shrink-0",children:"View match"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Games"}),e.jsxs("p",{className:"font-score text-base leading-none tracking-wide",children:[t.p1Games,"–",t.p2Games]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Points"}),e.jsxs("p",{className:"font-score text-base leading-none tracking-wide",children:[t.p1Points,"–",t.p2Points]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Point Diff"}),e.jsxs("p",{className:P("font-score text-base leading-none tracking-wide",t.p1Points-t.p2Points>0?"text-emerald-500":t.p1Points-t.p2Points<0?"text-rose-500":""),children:[t.p1Points-t.p2Points>0?"+":"",t.p1Points-t.p2Points]})]})]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap items-center justify-center gap-1",children:i.map((f,u)=>{var w;return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded bg-background/70 px-1.5 py-0.5",children:[e.jsx("span",{className:"font-sans text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:((w=t.gameLabels)==null?void 0:w[u])||`G${u+1}`}),e.jsx("span",{className:"font-sans text-[11px] font-semibold leading-none text-foreground",children:f})]},u)})})]})]},t.id)})}),G.length>3&&e.jsx("button",{onClick:()=>Ne(!Y),className:P("w-full flex items-center justify-center gap-1.5 py-1.5 text-xs font-medium rounded-lg transition-colors","text-primary hover:bg-primary/10"),children:Y?e.jsxs(e.Fragment,{children:[e.jsx(en,{className:"h-3.5 w-3.5"}),"Show Less"]}):e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"h-3.5 w-3.5"}),"View ",G.length-3," More"]})})]})]}):e.jsx("div",{children:e.jsx("div",{className:"pt-1 pb-0",children:e.jsxs("div",{className:"flex items-center justify-between px-2",children:[e.jsxs("div",{className:"text-center flex-1",children:[e.jsxs("div",{className:"relative inline-block",children:[e.jsx(te,{name:a,className:"h-14 w-14 mx-auto mb-1.5"}),e.jsx("button",{onClick:ct,className:"absolute -top-0.5 -right-0.5 bg-muted border border-border rounded-full w-4 h-4 flex items-center justify-center cursor-pointer shadow-sm",children:e.jsx(Se,{className:"h-2.5 w-2.5 text-foreground"})})]}),e.jsx("p",{className:"font-score text-scalable-sm truncate max-w-24 mx-auto",children:a.split(" ").pop()})]}),e.jsxs("div",{className:"relative flex items-center justify-center",children:[e.jsx("svg",{width:110,height:110,viewBox:"0 0 110 110",className:"transform -rotate-90",children:e.jsx("circle",{cx:110/2,cy:110/2,r:49,fill:"none",stroke:"hsl(var(--muted-foreground) / 0.15)",strokeWidth:12,strokeLinecap:"round"})}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-2xl font-score font-bold leading-none",children:"0"}),e.jsx("span",{className:"text-[11px] font-score text-muted-foreground leading-tight mt-0.5 tracking-wider",children:"MATCHES"})]})]}),e.jsxs("div",{className:"text-center flex-1",children:[e.jsxs("div",{className:"relative inline-block",children:[e.jsx(te,{name:r,className:"h-14 w-14 mx-auto mb-1.5"}),e.jsx("button",{onClick:dt,className:"absolute -top-0.5 -right-0.5 bg-muted border border-border rounded-full w-4 h-4 flex items-center justify-center cursor-pointer shadow-sm",children:e.jsx(Se,{className:"h-2.5 w-2.5 text-foreground"})})]}),e.jsx("p",{className:"font-score text-scalable-sm truncate max-w-24 mx-auto",children:r.split(" ").pop()})]})]})})}),e.jsxs(qs,{className:P("border-border/50",me?"bg-white":"bg-gradient-match-card"),
1children:[e.jsx(Js,{className:"pb-2 space-y-2",children:e.jsxs(Vs,{className:"text-base flex items-center gap-2",children:[e.jsx(tn,{className:"h-4 w-4 text-primary"}),"Stats Comparison"]})}),e.jsx(Xs,{children:Ls?e.jsxs("div",{className:"space-y-3",children:[e.jsx(H,{className:"h-12 w-full"}),e.jsx(H,{className:"h-12 w-full"}),e.jsx(H,{className:"h-12 w-full"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-3 border-b border-border/30",children:[e.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1.5 min-w-0",children:[e.jsx(te,{name:a,className:"h-16 w-16 ring-2 ring-border/40"}),e.jsx("div",{className:"text-center text-sm font-score text-muted-foreground truncate max-w-full px-1",children:Xt(a,r)})]}),e.jsx("div",{className:"w-20 flex items-center justify-center",children:e.jsx("span",{className:"font-score text-lg italic text-muted-foreground/70",children:"VS"})}),e.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1.5 min-w-0",children:[e.jsx(te,{name:r,className:"h-16 w-16 ring-2 ring-border/40"}),e.jsx("div",{className:"text-center text-sm font-score text-muted-foreground truncate max-w-full px-1",children:Xt(r,a)})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"flex-1 min-w-0 flex items-center gap-0.5 rounded-lg bg-muted/50 p-0.5 border border-border/40",children:[{key:"all",label:"All"},{key:"ppa",label:"PPA"},{key:"mlp",label:"MLP"}].map(t=>e.jsx("button",{type:"button",onClick:()=>Z(t.key),className:P("flex-1 rounded-md px-1 py-1 text-center text-[10px] font-sans font-semibold uppercase tracking-wide transition-colors",h===t.key?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:t.label},t.key))}),h!=="mlp"&&e.jsxs(Oe,{value:S,onValueChange:t=>as(t),children:[e.jsx(Ye,{className:"h-7 flex-1 min-w-0 justify-between gap-1 rounded-lg border border-border/40 bg-muted/50 px-2 text-[10px] font-sans font-semibold uppercase tracking-wide focus:ring-0 focus:ring-offset-0",children:e.jsx("span",{className:"truncate",children:S==="all"?"Events":S==="mens-doubles"?"MD":S==="womens-doubles"?"WD":S==="mixed-doubles"?"MXD":S==="mens-singles"?"MS":"WS"})}),e.jsxs(Ke,{className:"max-w-[calc(100vw-2rem)]",children:[e.jsx(N,{value:"all",className:"font-sans text-xs",children:"All Events"}),e.jsx(N,{value:"mens-doubles",className:"font-sans text-xs",children:"Men's Doubles"}),e.jsx(N,{value:"womens-doubles",className:"font-sans text-xs",children:"Women's Doubles"}),e.jsx(N,{value:"mixed-doubles",className:"font-sans text-xs",children:"Mixed Doubles"}),e.jsx(N,{value:"mens-singles",className:"font-sans text-xs",children:"Men's Singles"}),e.jsx(N,{value:"womens-singles",className:"font-sans text-xs",children:"Women's Singles"})]})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(ss,{years:vs,scope:L,onChange:ue,className:"w-full max-w-none px-1.5 text-[10px]"})})]}),lt&&Je&&(Ft!==void 0||Bt!==void 0)&&e.jsx(Q,{label:"PPA Rank",value1:Ft,value2:Bt,format:t=>`#${t}`,higherIsBetter:!1}),lt&&Je&&(Ht!==void 0||It!==void 0)&&e.jsx(Q,{label:"PPA Pts",value1:Ht,value2:It,format:t=>`${t.toLocaleString()}`,higherIsBetter:!0}),h==="mlp"&&((re==null?void 0:re.standing)!==void 0||(oe==null?void 0:oe.standing)!==void 0)&&e.jsx(Q,{label:"MLP Rank",value1:re==null?void 0:re.standing,value2:oe==null?void 0:oe.standing,format:t=>`#${t}`,higherIsBetter:!1}),e.jsx(Q,{label:"Matches",value1:$==null?void 0:$.totalMatches,value2:F==null?void 0:F.totalMatches,format:t=>`${t}`,higherIsBetter:!0}),e.jsx(Q,{label:"Win Rate",value1:$==null?void 0:$.winRate,value2:F==null?void 0:F.winRate,format:t=>`${t.toFixed(0)}%`,higherIsBetter:!0}),e.jsx(Q,{label:"Power Rank",value1:_s,value2:Ms,format:t=>`${t}%`,higherIsBetter:!0}),lt&&Je&&e.jsx(Q,{label:"Clutch Index",value1:nt==null?void 0:nt.clutchIndex,value2:at==null?void 0:at.clutchIndex,format:t=>`${t.toFixed(0)}%`,higherIsBetter:!0}),e.jsx(Q,{label:"Point Diff",value1:$==null?void 0:$.pointDiff,value2:F==null?void 0:F.pointDiff,format:t=>`${t>0?"+":""}${t}`,higherIsBetter:!0}),e.jsx(Q,{label:"Pts Won %",value1:$==null?void 0:$.pointsWonPercent,value2:F==null?void 0:F.pointsWonPercent,format:t=>`${t.toFixed(0)}%`,higherIsBetter:!0}),Ps&&Ss&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-px flex-1 bg-border/40"}),e.jsx("span",{className:"text-[10px] font-sans uppercase tracking-wide text-muted-foreground",children:"DreamBreaker"}),e.jsx("div",{className:"h-px flex-1 bg-border/40"})]}),e.jsx(Q,{label:"DB Played",value1:V==null?void 0:V.db_matches,value2:X==null?void 0:X.db_matches,format:t=>`${t}`,higherIsBetter:!0}),e.jsx(Q,{label:"DB Pts Won",value1:V==null?void 0:V.points_won,value2:X==null?void 0:X.points_won,format:t=>`${t}`,higherIsBetter:!0}),e.jsx(Q,{label:"DB Win %",value1:V==null?void 0:V.win_pct,value2:X==null?void 0:X.win_pct,format:t=>`${t.toFixed(0)}%`,higherIsBetter:!0})]})]})})]})]}),e.jsx(Us,{match:y?(()=>{const t=et.find(s=>
1s.id===y)||Ge.find(s=>s.id===y)||(ee==null?void 0:ee.find(s=>s.id===y))||(je==null?void 0:je.find(s=>s.id===y));return t?{...t,best_of:t.best_of}:null})():null,open:!!y,onOpenChange:t=>!t&&z(null)})]})},Q=({label:m,value1:x,value2:g,format:W,higherIsBetter:k})=>{const v=x??0,M=g??0,a=k?v>M?1:M>v?2:0:v<M?1:M<v?2:0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:P("flex-1 text-center font-score text-lg",a===1?"text-primary":"text-foreground"),children:[x!==void 0?W(v):"-",a===1&&e.jsx(es,{className:"inline h-3 w-3 ml-1 text-primary"})]}),e.jsx("div",{className:"w-20 text-center text-scalable-xs text-muted-foreground font-medium",children:m}),e.jsxs("div",{className:P("flex-1 text-center font-score text-lg",a===2?"text-primary":"text-foreground"),children:[a===2&&e.jsx(es,{className:"inline h-3 w-3 mr-1 text-primary"}),g!==void 0?W(M):"-"]})]})};export{Mn as HeadToHeadComparison};

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.