t2-mapper/docs/assets/ScoreScreen-D63KN6fm.js
2026-03-14 23:04:25 -07:00

1 line
No EOL
9.3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{r as e}from"./chunk-DECur_0Z.js";import{n as t,r as n,t as r}from"./jsx-runtime-BpGWiA-R.js";import{t as i}from"./iconBase-DI0lMIX5.js";import"./logger-CiAJCFpz.js";import"./traditional-CVpSAKe0.js";import"./mission-BLbEDC74.js";import{i as a}from"./engineStore-CLELjjpY.js";import{$ as o,Et as s,X as c}from"./index-OhjeY6aE.js";var l=t(),u=e(n(),1);function d(e){return i({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M232 306.667h48V176h-48v130.667z`},child:[]},{tag:`path`,attr:{d:`M407.67 170.271l30.786-30.786-33.942-33.941-30.785 30.786C341.217 111.057 300.369 96 256 96 149.961 96 64 181.961 64 288s85.961 192 192 192 192-85.961 192-192c0-44.369-15.057-85.217-40.33-117.729zm-45.604 223.795C333.734 422.398 296.066 438 256 438s-77.735-15.602-106.066-43.934C121.602 365.735 106 328.066 106 288s15.602-77.735 43.934-106.066C178.265 153.602 215.934 138 256 138s77.734 15.602 106.066 43.934C390.398 210.265 406 247.934 406 288s-15.602 77.735-43.934 106.066zM192 32h128v48H192z`},child:[]}]})(e)}var f={Dialog:`_Dialog_2r1di_1 _Dialog_6c89x_1`,Overlay:`_Overlay_2r1di_10 _Overlay_6c89x_20`,TitleBar:`_TitleBar_2r1di_14`,PlayerTotal:`_PlayerTotal_2r1di_26`,Title:`_Title_2r1di_14`,MatchClock:`_MatchClock_2r1di_45`,Time:`_Time_2r1di_55`,PlayersIcon:`_PlayersIcon_2r1di_59`,ClockIcon:`_ClockIcon_2r1di_63`,TableWrapper:`_TableWrapper_2r1di_68`,Table:`_Table_2r1di_68`,TeamHeaderRow:`_TeamHeaderRow_2r1di_90`,TeamName:`_TeamName_2r1di_97`,TeamScore:`_TeamScore_2r1di_105`,ColumnHeaderRow:`_ColumnHeaderRow_2r1di_113`,ColumnHeader:`_ColumnHeader_2r1di_113`,ColumnHeaderScore:`_ColumnHeaderScore_2r1di_127`,ColumnPing:`_ColumnPing_2r1di_131`,PlayerBody:`_PlayerBody_2r1di_140`,PlayerName:`_PlayerName_2r1di_154`,PlayerNameLocal:`_PlayerNameLocal_2r1di_162 _PlayerName_2r1di_154`,PlayerScore:`_PlayerScore_2r1di_167`,PlayerScoreLocal:`_PlayerScoreLocal_2r1di_174 _PlayerScore_2r1di_167`,ObserverBody:`_ObserverBody_2r1di_183`,Footer:`_Footer_2r1di_204`,CloseButton:`_CloseButton_2r1di_214 _DialogButton_6c89x_31`,Hint:`_Hint_2r1di_218`,Empty:`_Empty_2r1di_224`},p=r(),m={1:`Storm`,2:`Inferno`,3:`Starwolf`,4:`Diamond Sword`,5:`Blood Eagle`,6:`Phoenix`};function h(e){if(!e.length)return{avg:0,dev:0};let t=e.map(e=>e.ping),n=t.reduce((e,t)=>e+t,0)/t.length,r=t.reduce((e,t)=>e+(t-n)**2,0)/t.length;return{avg:Math.round(n),dev:Math.round(Math.sqrt(r))}}function g(e){let t=e<0?`-`:``,n=Math.abs(e),r=Math.floor(n/60),i=Math.floor(n%60);return`${t}${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`}function _(e){let t=(0,l.c)(5),{clockMs:n}=e,r=Math.abs(n)/1e3,i=n<0?Math.ceil(r):Math.floor(r),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,p.jsx)(d,{className:f.ClockIcon}),t[0]=a):a=t[0];let o;t[1]===i?o=t[2]:(o=g(i),t[1]=i,t[2]=o);let s;return t[3]===o?s=t[4]:(s=(0,p.jsxs)(`span`,{className:f.MatchClock,children:[a,` `,(0,p.jsx)(`span`,{className:f.Time,children:o})]}),t[3]=o,t[4]=s),s}function v(e){return e.name||m[e.teamId]||`Team ${e.teamId}`}function y(e){let t=(0,l.c)(56),{onClose:n}=e,r=(0,u.useRef)(null),i=o()===`live`,{connectedClientId:c,teamScores:d,playerRoster:m,matchClockMs:g}=a(se,oe),y,b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{r.current?.focus();try{document.exitPointerLock()}catch{}},b=[],t[0]=y,t[1]=b):(y=t[0],b=t[1]),(0,u.useEffect)(y,b);let x,S;t[2]===n?(x=t[3],S=t[4]):(x=()=>{let e=e=>{e.key===`Escape`&&n(),e.stopImmediatePropagation()},t=ae;return window.addEventListener(`keydown`,e,{capture:!0}),window.addEventListener(`keyup`,t,{capture:!0}),()=>{window.removeEventListener(`keydown`,e,{capture:!0}),window.removeEventListener(`keyup`,t,{capture:!0})}},S=[n],t[2]=n,t[3]=x,t[4]=S),(0,u.useEffect)(x,S);let C,w;t[5]===i?(C=t[6],w=t[7]):(C=()=>{if(!i)return;let e=ie;e();let t=setInterval(e,4e3);return()=>clearInterval(t)},w=[i],t[5]=i,t[6]=C,t[7]=w),(0,u.useEffect)(C,w);let T;if(t[8]!==m){let e=new Map,n=[];if(m)for(let t of m)if(t.teamId>0){let n=e.get(t.teamId);n?n.push(t):e.set(t.teamId,[t])}else n.push(t);for(let t of e.values())t.sort(re);n.sort(ne),T={teamPlayers:e,observers:n},t[8]=m,t[9]=T}else T=t[9];let{teamPlayers:E,observers:D}=T,O;bb0:{if(!d?.length){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[10]=e):e=t[10],O=e;break bb0}let e;t[11]===d?e=t[12]:(e=[...d].sort(te),t[11]=d,t[12]=e),O=e}let k=O,A=k.length>=2,j=k[0],M=k[1],N;t[13]!==j||t[14]!==E?(N=j?E.get(j.teamId)??[]:[],t[13]=j,t[14]=E,t[15]=N):N=t[15];let P=N,F;t[16]!==M||t[17]!==E?(F=M?E.get(M.teamId)??[]:[],t[16]=M,t[17]=E,t[18]=F):F=t[18];let I=F,L;t[19]===P?L=t[20]:(L=h(P),t[19]=P,t[20]=L);let R=L,z;t[21]===I?z=t[22]:(z=h(I),t[21]=I,t[22]=z);let B=z,V=Math.max(P.length,I.length),H;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,p.jsx)(`h2`,{className:f.Title,children:`Score`}),t[23]=H):H=t[23];let U;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,p.jsx)(s,{className:f.PlayersIcon}),t[24]=U):U=t[24];let W=m?.length??0,G;t[25]===W?G=t[26]:(G=(0,p.jsxs)(`span`,{className:f.PlayerTotal,children:[U,` `,W,` players`]}),t[25]=W,t[26]=G);let K;t[27]===g?K=t[28]:(K=g!=null&&(0,p.jsx)(_,{clockMs:g}),t[27]=g,t[28]=K);let q;t[29]!==G||t[30]!==K?(q=(0,p.jsxs)(`header`,{className:f.TitleBar,children:[H,` `,G,` `,K]}),t[29]=G,t[30]=K,t[31]=q):q=t[31];let J;t[32]!==c||t[33]!==A||t[34]!==V||t[35]!==D||t[36]!==m?.length||t[37]!==j||t[38]!==R||t[39]!==P||t[40]!==M||t[41]!==B||t[42]!==I?(J=A?(0,p.jsx)(`div`,{className:f.TableWrapper,children:(0,p.jsxs)(`table`,{className:f.Table,children:[(0,p.jsxs)(`thead`,{children:[(0,p.jsxs)(`tr`,{className:f.TeamHeaderRow,children:[(0,p.jsx)(`th`,{className:f.TeamName,children:v(j)}),(0,p.jsx)(`th`,{className:f.TeamScore,children:j.score}),(0,p.jsx)(`th`,{className:f.TeamName,children:v(M)}),(0,p.jsx)(`th`,{className:f.TeamScore,children:M.score})]}),(0,p.jsxs)(`tr`,{className:f.ColumnHeaderRow,children:[(0,p.jsxs)(`th`,{className:f.ColumnHeader,children:[(0,p.jsxs)(`span`,{children:[`Players (`,P.length,`)`]}),P.length>0&&(0,p.jsxs)(`span`,{className:f.ColumnPing,children:[` `,`PING: `,R.avg,` ± `,R.dev,`ms`]})]}),(0,p.jsx)(`th`,{className:f.ColumnHeaderScore,children:`Score`}),(0,p.jsxs)(`th`,{className:f.ColumnHeader,children:[(0,p.jsxs)(`span`,{children:[`Players (`,I.length,`)`]}),I.length>0&&(0,p.jsxs)(`span`,{className:f.ColumnPing,children:[` `,`PING: `,B.avg,` ± `,B.dev,`ms`]})]}),(0,p.jsx)(`th`,{className:f.ColumnHeaderScore,children:`Score`})]})]}),(0,p.jsx)(`tbody`,{className:f.PlayerBody,children:Array.from({length:V},(e,t)=>{let n=P[t],r=I[t],i=c!=null&&n?.clientId===c,a=c!=null&&r?.clientId===c;return(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{className:i?f.PlayerNameLocal:f.PlayerName,children:n?.name||(n?`...`:``)}),(0,p.jsx)(`td`,{className:i?f.PlayerScoreLocal:f.PlayerScore,children:n==null?``:n.score}),(0,p.jsx)(`td`,{className:a?f.PlayerNameLocal:f.PlayerName,children:r?.name||(r?`...`:``)}),(0,p.jsx)(`td`,{className:a?f.PlayerScoreLocal:f.PlayerScore,children:r==null?``:r.score})]},`${n?.clientId??``}-${r?.clientId??``}`)})}),D.length>0&&(()=>{let e=Math.ceil(D.length/2),t=Math.ceil(D.length/2);return(0,p.jsxs)(`tbody`,{className:f.ObserverBody,children:[(0,p.jsxs)(`tr`,{className:f.ColumnHeaderRow,children:[(0,p.jsxs)(`th`,{colSpan:2,className:f.ColumnHeader,children:[`Observers (`,D.length,`)`]}),(0,p.jsx)(`th`,{colSpan:2,className:f.ColumnHeader,children:`\xA0`})]}),Array.from({length:t},(t,n)=>{let r=D[n],i=D[n+e],a=c!=null&&r?.clientId===c,o=c!=null&&i?.clientId===c;return(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{className:a?f.PlayerNameLocal:f.PlayerName,children:r?.name||(r?`...`:``)}),(0,p.jsx)(`td`,{className:a?f.PlayerScoreLocal:f.PlayerScore,children:r==null?``:r.score}),(0,p.jsx)(`td`,{className:o?f.PlayerNameLocal:f.PlayerName,children:i?.name||``}),(0,p.jsx)(`td`,{className:o?f.PlayerScoreLocal:f.PlayerScore,children:i==null?``:i.score})]},`${r?.clientId??``}-${i?.clientId??``}`)})]})})()]})}):(0,p.jsx)(`div`,{className:f.Empty,children:m?.length?`No team data available`:`Waiting for player data…`}),t[32]=c,t[33]=A,t[34]=V,t[35]=D,t[36]=m?.length,t[37]=j,t[38]=R,t[39]=P,t[40]=M,t[41]=B,t[42]=I,t[43]=J):J=t[43];let Y;t[44]===n?Y=t[45]:(Y=(0,p.jsx)(`button`,{className:f.CloseButton,onClick:n,children:`Close`}),t[44]=n,t[45]=Y);let X;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,p.jsx)(`span`,{className:f.Hint,children:`Esc to close`}),t[46]=X):X=t[46];let Z;t[47]===Y?Z=t[48]:(Z=(0,p.jsxs)(`div`,{className:f.Footer,children:[Y,X]}),t[47]=Y,t[48]=Z);let Q;t[49]!==q||t[50]!==J||t[51]!==Z?(Q=(0,p.jsxs)(`div`,{ref:r,className:f.Dialog,onClick:ee,role:`dialog`,"aria-modal":`true`,"aria-label":`Score Screen`,tabIndex:-1,children:[q,J,Z]}),t[49]=q,t[50]=J,t[51]=Z,t[52]=Q):Q=t[52];let $;return t[53]!==n||t[54]!==Q?($=(0,p.jsx)(`div`,{className:f.Overlay,onClick:n,children:Q}),t[53]=n,t[54]=Q,t[55]=$):$=t[55],$}function ee(e){return e.stopPropagation()}function te(e,t){return e.teamId-t.teamId}function ne(e,t){return(e.name??``).localeCompare(t.name??``)}function re(e,t){return t.score-e.score||(e.name??``).localeCompare(t.name??``)}function ie(){c.getState().sendCommand(`getScores`)}function ae(e){e.stopImmediatePropagation()}function oe(e,t){return e.connectedClientId===t.connectedClientId&&e.teamScores===t.teamScores&&e.playerRoster===t.playerRoster&&e.matchClockMs===t.matchClockMs}function se(e){let t=e.playback.streamSnapshot;return{connectedClientId:t?.connectedClientId,teamScores:t?.teamScores,playerRoster:t?.playerRoster,matchClockMs:t?.matchClockMs}}export{y as ScoreScreen};