import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{Cn as t,Dn as n,Hr as r,Kt as i,Pn as a,Pr as o,Rn as s,Tn as c,Un as l,Xt as u,Yt as d,Zr as f,_i as p,an as m,c as h,d as g,ei as _,f as v,fi as y,gi as b,ii as x,jr as ee,l as te,mr as S,rn as C,u as ne,un as w}from"./vendor-DkM0BOLc.js";import{n as re,t as ie}from"./api--bJYSUUx.js";import{A as ae,D as oe,I as se,J as ce,K as le,M as ue,O as de,_ as fe,d as pe,f as me,j as he,k as T,lt as ge,u as _e,vt as E}from"./index-CYbEqOJT.js";import{i as D,n as ve,r as ye,t as be}from"./tooltip--hVBqEyY.js";import{t as xe}from"./status-pill-DnoqUkEp.js";import{t as O}from"./AgentIcon-Juqp0kn6.js";import{t as Se}from"./MapImage-CrNZxpK2.js";import{t as k}from"./delta-pill-Dcsd7ZTA.js";import{t as Ce}from"./useMatch-DKNMohXv.js";import{i as A,n as we,r as j,t as Te}from"./TaleOfTape-D4pWAjE2.js";import{n as Ee}from"./seo-helpers-yv5d9z5e.js";import{n as De,r as Oe,t as ke}from"./EditWidgetsButton-CzYV-Aym.js";import{t as Ae}from"./WatchButton-DUBFMJdf.js";import{i as je,n as M,r as Me,t as N}from"./pick-stream-link-DY3HKYG8.js";var P=e(p(),1);function Ne(e,t,n){return f({queryKey:[`live-match`,e,t],queryFn:()=>re(`/games/${e}/matches/${t}/live`),enabled:n&&!!t,refetchInterval:5e3,staleTime:3e3,retry:1,throwOnError:!1})}function Pe(e,t,n){return f({queryKey:[`matchPreview`,e,t],queryFn:()=>re(`/games/${e}/matches/${t}/preview`),enabled:!!t&&n,staleTime:300*1e3})}var F=_();function Fe({match:e,preview:t,gameSlug:n}){let r=e.team1??{id:``,name:`TBD`,abbreviation:null,logoUrl:null,slug:``},a=e.team2??{id:``,name:`TBD`,abbreviation:null,logoUrl:null,slug:``},o=t.team1,s=t.team2,c=t.h2h,u=e.stats?.streamLinks??[],f=e.stats?.vodLinks??[],p=!e.playedAt&&u.length===0&&e.tournament?ge(e.tournament.name):null,m=u.length>0?u:p?[p.primary,...p.coStreams]:[],h=e.playedAt?f:m,g=1/(1+10**(-(e=>1/Math.sqrt(1+e*e*3/(Math.PI*Math.PI*400*400)))(Math.sqrt(o.rd*o.rd+s.rd*s.rd))*(o.rating-s.rating)/400)),_=Math.round(g*100),v=100-_,y=_>=v;return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[h.length>0&&(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(i,{size:14,className:`text-zinc-400`}),h.map((e,t)=>(0,F.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:E(`flex items-center gap-1 rounded-full px-3 py-1 text-xs font-medium transition-colors`,e.platform?.toLowerCase().includes(`twitch`)?`bg-purple-500/10 text-purple-500 hover:bg-purple-500/20`:e.platform?.toLowerCase().includes(`youtube`)?`bg-red-500/10 text-red-500 hover:bg-red-500/20`:`bg-zinc-200/80 text-zinc-700 hover:bg-zinc-300 hover:text-zinc-900 dark:bg-zinc-800 dark:text-zinc-300 dark:hover:bg-zinc-700 dark:hover:text-zinc-100`),children:[e.platform,(0,F.jsx)(S,{size:10})]},t))]}),(0,F.jsx)(`div`,{className:`glk-card !p-0 overflow-hidden`,children:(0,F.jsxs)(`div`,{className:`relative bg-zinc-50 px-5 py-5 dark:bg-zinc-900`,children:[(0,F.jsxs)(`div`,{className:`glk-eyebrow mb-4 flex items-center justify-center gap-1.5`,children:[(0,F.jsx)(C,{size:10}),`Win Probability`]}),(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(ae,{name:r.name,slug:r.slug,abbreviation:r.abbreviation,logoUrl:r.logoUrl,size:`lg`}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:E(`text-sm font-black`,y?`text-zinc-900 dark:text-zinc-100`:`text-zinc-400`),children:r.abbreviation??r.name}),(0,F.jsx)(`div`,{className:`flex items-baseline gap-1`,children:(0,F.jsxs)(`span`,{className:E(`glk-metric-md`,y?`text-sky-500`:`text-zinc-400`),children:[_,`%`]})})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsx)(`div`,{className:E(`text-sm font-black`,y?`text-zinc-400`:`text-zinc-900 dark:text-zinc-100`),children:a.abbreviation??a.name}),(0,F.jsx)(`div`,{className:`flex items-baseline justify-end gap-1`,children:(0,F.jsxs)(`span`,{className:E(`glk-metric-md`,y?`text-zinc-400`:`text-sky-500`),children:[v,`%`]})})]}),(0,F.jsx)(ae,{name:a.name,slug:a.slug,abbreviation:a.abbreviation,logoUrl:a.logoUrl,size:`lg`})]})]}),(0,F.jsxs)(`div`,{className:`flex h-3 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700`,children:[(0,F.jsx)(`div`,{className:`rounded-l-full bg-sky-500 transition-all`,style:{width:`${_}%`}}),(0,F.jsx)(`div`,{className:`flex-1 rounded-r-full`})]}),(0,F.jsxs)(`div`,{className:`mt-3 flex items-center justify-between glk-tabular text-xs text-zinc-400`,children:[(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`span`,{className:`font-bold text-zinc-600 dark:text-zinc-300`,children:o.rating}),` `,`±`,o.rd]}),(0,F.jsx)(`span`,{className:`glk-eyebrow`,children:`Glicko Rating`}),(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`span`,{className:`font-bold text-zinc-600 dark:text-zinc-300`,children:s.rating}),` `,`±`,s.rd]})]})]})}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsxs)(`div`,{className:`glk-card`,children:[(0,F.jsxs)(`div`,{className:`glk-eyebrow mb-3 flex items-center gap-1.5`,children:[(0,F.jsx)(d,{size:10}),`Recent Form`]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(Ie,{name:r.abbreviation??r.name,logoUrl:r.logoUrl,teamName:r.name,slug:r.slug,abbreviation:r.abbreviation,form:o.recentForm}),(0,F.jsx)(`div`,{className:`border-t border-zinc-100 dark:border-zinc-800`}),(0,F.jsx)(Ie,{name:a.abbreviation??a.name,logoUrl:a.logoUrl,teamName:a.name,slug:a.slug,abbreviation:a.abbreviation,form:s.recentForm})]})]}),(0,F.jsxs)(`div`,{className:`glk-card`,children:[(0,F.jsxs)(`div`,{className:`glk-eyebrow mb-3 flex items-center gap-1.5`,children:[(0,F.jsx)(C,{size:10}),`Head to Head`]}),c.totalMatches>0?(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`glk-metric-md text-zinc-900 dark:text-zinc-100`,children:c.team1Wins}),(0,F.jsx)(`div`,{className:`flex h-2 flex-1 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700`,children:(0,F.jsx)(`div`,{className:`bg-sky-500 transition-all`,style:{width:`${c.totalMatches>0?c.team1Wins/c.totalMatches*100:50}%`}})}),(0,F.jsx)(`span`,{className:`glk-metric-md text-zinc-900 dark:text-zinc-100`,children:c.team2Wins})]}),(0,F.jsx)(`div`,{className:`space-y-1`,children:c.recentMeetings.slice(0,3).map((e,t)=>(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md bg-zinc-50 px-2 py-1 text-xs dark:bg-zinc-800/50`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400`,children:e.date}),(0,F.jsx)(`span`,{className:`font-bold text-zinc-600 dark:text-zinc-300`,children:e.score}),(0,F.jsx)(`span`,{className:`max-w-[80px] truncate text-right text-zinc-400`,children:e.tournament})]},t))})]}):(0,F.jsx)(`div`,{className:`flex flex-col items-center justify-center py-4`,children:(0,F.jsx)(xe,{tone:`warning`,uppercase:!1,children:`First meeting`})})]})]}),o.mapPool.length>0&&s.mapPool.length>0&&(0,F.jsxs)(`div`,{className:`glk-card`,children:[(0,F.jsxs)(`div`,{className:`glk-eyebrow mb-3 flex items-center gap-1.5`,children:[(0,F.jsx)(l,{size:10}),`Map Pool Comparison`]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-2xs font-medium text-zinc-400`,children:[(0,F.jsx)(`span`,{className:`w-12 text-right`,children:r.abbreviation??`T1`}),(0,F.jsx)(`span`,{className:`flex-1`}),(0,F.jsx)(`span`,{className:`w-14 text-center`,children:`Map`}),(0,F.jsx)(`span`,{className:`flex-1`}),(0,F.jsx)(`span`,{className:`w-12`,children:a.abbreviation??`T2`})]}),Le(o.mapPool,s.mapPool).map(e=>(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`w-12 text-right glk-metric-sm text-zinc-600 dark:text-zinc-300`,children:[Math.round(e.t1WinRate*100),`%`]}),(0,F.jsx)(`div`,{className:`flex h-2.5 flex-1 flex-row-reverse overflow-hidden rounded-full bg-zinc-100 dark:bg-zinc-800`,children:(0,F.jsx)(`div`,{className:`rounded-full bg-sky-500/70`,style:{width:`${e.t1WinRate*100}%`}})}),(0,F.jsxs)(`div`,{className:`w-14 text-center`,children:[(0,F.jsx)(`div`,{className:`text-xs font-bold text-zinc-900 dark:text-zinc-100`,children:e.mapName}),(0,F.jsxs)(`div`,{className:`glk-tabular text-[9px] text-zinc-400`,children:[e.t1Plays+e.t2Plays,` played`]})]}),(0,F.jsx)(`div`,{className:`flex h-2.5 flex-1 overflow-hidden rounded-full bg-zinc-100 dark:bg-zinc-800`,children:(0,F.jsx)(`div`,{className:`rounded-full bg-emerald-500/70`,style:{width:`${e.t2WinRate*100}%`}})}),(0,F.jsxs)(`span`,{className:`w-12 glk-metric-sm text-zinc-600 dark:text-zinc-300`,children:[Math.round(e.t2WinRate*100),`%`]})]},e.mapName))]})]})]})}function Ie({name:e,teamName:t,slug:n,abbreviation:r,logoUrl:i,form:a}){let o=a.filter(e=>e===`W`).length,s=a.filter(e=>e===`L`).length;return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,F.jsx)(ae,{name:t,slug:n,abbreviation:r,logoUrl:i,size:`xs`}),(0,F.jsx)(`span`,{className:`text-xs font-bold text-zinc-900 dark:text-zinc-100`,children:e}),(0,F.jsxs)(`span`,{className:`glk-tabular text-2xs text-zinc-400`,children:[o,`W `,s,`L`]})]}),(0,F.jsx)(`div`,{className:`flex gap-1`,children:a.map((e,t)=>(0,F.jsx)(`div`,{className:E(`h-4 w-4 rounded-sm text-center text-[9px] font-bold leading-4`,e===`W`?`bg-emerald-500/20 text-emerald-500`:`bg-red-500/15 text-red-400`),children:e},t))})]})}function Le(e,t){let n=new Map(t.map(e=>[e.mapName,e]));return e.filter(e=>n.has(e.mapName)).map(e=>({mapName:e.mapName,t1WinRate:e.winRate,t2WinRate:n.get(e.mapName).winRate,t1Plays:e.playCount,t2Plays:n.get(e.mapName).playCount})).sort((e,t)=>t.t1WinRate+t.t2WinRate-(e.t1WinRate+e.t2WinRate)).slice(0,7)}var I=`var(--glk-team1)`,L=`var(--glk-team2)`,R={elimination:`Elimination`,defuse:`Defuse`,detonate:`Detonate`,time:`Time out`},z={pistol:`Pistol`,eco:`Eco`,force:`Force buy`,full:`Full buy`};function B(e,t){let n=A(e,t),r=[],i=Array(e.length).fill(1),a=Array(e.length).fill(!1);for(let n=0;n<e.length;n++){let r=e[n].winnerTeamId===t,o=1;for(let i=n+1;i<e.length&&e[i].winnerTeamId===t===r;i++)o++;o>=3&&(n===0||e[n-1].winnerTeamId===t!==r)&&(a[n]=!0),i[n]=o}for(let o=0;o<e.length;o++){let s=e[o],c=n[o],l=s.winnerTeamId===t,u=s.roundNumber===1||s.roundNumber===13,d=j(s.roundNumber,l?s.team1LoadoutValue:s.team2LoadoutValue),f=l?s.team1LoadoutValue:s.team2LoadoutValue,p=l?s.team2LoadoutValue:s.team1LoadoutValue,m=f!=null&&p!=null&&p>f+5e3;r.push({round:s.roundNumber,diff:c.team1-c.team2,team1Score:c.team1,team2Score:c.team2,isTeam1Win:l,winType:s.winType,buyType:d,isPistol:u,isEcoWin:m,isStreakStart:a[o],streakLength:i[o]})}return r}var V=170,H=28,U=24,W=28,Re=4,ze=6,Be=5;function Ve({point:e,x:t,y:n,team1Name:r,team2Name:i}){return(0,F.jsxs)(`div`,{className:`pointer-events-none absolute z-10 rounded-lg border border-zinc-200 bg-white px-3 py-2 shadow-lg dark:border-zinc-700 dark:bg-zinc-800`,style:{left:Math.max(180/2,Math.min(t,600-180/2)),top:n-70,transform:`translateX(-50%)`,width:180},children:[(0,F.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,F.jsxs)(`span`,{className:`text-xs font-semibold uppercase text-zinc-400`,children:[`Round `,e.round]}),(0,F.jsxs)(`span`,{className:`text-xs font-bold tabular-nums text-zinc-900 dark:text-zinc-100`,children:[e.team1Score,`–`,e.team2Score]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:e.isTeam1Win?I:L}}),(0,F.jsx)(`span`,{className:`text-xs font-medium text-zinc-700 dark:text-zinc-300`,children:e.isTeam1Win?r:i})]}),(0,F.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-xs text-zinc-400`,children:[e.winType&&(0,F.jsx)(`span`,{children:R[e.winType]??e.winType}),e.buyType&&(0,F.jsxs)(`span`,{children:[`· `,z[e.buyType]]}),e.isEcoWin&&(0,F.jsx)(`span`,{className:`text-cyan-400`,children:`· Eco win!`})]})]})}function He({team1Name:e,team2Name:t}){let[n,r]=(0,P.useState)(!1);return(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(`button`,{onClick:()=>r(e=>!e),className:`flex h-4 w-4 items-center justify-center rounded-full border border-zinc-300 text-xs font-bold text-zinc-400 transition-colors hover:border-zinc-400 hover:text-zinc-500 dark:border-zinc-600 dark:hover:border-zinc-500 dark:hover:text-zinc-300`,"aria-label":`How to read this chart`,children:`?`}),n&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`fixed inset-0 z-20`,onClick:()=>r(!1)}),(0,F.jsxs)(`div`,{className:`absolute right-0 top-6 z-30 w-56 max-w-[calc(100vw-2rem)] rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-800`,children:[(0,F.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-zinc-700 dark:text-zinc-200`,children:`Reading the chart`}),(0,F.jsxs)(`ul`,{className:`space-y-1.5 text-xs leading-relaxed text-zinc-500 dark:text-zinc-400`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:I},children:e}),` leads when line goes up`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:L},children:t}),` leads when line goes down`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`span`,{className:`font-medium text-zinc-600 dark:text-zinc-300`,children:`Center line`}),` = tied score`]}),(0,F.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block h-2 w-2 rotate-45 rounded-[1px] bg-zinc-400`}),`Pistol rounds (R1, R13)`]}),(0,F.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full border border-cyan-400`}),`Eco win (upset)`]})]}),(0,F.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400`,children:`Hover dots for round details`})]})]})]})}function Ue({rounds:e,team1Id:t,team2Id:n,team1Name:r=`Team 1`,team2Name:i=`Team 2`,className:a}){let[o,s]=(0,P.useState)(null),c=(0,P.useMemo)(()=>B(e,t),[e,t]),l=e.some(e=>e.roundNumber>=25),u=c.length,d=(0,P.useMemo)(()=>{let e=Math.max(...c.map(e=>Math.abs(e.diff)),1);return Math.max(e,3)},[c]),f=(0,P.useCallback)((e,t)=>{let n=t-H*2;return H+e/Math.max(u-1,1)*n},[u]),p=(0,P.useCallback)(e=>{let t=V-U-W;return U+t/2-e/d*(t/2)},[d]),m=p(0),h=c.map((e,t)=>{let n=f(t,600),r=p(e.diff);return`${t===0?`M`:`L`} ${n} ${r}`}).join(` `),g=e=>{if(c.length<2)return``;let t=[];for(let n=0;n<c.length-1;n++){let r=f(n,600),i=p(c[n].diff),a=f(n+1,600),o=p(c[n+1].diff),s=c[n].diff,l=c[n+1].diff;if(s>=0&&l>=0||s<=0&&l<=0){if(e?s>=0||l>=0:s<=0||l<=0){let e=m;t.push(`M ${r} ${e} L ${r} ${i} L ${a} ${o} L ${a} ${e} Z`)}}else{let n=r+s/(s-l)*(a-r);(e?s>0:s<0)&&t.push(`M ${r} ${m} L ${r} ${i} L ${n} ${m} Z`),(e?l>0:l<0)&&t.push(`M ${n} ${m} L ${a} ${o} L ${a} ${m} Z`)}}return t.join(` `)},_=g(!0),v=g(!1),y=c.findIndex(e=>e.round===13),b=l?c.findIndex(e=>e.round===25):-1;return(0,F.jsxs)(`div`,{className:E(`relative`,a),children:[(0,F.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-4 text-xs`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:I}}),(0,F.jsx)(`span`,{className:`font-medium text-zinc-500 dark:text-zinc-400`,children:r})]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:L}}),(0,F.jsx)(`span`,{className:`font-medium text-zinc-500 dark:text-zinc-400`,children:i})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-zinc-400`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full border border-cyan-400`}),`Pistol`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-cyan-400/60`}),`Eco win`]}),(0,F.jsx)(He,{team1Name:r,team2Name:i})]})]}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsxs)(`svg`,{viewBox:`0 0 600 ${V}`,className:`w-full`,preserveAspectRatio:`xMidYMid meet`,role:`img`,"aria-label":`Momentum chart showing ${r} vs ${i} score differential across ${u} rounds. ${r} leads when the line is above center, ${i} leads when below.`,children:[(0,F.jsxs)(`defs`,{children:[(0,F.jsxs)(`linearGradient`,{id:`rb-grad-t1`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`0%`,stopColor:`var(--glk-team1)`,stopOpacity:`0.25`}),(0,F.jsx)(`stop`,{offset:`100%`,stopColor:`var(--glk-team1)`,stopOpacity:`0.03`})]}),(0,F.jsxs)(`linearGradient`,{id:`rb-grad-t2`,x1:`0`,y1:`1`,x2:`0`,y2:`0`,children:[(0,F.jsx)(`stop`,{offset:`0%`,stopColor:`var(--glk-team2)`,stopOpacity:`0.25`}),(0,F.jsx)(`stop`,{offset:`100%`,stopColor:`var(--glk-team2)`,stopOpacity:`0.03`})]})]}),(0,F.jsx)(`path`,{d:_,fill:`url(#rb-grad-t1)`}),(0,F.jsx)(`path`,{d:v,fill:`url(#rb-grad-t2)`}),(0,F.jsx)(`line`,{x1:H,y1:m,x2:600-H,y2:m,stroke:`currentColor`,strokeOpacity:`0.1`,strokeWidth:`1`,strokeDasharray:`4 3`}),y>0&&(()=>{let e=(f(y-1,600)+f(y,600))/2;return(0,F.jsxs)(`g`,{children:[(0,F.jsx)(`line`,{x1:e,y1:U,x2:e,y2:V-W,stroke:`currentColor`,strokeOpacity:`0.1`,strokeWidth:`1`,strokeDasharray:`3 3`}),(0,F.jsx)(`text`,{x:e,y:U-6,textAnchor:`middle`,className:`fill-zinc-400 text-xs font-semibold`,children:`HT`})]})})(),b>0&&(()=>{let e=(f(b-1,600)+f(b,600))/2;return(0,F.jsxs)(`g`,{children:[(0,F.jsx)(`line`,{x1:e,y1:U,x2:e,y2:V-W,stroke:`currentColor`,strokeOpacity:`0.1`,strokeWidth:`1`,strokeDasharray:`3 3`}),(0,F.jsx)(`text`,{x:e,y:U-6,textAnchor:`middle`,className:`fill-zinc-400 text-xs font-semibold`,children:`OT`})]})})(),(0,F.jsx)(`path`,{d:h,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.4`,strokeWidth:`1.5`,strokeLinejoin:`round`,strokeLinecap:`round`}),c.map((e,t)=>{let n=f(t,600),a=p(e.diff),l=e.isTeam1Win?I:L,u=e.isPistol?ze:e.isEcoWin?Be:Re,d=o===t;return(0,F.jsxs)(`g`,{children:[e.isEcoWin&&(0,F.jsx)(`circle`,{cx:n,cy:a,r:u+4,fill:`none`,stroke:`#22d3ee`,strokeWidth:`1`,strokeOpacity:`0.4`}),e.isPistol?(0,F.jsx)(`g`,{transform:`translate(${n}, ${a}) rotate(45)`,children:(0,F.jsx)(`rect`,{x:-u/1.4,y:-u/1.4,width:u*1.4,height:u*1.4,fill:l,rx:`1`,className:E(`transition-all`,d&&`scale-125`),style:{transformOrigin:`center`}})}):(0,F.jsx)(`circle`,{cx:n,cy:a,r:d?u+1.5:u,fill:l,className:`transition-all`,fillOpacity:e.isEcoWin?1:.85}),(0,F.jsx)(`circle`,{cx:n,cy:a,r:12,fill:`transparent`,onMouseEnter:()=>s(t),onMouseLeave:()=>s(null),onFocus:()=>s(t),onBlur:()=>s(null),className:`cursor-pointer`,tabIndex:0,role:`button`,"aria-label":`Round ${e.round}: ${e.isTeam1Win?r:i} wins ${e.team1Score}–${e.team2Score}${e.isEcoWin?`, eco win`:``}${e.isPistol?`, pistol round`:``}`}),(t===0||t===c.length-1||e.round%5==0||e.round===13)&&(0,F.jsx)(`text`,{x:n,y:V-W+16,textAnchor:`middle`,className:`fill-zinc-500 text-xs`,children:e.round})]},e.round)}),(0,F.jsxs)(`text`,{x:8,y:U+4,className:`fill-zinc-400 text-xs`,children:[`+`,d]}),(0,F.jsxs)(`text`,{x:8,y:V-W,className:`fill-zinc-400 text-xs`,children:[`-`,d]})]}),o!==null&&c[o]&&(0,F.jsx)(Ve,{point:c[o],x:f(o,600),y:p(c[o].diff),team1Name:r,team2Name:i})]}),(0,F.jsx)(`div`,{className:`mt-1 flex gap-px overflow-hidden rounded-full`,role:`list`,"aria-label":`Round-by-round win strip`,children:c.map(e=>{let t=e.buyType===`eco`?.35:e.buyType===`force`?.55:e.buyType===`pistol`?.7:.9,n=e.isTeam1Win?r:i;return(0,F.jsx)(`div`,{role:`listitem`,className:`h-1.5 flex-1 transition-opacity`,style:{backgroundColor:e.isTeam1Win?I:L,opacity:t},title:`R${e.round}: ${e.team1Score}–${e.team2Score}`,"aria-label":`Round ${e.round}: ${n} wins, ${e.team1Score}–${e.team2Score}`},e.round)})})]})}var G=`var(--glk-team1)`,K=`var(--glk-team2)`,We={pistol:.7,eco:.35,force:.55,full:.9},q=180,Ge=32,J=16,Y=28;function Ke({point:e,x:t,y:n,team1Name:r,team2Name:i}){let a=Math.max(190/2,Math.min(t,600-190/2)),o=e=>e==null?`N/A`:`${Math.round(e/1e3)}k`,s=(e.team1??0)-(e.team2??0),c=Math.abs(s)>3e3?s>0?r:i:null;return(0,F.jsxs)(`div`,{className:`pointer-events-none absolute z-10 rounded-lg border border-zinc-200 bg-white px-3 py-2 shadow-lg dark:border-zinc-700 dark:bg-zinc-800`,style:{left:a,top:n-80,transform:`translateX(-50%)`,width:190},children:[(0,F.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,F.jsxs)(`span`,{className:`text-xs font-semibold uppercase text-zinc-400`,children:[`Round `,e.round]}),e.isEcoWin&&(0,F.jsx)(`span`,{className:`text-xs font-bold text-cyan-400`,children:`Eco win!`})]}),(0,F.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`span`,{className:`text-xs font-medium`,style:{color:G},children:r}),(0,F.jsxs)(`span`,{className:`glk-tabular text-xs`,style:{color:G},children:[o(e.team1),` `,e.t1Buy&&(0,F.jsxs)(`span`,{className:`text-zinc-400`,children:[`(`,e.t1Buy,`)`]})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`span`,{className:`text-xs font-medium`,style:{color:K},children:i}),(0,F.jsxs)(`span`,{className:`glk-tabular text-xs`,style:{color:K},children:[o(e.team2),` `,e.t2Buy&&(0,F.jsxs)(`span`,{className:`text-zinc-400`,children:[`(`,e.t2Buy,`)`]})]})]})]}),c&&(0,F.jsxs)(`div`,{className:`mt-1 text-xs text-zinc-400`,children:[c,` had a `,Math.round(Math.abs(s)/1e3),`k loadout edge`]})]})}function qe({rounds:e,team1Id:t,team1Name:n,team2Name:r,className:i}){let[a,o]=(0,P.useState)(null),s=e.filter(e=>e.team1LoadoutValue!=null||e.team2LoadoutValue!=null),c=(0,P.useMemo)(()=>s.map(e=>{let n=e.team1LoadoutValue??0,r=e.team2LoadoutValue??0,i=e.winnerTeamId===t,a=i?n:r,o=i?r:n;return{round:e.roundNumber,team1:e.team1LoadoutValue,team2:e.team2LoadoutValue,winnerTeamId:e.winnerTeamId,winType:e.winType,isEcoWin:o>a+5e3,t1Buy:j(e.roundNumber,e.team1LoadoutValue),t2Buy:j(e.roundNumber,e.team2LoadoutValue)}}),[s,t]),l=(0,P.useMemo)(()=>{let e=0,n=0,r=0,i=0,a=0;for(let o of c)o.team1!=null&&o.team2!=null&&(e+=o.team1,n+=o.team2,r++),o.isEcoWin&&(o.winnerTeamId===t?i++:a++);return{t1Avg:r>0?Math.round(e/r):0,t2Avg:r>0?Math.round(n/r):0,t1EcoWins:i,t2EcoWins:a}},[c,t]),u=c.length,d=(0,P.useMemo)(()=>Math.max(...c.map(e=>Math.max(e.team1??0,e.team2??0)),5e3),[c]),f=(0,P.useCallback)(e=>{let t=600-Ge*2;return Ge+e/Math.max(u-1,1)*t},[u]),p=(0,P.useCallback)(e=>{let t=q-J-Y;return J+t-e/d*t},[d]),m=e=>{let t=c.filter(t=>t[e]!=null);if(t.length<2)return``;let n=q-Y,r=t[0],i=t[t.length-1];return`${t.map((t,n)=>{let r=f(c.indexOf(t)),i=p(t[e]);return`${n===0?`M`:`L`} ${r} ${i}`}).join(` `)} L ${f(c.indexOf(i))} ${n} L ${f(c.indexOf(r))} ${n} Z`},h=e=>c.filter(t=>t[e]!=null).map((t,n)=>{let r=f(c.indexOf(t)),i=p(t[e]);return`${n===0?`M`:`L`} ${r} ${i}`}).join(` `),g=c.findIndex(e=>e.round===13),_=c.some(e=>e.round>=25)?c.findIndex(e=>e.round===25):-1,v=(0,P.useMemo)(()=>{let e=[],t=d>2e4?7e3:5e3;for(let n=0;n<=d;n+=t)e.push(n);return e},[d]),[y,b]=(0,P.useState)(!1),x=(0,P.useRef)(null);return(0,P.useEffect)(()=>{if(!y)return;let e=e=>{x.current&&!x.current.contains(e.target)&&b(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[y]),s.length===0?(0,F.jsx)(`div`,{className:`glk-card flex items-center justify-center !p-6 text-sm text-zinc-400 ${i??``}`,children:`Economy data not available`}):(0,F.jsxs)(`div`,{className:i,children:[(0,F.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-4 text-xs`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:G}}),(0,F.jsx)(`span`,{className:`font-medium text-zinc-500 dark:text-zinc-400`,children:n}),(0,F.jsxs)(`span`,{className:`text-zinc-400`,children:[`(`,Math.round(l.t1Avg/1e3),`k avg)`]})]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:K}}),(0,F.jsx)(`span`,{className:`font-medium text-zinc-500 dark:text-zinc-400`,children:r}),(0,F.jsxs)(`span`,{className:`text-zinc-400`,children:[`(`,Math.round(l.t2Avg/1e3),`k avg)`]})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(l.t1EcoWins>0||l.t2EcoWins>0)&&(0,F.jsxs)(`div`,{className:`text-xs text-zinc-400`,children:[`Eco wins: `,(0,F.jsx)(`span`,{style:{color:G},children:l.t1EcoWins}),` / `,(0,F.jsx)(`span`,{style:{color:K},children:l.t2EcoWins})]}),(0,F.jsxs)(`div`,{className:`relative`,ref:x,children:[(0,F.jsx)(`button`,{onClick:()=>b(e=>!e),className:`flex h-4 w-4 items-center justify-center rounded-full border border-zinc-300 text-xs font-bold text-zinc-400 transition-colors hover:border-zinc-400 hover:text-zinc-500 dark:border-zinc-600 dark:hover:border-zinc-500 dark:hover:text-zinc-300`,"aria-label":`How to read this chart`,children:`?`}),y&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`fixed inset-0 z-20`,onClick:()=>b(!1)}),(0,F.jsxs)(`div`,{className:`absolute right-0 top-6 z-30 w-56 max-w-[calc(100vw-2rem)] rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-800`,children:[(0,F.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-zinc-700 dark:text-zinc-200`,children:`Reading the chart`}),(0,F.jsxs)(`ul`,{className:`space-y-1.5 text-xs leading-relaxed text-zinc-500 dark:text-zinc-400`,children:[(0,F.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:G}}),(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:G},children:n}),` loadout line`]}),(0,F.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:K}}),(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:K},children:r}),` loadout line`]}),(0,F.jsx)(`li`,{children:`Higher = more credits invested in weapons & abilities`}),(0,F.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full border border-cyan-400`}),`Eco win — won despite being out-bought`]}),(0,F.jsxs)(`li`,{children:[`DNA strips below show `,(0,F.jsx)(`span`,{className:`font-medium text-zinc-600 dark:text-zinc-300`,children:`buy type`}),` each round (eco, force, full)`]})]}),(0,F.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400`,children:`Hover dots for round details`})]})]})]})]})]}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsxs)(`svg`,{viewBox:`0 0 600 ${q}`,className:`w-full`,preserveAspectRatio:`xMidYMid meet`,role:`img`,"aria-label":`Economy timeline showing ${n} vs ${r} loadout values per round. ${n} average: ${Math.round(l.t1Avg/1e3)}k, ${r} average: ${Math.round(l.t2Avg/1e3)}k.`,children:[(0,F.jsxs)(`defs`,{children:[(0,F.jsxs)(`linearGradient`,{id:`eco-area-t1`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`0%`,stopColor:`var(--glk-team1)`,stopOpacity:`0.15`}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`var(--glk-team1)`,stopOpacity:`0`})]}),(0,F.jsxs)(`linearGradient`,{id:`eco-area-t2`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`0%`,stopColor:`var(--glk-team2)`,stopOpacity:`0.15`}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`var(--glk-team2)`,stopOpacity:`0`})]})]}),v.map(e=>(0,F.jsxs)(`g`,{children:[(0,F.jsx)(`line`,{x1:Ge,y1:p(e),x2:600-Ge,y2:p(e),stroke:`currentColor`,strokeOpacity:`0.06`,strokeWidth:`0.5`}),(0,F.jsx)(`text`,{x:Ge-4,y:p(e)+3,textAnchor:`end`,className:`fill-zinc-400 text-xs`,children:e===0?`0`:`${Math.round(e/1e3)}k`})]},e)),(0,F.jsx)(`path`,{d:m(`team1`),fill:`url(#eco-area-t1)`}),(0,F.jsx)(`path`,{d:m(`team2`),fill:`url(#eco-area-t2)`}),(0,F.jsx)(`path`,{d:h(`team1`),fill:`none`,stroke:`var(--glk-team1)`,strokeWidth:`1.5`,strokeLinejoin:`round`,strokeLinecap:`round`}),(0,F.jsx)(`path`,{d:h(`team2`),fill:`none`,stroke:`var(--glk-team2)`,strokeWidth:`1.5`,strokeLinejoin:`round`,strokeLinecap:`round`}),g>0&&(()=>{let e=(f(g-1)+f(g))/2;return(0,F.jsxs)(`g`,{children:[(0,F.jsx)(`line`,{x1:e,y1:J,x2:e,y2:q-Y,stroke:`currentColor`,strokeOpacity:`0.1`,strokeWidth:`1`,strokeDasharray:`3 3`}),(0,F.jsx)(`text`,{x:e,y:J-4,textAnchor:`middle`,className:`fill-zinc-400 text-xs font-semibold`,children:`HT`})]})})(),_>0&&(()=>{let e=(f(_-1)+f(_))/2;return(0,F.jsxs)(`g`,{children:[(0,F.jsx)(`line`,{x1:e,y1:J,x2:e,y2:q-Y,stroke:`currentColor`,strokeOpacity:`0.1`,strokeWidth:`1`,strokeDasharray:`3 3`}),(0,F.jsx)(`text`,{x:e,y:J-4,textAnchor:`middle`,className:`fill-zinc-400 text-xs font-semibold`,children:`OT`})]})})(),c.map((e,i)=>{let s=f(i),l=p(e.team1??0),u=p(e.team2??0),d=a===i;return(0,F.jsxs)(`g`,{children:[e.isEcoWin&&(0,F.jsx)(`circle`,{cx:s,cy:e.winnerTeamId===t?l:u,r:7,fill:`none`,stroke:`#22d3ee`,strokeWidth:`1`,strokeOpacity:`0.5`}),e.team1!=null&&(0,F.jsx)(`circle`,{cx:s,cy:l,r:d?4:2.5,fill:`var(--glk-team1)`,className:`transition-all`}),e.team2!=null&&(0,F.jsx)(`circle`,{cx:s,cy:u,r:d?4:2.5,fill:`var(--glk-team2)`,className:`transition-all`}),(0,F.jsx)(`rect`,{x:s-8,y:J,width:16,height:q-J-Y,fill:`transparent`,onMouseEnter:()=>o(i),onMouseLeave:()=>o(null),onFocus:()=>o(i),onBlur:()=>o(null),className:`cursor-pointer`,tabIndex:0,role:`button`,"aria-label":`Round ${e.round}: ${n} ${e.team1==null?`N/A`:Math.round(e.team1/1e3)+`k`}, ${r} ${e.team2==null?`N/A`:Math.round(e.team2/1e3)+`k`}${e.isEcoWin?`, eco win`:``}`}),d&&(0,F.jsx)(`line`,{x1:s,y1:J,x2:s,y2:q-Y,stroke:`currentColor`,strokeOpacity:`0.08`,strokeWidth:`1`}),(i===0||i===c.length-1||e.round%5==0||e.round===13)&&(0,F.jsx)(`text`,{x:s,y:q-Y+14,textAnchor:`middle`,className:`fill-zinc-500 text-xs`,children:e.round})]},e.round)})]}),a!==null&&c[a]&&(0,F.jsx)(Ke,{point:c[a],x:f(a),y:Math.min(p(c[a].team1??0),p(c[a].team2??0)),team1Name:n,team2Name:r})]}),(0,F.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`w-8 text-right text-xs font-medium sm:w-14`,style:{color:G},children:[(0,F.jsx)(`span`,{className:`sm:hidden`,children:n.slice(0,3)}),(0,F.jsx)(`span`,{className:`hidden sm:inline`,children:n})]}),(0,F.jsx)(`div`,{className:`flex flex-1 gap-0.5 overflow-hidden rounded-md`,role:`list`,"aria-label":`${n} buy type per round`,children:c.map((e,t)=>(0,F.jsx)(`div`,{role:`listitem`,className:`glk-bar-slide-in h-3 flex-1 rounded-sm sm:h-2.5`,style:{backgroundColor:G,opacity:e.t1Buy?We[e.t1Buy]:.2,"--glk-bar-i":t},title:`R${e.round}: ${e.t1Buy??`?`}`,"aria-label":`Round ${e.round}: ${e.t1Buy??`unknown`} buy`},`t1-${e.round}`))})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`w-8 text-right text-xs font-medium sm:w-14`,style:{color:K},children:[(0,F.jsx)(`span`,{className:`sm:hidden`,children:r.slice(0,3)}),(0,F.jsx)(`span`,{className:`hidden sm:inline`,children:r})]}),(0,F.jsx)(`div`,{className:`flex flex-1 gap-0.5 overflow-hidden rounded-md`,role:`list`,"aria-label":`${r} buy type per round`,children:c.map((e,t)=>(0,F.jsx)(`div`,{role:`listitem`,className:`glk-bar-slide-in h-3 flex-1 rounded-sm sm:h-2.5`,style:{backgroundColor:K,opacity:e.t2Buy?We[e.t2Buy]:.2,"--glk-bar-i":t},title:`R${e.round}: ${e.t2Buy??`?`}`,"aria-label":`Round ${e.round}: ${e.t2Buy??`unknown`} buy`},`t2-${e.round}`))})]})]}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-center gap-3 text-xs text-zinc-400`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`inline-block h-1.5 w-3 rounded-full bg-zinc-400`,style:{opacity:.35}}),` eco`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`inline-block h-1.5 w-3 rounded-full bg-zinc-400`,style:{opacity:.55}}),` force`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`inline-block h-1.5 w-3 rounded-full bg-zinc-400`,style:{opacity:.7}}),` pistol`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`inline-block h-1.5 w-3 rounded-full bg-zinc-400`,style:{opacity:.9}}),` full`]})]})]})}function X(e,t=0){return e==null?`—`:t>0?e.toFixed(t):Math.round(e).toString()}var Je=[{key:`acs`,label:`ACS`,optional:!0},{key:`kills`,label:`K`,fullLabel:`Kills`},{key:`deaths`,label:`D`,fullLabel:`Deaths`},{key:`adr`,label:`ADR`,hideClass:`hidden min-[420px]:table-cell`,optional:!0},{key:`fk`,label:`FK`,fullLabel:`First K`,hideClass:`hidden min-[540px]:table-cell`,optional:!0},{key:`fd`,label:`FD`,fullLabel:`First D`,hideClass:`hidden min-[540px]:table-cell`,optional:!0},{key:`kast`,label:`KAST`,hideClass:`hidden md:table-cell`,optional:!0},{key:`hsPct`,label:`HS%`,fullLabel:`HS %`,hideClass:`hidden lg:table-cell`,optional:!0}];function Ye({stat:e,isMvp:t,visibleKeys:n}){let r=e.kills!=null&&e.deaths!=null&&e.deaths>0?e.kills/e.deaths:null,i=r!=null&&r>=1;return(0,F.jsxs)(`tr`,{className:`border-b border-zinc-100 last:border-0 transition-colors hover:bg-zinc-50/50 dark:border-zinc-800/50 dark:hover:bg-zinc-800/30 ${t?`bg-amber-500/[0.04] border-l-2 border-l-amber-500 dark:bg-amber-500/[0.03]`:``}`,children:[(0,F.jsx)(`td`,{className:`py-2 pl-3 pr-2`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(O,{name:e.agent??``,size:`sm`,showFallback:!1}),t&&(0,F.jsx)(m,{size:10,className:`absolute -right-1 -top-1 fill-amber-400 text-amber-400`})]}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`div`,{className:`flex items-center gap-1 truncate text-xs font-semibold text-zinc-900 dark:text-zinc-100`,children:e.player?.slug?(0,F.jsx)(x,{to:`/valorant/players/${e.player.slug}`,className:`hover:text-[var(--glk-brand)] transition-colors`,children:e.player.ign}):e.player?.ign??`Unknown`}),(0,F.jsx)(`div`,{className:`text-xs text-zinc-400`,children:e.agent})]})]})}),n.has(`acs`)&&(0,F.jsx)(`td`,{className:`py-2 pr-3 text-right text-xs tabular-nums font-bold text-zinc-900 dark:text-zinc-100`,children:X(e.acs)}),n.has(`kills`)&&(0,F.jsx)(`td`,{className:`py-2 pr-3 text-right text-xs tabular-nums font-medium ${i?`text-emerald-500`:r==null?`text-zinc-700 dark:text-zinc-300`:`text-zinc-400`}`,children:X(e.kills)}),n.has(`deaths`)&&(0,F.jsx)(`td`,{className:`py-2 pr-3 text-right text-xs tabular-nums ${r!=null&&!i?`text-red-400/70`:`text-zinc-700 dark:text-zinc-300`}`,children:X(e.deaths)}),n.has(`adr`)&&(0,F.jsx)(`td`,{className:`py-2 pr-3 text-right text-xs tabular-nums text-zinc-600 dark:text-zinc-400 hidden min-[420px]:table-cell`,children:X(e.adr)}),n.has(`fk`)&&(0,F.jsx)(`td`,{className:`py-2 pr-3 text-right text-xs tabular-nums text-zinc-600 dark:text-zinc-400 hidden min-[540px]:table-cell`,children:X(e.fk)}),n.has(`fd`)&&(0,F.jsx)(`td`,{className:`py-2 pr-3 text-right text-xs tabular-nums text-zinc-600 dark:text-zinc-400 hidden min-[540px]:table-cell`,children:X(e.fd)}),n.has(`kast`)&&(0,F.jsx)(`td`,{className:`py-2 pr-3 text-right text-xs tabular-nums text-zinc-600 dark:text-zinc-400 hidden md:table-cell`,children:e.kast==null?`—`:`${X(e.kast*100)}%`}),n.has(`hsPct`)&&(0,F.jsx)(`td`,{className:`py-2 pr-3 text-right text-xs tabular-nums text-zinc-600 dark:text-zinc-400 hidden lg:table-cell`,children:e.hsPct==null?`—`:`${X(e.hsPct*100)}%`})]})}function Xe({players:e,label:t,teamSlug:n,teamColor:r,sortKey:i,onSort:a,headers:o,mvpId:s}){let c=(0,P.useMemo)(()=>new Set(o.map(e=>e.key)),[o]);return(0,F.jsxs)(`div`,{className:`glk-card !p-0 overflow-x-visible overflow-y-hidden`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-800/50`,children:[(0,F.jsx)(`span`,{className:`h-3 w-[3px] rounded-full`,style:{backgroundColor:r}}),n?(0,F.jsx)(x,{to:`/valorant/teams/${n}`,className:`text-xs font-semibold text-zinc-700 hover:text-[var(--glk-brand)] transition-colors dark:text-zinc-300`,children:t}):(0,F.jsx)(`span`,{className:`text-xs font-semibold text-zinc-700 dark:text-zinc-300`,children:t})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto`,children:(0,F.jsxs)(`table`,{className:`w-full text-sm`,"aria-label":`${t} scoreboard`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-zinc-200/50 dark:border-zinc-700/50`,children:[(0,F.jsx)(`th`,{className:`py-1.5 pl-3 text-left text-xs font-semibold uppercase tracking-wide text-zinc-400`,scope:`col`,children:`Player`}),o.map(e=>(0,F.jsx)(`th`,{scope:`col`,tabIndex:0,"aria-sort":e.key===i?`descending`:`none`,onClick:()=>a(e.key),onKeyDown:t=>(t.key===`Enter`||t.key===` `)&&a(e.key),className:`cursor-pointer py-1.5 pr-3 text-right text-xs font-semibold uppercase tracking-wide transition-colors ${e.key===i?`text-[var(--glk-brand)]`:`text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300`} ${e.hideClass??``}`,children:e.fullLabel?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`lg:hidden`,children:e.label}),(0,F.jsx)(`span`,{className:`hidden lg:inline`,children:e.fullLabel})]}):e.label},e.key))]})}),(0,F.jsx)(`tbody`,{children:e.map(e=>(0,F.jsx)(Ye,{stat:e,isMvp:e.id===s,visibleKeys:c},e.id))})]})})]})}function Ze({playerStats:e,team1Id:t,team2Id:n,team1Name:r,team2Name:i,team1Slug:a,team2Slug:o}){let s=(0,P.useMemo)(()=>Je.filter(t=>t.optional?e.some(e=>e[t.key]!=null):!0),[e]),c=s.length<Je.length,l=(0,P.useMemo)(()=>s.some(e=>e.key===`acs`)?`acs`:s[0]?.key??`kills`,[s]),[u,d]=(0,P.useState)(l),f=s.some(e=>e.key===u)?u:l,p=(0,P.useMemo)(()=>{let t=null;for(let n of e)n.acs!=null&&(t===null||n.acs>t.acs)&&(t={id:n.id,acs:n.acs});return t?.id},[e]),m=(0,P.useMemo)(()=>e.filter(e=>e.teamId===t).sort((e,t)=>(t[f]??0)-(e[f]??0)),[e,t,f]),h=(0,P.useMemo)(()=>e.filter(e=>e.teamId===n).sort((e,t)=>(t[f]??0)-(e[f]??0)),[e,n,f]),g=(0,P.useMemo)(()=>e.some(e=>e.acs!=null&&e.acs>0||e.kills!=null&&e.kills>0),[e]),_=e.length>0&&e.some(e=>e.player?.ign);if(!g&&!_)return(0,F.jsxs)(`div`,{className:`glk-card flex flex-col items-center gap-1 py-6 text-center`,"data-testid":`stats-unavailable-disclaimer`,children:[(0,F.jsx)(`span`,{className:`glk-eyebrow text-zinc-400`,children:`Player stats`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-500 dark:text-zinc-400`,children:`Per-player stats are not available from this match's data source.`})]});if(!g){let s=e.filter(e=>e.teamId===t),c=e.filter(e=>e.teamId===n),l=(e,t,n,r)=>(0,F.jsxs)(`div`,{className:`glk-card !p-0 overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-800/50`,children:[(0,F.jsx)(`span`,{className:`h-3 w-[3px] rounded-full`,style:{backgroundColor:r}}),n?(0,F.jsx)(x,{to:`/valorant/teams/${n}`,className:`text-xs font-semibold text-zinc-700 hover:text-[var(--glk-brand)] transition-colors dark:text-zinc-300`,children:t}):(0,F.jsx)(`span`,{className:`text-xs font-semibold text-zinc-700 dark:text-zinc-300`,children:t})]}),(0,F.jsx)(`ul`,{className:`divide-y divide-zinc-100 dark:divide-zinc-800/50`,children:e.map(e=>(0,F.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,F.jsx)(O,{name:e.agent??``,size:`sm`,showFallback:!1}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`div`,{className:`truncate text-xs font-semibold text-zinc-900 dark:text-zinc-100`,children:e.player?.slug?(0,F.jsx)(x,{to:`/valorant/players/${e.player.slug}`,className:`hover:text-[var(--glk-brand)] transition-colors`,children:e.player.ign}):e.player?.ign??`Unknown`}),e.agent&&(0,F.jsx)(`div`,{className:`text-xs text-zinc-400`,children:e.agent})]})]},e.id))}),(0,F.jsx)(`p`,{className:`px-3 py-2 text-xs text-zinc-400`,children:`Stats not recorded for this map.`})]});return(0,F.jsxs)(`div`,{className:`space-y-4`,children:[l(s,r,a,`var(--glk-team1)`),l(c,i,o,`var(--glk-team2)`)]})}return(0,F.jsxs)(`div`,{className:`space-y-4`,children:[c&&(0,F.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,"data-testid":`stats-partial-disclaimer`,children:`Some per-player stats (e.g. ACS, KAST, HS%) aren't available from this match's data source.`}),(0,F.jsx)(Xe,{players:m,label:r,teamSlug:a,teamColor:`var(--glk-team1)`,sortKey:f,onSort:d,headers:s,mvpId:p}),(0,F.jsx)(Xe,{players:h,label:i,teamSlug:o,teamColor:`var(--glk-team2)`,sortKey:f,onSort:d,headers:s,mvpId:p})]})}function Qe(e){return e==null?`—`:Math.round(e).toString()}function $e(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function et({weapon:e}){return e?(0,F.jsx)(`img`,{src:e.icon,alt:e.name,title:e.name,className:`h-4 w-auto max-w-[48px] object-contain opacity-80`}):(0,F.jsx)(`span`,{className:`text-zinc-500`,children:`—`})}function tt({health:e,armor:t,isAlive:n}){return n?(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`div`,{className:`h-1.5 w-12 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700`,children:(0,F.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500 transition-all duration-300`,style:{width:`${e}%`}})}),t>0&&(0,F.jsx)(`div`,{className:`h-1.5 w-4 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700`,children:(0,F.jsx)(`div`,{className:`h-full rounded-full bg-sky-400 transition-all duration-300`,style:{width:`${t/50*100}%`}})})]}):(0,F.jsx)(`span`,{className:`text-2xs text-red-400/60`,children:`DEAD`})}function nt({player:e}){let t=(e.deaths>0?e.kills/e.deaths:e.kills)>=1;return(0,F.jsxs)(`tr`,{className:E(`border-b border-zinc-100 last:border-0 transition-colors dark:border-zinc-800/50`,!e.isAlive&&`opacity-50`),children:[(0,F.jsx)(`td`,{className:`py-1.5 pl-3 pr-2`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(O,{name:e.agent,size:`sm`,showFallback:!1}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`div`,{className:`truncate text-xs font-semibold text-zinc-900 dark:text-zinc-100`,children:e.nickname}),(0,F.jsx)(`div`,{className:`text-2xs text-zinc-400`,children:e.agent})]})]})}),(0,F.jsx)(`td`,{className:`py-1.5 pr-2`,children:(0,F.jsx)(tt,{health:e.health,armor:e.armor,isAlive:e.isAlive})}),(0,F.jsx)(`td`,{className:`py-1.5 pr-2 hidden min-[480px]:table-cell`,children:(0,F.jsx)(et,{weapon:e.primaryWeapon})}),(0,F.jsx)(`td`,{className:E(`py-1.5 pr-2 text-right glk-metric-sm`,t?`text-emerald-500`:`text-zinc-400`),children:e.kills}),(0,F.jsx)(`td`,{className:`py-1.5 pr-2 text-right glk-tabular text-xs text-zinc-600 dark:text-zinc-400`,children:e.deaths}),(0,F.jsx)(`td`,{className:`py-1.5 pr-2 text-right glk-tabular text-xs text-zinc-600 dark:text-zinc-400`,children:e.assists}),(0,F.jsx)(`td`,{className:`py-1.5 pr-2 text-right glk-tabular text-xs text-zinc-600 dark:text-zinc-400 hidden min-[540px]:table-cell`,children:Qe(e.adr)}),(0,F.jsx)(`td`,{className:`py-1.5 pr-2 text-right glk-tabular text-xs text-zinc-600 dark:text-zinc-400 hidden md:table-cell`,children:e.openKills}),(0,F.jsxs)(`td`,{className:`py-1.5 pr-3 text-right glk-tabular text-xs text-zinc-500 hidden lg:table-cell`,children:[`$`,$e(e.equipmentValue)]})]})}function rt({team:e,teamColor:t,displayName:n}){let r=[...e.players].sort((e,t)=>t.kills-e.kills);return(0,F.jsxs)(`div`,{className:`glk-card !p-0 overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-200 bg-zinc-50 px-3 py-1.5 dark:border-zinc-800 dark:bg-zinc-800/50`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`h-3 w-[3px] rounded-full`,style:{backgroundColor:t}}),(0,F.jsx)(`span`,{className:`text-xs font-semibold text-zinc-700 dark:text-zinc-300`,children:n??e.name})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400`,children:e.side}),(0,F.jsx)(`span`,{className:`glk-metric-sm text-zinc-900 dark:text-zinc-100`,children:e.score})]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto`,children:(0,F.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-zinc-200/50 dark:border-zinc-700/50`,children:[(0,F.jsx)(`th`,{className:`glk-eyebrow py-1 pl-3 text-left`,children:`Player`}),(0,F.jsx)(`th`,{className:`glk-eyebrow py-1 text-left`,children:`HP`}),(0,F.jsx)(`th`,{className:`glk-eyebrow py-1 text-left hidden min-[480px]:table-cell`,children:`Weapon`}),(0,F.jsx)(`th`,{className:`glk-eyebrow py-1 pr-2 text-right`,children:`K`}),(0,F.jsx)(`th`,{className:`glk-eyebrow py-1 pr-2 text-right`,children:`D`}),(0,F.jsx)(`th`,{className:`glk-eyebrow py-1 pr-2 text-right`,children:`A`}),(0,F.jsx)(`th`,{className:`glk-eyebrow py-1 pr-2 text-right hidden min-[540px]:table-cell`,children:`ADR`}),(0,F.jsx)(`th`,{className:`glk-eyebrow py-1 pr-2 text-right hidden md:table-cell`,children:`FK`}),(0,F.jsx)(`th`,{className:`glk-eyebrow py-1 pr-3 text-right hidden lg:table-cell`,children:`Econ`})]})}),(0,F.jsx)(`tbody`,{children:r.map(e=>(0,F.jsx)(nt,{player:e},e.nickname))})]})})]})}function it({team1:e,team2:t,mapName:n,roundNumber:r,roundPhase:i,gameNumber:a,team1DisplayName:o,team2DisplayName:s}){let c=o??e.name,l=s??t.name;return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(xe,{tone:`live`,pulse:!0,children:`Live`}),(0,F.jsxs)(`span`,{className:`text-xs text-zinc-500`,children:[`Map `,a,` — `,n.charAt(0).toUpperCase()+n.slice(1)]})]}),(0,F.jsxs)(`span`,{className:`text-xs text-zinc-400`,children:[`Round `,r,` · `,i.replace(/_/g,` `)]})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-1`,children:[(0,F.jsx)(`span`,{className:`text-lg font-bold text-zinc-900 dark:text-zinc-100`,children:c}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg bg-zinc-100 px-3 py-1 dark:bg-zinc-800`,children:[(0,F.jsx)(`span`,{className:`glk-metric-lg text-zinc-900 dark:text-zinc-100`,children:e.score}),(0,F.jsx)(`span`,{className:`text-zinc-400`,children:`:`}),(0,F.jsx)(`span`,{className:`glk-metric-lg text-zinc-900 dark:text-zinc-100`,children:t.score})]}),(0,F.jsx)(`span`,{className:`text-lg font-bold text-zinc-900 dark:text-zinc-100`,children:l})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(rt,{team:e,teamColor:`var(--glk-team1, #f59e0b)`,displayName:c}),(0,F.jsx)(rt,{team:t,teamColor:`var(--glk-team2, #3b82f6)`,displayName:l})]})]})}function at(e,t,n){let r=0,i=0,a=0,o=0;for(let n of e){if(n.roundNumber>24)continue;let e=n.roundNumber<=12,s=n.winnerTeamId===t;e?s?r++:i++:s?a++:o++}return n===`attack`?{team1Attack:r,team1Defense:a,team2Attack:o,team2Defense:i}:{team1Attack:a,team1Defense:r,team2Attack:i,team2Defense:o}}var ot=12,Z=20,st=3,ct=3;function lt({rounds:e,team1Id:t,team1SideFirst:n}){let r=(0,P.useMemo)(()=>{let r=[];for(let i of e){if(i.roundNumber>24)continue;let e=i.roundNumber<=12,a=i.winnerTeamId===t,o;if(e){let e=n;o=a?e:e===`attack`?`defense`:`attack`}else{let e=n===`attack`?`defense`:`attack`;o=a?e:e===`attack`?`defense`:`attack`}r.push({round:i.roundNumber,team1Won:a,side:o,half:e?1:2})}return r},[e,t,n]),i=e=>r.filter(t=>t.half===e),a=ot*(Z+st)-st,o=Z;return(0,F.jsxs)(`svg`,{viewBox:`0 0 ${a} ${o*2+16}`,className:`w-full`,preserveAspectRatio:`xMidYMid meet`,children:[[1,2].map(e=>{let t=i(e),n=e===1?0:o+16;return(0,F.jsx)(`g`,{children:t.map((e,t)=>{let r=t*(Z+st),i=n,a=e.team1Won?`var(--glk-team1)`:`var(--glk-team2)`,o=e.side===`attack`;return(0,F.jsxs)(`g`,{children:[(0,F.jsx)(`rect`,{x:r,y:i,width:Z,height:Z,rx:ct,fill:a,fillOpacity:o?.85:.4,stroke:a,strokeWidth:o?0:1.5,strokeOpacity:.6}),(0,F.jsx)(`text`,{x:r+Z/2,y:i+Z/2,textAnchor:`middle`,dominantBaseline:`central`,className:`text-[8px] font-bold`,fill:`white`,fillOpacity:o?.9:.5,children:e.round})]},e.round)})},e)}),(0,F.jsx)(`text`,{x:a/2,y:o+10,textAnchor:`middle`,className:`fill-zinc-500 text-xs font-semibold uppercase tracking-widest dark:fill-zinc-400`,children:`side swap`})]})}function ut({mapResult:e,team1Id:t,team2Id:n,team1Name:r,team2Name:i}){let{team1SideFirst:a,roundResults:o}=e,s=at(o,t,a),[c,l]=(0,P.useState)(!1),u=(0,P.useRef)(null);if((0,P.useEffect)(()=>{if(!c)return;let e=e=>{u.current&&!u.current.contains(e.target)&&l(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]),o.length===0)return(0,F.jsx)(`p`,{className:`py-4 text-center text-xs text-zinc-400`,children:`Round data not available for this map.`});let d=s.team1Attack+s.team1Defense,f=s.team2Attack+s.team2Defense,p=s.team1Attack>=s.team1Defense,m=s.team2Attack>=s.team2Defense;return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-zinc-400`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-[3px]`,style:{backgroundColor:`var(--glk-team1)`,opacity:.85}}),r]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-[3px]`,style:{backgroundColor:`var(--glk-team2)`,opacity:.85}}),i]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-zinc-400`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-[3px] bg-zinc-500`,style:{opacity:.85}}),(0,F.jsx)(C,{size:10}),` atk`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-[3px] border border-zinc-400 bg-transparent`,style:{opacity:.6}}),(0,F.jsx)(w,{size:10}),` def`]}),(0,F.jsxs)(`div`,{className:`relative`,ref:u,children:[(0,F.jsx)(`button`,{onClick:()=>l(e=>!e),className:`flex h-4 w-4 items-center justify-center rounded-full border border-zinc-300 text-xs font-bold text-zinc-400 transition-colors hover:border-zinc-400 hover:text-zinc-500 dark:border-zinc-600 dark:hover:border-zinc-500 dark:hover:text-zinc-300`,"aria-label":`How to read this grid`,children:`?`}),c&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`fixed inset-0 z-20`,onClick:()=>l(!1)}),(0,F.jsxs)(`div`,{className:`absolute right-0 top-6 z-30 w-56 max-w-[calc(100vw-2rem)] rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-800`,children:[(0,F.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-zinc-700 dark:text-zinc-200`,children:`Reading the grid`}),(0,F.jsxs)(`ul`,{className:`space-y-1.5 text-xs leading-relaxed text-zinc-500 dark:text-zinc-400`,children:[(0,F.jsx)(`li`,{children:`Each cell = one round, colored by winning team`}),(0,F.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:`var(--glk-team1)`}}),(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--glk-team1)`},children:r}),` round win`]}),(0,F.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:`var(--glk-team2)`}}),(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--glk-team2)`},children:i}),` round win`]}),(0,F.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-[3px] bg-zinc-500`,style:{opacity:.85}}),`Solid = won on `,(0,F.jsx)(`span`,{className:`font-medium text-zinc-600 dark:text-zinc-300`,children:`attack`})]}),(0,F.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-[3px] border border-zinc-400 bg-transparent`,style:{opacity:.6}}),`Outlined = won on `,(0,F.jsx)(`span`,{className:`font-medium text-zinc-600 dark:text-zinc-300`,children:`defense`})]}),(0,F.jsx)(`li`,{children:`Top row = first half (R1–12), bottom = second half (R13–24)`})]})]})]})]})]})]}),(0,F.jsx)(lt,{rounds:o,team1Id:t,team1SideFirst:a}),(0,F.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-zinc-100/40 px-3 py-2 dark:bg-zinc-800/20`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`glk-metric glk-metric-lg leading-none`,style:{color:`var(--glk-team1)`},children:d}),(0,F.jsx)(`div`,{className:`text-xs uppercase text-zinc-400`,children:`rounds won`})]}),(0,F.jsxs)(`div`,{className:`text-right text-xs tabular-nums text-zinc-400`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,F.jsx)(C,{size:9}),` `,s.team1Attack]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,F.jsx)(w,{size:9}),` `,s.team1Defense]})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-zinc-100/40 px-3 py-2 dark:bg-zinc-800/20`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`glk-metric glk-metric-lg leading-none`,style:{color:`var(--glk-team2)`},children:f}),(0,F.jsx)(`div`,{className:`text-xs uppercase text-zinc-400`,children:`rounds won`})]}),(0,F.jsxs)(`div`,{className:`text-right text-xs tabular-nums text-zinc-400`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,F.jsx)(C,{size:9}),` `,s.team2Attack]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,F.jsx)(w,{size:9}),` `,s.team2Defense]})]})]})]}),(0,F.jsx)(`div`,{className:`mt-2 rounded-md bg-zinc-100/50 px-2.5 py-1.5 text-center text-xs text-zinc-400 dark:bg-zinc-800/30`,children:d===f?`Even regulation — both teams won the same number of rounds`:d>f?(0,F.jsxs)(`span`,{children:[r,` led regulation `,(0,F.jsxs)(`span`,{className:`font-semibold text-zinc-600 dark:text-zinc-300`,children:[d,`–`,f]}),p?`, stronger on attack`:`, stronger on defense`]}):(0,F.jsxs)(`span`,{children:[i,` led regulation `,(0,F.jsxs)(`span`,{className:`font-semibold text-zinc-600 dark:text-zinc-300`,children:[f,`–`,d]}),m?`, stronger on attack`:`, stronger on defense`]})})]})}var dt=e(b(),1);function ft({players:e,team1Id:t,team2Id:n,team1Name:r,team2Name:i,value:a,onChange:s}){let[c,l]=(0,P.useState)(!1),u=(0,P.useRef)(null),d=(0,P.useRef)(null),[f,p]=(0,P.useState)({top:0,left:0}),m=e.filter(e=>e.teamId===t),h=e.filter(e=>e.teamId===n),g=e.find(e=>e.id===a),_=(0,P.useCallback)(()=>{if(!u.current)return;let e=u.current.getBoundingClientRect();p({top:e.bottom+4,left:e.left})},[]);(0,P.useEffect)(()=>{if(c)return _(),window.addEventListener(`scroll`,_,!0),window.addEventListener(`resize`,_),()=>{window.removeEventListener(`scroll`,_,!0),window.removeEventListener(`resize`,_)}},[c,_]),(0,P.useEffect)(()=>{if(!c)return;let e=e=>{let t=e.target;u.current?.contains(t)||d.current?.contains(t)||l(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]),(0,P.useEffect)(()=>{if(!c)return;let e=e=>{e.key===`Escape`&&l(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[c]);let v=g?.teamId===t?`var(--glk-team1)`:`var(--glk-team2)`,y=c?(0,dt.createPortal)((0,F.jsx)(`div`,{ref:d,className:`fixed z-50 w-52 overflow-hidden rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-800`,style:{top:f.top,left:f.left},children:[{label:r,players:m,color:`var(--glk-team1)`},{label:i,players:h,color:`var(--glk-team2)`}].map(e=>e.players.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-zinc-100 bg-zinc-50 px-3 py-1.5 dark:border-zinc-700 dark:bg-zinc-800/80`,children:[(0,F.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full`,style:{backgroundColor:e.color}}),(0,F.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-zinc-400`,children:e.label})]}),e.players.map(t=>{let n=t.id===a;return(0,F.jsxs)(`button`,{onClick:()=>{s(t.id),l(!1)},className:`flex w-full items-center gap-2.5 px-3 py-2 text-left transition-colors ${n?`bg-[var(--glk-brand)]/5`:`hover:bg-zinc-50 dark:hover:bg-zinc-700/50`}`,role:`option`,"aria-selected":n,children:[(0,F.jsx)(O,{name:t.agent??``,size:`sm`,showFallback:!1}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`truncate text-xs font-semibold text-zinc-900 dark:text-zinc-100`,children:t.player?.ign??`Unknown`}),(0,F.jsxs)(`div`,{className:`text-xs`,style:{color:e.color},children:[t.agent,t.acs!=null&&(0,F.jsxs)(`span`,{className:`ml-1 text-zinc-400`,children:[`· `,Math.round(t.acs),` ACS`]})]})]}),n&&(0,F.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--glk-brand)]`})]},t.id)})]},e.label))}),document.body):null;return(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsxs)(`button`,{ref:u,onClick:()=>l(e=>!e),className:`flex items-center gap-2 rounded-lg border border-zinc-200 bg-white px-2.5 py-1.5 transition-colors hover:border-zinc-300 dark:border-zinc-700 dark:bg-zinc-800 dark:hover:border-zinc-600`,"aria-expanded":c,"aria-haspopup":`listbox`,children:[g&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(O,{name:g.agent??``,size:`xs`,showFallback:!1}),(0,F.jsxs)(`div`,{className:`text-left`,children:[(0,F.jsx)(`div`,{className:`text-xs font-bold leading-tight text-zinc-900 dark:text-zinc-100`,children:g.player?.ign??`Unknown`}),(0,F.jsx)(`div`,{className:`text-xs leading-tight`,style:{color:v},children:g.agent})]})]}),(0,F.jsx)(o,{size:12,className:`ml-1 text-zinc-400 transition-transform ${c?`rotate-180`:``}`})]}),y]})}var pt=[{key:`acs`,label:`ACS`,radarStat:!0},{key:`kd`,label:`K/D`,radarStat:!0},{key:`kills`,label:`Kills`},{key:`deaths`,label:`Deaths`,lowerIsBetter:!0},{key:`assists`,label:`Assists`},{key:`adr`,label:`ADR`,radarStat:!0},{key:`kast`,label:`KAST`,radarStat:!0},{key:`hsPct`,label:`HS%`,radarStat:!0},{key:`fk`,label:`FK`,radarStat:!0},{key:`fd`,label:`FD`,lowerIsBetter:!0}],mt=pt.filter(e=>e.radarStat);function ht(e,t){let n=e.map(e=>e[t]).filter(e=>e!==null);return n.length===0?null:n.reduce((e,t)=>e+t,0)}function gt(e,t){let n=e.map(e=>e[t]).filter(e=>e!==null);return n.length===0?null:n.reduce((e,t)=>e+t,0)/n.length}function _t(e){return{acs:gt(e,`acs`),kills:ht(e,`kills`),deaths:ht(e,`deaths`),assists:ht(e,`assists`),adr:gt(e,`adr`),kast:gt(e,`kast`),hsPct:gt(e,`hsPct`),fk:ht(e,`fk`),fd:ht(e,`fd`)}}function vt(e,t){return e===null||t===null?null:t===0?e>0?e:null:e/t}function Q(e,t){return t===`kd`?vt(e.kills,e.deaths):e[t]??null}function yt(e,t){return e===null?`—`:t===`kd`?e.toFixed(2):t===`kast`||t===`hsPct`?`${Math.round(e*100)}%`:Math.round(e).toString()}var bt=200,xt=bt/2,St=bt/2,Ct=72;function wt(e,t,n){let r=e??0,i=t??0,a=Math.max(r,i,.01),o=r/a,s=i/a;return n&&(o=a>0?1-r/(a*1.5):.5,s=a>0?1-i/(a*1.5):.5),o=Math.max(.15,Math.min(1,o)),s=Math.max(.15,Math.min(1,s)),[o,s]}function Tt(e,t,n){let r=Math.PI*2*e/t-Math.PI/2;return[xt+Math.cos(r)*n,St+Math.sin(r)*n]}function Et({p1:e,p2:t}){let n=mt.length,r=[.33,.66,1],i=[],a=[];for(let r=0;r<n;r++){let o=mt[r],[s,c]=wt(Q(e,o.key),Q(t,o.key),o.lowerIsBetter);i.push(Tt(r,n,Ct*s)),a.push(Tt(r,n,Ct*c))}let o=e=>e.map((e,t)=>`${t===0?`M`:`L`} ${e[0]} ${e[1]}`).join(` `)+` Z`;return(0,F.jsxs)(`svg`,{viewBox:`0 0 ${bt} ${bt}`,className:`mx-auto w-full max-w-[220px]`,role:`img`,"aria-label":`Player stat radar chart comparing selected players across ACS, K/D, ADR, KAST, HS%, FK, and FD`,children:[(0,F.jsxs)(`defs`,{children:[(0,F.jsxs)(`linearGradient`,{id:`radar-t1`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`0%`,stopColor:`var(--glk-team1)`,stopOpacity:`0.25`}),(0,F.jsx)(`stop`,{offset:`100%`,stopColor:`var(--glk-team1)`,stopOpacity:`0.08`})]}),(0,F.jsxs)(`linearGradient`,{id:`radar-t2`,x1:`1`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`0%`,stopColor:`var(--glk-team2)`,stopOpacity:`0.25`}),(0,F.jsx)(`stop`,{offset:`100%`,stopColor:`var(--glk-team2)`,stopOpacity:`0.08`})]})]}),r.map(e=>(0,F.jsx)(`polygon`,{points:Array.from({length:n},(t,r)=>Tt(r,n,Ct*e).join(`,`)).join(` `),fill:`none`,stroke:`currentColor`,strokeOpacity:`0.08`,strokeWidth:`0.5`},e)),Array.from({length:n},(e,t)=>{let[r,i]=Tt(t,n,Ct);return(0,F.jsx)(`line`,{x1:xt,y1:St,x2:r,y2:i,stroke:`currentColor`,strokeOpacity:`0.06`,strokeWidth:`0.5`},t)}),(0,F.jsx)(`path`,{d:o(a),fill:`url(#radar-t2)`,stroke:`var(--glk-team2)`,strokeWidth:`1.5`,strokeOpacity:`0.7`}),(0,F.jsx)(`path`,{d:o(i),fill:`url(#radar-t1)`,stroke:`var(--glk-team1)`,strokeWidth:`1.5`,strokeOpacity:`0.7`}),i.map(([e,t],n)=>(0,F.jsx)(`circle`,{cx:e,cy:t,r:`2.5`,fill:`var(--glk-team1)`,opacity:`0.9`},`p1-${n}`)),a.map(([e,t],n)=>(0,F.jsx)(`circle`,{cx:e,cy:t,r:`2.5`,fill:`var(--glk-team2)`,opacity:`0.9`},`p2-${n}`)),mt.map((e,t)=>{let[r,i]=Tt(t,n,Ct+16);return(0,F.jsx)(`text`,{x:r,y:i,textAnchor:`middle`,dominantBaseline:`central`,className:`fill-zinc-500 text-xs font-semibold uppercase dark:fill-zinc-400`,children:e.label},e.key)})]})}function Dt({player1Stats:e,player2Stats:t,allMapStats:n,team1Name:r,team2Name:i}){let[a,o]=(0,P.useState)(`map`),[s,c]=(0,P.useState)(!1),l=(0,P.useRef)(null);(0,P.useEffect)(()=>{if(!s)return;let e=e=>{l.current&&!l.current.contains(e.target)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[s]);let u=n!==void 0,d=a===`series`&&n?_t(n.player1):e,f=a===`series`&&n?_t(n.player2):t,p=(0,P.useMemo)(()=>{let e=0,t=0;for(let{key:n,lowerIsBetter:r}of pt){let i=Q(d,n),a=Q(f,n);i!=null&&a!=null&&((r?i<a:i>a)?e++:(r?a<i:a>i)&&t++)}return{p1:e,p2:t}},[d,f]),m=[`acs`,`kd`,`adr`,`kast`],h=(0,P.useMemo)(()=>{let n=null,r=0,i=`p1`;for(let e of m){let t=pt.find(t=>t.key===e);if(!t)continue;let a=Q(d,e),o=Q(f,e);if(a==null||o==null)continue;let s=Math.max(Math.abs(a),Math.abs(o),1),c=Math.abs(a-o)/s;c>r&&(r=c,n=e,i=(t.lowerIsBetter?a<o:a>o)?`p1`:`p2`)}if(!n||r<.05)return null;let a=i===`p1`?e.player?.ign??`P1`:t.player?.ign??`P2`,o=pt.find(e=>e.key===n),s=Q(i===`p1`?d:f,n),c=Q(i===`p1`?f:d,n),l=s!=null&&c!=null?Math.abs(s-c):null,u=l==null?``:n===`kd`?`+${l.toFixed(2)}`:`+${Math.round(l)}`;return{winnerName:a,statLabel:o?.label??``,value:yt(s,n),diff:u,winner:i}},[d,f,e,t]);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(O,{name:e.agent??``,size:`sm`,showFallback:!1}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`text-xs font-bold`,style:{color:`var(--glk-team1)`},children:e.agent}),(0,F.jsx)(`div`,{className:`text-xs text-zinc-400`,children:e.player?.ign})]})]}),(0,F.jsx)(`div`,{className:`flex flex-col items-center gap-1`,children:u?(0,F.jsxs)(`div`,{className:`flex gap-0.5 rounded-md bg-zinc-100 p-0.5 dark:bg-zinc-800`,role:`group`,"aria-label":`Stat scope`,children:[(0,F.jsx)(`button`,{onClick:()=>o(`map`),"aria-pressed":a===`map`,className:E(`rounded px-2 py-0.5 text-xs font-semibold uppercase transition-colors`,a===`map`?`bg-white text-zinc-900 shadow-sm dark:bg-zinc-700 dark:text-zinc-100`:`text-zinc-400`),children:`This Map`}),(0,F.jsx)(`button`,{onClick:()=>o(`series`),"aria-pressed":a===`series`,className:E(`rounded px-2 py-0.5 text-xs font-semibold uppercase transition-colors`,a===`series`?`bg-white text-zinc-900 shadow-sm dark:bg-zinc-700 dark:text-zinc-100`:`text-zinc-400`),children:`Full Series`})]}):(0,F.jsx)(`span`,{className:`text-xs font-semibold uppercase text-zinc-400`,children:`vs`})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsx)(`span`,{className:`text-xs font-bold`,style:{color:`var(--glk-team2)`},children:t.agent}),(0,F.jsx)(`div`,{className:`text-xs text-zinc-400`,children:t.player?.ign})]}),(0,F.jsx)(O,{name:t.agent??``,size:`sm`,showFallback:!1})]})]}),(0,F.jsx)(`div`,{className:`mb-2 flex justify-end`,ref:l,children:(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(`button`,{onClick:()=>c(e=>!e),className:`flex h-4 w-4 items-center justify-center rounded-full border border-zinc-300 text-xs font-bold text-zinc-400 transition-colors hover:border-zinc-400 hover:text-zinc-500 dark:border-zinc-600 dark:hover:border-zinc-500 dark:hover:text-zinc-300`,"aria-label":`How to read this comparison`,children:`?`}),s&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`fixed inset-0 z-20`,onClick:()=>c(!1)}),(0,F.jsxs)(`div`,{className:`absolute right-0 top-6 z-30 w-56 max-w-[calc(100vw-2rem)] rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-800`,children:[(0,F.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-zinc-700 dark:text-zinc-200`,children:`Reading the comparison`}),(0,F.jsxs)(`ul`,{className:`space-y-1.5 text-xs leading-relaxed text-zinc-500 dark:text-zinc-400`,children:[(0,F.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:`var(--glk-team1)`}}),(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--glk-team1)`},children:r}),` player shape`]}),(0,F.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:`var(--glk-team2)`}}),(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--glk-team2)`},children:i}),` player shape`]}),(0,F.jsx)(`li`,{children:`Larger radar shape = stronger in that stat relative to the opponent`}),(0,F.jsx)(`li`,{children:`Tug-of-war bar shows how many stats each player leads`}),(0,F.jsxs)(`li`,{children:[`Stats grid: `,(0,F.jsx)(`span`,{className:`font-medium text-zinc-600 dark:text-zinc-300`,children:`bold color`}),` = leading that stat`]}),(0,F.jsxs)(`li`,{children:[`Switch between `,(0,F.jsx)(`span`,{className:`font-medium text-zinc-600 dark:text-zinc-300`,children:`This Map`}),` and `,(0,F.jsx)(`span`,{className:`font-medium text-zinc-600 dark:text-zinc-300`,children:`Full Series`}),` to change scope`]})]})]})]})]})}),(0,F.jsx)(`div`,{className:`relative mb-3`,children:(0,F.jsx)(Et,{p1:d,p2:f})}),(0,F.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`glk-metric-sm`,style:{color:`var(--glk-team1)`},children:p.p1}),(0,F.jsx)(`div`,{className:`flex-1`,children:(0,F.jsxs)(`div`,{className:`flex h-1.5 overflow-hidden rounded-full bg-zinc-200/50 dark:bg-zinc-800`,children:[(0,F.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${p.p1+p.p2>0?p.p1/(p.p1+p.p2)*100:50}%`,backgroundColor:`var(--glk-team1)`}}),(0,F.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${p.p1+p.p2>0?p.p2/(p.p1+p.p2)*100:50}%`,backgroundColor:`var(--glk-team2)`}})]})}),(0,F.jsx)(`span`,{className:`glk-metric-sm`,style:{color:`var(--glk-team2)`},children:p.p2})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:pt.map(({key:e,label:t,lowerIsBetter:n})=>{let r=Q(d,e),i=Q(f,e),a=!1,o=!1;return r!==null&&i!==null&&(n?(a=r<i,o=i<r):(a=r>i,o=i>r)),(0,F.jsxs)(`div`,{className:`flex items-center justify-between rounded px-1.5 py-0.5 transition-colors hover:bg-zinc-100/50 dark:hover:bg-zinc-800/30`,children:[(0,F.jsx)(`span`,{className:E(`text-xs tabular-nums`,a?`font-bold text-[var(--glk-team1)]`:`text-zinc-400`),children:yt(r,e)}),(0,F.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-zinc-400`,children:t}),(0,F.jsx)(`span`,{className:E(`text-xs tabular-nums`,o?`font-bold text-[var(--glk-team2)]`:`text-zinc-400`),children:yt(i,e)})]},e)})}),h&&(0,F.jsx)(`div`,{className:`mt-2 rounded-md bg-zinc-100/50 px-3 py-1.5 text-center dark:bg-zinc-800/30`,children:(0,F.jsxs)(`span`,{className:`text-xs text-zinc-400`,children:[(0,F.jsx)(`span`,{className:`font-bold`,style:{color:h.winner===`p1`?`var(--glk-team1)`:`var(--glk-team2)`},children:h.winnerName}),` `,`led with`,` `,(0,F.jsxs)(`span`,{className:`font-semibold text-zinc-300`,children:[h.value,` `,h.statLabel]}),h.diff&&(0,F.jsxs)(`span`,{className:`text-zinc-500`,children:[` (`,h.diff,`)`]})]})})]})}function Ot({impact:e,team1:t,team2:n,winnerId:r}){if(!e.team1&&!e.team2)return null;let i=Pt({impact:e,team1:t,team2:n,winnerId:r});return(0,F.jsxs)(`section`,{className:`glk-card !p-4 sm:!p-5`,"aria-label":`Rating impact from this match`,children:[(0,F.jsx)(`div`,{className:`mb-3 flex items-center justify-between`,children:(0,F.jsx)(`h3`,{className:`glk-eyebrow text-zinc-500 dark:text-zinc-400`,children:`Rating Impact`})}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:gap-5`,children:[(0,F.jsx)(kt,{teamName:t.name,abbreviation:t.abbreviation,tier:t.currentTier??null,impact:e.team1,won:r===t.id}),(0,F.jsx)(kt,{teamName:n.name,abbreviation:n.abbreviation,tier:n.currentTier??null,impact:e.team2,won:r===n.id})]}),i&&(0,F.jsx)(`p`,{className:`mt-4 border-t border-zinc-200 pt-3 text-center text-xs text-zinc-600 dark:border-white/[0.06] dark:text-zinc-400`,children:i})]})}function kt({teamName:e,abbreviation:t,tier:n,impact:i,won:a}){let o=ce(n),s=t??e,c=!i||i.ratingPre==null,l=i&&i.ratingPre!=null&&i.ratingPost!=null?Math.round(i.ratingPost)-Math.round(i.ratingPre):null;return(0,F.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`truncate text-sm font-bold text-zinc-900 dark:text-zinc-100`,children:s}),o&&(0,F.jsx)(`span`,{className:E(`rounded px-1.5 py-0.5 text-2xs font-bold uppercase tracking-wide`,le(n)),children:o})]}),(0,F.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,F.jsx)(`span`,{className:`text-xs tabular-nums text-zinc-400`,children:c?`New`:i?.ratingPre}),(0,F.jsx)(r,{size:12,className:`text-zinc-300 dark:text-zinc-600`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:E(`glk-metric glk-metric-xl`,a?`text-zinc-900 dark:text-zinc-50`:`text-zinc-700 dark:text-zinc-300`),children:i?.ratingPost??`—`})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l!=null&&l===0&&(0,F.jsx)(k,{tone:`neutral`,className:`glk-pop`,children:`No change`}),l!=null&&l>0&&(0,F.jsxs)(k,{tone:`up`,className:`glk-pop`,children:[`+`,l]}),l!=null&&l<0&&(0,F.jsx)(k,{tone:`down`,className:`glk-pop`,children:l}),i&&(0,F.jsx)(At,{impact:i,tier:n})]})]})}function At({impact:e,tier:t}){let n=Nt(t),i=e.poolRankPre!==void 0||e.poolRankPost!==void 0,a=i?e.poolRankPre??null:e.rankPre,o=i?e.poolRankPost??null:e.rankPost;if(o==null)return null;let c=Mt({displayedScope:`pool`,poolName:n,poolRankPre:i?e.poolRankPre??null:null,poolRankPost:i?e.poolRankPost??null:null,globalRankPre:e.rankPre,globalRankPost:e.rankPost});if(a==null)return(0,F.jsx)(jt,{tooltipBody:c,children:(0,F.jsxs)(`span`,{className:`glk-eyebrow inline-flex items-center gap-1 text-zinc-500 dark:text-zinc-400`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400`,children:`Entered at`}),(0,F.jsxs)(`span`,{className:`tabular-nums text-zinc-700 dark:text-zinc-200`,children:[`#`,o]}),(0,F.jsxs)(`span`,{className:`text-zinc-400`,children:[`in `,n]})]})});let l=a-o,f=l>0?d:l<0?u:s;return(0,F.jsx)(jt,{tooltipBody:c,children:(0,F.jsxs)(`span`,{className:E(`inline-flex items-center gap-1 text-xs font-bold tabular-nums`,l>0?`text-emerald-600 dark:text-emerald-400`:l<0?`text-red-500 dark:text-red-400`:`text-zinc-500 dark:text-zinc-400`),children:[(0,F.jsx)(f,{size:11,"aria-hidden":`true`}),(0,F.jsxs)(`span`,{children:[`#`,a]}),(0,F.jsx)(r,{size:10,"aria-hidden":`true`}),(0,F.jsxs)(`span`,{children:[`#`,o]}),(0,F.jsxs)(`span`,{className:`font-medium text-zinc-500 dark:text-zinc-400`,children:[`in `,n]})]})})}function jt({tooltipBody:e,children:t}){return e?(0,F.jsx)(ye,{children:(0,F.jsxs)(be,{children:[(0,F.jsx)(D,{render:n=>(0,F.jsx)(`span`,{...n,tabIndex:0,role:`button`,"aria-label":e,className:`cursor-help focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--glk-brand)] rounded-sm`,children:t})}),(0,F.jsx)(ve,{children:(0,F.jsx)(`div`,{className:`text-xs whitespace-pre-line`,children:e})})]})}):(0,F.jsx)(F.Fragment,{children:t})}function Mt(e){let{poolName:t,poolRankPre:n,poolRankPost:r,globalRankPre:i,globalRankPost:a}=e,o=[];return(n!=null||r!=null)&&o.push(`In ${t}: ${n==null?`Unranked`:`#${n}`} → ${r==null?`Unranked`:`#${r}`}`),(i!=null||a!=null)&&o.push(`Global: ${i==null?`Unranked`:`#${i}`} → ${a==null?`Unranked`:`#${a}`}`),o.length===0?null:o.join(`
`)}function Nt(e){switch(e){case`t1`:case`vct`:return`VCT`;case`t2`:case`vcl`:return`Challengers`;case`gc`:case`game-changers`:return`Game Changers`;default:return`VCT`}}function Pt({impact:e,team1:t,team2:n,winnerId:r}){let i=[];if(e.team1&&e.team1.ratingPost!=null&&i.push({teamName:t.name,side:e.team1,didWin:r===t.id,rankDelta:Ft(e.team1),ratingDelta:It(e.team1),pool:Nt(t.currentTier)}),e.team2&&e.team2.ratingPost!=null&&i.push({teamName:n.name,side:e.team2,didWin:r===n.id,rankDelta:Ft(e.team2),ratingDelta:It(e.team2),pool:Nt(n.currentTier)}),i.length===0)return null;i.sort((e,t)=>t.rankDelta===e.rankDelta?t.ratingDelta===e.ratingDelta?e.didWin===t.didWin?0:e.didWin?-1:1:t.ratingDelta-e.ratingDelta:t.rankDelta-e.rankDelta);let{side:a,didWin:o,teamName:s,pool:c}=i[0],l=o?`This win moved`:`This loss dropped`,u=a.poolRankPre??a.rankPre,d=a.poolRankPost??a.rankPost;if(u!=null&&d!=null&&u!==d)return`${l} ${s} ${d<u?`up`:`down`} from #${u} (${a.ratingPre??`—`}) to #${d} (${a.ratingPost}) in ${c}.`;if(d!=null&&u==null)return`${s} entered the ${c} ranking at #${d} (${a.ratingPost}) after this match.`;if(a.ratingPre!=null&&a.ratingPost!=null&&a.ratingPre!==a.ratingPost){let e=Math.round(a.ratingPost)-Math.round(a.ratingPre);return`${l} ${s}'s rating ${e>0?`+${e}`:`${e}`} (${a.ratingPre} → ${a.ratingPost}) with no change in ${c} rank.`}return null}function Ft(e){let t=e.poolRankPre??e.rankPre,n=e.poolRankPost??e.rankPost;return t==null||n==null?0:Math.abs(t-n)}function It(e){return e.ratingPre==null||e.ratingPost==null?0:Math.abs(Math.round(e.ratingPost)-Math.round(e.ratingPre))}function Lt(e){let t=e.replace(`#`,``),n=parseInt(t.slice(0,2),16)/255,r=parseInt(t.slice(2,4),16)/255,i=parseInt(t.slice(4,6),16)/255,a=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;return[a(n),a(r),a(i)]}function Rt(e){let[t,n,r]=Lt(e);return .2126*t+.7152*n+.0722*r}function zt(e,t){let n=Rt(e),r=Rt(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}var Bt=`#09090b`,Vt=3,Ht=4.5;function Ut({color:e}){let t=zt(e,Bt);return(0,F.jsxs)(`span`,{className:`ml-auto text-xs font-mono tabular-nums ${t>=Ht?`text-emerald-400`:t>=Vt&&t<Ht?`text-amber-400`:`text-red-400`}`,title:`${t.toFixed(1)}:1 contrast vs dark bg`,children:[t.toFixed(1),`:1`]})}function Wt({label:e,color:t,onChange:n}){let r=(0,P.useRef)(null);return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>r.current?.click(),className:`relative h-7 w-7 flex-shrink-0 cursor-pointer rounded-md border border-white/10 transition-colors hover:border-white/30`,style:{backgroundColor:t},"aria-label":`Pick ${e} color`,children:(0,F.jsx)(`input`,{ref:r,type:`color`,value:t,onChange:e=>n(e.target.value),className:`absolute inset-0 cursor-pointer opacity-0`,tabIndex:-1})}),(0,F.jsx)(`span`,{className:`text-xs text-zinc-400`,children:e}),(0,F.jsx)(Ut,{color:t})]})}function Gt(){let{preferences:e,updatePreference:n}=se(),{team1:r,team2:i}=e.teamColors,o=T[0],s=(0,P.useCallback)((e,t)=>{n(`teamColors`,{team1:e,team2:t})},[n]),c=(0,P.useCallback)(()=>{s(o.team1,o.team2)},[o,s]),l=r===o.team1&&i===o.team2;return(0,F.jsxs)(v,{children:[(0,F.jsxs)(g,{className:`flex items-center gap-1.5 rounded-md border border-zinc-200 bg-zinc-50 px-2 py-1.5 text-xs font-medium text-zinc-500 transition-colors hover:border-zinc-300 hover:text-zinc-700 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-300`,"aria-label":`Team color picker`,children:[(0,F.jsx)(a,{size:12}),(0,F.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,F.jsx)(`span`,{className:`h-3 w-3 rounded-full border border-white/20`,style:{backgroundColor:r}}),(0,F.jsx)(`span`,{className:`h-3 w-3 rounded-full border border-white/20`,style:{backgroundColor:i}})]})]}),(0,F.jsx)(ne,{children:(0,F.jsx)(te,{side:`bottom`,align:`end`,sideOffset:6,children:(0,F.jsxs)(h,{className:`z-50 w-64 origin-[var(--transform-origin)] rounded-xl border border-zinc-200/50 bg-white p-3 shadow-lg shadow-zinc-950/10 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 dark:border-white/[0.08] dark:bg-zinc-900 dark:shadow-[0_8px_32px_-8px_rgba(0,0,0,0.7)]`,children:[(0,F.jsxs)(`div`,{className:`mb-2.5 flex items-center justify-between`,children:[(0,F.jsx)(`span`,{className:`text-xs font-semibold text-zinc-700 dark:text-zinc-300`,children:`Team Colors`}),!l&&(0,F.jsxs)(`button`,{type:`button`,onClick:c,className:`flex items-center gap-1 text-xs text-zinc-400 transition-colors hover:text-zinc-600 dark:hover:text-zinc-300`,children:[(0,F.jsx)(t,{size:10}),`Reset`]})]}),(0,F.jsx)(`div`,{className:`mb-3 space-y-1`,children:T.map(e=>{let t=r===e.team1&&i===e.team2;return(0,F.jsxs)(`button`,{type:`button`,onClick:()=>s(e.team1,e.team2),className:`flex w-full items-center gap-2.5 rounded-lg px-2 py-1.5 text-left text-xs transition-colors ${t?`bg-zinc-100 text-zinc-900 dark:bg-zinc-800 dark:text-zinc-100`:`text-zinc-500 hover:bg-zinc-50 hover:text-zinc-700 dark:text-zinc-400 dark:hover:bg-zinc-800/60 dark:hover:text-zinc-300`}`,children:[(0,F.jsxs)(`div`,{className:`flex gap-1`,children:[(0,F.jsx)(`span`,{className:`h-4 w-4 rounded border border-black/10 dark:border-white/10`,style:{backgroundColor:e.team1}}),(0,F.jsx)(`span`,{className:`h-4 w-4 rounded border border-black/10 dark:border-white/10`,style:{backgroundColor:e.team2}})]}),(0,F.jsx)(`span`,{className:`flex-1`,children:e.label}),t&&(0,F.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--glk-brand)]`})]},e.label)})}),(0,F.jsx)(`div`,{className:`mb-3 border-t border-zinc-200 dark:border-zinc-700/50`}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-400`,children:`Custom`}),(0,F.jsx)(Wt,{label:`Team 1`,color:r,onChange:e=>s(e,i)}),(0,F.jsx)(Wt,{label:`Team 2`,color:i,onChange:e=>s(r,e)})]}),(0,F.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-zinc-400`,children:`Contrast ratios are against dark backgrounds. Target 4.5:1 for readability.`})]})})})]})}var Kt=new Set([`vod-official`,`vod-co-stream`]);function qt(e=[],t=[],n=N){let r=[],i=new Set,a=(e,t)=>e?`id:${e}`:`url:${t}`,o=e.map((e,t)=>({link:e,i:t,ls:M(e.language,n)})).sort((e,t)=>t.ls-e.ls||e.i-t.i).map(e=>e.link);for(let e of o){if(!e.kind||!Kt.has(e.kind))continue;let t=a(e.videoId,e.url);i.has(t)||(i.add(t),i.add(`url:${e.url}`),r.push({url:e.url,platform:e.platform,videoId:e.videoId,language:e.language}))}for(let e of t){let t=a(je(e.url)??void 0,e.url),n=`url:${e.url}`;i.has(t)||i.has(n)||(i.add(t),i.add(n),r.push({url:e.url,platform:e.platform}))}return r}function Jt(e,t){try{let n=new URL(e),r=null,i=null;if(n.pathname.match(/^\/@[^/]+\/live\/?$/)||(n.hostname.includes(`youtu.be`)?(r=n.pathname.slice(1),i=n.searchParams.get(`t`)):n.pathname.startsWith(`/live/`)?(r=n.pathname.split(`/`)[2],i=n.searchParams.get(`t`)):(n.pathname===`/watch`||n.pathname===`/watch/`)&&(r=n.searchParams.get(`v`),i=n.searchParams.get(`t`)),!r))return null;let a=new URLSearchParams;i&&a.set(`start`,i),t&&(a.set(`autoplay`,`1`),a.set(`mute`,`1`));let o=a.toString();return`https://www.youtube.com/embed/${r}${o?`?${o}`:``}`}catch{return null}}function Yt(e){try{let t=new URL(e);if(!t.hostname.includes(`twitch.tv`))return null;let n=t.pathname.split(`/`).filter(Boolean),r=typeof window<`u`?window.location.hostname:``,i=r===`localhost`||r===`127.0.0.1`?`parent=localhost&parent=127.0.0.1&parent=glicko.app`:`parent=glicko.app`;return n[0]===`videos`&&n[1]?`https://player.twitch.tv/?video=${n[1]}&${i}`:n.length===1&&n[0]!==`videos`?`https://player.twitch.tv/?channel=${n[0]}&${i}`:null}catch{return null}}function Xt(e,t){return Jt(e,t)??Yt(e)??null}function Zt(e){return e.includes(`twitch.tv`)?`Twitch`:e.includes(`youtube.com`)||e.includes(`youtu.be`)?`YouTube`:`Watch`}function Qt(e){try{let t=new URL(e);if(t.hostname.includes(`twitch.tv`)){let e=t.pathname.split(`/`).filter(Boolean)[0];return e?e.toLowerCase():null}if(t.hostname.includes(`youtube.com`)||t.hostname.includes(`youtu.be`)){let e=t.pathname.split(`/`).filter(Boolean);return e[0]?.startsWith(`@`)?e[0]:(e[0]===`c`||e[0]===`user`||e[0]===`channel`)&&e[1]?e[1]:null}}catch{return null}return null}function $t(){return typeof navigator<`u`&&navigator.language?navigator.language:N}function en({vodLinks:e,streamLinks:t,status:r,className:i,preferredLocale:a,matchLabel:o}){let s=a??$t(),c=r===`live`,[l,u]=(0,P.useState)(0),d=(0,P.useMemo)(()=>c?[...t.length>0?t:e].sort((e,t)=>(e.url.includes(`youtube.com`)||e.url.includes(`youtu.be`)?0:1)-(t.url.includes(`youtube.com`)||t.url.includes(`youtu.be`)?0:1)):[],[c,t,e]),f=d[Math.min(l,d.length-1)],p=f?Xt(f.url,!0):null,m=(0,P.useMemo)(()=>qt(t,e,s),[t,e,s]);return e.length===0&&t.length===0?null:c&&d.length>0?(0,F.jsxs)(`div`,{className:i,children:[d.length>1&&(0,F.jsx)(`div`,{className:`mb-3 flex gap-1.5 overflow-x-auto pb-1`,children:d.map((e,t)=>{let n=Qt(e.url);return(0,F.jsxs)(`button`,{onClick:()=>u(t),className:`flex-shrink-0 rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${t===Math.min(l,d.length-1)?`bg-[var(--glk-brand)] text-white`:`bg-zinc-100 text-zinc-600 hover:bg-zinc-200 dark:bg-zinc-800 dark:text-zinc-400 dark:hover:bg-zinc-700`}`,title:e.url,children:[e.platform,n&&(0,F.jsxs)(`span`,{className:`ml-1 opacity-70`,children:[`· `,n]})]},`${e.url}-${t}`)})}),p?(0,F.jsx)(`div`,{className:`w-full overflow-hidden rounded-lg`,style:{aspectRatio:`16/9`},children:(0,F.jsx)(`iframe`,{src:p,className:`h-full w-full`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,loading:`lazy`,referrerPolicy:`no-referrer-when-downgrade`,title:o?`${o} — live on ${f?.platform??`stream`}`:`${f?.platform??`Live Stream`} — live match stream`})}):(0,F.jsxs)(`a`,{href:f?.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center justify-center gap-2 rounded-lg bg-zinc-100 py-6 text-sm text-zinc-500 transition-colors hover:text-zinc-700 dark:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-300`,children:[(0,F.jsx)(n,{size:14}),`Watch live on `,f?Zt(f.url):`stream`,(0,F.jsx)(S,{size:12})]})]}):m.length===0?null:(0,F.jsxs)(`div`,{className:i,children:[(0,F.jsxs)(`p`,{className:`mb-2 text-xs text-zinc-500 dark:text-zinc-400`,children:[m.length,` VOD`,m.length===1?``:`s`,` available`]}),(0,F.jsx)(`div`,{className:`space-y-1`,children:m.map((e,t)=>{let r=e.language??Qt(e.url);return(0,F.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-2 rounded-md px-2.5 py-2 text-xs text-zinc-600 transition-colors hover:bg-zinc-100 hover:text-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-100`,children:[(0,F.jsx)(n,{size:12,className:`flex-shrink-0`}),(0,F.jsx)(`span`,{className:`flex-1 truncate`,children:Zt(e.url)}),r&&(0,F.jsx)(`span`,{className:`flex-shrink-0 text-zinc-400 dark:text-zinc-500`,children:r}),(0,F.jsx)(S,{size:11,className:`flex-shrink-0 opacity-40`})]},`${e.videoId??e.url}-${t}`)})})]})}function tn(){return typeof navigator<`u`&&navigator.language?navigator.language:N}function nn(e){try{return new URL(e).hostname.toLowerCase()}catch{return``}}function rn(e){let t=nn(e);return t===`youtu.be`||t.endsWith(`.youtu.be`)||t===`youtube.com`||t.endsWith(`.youtube.com`)}function an(e){let t=nn(e);return t===`twitch.tv`||t.endsWith(`.twitch.tv`)}function on(e){try{let t=new URL(e);if(!t.hostname.toLowerCase().includes(`twitch.tv`))return null;let n=t.pathname.split(`/`).filter(Boolean),r=typeof window<`u`?window.location.hostname:``,i=r===`localhost`||r===`127.0.0.1`?`parent=glicko.app&parent=localhost&parent=127.0.0.1`:`parent=glicko.app`;return n[0]===`videos`&&n[1]?`https://player.twitch.tv/?video=${n[1]}&${i}`:n.length===1&&n[0]!==`videos`?`https://player.twitch.tv/?channel=${n[0]}&${i}`:null}catch{return null}}function sn({children:e}){return(0,F.jsx)(`div`,{className:`flex w-full items-center justify-center rounded-lg bg-zinc-100 px-4 py-8 text-center text-sm text-zinc-500 dark:bg-zinc-800 dark:text-zinc-400`,style:{aspectRatio:`16/9`},children:e})}function cn({url:e,label:t}){return(0,F.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`stream-embed-link-fallback`,className:`flex w-full items-center justify-center gap-2 rounded-lg bg-zinc-100 py-6 text-sm text-zinc-600 transition-colors hover:bg-zinc-200 dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700`,style:{aspectRatio:`16/9`},children:[(0,F.jsx)(n,{size:14}),t,(0,F.jsx)(S,{size:12})]})}function ln({embedSrc:e,title:t,poster:r,posterFallback:i,testId:a}){let[o,s]=(0,P.useState)(!1);return(0,F.jsx)(`div`,{className:`relative w-full overflow-hidden rounded-lg bg-black`,style:{aspectRatio:`16/9`},"data-testid":a,children:o?(0,F.jsx)(`iframe`,{src:e,className:`absolute inset-0 h-full w-full`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,referrerPolicy:`no-referrer-when-downgrade`,title:t}):(0,F.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),"aria-label":`Play video`,"data-testid":`stream-embed-facade-play`,className:`group absolute inset-0 flex h-full w-full items-center justify-center`,children:[r&&(0,F.jsx)(`img`,{src:r,alt:``,"aria-hidden":!0,loading:`lazy`,className:`absolute inset-0 h-full w-full object-cover`,onError:i?e=>{let t=e.currentTarget;t.src!==i&&(t.src=i)}:void 0}),(0,F.jsx)(`span`,{className:`absolute inset-0 bg-black/20 transition-colors group-hover:bg-black/30`}),(0,F.jsx)(`span`,{className:`relative flex h-16 w-16 items-center justify-center rounded-full bg-white/90 text-zinc-900 shadow-lg transition-transform group-hover:scale-110`,children:(0,F.jsx)(n,{size:28,className:`ml-1 fill-current`,"aria-hidden":!0})})]})})}function un({match:e,className:t,preferredLocale:n}){let r=(e.status??``).toLowerCase(),i=Me(e,n??tn());if(!i)return r===`scheduled`?(0,F.jsx)(`div`,{className:t,"data-testid":`stream-embed-placeholder`,children:(0,F.jsx)(sn,{children:(0,F.jsx)(`span`,{children:`The official stream will appear here at scheduled start.`})})}):(0,F.jsx)(`div`,{className:t,"data-testid":`stream-embed-placeholder`,children:(0,F.jsx)(sn,{children:(0,F.jsx)(`span`,{children:`Live stream / VOD will appear when available.`})})});let a=r===`live`?`live stream`:r===`completed`?`VOD`:`stream`;if(an(i.url)){let e=on(i.url);return e?(0,F.jsx)(`div`,{className:t,children:(0,F.jsx)(ln,{embedSrc:`${e}&autoplay=true`,title:`${i.channelTitle??i.platform} — ${a}`,testId:`stream-embed-twitch-iframe`})}):(0,F.jsx)(`div`,{className:t,children:(0,F.jsx)(cn,{url:i.url,label:`Watch on Twitch`})})}if(rn(i.url)){let e=i.videoId??je(i.url);return e?(0,F.jsx)(`div`,{className:t,children:(0,F.jsx)(ln,{embedSrc:`https://www.youtube.com/embed/${e}?autoplay=1`,title:`${i.channelTitle??i.platform} — ${a}`,poster:`https://i.ytimg.com/vi/${e}/maxresdefault.jpg`,posterFallback:`https://i.ytimg.com/vi/${e}/hqdefault.jpg`,testId:`stream-embed-youtube-iframe`})}):(0,F.jsx)(`div`,{className:t,children:(0,F.jsx)(cn,{url:i.url,label:`Watch on YouTube`})})}return(0,F.jsx)(`div`,{className:t,children:(0,F.jsx)(cn,{url:i.url,label:`Watch on ${i.platform}`})})}var dn={id:``,name:`TBD`,slug:``,abbreviation:null,logoUrl:null};function $(e){return e??dn}function fn(){let{gameSlug:e,matchId:t}=y(),{data:n,isLoading:r,isError:i,error:a,refetch:s,dataUpdatedAt:l}=Ce(e,t),u=n?he(n):!1,{data:d}=Ne(e,t,u),{isWatching:f,addToWatchlist:p,removeFromWatchlist:m,getPageWidgetConfig:h,updatePageWidgetConfig:g}=se(),_=n?`${$(n.team1).abbreviation??$(n.team1).name} vs ${$(n.team2).abbreviation??$(n.team2).name}`:void 0;de(i&&a instanceof ie?`Not Found`:_);let[v,b]=(0,P.useState)(0),[te,S]=(0,P.useState)(null),[C,ne]=(0,P.useState)(null),[w,re]=(0,P.useState)(!1),[ce,le]=(0,P.useState)(!0),T=(0,P.useMemo)(()=>n?.mapResults.filter(e=>e.winnerId!=null||e.team1Score>0||e.team2Score>0)??[],[n]),D=T[v],{data:ve}=Pe(e,t,T.length===0&&!!n?.team1&&!!n?.team2),{defaultP1:ye,defaultP2:be}=(0,P.useMemo)(()=>{if(!D?.playerStats?.length||!n)return{defaultP1:null,defaultP2:null};let e=D.playerStats.filter(e=>e.teamId===n.team1?.id),t=D.playerStats.filter(e=>e.teamId===n.team2?.id);return{defaultP1:e.sort((e,t)=>(t.acs??0)-(e.acs??0))[0]?.id??null,defaultP2:t.sort((e,t)=>(t.acs??0)-(e.acs??0))[0]?.id??null}},[D,n]),O=te??ye,k=C??be,A=D?.playerStats.find(e=>e.id===O),j=D?.playerStats.find(e=>e.id===k),je=(0,P.useMemo)(()=>{if(!(!A||!j||!n))return{player1:T.flatMap(e=>e.playerStats.filter(e=>e.teamId===A.teamId&&e.agent===A.agent)),player2:T.flatMap(e=>e.playerStats.filter(e=>e.teamId===j.teamId&&e.agent===j.agent))}},[T,n,A,j]),M=(0,P.useMemo)(()=>{if(!D||!n)return[];let e=$(n.team1),t=$(n.team2),r=[];r.push({key:`scoreboard`,title:`Scoreboard`,size:`lg`,titleHidden:!0,component:d?(0,F.jsx)(it,{team1:d.team1,team2:d.team2,mapName:d.mapName,roundNumber:d.roundNumber,roundPhase:d.roundPhase,gameNumber:d.gameNumber,team1DisplayName:e.abbreviation??e.name,team2DisplayName:t.abbreviation??t.name}):(0,F.jsx)(Ze,{playerStats:D.playerStats,team1Id:e.id,team2Id:t.id,team1Name:e.abbreviation??e.name,team2Name:t.abbreviation??t.name,team1Slug:e.slug||void 0,team2Slug:t.slug||void 0})});let i=!!(A&&j&&D.playerStats.length>=2);return i&&r.push({key:`h2h`,title:`Head-to-Head`,size:`md`,component:(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center gap-3`,children:[(0,F.jsx)(ft,{players:D.playerStats,team1Id:e.id,team2Id:t.id,team1Name:e.abbreviation??e.name,team2Name:t.abbreviation??t.name,value:O,onChange:S}),(0,F.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`vs`}),(0,F.jsx)(ft,{players:D.playerStats,team1Id:e.id,team2Id:t.id,team1Name:e.abbreviation??e.name,team2Name:t.abbreviation??t.name,value:k,onChange:ne})]}),(0,F.jsx)(Dt,{player1Stats:A,player2Stats:j,allMapStats:je,team1Name:e.abbreviation??e.name,team2Name:t.abbreviation??t.name,team1Slug:e.slug||void 0,team2Slug:t.slug||void 0})]})}),r.push({key:`sideSplits`,title:`Side Info`,size:i?`sm`:`lg`,component:(0,F.jsx)(ut,{mapResult:D,team1Id:e.id,team2Id:t.id,team1Name:e.name,team2Name:t.name})}),D.roundResults.length>0&&r.push({key:`rounds`,title:`Momentum`,size:`lg`,component:(0,F.jsx)(Ue,{rounds:D.roundResults,team1Id:e.id,team2Id:t.id,team1Name:e.abbreviation??e.name,team2Name:t.abbreviation??t.name})}),D.roundResults.some(e=>e.team1LoadoutValue!=null)&&r.push({key:`economy`,title:`Economy Timeline`,size:`lg`,component:(0,F.jsx)(qe,{rounds:D.roundResults,team1Id:e.id,team2Id:t.id,team1Name:e.abbreviation??e.name,team2Name:t.abbreviation??t.name})}),r},[D,n,d,O,k,A,j,je,S,ne]),Me=`matchDetail`,N=h(Me,{order:(0,P.useMemo)(()=>M.map(e=>e.key),[M]),sizes:{}}),Ie=(0,P.useMemo)(()=>{let e=new Map(M.map(e=>[e.key,e])),t=new Set(N.hidden),n=N.order.map(t=>e.get(t)).filter(e=>!!e&&!t.has(e.key)),r=new Set(n.map(e=>e.key)),i=M.filter(e=>!r.has(e.key)&&!t.has(e.key));return[...n,...i]},[M,N.order,N.hidden]),Le=e=>{g(Me,{order:e})},I=e=>{g(Me,{hidden:[...N.hidden,e]})};if(i&&a instanceof ie)return(0,F.jsx)(oe,{});if(r||i||!n)return(0,F.jsx)(pe,{title:`Match`,breadcrumbs:[{label:`Matches`,href:`/${e}/matches`}],className:`flex h-full flex-col overflow-hidden`,loadingKind:`detail`,emptyMessage:`Match not found.`,status:{isLoading:r,isError:i,error:i?Error(`Failed to load match`):null,isEmpty:!r&&!i&&!n,retry:()=>void s()},children:(0,F.jsx)(`div`,{})});let L=$(n.team1),R=$(n.team2),z=T.filter(e=>e.winnerId===L.id).length,B=T.filter(e=>e.winnerId===R.id).length;if(z===0&&B===0&&n.stats?.seriesScore){let[e,t]=Array.isArray(n.stats.seriesScore)?n.stats.seriesScore:n.stats.seriesScore.split(`-`).map(Number);!isNaN(e)&&!isNaN(t)&&(z=e,B=t)}z===0&&B===0&&(n.team1Maps??0)+(n.team2Maps??0)>0&&(z=n.team1Maps??0,B=n.team2Maps??0);let V=_??`${L.abbreviation??L.name} vs ${R.abbreviation??R.name}`,H=n.tournament?`${L.name} vs ${R.name} — ${n.tournament.name}`:`${L.name} vs ${R.name}`,U=n.tournament?`${L.name} vs ${R.name} at ${n.tournament.name} — Valorant ${n.format?.toUpperCase()??`match`}. Live stats, scoreboard, and analytics on Glicko.`:`${L.name} vs ${R.name} — Valorant match stats and analytics on Glicko.`,W=n.team1&&n.team2?fe({name:`${L.name} vs ${R.name}`,url:typeof window<`u`?window.location.href:`https://glicko.app/${e}/matches/${n.id}`,startDate:n.playedAt??n.scheduledAt??new Date().toISOString(),homeTeam:{name:L.name,url:`https://glicko.app/${e}/teams/${L.slug}`},awayTeam:{name:R.name,url:`https://glicko.app/${e}/teams/${R.slug}`},organizer:n.tournament?{name:n.tournament.name,url:`https://glicko.app/${e}/tournaments/${n.tournament.slug}`}:void 0}):null;return(0,F.jsxs)(pe,{title:V,lightVignette:!0,breadcrumbs:[{label:`Matches`,href:`/${e}/matches`}],seo:{title:H,description:U,image:Ee(e??`valorant`,`match`,n.id),type:`article`},actions:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(Gt,{}),(0,F.jsx)(Ae,{entry:{type:`match`,slug:n.id,name:V,meta:{title:V}},isWatching:f(n.id),onAdd:p,onRemove:m}),(0,F.jsx)(De,{editing:w,onToggle:()=>re(e=>!e)})]}),tabs:w?(0,F.jsx)(ke,{}):void 0,freshness:{lastUpdatedAt:l},className:`flex h-full flex-col overflow-hidden`,children:[W&&(0,F.jsx)(me,{data:W}),(0,F.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,F.jsxs)(_e,{className:`mx-auto max-w-6xl`,children:[(0,F.jsxs)(`div`,{className:`mb-6 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`glk-card relative overflow-hidden !px-3 !py-4 sm:!px-5 sm:!py-5`,children:[(n.tournament||n.stage&&n.stage!==`other`)&&(0,F.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-center gap-2`,children:[n.tournament&&(0,F.jsx)(x,{to:`/${e}/tournaments/${n.tournament.slug}`,className:`rounded-full bg-zinc-200/80 px-2.5 py-0.5 text-xs font-medium text-zinc-600 transition-colors hover:text-[var(--glk-brand)] dark:bg-zinc-800 dark:text-zinc-400`,children:n.tournament.name}),n.stage&&n.stage!==`other`&&(0,F.jsx)(xe,{tone:`neutral`,uppercase:!1,children:n.stage}),(0,F.jsx)(xe,{tone:`neutral`,children:n.format})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-center gap-3 sm:gap-8`,"aria-label":`${L.name} ${z} – ${B} ${R.name}${n.winner?`, ${n.winner.id===L.id?L.name:R.name} wins`:``}`,children:[(0,F.jsxs)(`div`,{className:E(`flex flex-col items-center gap-1 sm:gap-1.5 min-w-0 max-w-[38%]`,n.winner&&n.winner.id!==L.id&&`opacity-50`),children:[(0,F.jsx)(ae,{name:L.name,slug:L.slug,abbreviation:L.abbreviation,logoUrl:L.logoUrl,size:`lg`}),n.team1?(0,F.jsx)(x,{to:`/${e}/teams/${L.slug}`,className:`max-w-full truncate text-center text-sm font-black text-zinc-900 transition-colors hover:text-[var(--glk-brand)] dark:text-zinc-100 sm:text-lg`,children:L.name}):(0,F.jsx)(`span`,{className:`max-w-full truncate text-sm font-black opacity-40 sm:text-lg`,children:L.name}),n.team1Rating&&(0,F.jsxs)(`span`,{className:`text-2xs tabular-nums text-zinc-400`,children:[n.team1Rating.rating,` `,(0,F.jsxs)(`span`,{className:`text-zinc-400/60`,children:[`±`,n.team1Rating.rd]})]})]}),(0,F.jsx)(`div`,{className:`flex-shrink-0 text-center`,children:(0,F.jsxs)(`div`,{className:`glk-metric glk-metric-xl text-zinc-900 dark:text-zinc-100`,children:[z,(0,F.jsx)(`span`,{className:`mx-1 text-zinc-300 dark:text-zinc-600`,children:`–`}),B]})}),(0,F.jsxs)(`div`,{className:E(`flex flex-col items-center gap-1 sm:gap-1.5 min-w-0 max-w-[38%]`,n.winner&&n.winner.id!==R.id&&`opacity-50`),children:[(0,F.jsx)(ae,{name:R.name,slug:R.slug,abbreviation:R.abbreviation,logoUrl:R.logoUrl,size:`lg`}),n.team2?(0,F.jsx)(x,{to:`/${e}/teams/${R.slug}`,className:`max-w-full truncate text-center text-sm font-black text-zinc-900 transition-colors hover:text-[var(--glk-brand)] dark:text-zinc-100 sm:text-lg`,children:R.name}):(0,F.jsx)(`span`,{className:`max-w-full truncate text-sm font-black opacity-40 sm:text-lg`,children:R.name}),n.team2Rating&&(0,F.jsxs)(`span`,{className:`text-2xs tabular-nums text-zinc-400`,children:[n.team2Rating.rating,` `,(0,F.jsxs)(`span`,{className:`text-zinc-400/60`,children:[`±`,n.team2Rating.rd]})]})]})]}),!n.playedAt&&n.scheduledAt&&(0,F.jsxs)(`div`,{className:`mt-3 text-center text-xs text-zinc-400`,children:[new Date(n.scheduledAt).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`}),` · `,new Date(n.scheduledAt).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`})]}),n.winner&&(0,F.jsx)(`div`,{className:E(`absolute top-0 h-full w-1 bg-[var(--glk-brand)]`,n.winner.id===L.id?`left-0`:`right-0`)}),T.length>0&&(0,F.jsx)(`div`,{className:`mt-3 flex justify-center`,children:(0,F.jsx)(Te,{narrative:we(n)})})]}),(()=>{let e=(n.status??``).toLowerCase();return e!==`live`&&e!==`completed`&&e!==`scheduled`||!(n.stats?.streamLinks??[]).some(e=>typeof e.kind==`string`)&&e!==`scheduled`?null:(0,F.jsx)(un,{match:n,className:`glk-card !p-0 overflow-hidden`})})(),(()=>{let e=he(n),t=n.stats?.streamLinks??[],r=n.stats?.vodLinks??[],i=e&&t.length===0&&n.tournament?ge(n.tournament.name):null,a=t.length>0?t:i?[i.primary,...i.coStreams]:[];return(e?a.length>0||r.length>0:qt(t,r).length>0)?(0,F.jsxs)(`div`,{className:`glk-card !p-0 overflow-x-visible overflow-y-hidden`,children:[(0,F.jsxs)(`button`,{onClick:()=>le(e=>!e),"aria-expanded":ce,"aria-controls":`stream-vod-panel`,className:`flex w-full items-center justify-between px-4 py-2.5 text-xs font-medium text-zinc-500 transition-colors hover:text-zinc-700 dark:text-zinc-400 dark:hover:text-zinc-200`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(c,{size:12,className:e?`text-red-500`:``}),e?`Watch Live`:`Watch VODs`]}),ce?(0,F.jsx)(ee,{size:14}):(0,F.jsx)(o,{size:14})]}),ce&&(0,F.jsx)(`div`,{id:`stream-vod-panel`,className:`px-4 pb-4`,children:(0,F.jsx)(en,{streamLinks:a,vodLinks:r,status:e?`live`:n.status,matchLabel:_})})]}):null})(),n.mapResults.length>0&&(()=>{let e=n.mapResults.findIndex(e=>!ue(e));return(0,F.jsx)(`div`,{className:`flex h-16 gap-1 sm:h-24 sm:gap-1.5`,role:`group`,"aria-label":`Map selection`,children:n.mapResults.map((t,r)=>{let i=t.winnerId!=null||t.team1Score>0||t.team2Score>0,a=ue(t),o=u&&!a&&r===e,s=i&&T[v]?.id===t.id,c=T.findIndex(e=>e.id===t.id),l=t.winnerId===L.id?L.abbreviation??L.name:t.winnerId===R.id?R.abbreviation??R.name:null,d=o?`Map ${r+1}: ${t.mapName??`Unknown`}, live ${t.team1Score}–${t.team2Score}`:i?`Map ${r+1}: ${t.mapName??`Unknown`}, ${t.team1Score}–${t.team2Score}${l?`, ${l} wins`:``}${s?`, currently selected`:``}`:`Map ${r+1}: ${t.mapName??`Unknown`}, not yet played`;return(0,F.jsxs)(`button`,{onClick:()=>{c>=0&&b(c)},disabled:!i,"aria-label":d,"aria-pressed":s,className:`group relative flex-1 overflow-hidden rounded-lg border transition-all duration-200 ${o?`border-[var(--glk-brand)] ring-2 ring-[var(--glk-brand)]/40 shadow-[0_0_16px_rgba(255,70,85,0.25)]`:s?`border-[var(--glk-brand)] ring-1 ring-[var(--glk-brand)]/30 shadow-[0_0_12px_rgba(255,70,85,0.15)]`:i?`border-zinc-200 hover:border-zinc-300 dark:border-white/[0.06] dark:hover:border-white/10`:`border-dashed border-zinc-200/40 dark:border-white/[0.06]`}`,children:[(0,F.jsx)(Se,{name:t.mapName,variant:`strip`,index:r,total:n.mapResults.length,grayed:!i}),(0,F.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-black/90 via-black/30 to-transparent`}),(0,F.jsxs)(`div`,{className:`absolute bottom-0 left-0 w-full px-2.5 pb-2 pt-4`,style:{textShadow:`0 1px 4px rgba(0,0,0,0.8), 0 0 2px rgba(0,0,0,0.6)`},children:[(0,F.jsx)(`div`,{className:`glk-eyebrow text-white/90`,children:t.mapName}),i?(0,F.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,F.jsx)(`span`,{className:E(`text-lg font-black tabular-nums leading-none`,t.winnerId===L.id?`text-white`:`text-white/50`),children:t.team1Score}),(0,F.jsx)(`span`,{className:`text-white/30`,children:`–`}),(0,F.jsx)(`span`,{className:E(`text-lg font-black tabular-nums leading-none`,t.winnerId===R.id?`text-white`:`text-white/50`),children:t.team2Score}),t.winnerId&&(0,F.jsx)(`span`,{className:`text-xs font-bold text-white/70`,children:t.winnerId===L.id?L.abbreviation??L.name:R.abbreviation??R.name})]}):(0,F.jsx)(`div`,{className:`glk-eyebrow text-white/30`,children:(()=>{let e=n.format===`bo5`?3:n.format===`bo3`?2:1,t=n.mapResults.filter(e=>e.winnerId===L.id).length,r=n.mapResults.filter(e=>e.winnerId===R.id).length;return t>=e||r>=e?`Decider not needed`:`Upcoming`})()})]}),o?(0,F.jsxs)(`span`,{className:`absolute right-2 top-2 inline-flex items-center gap-1 rounded bg-[var(--glk-brand)] px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider text-white shadow-[0_0_8px_rgba(255,70,85,0.6)]`,children:[(0,F.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5`,"aria-hidden":`true`,children:[(0,F.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-white/80`}),(0,F.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-white`})]}),`Live`]}):s?(0,F.jsx)(`div`,{className:`absolute right-2 top-2 h-1.5 w-1.5 rounded-full bg-[var(--glk-brand)]`}):null]},t.id)})})})()]}),(n.status===`completed`||n.status===`forfeit`)&&n.ratingImpact&&n.team1&&n.team2&&(0,F.jsx)(`div`,{className:`mb-4`,children:(0,F.jsx)(Ot,{impact:n.ratingImpact,team1:{id:L.id,name:L.name,abbreviation:L.abbreviation,currentTier:n.team1?.currentTier},team2:{id:R.id,name:R.name,abbreviation:R.abbreviation,currentTier:n.team2?.currentTier},winnerId:n.winner?.id??null})}),n.status===`tbd`?(0,F.jsx)(`div`,{className:`glk-card !p-6 text-center text-zinc-500 dark:text-zinc-400`,children:`Teams not yet determined — awaiting earlier bracket results`}):(0,F.jsxs)(F.Fragment,{children:[T.length===0&&(ve&&n.team1&&n.team2?(0,F.jsx)(Fe,{match:n,preview:ve,gameSlug:e}):(0,F.jsx)(`div`,{className:`glk-card !p-8 text-center`,children:n.playedAt?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`text-sm font-semibold text-zinc-500 dark:text-zinc-400`,children:`No map data available`}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:`This match has concluded but detailed map and player stats have not been recorded.`})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`mb-3 flex items-center justify-center`,children:(0,F.jsx)(xe,{tone:`warning`,pulse:!0,children:`Match in progress`})}),(0,F.jsx)(`p`,{className:`text-xs text-zinc-400`,children:`Detailed stats will appear once the match concludes. Check back soon.`})]})})),T.length>0&&(0,F.jsx)(F.Fragment,{children:D&&(0,F.jsx)(Oe,{widgets:Ie,columns:3,editing:w,onReorder:Le,onHide:I})})]})]})})]})}export{fn as default};