import{ri as e,si as t}from"./vendor-DU4C2Mru.js";import{M as n,P as r,vt as i}from"./index-B7s3VjPV.js";import{t as a}from"./status-pill-bTqAlgAD.js";import{t as o}from"./MapImage-wRd7latf.js";var s=e();function c(e,t){if(t<=1)return e;let n=Math.ceil(t/2),r=0;for(let t=0;t<n;t++){let i=n+t,a=1;for(let e=0;e<t;e++)a*=(i-1-e)/(e+1);r+=a*e**+n*(1-e)**t}return r}function l({match:e,gameSlug:l,hideSpoilers:u}){let d=e.team1,f=e.team2,p=e.mapResults??[],m=e.mapResults?.filter(e=>r(e)&&e.winnerId===d.id).length??0,h=e.mapResults?.filter(e=>r(e)&&e.winnerId===f.id).length??0,g=[...p].reverse().find(e=>!r(e)&&(e.team1Score>0||e.team2Score>0)),_=p.find(e=>!r(e)&&e.team1Score===0&&e.team2Score===0),v=e.status===`live`,y=g??(v?_:void 0)??[...p].filter(r).slice(-1)[0],b=d.rating==null?null:Math.round(d.rating),x=f.rating==null?null:Math.round(f.rating),S=c(b!=null&&x!=null?1/(1+10**((x-b)/400)):.5,/bo5|best of 5/i.test(e.format??``)?5:/bo3|best of 3/i.test(e.format??``)?3:1),C=Math.round(S*100),w=100-C,T=b!=null&&x!=null,E=y?p.indexOf(y):-1;return(0,s.jsx)(t,{to:`/${l}/matches/${e.id}`,className:i(`glk-card glk-card-interactive !p-0 group relative block overflow-hidden`,`glk-featured-match`),style:{borderLeft:`3px solid var(--glk-brand)`,backgroundImage:`linear-gradient(135deg, color-mix(in srgb, var(--glk-brand) 6%, transparent), transparent 60%)`},children:(0,s.jsxs)(`div`,{className:`p-4`,children:[(0,s.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,s.jsx)(a,{tone:`live`,size:`xs`,pulse:!0,children:`Live`}),e.tournament?.name&&(0,s.jsxs)(`span`,{className:`min-w-0 truncate text-xs text-zinc-600 dark:text-zinc-300`,children:[e.tournament.name,e.stage?(0,s.jsxs)(`span`,{className:`text-zinc-400`,children:[` · `,e.stage]}):null]}),e.format&&(0,s.jsx)(`span`,{className:`rounded border border-zinc-200 px-1.5 py-0.5 text-2xs font-bold tracking-wider text-zinc-500 dark:border-white/10 dark:text-zinc-400`,children:e.format.toUpperCase()}),y&&(0,s.jsxs)(`span`,{className:`glk-featured-current-map ml-auto flex items-center gap-1.5 text-xs`,children:[(0,s.jsxs)(`span`,{className:`glk-eyebrow`,children:[`Map `,E>=0?E+1:p.length]}),(0,s.jsx)(`span`,{className:`capitalize text-zinc-600 dark:text-zinc-300`,children:y.mapName.toLowerCase()})]})]}),(0,s.jsxs)(`div`,{className:`glk-featured-main mt-4 grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-4`,children:[(0,s.jsxs)(`div`,{className:`glk-featured-team glk-featured-team-1 flex min-w-0 items-center gap-3`,children:[(0,s.jsx)(n,{name:d.name,slug:d.slug,abbreviation:d.abbreviation,logoUrl:d.logoUrl,size:`lg`}),(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`div`,{className:`truncate text-[18px] font-bold tracking-tight text-zinc-900 dark:text-zinc-50`,style:{fontFamily:`var(--font-display)`},children:d.name}),(0,s.jsx)(`div`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:b!=null&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`span`,{className:`glk-eyebrow mr-1`,children:`Rating`}),(0,s.jsx)(`span`,{className:`glk-metric glk-metric-sm text-zinc-700 dark:text-zinc-200`,children:b})]})})]})]}),(0,s.jsxs)(`div`,{className:`glk-featured-score flex flex-col items-center`,children:[(0,s.jsx)(`div`,{className:`flex items-baseline gap-1.5 font-mono font-bold leading-none tracking-tight`,children:u?(0,s.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,style:{fontSize:36},children:`· — ·`}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`span`,{className:i(`glk-tabular`,m>=h?`text-zinc-900 dark:text-zinc-50`:`text-zinc-400 dark:text-zinc-500`),style:{fontSize:36},children:m}),(0,s.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-600`,style:{fontSize:28},children:`–`}),(0,s.jsx)(`span`,{className:i(`glk-tabular`,h>=m?`text-zinc-900 dark:text-zinc-50`:`text-zinc-400 dark:text-zinc-500`),style:{fontSize:36},children:h})]})}),(0,s.jsx)(`div`,{className:`glk-eyebrow mt-1.5`,children:`Map Series`})]}),(0,s.jsxs)(`div`,{className:`glk-featured-team glk-featured-team-2 flex min-w-0 items-center justify-end gap-3`,children:[(0,s.jsxs)(`div`,{className:`glk-featured-team-2-meta min-w-0 text-right`,children:[(0,s.jsx)(`div`,{className:`truncate text-[18px] font-bold tracking-tight text-zinc-900 dark:text-zinc-50`,style:{fontFamily:`var(--font-display)`},children:f.name}),(0,s.jsx)(`div`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:x!=null&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`span`,{className:`glk-eyebrow mr-1`,children:`Rating`}),(0,s.jsx)(`span`,{className:`glk-metric glk-metric-sm text-zinc-700 dark:text-zinc-200`,children:x})]})})]}),(0,s.jsx)(n,{name:f.name,slug:f.slug,abbreviation:f.abbreviation,logoUrl:f.logoUrl,size:`lg`})]})]}),p.length>0&&!u&&(0,s.jsx)(`div`,{className:`mt-4 grid gap-2`,style:{gridTemplateColumns:`repeat(${Math.min(p.length,3)}, minmax(0, 1fr))`},children:p.slice(0,3).map((e,t)=>{let n=v&&e===y&&!r(e),a=e.winnerId===d.id;return(0,s.jsxs)(`div`,{className:i(`relative flex items-center gap-3 overflow-hidden rounded-md border px-2.5 py-2`,n?`border-red-500/30 bg-red-500/5`:`border-zinc-200 bg-zinc-50 dark:border-white/[0.06] dark:bg-white/[0.02]`),children:[(0,s.jsxs)(`div`,{className:`pointer-events-none absolute inset-0`,"aria-hidden":`true`,children:[(0,s.jsx)(o,{name:e.mapName,variant:`strip`,index:t,total:p.length,grayed:!n&&!r(e)}),(0,s.jsx)(`div`,{className:i(`absolute inset-0`,n?`bg-red-500/10`:`bg-zinc-50/80 dark:bg-zinc-900/80`)})]}),n&&(0,s.jsx)(`span`,{className:`glk-live-dot absolute right-1.5 top-1.5 z-20`,"aria-label":`Live map`}),(0,s.jsxs)(`div`,{className:`relative z-10 min-w-0 flex-1`,children:[(0,s.jsxs)(`div`,{className:`glk-eyebrow`,children:[`Map `,t+1]}),(0,s.jsx)(`div`,{className:`truncate text-sm font-semibold capitalize text-zinc-800 drop-shadow-[0_1px_1px_rgba(0,0,0,0.25)] dark:text-zinc-100`,children:e.mapName.toLowerCase()})]}),(0,s.jsxs)(`div`,{className:i(`glk-metric glk-tabular relative z-10 mt-3 flex items-center gap-1.5 self-end rounded-md border border-white/10 bg-zinc-950/60 px-2 py-1 text-sm leading-none shadow-[inset_0_1px_0_rgba(255,255,255,0.06)] backdrop-blur-[2px] dark:border-white/10 dark:bg-black/50`,n&&`mr-3`),children:[(0,s.jsx)(`span`,{className:i(r(e)&&!a?`text-zinc-200 dark:text-zinc-500`:`text-zinc-100`),children:e.team1Score}),(0,s.jsx)(`span`,{className:`text-zinc-300 dark:text-zinc-600`,children:`·`}),(0,s.jsx)(`span`,{className:i(r(e)&&a?`text-zinc-200 dark:text-zinc-500`:`text-zinc-100`),children:e.team2Score})]})]},t)})}),!u&&T&&(0,s.jsxs)(`div`,{className:`mt-4`,children:[(0,s.jsxs)(`div`,{className:`glk-eyebrow mb-1.5 flex items-center justify-between`,children:[(0,s.jsx)(`span`,{className:`flex items-center gap-1.5`,children:`Win Probability`}),(0,s.jsxs)(`span`,{className:`normal-case tracking-normal text-zinc-400 dark:text-zinc-500`,children:[`Glicko matchup · `,e.format?e.format.toUpperCase():`BO1`]})]}),(0,s.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full`,style:{background:`linear-gradient(90deg,
#0ea5e9 0%,
#0ea5e9 ${Math.max(0,C-18)}%,
#f59e0b ${Math.min(100,C+18)}%,
#f59e0b 100%)`}}),(0,s.jsxs)(`div`,{className:`glk-tabular mt-1 flex min-w-0 justify-between gap-2 text-2xs`,children:[(0,s.jsxs)(`span`,{className:`truncate font-bold text-sky-500`,children:[d.abbreviation??d.name,` `,C,`%`]}),(0,s.jsxs)(`span`,{className:`truncate text-right font-bold text-amber-500`,children:[w,`% `,f.abbreviation??f.name]})]})]})]})})}export{l as t};