mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-05-19 20:26:48 +00:00
1 line
No EOL
7.4 KiB
JavaScript
1 line
No EOL
7.4 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 ee}from"./SettingsProvider-BdqQ2Cm4.js";import{A as i,y as te}from"./index-BZ0wFa-D.js";var a=e(n(),1),ne=t(),o={Dialog:`_Dialog_1s844_1 _Dialog_1t9wa_1`,Overlay:`_Overlay_1s844_10 _Overlay_1t9wa_22`,Header:`_Header_1s844_14`,Title:`_Title_1s844_22`,HiddenRadio:`_HiddenRadio_1s844_31`,RefreshButton:`_RefreshButton_1s844_41 _DialogButton_1t9wa_33`,ServerCount:`_ServerCount_1s844_47`,TableWrapper:`_TableWrapper_1s844_52`,Table:`_Table_1s844_52`,CompactHidden:`_CompactHidden_1s844_118`,EmptyServer:`_EmptyServer_1s844_169`,Empty:`_Empty_1s844_169`,PasswordIcon:`_PasswordIcon_1s844_186`,PlayersIcon:`_PlayersIcon_1s844_198`,Footer:`_Footer_1s844_209`,JoinButton:`_JoinButton_1s844_220 _DialogButton_1t9wa_33`,CloseButton:`_CloseButton_1s844_225 _Secondary_1t9wa_72 _DialogButton_1t9wa_33`,WarriorField:`_WarriorField_1s844_229`,WarriorLabel:`_WarriorLabel_1s844_235`,WarriorInput:`_WarriorInput_1s844_241`,Hint:`_Hint_1s844_261`,Actions:`_Actions_1s844_267 _Actions_1t9wa_86`},s=r();function c(e){let t=(0,ne.c)(102),{onClose:n}=e,r=i(le),c=i(ce),l=i(se),u=i(oe),d=i(ae),{warriorName:f,setWarriorName:ue}=ee(),[p,de]=(0,a.useState)(null),m;t[0]!==d||t[1]!==n||t[2]!==p||t[3]!==f?(m=()=>{p&&(d(p,f),n())},t[0]=d,t[1]=n,t[2]=p,t[3]=f,t[4]=m):m=t[4];let h=m,g;t[5]!==d||t[6]!==n||t[7]!==f?(g=e=>{d(e,f),n()},t[5]=d,t[6]=n,t[7]=f,t[8]=g):g=t[8];let _=g,[v,fe]=(0,a.useState)(`ping`),[y,pe]=(0,a.useState)(`asc`),me=(0,a.useRef)(null),b,x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{me.current?.focus();try{document.exitPointerLock()}catch{}},x=[],t[9]=b,t[10]=x):(b=t[9],x=t[10]),(0,a.useEffect)(b,x);let S,C;t[11]===u?(S=t[12],C=t[13]):(S=()=>{u()},C=[u],t[11]=u,t[12]=S,t[13]=C),(0,a.useEffect)(S,C);let w,he;t[14]===n?(w=t[15],he=t[16]):(w=()=>{let e=e=>{e.stopPropagation(),e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},he=[n],t[14]=n,t[15]=w,t[16]=he),(0,a.useEffect)(w,he);let T;t[17]===v?T=t[18]:(T=e=>{v===e?pe(ie):(fe(e),pe(`desc`))},t[17]=v,t[18]=T);let E=T,D;if(t[19]!==r||t[20]!==y||t[21]!==v){let e;t[23]!==y||t[24]!==v?(e=(e,t)=>{let n=e[v],r=t[v],ee=typeof n==`number`&&typeof r==`number`?n-r:String(n).localeCompare(String(r));return y===`asc`?ee:-ee},t[23]=y,t[24]=v,t[25]=e):e=t[25],D=[...r].sort(e),t[19]=r,t[20]=y,t[21]=v,t[22]=D}else D=t[22];let ge=D,O;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,s.jsx)(`h2`,{className:o.Title,children:`Server Browser`}),t[26]=O):O=t[26];let _e=r.length===1?``:`s`,k;t[27]!==r.length||t[28]!==_e?(k=(0,s.jsxs)(`span`,{className:o.ServerCount,children:[r.length,` server`,_e]}),t[27]=r.length,t[28]=_e,t[29]=k):k=t[29];let A;t[30]!==u||t[31]!==c?(A=(0,s.jsx)(`button`,{className:o.RefreshButton,onClick:u,disabled:c,children:`Refresh`}),t[30]=u,t[31]=c,t[32]=A):A=t[32];let j;t[33]!==k||t[34]!==A?(j=(0,s.jsxs)(`div`,{className:o.Header,children:[O,k,A]}),t[33]=k,t[34]=A,t[35]=j):j=t[35];let M;t[36]===E?M=t[37]:(M=(0,s.jsx)(`th`,{"data-column":`server`,onClick:()=>E(`name`),children:`Server Name`}),t[36]=E,t[37]=M);let N;t[38]===E?N=t[39]:(N=()=>E(`playerCount`),t[38]=E,t[39]=N);let P;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,s.jsx)(te,{className:o.PlayersIcon,title:`Players`,"aria-label":`Players`}),t[40]=P):P=t[40];let F;t[41]===N?F=t[42]:(F=(0,s.jsx)(`th`,{"data-column":`players`,onClick:N,children:P}),t[41]=N,t[42]=F);let I;t[43]===E?I=t[44]:(I=(0,s.jsx)(`th`,{"data-column":`ping`,onClick:()=>E(`ping`),children:`Ping`}),t[43]=E,t[44]=I);let L;t[45]===E?L=t[46]:(L=(0,s.jsx)(`th`,{"data-column":`map`,onClick:()=>E(`mapName`),children:`Map`}),t[45]=E,t[46]=L);let R;t[47]===E?R=t[48]:(R=(0,s.jsx)(`th`,{"data-column":`gameType`,onClick:()=>E(`gameType`),children:`Type`}),t[47]=E,t[48]=R);let z;t[49]===E?z=t[50]:(z=(0,s.jsx)(`th`,{"data-column":`mod`,onClick:()=>E(`mod`),children:`Mod`}),t[49]=E,t[50]=z);let B;t[51]!==M||t[52]!==F||t[53]!==I||t[54]!==L||t[55]!==R||t[56]!==z?(B=(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{children:[M,F,I,L,R,z]})}),t[51]=M,t[52]=F,t[53]=I,t[54]=L,t[55]=R,t[56]=z,t[57]=B):B=t[57];let V;if(t[58]!==l||t[59]!==_||t[60]!==n||t[61]!==p||t[62]!==ge){let e;t[64]!==l||t[65]!==_||t[66]!==n||t[67]!==p?(e=e=>(0,s.jsxs)(`tr`,{onClick:()=>{de(e.address);let t=document.forms.namedItem(`serverList`).elements.namedItem(`serverAddress`);Array.from(t).find(t=>t.value===e.address).focus()},onDoubleClick:()=>{de(e.address),_(e.address),n()},children:[(0,s.jsxs)(`td`,{"data-column":`server`,children:[(0,s.jsx)(`input`,{type:`radio`,className:o.HiddenRadio,name:`serverAddress`,value:e.address,checked:p===e.address,onChange:e=>{de(e.target.value)}}),e.passwordRequired&&(0,s.jsx)(`span`,{className:o.PasswordIcon,children:`🔒`}),e.name]}),(0,s.jsxs)(`td`,{className:e.playerCount===0?o.EmptyServer:void 0,"data-column":`players`,children:[e.playerCount,(0,s.jsxs)(`span`,{className:o.CompactHidden,children:[` / `,e.maxPlayers]})]}),(0,s.jsx)(`td`,{"data-column":`ping`,children:l==null?`—`:(e.ping+l).toLocaleString()}),(0,s.jsx)(`td`,{"data-column":`map`,children:e.mapName}),(0,s.jsx)(`td`,{"data-column":`gameType`,children:e.gameType}),(0,s.jsx)(`td`,{"data-column":`mod`,children:e.mod})]},e.address),t[64]=l,t[65]=_,t[66]=n,t[67]=p,t[68]=e):e=t[68],V=ge.map(e),t[58]=l,t[59]=_,t[60]=n,t[61]=p,t[62]=ge,t[63]=V}else V=t[63];let H;t[69]===V?H=t[70]:(H=(0,s.jsx)(`tbody`,{children:V}),t[69]=V,t[70]=H);let U;t[71]!==B||t[72]!==H?(U=(0,s.jsxs)(`table`,{className:o.Table,children:[B,H]}),t[71]=B,t[72]=H,t[73]=U):U=t[73];let W;t[74]!==h||t[75]!==U?(W=(0,s.jsx)(`div`,{className:o.TableWrapper,children:(0,s.jsx)(`form`,{name:`serverList`,onSubmit:h,children:U})}),t[74]=h,t[75]=U,t[76]=W):W=t[76];let G;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,s.jsx)(`label`,{className:o.WarriorLabel,htmlFor:`warriorName`,children:`Warrior`}),t[77]=G):G=t[77];let K;t[78]===ue?K=t[79]:(K=e=>ue(e.target.value),t[78]=ue,t[79]=K);let q;t[80]!==K||t[81]!==f?(q=(0,s.jsxs)(`div`,{className:o.WarriorField,children:[G,(0,s.jsx)(`input`,{id:`warriorName`,className:o.WarriorInput,type:`text`,value:f,onChange:K,placeholder:`Name thyself…`,maxLength:24})]}),t[80]=K,t[81]=f,t[82]=q):q=t[82];let J;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,s.jsx)(`span`,{className:o.Hint,children:`Double-click a server to join`}),t[83]=J):J=t[83];let Y;t[84]===n?Y=t[85]:(Y=(0,s.jsx)(`button`,{onClick:n,className:o.CloseButton,children:`Cancel`}),t[84]=n,t[85]=Y);let ve=!p,X;t[86]!==h||t[87]!==ve?(X=(0,s.jsx)(`button`,{onClick:h,disabled:ve,className:o.JoinButton,children:`Join`}),t[86]=h,t[87]=ve,t[88]=X):X=t[88];let Z;t[89]!==Y||t[90]!==X?(Z=(0,s.jsxs)(`div`,{className:o.Actions,children:[Y,X]}),t[89]=Y,t[90]=X,t[91]=Z):Z=t[91];let Q;t[92]!==q||t[93]!==Z?(Q=(0,s.jsxs)(`div`,{className:o.Footer,children:[q,J,Z]}),t[92]=q,t[93]=Z,t[94]=Q):Q=t[94];let $;t[95]!==j||t[96]!==W||t[97]!==Q?($=(0,s.jsxs)(`div`,{className:o.Dialog,ref:me,tabIndex:-1,onClick:re,children:[j,W,Q]}),t[95]=j,t[96]=W,t[97]=Q,t[98]=$):$=t[98];let ye;return t[99]!==n||t[100]!==$?(ye=(0,s.jsx)(`div`,{className:o.Overlay,onClick:n,children:$}),t[99]=n,t[100]=$,t[101]=ye):ye=t[101],ye}function re(e){return e.stopPropagation()}function ie(e){return e===`asc`?`desc`:`asc`}function ae(e){return e.joinServer}function oe(e){return e.listServers}function se(e){return e.browserToRelayPing}function ce(e){return e.serversLoading}function le(e){return e.servers}export{c as ServerBrowser}; |