mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-03-19 20:31:13 +00:00
1 line
No EOL
6.9 KiB
JavaScript
1 line
No EOL
6.9 KiB
JavaScript
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{a as i}from"./SettingsProvider-DlQTXm3x.js";import"./logger-DePRU8Hm.js";import"./traditional-DPdbI9gv.js";import"./mission-CWASMBNZ.js";import{Z as a}from"./index-C2tCa94d.js";var ee=t(),o=e(n(),1),s={Dialog:`_Dialog_tsmc0_1 _Dialog_6c89x_1`,Overlay:`_Overlay_tsmc0_10 _Overlay_6c89x_20`,Header:`_Header_tsmc0_14`,Title:`_Title_tsmc0_22`,HiddenRadio:`_HiddenRadio_tsmc0_31`,RefreshButton:`_RefreshButton_tsmc0_41 _DialogButton_6c89x_31`,ServerCount:`_ServerCount_tsmc0_47`,TableWrapper:`_TableWrapper_tsmc0_52`,Table:`_Table_tsmc0_52`,EmptyServer:`_EmptyServer_tsmc0_104`,Empty:`_Empty_tsmc0_104`,PasswordIcon:`_PasswordIcon_tsmc0_121`,Footer:`_Footer_tsmc0_134`,JoinButton:`_JoinButton_tsmc0_145 _DialogButton_6c89x_31`,CloseButton:`_CloseButton_tsmc0_150 _Secondary_6c89x_70 _DialogButton_6c89x_31`,WarriorField:`_WarriorField_tsmc0_154`,WarriorLabel:`_WarriorLabel_tsmc0_160`,WarriorInput:`_WarriorInput_tsmc0_166`,Hint:`_Hint_tsmc0_186`,Actions:`_Actions_tsmc0_192 _Actions_6c89x_84`},c=r();function l(e){let t=(0,ee.c)(90),{onClose:n}=e,r=a(se),l=a(oe),u=a(ae),d=a(ie),f=a(re),{warriorName:p,setWarriorName:ce}=i(),[m,h]=(0,o.useState)(null),g;t[0]!==f||t[1]!==n||t[2]!==m||t[3]!==p?(g=()=>{m&&(f(m,p),n())},t[0]=f,t[1]=n,t[2]=m,t[3]=p,t[4]=g):g=t[4];let _=g,v;t[5]!==f||t[6]!==n||t[7]!==p?(v=e=>{f(e,p),n()},t[5]=f,t[6]=n,t[7]=p,t[8]=v):v=t[8];let y=v,[b,le]=(0,o.useState)(`ping`),[x,ue]=(0,o.useState)(`asc`),de=(0,o.useRef)(null),S,C;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{de.current?.focus();try{document.exitPointerLock()}catch{}},C=[],t[9]=S,t[10]=C):(S=t[9],C=t[10]),(0,o.useEffect)(S,C);let w,T;t[11]===d?(w=t[12],T=t[13]):(w=()=>{d()},T=[d],t[11]=d,t[12]=w,t[13]=T),(0,o.useEffect)(w,T);let E,D;t[14]===n?(E=t[15],D=t[16]):(E=()=>{let e=e=>{e.stopPropagation(),e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},D=[n],t[14]=n,t[15]=E,t[16]=D),(0,o.useEffect)(E,D);let O;t[17]===b?O=t[18]:(O=e=>{b===e?ue(ne):(le(e),ue(`desc`))},t[17]=b,t[18]=O);let k=O,A;if(t[19]!==r||t[20]!==x||t[21]!==b){let e;t[23]!==x||t[24]!==b?(e=(e,t)=>{let n=e[b],r=t[b],i=typeof n==`number`&&typeof r==`number`?n-r:String(n).localeCompare(String(r));return x===`asc`?i:-i},t[23]=x,t[24]=b,t[25]=e):e=t[25],A=[...r].sort(e),t[19]=r,t[20]=x,t[21]=b,t[22]=A}else A=t[22];let j=A,M;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,c.jsx)(`h2`,{className:s.Title,children:`Server Browser`}),t[26]=M):M=t[26];let N=r.length===1?``:`s`,P;t[27]!==r.length||t[28]!==N?(P=(0,c.jsxs)(`span`,{className:s.ServerCount,children:[r.length,` server`,N]}),t[27]=r.length,t[28]=N,t[29]=P):P=t[29];let F;t[30]!==d||t[31]!==l?(F=(0,c.jsx)(`button`,{className:s.RefreshButton,onClick:d,disabled:l,children:`Refresh`}),t[30]=d,t[31]=l,t[32]=F):F=t[32];let I;t[33]!==P||t[34]!==F?(I=(0,c.jsxs)(`div`,{className:s.Header,children:[M,P,F]}),t[33]=P,t[34]=F,t[35]=I):I=t[35];let L;t[36]===k?L=t[37]:(L=(0,c.jsx)(`thead`,{children:(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`th`,{onClick:()=>k(`name`),children:`Server Name`}),(0,c.jsx)(`th`,{onClick:()=>k(`playerCount`),children:`Players`}),(0,c.jsx)(`th`,{onClick:()=>k(`ping`),children:`Ping`}),(0,c.jsx)(`th`,{onClick:()=>k(`mapName`),children:`Map`}),(0,c.jsx)(`th`,{onClick:()=>k(`gameType`),children:`Type`}),(0,c.jsx)(`th`,{onClick:()=>k(`mod`),children:`Mod`})]})}),t[36]=k,t[37]=L);let R;if(t[38]!==u||t[39]!==y||t[40]!==n||t[41]!==m||t[42]!==j){let e;t[44]!==u||t[45]!==y||t[46]!==n||t[47]!==m?(e=e=>(0,c.jsxs)(`tr`,{onClick:()=>{h(e.address);let t=document.forms.serverList.elements.serverAddress;Array.from(t).find(t=>t.value===e.address).focus()},onDoubleClick:()=>{h(e.address),y(e.address),n()},children:[(0,c.jsxs)(`td`,{children:[(0,c.jsx)(`input`,{type:`radio`,className:s.HiddenRadio,name:`serverAddress`,value:e.address,checked:m===e.address,onChange:e=>{h(e.target.value)}}),e.passwordRequired&&(0,c.jsx)(`span`,{className:s.PasswordIcon,children:`🔒`}),e.name]}),(0,c.jsxs)(`td`,{className:e.playerCount===0?s.EmptyServer:void 0,children:[e.playerCount,` / `,e.maxPlayers]}),(0,c.jsx)(`td`,{children:u==null?`—`:(e.ping+u).toLocaleString()}),(0,c.jsx)(`td`,{children:e.mapName}),(0,c.jsx)(`td`,{children:e.gameType}),(0,c.jsx)(`td`,{children:e.mod})]},e.address),t[44]=u,t[45]=y,t[46]=n,t[47]=m,t[48]=e):e=t[48],R=j.map(e),t[38]=u,t[39]=y,t[40]=n,t[41]=m,t[42]=j,t[43]=R}else R=t[43];let z;t[49]!==l||t[50]!==j.length?(z=j.length===0&&!l&&(0,c.jsx)(`tr`,{className:s.Empty,children:(0,c.jsx)(`td`,{colSpan:6,children:`No servers found`})}),t[49]=l,t[50]=j.length,t[51]=z):z=t[51];let B;t[52]!==l||t[53]!==j.length?(B=l&&j.length===0&&(0,c.jsx)(`tr`,{className:s.Empty,children:(0,c.jsx)(`td`,{colSpan:6,children:`Querying master server…`})}),t[52]=l,t[53]=j.length,t[54]=B):B=t[54];let V;t[55]!==R||t[56]!==z||t[57]!==B?(V=(0,c.jsxs)(`tbody`,{children:[R,z,B]}),t[55]=R,t[56]=z,t[57]=B,t[58]=V):V=t[58];let H;t[59]!==L||t[60]!==V?(H=(0,c.jsxs)(`table`,{className:s.Table,children:[L,V]}),t[59]=L,t[60]=V,t[61]=H):H=t[61];let U;t[62]!==_||t[63]!==H?(U=(0,c.jsx)(`div`,{className:s.TableWrapper,children:(0,c.jsx)(`form`,{name:`serverList`,onSubmit:_,children:H})}),t[62]=_,t[63]=H,t[64]=U):U=t[64];let W;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,c.jsx)(`label`,{className:s.WarriorLabel,htmlFor:`warriorName`,children:`Warrior`}),t[65]=W):W=t[65];let G;t[66]===ce?G=t[67]:(G=e=>ce(e.target.value),t[66]=ce,t[67]=G);let K;t[68]!==G||t[69]!==p?(K=(0,c.jsxs)(`div`,{className:s.WarriorField,children:[W,(0,c.jsx)(`input`,{id:`warriorName`,className:s.WarriorInput,type:`text`,value:p,onChange:G,placeholder:`Name thyself…`,maxLength:24})]}),t[68]=G,t[69]=p,t[70]=K):K=t[70];let q;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,c.jsx)(`span`,{className:s.Hint,children:`Double-click a server to join`}),t[71]=q):q=t[71];let J;t[72]===n?J=t[73]:(J=(0,c.jsx)(`button`,{onClick:n,className:s.CloseButton,children:`Cancel`}),t[72]=n,t[73]=J);let fe=!m,Y;t[74]!==_||t[75]!==fe?(Y=(0,c.jsx)(`button`,{onClick:_,disabled:fe,className:s.JoinButton,children:`Join`}),t[74]=_,t[75]=fe,t[76]=Y):Y=t[76];let X;t[77]!==J||t[78]!==Y?(X=(0,c.jsxs)(`div`,{className:s.Actions,children:[J,Y]}),t[77]=J,t[78]=Y,t[79]=X):X=t[79];let Z;t[80]!==K||t[81]!==X?(Z=(0,c.jsxs)(`div`,{className:s.Footer,children:[K,q,X]}),t[80]=K,t[81]=X,t[82]=Z):Z=t[82];let Q;t[83]!==I||t[84]!==U||t[85]!==Z?(Q=(0,c.jsxs)(`div`,{className:s.Dialog,ref:de,tabIndex:-1,onClick:te,children:[I,U,Z]}),t[83]=I,t[84]=U,t[85]=Z,t[86]=Q):Q=t[86];let $;return t[87]!==n||t[88]!==Q?($=(0,c.jsx)(`div`,{className:s.Overlay,onClick:n,children:Q}),t[87]=n,t[88]=Q,t[89]=$):$=t[89],$}function te(e){return e.stopPropagation()}function ne(e){return e===`asc`?`desc`:`asc`}function re(e){return e.joinServer}function ie(e){return e.listServers}function ae(e){return e.browserToRelayPing}function oe(e){return e.serversLoading}function se(e){return e.servers}export{l as ServerBrowser}; |