screeps-client 0.14.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embedded/_client/{CodePanel-BCT5gOp2.js → CodePanel-DbI1p64i.js} +1 -1
- package/dist/embedded/_client/{MapRenderer-BhdM60pB.js → MapRenderer-JGmiJiMQ.js} +1 -1
- package/dist/{standalone/_client/MapViewer-ohczy5X5.js → embedded/_client/MapViewer-DRGfQymU.js} +1 -1
- package/dist/embedded/_client/{clientStore-D9C-lzp_.js → clientStore-BkKTI1yP.js} +2 -2
- package/dist/embedded/_client/index-B3kr31NT.js +18 -0
- package/dist/embedded/_client/src-DOHtCEgE.js +2 -0
- package/dist/embedded/_client/src-DOI24OGW.js +1 -0
- package/dist/embedded/index.html +4 -4
- package/dist/standalone/_client/{CodePanel-CbZ9oLxx.js → CodePanel-DmnU5spM.js} +1 -1
- package/dist/standalone/_client/{MapRenderer-ocYYDw6I.js → MapRenderer-EC8M_9DU.js} +1 -1
- package/dist/{xxscreeps-mod/_client/MapViewer-tK26tzGo.js → standalone/_client/MapViewer-DXqmf6AB.js} +1 -1
- package/dist/standalone/_client/{clientStore-Bzb-4S7X.js → clientStore-B8tjUCpm.js} +2 -2
- package/dist/standalone/_client/index-CbY5bX2L.js +18 -0
- package/dist/standalone/_client/src-0EojLW1k.js +2 -0
- package/dist/standalone/_client/src-DXDMxHMV.js +1 -0
- package/dist/standalone/index.html +4 -4
- package/dist/xxscreeps-mod/_client/{CodePanel-kFIhDB_i.js → CodePanel-CtpGv5wF.js} +1 -1
- package/dist/xxscreeps-mod/_client/{MapRenderer-C1QOWyVr.js → MapRenderer-d2GiP4ov.js} +1 -1
- package/dist/{embedded/_client/MapViewer-CDbIVsBg.js → xxscreeps-mod/_client/MapViewer-DpPG4DTa.js} +1 -1
- package/dist/xxscreeps-mod/_client/{clientStore-DjZCrEbe.js → clientStore-hqyQVxvz.js} +2 -2
- package/dist/xxscreeps-mod/_client/index-DSEcfL6s.js +18 -0
- package/dist/xxscreeps-mod/_client/src-B8KQoKM5.js +2 -0
- package/dist/xxscreeps-mod/_client/src-DrX6yMZJ.js +1 -0
- package/dist/xxscreeps-mod/index.html +4 -4
- package/package.json +1 -1
- package/dist/embedded/_client/index-5jkGDIrC.js +0 -18
- package/dist/embedded/_client/src-DAkicyZU.js +0 -1
- package/dist/embedded/_client/src-cTbBCJWr.js +0 -2
- package/dist/standalone/_client/index-D_Z0lV3_.js +0 -18
- package/dist/standalone/_client/src-CjsOFhYA.js +0 -1
- package/dist/standalone/_client/src-mXm3a7Ed.js +0 -2
- package/dist/xxscreeps-mod/_client/index-ViUlM-YN.js +0 -18
- package/dist/xxscreeps-mod/_client/src-BxX_JHtm.js +0 -2
- package/dist/xxscreeps-mod/_client/src-lTglq1gg.js +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_client/CodePanel-DbI1p64i.js","_client/vendor-codemirror-B6f_i0wP.js","_client/clientStore-BkKTI1yP.js","_client/vendor-pixi-QLQyXP3g.js","_client/rolldown-runtime-Bh1tDfsg.js","_client/core-BpboMUoB.js","_client/src-DOHtCEgE.js","_client/decompress-CWkNrR0q.js","_client/MapViewer-DRGfQymU.js","_client/MapRenderer-JGmiJiMQ.js","_client/init-BkMwFmiF.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{A as e,C as t,D as n,E as r,O as i,S as a,T as o,_ as s,b as c,c as l,d as u,f as d,g as f,h as p,j as m,l as h,m as g,p as _,u as v,v as y,w as b,x,y as S}from"./vendor-codemirror-B6f_i0wP.js";import{$ as C,A as w,B as T,C as E,D,E as O,F as k,G as A,H as j,I as ee,J as M,K as te,L as ne,M as re,N as ie,O as ae,P as oe,Q as N,R as P,S as F,T as se,U as ce,V as le,W as ue,X as de,Y as fe,Z as I,_ as pe,a as me,at as L,b as he,c as ge,d as _e,et as R,f as ve,h as ye,i as be,it as xe,j as Se,k as Ce,l as we,m as Te,n as z,nt as B,o as Ee,ot as V,p as De,q as Oe,r as ke,rt as H,s as Ae,st as je,t as Me,tt as Ne,u as Pe,v as Fe,w as Ie,x as U,y as Le,z as Re}from"./clientStore-BkKTI1yP.js";import{_ as ze,a as Be,b as Ve,c as He,d as Ue,f as We,g as Ge,h as Ke,l as W,m as qe,o as Je,p as Ye,u as Xe,v as Ze,x as Qe,y as $e}from"./vendor-pixi-QLQyXP3g.js";import{a as et,c as tt,d as nt,g as rt,h as it,i as at,k as ot,l as st,m as ct,n as lt,o as ut,p as dt,s as ft,t as pt,u as mt}from"./src-DOHtCEgE.js";import{$ as ht,A as gt,At as _t,B as vt,C as yt,Ct as bt,D as xt,Dt as St,E as Ct,Et as wt,F as Tt,Ft as Et,G as Dt,H as Ot,I as kt,It as At,J as jt,K as Mt,L as Nt,M as Pt,Mt as Ft,N as It,Nt as Lt,O as Rt,Ot as zt,P as Bt,Pt as Vt,Q as Ht,R as Ut,Rt as Wt,S as Gt,St as Kt,T as qt,Tt as G,U as Jt,V as Yt,W as Xt,X as Zt,Y as Qt,Z as $t,_ as en,_t as tn,a as nn,at as rn,b as an,c as on,ct as sn,d as cn,dt as ln,et as un,f as dn,ft as fn,g as pn,gt as mn,h as hn,ht as gn,i as _n,it as vn,j as yn,jt as bn,k as xn,kt as Sn,l as Cn,lt as wn,m as Tn,mt as En,n as Dn,nt as On,o as kn,ot as An,p as jn,pt as Mn,q as Nn,r as Pn,rt as Fn,s as In,st as Ln,tt as Rn,u as zn,ut as Bn,vt as Vn,w as Hn,wt as Un,x as Wn,xt as Gn,z as Kn}from"./MapRenderer-JGmiJiMQ.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var qn={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},Jn=V(`<svg>`),Yn=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Xn=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Zn=e=>{let t=Xn(e);return t.charAt(0).toUpperCase()+t.slice(1)},Qn=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),K=t=>{let[n,r]=e(t,[`color`,`size`,`strokeWidth`,`children`,`class`,`name`,`iconNode`,`absoluteStrokeWidth`]);return(()=>{var e=Jn();return xe(e,o(qn,{get width(){return n.size??qn.width},get height(){return n.size??qn.height},get stroke(){return n.color??qn.stroke},get"stroke-width"(){return R(()=>!!n.absoluteStrokeWidth)()?Number(n.strokeWidth??qn[`stroke-width`])*24/Number(n.size):Number(n.strokeWidth??qn[`stroke-width`])},get class(){return Qn(`lucide`,`lucide-icon`,...n.name==null?[]:[`lucide-${Yn(Zn(n.name))}`,`lucide-${Yn(n.name)}`],n.class==null?``:n.class)}},r),!0,!0),C(e,f(u,{get each(){return n.iconNode},children:([e,t])=>f(de,o({component:e},t))})),e})()},$n=[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]],er=e=>f(K,o(e,{iconNode:$n,name:`arrow-left-right`})),tr=[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`path`,{d:`M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z`,key:`1l2ple`}],[`path`,{d:`M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z`,key:`1wam0m`}]],nr=e=>f(K,o(e,{iconNode:tr,name:`atom`})),rr=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.9 4.9 14.2 14.2`,key:`1m5liu`}]],ir=e=>f(K,o(e,{iconNode:rr,name:`ban`})),ar=[[`path`,{d:`m11 7-3 5h4l-3 5`,key:`b4a64w`}],[`path`,{d:`M14.856 6H16a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.935`,key:`lre1cr`}],[`path`,{d:`M22 14v-4`,key:`14q9d5`}],[`path`,{d:`M5.14 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2.936`,key:`13q5k0`}]],or=e=>f(K,o(e,{iconNode:ar,name:`battery-charging`})),sr=[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]],cr=e=>f(K,o(e,{iconNode:sr,name:`bell-off`})),lr=[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]],ur=e=>f(K,o(e,{iconNode:lr,name:`bell`})),dr=[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],fr=e=>f(K,o(e,{iconNode:dr,name:`chart-column`})),pr=[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]],mr=e=>f(K,o(e,{iconNode:pr,name:`check`})),hr=[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]],gr=e=>f(K,o(e,{iconNode:hr,name:`chevron-down`})),_r=[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]],vr=e=>f(K,o(e,{iconNode:_r,name:`chevron-right`})),yr=[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]],br=e=>f(K,o(e,{iconNode:yr,name:`chevron-left`})),xr=[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]],Sr=e=>f(K,o(e,{iconNode:xr,name:`chevrons-left`})),Cr=[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]],wr=e=>f(K,o(e,{iconNode:Cr,name:`chevrons-right`})),Tr=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]],Er=e=>f(K,o(e,{iconNode:Tr,name:`circle-slash`})),Dr=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]],Or=e=>f(K,o(e,{iconNode:Dr,name:`clock`})),kr=[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]],Ar=e=>f(K,o(e,{iconNode:kr,name:`code-xml`})),jr=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]],Mr=e=>f(K,o(e,{iconNode:jr,name:`crosshair`})),Nr=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]],Pr=e=>f(K,o(e,{iconNode:Nr,name:`database`})),Fr=[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]],Ir=e=>f(K,o(e,{iconNode:Fr,name:`external-link`})),Lr=[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]],Rr=e=>f(K,o(e,{iconNode:Lr,name:`eye`})),zr=[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M16 16h.01`,key:`1f9h7w`}],[`path`,{d:`M3 19a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a.5.5 0 0 0-.769-.422l-4.462 2.844A.5.5 0 0 1 15 10.5v-2a.5.5 0 0 0-.769-.422L9.77 10.922A.5.5 0 0 1 9 10.5V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z`,key:`1iv0i2`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]],Br=e=>f(K,o(e,{iconNode:zr,name:`factory`})),Vr=[[`path`,{d:`M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z`,key:`i9b6wo`}],[`line`,{x1:`4`,x2:`4`,y1:`22`,y2:`15`,key:`1cm3nv`}]],Hr=e=>f(K,o(e,{iconNode:Vr,name:`flag`})),Ur=[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]],Wr=e=>f(K,o(e,{iconNode:Ur,name:`flask-conical`})),Gr=[[`path`,{d:`M6 3h12l4 6-10 13L2 9Z`,key:`1pcd5k`}],[`path`,{d:`M11 3 8 9l4 13 4-13-3-6`,key:`1fcu3u`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]],Kr=e=>f(K,o(e,{iconNode:Gr,name:`gem`})),qr=[[`path`,{d:`m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9`,key:`eefl8a`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`b7pghm`}]],Jr=e=>f(K,o(e,{iconNode:qr,name:`hammer`})),Yr=[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]],Xr=e=>f(K,o(e,{iconNode:Yr,name:`key-round`})),Zr=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]],Qr=e=>f(K,o(e,{iconNode:Zr,name:`layout-dashboard`})),$r=[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]],ei=e=>f(K,o(e,{iconNode:$r,name:`loader`})),ti=[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]],ni=e=>f(K,o(e,{iconNode:ti,name:`lock`})),ri=[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]],ii=e=>f(K,o(e,{iconNode:ri,name:`log-in`})),ai=[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]],oi=e=>f(K,o(e,{iconNode:ai,name:`log-out`})),si=[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]],ci=e=>f(K,o(e,{iconNode:si,name:`mail`})),li=[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]],ui=e=>f(K,o(e,{iconNode:li,name:`map`})),di=[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]],fi=e=>f(K,o(e,{iconNode:di,name:`move`})),pi=[[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}],[`path`,{d:`m17 13 5 5m-5 0 5-5`,key:`im3w4b`}]],mi=e=>f(K,o(e,{iconNode:pi,name:`package-x`})),hi=[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]],gi=e=>f(K,o(e,{iconNode:hi,name:`pause`})),_i=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]],vi=e=>f(K,o(e,{iconNode:_i,name:`pencil`})),yi=[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]],bi=e=>f(K,o(e,{iconNode:yi,name:`play`})),xi=[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]],Si=e=>f(K,o(e,{iconNode:xi,name:`plus`})),Ci=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]],wi=e=>f(K,o(e,{iconNode:Ci,name:`refresh-cw`})),Ti=[[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z`,key:`m3kijz`}],[`path`,{d:`m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z`,key:`1fmvmk`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0`,key:`1f8sc4`}],[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}]],Ei=e=>f(K,o(e,{iconNode:Ti,name:`rocket`})),Di=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]],Oi=e=>f(K,o(e,{iconNode:Di,name:`rotate-ccw`})),ki=[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]],Ai=e=>f(K,o(e,{iconNode:ki,name:`send`})),ji=[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]],Mi=e=>f(K,o(e,{iconNode:ji,name:`settings`})),Ni=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]],Pi=e=>f(K,o(e,{iconNode:Ni,name:`shield-check`})),Fi=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]],Ii=e=>f(K,o(e,{iconNode:Fi,name:`shield`})),Li=[[`path`,{d:`m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7`,key:`ztvudi`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}],[`path`,{d:`M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4`,key:`2ebpfo`}],[`path`,{d:`M2 7h20`,key:`1fcdvo`}],[`path`,{d:`M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7`,key:`6c3vgh`}]],Ri=e=>f(K,o(e,{iconNode:Li,name:`store`})),zi=[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]],Bi=e=>f(K,o(e,{iconNode:zi,name:`sun`})),Vi=[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]],Hi=e=>f(K,o(e,{iconNode:Vi,name:`terminal`})),Ui=[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]],Wi=e=>f(K,o(e,{iconNode:Ui,name:`trash-2`})),Gi=[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]],Ki=e=>f(K,o(e,{iconNode:Gi,name:`trending-up`})),qi=[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]],Ji=e=>f(K,o(e,{iconNode:qi,name:`x`})),Yi=[[`path`,{d:`M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317`,key:`193nxd`}],[`path`,{d:`M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773`,key:`27a7lr`}],[`path`,{d:`M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643`,key:`1e0qe9`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]],Xi=e=>f(K,o(e,{iconNode:Yi,name:`zap-off`})),Zi=[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]],Qi=e=>f(K,o(e,{iconNode:Zi,name:`zap`}));function $i(e,t){let[r,i]=a(null),[o,s]=a(!1),[c,l]=a(null),u=async(e,n)=>{try{(await ft(e,n))?.username?t({url:e,token:n}):(l(null),i({url:e,token:n}))}catch{t({url:e,token:n})}};return{startLogin:t=>{let r=t.replace(/\/$/,``),i=window.open(`${r}/api/auth/${e}`,`screeps-oauth-${e}`,`width=800,height=600,left=200,top=100`),a=e=>{try{let t=JSON.parse(e.data);t.token&&(s(),u(r,t.token))}catch{}},o=setInterval(()=>{i?.closed&&s()},500),s=()=>{clearInterval(o),window.removeEventListener(`message`,a)};window.addEventListener(`message`,a),n(s)},pending:r,submitting:o,regError:c,completeRegistration:async(e,n)=>{let a=r();if(a){s(!0),l(null);try{let{token:r}=await ut(a.url,a.token,e,n);i(null),t({url:a.url,token:r})}catch(e){l(e instanceof Error?e.message:`Registration failed`)}finally{s(!1)}}},cancelRegistration:()=>{i(null),l(null)}}}function ea(e){let[t,r]=a(null),[i,o]=a(null),[c,l]=a(null);return s(()=>{let t=e();r(null),o(null),l(null);let i=!1,a=setTimeout(async()=>{try{let e=await st(t);if(i)return;if(r(e),l(null),nt(e)){let e=await tt(t);i||o(e)}}catch{i||(l(`Could not reach server`),r(null))}},400);n(()=>{i=!0,clearTimeout(a)})}),{serverVersion:t,authModInfo:i,serverError:c}}var ta=V(`<span style=font-size:11px;display:inline-flex;align-items:center;gap:3px>`),na=V(`<form style=display:flex;flex-direction:column;gap:16px><h2 style=margin:0;font-size:20px>Finish creating your account</h2><div style=font-size:13px;color:#8b949e>Signed in with <!> — choose a username to finish setting up your account.</div><label style=display:flex;flex-direction:column;gap:4px><div style=display:flex;align-items:baseline;gap:8px><span style=font-size:12px;color:#8b949e>Username</span></div><input type=text name=username autocomplete=username autofocus></label><label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Email <span style=color:#484f58>(optional)</span></span><input type=email name=email autocomplete=email></label><button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600></button><button type=button style="padding:8px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#8b949e;font-size:12px;cursor:pointer">Cancel`),ra=V(`<div style=color:#f85149;font-size:13px>`),ia={padding:`8px 12px`,"border-radius":`6px`,border:`1px solid #30363d`,background:`#0d1117`,color:`#c9d1d9`,width:`100%`,"box-sizing":`border-box`};function aa(e,t){let[r,i]=a(`idle`);return s(()=>{let r=t();if(!r){i(`idle`);return}i(`checking`);let a=!1,o=setTimeout(async()=>{try{let t=await et(e(),r);a||i(t.error?`taken`:`available`)}catch{a||i(`error`)}},500);n(()=>{a=!0,clearTimeout(o)})}),r}function oa(e){let t={idle:null,checking:{children:`Checking…`,color:`#8b949e`},available:{children:[f(mr,{size:12}),` Available`],color:`#3fb950`},taken:{children:[f(Ji,{size:12}),` Already taken`],color:`#f85149`},error:{children:`Could not verify`,color:`#d29922`}},n=()=>t[e.state];return f(_,{get when(){return n()},get children(){var e=ta();return C(e,()=>n().children),S(t=>H(e,`color`,n().color)),e}})}function sa(e){let[t,n]=a(``),[r,i]=a(``),o=aa(()=>e.url,t),s=()=>!e.submitting&&t()!==``&&o()!==`taken`&&o()!==`checking`,c=n=>{n.preventDefault(),s()&&e.onSubmit(t(),r()||void 0)};return(()=>{var a=na(),l=a.firstChild.nextSibling,u=l.firstChild.nextSibling;u.nextSibling;var d=l.nextSibling,p=d.firstChild;p.firstChild;var m=p.nextSibling,h=d.nextSibling,g=h.firstChild;g.firstChild.nextSibling;var _=g.nextSibling,v=h.nextSibling,y=v.nextSibling;return a.addEventListener(`submit`,c),C(l,()=>e.providerLabel,u),C(p,f(oa,{get state(){return o()}}),null),m.$$input=e=>n(e.currentTarget.value),_.$$input=e=>i(e.currentTarget.value),C(a,(()=>{var t=R(()=>!!e.error);return()=>t()&&(()=>{var t=ra();return C(t,()=>e.error),t})()})(),v),C(v,()=>e.submitting?`Creating account…`:`Continue`),y.$$click=()=>e.onCancel(),S(t=>{var n=ia,r=e.submitting,i=ia,a=e.submitting,o=!s(),c=s()?`pointer`:`not-allowed`,l=s()?1:.5;return t.e=L(m,n,t.e),r!==t.t&&(m.disabled=t.t=r),t.a=L(_,i,t.a),a!==t.o&&(_.disabled=t.o=a),o!==t.i&&(v.disabled=t.i=o),c!==t.n&&H(v,`cursor`,t.n=c),l!==t.s&&H(v,`opacity`,t.s=l),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),S(()=>m.value=t()),S(()=>_.value=r()),a})()}N([`input`,`click`]);var ca=V(`<span style=font-size:11px;display:inline-flex;align-items:center;gap:3px>`),la=V(`<div style="color:#3fb950;font-size:14px;text-align:center;padding:8px 0">Account created! Logging you in…`),ua=V(`<label style=display:flex;flex-direction:column;gap:4px><div style=display:flex;align-items:baseline;gap:8px><span style=font-size:12px;color:#8b949e>Username</span></div><input type=text name=username autocomplete=username>`),da=V(`<label style=display:flex;flex-direction:column;gap:4px><div style=display:flex;align-items:baseline;gap:8px><span style=font-size:12px;color:#8b949e>Email</span></div><input type=email name=email autocomplete=email>`),fa=V(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Password</span><input type=password name=new-password autocomplete=new-password>`),pa=V(`<span style=font-size:11px;color:#f85149>Passwords don't match`),ma=V(`<label style=display:flex;flex-direction:column;gap:4px><div style=display:flex;align-items:baseline;gap:8px><span style=font-size:12px;color:#8b949e>Confirm Password</span></div><input type=password name=confirm-password autocomplete=new-password>`),ha=V(`<button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),ga=V(`<button type=button style="padding:8px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#8b949e;font-size:12px;cursor:pointer">Back to Login`),_a=V(`<form style=display:flex;flex-direction:column;gap:16px><h2 style=margin:0;font-size:20px>Create Account`),va=V(`<div style=color:#f85149;font-size:13px>`),ya=V(`<div style="width:360px;padding:16px 20px;border-radius:8px;background:#161b22;border:1px solid #30363d;color:#c9d1d9;font-size:13px;line-height:1.6">`),ba=V(`<button type=button style=background:none;border:none;color:#58a6ff;font-size:12px;cursor:pointer;padding:0>Create account`),xa=V(`<div style=display:flex;gap:8px><button type=button style="flex:1;padding:8px;border-radius:6px;border:1px solid #30363d;color:#fff;cursor:pointer">Password</button><button type=button style="flex:1;padding:8px;border-radius:6px;border:1px solid #30363d;color:#fff;cursor:pointer">Token`),Sa=V(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Server URL</span><input type=url name=url autocomplete=url inputmode=url>`),Ca=V(`<div style=color:#8b949e;font-size:12px;margin-top:-8px>`),wa=V(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Server Password <span style=color:#484f58>(optional)</span></span><input type=password name=server-password autocomplete=off data-1p-ignore data-lpignore=true placeholder="Leave empty if not required">`),Ta=V(`<div style=display:flex;align-items:center;gap:8px;color:#484f58;font-size:12px><div style=flex:1;height:1px;background:#30363d></div>or<div style=flex:1;height:1px;background:#30363d>`),Ea=V(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#1b2838;color:#c7d5e0;font-weight:600>Login with Steam`),Da=V(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#5865F2;color:#fff;font-weight:600>Login with Discord`),Oa=V(`<button type=button style="padding:8px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#8b949e;font-size:12px">Connect as Guest (read-only)`),ka=V(`<form style=display:flex;flex-direction:column;gap:16px><div style=display:flex;align-items:baseline;justify-content:space-between><h2 style=margin:0;font-size:20px>Connect to Screeps</h2></div><button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),Aa=V(`<div style="width:360px;padding:12px 20px;border-radius:8px;background:#161b22;border:1px solid #30363d"><div style=font-size:11px;color:#484f58;margin-bottom:8px;text-transform:uppercase;letter-spacing:0.05em>Server Mods</div><div style=display:flex;flex-wrap:wrap;gap:6px>`),ja=V(`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;width:100%;height:100%;overflow:auto;padding:24px 0;box-sizing:border-box"><div style="display:flex;flex-direction:column;gap:16px;width:360px;padding:32px;border-radius:8px;background:#161b22;border:1px solid #30363d">`),Ma=V(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Email or Username</span><input type=text id=username name=username autocomplete=username>`),Na=V(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Password</span><input type=password id=password name=password autocomplete=current-password>`),Pa=V(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Auth Token</span><input type=password name=token autocomplete=off>`),Fa=V(`<span style="font-size:11px;padding:2px 8px;border-radius:12px;background:#21262d;border:1px solid #30363d;color:#8b949e;font-family:monospace">`),Ia={padding:`8px 12px`,"border-radius":`6px`,border:`1px solid #30363d`,background:`#0d1117`,color:`#c9d1d9`};function La(e,t,r){let[i,o]=a(`idle`);return s(()=>{let i=t();if(!i){o(`idle`);return}o(`checking`);let a=!1,s=setTimeout(async()=>{try{let t=await r(e(),i);a||o(t.error?`taken`:`available`)}catch{a||o(`error`)}},500);n(()=>{a=!0,clearTimeout(s)})}),i}function Ra(e){let t={idle:null,checking:{children:`Checking…`,color:`#8b949e`},available:{children:[f(mr,{size:12}),` Available`],color:`#3fb950`},taken:{children:[f(Ji,{size:12}),` Already taken`],color:`#f85149`},error:{children:`Could not verify`,color:`#d29922`}},n=()=>t[e.state];return f(_,{get when(){return n()},get children(){var e=ca();return C(e,()=>n().children),S(t=>H(e,`color`,n().color)),e}})}function za(e){let[t,n]=a(``),[r,i]=a(``),[o,s]=a(``),[c,l]=a(``),[u,d]=a(!1),[p,m]=a(null),[h,g]=a(!1),v=La(()=>e.url,t,et),y=La(()=>e.url,r,at),b=()=>c()!==``&&o()!==c(),x=()=>!u()&&t()!==``&&r()!==``&&o().length>=4&&o()===c()&&v()!==`taken`&&v()!==`checking`&&y()!==`taken`&&y()!==`checking`,w=async n=>{if(n.preventDefault(),x()){d(!0),m(null);try{let n=await it(e.url,t(),r(),o());if(n.error){m(n.error);return}g(!0),setTimeout(()=>e.onSuccess(r(),o()),1500)}catch(e){m(e instanceof Error?e.message:`Registration failed`)}finally{d(!1)}}};return(()=>{var a=_a();return a.firstChild,a.addEventListener(`submit`,w),C(a,f(_,{get when(){return h()},get children(){return la()}}),null),C(a,f(_,{get when(){return!h()},get children(){return[(()=>{var e=ua(),r=e.firstChild;r.firstChild;var i=r.nextSibling;return C(r,f(Ra,{get state(){return v()}}),null),i.$$input=e=>n(e.currentTarget.value),S(e=>{var t=Ia,n=u();return e.e=L(i,t,e.e),n!==e.t&&(i.disabled=e.t=n),e},{e:void 0,t:void 0}),S(()=>i.value=t()),e})(),(()=>{var e=da(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return C(t,f(Ra,{get state(){return y()}}),null),n.$$input=e=>i(e.currentTarget.value),S(e=>{var t=Ia,r=u();return e.e=L(n,t,e.e),r!==e.t&&(n.disabled=e.t=r),e},{e:void 0,t:void 0}),S(()=>n.value=r()),e})(),(()=>{var e=fa(),t=e.firstChild.nextSibling;return t.$$input=e=>s(e.currentTarget.value),S(e=>{var n=Ia,r=u();return e.e=L(t,n,e.e),r!==e.t&&(t.disabled=e.t=r),e},{e:void 0,t:void 0}),S(()=>t.value=o()),e})(),(()=>{var e=ma(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return C(t,f(_,{get when(){return b()},get children(){return pa()}}),null),n.$$input=e=>l(e.currentTarget.value),S(e=>{var t={...Ia,border:b()?`1px solid #f85149`:`1px solid #30363d`},r=u();return e.e=L(n,t,e.e),r!==e.t&&(n.disabled=e.t=r),e},{e:void 0,t:void 0}),S(()=>n.value=c()),e})(),R(()=>R(()=>!!p())()&&(()=>{var e=va();return C(e,p),e})()),(()=>{var e=ha();return C(e,()=>u()?`Creating account…`:`Create Account`),S(t=>{var n=!x(),r=x()?`pointer`:`not-allowed`,i=x()?1:.5;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&H(e,`cursor`,t.t=r),i!==t.a&&H(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})(),(()=>{var t=ga();return t.$$click=()=>e.onCancel(),t})()]}}),null),a})()}function Ba(){let e=ce(),t=ue(),[n,r]=a(`login`),[i,o]=a(`password`),[c,l]=a(e?j():window.location.origin),[d,p]=a(``),[m,h]=a(``),[g,v]=a(``),[y,b]=a(``),{serverVersion:x,authModInfo:w,serverError:T}=ea(c),E=()=>x()?.serverData?.welcomeText??null,D=()=>(x()?.serverData?.features??[]).filter(e=>e.name!==`auth`&&e.version!=null),O=()=>{let e=x();return e?dt(e):void 0},k=()=>{let e=O();if(e)return e.steamLogin;let t=x();return t?nt(t)?.authTypes?.includes(`steam`)??!0:!0},A=()=>{let e=x();return e?mt(e)?.discordLogin??!1:!1},ee=()=>{let e=O();return e?e.allowEmailRegistration:w()?.allowRegistration===!0||(x()?.serverData?.features??[]).some(e=>e.name===`official-like`)},M=()=>O()?.allowGuestAccess??!0,te=()=>{let e=x();return e?!ct(e):!0},ne=$i(`steam`,({url:e,token:t})=>{r(`login`),ke({url:e,auth:`token`,authMethod:`steam`,token:t,serverPassword:y()||void 0,storage:null})});s(()=>{ne.pending()&&r(`steam-username`)});let re=()=>ne.startLogin(c()),ie=$i(`discord`,({url:e,token:t})=>{r(`login`),ke({url:e,auth:`token`,authMethod:`discord`,token:t,serverPassword:y()||void 0,storage:null})});s(()=>{ie.pending()&&r(`discord-username`)});let ae=()=>ie.startLogin(c()),oe=async e=>{e.preventDefault(),await ke({url:c(),auth:i(),email:d()||void 0,password:m()||void 0,token:g()||void 0,serverPassword:y()||void 0,storage:null})},N=async e=>{e.preventDefault(),await ke({url:c(),auth:`guest`,serverPassword:y()||void 0,storage:null})},P=async(e,t)=>{try{await ke({url:c(),auth:`password`,email:e,password:t,serverPassword:y()||void 0,storage:null})}catch{r(`login`),o(`password`),p(e),h(t)}},F=()=>pe()===`connecting`;return(()=>{var a=ja(),s=a.firstChild;return C(a,f(_,{get when(){return E()},get children(){var e=ya();return S(()=>e.innerHTML=E()),e}}),s),C(s,f(_,{get when(){return n()===`register`},get children(){return f(za,{get url(){return c()},get serverPassword(){return y()},onSuccess:P,onCancel:()=>r(`login`)})}}),null),C(s,f(_,{get when(){return n()===`steam-username`},get children(){return f(sa,{get url(){return ne.pending().url},providerLabel:`Steam`,get submitting(){return ne.submitting()},get error(){return ne.regError()},onSubmit:(e,t)=>void ne.completeRegistration(e,t),onCancel:()=>{ne.cancelRegistration(),r(`login`)}})}}),null),C(s,f(_,{get when(){return n()===`discord-username`},get children(){return f(sa,{get url(){return ie.pending().url},providerLabel:`Discord`,get submitting(){return ie.submitting()},get error(){return ie.regError()},onSubmit:(e,t)=>void ie.completeRegistration(e,t),onCancel:()=>{ie.cancelRegistration(),r(`login`)}})}}),null),C(s,f(_,{get when(){return n()===`login`},get children(){var n=ka(),a=n.firstChild;a.firstChild;var s=a.nextSibling;return n.addEventListener(`submit`,oe),C(a,f(_,{get when(){return ee()},get children(){var e=ba();return e.$$click=()=>r(`register`),e}}),null),C(n,f(_,{when:!e,get children(){var e=xa(),t=e.firstChild,n=t.nextSibling;return t.$$click=()=>o(`password`),n.$$click=()=>o(`token`),S(e=>{var r=i()===`password`?`#238636`:`transparent`,a=i()===`token`?`#238636`:`transparent`;return r!==e.e&&H(t,`background`,e.e=r),a!==e.t&&H(n,`background`,e.t=a),e},{e:void 0,t:void 0}),e}}),s),C(n,f(_,{when:!e,get children(){return[(()=>{var e=Sa(),t=e.firstChild.nextSibling;return t.$$input=e=>l(e.currentTarget.value),S(e=>L(t,Ia,e)),S(()=>t.value=c()),e})(),f(_,{get when(){return T()},get children(){var e=Ca();return C(e,T),e}})]}}),s),C(n,(()=>{var e=R(()=>i()===`password`);return()=>e()?[(()=>{var e=Ma(),t=e.firstChild.nextSibling;return t.$$input=e=>p(e.currentTarget.value),S(e=>L(t,Ia,e)),S(()=>t.value=d()),e})(),(()=>{var e=Na(),t=e.firstChild.nextSibling;return t.$$input=e=>h(e.currentTarget.value),S(e=>L(t,Ia,e)),S(()=>t.value=m()),e})()]:(()=>{var e=Pa(),t=e.firstChild.nextSibling;return t.$$input=e=>v(e.currentTarget.value),S(e=>L(t,Ia,e)),S(()=>t.value=g()),e})()})(),s),C(n,f(_,{get when(){return te()},get children(){var e=wa(),t=e.firstChild;t.firstChild.nextSibling;var n=t.nextSibling;return n.$$input=e=>b(e.currentTarget.value),S(e=>L(n,Ia,e)),S(()=>n.value=y()),e}}),s),C(n,(()=>{var e=R(()=>!!me());return()=>e()&&(()=>{var e=va();return C(e,me),e})()})(),s),C(s,()=>F()?`Connecting…`:`Connect`),C(n,f(_,{get when(){return k()||A()},get children(){var e=Ta();return e.firstChild.nextSibling.nextSibling,e}}),null),C(n,f(_,{get when(){return k()},get children(){var e=Ea();return e.$$click=re,S(t=>{var n=F(),r=F()?`not-allowed`:`pointer`,i=F()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&H(e,`cursor`,t.t=r),i!==t.a&&H(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),C(n,f(_,{get when(){return A()},get children(){var e=Da();return e.$$click=ae,S(t=>{var n=F(),r=F()?`not-allowed`:`pointer`,i=F()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&H(e,`cursor`,t.t=r),i!==t.a&&H(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),C(n,f(_,{get when(){return(!e||t)&&M()},get children(){var e=Oa();return e.addEventListener(`mouseleave`,e=>{e.currentTarget.style.borderColor=`#30363d`}),e.addEventListener(`mouseenter`,e=>{F()||(e.currentTarget.style.borderColor=`#8b949e`)}),e.$$click=N,S(t=>{var n=F(),r=F()?`not-allowed`:`pointer`,i=F()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&H(e,`cursor`,t.t=r),i!==t.a&&H(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),S(e=>{var t=F(),n=F()?`not-allowed`:`pointer`,r=F()?.6:1;return t!==e.e&&(s.disabled=e.e=t),n!==e.t&&H(s,`cursor`,e.t=n),r!==e.a&&H(s,`opacity`,e.a=r),e},{e:void 0,t:void 0,a:void 0}),n}}),null),C(a,f(_,{get when(){return D().length>0},get children(){var e=Aa(),t=e.firstChild.nextSibling;return C(t,f(u,{get each(){return D()},children:e=>(()=>{var t=Fa();return C(t,()=>e.name,null),C(t,(()=>{var t=R(()=>!!e.version);return()=>t()?` ${e.version}`:``})(),null),t})()})),e}}),null),a})()}N([`input`,`click`]);var Va=[{id:`screeps-world`,name:`Screeps World`,url:`https://screeps.com`,forcedAuth:`token`,hasServerPassword:!1,builtin:!0},{id:`screeps-season`,name:`Screeps Season`,url:`https://screeps.com/season`,forcedAuth:`token`,hasServerPassword:!1,builtin:!0}],Ha=`screeps:desktop:servers`,Ua=`screeps:desktop:selectedServer`;function Wa(){try{let e=localStorage.getItem(Ha);return e?JSON.parse(e):[]}catch{return[]}}function Ga(e){localStorage.setItem(Ha,JSON.stringify(e))}function Ka(){return[...Va,...Wa()]}function qa(e){let t=Wa(),n={...e,id:crypto.randomUUID()};return Ga([...t,n]),n}function Ja(e){Ga(Wa().filter(t=>t.id!==e))}function Ya(e,t){Ga(Wa().map(n=>n.id===e?{...n,...t}:n))}function Xa(){return localStorage.getItem(Ua)}function Za(e){localStorage.setItem(Ua,e)}var Qa=V(`<div style=display:flex;flex-direction:column;height:100%;gap:8px><div style=font-size:11px;color:#484f58;text-transform:uppercase;letter-spacing:0.05em;font-weight:600;padding-bottom:4px>Servers</div><div style=flex:1;overflow:auto;display:flex;flex-direction:column;gap:2px></div><button type=button style="display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 10px;border-radius:6px;border:1px dashed #30363d;background:transparent;color:#8b949e;font-size:12px;cursor:pointer;flex-shrink:0"> Add Server`),$a=V(`<button type=button title=Edit style=background:none;border:none;cursor:pointer;color:#8b949e;padding:2px;display:flex;align-items:center;border-radius:4px;flex-shrink:0>`),eo=V(`<button type=button title=Remove style=background:none;border:none;cursor:pointer;color:#f85149;padding:2px;display:flex;align-items:center;border-radius:4px;flex-shrink:0>`),to=V(`<div style="display:flex;align-items:center;padding:8px 10px;border-radius:6px;cursor:pointer;gap:6px;transition:background 0.1s, border-color 0.1s"><div style=flex:1;min-width:0><div style=font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis></div><div style=font-size:10px;color:#484f58;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px>`),no=V(`<div style=font-size:12px;color:#d29922;margin-top:4px>`),ro=V(`<div style=display:flex;gap:8px><button type=button style="flex:1;padding:8px;border-radius:6px;border:1px solid #30363d;color:#fff;cursor:pointer;font-size:13px">Password</button><button type=button style="flex:1;padding:8px;border-radius:6px;border:1px solid #30363d;color:#fff;cursor:pointer;font-size:13px">Token`),io=V(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Email or Username</span><input type=text name=username autocomplete=username>`),ao=V(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Password</span><input type=password name=password autocomplete=current-password>`),oo=V(`<label style=display:flex;align-items:center;gap:8px;cursor:pointer><input type=checkbox style=width:14px;height:14px;accent-color:#238636;cursor:pointer;flex-shrink:0><span style=font-size:13px;color:#8b949e>Save <!> in keychain`),so=V(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Server Password <span style=color:#484f58>(optional)</span></span><input type=password name=server-password autocomplete=off data-1p-ignore data-lpignore=true placeholder="Leave empty if not required">`),co=V(`<div style=color:#f85149;font-size:13px>`),lo=V(`<div style=display:flex;align-items:center;gap:8px;color:#484f58;font-size:12px><div style=flex:1;height:1px;background:#30363d></div>or<div style=flex:1;height:1px;background:#30363d>`),uo=V(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#1b2838;color:#c7d5e0;font-weight:600>Login with Steam`),fo=V(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#5865F2;color:#fff;font-weight:600>Login with Discord`),po=V(`<form style=display:flex;flex-direction:column;gap:16px><div><h2 style="margin:0 0 4px;font-size:18px;color:#c9d1d9"></h2><div style=font-size:11px;color:#484f58></div></div><button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),mo=V(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Auth Token</span><input type=password name=token autocomplete=off>`),ho=V(`<form style=display:flex;flex-direction:column;gap:16px><h2 style=margin:0;font-size:18px;color:#c9d1d9></h2><label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Name</span><input type=text placeholder="My Private Server"required></label><label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Server URL</span><input type=url placeholder=https://example.com required></label><label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Auth Method</span><span style=font-size:11px;color:#484f58;margin-bottom:2px>Restrict available login options for this server</span><select style=cursor:pointer><option value>Auto-detect (show all options)</option><option value=token>Token only</option><option value=password>Password only</option><option value=guest>Guest only (read-only)</option></select></label><label style=display:flex;align-items:center;gap:10px;cursor:pointer><input type=checkbox style=width:14px;height:14px;accent-color:#238636;cursor:pointer;flex-shrink:0><span style=font-size:13px;color:#c9d1d9>Server requires a connection password</span></label><div style=display:flex;gap:8px;margin-top:4px><button type=submit style=flex:1;padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600;cursor:pointer></button><button type=button style="flex:1;padding:10px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#8b949e;cursor:pointer">Cancel`),go=V(`<div style=color:#484f58;text-align:center;padding-top:60px;font-size:14px>Select a server from the list`),_o=V(`<div style=display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;overflow:auto;padding:24px;box-sizing:border-box><div style="display:flex;width:680px;min-height:420px;border-radius:8px;background:#161b22;border:1px solid #30363d;overflow:hidden;flex-shrink:0"><div style="width:200px;min-width:200px;border-right:1px solid #30363d;padding:24px 16px;box-sizing:border-box;display:flex;flex-direction:column"></div><div style="flex:1;padding:28px 32px;box-sizing:border-box;overflow:auto">`),{log:vo}=P(`desktop-login`),yo={padding:`8px 12px`,"border-radius":`6px`,border:`1px solid #30363d`,background:`#0d1117`,color:`#c9d1d9`,width:`100%`,"box-sizing":`border-box`};function bo(e){let[t,n]=a(null),r=e=>{try{return new URL(e).hostname}catch{return e}};return(()=>{var i=Qa(),a=i.firstChild.nextSibling,o=a.nextSibling,s=o.firstChild;return C(a,f(u,{get each(){return e.servers},children:i=>{let a=()=>e.selectedId===i.id,o=()=>t()===i.id;return(()=>{var t=to(),s=t.firstChild.firstChild,c=s.nextSibling;return t.addEventListener(`mouseleave`,()=>n(null)),t.addEventListener(`mouseenter`,()=>n(i.id)),t.$$click=()=>e.onSelect(i.id),C(s,()=>i.name),C(c,()=>r(i.url)),C(t,f(_,{get when(){return R(()=>!i.builtin)()&&o()},get children(){return[(()=>{var t=$a();return t.$$click=t=>{t.stopPropagation(),e.onEdit(i)},C(t,f(vi,{size:12})),t})(),(()=>{var t=eo();return t.$$click=t=>{t.stopPropagation(),e.onDelete(i.id)},C(t,f(Wi,{size:12})),t})()]}}),null),S(e=>{var n=a()?`#1f6feb20`:o()?`#1c2128`:`transparent`,r=`1px solid ${a()?`#1f6feb60`:`transparent`}`,i=a()?`#58a6ff`:`#c9d1d9`,c=a()?`500`:`normal`;return n!==e.e&&H(t,`background`,e.e=n),r!==e.t&&H(t,`border`,e.t=r),i!==e.a&&H(s,`color`,e.a=i),c!==e.o&&H(s,`font-weight`,e.o=c),e},{e:void 0,t:void 0,a:void 0,o:void 0}),t})()}})),o.$$click=()=>e.onAdd(),C(o,f(Si,{size:12}),s),i})()}function xo(e){let[t,n]=a(m(()=>e.server.forcedAuth===`token`?`token`:`password`)),[o,c]=a(``),[l,u]=a(``),[d,p]=a(``),[h,g]=a(``),[v,y]=a(!1),[b,x]=a(!1),w=()=>e.server.forcedAuth??t();async function T(e){vo(`applyLoadedCredential: loading for "${e}"`);let t=await se(e);if(vo(`applyLoadedCredential: result for "${e}" →`,t===null?`[not found]`:`[found]`),t!==null){x(!0),y(!0);let e=w();vo(`applyLoadedCredential: applying to field, effectiveAuth="${e}"`),e===`token`?p(t):u(t)}}i(()=>{vo(`ServerLoginForm mounted, server="${e.server.url}"`),T(e.server.url)}),s(r(()=>e.server.id,()=>{c(``),u(``),p(``),g(``),x(!1),y(!1),n(e.server.forcedAuth===`token`?`token`:`password`),T(e.server.url)},{defer:!0}));let{serverVersion:E,serverError:D}=ea(()=>e.server.url),k=()=>!e.server.forcedAuth,A=()=>{if(e.server.hasServerPassword===!1)return!1;let t=E();return t?!ct(t):!0},j=()=>{if(e.server.forcedAuth)return!1;let t=E();if(!t)return!0;let n=dt(t);return n?n.steamLogin:nt(t)?.authTypes?.includes(`steam`)??!0},ee=()=>{if(e.server.forcedAuth)return!1;let t=E();return t?mt(t)?.discordLogin??!1:!1},M=()=>pe()===`connecting`,te=async t=>{y(t),!t&&b()&&(await Ie(e.server.url),x(!1),w()===`token`?p(``):u(``))},ne=async t=>{t.preventDefault();let n=w(),r=n===`token`?d():n===`password`?l():null,i=v()&&!b()&&r!==null&&r!==``;vo(`handleSubmit: auth="${n}" saveCredentials=${v()} credentialSaved=${b()} willSave=${i} credential=${r!==null&&r!==``?`[present]`:`[empty]`}`),i&&(vo(`handleSubmit: saving credential for "${e.server.url}"`),await O(e.server.url,r),x(!0),vo(`handleSubmit: credential saved`));try{await ke({url:e.server.url,auth:n,email:o()||void 0,password:l()||void 0,token:d()||void 0,serverPassword:h()||void 0,storage:null})}catch{i&&(vo(`handleSubmit: connect failed, removing saved credential`),Ie(e.server.url),x(!1))}},re=$i(`steam`,({url:e,token:t})=>{ke({url:e,auth:`token`,authMethod:`steam`,token:t,serverPassword:h()||void 0,storage:null})}),ie=()=>re.startLogin(e.server.url),ae=$i(`discord`,({url:e,token:t})=>{ke({url:e,auth:`token`,authMethod:`discord`,token:t,serverPassword:h()||void 0,storage:null})}),oe=()=>ae.startLogin(e.server.url),N=()=>re.pending()?{login:re,label:`Steam`}:ae.pending()?{login:ae,label:`Discord`}:void 0;return f(_,{get when(){return!N()},get fallback(){return f(sa,{get url(){return N().login.pending().url},get providerLabel(){return N().label},get submitting(){return N().login.submitting()},get error(){return N().login.regError()},onSubmit:(e,t)=>void N().login.completeRegistration(e,t),onCancel:()=>N().login.cancelRegistration()})},get children(){var r=po(),i=r.firstChild,a=i.firstChild,s=a.nextSibling,m=i.nextSibling;return r.addEventListener(`submit`,ne),C(a,()=>e.server.name),C(s,()=>e.server.url),C(i,f(_,{get when(){return D()},get children(){var e=no();return C(e,D),e}}),null),C(r,f(_,{get when(){return k()},get children(){var e=ro(),r=e.firstChild,i=r.nextSibling;return r.$$click=()=>n(`password`),i.$$click=()=>n(`token`),S(e=>{var n=t()===`password`?`#238636`:`transparent`,a=t()===`token`?`#238636`:`transparent`;return n!==e.e&&H(r,`background`,e.e=n),a!==e.t&&H(i,`background`,e.t=a),e},{e:void 0,t:void 0}),e}}),m),C(r,f(_,{get when(){return w()!==`guest`},get children(){return[f(_,{get when(){return w()===`password`},get fallback(){return(()=>{var e=mo(),t=e.firstChild.nextSibling;return t.$$input=e=>p(e.currentTarget.value),S(e=>{var n=b(),r={...yo,opacity:b()?.5:1,cursor:b()?`not-allowed`:`text`};return n!==e.e&&(t.disabled=e.e=n),e.t=L(t,r,e.t),e},{e:void 0,t:void 0}),S(()=>t.value=d()),e})()},get children(){return[(()=>{var e=io(),t=e.firstChild.nextSibling;return t.$$input=e=>c(e.currentTarget.value),S(e=>L(t,yo,e)),S(()=>t.value=o()),e})(),(()=>{var e=ao(),t=e.firstChild.nextSibling;return t.$$input=e=>u(e.currentTarget.value),S(e=>{var n=b(),r={...yo,opacity:b()?.5:1,cursor:b()?`not-allowed`:`text`};return n!==e.e&&(t.disabled=e.e=n),e.t=L(t,r,e.t),e},{e:void 0,t:void 0}),S(()=>t.value=l()),e})()]}}),(()=>{var e=oo(),t=e.firstChild,n=t.nextSibling,r=n.firstChild.nextSibling;return r.nextSibling,t.addEventListener(`change`,e=>{te(e.currentTarget.checked)}),C(n,()=>w()===`token`?`token`:`password`,r),S(()=>t.checked=v()),e})()]}}),m),C(r,f(_,{get when(){return A()},get children(){var e=so(),t=e.firstChild;t.firstChild.nextSibling;var n=t.nextSibling;return n.$$input=e=>g(e.currentTarget.value),S(e=>L(n,yo,e)),S(()=>n.value=h()),e}}),m),C(r,f(_,{get when(){return me()},get children(){var e=co();return C(e,me),e}}),m),C(m,(()=>{var e=R(()=>!!M());return()=>e()?`Connecting…`:w()===`guest`?`Connect as Guest (read-only)`:`Connect`})()),C(r,f(_,{get when(){return j()||ee()},get children(){var e=lo();return e.firstChild.nextSibling.nextSibling,e}}),null),C(r,f(_,{get when(){return j()},get children(){var e=uo();return e.$$click=ie,S(t=>{var n=M(),r=M()?`not-allowed`:`pointer`,i=M()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&H(e,`cursor`,t.t=r),i!==t.a&&H(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),C(r,f(_,{get when(){return ee()},get children(){var e=fo();return e.$$click=oe,S(t=>{var n=M(),r=M()?`not-allowed`:`pointer`,i=M()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&H(e,`cursor`,t.t=r),i!==t.a&&H(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),S(e=>{var t=M(),n=M()?`not-allowed`:`pointer`,r=M()?.6:1;return t!==e.e&&(m.disabled=e.e=t),n!==e.t&&H(m,`cursor`,e.t=n),r!==e.a&&H(m,`opacity`,e.a=r),e},{e:void 0,t:void 0,a:void 0}),r}})}function So(e){let t=()=>!!e.server,[n,r]=a(m(()=>e.server?.name??``)),[i,o]=a(m(()=>e.server?.url??``)),[s,c]=a(m(()=>e.server?.forcedAuth??``)),[l,u]=a(m(()=>e.server?.hasServerPassword??!0)),d=r=>{r.preventDefault();let a=i().trim().replace(/\/$/,``);if(!n().trim()||!a)return;let o=s(),c={name:n().trim(),url:a,forcedAuth:o===``?void 0:o,hasServerPassword:l()};t()&&e.server?(Ya(e.server.id,c),e.onSave({...e.server,...c})):e.onSave(qa(c))};return(()=>{var a=ho(),f=a.firstChild,p=f.nextSibling,m=p.firstChild.nextSibling,h=p.nextSibling,g=h.firstChild.nextSibling,_=h.nextSibling,v=_.firstChild.nextSibling.nextSibling,y=_.nextSibling,b=y.firstChild;b.nextSibling;var x=y.nextSibling.firstChild,w=x.nextSibling;return a.addEventListener(`submit`,d),C(f,()=>t()?`Edit Server`:`Add Server`),m.$$input=e=>r(e.currentTarget.value),g.$$input=e=>o(e.currentTarget.value),v.addEventListener(`change`,e=>c(e.currentTarget.value)),b.addEventListener(`change`,e=>u(e.currentTarget.checked)),C(x,()=>t()?`Save Changes`:`Add Server`),w.$$click=()=>e.onCancel(),S(e=>{var t=yo,n=yo,r={...yo};return e.e=L(m,t,e.e),e.t=L(g,n,e.t),e.a=L(v,r,e.a),e},{e:void 0,t:void 0,a:void 0}),S(()=>m.value=n()),S(()=>g.value=i()),S(()=>v.value=s()),S(()=>b.checked=l()),a})()}function Co(){let e=()=>{let e=Xa();return e&&Ka().some(t=>t.id===e)?e:Va[0].id},[t,n]=a(Ka()),[r,i]=a(e()),[o,s]=a(`login`),[c,l]=a(null),u=()=>t().find(e=>e.id===r())??null,p=()=>n(Ka()),m=e=>{i(e),Za(e),s(`login`)},h=()=>{i(null),s(`add`)},_=e=>{l(e),s(`edit`)},v=e=>{Ja(e),p(),r()===e&&m(Va[0].id)},y=e=>{p(),m(e.id)},b=()=>{o()===`edit`&&c()?i(c().id):i(r()??Va[0].id),s(`login`)};return(()=>{var e=_o(),n=e.firstChild.firstChild,i=n.nextSibling;return C(n,f(bo,{get servers(){return t()},get selectedId(){return r()},onSelect:m,onEdit:_,onDelete:v,onAdd:h})),C(i,f(g,{get children(){return[f(d,{get when(){return o()===`add`},get children(){return f(So,{onSave:y,onCancel:b})}}),f(d,{get when(){return R(()=>o()===`edit`)()?c():null},children:e=>f(So,{get server(){return e()},onSave:y,onCancel:b})}),f(d,{get when(){return R(()=>o()===`login`)()?u():null},children:e=>f(xo,{get server(){return e()}})}),f(d,{when:!0,get children(){return go()}})]}})),e})()}N([`click`,`input`]);var wo=V(`<div style=display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;width:100%;height:100%><div style="width:32px;height:32px;border:3px solid #30363d;border-top-color:#58a6ff;border-radius:50%;animation:spin 0.8s linear infinite"></div><div style=color:#8b949e;font-size:13px>Connecting…`);function To(){return(()=>{var e=wo();return e.firstChild.nextSibling,e})()}var Eo=V(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:500;display:flex;align-items:center;justify-content:center><div style="width:min(440px, calc(100% - 48px));background:#161b22;border:1px solid #30363d;border-radius:8px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);padding:20px"><div style=font-size:16px;font-weight:600;color:#f85149;margin-bottom:12px>Connection lost</div><p style="font-size:13px;color:#c9d1d9;line-height:1.5;margin:0 0 18px"></p><div style=display:flex;justify-content:flex-end;gap:8px><button style="padding:7px 14px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer;font-size:13px">Logout</button><button style="padding:7px 14px;border-radius:4px;border:none;background:#58a6ff;color:#0d1117;cursor:pointer;font-size:13px;font-weight:600">Reload page`);function Do(){return f(_,{get when(){return De()},get children(){var e=Eo(),t=e.firstChild.firstChild.nextSibling,n=t.nextSibling.firstChild,r=n.nextSibling;return C(t,De),n.$$click=()=>be(),r.$$click=()=>window.location.reload(),e}})}N([`click`]);var Oo=V(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:500;display:flex;align-items:center;justify-content:center><div style="width:min(480px, calc(100% - 48px));background:#161b22;border:1px solid #30363d;border-radius:8px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);padding:20px"><div style=font-size:16px;font-weight:600;color:#f85149;margin-bottom:12px>Rate limit exceeded</div><p style="font-size:13px;color:#c9d1d9;line-height:1.5;margin:0 0 18px;word-break:break-word"></p><div style=display:flex;justify-content:flex-end;gap:8px><button style="padding:7px 14px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer;font-size:13px">Close`),ko=V(`<button style="padding:7px 14px;border-radius:4px;border:none;background:#58a6ff;color:#0d1117;cursor:pointer;font-size:13px;font-weight:600">Disable rate limiting`);function Ao(){return f(_,{get when(){return Pe()},children:e=>(()=>{var t=Oo(),n=t.firstChild.firstChild.nextSibling,r=n.nextSibling,i=r.firstChild;return C(n,()=>e().message),i.$$click=()=>ye(null),C(r,f(_,{get when(){return e().disableLink},children:e=>(()=>{var t=ko();return t.$$click=()=>void fe(e()),t})()}),null),t})()})}N([`click`]);var jo=V(`<span style="padding:2px 8px;border-radius:4px;background:#21262d;border:1px solid #30363d;color:#8b949e;font-size:11px;font-weight:600;letter-spacing:0.05em;text-transform:uppercase">Guest`),Mo=V(`<div style="display:flex;align-items:center;gap:12px;padding:8px 16px;border-bottom:1px solid #30363d;font-size:13px"><div style=display:flex;align-items:center;gap:6px><span style=width:8px;height:8px;border-radius:50%;display:inline-block></span><span style=color:#8b949e>`);function No(){let e=()=>{switch(pe()){case`connected`:return`#238636`;case`connecting`:return`#d29922`;case`error`:return`#f85149`;default:return`#8b949e`}};return(()=>{var t=Mo(),n=t.firstChild.firstChild,r=n.nextSibling;return C(r,(()=>{var e=R(()=>pe()===`connected`);return()=>e()?`Online`:pe()})()),C(t,f(_,{get when(){return ge()},get children(){return jo()}}),null),S(t=>H(n,`background-color`,e())),t})()}var Po=class{container;hoverGraphics;pendingGraphics;selectionContainer;selectionGraphics=new Map;selectionTypes=new Map;selectionVisuals=new Map;ticker=null;tickerCallback=null;constructor(e){this.container=new ze,this.container.label=`hoverHighlight`,this.container.eventMode=`none`,this.hoverGraphics=new W,this.hoverGraphics.eventMode=`none`,this.container.addChild(this.hoverGraphics),this.pendingGraphics=new W,this.pendingGraphics.eventMode=`none`,this.container.addChild(this.pendingGraphics),this.selectionContainer=new ze,this.selectionContainer.eventMode=`none`,this.container.addChild(this.selectionContainer),e&&(this.ticker=e,this.tickerCallback=()=>this.trackCreepRings(),e.add(this.tickerCallback))}setHoveredTile(e,t){if(this.hoverGraphics.clear(),e===null||t===null)return;let n=e*12,r=t*12;this.hoverGraphics.rect(n,r,12,12),this.hoverGraphics.stroke({width:1,color:16777215,alpha:.35}),this.hoverGraphics.rect(n,r,12,12),this.hoverGraphics.fill({color:16777215,alpha:.06})}setSelectedObjects(e){this.selectionContainer.removeChildren();for(let e of this.selectionGraphics.values())e.destroy();this.selectionGraphics.clear(),this.selectionTypes.clear(),this.selectionVisuals.clear();for(let{id:t,type:n,visual:r}of e){let e=new W;e.eventMode=`none`,this.selectionContainer.addChild(e),this.selectionGraphics.set(t,e),this.selectionTypes.set(t,n),this.selectionVisuals.set(t,r),n===`creep`?this.drawCreepRing(e,r.x,r.y):this.drawStructureBox(e,r.x,r.y)}}clearSelection(){this.selectionContainer.removeChildren();for(let e of this.selectionGraphics.values())e.destroy();this.selectionGraphics.clear(),this.selectionTypes.clear(),this.selectionVisuals.clear()}setPendingTile(e,t){if(this.pendingGraphics.clear(),e===null||t===null)return;let n=e*12,r=t*12,i=n+12/2,a=r+12/2,o=12*.35;this.pendingGraphics.moveTo(i-o,a),this.pendingGraphics.lineTo(i+o,a),this.pendingGraphics.moveTo(i,a-o),this.pendingGraphics.lineTo(i,a+o),this.pendingGraphics.stroke({width:1.5,color:15763518,alpha:.9}),this.pendingGraphics.rect(n+1,r+1,10,10),this.pendingGraphics.stroke({width:1.5,color:15763518,alpha:.6})}clearPendingTile(){this.pendingGraphics.clear()}drawCreepRing(e,t,n){e.clear();let r=t+12/2,i=n+12/2;e.circle(r,i,5.76),e.stroke({width:1.5,color:16777215,alpha:.9})}drawStructureBox(e,t,n){e.clear(),e.rect(t+1,n+1,10,10),e.stroke({width:1.5,color:16777215,alpha:.9}),e.rect(t+1,n+1,10,10),e.fill({color:16777215,alpha:.04})}trackCreepRings(){for(let[e,t]of this.selectionGraphics){if(this.selectionTypes.get(e)!==`creep`)continue;let n=this.selectionVisuals.get(e);!n||n.destroyed||this.drawCreepRing(t,n.x,n.y)}}destroy(){this.ticker&&this.tickerCallback&&this.ticker.remove(this.tickerCallback),this.ticker=null,this.tickerCallback=null,this.clearSelection(),this.clearPendingTile(),this.pendingGraphics.destroy(),this.hoverGraphics.destroy(),this.container.destroy()}},Fo=.2,Io=3,Lo=class{displaySprite;renderer;rt;scene;gradientTexture;lights=new Map;dirty=!1;destroyed=!1;constructor(e){this.renderer=e,this.gradientTexture=Ro(),this.rt=Be.create({width:600,height:600}),this.scene=new ze;let t=new W;t.rect(0,0,600,600),t.fill({color:0,alpha:Fo}),this.scene.addChild(t),this.displaySprite=new Ge(this.rt),this.render()}setLights(e){let t=new Set;for(let{id:n,cx:r,cy:i}of e){t.add(n);let e=this.lights.get(n);e||(e=new Ge(this.gradientTexture),e.anchor.set(.5),e.blendMode=`erase`,this.scene.addChild(e),this.lights.set(n,e)),e.position.set(r,i)}for(let[e,n]of this.lights)t.has(e)||(n.destroy(),this.lights.delete(e));this.dirty=!0}setLightPosition(e,t,n){let r=this.lights.get(e);r&&(r.x===t&&r.y===n||(r.position.set(t,n),this.dirty=!0))}render(){this.destroyed||!this.dirty||(this.renderer.render({container:this.scene,target:this.rt,clear:!0}),this.dirty=!1)}clear(){for(let e of this.lights.values())e.destroy();this.lights.clear(),this.dirty=!0,this.render()}destroy(){if(!this.destroyed){this.destroyed=!0;for(let e of this.lights.values())e.destroy();this.lights.clear(),this.scene.destroy({children:!0}),this.rt.destroy(!0),this.gradientTexture.destroy(!0),this.displaySprite.destroy()}}};function Ro(){let e=Io*12,t=e*2,n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`),i=r.createRadialGradient(e,e,0,e,e,e);return i.addColorStop(0,`rgba(255,255,255,1)`),i.addColorStop(1,`rgba(255,255,255,0)`),r.fillStyle=i,r.beginPath(),r.arc(e,e,e,0,Math.PI*2),r.fill(),Ze.from(n)}var zo=48,Bo=128,Vo={terrain:0,objects:10,animations:20,darkOverlay:30,visuals:40,hover:50,nav:60},Ho=new Set([`road`,`constructedWall`,`rampart`]),Uo=class e{app;world;hoverLayer;darkOverlay;lightLayer;lighting;destroyed=!1;canDrag=!1;container;resizeObserver=null;bounceRaf=null;wheelTimeout=null;navOverlay;lastMouseX=0;lastMouseY=0;onHoverTile=null;onClickTile=null;onRightClick=null;constructor(e,t){this.app=e,this.container=t,this.world=new ze({sortableChildren:!0}),this.app.stage.addChild(this.world),this.lighting=new Lo(this.app.renderer),this.darkOverlay=this.lighting.displaySprite,this.darkOverlay.label=`darkOverlay`,this.darkOverlay.zIndex=Vo.darkOverlay,this.world.addChild(this.darkOverlay),this.lightLayer=new ze,this.lightLayer.label=`lightLayer`,this.hoverLayer=new Po(e.ticker),this.hoverLayer.container.zIndex=Vo.hover,this.world.addChild(this.hoverLayer.container),this.navOverlay=new ze,this.navOverlay.zIndex=Vo.nav,this.world.addChild(this.navOverlay),this.setupCamera(),this.centerView(),this.clampView(),this.setupResizeObserver()}bringNavOverlayToTop(){this.hoverLayer.container.parent===this.world&&(this.world.removeChild(this.hoverLayer.container),this.world.addChild(this.hoverLayer.container)),this.navOverlay.parent===this.world&&(this.world.removeChild(this.navOverlay),this.world.addChild(this.navOverlay))}static async create(t){let n=new Ke;return await n.init({background:`#0d1117`,antialias:!0,resolution:window.devicePixelRatio||1,autoDensity:!0}),t.appendChild(n.canvas),new e(n,t)}getMinScale(){let e=this.container.clientWidth,t=this.container.clientHeight;return Math.min(e,t)/664}clampView(e=!1){let t=600*this.world.scale.x,n=this.container.clientWidth,r=this.container.clientHeight,i=e?Bo:0;if(t<=n){let r=n/2-t/2;e?this.world.x=Math.min(r+Bo,Math.max(r-Bo,this.world.x)):this.world.x=r}else{let e=n-t-zo-i,r=zo+i;this.world.x=Math.min(r,Math.max(e,this.world.x))}if(t<=r){let n=r/2-t/2;e?this.world.y=Math.min(n+Bo,Math.max(n-Bo,this.world.y)):this.world.y=n}else{let e=r-t-zo-i,n=zo+i;this.world.y=Math.min(n,Math.max(e,this.world.y))}this.canDrag=!0}getTargetPosition(){let e=600*this.world.scale.x,t=this.container.clientWidth,n=this.container.clientHeight,r=null,i=null;if(e<=t)r=t/2-e/2;else{let n=t-e-zo,i=zo;this.world.x<n?r=n:this.world.x>i&&(r=i)}if(e<=n)i=n/2-e/2;else{let t=n-e-zo,r=zo;this.world.y<t?i=t:this.world.y>r&&(i=r)}return r===null&&i===null?null:{x:r??this.world.x,y:i??this.world.y}}springBack(){let e=this.getTargetPosition(),t=this.getTargetScale();if(!e&&t===null)return;let n=this.world.x,r=this.world.y,i=this.world.scale.x,a=performance.now(),o=this.container.clientWidth/2,s=this.container.clientHeight/2,c=(o-n)/i,l=(s-r)/i,u=d=>{let f=d-a,p=Math.min(1,f/300),m=1-(1-p)**3;if(t!==null){let e=i+(t-i)*m;this.world.scale.set(e),this.world.x=o-c*e,this.world.y=s-l*e}e&&t===null&&(this.world.x=n+(e.x-n)*m,this.world.y=r+(e.y-r)*m),p<1?this.bounceRaf=requestAnimationFrame(u):(this.bounceRaf=null,this.clampView())};this.cancelBounce(),this.bounceRaf=requestAnimationFrame(u)}cancelBounce(){this.bounceRaf!==null&&(cancelAnimationFrame(this.bounceRaf),this.bounceRaf=null)}cancelWheelTimeout(){this.wheelTimeout!==null&&(clearTimeout(this.wheelTimeout),this.wheelTimeout=null)}getTargetScale(){let e=this.getMinScale();return this.world.scale.x<e?e:this.world.scale.x>5?5:null}setupCamera(){let e=!1,t=new Ve(0,0),n=new Ve(0,0),r=this.app.canvas;r.style.touchAction=`none`,r.style.userSelect=`none`;let i=new Map,a=!1,o=0,s=0,c=0,l=0;r.addEventListener(`pointerdown`,u=>{if(this.cancelBounce(),this.cancelWheelTimeout(),i.set(u.pointerId,{x:u.clientX,y:u.clientY}),r.setPointerCapture(u.pointerId),i.size>=2){e=!1,a=!0;let t=[...i.values()],n=r.getBoundingClientRect(),u=(t[0].x+t[1].x)/2-n.left,d=(t[0].y+t[1].y)/2-n.top;c=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),l=this.world.scale.x,o=(u-this.world.x)/l,s=(d-this.world.y)/l}else a=!1,e=this.canDrag,t=new Ve(u.clientX,u.clientY),n=new Ve(u.clientX,u.clientY)}),r.addEventListener(`pointermove`,n=>{let u=r.getBoundingClientRect();if(this.lastMouseX=n.clientX-u.left,this.lastMouseY=n.clientY-u.top,i.has(n.pointerId)&&i.set(n.pointerId,{x:n.clientX,y:n.clientY}),a&&i.size===2){let e=[...i.values()],t=(e[0].x+e[1].x)/2-u.left,n=(e[0].y+e[1].y)/2-u.top,r=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y),a=this.getMinScale(),d=.6,f=r/c*l;f<a&&(f=a+(f-a)*d),f>5&&(f=5+(f-5)*d),this.cancelBounce(),this.world.scale.set(f),this.world.x=t-o*f,this.world.y=n-s*f,this.clampView(!0);return}if(!a){let e=this.screenToTile(this.lastMouseX,this.lastMouseY);this.hoverLayer.setHoveredTile(e?.tx??null,e?.ty??null),this.onHoverTile?.(e?.tx??null,e?.ty??null)}if(!e||!this.canDrag)return;let d=n.clientX-t.x,f=n.clientY-t.y;this.world.x+=d,this.world.y+=f,t=new Ve(n.clientX,n.clientY),this.clampView(!0)});let u=t=>{if(r.releasePointerCapture(t.pointerId),i.delete(t.pointerId),a){i.size<2&&(a=!1,e=!1,this.springBack());return}e=!1;let o=t.clientX-n.x,s=t.clientY-n.y;if(Math.sqrt(o*o+s*s)<4){let e=r.getBoundingClientRect(),n=t.clientX-e.left,i=t.clientY-e.top,a=this.screenToTile(n,i);a&&this.onClickTile?.(a.tx,a.ty,t.ctrlKey||t.metaKey)}this.springBack()};r.addEventListener(`pointerup`,u),r.addEventListener(`pointercancel`,u),r.addEventListener(`contextmenu`,e=>{e.preventDefault(),e.button===2&&this.onRightClick?.()}),r.addEventListener(`pointerleave`,()=>{this.hoverLayer.setHoveredTile(null,null),this.onHoverTile?.(null,null)}),r.addEventListener(`wheel`,e=>{e.preventDefault();let t=e.deltaY>0?.9:1.1,n=this.getMinScale(),i=this.world.scale.x*t,a=.6;i<n&&(i=n+(i-n)*a),i>5&&(i=5+(i-5)*a);let o=r.getBoundingClientRect(),s=e.clientX-o.left,c=e.clientY-o.top;if(this.cancelBounce(),i<n){let e=this.container.clientWidth/2,t=this.container.clientHeight/2,n=(e-this.world.x)/this.world.scale.x,r=(t-this.world.y)/this.world.scale.y;this.world.scale.set(i),this.world.x=e-n*i,this.world.y=t-r*i}else{let e=(s-this.world.x)/this.world.scale.x,t=(c-this.world.y)/this.world.scale.y;this.world.scale.set(i),this.world.x=s-e*i,this.world.y=c-t*i}this.clampView(),this.cancelWheelTimeout(),this.wheelTimeout=window.setTimeout(()=>{this.wheelTimeout=null,this.springBack()},80)},{passive:!1})}setTileHandlers(e,t,n){this.onHoverTile=e,this.onClickTile=t,this.onRightClick=n??null}screenToTile(e,t){let n=(e-this.world.x)/this.world.scale.x,r=(t-this.world.y)/this.world.scale.y,i=Math.floor(n/12),a=Math.floor(r/12);return i<0||i>=50||a<0||a>=50?null:{tx:i,ty:a}}centerView(){let e=this.container.clientWidth/2,t=this.container.clientHeight/2,n=this.world.scale.x;this.world.x=e-600*n/2,this.world.y=t-600*n/2}resetView(){this.cancelBounce(),this.cancelWheelTimeout(),this.world.scale.set(this.getMinScale()),this.centerView(),this.clampView()}setupResizeObserver(){let{width:e,height:t}=this.container.getBoundingClientRect();this.app.renderer.resize(e,t),this.resizeObserver=new ResizeObserver(e=>{let{width:t,height:n}=e[0].contentRect;this.app.renderer.resize(t,n),this.clampView()}),this.resizeObserver.observe(this.container)}setupNavigationZones(e){this.navOverlay.removeChildren();let t=(e,t,n,r,i,a)=>{if(!a)return;let o=new W;o.x=e,o.y=t,o.hitArea=new $e(0,0,n,r),o.fill({color:16777215,alpha:.12}),o.poly(i),o.fill(),o.eventMode=`static`,o.cursor=`pointer`,o.alpha=1,o.on(`pointerover`,()=>{o.clear(),o.fill({color:16777215,alpha:.06}),o.rect(0,0,n,r),o.fill(),o.fill({color:16777215,alpha:.35}),o.poly(i),o.fill()}),o.on(`pointerout`,()=>{o.clear(),o.fill({color:16777215,alpha:.12}),o.poly(i),o.fill()}),o.on(`pointerdown`,a),this.navOverlay.addChild(o)};t(-48,0,zo,600,[18,300,zo-6,282,zo-6,318],e.west),t(600,0,zo,600,[zo-18,300,6,282,6,318],e.east),t(0,-48,600,zo,[300,18,282,zo-6,318,zo-6],e.north),t(0,600,600,zo,[300,zo-18,282,6,318,6],e.south);for(let e of this.navOverlay.children){let t=e,n=t.hitArea,r=this.world.x+t.x*this.world.scale.x,i=this.world.y+t.y*this.world.scale.y,a=n.width*this.world.scale.x,o=n.height*this.world.scale.y;this.lastMouseX>=r&&this.lastMouseX<=r+a&&this.lastMouseY>=i&&this.lastMouseY<=i+o&&t.emit(`pointerover`,new Event(`pointerover`))}}clear(){for(let e=this.world.children.length-1;e>=0;e--){let t=this.world.children[e];t!==this.navOverlay&&t!==this.hoverLayer.container&&t!==this.darkOverlay&&this.world.removeChild(t)}this.navOverlay.removeChildren(),this.hoverLayer.clearSelection(),this.hoverLayer.setHoveredTile(null,null),this.clearLighting(),this.world.scale.set(1),this.cancelBounce(),this.cancelWheelTimeout(),this.clampView()}clearLighting(){this.lighting.clear()}updateLighting(e){let t=[];for(let n in e){let r=e[n];r&&(typeof r.type==`string`&&Ho.has(r.type)||typeof r.x!=`number`||typeof r.y!=`number`||t.push({id:n,cx:(r.x+.5)*12,cy:(r.y+.5)*12}))}this.lighting.setLights(t),this.lighting.render()}destroy(){this.destroyed||(this.destroyed=!0,this.cancelBounce(),this.cancelWheelTimeout(),this.resizeObserver?.disconnect(),this.resizeObserver=null,this.hoverLayer.destroy(),this.lighting.destroy(),this.app.destroy(!0,{children:!0}))}};function Wo(e){return e}function Go(e){return{floorColor:e?.floorColor??3421243,swampFillColor:e?.swampFillColor??2632986,swampBorderColor:e?.swampBorderColor??2500383,swampBorderWidth:e?.swampBorderWidth??.2,swampGlowColor:e?.swampGlowColor??2771488,wallFillColor:e?.wallFillColor??1579032,wallBorderColor:e?.wallBorderColor??0,wallBorderWidth:e?.wallBorderWidth??.05,wallNoiseColor:e?.wallNoiseColor??2631720}}function Ko(e,t,n,r){let i=!1;for(let r=0;r<50;r++)for(let a=0;a<50;a++){let o=t.get(a,r)===n,s=r>0&&t.get(a,r-1)===n,c=r<49&&t.get(a,r+1)===n,l=a>0&&t.get(a-1,r)===n,u=a<49&&t.get(a+1,r)===n,d=a*12+6,f=r*12+6;o?(i=!0,!s&&!l&&r>0&&a>0?(e.moveTo(d,r*12),e.arc(d,f,6,-Math.PI/2,Math.PI,!0),e.lineTo(d,f),e.closePath()):e.rect(a*12,r*12,6,6)):s&&l&&t.get(a-1,r-1)===n&&(i=!0,e.moveTo(d,r*12),e.lineTo(a*12,r*12),e.lineTo(a*12,f),e.arc(d,f,6,Math.PI,-Math.PI/2,!1),e.closePath()),o?!s&&!u&&r>0&&a<49?(e.moveTo(d,r*12),e.arc(d,f,6,-Math.PI/2,0,!1),e.lineTo(d,f),e.closePath()):e.rect(d,r*12,6,6):s&&u&&t.get(a+1,r-1)===n&&(i=!0,e.moveTo(d,r*12),e.lineTo(a*12+12,r*12),e.lineTo(a*12+12,f),e.arc(d,f,6,0,-Math.PI/2,!0),e.closePath()),o?!c&&!l&&r<49&&a>0?(e.moveTo(a*12,f),e.arc(d,f,6,Math.PI,Math.PI/2,!0),e.lineTo(d,f),e.closePath()):e.rect(a*12,f,6,6):c&&l&&t.get(a-1,r+1)===n&&(i=!0,e.moveTo(a*12,f),e.lineTo(a*12,r*12+12),e.lineTo(d,r*12+12),e.arc(d,f,6,Math.PI/2,Math.PI,!1),e.closePath()),o?!c&&!u&&r<49&&a<49?(e.moveTo(d,r*12+12),e.arc(d,f,6,Math.PI/2,0,!0),e.lineTo(d,f),e.closePath()):e.rect(d,f,6,6):c&&u&&t.get(a+1,r+1)===n&&(i=!0,e.moveTo(d,r*12+12),e.lineTo(a*12+12,r*12+12),e.lineTo(a*12+12,f),e.arc(d,f,6,0,Math.PI/2,!1),e.closePath())}i&&r(e)}function qo(e,t){let n=Wt,r=(t,r,i)=>{let a=t*12+12/2,o=r*12+12/2,s=12*.3;i===`up`?(e.moveTo(a,o-s),e.lineTo(a+s,o+s),e.lineTo(a-s,o+s)):i===`down`?(e.moveTo(a,o+s),e.lineTo(a+s,o-s),e.lineTo(a-s,o-s)):i===`left`?(e.moveTo(a-s,o),e.lineTo(a+s,o-s),e.lineTo(a+s,o+s)):i===`right`&&(e.moveTo(a+s,o),e.lineTo(a-s,o-s),e.lineTo(a-s,o+s)),e.fill(n)};for(let e=0;e<50;e++)t.get(e,0)!==ot.Wall&&r(e,0,`up`),t.get(e,49)!==ot.Wall&&r(e,49,`down`);for(let e=0;e<50;e++)t.get(0,e)!==ot.Wall&&r(0,e,`left`),t.get(49,e)!==ot.Wall&&r(49,e,`right`)}function Jo(e){let t=new W;return t.rect(0,0,600,600),t.fill(e.floorColor),t}function Yo(e,t){let n=new W;return Ko(n,e,ot.Swamp,e=>e.fill(t.swampFillColor)),n.alpha=.4,n}function Xo(e,t){let n=new W,r={color:t.wallBorderColor,width:12*t.wallBorderWidth,alignment:0,cap:`round`,join:`round`};return Ko(n,e,ot.Wall,e=>e.stroke(r)),Ko(n,e,ot.Wall,e=>e.fill(t.wallFillColor)),qo(n,e),n.rect(0,0,600,600),n.stroke({width:1,color:At}),n}function Zo(e,t){let n=new W;return n.label=`swampGlow`,Ko(n,e,ot.Swamp,e=>e.fill(t.swampGlowColor)),n.alpha=.45,n.filters=[new Ue({strength:5,quality:3})],n}function Qo(e,t,n){let r=new W;Ko(r,e,ot.Wall,e=>e.fill(n.wallNoiseColor)),r.alpha=.5,r.filters=[new Xe({noise:.12,seed:1})],r.filterArea=new $e(0,0,600,600);let i=t.generateTexture({target:r,frame:r.filterArea});r.filters=null,r.destroy();let a=new Ge(i);return a.label=`wallNoise`,a}function $o(e,t,n){let r=Go(n),i=new ze,a=Qo(e,t,r),o=i.destroy.bind(i);if(i.destroy=e=>{a.destroyed||(a.removeFromParent(),a.destroy({texture:!0,textureSource:!0})),o(e)},i.addChild(Jo(r)),i.addChild(Yo(e,r)),i.addChild(Xo(e,r)),i.addChild(Zo(e,r)),i.addChild(a),n?.wallTextureUrl&&(a.visible=!1),n?.floorTextureUrl){let{floorTextureUrl:e,floorTextureTint:t=16777215,floorTextureAlpha:r=1,floorTextureTileScale:a=1}=n;We.load(Wo(e)).then(e=>{if(i.destroyed)return;let n=new He({texture:e,width:600,height:600});n.tint=t,n.alpha=r,n.tileScale.set(a*.8),i.addChildAt(n,1)}).catch(()=>{})}if(n?.wallTextureUrl){let{wallTextureUrl:t,wallTextureTint:r=16777215,wallTextureAlpha:a=1,wallTextureTileScale:o=1}=n;We.load(Wo(t)).then(t=>{if(i.destroyed)return;let n=new He({texture:t,width:600,height:600});n.tint=r,n.alpha=a,n.tileScale.set(o);let s=new W;Ko(s,e,ot.Wall,e=>e.fill(16777215)),i.addChild(s),n.mask=s,i.addChild(n)}).catch(()=>{})}return i}function es(e,t){e.getChildByLabel(`swampGlow`).visible=t,e.getChildByLabel(`wallNoise`).visible=t}function ts(e,t){let n=parseInt(e.replace(`#`,``),16),r=Math.min(255,Math.round((n>>16&255)*t)),i=Math.min(255,Math.round((n>>8&255)*t)),a=Math.min(255,Math.round((n&255)*t));return r<<16|i<<8|a}function ns(e){return parseInt(e.replace(`#`,``),16)}function rs(e,t){if(e==null)return t;let n=Number(e);return isNaN(n)?t:n}function is(e,t,n){let r=n.terrain??{};e.floorBackgroundColor&&(r.floorColor=ts(e.floorBackgroundColor,rs(e.floorBackgroundBrightness,1))),e.swampColor&&(r.swampFillColor=ns(e.swampColor)),e.swampStrokeColor&&(r.swampBorderColor=ns(e.swampStrokeColor)),e.swampStrokeWidth!=null&&(r.swampBorderWidth=rs(e.swampStrokeWidth,50)/250),e.roadsColor&&(n.roadColor=ts(e.roadsColor,rs(e.roadsBrightness,1))),t.floorForegroundUrl&&(r.floorTextureUrl=t.floorForegroundUrl,e.floorForegroundColor&&(r.floorTextureTint=ts(e.floorForegroundColor,rs(e.floorForegroundBrightness,1))),r.floorTextureAlpha=rs(e.floorForegroundAlpha,1),r.floorTextureTileScale=rs(e.tileScale??t.tileScale,1)),n.terrain=r}function as(e,t,n){let r=n.terrain??{};e.backgroundColor&&(r.wallFillColor=ts(e.backgroundColor,rs(e.backgroundBrightness,1))),e.strokeColor&&(r.wallBorderColor=ts(e.strokeColor,rs(e.strokeBrightness,1))),e.strokeWidth!=null&&(r.wallBorderWidth=rs(e.strokeWidth,10)/250),t.foregroundUrl&&(r.wallTextureUrl=t.foregroundUrl,e.foregroundColor&&(r.wallTextureTint=ts(e.foregroundColor,rs(e.foregroundBrightness,1))),r.wallTextureAlpha=rs(e.foregroundAlpha,1),r.wallTextureTileScale=rs(e.tileScale??t.tileScale,1)),n.terrain=r}function os(e){let t={};for(let n of e.decorations){let e=n.decoration.type;e===`floorLandscape`?is(n.active,n.decoration,t):e===`wallLandscape`&&as(n.active,n.decoration,t)}return t}var ss={1:200,2:45e3,3:135e3,4:405e3,5:1215e3,6:3645e3,7:10935e3},cs={1:2e4,2:1e4,3:2e4,4:4e4,5:8e4,6:12e4,7:15e4,8:2e5},ls=new Xt,us=12*.44,ds=12*.28,fs=50,ps=32,ms=12/ps,hs=12/2-12*.44,gs=2,_s=12*1.2/ps,vs=5,ys=2.5,bs=2,xs=2.6,Ss=2,Cs=12,ws=15790320,Ts=1710618,Es=12*.42,Ds=12*.3,Os=1,ks={H:2236962,O:2236962},As=.2,js=12*.42,Ms=32,Ns=9/Ms,Ps=8,Fs=1600,Is=16776428,Ls=4473924,Rs=1.7999999999999998;function zs(e,t){return t<=0?Ps:Ps*Math.max(0,Math.min(1,e/t))}function Bs(e){let t=e%Fs/Fs;return .5-.5*Math.cos(t*Math.PI*2)}function Vs(e){return Xs(wt,Is,Bs(e))}function Hs(e,t,n){e.clear();let r=t<=0,i=Ps/2,a=Ps*.25;if(e.roundRect(6-i,6-i,Ps,Ps,a),e.fill(G),r)e.roundRect(6-i,6-i,Ps,Ps,a),e.stroke({width:Rs,color:Xs(G,Ls,Bs(n))});else{let r=t/2;e.roundRect(6-r,6-r,t,t,t*.25),e.fill(Vs(n))}}function Us(e,t){let n=e.__sourceGraphics;n&&(e.__sourceSize=t,Hs(n,t,performance.now()))}function Ws(e){return{energy:typeof e.energy==`number`?e.energy:0,capacity:typeof e.energyCapacity==`number`?e.energyCapacity:3e3}}var Gs=12*.3,Ks=1.44,qs=Gs-Ks/2,Js=12*.42,Ys=1500;function Xs(e,t,n){let r=e>>16&255,i=e>>8&255,a=e&255,o=t>>16&255,s=t>>8&255,c=t&255,l=Math.round(r+(o-r)*n),u=Math.round(i+(s-i)*n),d=Math.round(a+(c-a)*n);return l<<16|u<<8|d}function Zs(e,t){e.clear(),e.circle(12/2,12/2,Gs),e.stroke({width:Ks,color:t,alpha:.95})}var Qs=12*.975,$s=2.16,ec=Math.PI/3,tc=1;function nc(e,t){e.clear();for(let n=0;n<3;n++){let r=n*(2*Math.PI/3)+ec/2,i=r+2*Math.PI/3-ec;e.arc(0,0,Qs,r,i),e.stroke({width:$s,color:t,cap:`round`})}}function rc(e,t,n,r,i,a,o){if(e.clear(),a<=0||i<=0)return;let s=Math.min(1,i/a);if(s>=1){e.circle(t,n,r),e.fill({color:o,alpha:.55});return}let c=-Math.PI/2,l=c+s*Math.PI*2;e.moveTo(t,n),e.lineTo(t+r*Math.cos(c),n+r*Math.sin(c)),e.arc(t,n,r,c,l),e.closePath(),e.fill({color:o,alpha:.55})}var ic=12*.5,ac=1.2000000000000002,oc=12*.4;function sc(e,t){let n=e.spawning;if(!n||typeof n!=`object`)return null;let r=typeof n.needTime==`number`&&n.needTime>0?n.needTime:null;return r===null?null:typeof n.remainingTime==`number`?{needTime:r,endTime:t+n.remainingTime}:typeof n.spawnTime==`number`?{needTime:r,endTime:n.spawnTime>t?n.spawnTime:n.spawnTime+r}:{needTime:r,endTime:t+r}}function cc(e){let t=e.spawning;return!t||typeof t!=`object`?null:`${String(t.name)}:${String(t.needTime)}:${String(t.remainingTime)}:${String(t.spawnTime)}`}function lc(e,t,n){return Math.max(0,Math.min(1,1-(t-n)/e))}function uc(e,t){if(e.clear(),t===null||(e.circle(6,6,ic),e.stroke({width:ac,color:16777215,alpha:.12}),t<=0))return;let n=-Math.PI/2,r=n+Math.min(1,t)*Math.PI*2;e.moveTo(6+ic*Math.cos(n),6+ic*Math.sin(n)),e.arc(6,6,ic,n,r),e.stroke({width:ac,color:wt,alpha:.95,cap:`round`})}function dc(e,t,n){return n.flatMap(([n,r])=>[e+n*12,t+r*12])}function fc(e,t,n,r){n-t<.001||(e.moveTo(us*Math.cos(t),us*Math.sin(t)),e.arc(0,0,us,t,n),e.lineTo(ds*Math.cos(n),ds*Math.sin(n)),e.arc(0,0,ds,n,t,!0),e.closePath(),e.fill(r))}var pc=[[0,-.3],[.22,.05],[.15,.2],[-.15,.2],[-.22,.05]],mc=12*.073,hc=null;function gc(){if(hc)return hc;let e=dc(12/2,12/2,pc),t=new qe({type:`linear`,start:{x:.5,y:0},end:{x:.5,y:1},colorStops:[{offset:0,color:tn},{offset:1,color:mn}]});return hc=new Ye().poly(e).fill(t).poly(e).stroke({width:mc,color:gn,alignment:.5,join:`miter`,miterLimit:6}),hc}function _c(e){e.addChild(new W({context:gc()}))}function vc(e){let t=0;if(typeof e.storeCapacity==`number`)t=e.storeCapacity;else{let n=e.body;n&&(t=n.filter(e=>e.type===`carry`).length*50)}if(t===0)return{used:0,capacity:0};let n=0;if(e.store&&typeof e.store==`object`){let t=e.store;for(let e in t){let r=t[e];typeof r==`number`&&(n+=r)}}else typeof e.energy==`number`&&(n=e.energy);return{used:n,capacity:t}}function yc(e,t){return t<=0||e<=0?0:ds*.8*Math.min(1,e/t)}function bc(e,t){let n=e.__creepFillGraphics;n&&(n.clear(),t>0&&(n.circle(0,0,t),n.fill(Mn)))}function xc(e){return Vn[e]??13226457}function Sc(e){let t=50;typeof e.energyCapacity==`number`?t=e.energyCapacity:typeof e.storeCapacity==`number`?t=e.storeCapacity:e.storeCapacityResource&&typeof e.storeCapacityResource==`object`&&(t=e.storeCapacityResource.energy??50);let n=0;return typeof e.energy==`number`?n=e.energy:e.store&&typeof e.store==`object`&&(n=e.store.energy??0),{energy:n,capacity:t}}function Cc(e){return e>=200?1.15:e>=100?.85:.7}function wc(e,t){return t<=0||e<=0?0:Ds*Cc(t)*Math.min(1,e/t)}var Tc=12*.25,Ec=12*.3;function Dc(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function Oc(e,t){let n=e.__linkFillGraphics;if(!n||(n.clear(),t<=0))return;let r=Tc*t,i=Ec*t;n.poly([6,6-i,6+r,6,6,6+i,6-r,6]),n.fill(wt)}function kc(e,t,n,r){let i=Cc(n),a=new W;a.circle(6,6,Es*i),a.fill(G),a.circle(6,6,Es*i),a.stroke({width:Os*i,color:r}),a.circle(6,6,Ds*i),a.fill(zt),e.addChild(a);let o=new W,s=wc(t,n);s>0&&(o.circle(6,6,s),o.fill(wt)),e.addChild(o),e.__fillGraphics=o}function Ac(e,t){let n=e.__fillGraphics;n&&(n.clear(),t>0&&(n.circle(6,6,t),n.fill(wt)))}var jc=-12*.4,Mc=-12*.3,Nc=12*.8,Pc=12*.6,Fc=.4,Ic=.3,Lc=Math.PI/2,Rc=Math.PI/2;function zc(e,t,n){let r=(t-e)%(Math.PI*2);return r>Math.PI?r-=Math.PI*2:r<-Math.PI&&(r+=Math.PI*2),e+r*n}var Bc=12*.45,Vc=12*.6,Hc=12*.275,Uc=12*.2,Wc=.5;function Gc(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function Kc(e,t){let n=e.__towerFillGraphics;if(!n||(n.clear(),t<=0))return;let r=e.__towerFillRect;if(r){let e=r.heightMax*t,i=r.yMin+r.heightMax-e,a=Math.min(r.rx,r.width/2,e/2);n.roundRect(r.x,i,r.width,e,a),n.fill(wt);return}let i=.5,a=Pc*t;n.rect(jc+i,Mc+Pc-a+i,Nc-i*2,a-i*2),n.fill(wt)}var qc=0,Jc=-12*.1,Yc=12,Xc=12*1.2,Zc=[`energy`,`power`];function Qc(e){let t=typeof e.storeCapacity==`number`?e.storeCapacity:0;if(t===0||!e.store||typeof e.store!=`object`)return{bands:[],used:0,capacity:0,dominant:null};let n=e.store,r=[],i=null,a=0;for(let e in n){let t=n[e];typeof t==`number`&&t>0&&(r.push([e,t]),t>a&&(a=t,i=e))}r.sort(([e],[t])=>{let n=Zc.indexOf(e),r=Zc.indexOf(t);return(n===-1?99:n)-(r===-1?99:r)||(e<t?-1:+(e>t))});let o=0;return{bands:r.map(([e,t])=>(o+=t,{color:Un[e]??7105644,amount:t})),used:o,capacity:t,dominant:i}}function $c(e,t,n,r,i,a,o,s=0){if(i<=0||o<=0)return;let c=t+s,l=r-s*2,u=i-s*2,d=n-s;if(u<=0)return;if(!a||a.length===0){e.rect(c,d-u,l,u),e.fill(wt);return}let f=d;for(let t of a){let n=u*(t.amount/o);n>0&&(e.rect(c,f-n,l,n),e.fill(t.color)),f-=n}}function el(e,t){if(!e||e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n].color!==t[n].color||e[n].amount!==t[n].amount)return!1;return!0}function tl(e,t){return t<=0||e<=0?0:Vc*Math.min(1,e/t)}function nl(e,t){let n=e.__containerFillG;n&&(n.clear(),$c(n,Hc,Uc+Vc,Bc,t,e.__containerBands,e.__containerUsed??0,Wc))}function rl(e,t){return t<=0||e<=0?0:Xc*Math.min(1,e/t)}function il(e,t){let n=e.__storageFillG;n&&(n.clear(),$c(n,qc,Jc+Xc,Yc,t,e.__storageBands,e.__storageUsed??0))}function al(e){return Un[e]??7105644}function q(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function ol(e,t){return oc*q(e,t)}var sl=12*.35;function cl(e,t){let n=e.__terminalFillG;if(n&&(n.clear(),t>0)){let r=sl*t;n.rect(6-r,6-r,r*2,r*2),n.fill(e.__terminalFillColor??16771195)}}var ll=16777215,ul=.55,dl=[[[0,-.65],[-.45,-.45],[.45,-.45]],[[.65,0],[.45,-.45],[.45,.45]],[[0,.65],[.45,.45],[-.45,.45]],[[-.65,0],[-.45,.45],[-.45,-.45]]];function fl(e,t,n){for(let r of dl)e.poly(dc(t,n,r)),e.fill({color:ll,alpha:ul})}var pl=12*.025,ml=12*.36,hl=12*.05,gl=12*.8,_l=12*.9,vl=12*.25,yl=2e3,bl=3e3,xl=16777215,Sl=12*.55,Cl=12*.16,wl=12*.07,Tl=.22,El=.5;function Dl(e,t,n){e.circle(t,n,Sl),e.stroke({width:Cl,color:xl,alpha:Tl}),e.circle(t,n,Sl),e.stroke({width:wl,color:xl,alpha:El})}var Ol=12*.45,kl=919304,Al=2758168,jl=12*.06,Ml=14830150,Nl=12*.17,Pl=12*.085,Fl=2600,Il=12*.1,Ll=12*.42,Rl=.6,zl=null;function Bl(){if(zl)return zl;let e=document.createElement(`canvas`);e.width=e.height=128;let t=e.getContext(`2d`),n=t.createRadialGradient(64,64,0,64,64,64);return n.addColorStop(0,`rgba(255,255,255,1)`),n.addColorStop(.45,`rgba(255,255,255,0.72)`),n.addColorStop(.75,`rgba(255,255,255,0.22)`),n.addColorStop(1,`rgba(255,255,255,0)`),t.fillStyle=n,t.fillRect(0,0,128,128),zl=Ze.from(e),zl}function Vl(e){return typeof e.cooldownTime==`number`?e.cooldownTime:0}function Hl(e){let t=e.store&&typeof e.store==`object`?e.store:{},n=e.storeCapacityResource&&typeof e.storeCapacityResource==`object`?e.storeCapacityResource:{},r=typeof t.energy==`number`?t.energy:0,i=typeof n.energy==`number`?n.energy:yl,a=null,o=0;for(let e in t){if(e===`energy`)continue;let n=t[e];typeof n==`number`&&n>o&&(o=n,a=e)}let s=a&&typeof n[a]==`number`?n[a]:bl;return{energy:r,energyCap:i,mineralType:a,mineral:o,mineralCap:s}}function Ul(e,t,n){let r=e.__labMineralG;r&&(r.clear(),n>0)&&(r.circle(6,6-pl,ml*n),r.fill(e.__labMineralColor??7105644));let i=e.__labEnergyG;if(i&&(i.clear(),t>0)){let e=.5;i.rect(hl+e,gl+e,(_l-e*2)*t,vl-e*2),i.fill(wt)}}var Wl=3e5,Gl=5e3,Kl=-.8,ql=.2,Jl=.4,Yl=-.34,Xl=.34,Zl=.27,Ql=.45;function $l(e){let t=e.store&&typeof e.store==`object`?e.store:{},n=e.storeCapacityResource&&typeof e.storeCapacityResource==`object`?e.storeCapacityResource:{};return{energy:typeof t.energy==`number`?t.energy:0,energyCap:typeof n.energy==`number`?n.energy:typeof e.storeCapacity==`number`?e.storeCapacity:Wl,ghodium:typeof t.G==`number`?t.G:0,ghodiumCap:typeof n.G==`number`?n.G:Gl}}function eu(e,t,n){let r=e.__nukerEnergyG;if(r&&(r.clear(),t>0)){let e=ql-Kl,n=ql-e*t,i=Jl*(n-Kl)/e;r.poly([6+i*12,6+n*12,6+Jl*12,6+ql*12,6-Jl*12,6+ql*12,6-i*12,6+n*12]),r.fill(wt)}let i=e.__nukerGhodiumG;if(i&&(i.clear(),n>0)){let e=6+Yl*12,t=6+Zl*12,r=(Xl-Yl)*12,a=(Ql-Zl)*12;i.rect(e,t,r*n,a),i.fill(al(`G`))}}var tu=100,nu=12*.51,ru=12*.12;function iu(e){let t=e.store&&typeof e.store==`object`?e.store:{},n=e.storeCapacityResource&&typeof e.storeCapacityResource==`object`?e.storeCapacityResource:{};return{power:typeof t.power==`number`?t.power:0,powerCap:typeof n.power==`number`?n.power:tu}}function au(e,t){if(e.clear(),!(t<=0)){if(t>=1)e.circle(6,6,nu);else{let n=-Math.PI/2,r=n+t*Math.PI*2;e.moveTo(6+nu*Math.cos(n),6+nu*Math.sin(n)),e.arc(6,6,nu,n,r)}e.stroke({width:ru,color:_t})}}function ou(e,t){e.__powerSpawnPowerG&&au(e.__powerSpawnPowerG,t)}var su=5e3,cu=12/100,lu=1.2000000000000002,uu=3346705,du=6710886,fu=2e3,pu=15998771,mu=13832226,hu=9240589,gu=[-45,-75,45,-75,75,-45,75,45,45,75,-45,75,-75,45,-75,-45];function _u(e){if(typeof e.power==`number`)return e.power;let t=e.store&&typeof e.store==`object`?e.store:{};return typeof t.power==`number`?t.power:0}function vu(e){return Math.sqrt(Math.max(0,e)/su*3e3/Math.PI)*1.5*cu}function yu(e){let t=e%fu/fu;return t<1/3?Xs(pu,mu,t*3):t<2/3?Xs(mu,hu,(t-1/3)*3):Xs(hu,pu,(t-2/3)*3)}function bu(e,t,n){if(e.clear(),t<=0)return;let r=t*(.8+.2*Math.cos(n%fu/fu*2*Math.PI));e.circle(6,6,r),e.fill(yu(n)),e.circle(6,6,r),e.stroke({width:lu,color:hu})}var xu=8,Su=12*.4,Cu=12*.5,wu=.22,Tu=12*.25,Eu=12*.32,Du=12*.24,Ou=12*.28,ku=12*.38,Au=12*.36,ju=5,Mu=16777215;function Nu(){let e=2*Math.PI/xu,t=[];for(let n=0;n<xu;n++){let r=-Math.PI/2+n*e,i=r-wu,a=r+wu,o=r-e+wu;for(let e=0;e<=3;e++){let n=o+(i-o)*(e/3);t.push(6+Su*Math.cos(n),6+Su*Math.sin(n))}for(let e=0;e<=3;e++){let n=i+(a-i)*(e/3);t.push(6+Cu*Math.cos(n),6+Cu*Math.sin(n))}}return t}var Pu=Nu();function Fu(e){return typeof e.cooldown==`number`&&e.cooldown>0}function Iu(e,t){e.clear(),e.poly(Pu),e.fill(G),e.poly(Pu),e.stroke({width:12*.06,color:t})}function Lu(e,t){e.clear();let n=.14,r=2*Math.PI/ju-n;for(let i=0;i<ju;i++){let a=-Math.PI/2+i*(2*Math.PI/ju)+n/2,o=a+r;e.moveTo(6+Tu*Math.cos(a),6+Tu*Math.sin(a)),e.arc(6,6,Eu,a,o),e.arc(6,6,Tu,o,a,!0),e.closePath(),e.fill(i<t?zt:St)}}function Ru(e,t){return t<=0||e<=0?0:Ou*Math.min(1,e/t)}function zu(e,t){let n=e.__factoryFillG;n&&(n.clear(),$c(n,ku,Au+Ou,Du,t,e.__factoryBands,e.__factoryUsed??0,.5))}var Bu=12*.65,Vu=Bu,Hu=12*.42;function Uu(e,t,n,r,i,a,o,s){e.clear();let c=.1,l=2*Math.PI/8-c;for(let u=0;u<8;u++){let d=-Math.PI/2+u*(2*Math.PI/8)+c/2,f=d+l,p=t+i*Math.cos(d),m=n+i*Math.sin(d);if(u<a)e.moveTo(p,m),e.arc(t,n,r,d,f),e.arc(t,n,i,f,d,!0),e.closePath(),e.fill({color:14540253,alpha:.9});else if(u===a&&s>0){if(e.moveTo(p,m),e.arc(t,n,r,d,f),e.arc(t,n,i,f,d,!0),e.closePath(),e.fill({color:1973790,alpha:.85}),o>0){let a=d+l*Math.min(1,o/s);e.moveTo(p,m),e.arc(t,n,r,d,a),e.arc(t,n,i,a,d,!0),e.closePath(),e.fill({color:14540253,alpha:.9})}}else e.moveTo(p,m),e.arc(t,n,r,d,f),e.arc(t,n,i,f,d,!0),e.closePath(),e.fill({color:1973790,alpha:.6})}}function Wu(e,t,n,r){let i=e.__ctrlSegSprites;if(i)for(let e=0;e<i.length;e++)e<t?i[e].alpha=1:e===t&&r>0?i[e].alpha=Math.max(.15,n/r):i[e].alpha=.15}function Gu(e,t){let n=e.user;return typeof n!=`string`||!t?!1:n!==t}var Ku=`2`,qu=`3`;function Ju(e,t){let n=typeof e.user==`string`?e.user:void 0;return n?n===Ku||t?.[n]?.username===`Invader`?`Invader`:n===qu||t?.[n]?.username===`Source Keeper`?`Source Keeper`:null:null}function Yu(e,t){return(e.type===`creep`?e.spawning?-1:100:e.type===`flag`?200:0)+(e.type===`flag`?t?.flag?.zIndex??0:e.type===`controller`?t?.controller?.zIndex??0:e.type===`tombstone`?t?.tombstone?.zIndex??0:e.type===`mineral`?t?.mineral?.zIndex??0:e.type===`extractor`?tc:t?.sprites[e.type]?.zIndex??0)}function Xu(e,t=!0,n,r,i,a,o,s){let c=new ze,l=new W,u=xc(e.type),d=typeof e.user==`string`?e.user:void 0,f=d!==void 0&&n!==void 0&&d!==n?Gn:Sn;switch(e.type){case`creep`:{if(Ju(e,a)){_c(c);break}let t=2*Math.PI,r=new ze;r.position.set(6,6),r.rotation=-Math.PI/2;let o=Gu(e,n);if(o){let e=new W;e.circle(0,0,us+.75),e.stroke({width:1.5,color:Gn}),r.addChild(e)}let s=new W;s.circle(0,0,us),s.fill(On),r.addChild(s);let l=e.body??[],u=0,d=0,f=0,p=[],m={};for(let e of l)e.type===`work`?u++:e.type===`move`?d++:(m[e.type]===void 0&&(p.push(e.type),m[e.type]=0),m[e.type]++,f++);let h=u/fs*t,g=d/fs*t,_=f/fs*t,v=h/2,y=v+_/2,b=Math.PI-g/2,x=Math.PI+g/2,S=t-h/2-_/2,C=t-h/2,w=new W;h>0&&fc(w,-h/2,v,Fn.work??16770413);let T=v;for(let e of p){let n=(m[e]??0)/fs*t/2;fc(w,T,T+n,Fn[e]??7829367),T+=n}fc(w,y,b,rn),g>0&&fc(w,b,x,Fn.move??11122630),fc(w,x,S,rn);let E=C;for(let e of p){let n=(m[e]??0)/fs*t/2;fc(w,E-n,E,Fn[e]??7829367),E-=n}r.addChild(w);let D=new W;D.circle(0,0,ds),D.fill(Rn),r.addChild(D);let O=typeof e.user==`string`?e.user:void 0,k=O?a?.[O]?.badge:void 0;if(k&&i){let e=new Ge;e.anchor.set(.5,.5);let t=ds*2;e.width=t,e.height=t,e.rotation=Math.PI/2,r.addChild(e),c.__creepBadgeSprite=e,i.getOrCreate(k).then(t=>{e.destroyed||(e.texture=t)}).catch(()=>{})}else if(o){let e=new W;e.circle(0,0,ds*.82),e.fill({color:Gn,alpha:.9}),r.addChild(e),c.__creepForeignMark=e}let{used:A,capacity:j}=vc(e),ee=yc(A,j),M=new W;ee>0&&(M.circle(0,0,ee),M.fill(Mn)),r.addChild(M),c.__creepFillGraphics=M,c.__creepUsed=A,c.__creepCapacity=j;let te=(us+ds)/2,ne=(us-ds)*.45,re=new W;re.moveTo(us,0),re.lineTo(te,-ne),re.lineTo(te,ne),re.closePath(),re.fill(vn),r.addChild(re),c.addChild(r),c.__bodyContainer=r;break}case`extension`:{let{energy:t,capacity:n}=Sc(e);kc(c,t,n,f),c.__extEnergy=t,c.__extCapacity=n;break}case`spawn`:{let t=12*.65;l.circle(6,6,t),l.fill(G),c.sortableChildren=!0;let n=c,r=typeof e.user==`string`?e.user:void 0,o=r?a?.[r]?.badge:void 0;if(o&&i){let e=new Ge;e.anchor.set(.5,.5),e.width=t*2,e.height=t*2,e.position.set(6,6),e.zIndex=1;let r=new W;r.circle(6,6,t),r.fill(16777215),e.mask=r,c.addChild(e),c.addChild(r),n.__spawnBadgeSprite=e,i.getOrCreate(o).then(t=>{e.destroyed||(e.texture=t)}).catch(()=>{})}let{energy:s,capacity:u}=Sc(e),d=new W;d.zIndex=2,c.addChild(d),n.__fillGraphics=d,Ac(n,ol(s,u)),n.__spawnEnergy=s,n.__spawnCapacity=u;let f=new W;f.circle(6,6,t),f.stroke({width:12*.1,color:13421772}),f.zIndex=3,c.addChild(f);let p=new W;p.zIndex=4;let m=sc(e,0),h=m?lc(m.needTime,m.endTime,0):null;uc(p,h),c.addChild(p),n.__spawnRing=p,n.__spawnRatio=h,m&&(n.__spawnNeedTime=m.needTime,n.__spawnEndTime=m.endTime),n.__spawnSig=cc(e);break}case`powerSpawn`:{l.circle(6,6,12*.65),l.fill(G),l.circle(6,6,12*.65),l.stroke({width:12*.1,color:_t}),l.circle(6,6,12*.4),l.fill(wt),c.sortableChildren=!0;let t=new W;t.zIndex=1;let{power:n,powerCap:r}=iu(e);au(t,q(n,r)),c.addChild(t);let i=c;i.__powerSpawnPowerG=t,i.__powerSpawnPower=n,i.__powerSpawnPowerCap=r;break}case`source`:{let{energy:t,capacity:n}=Ws(e),r=zs(t,n),i=new W;Hs(i,r,performance.now()),c.addChild(i),c.__sourceGraphics=i,c.__sourceEnergy=t,c.__sourceCapacity=n,c.__sourceSize=r;break}case`constructionSite`:{let t=typeof e.user==`string`?e.user:void 0,r=t!==void 0&&t===n,i=r?wn:An,a=r?Bn:Ln,o=r?ln:sn,s=typeof e.progress==`number`?e.progress:0,l=typeof e.progressTotal==`number`?e.progressTotal:1,u=new W;c.addChild(u),c.__csBuildGlow=u;let d=new W;rc(d,6,6,qs,s,l,i),c.addChild(d),c.__csFillGraphics=d;let f=new W;Zs(f,i),c.addChild(f),c.__csRingGraphics=f,c.__csProgress=s,c.__csProgressTotal=l,c.__csUser=t,c.__csColor=i,c.__csColorDark=a,c.__csColorLight=o;break}case`mineral`:{let t=typeof e.mineralType==`string`?e.mineralType:`?`,n=o?.mineral;if(n&&s){let e=`mineral/${t}`,r=12*n.tileScale,i=(e,t)=>{e.texture=t,e.width=r,e.height=r},a=new Ge;a.anchor.set(.5,.5),a.x=6,a.y=6,c.addChild(a);let l=s.getTexture(o.atlasUrl,e);l?i(a,l):s.getOrLoad(o.atlasUrl).then(t=>{a.destroyed||i(a,t.textures[e]??Ze.EMPTY)}).catch(()=>{})}else{let e=Un[t]??7979263,n=ks[t]??16777215,r=new W;r.circle(6,6,js),r.fill(e),c.addChild(r);let i=new Je({text:t,style:{fontSize:Ms,fill:n,fontWeight:`bold`}});i.anchor.set(.5,.5),i.scale.set(Ns),i.position.set(6,6),c.addChild(i)}break}case`deposit`:{let t=typeof e.depositType==`string`?e.depositType:void 0,n=o?.deposit;if(t&&n&&s){let e=12*n.tileScale,r=(t,n)=>{t.texture=n,t.width=e,t.height=e},i=fn[t];for(let e of[`deposit/${t}/shape`,`deposit/${t}/fill`]){let t=e.endsWith(`/fill`),n=new Ge;n.anchor.set(.5,.5),n.x=6,n.y=6,i!==void 0&&(n.tint=i),t&&(n.alpha=As),c.addChild(n);let a=s.getTexture(o.atlasUrl,e);a?r(n,a):s.getOrLoad(o.atlasUrl).then(t=>{n.destroyed||r(n,t.textures[e]??Ze.EMPTY)}).catch(()=>{})}break}l.rect(2,2,8,8),l.fill(u),c.addChild(l);break}case`controller`:{let t=typeof e.level==`number`?e.level:0,n=typeof e.progress==`number`?e.progress:0,r=typeof e.progressTotal==`number`?e.progressTotal:0,l=e.reservation,u=typeof e.user==`string`?e.user:typeof l?.user==`string`?l.user:void 0,d=u?a?.[u]?.badge:void 0,f=o?.controller;if(f&&s){let e=12*f.tileScale,i=e/600,a=new Ge;a.anchor.set(.5,.5),a.x=6,a.y=6,a.width=e,a.height=e,c.addChild(a);let l=[];for(let e=0;e<8;e++){let t=new Ge;t.anchor.set(.5,.5),t.x=6,t.y=6,t.scale.set(i),t.rotation=Math.PI/4*e,c.addChild(t),l.push(t)}c.__ctrlSegSprites=l,Wu(c,t,n,r);let u=()=>s.getOrLoad(o.atlasUrl),d=s.getTexture(o.atlasUrl,f.backgroundFrame);d?a.texture=d:u().then(e=>{a.destroyed||(a.texture=e.textures[f.backgroundFrame]??Ze.EMPTY)}).catch(()=>{});let p=s.getTexture(o.atlasUrl,f.segmentFrame);if(p)for(let e of l)e.texture=p;else u().then(e=>{let t=e.textures[f.segmentFrame]??Ze.EMPTY;for(let e of l)e.destroyed||(e.texture=t)}).catch(()=>{})}else{let e=new W,i=[];for(let e=0;e<8;e++){let t=-Math.PI/2+e*Math.PI/4;i.push(6+Bu*Math.cos(t),6+Bu*Math.sin(t))}e.poly(i),e.fill(2238513),e.poly(i),e.stroke({width:12*.07,color:8027781}),c.addChild(e);let a=new W;Uu(a,6,6,Vu,Hu,t,n,r),c.addChild(a),c.__ctrlSegGraphics=a}c.__ctrlLevel=t,c.__ctrlProgress=n,c.__ctrlProgressTotal=r,c.__ctrlDowngradeTime=typeof e.downgradeTime==`number`?e.downgradeTime:void 0,c.__ctrlUserId=u;let p=new W;if(d?(p.circle(6,6,Hu),p.fill(G)):(p.circle(6,6,Hu),p.fill(3028031),p.circle(6,6,Hu),p.stroke({width:12*.04,color:8027781}),p.circle(6,6,12*.16),p.fill(10133672)),c.addChild(p),d&&i){let e=new Ge;e.anchor.set(.5,.5),e.width=Hu*2,e.height=Hu*2,e.position.set(6,6);let t=new W;t.circle(6,6,Hu),t.fill(16777215),c.addChild(e),e.mask=t,c.addChild(t),i.getOrCreate(d).then(t=>{e.destroyed||(e.texture=t)}).catch(()=>{})}break}case`energy`:l.circle(6,6,12*.2),l.fill(wt);break;case`road`:break;case`constructedWall`:break;case`rampart`:break;case`tower`:{let{energy:t,capacity:n}=Sc(e),r=o?.tower;if(r&&s){let e=12*r.tileScale,i=new Ge;i.anchor.set(.5,.5),i.position.set(6,6),i.tint=f,c.addChild(i);let a=new ze;a.position.set(6,6),c.addChild(a);let l=new Ge;l.anchor.set(.5,.5),a.addChild(l);let u=new W;a.addChild(u),c.__barrelContainer=a,c.__towerFillGraphics=u,c.__towerEnergy=t,c.__towerCapacity=n;let d=a=>{let o=a.orig?.width||a.width,s=o>0?e/o:1;i.scale.set(s),l.scale.set(s),c.__towerFillRect={x:r.fill.x*s,yMin:r.fill.yMin*s,width:r.fill.width*s,heightMax:r.fill.heightMax*s,rx:r.fill.rx*s,ry:r.fill.ry*s},Kc(c,Gc(t,n))},p=s.getTexture(o.atlasUrl,r.ringFrame),m=s.getTexture(o.atlasUrl,r.bodyFrame);p&&m?(i.texture=p,l.texture=m,d(m)):s.getOrLoad(o.atlasUrl).then(e=>{if(i.destroyed||(i.texture=e.textures[r.ringFrame]??Ze.EMPTY),!l.destroyed){let t=e.textures[r.bodyFrame]??Ze.EMPTY;l.texture=t,c.destroyed||d(t)}}).catch(()=>{});break}let i=new W;i.circle(6,6,12*.6),i.fill(G),i.circle(6,6,12*.6),i.stroke({width:12*.05,color:f}),c.addChild(i);let a=new ze;a.position.set(6,6);let l=new W;l.rect(jc,Mc,Nc,Pc),l.fill(G),a.addChild(l);let u=new W;a.addChild(u),c.__towerFillGraphics=u,c.__towerEnergy=t,c.__towerCapacity=n,Kc(c,Gc(t,n));let d=new W;d.rect(jc,Mc,Nc,Pc),d.stroke({width:1,color:St}),a.addChild(d);let p=new W;p.rect(-12*.2,-12*.9,12*.4,12*.5),p.fill(zt),p.rect(-12*.2,-12*.9,12*.4,12*.5),p.stroke({width:12*.07,color:G}),a.addChild(p),c.addChild(a),c.__barrelContainer=a;break}case`storage`:{let t=o?.sprites.storage;if(t&&s){let{bands:n,used:r,capacity:i}=Qc(e),a=12*t.tileScale,l=(e,t)=>{e.texture=t,e.width=a,e.height=a};for(let e of t.layers){let t=new Ge;t.anchor.set(.5,.5),t.x=6,t.y=6,e.tint===`owner`&&(t.tint=f),c.addChild(t);let n=s.getTexture(o.atlasUrl,e.frame);n?l(t,n):s.getOrLoad(o.atlasUrl).then(n=>{t.destroyed||l(t,n.textures[e.frame]??Ze.EMPTY)}).catch(()=>{})}let u=new W;c.addChild(u),c.__storageFillG=u,c.__storageBands=n,c.__storageUsed=r,c.__storageCapacity=i,il(c,rl(r,i));break}let{bands:n,used:r,capacity:i}=Qc(e),a=dc(6,6,[[-.6,-.7],[0,-.8],[.6,-.7],[.65,0],[.6,.7],[0,.8],[-.6,.7],[-.65,0],[-.6,-.7]]);l.poly(a),l.fill(G),l.poly(a),l.stroke({width:12*.05,color:f}),l.rect(6-12*.5,6-12*.6,12,12*1.2),l.fill(St),c.addChild(l);let u=new W;c.addChild(u),c.__storageFillG=u,c.__storageBands=n,c.__storageUsed=r,c.__storageCapacity=i,il(c,rl(r,i));let d=new W;d.rect(6-12*.5,6-12*.6,12,12*1.2),d.stroke({width:12*.1,color:G}),c.addChild(d);break}case`terminal`:{let t=dc(6,6,[[0,-.8],[.55,-.55],[.8,0],[.55,.55],[0,.8],[-.55,.55],[-.8,0],[-.55,-.55],[0,-.8]]),n=dc(6,6,[[0,-.65],[.45,-.45],[.65,0],[.45,.45],[0,.65],[-.45,.45],[-.65,0],[-.45,-.45],[0,-.65]]);l.poly(t),l.fill(G),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(zt),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.fill(St),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.stroke({width:12*.1,color:G}),c.addChild(l);let{used:r,capacity:i,dominant:a}=Qc(e),o=new W;c.addChild(o);let s=c;s.__terminalFillG=o,s.__terminalDominant=a??void 0,s.__terminalFillColor=a?al(a):wt,s.__terminalUsed=r,s.__terminalCapacity=i,cl(s,q(r,i));let u=new W;fl(u,6,6),u.alpha=0,c.addChild(u),s.__terminalCooldownG=u,s.__terminalCooldownTime=Vl(e);break}case`link`:{let t=dc(6,6,[[0,-.5],[.4,0],[0,.5],[-.4,0],[0,-.5]]),n=dc(6,6,[[0,-.3],[.25,0],[0,.3],[-.25,0],[0,-.3]]);l.poly(t),l.fill(G),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(St),c.addChild(l);let{energy:r,capacity:i}=Sc(e),a=new W;c.addChild(a);let o=c;o.__linkFillGraphics=a,o.__linkEnergy=r,o.__linkCapacity=i,Oc(o,Dc(r,i));break}case`lab`:{let t=6-12*.025;l.circle(6,t,12*.55),l.fill(G),l.circle(6,t,12*.55),l.stroke({width:12*.05,color:f}),l.circle(6,t,12*.4),l.fill(St),c.addChild(l);let{energy:n,energyCap:r,mineralType:i,mineral:a,mineralCap:o}=Hl(e),s=new W;c.addChild(s);let u=new W;u.rect(6-12*.45,9.6,12*.9,12*.25),u.fill(G),u.poly(dc(6,6,[[-.45,.3],[-.45,.55],[.45,.55],[.45,.3]])),u.stroke({width:12*.05,color:f}),c.addChild(u);let d=new W;c.addChild(d);let p=c;p.__labMineralG=s,p.__labEnergyG=d,p.__labMineralType=i??void 0,p.__labMineralColor=i?al(i):void 0,p.__labEnergy=n,p.__labEnergyCap=r,p.__labMineral=a,p.__labMineralCap=o,Ul(p,q(n,r),q(a,o));let m=new W;Dl(m,6,t),m.alpha=0,c.addChild(m),p.__labCooldownG=m,p.__labCooldownTime=Vl(e);break}case`container`:{let{bands:t,used:n,capacity:r}=Qc(e);l.rect(Hc,Uc,Bc,Vc),l.fill(G),l.rect(Hc+Wc,Uc+Wc,Bc-Wc*2,Vc-Wc*2),l.fill(St),c.addChild(l);let i=new W;c.addChild(i),c.__containerFillG=i,c.__containerBands=t,c.__containerUsed=n,c.__containerCapacity=r,nl(c,tl(n,r));let a=new W;a.rect(Hc,Uc,Bc,Vc),a.stroke({width:12*.1,color:G}),c.addChild(a);break}case`observer`:l.circle(6,6,12*.45),l.fill(G),l.circle(6,6,12*.45),l.stroke({width:12*.05,color:f}),l.circle(8.7,6,12*.2),l.fill(f);break;case`nuker`:{let t=dc(6,6,[[0,-1],[-.47,.2],[-.5,.5],[.5,.5],[.47,.2],[0,-1]]),n=dc(6,6,[[0,-.8],[-.4,.2],[.4,.2],[0,-.8]]);l.poly(t),l.fill(G),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(St),l.poly(n),l.stroke({width:12*.01,color:f}),c.addChild(l);let{energy:r,energyCap:i,ghodium:a,ghodiumCap:o}=$l(e),s=new W;c.addChild(s);let u=new W;c.addChild(u);let d=c;d.__nukerEnergyG=s,d.__nukerGhodiumG=u,d.__nukerEnergy=r,d.__nukerEnergyCap=i,d.__nukerGhodium=a,d.__nukerGhodiumCap=o,eu(d,q(r,i),q(a,o));break}case`factory`:{let t=typeof e.level==`number`?e.level:0,{bands:n,used:r,capacity:i}=Qc(e),a=new W;Iu(a,f),c.addChild(a),l.rect(ku,Au,Du,Ou),l.fill(St),c.addChild(l);let o=new W;Lu(o,t),c.addChild(o);let s=new W;c.addChild(s);let u=c;u.__factoryGearG=a,u.__factoryRingG=o,u.__factoryFillG=s,u.__factoryBands=n,u.__factoryUsed=r,u.__factoryCapacity=i,u.__factoryLevel=t,u.__factoryCooldownEnd=Vl(e),u.__factoryGlowColor=f,zu(u,Ru(r,i));break}case`extractor`:{let t=new W;t.position.set(6,6),nc(t,d===void 0?Kt:f),c.addChild(t);let n=c;n.__extractorRing=t,n.__extractorActive=Fu(e);break}case`invaderCore`:l.circle(6,6,12*.45),l.fill(G),l.circle(6,6,12*.45),l.stroke({width:12*.05,color:f}),l.circle(6,6,12*.35),l.fill(St);break;case`flag`:{let n=typeof e.color==`number`?e.color:0,r=typeof e.secondaryColor==`number`?e.secondaryColor:0,i=En[n]??En[0],a=En[r]??En[0],u=o?.flag;if(u&&s){let e=12*u.tileScale,t=()=>s.getOrLoad(o.atlasUrl),l=(t,n)=>{t.texture=n,t.width=e,t.height=e},d=new Ge;d.anchor.set(.5,.5),d.x=6,d.y=6,d.tint=i,c.addChild(d);let f=s.getTexture(o.atlasUrl,u.mainFrame);if(f?l(d,f):t().then(e=>{d.destroyed||l(d,e.textures[u.mainFrame]??Ze.EMPTY)}).catch(()=>{}),r!==n){let e=new Ge;e.anchor.set(.5,.5),e.x=6,e.y=6,e.tint=a,c.addChild(e);let n=s.getTexture(o.atlasUrl,u.secondFrame);n?l(e,n):t().then(t=>{e.destroyed||l(e,t.textures[u.secondFrame]??Ze.EMPTY)}).catch(()=>{})}}else{l.rect(5.28,1.5,1.44,12.599999999999998),l.fill(8947848);let e=6.720000000000001,t=14.820000000000002,n=10.92/2,r=n;l.moveTo(e,1.5),l.lineTo(t,n),l.lineTo(e,r),l.closePath(),l.fill(i),l.moveTo(e,r),l.lineTo(t,n),l.lineTo(e,9.42),l.closePath(),l.fill(a),c.addChild(l)}if(c.__flagColor=n,c.__flagSecondaryColor=r,typeof e.name==`string`){let n=new Je({text:e.name,style:{fontSize:ps,fill:16777215}});n.scale.set(ms),n.anchor.set(.5,0),n.x=6,n.y=12.600000000000001,n.visible=t,c.__nameLabel=n,c.addChild(n)}break}case`ruin`:{let t=typeof e.user==`string`?e.user:void 0,r=t!==void 0&&t===n?wn:Gn,i=12*.42,a=Math.PI/5,o=new W;for(let e=0;e<6;e++){let t=e*Math.PI*2/6,n=t-a/2,s=t+a/2,c=6+i*Math.cos(n),l=6+i*Math.sin(n);o.moveTo(c,l),o.arc(6,6,i,n,s),o.stroke({width:12*.09,color:r,alpha:.75,cap:`round`})}c.addChild(o);let s=12*.18,l=new W;l.moveTo(6-s,6-s),l.lineTo(8.16,8.16),l.moveTo(8.16,6-s),l.lineTo(6-s,8.16),l.stroke({width:12*.11,color:r,cap:`round`}),c.addChild(l);break}case`tombstone`:{let t=typeof e.user==`string`?e.user:void 0,r=t!==void 0&&t===n?wn:Gn,i=o?.tombstone;if(i&&s){let e=12*i.tileScale,t=()=>s.getOrLoad(o.atlasUrl),n=new Ge;n.anchor.set(.5,.5),n.x=6,n.y=6,n.width=e,n.height=e,c.addChild(n);let a=new Ge;a.anchor.set(.5,.5),a.x=6,a.y=6,a.width=e,a.height=e,a.tint=r,c.addChild(a);let l=s.getTexture(o.atlasUrl,i.shellFrame);l?n.texture=l:t().then(e=>{n.destroyed||(n.texture=e.textures[i.shellFrame]??Ze.EMPTY)}).catch(()=>{});let u=s.getTexture(o.atlasUrl,i.crossFrame);u?a.texture=u:t().then(e=>{a.destroyed||(a.texture=e.textures[i.crossFrame]??Ze.EMPTY)}).catch(()=>{})}else{let e=12*.62,t=6-e/2,n=e/2,i=new W;i.moveTo(t,4.8),i.arc(6,4.8,n,Math.PI,0,!1),i.lineTo(9.719999999999999,10.92),i.lineTo(t,10.92),i.closePath(),i.fill(G),i.moveTo(t,4.8),i.arc(6,4.8,n,Math.PI,0,!1),i.lineTo(9.719999999999999,10.92),i.lineTo(t,10.92),i.closePath(),i.stroke({width:12*.07,color:r,alpha:.9}),c.addChild(i);let a=12*.18,o=new W;o.moveTo(6-a,6-a*.6),o.lineTo(8.16,7.296),o.moveTo(8.16,6-a*.6),o.lineTo(6-a,7.296),o.stroke({width:12*.09,color:r,cap:`round`}),c.addChild(o)}break}case`powerBank`:{let t=new W,n=[];for(let e=0;e<gu.length;e+=2)n.push(6+gu[e]*cu,6+gu[e+1]*cu);t.poly(n),t.fill(uu),t.poly(n),t.stroke({width:lu,color:du}),c.addChild(t);let r=_u(e),i=vu(r),a=new W;bu(a,i,performance.now()),c.addChild(a);let o=c;o.__powerBankEllipseG=a,o.__powerBankPower=r,o.__powerBankRadius=i;break}case`keeperLair`:{l.circle(6,6,Ol),l.fill(kl),l.circle(6,6,Ol),l.stroke({width:jl,color:Al}),c.addChild(l);let t=new Ge(Bl());t.anchor.set(.5),t.position.set(6,6),t.tint=Ml,t.alpha=0,t.width=t.height=Il*2,c.addChild(t);let n=new W;n.circle(6,6,Nl),n.fill(Ml),n.circle(6,6,Pl),n.fill(kl),c.addChild(n);let r=c;r.__keeperGlow=t,r.__keeperPhase=(e.x*31+e.y*17)%97/97;break}default:l.rect(1,1,10,10),l.fill(u)}if(e.type!==`extension`&&e.type!==`road`&&e.type!==`creep`&&e.type!==`tower`&&e.type!==`controller`&&e.type!==`flag`&&e.type!==`source`&&e.type!==`constructionSite`&&e.type!==`mineral`&&e.type!==`tombstone`&&e.type!==`ruin`&&e.type!==`storage`&&e.type!==`constructedWall`&&e.type!==`rampart`&&e.type!==`container`&&e.type!==`deposit`&&e.type!==`link`&&e.type!==`terminal`&&e.type!==`lab`&&e.type!==`nuker`&&e.type!==`factory`&&e.type!==`powerBank`&&e.type!==`keeperLair`&&c.addChild(l),e.type===`creep`&&typeof e.name==`string`){let r=Gu(e,n),i;if(r){let t=typeof e.user==`string`?e.user:void 0;i=Ju(e,a)??(t?a?.[t]?.username??t:`Hostile`)}else i=e.name;let o=new Je({text:i,style:{fontSize:ps,fill:r?Gn:16777215}});o.scale.set(ms),o.anchor.set(.5,1),o.x=6,o.y=hs-gs,o.visible=t,c.__nameLabel=o,c.addChild(o)}return c.zIndex=Yu(e,o),c.position.set(e.x*12,e.y*12),c}function Zu(e){e.destroy({children:!0})}function Qu(e){let t=new Je({text:e.length>Cs?e.slice(0,Cs):e,style:{fontSize:ps,fill:Ts,fontWeight:`600`}});t.scale.set(_s),t.anchor.set(.5,.5);let n=t.width,r=t.height,i=n+vs*2,a=r+ys*2,o=a/2,s=new W;s.roundRect(-i/2,-a/2,i,a,o),s.fill(ws),s.roundRect(-i/2,-a/2,i,a,o),s.stroke({width:.4,color:1118481,alpha:.55}),s.moveTo(-2,a/2-.1),s.lineTo(0,a/2+xs),s.lineTo(bs,a/2-.1),s.closePath(),s.fill(ws),s.moveTo(-2,a/2-.1),s.lineTo(0,a/2+xs),s.lineTo(bs,a/2-.1),s.stroke({width:.4,color:1118481,alpha:.55});let c=new ze;return c.addChild(s),c.addChild(t),c.pivot.set(0,a/2+xs),c}var $u=class{container;objects=new Map;rawObjects=new Map;roadGraphics;rampartGraphics;rampartGlowGraphics;wallGraphics;wallMarkGraphics;ticker=null;tickerCallback=null;fillAnimations=new Map;buildGlowAnimations=new Map;ctrlFlashAnimations=new Map;currentGameTime=0;sayBubbles=new Set;moveDuration=600;tickMs=2e3;lastTickAt=0;EXT_ANIM_DURATION=300;instantMode=!1;lastWorldScale=1;showLabels;currentUserId;badge;badgeCache=ls;users;activeTheme=null;atlasCache=null;roadColor=bt;wallColor=G;lighting=null;constructor(e,t=!0,n,r,i){this.showLabels=t,this.currentUserId=n,this.badge=r,this.users=i,this.container=new ze,this.container.sortableChildren=!0,this.wallGraphics=new W,this.wallGraphics.zIndex=-3,this.container.addChild(this.wallGraphics),this.wallMarkGraphics=new W,this.wallMarkGraphics.zIndex=-2,this.container.addChild(this.wallMarkGraphics),this.rampartGraphics=new W,this.rampartGraphics.zIndex=150,this.container.addChild(this.rampartGraphics),this.rampartGlowGraphics=new W,this.rampartGlowGraphics.zIndex=149,this.rampartGlowGraphics.filters=[new Ue({strength:3,quality:3})],this.container.addChild(this.rampartGlowGraphics),this.roadGraphics=new W,this.container.addChild(this.roadGraphics),e&&(this.ticker=e,this.tickerCallback=()=>this.tick(),e.add(this.tickerCallback))}setTheme(e,t){this.activeTheme=e,this.atlasCache=t}setRoadColor(e){this.roadColor=e,this.redrawRoads()}setWallColor(e){this.wallColor=e,this.redrawWalls()}setLightingLayer(e){this.lighting=e}tick(){let e=performance.now(),t=this.lighting;for(let[n,r]of this.objects){if(r.__targetX===void 0||r.__targetY===void 0)continue;let i=r.__moveDur??0,a=e-(r.__moveStartT??e);if(i<=0||a>=i){r.position.set(r.__targetX,r.__targetY),r.__targetX=void 0,r.__targetY=void 0,r.__moveStartX=void 0,r.__moveStartY=void 0,r.__moveStartT=void 0,r.__moveDur=void 0,t?.setLightPosition(n,r.x+12/2,r.y+12/2);continue}let o=a/i,s=r.__moveStartX??r.x,c=r.__moveStartY??r.y;r.x=s+(r.__targetX-s)*o,r.y=c+(r.__targetY-c)*o,t?.setLightPosition(n,r.x+12/2,r.y+12/2)}let n=this.container.parent?.scale.x??1;if(n!==this.lastWorldScale){this.lastWorldScale=n;for(let e of this.objects.values())this.applyLabelScale(e)}let r=performance.now(),i=r/1e3,a=.5+.5*Math.sin(r*2*Math.PI/Ys),o=Math.min(1,(r-this.lastTickAt)/this.tickMs),s=Math.sin(o*Math.PI);for(let e of this.objects.values()){if(e.__barrelContainer){let t=e.__barrelContainer;e.__towerAimUntil!==void 0&&r<e.__towerAimUntil&&e.__towerAimAngle!==void 0?t.rotation=zc(t.rotation,e.__towerAimAngle,Ic):(e.__towerAimUntil!==void 0&&(e.__towerIdlePhase=t.rotation-i*Fc,e.__towerAimUntil=void 0,e.__towerAimAngle=void 0),t.rotation=i*Fc+(e.__towerIdlePhase??0))}if(e.__extractorRing){let t=e.__extractorActive===!0;t&&!e.__extractorWasActive&&(e.__extractorPhase=e.__extractorRing.rotation-i*Lc),t&&(e.__extractorRing.rotation=i*Lc+(e.__extractorPhase??0)),e.__extractorWasActive=t}if(e.__csRingGraphics&&e.__csColorDark!==void 0&&e.__csColorLight!==void 0&&Zs(e.__csRingGraphics,Xs(e.__csColorDark,e.__csColorLight,a)),e.__factoryGearG){let t=(e.__factoryCooldownEnd??0)>this.currentGameTime;t?Iu(e.__factoryGearG,Xs(e.__factoryGlowColor??9419667,Mu,.5*a)):e.__factoryWasOnCd&&Iu(e.__factoryGearG,e.__factoryGlowColor??9419667),e.__factoryWasOnCd=t}if(e.__labCooldownG){let t=(e.__labCooldownTime??0)>this.currentGameTime;e.__labCooldownG.alpha=t?s:0}if(e.__terminalCooldownG){let t=(e.__terminalCooldownTime??0)>this.currentGameTime;e.__terminalCooldownG.alpha=t?s:0}if(e.__keeperGlow){let t=(r/Fl+(e.__keeperPhase??0))%1,n=Il+(1-(1-t)*(1-t))*(Ll-Il);e.__keeperGlow.width=e.__keeperGlow.height=n*2,e.__keeperGlow.alpha=Rl*Math.sin(Math.PI*t)}}for(let[e,t]of this.fillAnimations){let n=Math.min(1,(r-t.startTime)/this.EXT_ANIM_DURATION),i=n<.5?2*n*n:1-(-2*n+2)**2/2;t.apply(t.visual,t.fromA+(t.toA-t.fromA)*i,t.fromB+(t.toB-t.fromB)*i),n>=1&&this.fillAnimations.delete(e)}for(let e of this.objects.values()){let t=e.__sourceGraphics;t&&Hs(t,e.__sourceSize??Ps,r)}for(let e of this.objects.values()){let t=e.__powerBankEllipseG;t&&bu(t,e.__powerBankRadius??0,r)}for(let[e,t]of this.buildGlowAnimations){let n=this.objects.get(e),i=n?.__csBuildGlow;if(!n||!i){this.buildGlowAnimations.delete(e);continue}let a=(r-t.startTime)/t.duration,o;o=a<=0?0:a<.5?a/.5:a<.7?1:a<1?1-(a-.7)/.3:0,i.clear(),o>0&&(i.circle(12/2,12/2,Js),i.fill({color:wt,alpha:o*.75})),a>=1&&this.buildGlowAnimations.delete(e)}for(let[e,t]of this.ctrlFlashAnimations){let n=this.objects.get(e),i=n?.__ctrlSegSprites;if(!n||!i){this.ctrlFlashAnimations.delete(e);continue}let a=Math.min(1,(r-t.startTime)/t.duration),o=1-(1-a)*(1-a),s=i[t.segIndex];s&&!s.destroyed&&(s.alpha=1-.85*o),a>=1&&(s&&!s.destroyed&&(s.alpha=.15),this.ctrlFlashAnimations.delete(e))}for(let e of this.objects.values()){let t=e.__ctrlLevel,n=e.__ctrlSegSprites;if(!t||!n)continue;let i=e.__ctrlDowngradeTime;if(!i){for(let e=0;e<t;e++){let t=n[e];t&&!t.destroyed&&(t.tint=16777215)}continue}let a=cs[t]??2e4,o=1-Math.max(0,i-this.currentGameTime)/a;if(o<=.2){for(let e=0;e<t;e++){let t=n[e];t&&!t.destroyed&&(t.tint=16777215)}continue}let s=(o-.2)/.8,c=.3+s*1.5,l=.5+.5*Math.sin(2*Math.PI*c*r/1e3),u=Xs(16777215,Xs(16768477,16720418,s),s*l);for(let e=0;e<t;e++){let t=n[e];t&&!t.destroyed&&(t.tint=u)}}this.lighting?.render()}startFill(e,t,n,r,i,a=0,o=0){if(this.instantMode){n(t,i,o);return}r===i&&a===o||this.fillAnimations.set(e,{visual:t,fromA:r,toA:i,fromB:a,toB:o,apply:n,startTime:performance.now()})}startExtAnimation(e,t,n,r,i,a){this.startFill(e,t,Ac,wc(n,r),wc(i,a))}startLinkAnimation(e,t,n,r,i,a){this.startFill(e,t,Oc,Dc(n,r),Dc(i,a))}startCreepFillAnimation(e,t,n,r,i,a){this.startFill(e,t,bc,yc(n,r),yc(i,a))}startTowerFillAnimation(e,t,n,r,i,a){this.startFill(e,t,Kc,Gc(n,r),Gc(i,a))}startStorageFillAnimation(e,t,n,r,i,a){this.startFill(e,t,il,rl(n,r),rl(i,a))}startContainerFillAnimation(e,t,n,r,i,a){this.startFill(e,t,nl,tl(n,r),tl(i,a))}startTerminalFillAnimation(e,t,n,r,i,a){this.startFill(e,t,cl,q(n,r),q(i,a))}startFactoryFillAnimation(e,t,n,r,i,a){this.startFill(e,t,zu,Ru(n,r),Ru(i,a))}startLabFillAnimation(e,t,n,r,i,a,o,s,c,l){this.startFill(e,t,Ul,q(n,r),q(o,s),q(i,a),q(c,l))}startNukerFillAnimation(e,t,n,r,i,a,o,s,c,l){this.startFill(e,t,eu,q(n,r),q(o,s),q(i,a),q(c,l))}startSourceAnimation(e,t,n,r,i,a){this.startFill(e,t,Us,zs(n,r),zs(i,a))}startPowerSpawnPowerAnimation(e,t,n,r,i,a){this.startFill(e,t,ou,q(n,r),q(i,a))}startSpawnFillAnimation(e,t,n,r,i,a){this.startFill(e,t,Ac,ol(n,r),ol(i,a))}update(e,t,n,r){n&&(this.users=n),r!==void 0&&(r!==this.currentGameTime&&(this.lastTickAt=performance.now()),this.currentGameTime=r);let i=!1,a=!1,o=!1;if(t)for(let n in t)if(t[n]===null){let e=this.rawObjects.get(n);e&&e.type===`road`&&(i=!0),e&&e.type===`constructedWall`&&(a=!0),e&&e.type===`rampart`&&(o=!0);let t=this.objects.get(n);t&&(this.container.removeChild(t),Zu(t),this.objects.delete(n),this.rawObjects.delete(n),this.fillAnimations.delete(n),this.buildGlowAnimations.delete(n),this.ctrlFlashAnimations.delete(n),this.sayBubbles.delete(n))}else{let t=e[n];if(!t)continue;if(t.type===`road`){let e=this.rawObjects.get(n);(!e||e.x!==t.x||e.y!==t.y)&&(i=!0)}else if(t.type===`constructedWall`){let e=this.rawObjects.get(n);(!e||e.x!==t.x||e.y!==t.y)&&(a=!0)}else if(t.type===`rampart`){let e=this.rawObjects.get(n);(!e||e.x!==t.x||e.y!==t.y||e.user!==t.user)&&(o=!0)}this.rawObjects.set(n,t);let r=this.objects.get(n);if(r){let e=t.x*12,i=t.y*12;if(t.type===`creep`){let a=t.x-(r.__tileX??t.x),o=t.y-(r.__tileY??t.y);(a!==0||o!==0)&&(r.__angle=Math.atan2(o,a),r.__bodyContainer&&(r.__bodyContainer.rotation=r.__angle)),r.__tileX=t.x,r.__tileY=t.y,this.instantMode?(r.position.set(e,i),r.__targetX=void 0,r.__targetY=void 0,r.__moveStartX=void 0,r.__moveStartY=void 0,r.__moveStartT=void 0,r.__moveDur=void 0):(r.x!==e||r.y!==i)&&(r.__targetX=e,r.__targetY=i,r.__moveStartX=r.x,r.__moveStartY=r.y,r.__moveStartT=performance.now(),r.__moveDur=this.moveDuration);let{used:s,capacity:c}=vc(t);(r.__creepUsed!==s||r.__creepCapacity!==c)&&(this.startCreepFillAnimation(n,r,r.__creepUsed??0,r.__creepCapacity??c,s,c),r.__creepUsed=s,r.__creepCapacity=c);let l=Yu(t,this.activeTheme);r.zIndex!==l&&(r.zIndex=l)}else if(t.type===`flag`){let a=typeof t.color==`number`?t.color:0,o=typeof t.secondaryColor==`number`?t.secondaryColor:0;if(r.__flagColor!==a||r.__flagSecondaryColor!==o){this.container.removeChild(r),Zu(r),this.objects.delete(n);let e=Xu(t,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=t.x,e.__tileY=t.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e)}else r.position.set(e,i)}else r.position.set(e,i);if(t.type===`extension`){let{energy:e,capacity:i}=Sc(t),a=r;(a.__extEnergy!==e||a.__extCapacity!==i)&&(this.startExtAnimation(n,r,a.__extEnergy??0,a.__extCapacity??i,e,i),a.__extEnergy=e,a.__extCapacity=i)}if(t.type===`link`){let{energy:e,capacity:i}=Sc(t);(r.__linkEnergy!==e||r.__linkCapacity!==i)&&(this.startLinkAnimation(n,r,r.__linkEnergy??0,r.__linkCapacity??i,e,i),r.__linkEnergy=e,r.__linkCapacity=i)}if(t.type===`tower`){let{energy:e,capacity:i}=Sc(t);(r.__towerEnergy!==e||r.__towerCapacity!==i)&&(this.startTowerFillAnimation(n,r,r.__towerEnergy??0,r.__towerCapacity??i,e,i),r.__towerEnergy=e,r.__towerCapacity=i)}if(t.type===`storage`){let{bands:e,used:i,capacity:a}=Qc(t);if(r.__storageUsed!==i||r.__storageCapacity!==a){let t=r.__storageUsed??0,o=r.__storageCapacity??a;r.__storageBands=e,r.__storageUsed=i,r.__storageCapacity=a,this.startStorageFillAnimation(n,r,t,o,i,a)}else el(r.__storageBands,e)||(r.__storageBands=e,il(r,rl(i,a)))}if(t.type===`container`){let{bands:e,used:i,capacity:a}=Qc(t);if(r.__containerUsed!==i||r.__containerCapacity!==a){let t=r.__containerUsed??0,o=r.__containerCapacity??a;r.__containerBands=e,r.__containerUsed=i,r.__containerCapacity=a,this.startContainerFillAnimation(n,r,t,o,i,a)}else el(r.__containerBands,e)||(r.__containerBands=e,nl(r,tl(i,a)))}if(t.type===`terminal`){let{used:e,capacity:i,dominant:a}=Qc(t),o=a??void 0;if(r.__terminalDominant!==o&&(r.__terminalDominant=o,r.__terminalFillColor=o?al(o):wt,cl(r,q(e,i))),r.__terminalUsed!==e||r.__terminalCapacity!==i){let t=r.__terminalUsed??0,a=r.__terminalCapacity??i;r.__terminalUsed=e,r.__terminalCapacity=i,this.startTerminalFillAnimation(n,r,t,a,e,i)}r.__terminalCooldownTime=Vl(t)}if(t.type===`lab`){let{energy:e,energyCap:i,mineralType:a,mineral:o,mineralCap:s}=Hl(t),c=a??void 0;if(r.__labMineralType!==c&&(r.__labMineralType=c,r.__labMineralColor=a?al(a):void 0,Ul(r,q(e,i),q(o,s))),r.__labEnergy!==e||r.__labEnergyCap!==i||r.__labMineral!==o||r.__labMineralCap!==s){let t=r.__labEnergy??0,a=r.__labEnergyCap??i,c=r.__labMineral??0,l=r.__labMineralCap??s;r.__labEnergy=e,r.__labEnergyCap=i,r.__labMineral=o,r.__labMineralCap=s,this.startLabFillAnimation(n,r,t,a,c,l,e,i,o,s)}r.__labCooldownTime=Vl(t)}if(t.type===`nuker`){let{energy:e,energyCap:i,ghodium:a,ghodiumCap:o}=$l(t);if(r.__nukerEnergy!==e||r.__nukerEnergyCap!==i||r.__nukerGhodium!==a||r.__nukerGhodiumCap!==o){let t=r.__nukerEnergy??0,s=r.__nukerEnergyCap??i,c=r.__nukerGhodium??0,l=r.__nukerGhodiumCap??o;r.__nukerEnergy=e,r.__nukerEnergyCap=i,r.__nukerGhodium=a,r.__nukerGhodiumCap=o,this.startNukerFillAnimation(n,r,t,s,c,l,e,i,a,o)}}if(t.type===`powerSpawn`){let{power:e,powerCap:i}=iu(t);if(r.__powerSpawnPower!==e||r.__powerSpawnPowerCap!==i){let t=r.__powerSpawnPower??0,a=r.__powerSpawnPowerCap??i;r.__powerSpawnPower=e,r.__powerSpawnPowerCap=i,this.startPowerSpawnPowerAnimation(n,r,t,a,e,i)}}if(t.type===`extractor`&&(r.__extractorActive=Fu(t)),t.type===`factory`){let{bands:e,used:i,capacity:a}=Qc(t),o=typeof t.level==`number`?t.level:0;if(r.__factoryLevel!==o&&r.__factoryRingG&&(r.__factoryLevel=o,Lu(r.__factoryRingG,o)),r.__factoryCooldownEnd=Vl(t),r.__factoryUsed!==i||r.__factoryCapacity!==a){let t=r.__factoryUsed??0,o=r.__factoryCapacity??a;r.__factoryBands=e,r.__factoryUsed=i,r.__factoryCapacity=a,this.startFactoryFillAnimation(n,r,t,o,i,a)}else el(r.__factoryBands,e)||(r.__factoryBands=e,zu(r,Ru(i,a)))}if(t.type===`controller`){let e=typeof t.level==`number`?t.level:0,i=typeof t.progress==`number`?t.progress:0,a=typeof t.progressTotal==`number`?t.progressTotal:0,o=t.reservation,s=typeof t.user==`string`?t.user:typeof o?.user==`string`?o.user:void 0;if(r.__ctrlUserId!==s){this.container.removeChild(r),Zu(r),this.objects.delete(n);let e=Xu(t,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=t.x,e.__tileY=t.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e);continue}(r.__ctrlLevel!==e||r.__ctrlProgress!==i||r.__ctrlProgressTotal!==a)&&(r.__ctrlSegSprites?(!this.instantMode&&e<8&&i>(r.__ctrlProgress??0)&&this.ctrlFlashAnimations.set(n,{segIndex:e,startTime:performance.now(),duration:400}),Wu(r,e,i,a)):r.__ctrlSegGraphics&&Uu(r.__ctrlSegGraphics,12/2,12/2,Vu,Hu,e,i,a),r.__ctrlLevel=e,r.__ctrlProgress=i,r.__ctrlProgressTotal=a);let c=typeof t.downgradeTime==`number`?t.downgradeTime:void 0;r.__ctrlDowngradeTime!==c&&(r.__ctrlDowngradeTime=c)}if(t.type===`source`){let{energy:e,capacity:i}=Ws(t);(r.__sourceEnergy!==e||r.__sourceCapacity!==i)&&(this.startSourceAnimation(n,r,r.__sourceEnergy??0,r.__sourceCapacity??i,e,i),r.__sourceEnergy=e,r.__sourceCapacity=i)}if(t.type===`constructionSite`){let e=typeof t.progress==`number`?t.progress:0,n=typeof t.progressTotal==`number`?t.progressTotal:1;(r.__csProgress!==e||r.__csProgressTotal!==n)&&(r.__csFillGraphics&&rc(r.__csFillGraphics,12/2,12/2,qs,e,n,r.__csColor??9419667),r.__csProgress=e,r.__csProgressTotal=n)}if(t.type===`powerBank`){let e=_u(t);r.__powerBankPower!==e&&(r.__powerBankPower=e,r.__powerBankRadius=vu(e))}}else{let e=Xu(t,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=t.x,e.__tileY=t.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e)}}else{let t=new Set;for(let n in e){let r=e[n];if(!r)continue;t.add(n),this.rawObjects.set(n,r);let i=this.objects.get(n);if(i){let e=r.x*12,t=r.y*12;if(r.type===`creep`){let a=r.x-(i.__tileX??r.x),o=r.y-(i.__tileY??r.y);(a!==0||o!==0)&&(i.__angle=Math.atan2(o,a),i.__bodyContainer&&(i.__bodyContainer.rotation=i.__angle)),i.__tileX=r.x,i.__tileY=r.y,this.instantMode?(i.position.set(e,t),i.__targetX=void 0,i.__targetY=void 0,i.__moveStartX=void 0,i.__moveStartY=void 0,i.__moveStartT=void 0,i.__moveDur=void 0):(i.x!==e||i.y!==t)&&(i.__targetX=e,i.__targetY=t,i.__moveStartX=i.x,i.__moveStartY=i.y,i.__moveStartT=performance.now(),i.__moveDur=this.moveDuration);let{used:s,capacity:c}=vc(r);(i.__creepUsed!==s||i.__creepCapacity!==c)&&(this.startCreepFillAnimation(n,i,i.__creepUsed??0,i.__creepCapacity??c,s,c),i.__creepUsed=s,i.__creepCapacity=c);let l=Yu(r,this.activeTheme);i.zIndex!==l&&(i.zIndex=l)}else if(r.type===`flag`){let a=typeof r.color==`number`?r.color:0,o=typeof r.secondaryColor==`number`?r.secondaryColor:0;if(i.__flagColor!==a||i.__flagSecondaryColor!==o){this.container.removeChild(i),Zu(i),this.objects.delete(n);let e=Xu(r,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=r.x,e.__tileY=r.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e)}else i.position.set(e,t)}else i.position.set(e,t);if(r.type===`extension`){let{energy:e,capacity:t}=Sc(r),a=i;(a.__extEnergy!==e||a.__extCapacity!==t)&&(this.startExtAnimation(n,i,a.__extEnergy??0,a.__extCapacity??t,e,t),a.__extEnergy=e,a.__extCapacity=t)}if(r.type===`link`){let{energy:e,capacity:t}=Sc(r);(i.__linkEnergy!==e||i.__linkCapacity!==t)&&(this.startLinkAnimation(n,i,i.__linkEnergy??0,i.__linkCapacity??t,e,t),i.__linkEnergy=e,i.__linkCapacity=t)}if(r.type===`tower`){let{energy:e,capacity:t}=Sc(r);(i.__towerEnergy!==e||i.__towerCapacity!==t)&&(this.startTowerFillAnimation(n,i,i.__towerEnergy??0,i.__towerCapacity??t,e,t),i.__towerEnergy=e,i.__towerCapacity=t)}if(r.type===`controller`){let e=typeof r.level==`number`?r.level:0,t=typeof r.progress==`number`?r.progress:0,a=typeof r.progressTotal==`number`?r.progressTotal:0,o=r.reservation,s=typeof r.user==`string`?r.user:typeof o?.user==`string`?o.user:void 0;if(i.__ctrlUserId!==s){this.container.removeChild(i),Zu(i),this.objects.delete(n);let e=Xu(r,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=r.x,e.__tileY=r.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e);continue}(i.__ctrlLevel!==e||i.__ctrlProgress!==t||i.__ctrlProgressTotal!==a)&&(i.__ctrlSegSprites?(!this.instantMode&&e>(i.__ctrlLevel??0)&&e>0&&this.ctrlFlashAnimations.set(n,{segIndex:e-1,startTime:performance.now(),duration:500}),Wu(i,e,t,a)):i.__ctrlSegGraphics&&Uu(i.__ctrlSegGraphics,12/2,12/2,Vu,Hu,e,t,a),i.__ctrlLevel=e,i.__ctrlProgress=t,i.__ctrlProgressTotal=a);let c=typeof r.downgradeTime==`number`?r.downgradeTime:void 0;i.__ctrlDowngradeTime!==c&&(i.__ctrlDowngradeTime=c)}if(r.type===`source`){let{energy:e,capacity:t}=Ws(r);(i.__sourceEnergy!==e||i.__sourceCapacity!==t)&&(this.startSourceAnimation(n,i,i.__sourceEnergy??0,i.__sourceCapacity??t,e,t),i.__sourceEnergy=e,i.__sourceCapacity=t)}if(r.type===`constructionSite`){let e=typeof r.progress==`number`?r.progress:0,t=typeof r.progressTotal==`number`?r.progressTotal:1;(i.__csProgress!==e||i.__csProgressTotal!==t)&&(i.__csFillGraphics&&rc(i.__csFillGraphics,12/2,12/2,qs,e,t,i.__csColor??9419667),i.__csProgress=e,i.__csProgressTotal=t)}if(r.type===`powerBank`){let e=typeof r.power==`number`?r.power:0;i.__powerBankPower!==e&&(i.__powerBankPower=e,i.__powerBankRadius=vu(e))}}else{let e=Xu(r,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=r.x,e.__tileY=r.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e)}}for(let[e,n]of this.objects)t.has(e)||(this.container.removeChild(n),Zu(n),this.objects.delete(e),this.rawObjects.delete(e),this.fillAnimations.delete(e),this.buildGlowAnimations.delete(e),this.ctrlFlashAnimations.delete(e),this.sayBubbles.delete(e));i=!0,a=!0,o=!0}a&&this.redrawWalls(),o&&this.redrawRamparts(),i&&this.redrawRoads();for(let[e,t]of this.objects){if(!t.__spawnRing)continue;let n=this.rawObjects.get(e),r=n?cc(n):null;if(r!==t.__spawnSig){t.__spawnSig=r;let e=n&&r?sc(n,this.currentGameTime):null;t.__spawnNeedTime=e?.needTime,t.__spawnEndTime=e?.endTime}let i=t.__spawnNeedTime!==void 0&&t.__spawnEndTime!==void 0?lc(t.__spawnNeedTime,t.__spawnEndTime,this.currentGameTime):null;if(i!==t.__spawnRatio&&(uc(t.__spawnRing,i),t.__spawnRatio=i),n){let{energy:r,capacity:i}=Sc(n);(t.__spawnEnergy!==r||t.__spawnCapacity!==i)&&(this.startSpawnFillAnimation(e,t,t.__spawnEnergy??0,t.__spawnCapacity??i,r,i),t.__spawnEnergy=r,t.__spawnCapacity=i)}}this.refreshForeignCreepLabels(),this.refreshForeignCreepBadges()}redrawWalls(){this.wallGraphics.clear(),this.wallMarkGraphics.clear();let e=Array.from({length:50},()=>Array(50).fill(!1)),t=[];for(let n of this.rawObjects.values())n.type===`constructedWall`&&typeof n.x==`number`&&typeof n.y==`number`&&n.x>=0&&n.x<50&&n.y>=0&&n.y<50&&(e[n.x][n.y]=!0,t.push({x:n.x,y:n.y}));if(t.length===0)return;let n=t=>{let n=!1;for(let r=0;r<50;r++)for(let i=0;i<50;i++){let a=e[i][r],o=r>0&&e[i][r-1],s=r<49&&e[i][r+1],c=i>0&&e[i-1][r],l=i<49&&e[i+1][r],u=i*12+6,d=r*12+6;a?(n=!0,!o&&!c&&r>0&&i>0?(t.moveTo(u,r*12),t.arc(u,d,6,-Math.PI/2,Math.PI,!0),t.lineTo(u,d),t.closePath()):t.rect(i*12,r*12,6,6)):o&&c&&e[i-1][r-1]&&(n=!0,t.moveTo(u,r*12),t.lineTo(i*12,r*12),t.lineTo(i*12,d),t.arc(u,d,6,Math.PI,-Math.PI/2,!1),t.closePath()),a?!o&&!l&&r>0&&i<49?(t.moveTo(u,r*12),t.arc(u,d,6,-Math.PI/2,0,!1),t.lineTo(u,d),t.closePath()):t.rect(u,r*12,6,6):o&&l&&e[i+1][r-1]&&(n=!0,t.moveTo(u,r*12),t.lineTo(i*12+12,r*12),t.lineTo(i*12+12,d),t.arc(u,d,6,0,-Math.PI/2,!0),t.closePath()),a?!s&&!c&&r<49&&i>0?(t.moveTo(i*12,d),t.arc(u,d,6,Math.PI,Math.PI/2,!0),t.lineTo(u,d),t.closePath()):t.rect(i*12,d,6,6):s&&c&&e[i-1][r+1]&&(n=!0,t.moveTo(i*12,d),t.lineTo(i*12,r*12+12),t.lineTo(u,r*12+12),t.arc(u,d,6,Math.PI/2,Math.PI,!1),t.closePath()),a?!s&&!l&&r<49&&i<49?(t.moveTo(u,r*12+12),t.arc(u,d,6,Math.PI/2,0,!0),t.lineTo(u,d),t.closePath()):t.rect(u,d,6,6):s&&l&&e[i+1][r+1]&&(n=!0,t.moveTo(u,r*12+12),t.lineTo(i*12+12,r*12+12),t.lineTo(i*12+12,d),t.arc(u,d,6,0,Math.PI/2,!1),t.closePath())}return n};n(this.wallGraphics)&&this.wallGraphics.stroke({color:0,width:12*.06,alignment:0,cap:`round`,join:`round`}),n(this.wallGraphics),this.wallGraphics.fill(this.wallColor);let r=12*.32,i=12*.09;for(let{x:e,y:n}of t){let t=e*12,a=n*12;this.wallMarkGraphics.rect(t+12*.12,a+12*.3,r,i),this.wallMarkGraphics.rect(t+12*.56,a+12*.58,r,i)}this.wallMarkGraphics.fill({color:4210752})}redrawRoads(){this.roadGraphics.clear();let e=this.roadColor,t=Array.from({length:50},()=>Array(50).fill(!1)),n=[];for(let e of this.rawObjects.values())e.type===`road`&&(n.push(e),e.x>=0&&e.x<50&&e.y>=0&&e.y<50&&(t[e.x][e.y]=!0));if(n.length===0)return;let r=12*.125;for(let e of n)this.roadGraphics.circle(e.x*12+6,e.y*12+6,r);this.roadGraphics.fill(e);let i=[[1,0],[1,1],[0,1],[-1,1]];for(let e of n){let n=e.x*12+6,r=e.y*12+6;for(let[a,o]of i){let i=e.x+a,s=e.y+o;if(i>=0&&i<50&&s>=0&&s<50&&t[i][s]){let e=i*12+6,t=s*12+6;this.roadGraphics.moveTo(n,r),this.roadGraphics.lineTo(e,t)}}}this.roadGraphics.stroke({width:r*2,color:e})}redrawRamparts(){this.rampartGraphics.clear(),this.rampartGlowGraphics.clear();let e=Array.from({length:50},()=>Array(50).fill(void 0));for(let t of this.rawObjects.values())t.type===`rampart`&&t.x>=0&&t.x<50&&t.y>=0&&t.y<50&&(e[t.x][t.y]=typeof t.user==`string`?t.user:void 0);let t=e=>!e||!this.currentUserId||e===this.currentUserId?{color:bn,alpha:.4}:{color:Ft,alpha:.36},n=Array.from({length:50},()=>Array(50).fill(!1)),r=Array.from({length:50},()=>Array(50).fill(!1));for(let t=0;t<50;t++)for(let i=0;i<50;i++){let a=e[i][t];a!==void 0&&(!this.currentUserId||a===this.currentUserId?n[i][t]=!0:r[i][t]=!0)}let i=(e,t)=>{let n=t=>{let n=!1,r=(e,r,i,a)=>{t.moveTo(e,r),t.lineTo(i,a),n=!0},i=(e,r,i,a,o,s,c)=>{t.moveTo(e,r),t.arc(s,c,6,i,a,o),n=!0};for(let t=0;t<50;t++)for(let n=0;n<50;n++){let a=t>0&&e[n][t-1],o=t<49&&e[n][t+1],s=n>0&&e[n-1][t],c=n<49&&e[n+1][t],l=n>0&&t>0&&e[n-1][t-1],u=n<49&&t>0&&e[n+1][t-1],d=n>0&&t<49&&e[n-1][t+1],f=n<49&&t<49&&e[n+1][t+1],p=n*12+6,m=t*12+6;e[n][t]?(!a&&!s&&t>0&&n>0?i(p,t*12,-Math.PI/2,Math.PI,!0,p,m):(!a&&!(s&&l)&&r(n*12,t*12,p,t*12),!s&&!(a&&l)&&r(n*12,t*12,n*12,m)),!a&&!c&&t>0&&n<49?i(p,t*12,-Math.PI/2,0,!1,p,m):(!a&&!(c&&u)&&r(p,t*12,n*12+12,t*12),!c&&!(a&&u)&&r(n*12+12,t*12,n*12+12,m)),!o&&!s&&t<49&&n>0?i(n*12,m,Math.PI,Math.PI/2,!0,p,m):(!o&&!(s&&d)&&r(n*12,t*12+12,p,t*12+12),!s&&!(o&&d)&&r(n*12,m,n*12,t*12+12)),!o&&!c&&t<49&&n<49?i(p,t*12+12,Math.PI/2,0,!0,p,m):(!o&&!(c&&f)&&r(p,t*12+12,n*12+12,t*12+12),!c&&!(o&&f)&&r(n*12+12,m,n*12+12,t*12+12))):(a&&s&&l&&i(n*12,m,Math.PI,-Math.PI/2,!1,p,m),a&&c&&u&&i(n*12+12,m,0,-Math.PI/2,!0,p,m),o&&s&&d&&i(p,t*12+12,Math.PI/2,Math.PI,!1,p,m),o&&c&&f&&i(n*12+12,m,0,Math.PI/2,!1,p,m))}return n};n(this.rampartGlowGraphics)&&this.rampartGlowGraphics.stroke({color:t,width:12*.3,alpha:.55,alignment:.5,cap:`butt`,join:`round`}),n(this.rampartGraphics)&&this.rampartGraphics.stroke({color:t,width:12*.08,alpha:.9,alignment:.5,cap:`butt`,join:`round`})};for(let n=0;n<50;n++)for(let r=0;r<50;r++){let i=e[r][n],a=i!==void 0,o=n>0&&e[r][n-1]!==void 0,s=n<49&&e[r][n+1]!==void 0,c=r>0&&e[r-1][n]!==void 0,l=r<49&&e[r+1][n]!==void 0,u=r*12+6,d=n*12+6;if(a){let e=t(i);!o&&!c&&n>0&&r>0?(this.rampartGraphics.moveTo(u,n*12),this.rampartGraphics.arc(u,d,6,-Math.PI/2,Math.PI,!0),this.rampartGraphics.lineTo(u,d),this.rampartGraphics.fill(e)):(this.rampartGraphics.rect(r*12,n*12,6,6),this.rampartGraphics.fill(e))}else if(o&&c&&e[r-1][n-1]!==void 0){let i=t(e[r-1][n-1]);this.rampartGraphics.moveTo(u,n*12),this.rampartGraphics.lineTo(r*12,n*12),this.rampartGraphics.lineTo(r*12,d),this.rampartGraphics.arc(u,d,6,Math.PI,-Math.PI/2,!1),this.rampartGraphics.fill(i)}if(a){let e=t(i);!o&&!l&&n>0&&r<49?(this.rampartGraphics.moveTo(u,n*12),this.rampartGraphics.arc(u,d,6,-Math.PI/2,0,!1),this.rampartGraphics.lineTo(u,d),this.rampartGraphics.fill(e)):(this.rampartGraphics.rect(u,n*12,6,6),this.rampartGraphics.fill(e))}else if(o&&l&&e[r+1][n-1]!==void 0){let i=t(e[r+1][n-1]);this.rampartGraphics.moveTo(u,n*12),this.rampartGraphics.lineTo(r*12+12,n*12),this.rampartGraphics.lineTo(r*12+12,d),this.rampartGraphics.arc(u,d,6,0,-Math.PI/2,!0),this.rampartGraphics.fill(i)}if(a){let e=t(i);!s&&!c&&n<49&&r>0?(this.rampartGraphics.moveTo(r*12,d),this.rampartGraphics.arc(u,d,6,Math.PI,Math.PI/2,!0),this.rampartGraphics.lineTo(u,d),this.rampartGraphics.fill(e)):(this.rampartGraphics.rect(r*12,d,6,6),this.rampartGraphics.fill(e))}else if(s&&c&&e[r-1][n+1]!==void 0){let i=t(e[r-1][n+1]);this.rampartGraphics.moveTo(r*12,d),this.rampartGraphics.lineTo(r*12,n*12+12),this.rampartGraphics.lineTo(u,n*12+12),this.rampartGraphics.arc(u,d,6,Math.PI/2,Math.PI,!1),this.rampartGraphics.fill(i)}if(a){let e=t(i);!s&&!l&&n<49&&r<49?(this.rampartGraphics.moveTo(u,n*12+12),this.rampartGraphics.arc(u,d,6,Math.PI/2,0,!0),this.rampartGraphics.lineTo(u,d),this.rampartGraphics.fill(e)):(this.rampartGraphics.rect(u,d,6,6),this.rampartGraphics.fill(e))}else if(s&&l&&e[r+1][n+1]!==void 0){let i=t(e[r+1][n+1]);this.rampartGraphics.moveTo(u,n*12+12),this.rampartGraphics.lineTo(r*12+12,n*12+12),this.rampartGraphics.lineTo(r*12+12,d),this.rampartGraphics.arc(u,d,6,0,Math.PI/2,!1),this.rampartGraphics.fill(i)}}i(n,Vt),i(r,Lt)}getObjectsAtTile(e,t){let n=[];for(let[r,i]of this.objects){let a=this.rawObjects.get(r);a&&a.x===e&&a.y===t&&n.push({id:r,obj:a,visual:i})}return n}applyLabelScale(e){let t=this.lastWorldScale||1;e.__nameLabel&&(e.__nameLabel.scale.set(ms/t),e.__nameLabel.anchor.y===0?e.__nameLabel.y=12.600000000000001:e.__nameLabel.y=hs-gs/t),e.__sayBubble&&!e.__sayBubble.destroyed&&(e.__sayBubble.scale.set(1/t),e.__sayBubble.position.set(12/2,hs-Ss/t))}refreshForeignCreepLabels(){if(this.currentUserId)for(let[e,t]of this.objects){let n=this.rawObjects.get(e);if(!n||n.type!==`creep`||!t.__nameLabel||!Gu(n,this.currentUserId))continue;let r=typeof n.user==`string`?n.user:void 0,i=Ju(n,this.users)??(r?this.users?.[r]?.username??r:`Hostile`);t.__nameLabel.text!==i&&(t.__nameLabel.text=i)}}refreshForeignCreepBadges(){if(this.currentUserId)for(let[e,t]of this.objects){let n=this.rawObjects.get(e);if(!n||n.type!==`creep`||!Gu(n,this.currentUserId)||t.__creepBadgeSprite)continue;let r=typeof n.user==`string`?n.user:void 0,i=r?this.users?.[r]?.badge:void 0;if(!i)continue;let a=t.__bodyContainer;if(!a)continue;t.__creepForeignMark&&!t.__creepForeignMark.destroyed&&(a.removeChild(t.__creepForeignMark),t.__creepForeignMark.destroy(),t.__creepForeignMark=void 0);let o=new Ge;o.anchor.set(.5,.5);let s=ds*2;o.width=s,o.height=s,o.rotation=Math.PI/2,a.addChild(o),t.__creepBadgeSprite=o,this.badgeCache.getOrCreate(i).then(e=>{o.destroyed||(o.texture=e)}).catch(()=>{o.destroyed||(a.removeChild(o),o.destroy()),t.__creepBadgeSprite=void 0})}}triggerBuildAt(e,t,n){if(!this.instantMode)for(let[r,i]of this.objects){let a=this.rawObjects.get(r);if(!(!a||a.type!==`constructionSite`)&&!(a.x!==e||a.y!==t)&&i.__csBuildGlow){this.buildGlowAnimations.set(r,{startTime:performance.now(),duration:n});return}}}triggerTowerAim(e,t,n,r){if(this.instantMode)return;let i=this.objects.get(e);if(!i||!i.__barrelContainer)return;let a=this.rawObjects.get(e);if(!a)return;let o=t-a.x,s=n-a.y;o===0&&s===0||(i.__towerAimAngle=Math.atan2(s,o)+Rc,i.__towerAimUntil=performance.now()+r)}triggerSay(e,t){let n=this.objects.get(e);if(!n||n.__sayMessage===t&&n.__sayBubble&&!n.__sayBubble.destroyed)return;n.__sayBubble&&!n.__sayBubble.destroyed&&(n.removeChild(n.__sayBubble),n.__sayBubble.destroy({children:!0}));let r=Qu(t);n.addChild(r),n.__sayBubble=r,n.__sayMessage=t,this.applyLabelScale(n),this.sayBubbles.add(e)}setMoveDuration(e){this.moveDuration=Math.max(0,e)}setTickDuration(e){this.tickMs=Math.max(1,e)}pruneSayBubblesExcept(e){if(this.sayBubbles.size!==0)for(let t of this.sayBubbles){if(e.has(t))continue;let n=this.objects.get(t);n?.__sayBubble&&!n.__sayBubble.destroyed&&(n.removeChild(n.__sayBubble),n.__sayBubble.destroy({children:!0})),n&&(n.__sayBubble=void 0,n.__sayMessage=void 0),this.sayBubbles.delete(t)}}setInstantMode(e){if(this.instantMode=e,e){for(let e of this.objects.values())e.__targetX!==void 0&&(e.position.set(e.__targetX,e.__targetY),e.__targetX=void 0,e.__targetY=void 0,e.__moveStartX=void 0,e.__moveStartY=void 0,e.__moveStartT=void 0,e.__moveDur=void 0),e.__sayBubble&&!e.__sayBubble.destroyed&&(e.removeChild(e.__sayBubble),e.__sayBubble.destroy({children:!0}),e.__sayBubble=void 0,e.__sayMessage=void 0);this.sayBubbles.clear();for(let e of this.fillAnimations.values())e.apply(e.visual,e.toA,e.toB);this.fillAnimations.clear(),this.buildGlowAnimations.clear(),this.ctrlFlashAnimations.clear()}}setShowLabels(e){this.showLabels=e;for(let t of this.objects.values())t.__nameLabel&&(t.__nameLabel.visible=e)}getVisualById(e){return this.objects.get(e)}clear(){for(let e of this.objects.values())Zu(e);this.objects.clear(),this.rawObjects.clear(),this.fillAnimations.clear(),this.buildGlowAnimations.clear(),this.ctrlFlashAnimations.clear(),this.sayBubbles.clear(),this.roadGraphics.clear(),this.rampartGraphics.clear(),this.rampartGlowGraphics.clear(),this.container.removeChildren(),this.container.addChild(this.rampartGraphics),this.container.addChild(this.rampartGlowGraphics),this.container.addChild(this.roadGraphics)}destroy(){this.clear(),this.ticker&&this.tickerCallback&&this.ticker.remove(this.tickerCallback),this.ticker=null,this.tickerCallback=null}},ed=2,td=3,nd=12*.45,rd=.55;function id(e,t){return{cx:e*12+12/2,cy:t*12+12/2}}var ad=class{container;graphics;animations=[];ticker=null;tickerCallback=null;constructor(e){this.container=new ze,this.graphics=new W,this.container.addChild(this.graphics),e&&(this.ticker=e,this.tickerCallback=()=>this.animate(),e.add(this.tickerCallback))}addHarvest(e,t,n,r,i){let a=id(e,t),o=id(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Mt,width:ed,glowAtSource:!0})}addUpgradeController(e,t,n,r,i){let a=id(e,t),o=id(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:un,width:ed})}addTransfer(e,t,n,r,i){let a=id(e,t),o=id(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:ht,width:ed})}addBuild(e,t,n,r,i){let a=id(e,t),o=id(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Dt,width:ed})}addRepair(e,t,n,r,i){let a=id(e,t),o=id(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Qt,width:ed})}addLinkTransfer(e,t,n,r,i){let a=id(e,t),o=id(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:jt,width:ed})}addLabReaction(e,t,n,r,i){let a=id(e,t),o=id(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Nn,width:ed})}addTowerBeam(e,t,n,r,i,a){let o=id(e,t),s=id(n,r);this.animations.push({fromX:o.cx,fromY:o.cy,toX:s.cx,toY:s.cy,startTime:performance.now(),duration:i,color:a,width:td})}addTowerAttack(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,Zt)}addTowerHeal(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,$t)}addTowerRepair(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,Ht)}animate(){this.graphics.clear();let e=performance.now(),t=!1;for(let n=this.animations.length-1;n>=0;n--){let r=this.animations[n],i=e-r.startTime,a=Math.min(1,i/r.duration),o,s,c,l,u=.5,d=.2;if(a<u){let e=a/u;o=r.fromX,s=r.fromY,c=r.fromX+(r.toX-r.fromX)*e,l=r.fromY+(r.toY-r.fromY)*e}else if(a<.7)o=r.fromX,s=r.fromY,c=r.toX,l=r.toY;else{let e=(a-u-d)/(1-u-d);o=r.fromX+(r.toX-r.fromX)*e,s=r.fromY+(r.toY-r.fromY)*e,c=r.toX,l=r.toY}if(this.graphics.moveTo(o,s),this.graphics.lineTo(c,l),this.graphics.stroke({width:r.width,color:r.color}),a>=u){let e=(a-u)/(1-u),t=(1-e)*rd,n=r.width/ed*nd*(.7+.5*e),i=r.glowAtSource?r.fromX:r.toX,o=r.glowAtSource?r.fromY:r.toY;this.graphics.circle(i,o,n),this.graphics.fill({color:r.color,alpha:t*.4}),this.graphics.circle(i,o,n*.55),this.graphics.fill({color:r.color,alpha:t})}t=!0,a>=1&&this.animations.splice(n,1)}t||this.graphics.clear()}clear(){this.animations.length=0,this.graphics.clear()}destroy(){this.clear(),this.ticker&&this.tickerCallback&&this.ticker.remove(this.tickerCallback),this.ticker=null,this.tickerCallback=null,this.graphics.destroy(),this.container.destroy()}},od=e=>(e+.5)*12,sd={dashed:[.3*12,.25*12],dotted:[.1*12,.2*12]},cd=2400;function ld(e){if(e==null)return .7;if(typeof e==`number`)return e;let t=e.match(/^([0-9.]+)(px)?/);if(!t)return .7;let n=parseFloat(t[1]);return t[2]?n/12:n}function ud(e){if(typeof e!=`string`)return`sans-serif`;let t=e.match(/^[0-9.]+(px)?\s+(.+)$/);return t?t[2]:`sans-serif`}var dd=class{container;canvas;ctx;texture;sprite;resolution;world;ticker;lastRaw=``;lastPhysSize=0;prevScaleX=-1;constructor(e,t,n){this.resolution=e.resolution,this.world=t,this.ticker=n,this.canvas=document.createElement(`canvas`),this.ctx=this.canvas.getContext(`2d`);let r=this.idealPhysSize();this.canvas.width=r,this.canvas.height=r,this.texture=Ze.from(this.canvas,!0),this.lastPhysSize=r,this.sprite=new Ge(this.texture),this.sprite.scale.set(600/r),this.container=new ze,this.container.label=`visuals`,this.container.addChild(this.sprite),this.ticker.add(this.onTick,this)}idealPhysSize(){return Math.min(Math.ceil(this.world.scale.x*this.resolution*600),cd)}onTick=()=>{let e=this.world.scale.x,t=this.idealPhysSize();e===this.prevScaleX&&t!==this.lastPhysSize&&this.lastRaw&&(this.resizeTo(t),this.redraw()),this.prevScaleX=e};update(e){this.lastRaw=e;let t=this.idealPhysSize();t!==this.lastPhysSize&&this.resizeTo(t),this.redraw()}resizeTo(e){this.canvas.width=e,this.canvas.height=e;let t=this.texture;this.texture=Ze.from(this.canvas,!0),this.sprite.texture=this.texture,this.sprite.scale.set(600/e),t.destroy(!0),this.lastPhysSize=e}redraw(){let{ctx:e,canvas:t}=this;if(e.clearRect(0,0,t.width,t.height),!this.lastRaw){this.sprite.visible=!1,this.texture.source.update();return}let n=t.width/600;e.save(),e.scale(n,n);for(let e of this.lastRaw.split(`
|
|
3
|
+
`)){if(!e.trim())continue;let t;try{t=JSON.parse(e)}catch{continue}let n=t.s??{},r=n.opacity??1;switch(t.t){case`l`:this.drawLine(t,n,r);break;case`c`:this.drawCircle(t,n,r);break;case`r`:this.drawRect(t,n,r);break;case`p`:this.drawPoly(t,n,r);break;case`t`:this.drawText(t,n,r);break}}e.restore(),this.texture.source.update(),this.sprite.visible=!0}drawLine(e,t,n){let{ctx:r}=this;r.save(),r.globalAlpha=n,r.strokeStyle=t.color??`#ffffff`,r.lineWidth=(t.width??.1)*12,r.setLineDash(t.lineStyle===`dotted`?sd.dotted:t.lineStyle===`dashed`?sd.dashed:[]),r.beginPath(),r.moveTo(od(e.x1),od(e.y1)),r.lineTo(od(e.x2),od(e.y2)),r.stroke(),r.restore()}drawCircle(e,t,n){let{ctx:r}=this;r.save(),r.globalAlpha=n,r.setLineDash(t.lineStyle===`dotted`?sd.dotted:t.lineStyle===`dashed`?sd.dashed:[]),r.beginPath(),r.arc(od(e.x),od(e.y),(t.radius??.5)*12,0,2*Math.PI),t.fill&&t.fill!==`transparent`&&(r.fillStyle=t.fill,r.fill()),t.stroke&&t.strokeWidth&&(r.strokeStyle=t.stroke,r.lineWidth=t.strokeWidth*12,r.stroke()),r.restore()}drawRect(e,t,n){let{ctx:r}=this;r.save(),r.globalAlpha=n,r.setLineDash(t.lineStyle===`dotted`?sd.dotted:t.lineStyle===`dashed`?sd.dashed:[]),r.beginPath(),r.rect(od(e.x),od(e.y),e.w*12,e.h*12),t.fill&&t.fill!==`transparent`&&(r.fillStyle=t.fill,r.fill()),t.stroke&&t.strokeWidth&&(r.strokeStyle=t.stroke,r.lineWidth=t.strokeWidth*12,r.stroke()),r.restore()}drawPoly(e,t,n){if(!e.points?.length)return;let{ctx:r}=this;r.save(),r.globalAlpha=n,r.setLineDash(t.lineStyle===`dotted`?sd.dotted:t.lineStyle===`dashed`?sd.dashed:[]),r.beginPath(),r.moveTo(od(e.points[0][0]),od(e.points[0][1]));for(let t=1;t<e.points.length;t++)r.lineTo(od(e.points[t][0]),od(e.points[t][1]));t.fill&&t.fill!==`transparent`&&(r.fillStyle=t.fill,r.fill()),t.stroke&&t.strokeWidth&&(r.closePath(),r.strokeStyle=t.stroke,r.lineWidth=t.strokeWidth*12,r.stroke()),r.restore()}drawText(e,t,n){let{ctx:r}=this,i=ld(t.font)*12,a=ud(t.font),o=t.align??`left`,s=od(e.x),c=od(e.y);if(r.save(),r.globalAlpha=n,r.font=`${i}px ${a}`,r.textAlign=o,r.textBaseline=`middle`,t.backgroundColor&&t.backgroundColor!==`transparent`){let n=r.measureText(e.text).width,a=(t.backgroundPadding??.3)*12,l=o===`center`?.5:+(o===`right`);r.fillStyle=t.backgroundColor,r.fillRect(s-l*n-a,c-i/2-a,n+a*2,i+a*2)}r.fillStyle=t.color??`#ffffff`,t.stroke&&t.strokeWidth&&(r.strokeStyle=t.stroke,r.lineWidth=t.strokeWidth*12,r.lineJoin=`round`,r.strokeText(e.text,s,c)),r.fillText(e.text,s,c),r.restore()}destroy(){this.ticker.remove(this.onTick,this),this.texture.destroy(!0),this.container.destroy({children:!0})}},fd=Symbol(`store-raw`),pd=Symbol(`store-node`),md=Symbol(`store-has`),hd=Symbol(`store-self`),gd={onStoreNodeUpdate:null};function _d(e){let t=e[l];if(!t&&(Object.defineProperty(e,l,{value:t=new Proxy(e,Td)}),!Array.isArray(e))){let n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),a=i!==null&&typeof e==`object`&&!!e&&!Array.isArray(e)&&i!==Object.prototype;if(a){let e=Object.getOwnPropertyDescriptors(i);n.push(...Object.keys(e)),Object.assign(r,e)}for(let i=0,o=n.length;i<o;i++){let o=n[i];a&&o===`constructor`||r[o].get&&Object.defineProperty(e,o,{configurable:!0,enumerable:r[o].enumerable,get:r[o].get.bind(t)})}}return t}function vd(e){let t;return typeof e==`object`&&!!e&&(e[l]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function yd(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[fd])return n;if(!vd(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let n=0,a=e.length;n<a;n++)i=e[n],(r=yd(i,t))!==i&&(e[n]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);let n=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);for(let s=0,c=n.length;s<c;s++)a=n[s],!o[a].get&&(i=e[a],(r=yd(i,t))!==i&&(e[a]=r))}return e}function bd(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function xd(e,t,n){if(e[t])return e[t];let[r,i]=a(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function Sd(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===l||t===pd?n:(delete n.value,delete n.writable,n.get=()=>e[l][t],n)}function Cd(e){t()&&xd(bd(e,pd),hd)()}function wd(e){return Cd(e),Reflect.ownKeys(e)}var Td={get(e,n,r){if(n===fd)return e;if(n===l)return r;if(n===h)return Cd(e),r;let i=bd(e,pd),a=i[n],o=a?a():e[n];if(n===pd||n===md||n===`__proto__`)return o;if(!a){let r=Object.getOwnPropertyDescriptor(e,n);t()&&(typeof o!=`function`||e.hasOwnProperty(n))&&!(r&&r.get)&&(o=xd(i,n,o)())}return vd(o)?_d(o):o},has(e,n){return n===fd||n===l||n===h||n===pd||n===md||n===`__proto__`?!0:(t()&&xd(bd(e,md),n)(),n in e)},set(){return console.warn(`Cannot mutate a Store directly`),!0},deleteProperty(){return console.warn(`Cannot mutate a Store directly`),!0},ownKeys:wd,getOwnPropertyDescriptor:Sd};function Ed(e,t,n,r=!1){if(t===`__proto__`){console.warn(`Refusing to set "__proto__" on a store.`);return}if(!r&&e[t]===n)return;let i=e[t],a=e.length;gd.onStoreNodeUpdate&&gd.onStoreNodeUpdate(e,t,n,i),n===void 0?(delete e[t],e[md]&&e[md][t]&&i!==void 0&&e[md][t].$()):(e[t]=n,e[md]&&e[md][t]&&i===void 0&&e[md][t].$());let o=bd(e,pd),s;if((s=xd(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=xd(o,`length`,a))&&s.$(e.length)}(s=o[hd])&&s.$()}function Dd(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];Od(i)||Ed(e,i,t[i])}}function Od(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function kd(e,t){if(typeof t==`function`&&(t=t(e)),t=yd(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){let r=t[n];e[n]!==r&&Ed(e,n,r)}Ed(e,`length`,r)}else Dd(e,t)}function Ad(e,t,n=[]){let r,i=e;if(t.length>1){r=t.shift();let a=typeof r,o=Array.isArray(e);if(a===`string`&&(r===`__proto__`||t.length>1&&Od(r))){console.warn(`Refusing to traverse unsafe key "${r}" on a store.`);return}if(Array.isArray(r)){for(let i=0;i<r.length;i++)Ad(e,[r[i]].concat(t),n);return}else if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&Ad(e,[i].concat(t),n);return}else if(o&&a===`object`){let{from:i=0,to:a=e.length-1,by:o=1}=r;for(let r=i;r<=a;r+=o)Ad(e,[r].concat(t),n);return}else if(t.length>1){Ad(e[r],t,[r].concat(n));return}i=e[r],n=[r].concat(n)}let a=t[0];typeof a==`function`&&(a=a(i,n),a===i)||r===void 0&&a==null||(a=yd(a),r===void 0||vd(i)&&vd(a)&&!Array.isArray(a)?Dd(i,a):Ed(e,r,a))}function jd(...[e,t]){let n=yd(e||{}),r=Array.isArray(n);if(typeof n!=`object`&&typeof n!=`function`)throw Error(`Unexpected type ${typeof n} received when initializing 'createStore'. Expected an object.`);let i=_d(n);v.registerGraph({value:n,name:t&&t.name});function a(...e){p(()=>{r&&e.length===1?kd(n,e[0]):Ad(n,e)})}return[i,a]}var Md=Symbol(`store-root`);function Nd(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function Pd(e,t,n,r,i){if(Nd(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==Md&&(!vd(e)||!vd(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){Ed(t,n,e);return}if(o){if(e.length&&a.length&&(!r||i&&e[0]&&e[0][i]!=null)){let t,n,o,s,c,l,u,d;for(o=0,s=Math.min(a.length,e.length);o<s&&(a[o]===e[o]||i&&a[o]&&e[o]&&a[o][i]&&a[o][i]===e[o][i]);o++)Pd(e[o],a,o,r,i);let f=Array(e.length),p=new Map;for(s=a.length-1,c=e.length-1;s>=o&&c>=o&&(a[s]===e[c]||i&&a[s]&&e[c]&&a[s][i]&&a[s][i]===e[c][i]);s--,c--)f[c]=a[s];if(o>c||o>s){for(n=o;n<=c;n++)Ed(a,n,e[n]);for(;n<e.length;n++)Ed(a,n,f[n]),Pd(e[n],a,n,r,i);a.length>e.length&&Ed(a,`length`,e.length);return}for(u=Array(c+1),n=c;n>=o;n--)l=e[n],d=i&&l?l[i]:l,t=p.get(d),u[n]=t===void 0?-1:t,p.set(d,n);for(t=o;t<=s;t++)l=a[t],d=i&&l?l[i]:l,n=p.get(d),n!==void 0&&n!==-1&&(f[n]=a[t],n=u[n],p.set(d,n));for(n=o;n<e.length;n++)n in f?(Ed(a,n,f[n]),Pd(e[n],a,n,r,i)):Ed(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)Pd(e[t],a,t,r,i);a.length>e.length&&Ed(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)Nd(s[t])||Pd(e[s[t]],a,s[t],r,i);let c=Object.keys(a);for(let t=0,n=c.length;t<n;t++)e[c[t]]===void 0&&Ed(a,c[t],void 0)}function Fd(e,t={}){let{merge:n,key:r=`id`}=t,i=yd(e);return e=>{if(!vd(e)||!vd(i))return i;let t=Pd(i,{[Md]:e},Md,n,r);return t===void 0?e:t}}var Id=new WeakMap;function Ld(e,t){let[n,r]=jd(t),i={id:e,type:t.type,raw:n};return Id.set(i,e=>r(Fd(e,{key:`_id`,merge:!1}))),i}var[Rd,zd]=a([]);function Bd(){zd([])}function Vd(e){zd(t=>t.filter(t=>t.id!==e))}function Hd(e,t){let n=Rd(),r=!1,i=[];for(let a of n){let n=e[a.id];if(n===null){r=!0;continue}if(n!==void 0){let e=t[a.id];e&&Id.get(a)?.(e)}i.push(a)}r&&zd(i)}function Ud(e){let t=Rd();if(t.length===0)return;let n=!1,r=[];for(let i of t){let t=e[i.id];if(!t){n=!0;continue}Id.get(i)?.(t),r.push(i)}n&&zd(r)}var[Wd,Gd]=a(null),[Kd,qd]=a(null),[Jd,Yd]=a(null),[Xd,Zd]=a(null),[Qd,$d]=a(null),[ef,tf]=a({}),[nf,rf]=a(null),[af,of]=a(null),[sf,cf]=a(null),[J,lf]=a(!1),[uf,df]=a(0),[ff,pf]=a(0),[mf,hf]=a(0),[gf,_f]=a(!1),[vf,yf]=a(1),[bf,xf]=a(!1),Sf=null;function Cf(){Sf!==null&&(clearInterval(Sf),Sf=null)}function wf(){Cf(),Sf=setInterval(()=>{let e=uf()+1;e>mf()?(Cf(),_f(!1)):df(e)},Math.max(50,Math.round(1e3/vf())))}var Tf=2e5;function Ef(e,t,n){let r=e,i=Math.max(0,r-(t==null?Tf:t===0?r:t)),a=n&&n>0?n:0,o=a>0?Math.max(i,e-e%a-a):e;hf(r),pf(i),df(Math.max(i,o)),_f(!1),Cf(),lf(!0)}function Df(){Cf(),_f(!1),lf(!1)}function Of(e){df(Math.max(ff(),Math.min(mf(),e)))}function kf(e){Of(uf()+e)}function Af(){gf()?(Cf(),_f(!1)):(_f(!0),wf())}function jf(){Cf(),_f(!1)}function Mf(e){yf(e),gf()&&wf()}var Nf=class extends Error{constructor(e){super(e),this.name=`HistoryUnavailableError`}};function Pf(e){if(e?.status===404)return!0;let t=e?.message;return typeof t==`string`&&t.includes(`HTTP 404`)}var Ff=class{room;shard;http;chunkSize;chunkCache=new Map;inflight=new Map;constructor(e,t,n,r){this.room=e,this.shard=t,this.http=n,this.chunkSize=r}chunkBase(e){return e-e%this.chunkSize}loadChunk(e){let t=this.chunkCache.get(e);if(t)return Promise.resolve(t);let n=this.inflight.get(e);if(n)return n;let r=this.http.game.roomHistory(this.room,e,this.shard).then(t=>(this.chunkCache.set(e,t),this.inflight.delete(e),t)).catch(t=>{throw this.inflight.delete(e),t});return this.inflight.set(e,r),r}applyDiff(e,t){let n={...e};for(let e in t){let r=t[e];r===null?delete n[e]:n[e]?n[e]={...n[e],...r}:n[e]=r}return n}async getStateAtTick(e){let t=this.chunkBase(e),n,r;try{n=await this.loadChunk(t)}catch(i){let a=t-this.chunkSize;if(a<0)throw Pf(i)?new Nf(`No history data available for tick ${e}`):i;try{n=await this.loadChunk(a)}catch(t){throw Pf(t)?new Nf(`No history data available for tick ${e}`):t}t=a;let o=Object.keys(n.ticks).map(Number).filter(e=>e>=t),s=o.length>0?Math.max(...o):t;r=s,e=s}let i=n.ticks[String(t)]??{},a={};for(let e in i)i[e]!==null&&(a[e]=i[e]);for(let r=t+1;r<=e;r++){let e=n.ticks[String(r)];e&&Object.keys(e).length>0&&(a=this.applyDiff(a,e))}return{objects:a,diff:n.ticks[String(e)]??{},gameTime:e,clampedTo:r}}},If=V(`<div style=text-align:center;display:flex;flex-direction:column;align-items:center;gap:6px><div style=font-size:14px;font-weight:600;color:#f85149>You have no rooms!</div><button style="padding:4px 12px;border-radius:4px;border:1px solid #238636;background:#1a3a2a;color:#3fb950;font-size:12px;cursor:pointer">Place Spawn`),Lf=V(`<div style=text-align:center;display:flex;flex-direction:column;align-items:center;gap:6px><div style=font-size:14px;font-weight:600;color:#f85149>You lost all your spawns!</div><button style="padding:4px 12px;border-radius:4px;border:1px solid #da3633;background:#3d1a1a;color:#f85149;font-size:12px;cursor:pointer">Respawn`),Rf=V(`<div style=display:flex;flex-direction:column;gap:2px;text-align:center><span>Moving "<!>" → </span><span style=opacity:0.6;font-size:0.9em>Navigate rooms or change target in sidebar · Right-click to cancel`),zf=V(`<div style=display:flex;flex-direction:column;gap:2px;text-align:center><span></span><span style=opacity:0.6;font-size:0.9em>Right-click to exit flag mode`),Bf=V(`<div style=display:flex;flex-direction:column;gap:2px;text-align:center><span>Select a structure type, then click to build</span><span style=opacity:0.6;font-size:0.9em>Ctrl+click to remove construction sites</span><span style=opacity:0.6;font-size:0.9em>Right-click to exit build mode`),Vf=V(`<div style=display:flex;flex-direction:column;gap:2px;text-align:center><span></span><span style=opacity:0.6;font-size:0.9em>Ctrl+click to remove construction sites</span><span style=opacity:0.6;font-size:0.9em>Right-click to exit build mode`),{log:Hf,warn:Uf,error:Wf}=P(`build`),Gf={COLOR_RED:1,COLOR_PURPLE:2,COLOR_BLUE:3,COLOR_CYAN:4,COLOR_GREEN:5,COLOR_YELLOW:6,COLOR_ORANGE:7,COLOR_BROWN:8,COLOR_GREY:9,COLOR_WHITE:10},Kf={spawn:{0:0,1:1,2:1,3:1,4:1,5:1,6:1,7:2,8:3},extension:{0:0,1:0,2:5,3:10,4:20,5:30,6:40,7:50,8:60},link:{1:0,2:0,3:0,4:0,5:2,6:3,7:4,8:6},road:{0:2500,1:2500,2:2500,3:2500,4:2500,5:2500,6:2500,7:2500,8:2500},constructedWall:{1:0,2:2500,3:2500,4:2500,5:2500,6:2500,7:2500,8:2500},rampart:{1:0,2:2500,3:2500,4:2500,5:2500,6:2500,7:2500,8:2500},storage:{1:0,2:0,3:0,4:1,5:1,6:1,7:1,8:1},tower:{1:0,2:0,3:1,4:1,5:2,6:2,7:3,8:6},observer:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:1},powerSpawn:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:1},extractor:{1:0,2:0,3:0,4:0,5:0,6:1,7:1,8:1},terminal:{1:0,2:0,3:0,4:0,5:0,6:1,7:1,8:1},lab:{1:0,2:0,3:0,4:0,5:0,6:3,7:6,8:10},container:{0:5,1:5,2:5,3:5,4:5,5:5,6:5,7:5,8:5},nuker:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:1},factory:{1:0,2:0,3:0,4:0,5:0,6:0,7:1,8:1}},[qf,Jf]=a(`view`),[Yf,Xf]=a({name:``,color:`COLOR_WHITE`,secondaryColor:`COLOR_WHITE`}),[Zf,Qf]=a(null),[$f,ep]=a(null),[tp,np]=a({structureType:``,structureName:``});x(()=>{s(()=>{let e=tp().structureType;if(!e)return;let t=Jd()??0,n=Kf[e];if(!n)return;let r=E()===`empty`&&e===`spawn`?Math.max(n[t]??0,1):n[t]??0;r!==2500&&(ef()[e]??0)>=r&&(np({structureType:``,structureName:``}),rp())})});function rp(){Qf(null)}function ip(){ep(null)}function ap(){np({structureType:``,structureName:``})}function op(e,t){let n=z(),r=tp(),i=Zf();if(!n||!r.structureType||!i){Uf(`missing requirements`,{hasClient:!!n,structureType:r.structureType,pending:i});return}if(E()===`empty`&&r.structureType===`spawn`){Hf(`placing spawn`,{room:e,x:i.tx,y:i.ty,name:r.structureName||void 0,shard:t??void 0}),n.http.game.placeSpawn(e,i.tx,i.ty,r.structureName||void 0,t??void 0).then(()=>(Hf(`spawn placed`),A(`Spawn placed successfully`,`success`),rp(),n.stores.user.refreshWorldStatus())).catch(e=>{Wf(`place spawn failed:`,e),A(`Failed to place spawn: ${e.message}`,`error`)});return}Hf(`creating construction site`,{room:e,x:i.tx,y:i.ty,structureType:r.structureType,name:r.structureName||void 0,shard:t??void 0}),n.http.game.createConstruction(e,i.tx,i.ty,r.structureType,r.structureName||void 0,t??void 0).then(()=>{Hf(`construction site created`),A(`Construction site for ${r.structureType} created`,`success`),rp()}).catch(e=>{Wf(`create construction failed:`,e),A(`Failed to create construction site: ${e.message}`,`error`)})}function sp(){Jf(`view`),rp(),ip(),ap()}function cp(){Jf(`view`),rp(),m($f)?.type!==`moveFlag`&&ip(),ap()}function lp(){let e=qf(),t=Zf(),n=$f(),r=E();if(r===`empty`)return(()=>{var e=If(),t=e.firstChild.nextSibling;return t.$$click=()=>{Jf(`build`),np({structureType:`spawn`,structureName:``})},e})();if(r===`lost`)return(()=>{var e=Lf(),t=e.firstChild.nextSibling;return t.$$click=()=>{let e=z();e&&e.http.user.respawn().then(()=>{A(`Respawn successful`,`success`),Ee()}).catch(e=>{A(`Respawn failed: ${e.message}`,`error`)})},e})();if(n?.type===`moveFlag`)return(()=>{var e=Rf(),t=e.firstChild,r=t.firstChild.nextSibling;return r.nextSibling,t.nextSibling,C(t,()=>n.name,r),C(t,()=>n.targetRoom,null),e})();if(e===`flag`)return(()=>{var e=zf(),n=e.firstChild;return n.nextSibling,C(n,t?`Click again to confirm position`:`Click to choose flag position`),e})();if(e===`build`){let e=tp(),t=Jd(),n=ef(),r=e.structureType;if(!r)return(()=>{var e=Bf();return e.firstChild.nextSibling.nextSibling,e})();let i=Kf[r]?.[t??0]??0,a=n[r]??0,o=r.replace(/([A-Z])/g,` $1`).trim(),s=i===2500?`${a}/∞`:`${a}/${i}`;return(()=>{var e=Vf(),t=e.firstChild;return t.nextSibling.nextSibling,C(t,`Click to build ${o} (${s})`),e})()}return null}N([`click`]);var up=V(`<div style="position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);padding:16px 22px;border-radius:8px;background:rgba(13, 17, 23, 0.9);border:1px solid #30363d;text-align:center;max-width:320px;pointer-events:none;user-select:none;z-index:11"><div style=font-size:14px;font-weight:600;color:#c9d1d9;margin-bottom:4px>No data available for this tick</div><div style=font-size:12px;color:#8b949e>Use the timeline below to choose another tick.`),dp=V(`<div style="position:absolute;bottom:0;left:0;right:0;padding:8px 12px;background:rgba(13, 17, 23, 0.85);border-top:1px solid #30363d;z-index:10"><input type=range step=1 style=width:100%;cursor:pointer><div style=display:flex;justify-content:space-between;font-size:10px;color:#8b949e;margin-top:2px><span></span><span></span><span>`),fp=V(`<div style=width:100%;height:100%;position:relative><div style=width:100%;height:100%>`),pp=V(`<div style="position:absolute;top:12px;left:50%;transform:translateX(-50%);padding:6px 16px;border-radius:6px;background:rgba(13, 17, 23, 0.65);border:1px solid rgba(48, 54, 61, 0.6);font-size:13px;font-weight:500;color:#c9d1d9;user-select:none;z-index:10">`),mp=V(`<div style="position:absolute;top:8px;right:8px;padding:4px 10px;border-radius:4px;background:rgba(13, 17, 23, 0.8);border:1px solid #30363d;font-size:12px;color:#8b949e;z-index:10">Tick `),{log:hp,error:gp}=P(`room`);function _p(e,t,n=4){e.http.game.genUniqueFlagName().then(r=>{if(r.name===t&&n>0){setTimeout(()=>_p(e,t,n-1),200);return}Xf(e=>({...e,name:r.name}))}).catch(e=>gp(`gen unique flag name failed:`,e))}function vp(e){let t=e=>e==="default"?yt:null,r,o=null,c=null,l=null,u=null,d=null,[p,h]=a(null),[g,v]=a(null),[y,b]=a(null),[x,w]=a(null),[T,D]=a(``),[O,k]=a(!1),[j,ee]=a(uf());s(()=>ee(uf()));let M=null;return i(async()=>{r&&h(await Uo.create(r))}),n(()=>{M!==null&&clearTimeout(M),o?.destroy(),o=null,l?.destroy(),l=null,u?.destroy(),u=null;let e=p();e&&e.destroy()}),s(()=>{let t=z();if(!t)return;let r=e.room,i=e.shard;v(null),b(null),cf(r),of(i);let a=!1;t.stores.room.terrain(r,i).then(e=>{a||(hp(`terrain loaded — ${r}`),v({room:r,data:e}))}).catch(e=>{a||gp(`terrain load failed for ${r}:`,e)}),m(Ut)&&t.http.game.roomDecorations(r,i).then(e=>{a||(hp(`decorations loaded — ${r}: ${e.decorations.length} item(s)`),b({room:r,decoration:os(e)}))}).catch(e=>{a||hp(`no decorations for ${r}: ${e}`)}),n(()=>{a=!0})}),s(()=>{let t=z();if(!t||J())return;let r=e.room,i=e.shard;hp(`navigate → ${r} (shard=${i??`default`})`),w(null),D(``),Te(null),Bd(),Gd(null),qd(null),Yd(null),Zd(null),$d(null),tf({}),rf(null);let a=new rt;a.add(t.stores.room.subscribe(r,i)),a.add(t.stores.room.on(`room:error`,e=>{A(`Room subscription error (${e.room}): ${e.message}`,`error`,8e3)})),a.add(t.stores.room.on(`room:update`,e=>{let t=0,n={},i=0,a=null,o=null,s=null;for(let r in e.objects){t++;let c=e.objects[r];if(!c)continue;let l=c.type;if(typeof l==`string`)if(l===`constructionSite`){let e=c.structureType;typeof e==`string`&&(n[e]=(n[e]||0)+1)}else n[l]=(n[l]||0)+1;if(l===`controller`){if(typeof c.user==`string`){let t=c.user;o={userId:t,username:e.users?.[t]?.username??t},typeof c.level==`number`&&(i=c.level),typeof c.progress==`number`&&(a=c.progress)}let t=c.reservation;t&&typeof t.user==`string`&&typeof t.endTime==`number`&&(s={user:t.user,endTime:t.endTime})}}e.diff||hp(`objects loaded — ${r}: ${t} objects, tick=${e.gameTime}`),w({objects:e.objects,diff:e.diff,users:e.users}),D(e.visual),Te(e.gameTime??null),_e(e.gameTime),Gd(t),qd(o),Yd(i||null),Zd(a),$d(s),tf(n),rf(e.users??null)})),n(()=>{hp(`leaving ${r}`),a.dispose()})}),s(()=>{let t=z();if(!t||!J())return;D(``);let r=e.room,i=e.shard,a=we()??!0,o=ve()?.serverData?.historyChunkSize??(a?20:100),c=m(nf)??void 0,l=new Ff(r,i,t.http,o);s(()=>{let e=uf(),t=!1;xf(!0),l.getStateAtTick(e).then(e=>{if(t)return;if(xf(!1),k(!1),e.clampedTo!==void 0){hf(e.clampedTo),Of(e.clampedTo);return}w({objects:e.objects,diff:void 0,users:c}),Te(e.gameTime);let n=0,r={},i=0,a=null,o=null,s=null;for(let t in e.objects){n++;let l=e.objects[t];if(!l)continue;let u=l.type;if(typeof u==`string`)if(u===`constructionSite`){let e=l.structureType;typeof e==`string`&&(r[e]=(r[e]||0)+1)}else r[u]=(r[u]||0)+1;if(u===`controller`){if(typeof l.user==`string`){let e=l.user;o={userId:e,username:c?.[e]?.username??e},typeof l.level==`number`&&(i=l.level),typeof l.progress==`number`&&(a=l.progress)}let e=l.reservation;e&&typeof e.user==`string`&&typeof e.endTime==`number`&&(s={user:e.user,endTime:e.endTime})}}Gd(n),qd(o),Yd(i||null),Zd(a),$d(s),tf(r)}).catch(n=>{if(!t){if(xf(!1),n instanceof Nf){if(k(!0),gf()){let t=l.chunkBase(e)+o;t<=mf()?Of(t):jf()}return}k(!1),A(`History load failed for tick ${e}: ${n.message}`,`error`,5e3)}}),n(()=>{t=!0})}),n(()=>k(!1))}),s(()=>{let t=p();if(!t)return;e.room,e.shard,cp(),t.hoverLayer.clearPendingTile();let n=m($f);n?.type===`moveFlag`?ep({...n,targetRoom:e.room}):t.resetView(),d?.destroy(),d=null,t.clear(),t.resetView(),o?.destroy(),o=null,l?.destroy(),l=null,u?.destroy(),u=null;let r=m(g);if(r&&r.room===e.room){hp(`terrain applied immediately (pre-loaded) — ${e.room}`);let n=m(y);d=$o(r.data,t.app.renderer,n?.room===e.room?n.decoration.terrain:void 0),es(d,m(Ot)),d.zIndex=Vo.terrain,t.world.addChild(d),t.bringNavOverlayToTop()}let i=e.room,a=e.shard,s=Wn(i),c=m(()=>e.onNavigate),f=m(F);if(s&&c){let e=(e,t)=>!f||an(e,t,f),n=e=>{hp(`navigate requested: ${i} → ${e}`),c(e,a)};t.setupNavigationZones({west:e(s.x-1,s.y)?()=>n(en(s.x-1,s.y)):void 0,east:e(s.x+1,s.y)?()=>n(en(s.x+1,s.y)):void 0,north:e(s.x,s.y-1)?()=>n(en(s.x,s.y-1)):void 0,south:e(s.x,s.y+1)?()=>n(en(s.x,s.y+1)):void 0})}}),s(()=>{let t=p();if(!t)return;let n=m(()=>e.room),r=m(()=>e.shard),i=Wn(n);if(i&&e.onNavigate){let a=e.onNavigate,o=F(),s=(e,t)=>!o||an(e,t,o),c=e=>{hp(`navigate requested: ${n} → ${e}`),a(e,r)};hn({currentRoom:()=>e.room,worldBounds:F,onMove:(e,t)=>c(en(e,t))}),t.setupNavigationZones({west:s(i.x-1,i.y)?()=>c(en(i.x-1,i.y)):void 0,east:s(i.x+1,i.y)?()=>c(en(i.x+1,i.y)):void 0,north:s(i.x,i.y-1)?()=>c(en(i.x,i.y-1)):void 0,south:s(i.x,i.y+1)?()=>c(en(i.x,i.y+1)):void 0})}}),s(()=>{let e=qf(),t=p();e===`view`&&t&&(rp(),t.hoverLayer.clearPendingTile())}),s(()=>{let e=p(),t=Zf();e&&(t?e.hoverLayer.setPendingTile(t.tx,t.ty):e.hoverLayer.clearPendingTile())}),s(()=>{let t=p(),n=g();if(!t||!n||n.room!==e.room)return;if(d?.parent){hp(`terrain already in scene, skipping — ${e.room}`);return}hp(`terrain applied (async) — ${e.room}`);let r=m(y);d=$o(n.data,t.app.renderer,r?.room===e.room?r.decoration.terrain:void 0),es(d,m(Ot)),t.world.addChildAt(d,0),t.bringNavOverlayToTop()}),s(()=>{if(Ut())return;b(null);let t=m(p),n=m(g);!t||!n||n.room!==e.room||d?.parent&&(d.destroy(),d=$o(n.data,t.app.renderer),es(d,m(Ot)),t.world.addChildAt(d,0),t.bringNavOverlayToTop(),o?.setRoadColor(bt),o?.setWallColor(G))}),s(()=>{let t=p(),n=y(),r=m(g);!t||!n||n.room!==e.room||!r||r.room!==e.room||d?.parent&&(hp(`decoration arrived, rebuilding terrain layer — ${e.room}`),d.destroy(),d=$o(r.data,t.app.renderer,n.decoration.terrain),es(d,m(Ot)),t.world.addChildAt(d,0),t.bringNavOverlayToTop(),o&&n.decoration.roadColor!=null&&o.setRoadColor(n.decoration.roadColor),o&&n.decoration.terrain?.wallFillColor!=null&&o.setWallColor(n.decoration.terrain.wallFillColor))}),s(()=>{let n=p(),r=x();if(!n)return;if(!r){o?.clear(),l?.clear(),n.clearLighting();return}let{objects:i,diff:a,users:s}=r,d=o?a:void 0;if(!o){hp(`object layer created — ${e.room}`),o=new $u(n.app.ticker,Tt(),U()?._id,U()?.badge,s),o.setTheme(t(m(Yt)),Gt),o.setInstantMode(m(J));let r=m(y);r?.room===e.room&&(r.decoration.roadColor!=null&&o.setRoadColor(r.decoration.roadColor),r.decoration.terrain?.wallFillColor!=null&&o.setWallColor(r.decoration.terrain.wallFillColor)),o.setLightingLayer(n.lighting),o.container.label=`objects`,o.container.zIndex=Vo.objects,n.world.addChild(o.container),l=new ad(n.app.ticker),l.container.label=`animations`,l.container.zIndex=Vo.animations,n.world.addChild(l.container),u=new dd(n.app.renderer,n.world,n.app.ticker),u.container.zIndex=Vo.visuals,n.world.addChild(u.container),n.setTileHandlers((e,t)=>{},(t,r,i)=>{let a=e.room,s=e.shard,c=qf(),l=$f();if(l?.type===`moveFlag`){let e=z();if(!e)return;let{name:n,room:i,color:a,secondaryColor:o,targetRoom:c}=l;e.http.game.removeFlag(i,n,s??void 0).then(()=>e.http.game.createFlag(c,t,r,n,a,o,s??void 0)).then(()=>{A(`Flag "${n}" moved`,`success`),ip()}).catch(e=>{gp(`move flag failed:`,e),A(`Failed to move flag "${n}"`,`error`),ip()});return}if(c===`flag`){let e=Zf();if(!e||e.tx!==t||e.ty!==r){Qf({tx:t,ty:r}),n.hoverLayer.setPendingTile(t,r);return}let i=z();if(!i)return;let o=Yf(),c=o.name.trim();if(!c){A(`Flag name is required`,`error`);return}let l=Gf[o.color]??0,u=Gf[o.secondaryColor]??0;i.http.game.createFlag(a,t,r,c,l,u,s??void 0).then(()=>{A(`Flag "${c}" created`,`success`),rp(),n.hoverLayer.clearPendingTile(),_p(i,c)}).catch(e=>gp(`create flag failed:`,e));return}if(c===`build`){if(!i&&!tp().structureType){A(`Select a structure type first`,`error`);return}if(i){if(!o)return;let e=o.getObjectsAtTile(t,r).filter(({obj:e})=>e.type===`constructionSite`);if(e.length===0){A(`No construction sites on this tile`,`error`);return}let i=z();if(!i)return;i.http.game.removeConstructionSite(a,e.map(({id:e})=>e),s??void 0).then(()=>{A(`Removed ${e.length} construction site${e.length>1?`s`:``}`,`success`),rp(),n.hoverLayer.clearPendingTile()}).catch(e=>{gp(`remove construction sites failed:`,e),A(`Failed to remove construction sites: ${e.message}`,`error`)});return}Qf({tx:t,ty:r}),n.hoverLayer.setPendingTile(t,r),op(a,s);return}if(rp(),n.hoverLayer.clearPendingTile(),!o)return;let u=o.getObjectsAtTile(t,r);if(u.length===0){i||(zd([]),n.hoverLayer.clearSelection());return}let d=[...Rd()];if(i){let e=new Set(u.map(e=>e.id));if(d.some(t=>e.has(t.id)))d=d.filter(t=>!e.has(t.id));else{let e=u.filter(({id:e})=>!d.some(t=>t.id===e)).map(({id:e,obj:t})=>Ld(e,t));d=[...d,...e]}}else d=u.map(({id:e,obj:t})=>Ld(e,t));zd(d);let f=d.map(({id:e,type:t})=>({id:e,type:t,visual:o.getVisualById(e)})).filter(e=>e.visual!=null);n.hoverLayer.setSelectedObjects(f)},()=>{let e=qf();(e===`build`||e===`flag`||$f()?.type===`moveFlag`)&&(sp(),n.hoverLayer.clearPendingTile())})}d?Hd(d,i):Ud(i);let f=J()?Math.round(1e3/m(vf)):Fe()??2e3,h=f*.6,g=Math.round(f*.9);o.setMoveDuration(g),o.setTickDuration(f),c={objects:i,users:s},o.update(i,d,s,Ae()??void 0),o.setShowLabels(m(Tt));let _=new Set;if(l){l.clear();for(let e in i){let t=i[e];if(!t)continue;let n=t.actionLog;if(!n)continue;if(t.type===`tower`){let r=n.attack,i=n.heal,a=n.repair;r&&l.addTowerAttack(t.x,t.y,r.x,r.y,h),i&&l.addTowerHeal(t.x,t.y,i.x,i.y,h),a&&l.addTowerRepair(t.x,t.y,a.x,a.y,h);let s=r??i??a;s&&o?.triggerTowerAim(e,s.x,s.y,h);continue}if(t.type===`link`){let e=n.transferEnergy;e&&l.addLinkTransfer(t.x,t.y,e.x,e.y,h);continue}if(t.type===`lab`){let e=n.runReaction??n.reverseReaction;e&&(l.addLabReaction(e.x1,e.y1,t.x,t.y,h),l.addLabReaction(e.x2,e.y2,t.x,t.y,h));continue}if(t.type!==`creep`)continue;let r=n.harvest;r&&l.addHarvest(r.x,r.y,t.x,t.y,h);let a=n.upgradeController;a&&l.addUpgradeController(t.x,t.y,a.x,a.y,h);let s=n.build;s&&(l.addBuild(t.x,t.y,s.x,s.y,h),o?.triggerBuildAt(s.x,s.y,h));let c=n.repair;c&&l.addRepair(t.x,t.y,c.x,c.y,h);let u=n.transfer;u&&l.addTransfer(t.x,t.y,u.x,u.y,h);let d=n.say;if(d&&typeof d.message==`string`&&d.message.length>0){let n=U()?._id;(d.isPublic===!0||n!=null&&t.user===n)&&(o?.triggerSay(e,d.message),_.add(e))}}}o.pruneSayBubblesExcept(_),m(Hn)&&n.updateLighting(i)}),s(()=>{let e=T();u?.update(Kn()?e:``)}),s(()=>{o?.setInstantMode(J())}),s(()=>{let e=Ot();d&&es(d,e)}),s(()=>{let e=p();if(!e)return;let t=Hn();e.darkOverlay.visible=t,e.lightLayer.visible=t,t||e.clearLighting()}),s(()=>{let e=t(Yt());o&&(o.setTheme(e,Gt),c&&(o.clear(),o.update(c.objects,void 0,c.users)))}),(()=>{var e=fp(),t=e.firstChild;return je(e=>r=e,t),C(e,(()=>{var e=R(()=>!!lp());return()=>e()&&(()=>{var e=pp();return C(e,lp),S(t=>H(e,`pointer-events`,E()===`empty`||E()===`lost`?`auto`:`none`)),e})()})(),null),C(e,(()=>{var e=R(()=>!J()&&Ae()!==null);return()=>e()&&(()=>{var e=mp();return e.firstChild,C(e,Ae,null),e})()})(),null),C(e,f(_,{get when(){return R(()=>!!J())()&&O()},get children(){var e=up();return e.firstChild.nextSibling,e}}),null),C(e,f(_,{get when(){return J()},get children(){var e=dp(),t=e.firstChild,n=t.nextSibling.firstChild,r=n.nextSibling,i=r.nextSibling;return t.$$input=e=>{let t=parseInt(e.currentTarget.value,10);ee(t),M!==null&&clearTimeout(M),M=setTimeout(()=>{M=null,Of(t)},150)},C(n,ff),C(r,(()=>{var e=R(()=>!!bf());return()=>e()?`Loading…`:`Tick ${uf()}`})()),C(i,mf),S(e=>{var n=ff(),i=mf(),a=bf()?`#f0883e`:`#8b949e`;return n!==e.e&&B(t,`min`,e.e=n),i!==e.t&&B(t,`max`,e.t=i),a!==e.a&&H(r,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),S(()=>t.value=j()),e}}),null),e})()}N([`input`]);var yp=V(`<div style=position:fixed;bottom:16px;right:16px;display:flex;flex-direction:column;gap:8px;z-index:9999;pointer-events:none>`),bp=V(`<div style="padding:10px 16px;border-radius:6px;font-size:13px;color:#fff;box-shadow:0 4px 12px rgba(0,0,0,0.4);max-width:320px;word-break:break-word;pointer-events:auto;animation:toast-in 0.2s ease">`);function xp(){return(()=>{var e=yp();return C(e,f(u,{get each(){return te()},children:e=>(()=>{var t=bp();return C(t,()=>e.message),S(n=>H(t,`background`,e.type===`error`?`#da3633`:`#238636`)),t})()})),e})()}var[Sp,Cp]=a(!0),[wp,Tp]=a(!0),[Ep,Dp]=a(!1),[Op,kp]=a(``),Ap;function jp(e){Ap=e}function Mp(e){kp(e),Tp(!0),requestAnimationFrame(()=>{Ap?.focus();let t=e.length;Ap?.setSelectionRange(t,t)})}function Np(){Cp(e=>!e)}function Pp(){Tp(e=>!e)}function Fp(){Dp(e=>!e)}var[Ip,Lp]=a(w(D.memoryWatches,[])),[Rp,zp]=a(null),[Bp,Vp]=jd({});function Hp(e){let t=e.trim();t&&(Lp(e=>e.includes(t)?e:[...e,t]),k(D.memoryWatches,Ip()))}function Up(e){Lp(t=>t.filter(t=>t!==e)),k(D.memoryWatches,Ip())}function Wp(){zp(null)}function Gp(e,t){zp({creepId:e,name:t})}function Kp(e,t){let n=[...t];if(e){let t=`creeps.${e.name}`;n.includes(t)||n.push(t)}return n}function qp(e){let t=new Map,r=()=>{let n=z();if(!n)return;let r=new Set(Kp(Rp(),Ip()));for(let i of r)t.has(i)||t.set(i,n.stores.user.subscribeMemory(i,e));for(let[e,n]of t)r.has(e)||(n.dispose(),t.delete(e))};s(()=>{Ip(),Rp(),r()});let i=z(),a=null;return i?a=i.stores.user.on(`user:memory`,e=>{Vp(e.path,e.value)}):console.warn(`[memoryStore] no client available when initMemorySubscriptions called`),n(()=>{for(let e of t.values())e.dispose();t.clear(),a?.dispose()}),r(),()=>{for(let e of t.values())e.dispose();t.clear(),a?.dispose()}}x(()=>{s(()=>{let e=Rp();e&&(Rd().some(t=>t.id===e.creepId)||Wp())})});var Jp=V(`<button style=color:#8b949e>`),Yp=V(`<span style=width:18px;flex-shrink:0>`),Xp=V(`<span style=color:#484f58;font-style:italic>{…}`),Zp=V(`<span style=color:#484f58;font-style:italic>`),Qp=V(`<button title=Reload>`),$p=V(`<span title="Click to edit"style=cursor:text;flex:1>`),em=V(`<input type=text autofocus style="background:#161b22;border:1px solid #388bfd;color:#c9d1d9;border-radius:3px;padding:0 4px;font-size:12px;font-family:inherit;flex:1;min-width:60px">`),tm=V(`<button title=Save style=color:#3fb950>`),nm=V(`<button title=Discard style=color:#f85149>`),rm=V(`<div><div style=display:flex;align-items:center;gap:2px;min-height:20px><span style=color:#8b949e;flex-shrink:0></span><span style="color:#484f58;margin:0 2px;flex-shrink:0">:</span><button>`),{error:im}=P(`MemoryTree`);function am(e){return typeof e==`object`&&!!e&&`__screeps_object__`in e}var om={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},sm={background:`transparent`,border:`none`,color:`#8b949e`,cursor:`pointer`,padding:`2px`,"border-radius":`3px`,display:`inline-flex`,"align-items":`center`,"justify-content":`center`,"flex-shrink":0};function cm(e){return e.replace(/^Memory\.?/,``)}function lm(e){let[t,n]=a((e.depth??0)<2),r=()=>e.depth??0,[o,s]=a(!1),[c,l]=a(``),[d,p]=a(!1),[m,h]=a(void 0),g=()=>am(e.value)&&m()!==void 0?m():e.value,v=()=>{let e=g();return!am(e)&&typeof e==`object`&&!!e},y=()=>v()?Object.entries(g()):[],b=()=>y().length,x=async()=>{p(!0);try{let t=z();if(!t)return;let n=cm(e.path),r=await t.http.user.memory.get(n,e.shard);h(r.data===`[object Object]`?{__screeps_object__:!0}:r.data)}catch(e){im(`fetch memory failed`,e)}finally{p(!1)}},w=()=>{h(void 0),x()};i(()=>{t()&&am(e.value)&&m()===void 0&&x()});let T=async()=>{if(am(e.value)&&m()===void 0){await x(),n(!0);return}t()&&h(void 0),n(e=>!e)},E=async()=>{let t=c().trim(),n;if(t===`null`)n=null;else if(t===`true`)n=!0;else if(t===`false`)n=!1;else{let e=Number(t);if(!Number.isNaN(e)&&t!==``)n=e;else try{n=JSON.parse(t)}catch{n=t}}let r=z();if(!r)return;let i=cm(e.path);try{await r.http.user.memory.set(i,n,e.shard)}catch(e){im(`set memory failed`,e),s(!1);return}s(!1),e.onRefresh?.()},D=()=>{let e=g();return v()?`#c9d1d9`:typeof e==`string`?`#3fb950`:typeof e==`number`?`#79c0ff`:typeof e==`boolean`?`#a371f7`:`#8b949e`},O=()=>{let e=g();return e===null?`null`:e===void 0?`undefined`:typeof e==`string`?JSON.stringify(e):String(e)};return(()=>{var n=rm(),i=n.firstChild,a=i.firstChild,p=a.nextSibling.nextSibling;return C(i,f(_,{get when(){return v()||am(g())},get children(){var e=Jp();return e.$$click=()=>void T(),C(e,f(_,{get when(){return d()},get children(){return f(ei,{size:12,style:{animation:`spin 1s linear infinite`}})}}),null),C(e,f(_,{get when(){return!d()},get children(){return f(_,{get when(){return t()},get fallback(){return f(vr,{size:12})},get children(){return f(gr,{size:12})}})}}),null),S(n=>{var r={...sm},i=t()?`Collapse`:`Expand`,a=d();return n.e=L(e,r,n.e),i!==n.t&&B(e,`title`,n.t=i),a!==n.a&&(e.disabled=n.a=a),n},{e:void 0,t:void 0,a:void 0}),e}}),a),C(i,f(_,{get when(){return R(()=>!v())()&&!am(g())},get children(){return Yp()}}),a),C(a,()=>e.label),C(i,f(_,{get when(){return am(g())},get children(){return Xp()}}),p),C(i,f(_,{get when(){return v()},get children(){var e=Zp();return C(e,(()=>{var e=R(()=>!!Array.isArray(g()));return()=>e()?`[${b()}]`:`{${b()}}`})()),e}}),p),C(i,f(_,{get when(){return R(()=>!!am(e.value))()&&!d()},get children(){var e=Qp();return e.$$click=()=>w(),C(e,f(wi,{size:11})),S(t=>L(e,sm,t)),e}}),p),C(i,f(_,{get when(){return R(()=>!v())()&&!am(g())},get children(){return[f(_,{get when(){return!o()},get children(){var e=$p();return e.$$click=()=>{l(O()),s(!0)},C(e,O),S(t=>H(e,`color`,D())),e}}),f(_,{get when(){return o()},get children(){return[(()=>{var e=em();return e.$$keydown=e=>{e.key===`Enter`&&E(),e.key===`Escape`&&s(!1)},e.$$input=e=>l(e.currentTarget.value),S(()=>e.value=c()),e})(),(()=>{var e=tm();return e.$$mousedown=e=>{e.preventDefault(),E()},C(e,f(mr,{size:12})),S(t=>L(e,{...sm},t)),e})(),(()=>{var e=nm();return e.$$mousedown=e=>{e.preventDefault(),s(!1)},C(e,f(Ji,{size:12})),S(t=>L(e,{...sm},t)),e})()]}})]}}),p),p.$$click=()=>Mp(`Memory.${cm(e.path)} = `),C(p,f(Hi,{size:11})),C(n,f(_,{get when(){return R(()=>!!v())()&&t()},get children(){return f(u,{get each(){return y()},children:([t,n])=>f(lm,{value:n,path:Array.isArray(g())?`${e.path}[${t}]`:`${e.path}.${t}`,label:t,get shard(){return e.shard},get depth(){return r()+1},get onRefresh(){return R(()=>!!am(e.value))()?w:e.onRefresh}})})}}),null),S(t=>{var i={"padding-left":r()>0?`14px`:`0`,...om},a=sm,o=`Insert Memory.${cm(e.path)} = into console`;return t.e=L(n,i,t.e),t.t=L(p,a,t.t),o!==t.a&&B(p,`title`,t.a=o),t},{e:void 0,t:void 0,a:void 0}),n})()}function um(e){return f(lm,{get value(){return e.value},get path(){return e.path},get label(){return e.label},get shard(){return e.shard},depth:0})}N([`click`,`input`,`keydown`,`mousedown`]);var dm=V(`<div style=color:#484f58;font-style:italic>No paths watched — add one below.`),fm=V(`<div style=flex-shrink:0;display:flex;flex-direction:column;overflow:hidden><div class=console-scroll style=flex:1;overflow:auto;padding:8px></div><form style="display:flex;gap:6px;padding:8px;border-top:1px solid #30363d"><input type=text placeholder=creeps.Harvester1.energy style="flex:1;padding:6px 8px;border-radius:4px;border:1px solid #30363d;background:#161b22;color:#c9d1d9;font-size:12px;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"><button type=submit title="Add watch"style="padding:6px 8px;border-radius:4px;border:none;background:#238636;color:#fff;font-size:12px;cursor:pointer;display:flex;align-items:center;gap:4px"> Watch`),pm=V(`<div style=margin-bottom:8px><div style="display:flex;align-items:center;gap:4px;border-bottom:1px solid #21262d;padding-bottom:4px;margin-bottom:4px"><span style=color:#f0883e;font-weight:600;flex:1></span><span style=color:#484f58;font-size:10px;font-style:italic>temp</span><button title="Remove temp watch">`),mm=V(`<div style=margin-bottom:8px><div style="display:flex;align-items:center;gap:4px;border-bottom:1px solid #21262d;padding-bottom:4px;margin-bottom:4px"><span style=color:#c9d1d9;font-weight:600;flex:1></span><button title="Remove watch">`),hm=V(`<div style=flex-shrink:0;display:flex;overflow:hidden><div style="width:32px;flex-shrink:0;border-right:1px solid #30363d;display:flex;flex-direction:column;align-items:center;padding:6px 0;gap:6px"><button></button><button title=Clear></button></div><div class=console-scroll style=flex:1;overflow:auto;padding:8px>`),gm=V(`<div style=width:4px;flex-shrink:0;cursor:col-resize>`),_m=V(`<div style=flex-shrink:0;display:flex;flex-direction:column;overflow:hidden><div class=console-scroll style=flex:1;overflow:auto;padding:8px></div><form style="display:flex;gap:6px;padding:8px;border-top:1px solid #30363d"><span style=color:#8b949e;font-size:13px;line-height:28px>></span><input type=text placeholder="Game.creeps.Harvester1.moveTo(10, 10)"style="flex:1;padding:6px 8px;border-radius:4px;border:1px solid #30363d;background:#161b22;color:#c9d1d9;font-size:12px;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"><button type=submit style="padding:6px 12px;border-radius:4px;border:none;background:#238636;color:#fff;font-size:12px;cursor:pointer">Run`),vm=V(`<div style=flex:1;display:flex;overflow:hidden>`),ym=V(`<div style=display:flex;flex-direction:column;height:100%;background:#0d1117><div style="height:32px;flex-shrink:0;padding:0 10px;border-bottom:1px solid #30363d;display:flex;align-items:center;gap:6px"><button>Log</button><button>Console</button><button>Memory</button></div><style>
|
|
4
|
+
.console-scroll::-webkit-scrollbar {
|
|
5
|
+
width: 8px;
|
|
6
|
+
height: 8px;
|
|
7
|
+
}
|
|
8
|
+
.console-scroll::-webkit-scrollbar-track {
|
|
9
|
+
background: #161b22;
|
|
10
|
+
}
|
|
11
|
+
.console-scroll::-webkit-scrollbar-thumb {
|
|
12
|
+
background: #484f58;
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
}
|
|
15
|
+
.console-scroll::-webkit-scrollbar-thumb:hover {
|
|
16
|
+
background: #6e7681;
|
|
17
|
+
}
|
|
18
|
+
`),bm=V(`<div style=color:#484f58;font-style:italic>No log output yet…`),xm=V(`<div style=margin-bottom:4px;color:#f85149;white-space:pre-wrap;word-break:break-word>`),Sm=V(`<div style=margin-bottom:4px;color:#c9d1d9;white-space:pre-wrap;word-break:break-word>`),Cm=V(`<div style=color:#484f58;font-style:italic>No command results yet…`),wm=V(`<div style=margin-bottom:4px;color:#58a6ff;white-space:pre-wrap;word-break:break-word>`),{error:Tm}=P(`console`);function Em(e){let[t,n]=a(``),r=()=>e.shard??af();i(()=>{qp(r())});let o={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},s={background:`transparent`,border:`none`,color:`#8b949e`,cursor:`pointer`,padding:`4px`,"border-radius":`4px`,display:`flex`,"align-items":`center`,"justify-content":`center`};return(()=>{var i=fm(),a=i.firstChild,c=a.nextSibling,l=c.firstChild,d=l.nextSibling,p=d.firstChild;return C(a,f(_,{get when(){return Rp()},children:e=>{let t=`creeps.${e().name}`;return(()=>{var e=pm(),n=e.firstChild.firstChild,i=n.nextSibling.nextSibling;return C(n,t),I(i,`click`,Wp,!0),C(i,f(Ji,{size:12})),C(e,f(um,{get value(){return Bp[t]},path:`Memory.${t}`,label:t,get shard(){return r()}}),null),S(e=>L(i,s,e)),e})()}}),null),C(a,f(u,{get each(){return Ip()},children:e=>(()=>{var t=mm(),n=t.firstChild.firstChild,i=n.nextSibling;return C(n,e),i.$$click=()=>Up(e),C(i,f(Ji,{size:12})),C(t,f(um,{get value(){return Bp[e]},path:`Memory.${e}`,label:e,get shard(){return r()}}),null),S(e=>L(i,s,e)),t})()}),null),C(a,f(_,{get when(){return R(()=>Ip().length===0)()&&!Rp()},get children(){return dm()}}),null),c.addEventListener(`submit`,e=>{e.preventDefault(),Hp(t()),n(``)}),l.$$input=e=>n(e.currentTarget.value),C(d,f(Si,{size:14}),p),S(t=>{var n=`${e.width*100}%`,r={...o};return n!==t.e&&H(i,`width`,t.e=n),t.t=L(a,r,t.t),t},{e:void 0,t:void 0}),S(()=>l.value=t()),i})()}function Dm(e){let[t,r]=a([]),[o,c]=a(!0),[l,d]=a(w(D.consoleWeights,[1,1,1])),[p,m]=a(null),h,g,v,y=0;i(()=>{let e=z();if(!e)return;let t=new rt;t.add(e.stores.user.subscribe(`console`)),t.add(e.stores.user.on(`user:console`,e=>{let t=e.messages,n={id:y++,log:t.log??[],results:t.results??[],error:t.error??[]};r(e=>{let t=[...e,n];return t.length>200?t.slice(t.length-200):t})})),n(()=>t.dispose())}),s(()=>{t(),o()&&requestAnimationFrame(()=>{Sp()&&h&&(h.scrollTop=h.scrollHeight),wp()&&g&&(g.scrollTop=g.scrollHeight)})});let b=(t,n,r)=>{let i=!t&&!n&&!r;i&&!e.isCollapsed&&e.onToggle?.(),!i&&e.isCollapsed&&e.onToggle?.()};s(()=>{b(Sp(),wp(),Ep())});let x=()=>{let e=l(),t=[Sp(),wp(),Ep()],n=t.filter(Boolean).length;if(n===0)return[0,0,0];if(n===1){let e=t.findIndex(Boolean);return[0,0,0].map((t,n)=>+(n===e))}let r=t.map((t,n)=>t?e[n]:0).reduce((e,t)=>e+t,0);if(r===0){let e=1/n;return[0,0,0].map((n,r)=>t[r]?e:0)}return t.map((t,n)=>t?e[n]/r:0)};s(()=>{k(D.consoleWeights,l())});let T=e=>t=>{t.preventDefault(),t.stopPropagation(),m(e),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,E),window.addEventListener(`pointerup`,O,{once:!0})},E=e=>{let t=p();if(t===null)return;let n=v;if(!n)return;let r=n.getBoundingClientRect(),i=Math.max(.02,Math.min(.98,(e.clientX-r.left)/r.width)),a=[...l()],o=[Sp(),wp(),Ep()];if(t===0){let e=o[0],t=o[1];if(!e||!t)return;a[0]=i/(1-i),a[1]=1,d(a)}else{let e=o[1],t=o[2];if(!e||!t)return;a[1]=i/(1-i),a[2]=1,d(a)}},O=()=>{m(null),document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,E)},[A,j]=a([]),[ee,M]=a(null),[te,ne]=a(``),re=e=>{let t=A();if(t.length!==0){if(e.key===`ArrowUp`){e.preventDefault();let n=ee();n===null?(ne(Op()),M(t.length-1),kp(t[t.length-1])):n>0&&(M(n-1),kp(t[n-1]))}else if(e.key===`ArrowDown`){e.preventDefault();let n=ee();if(n===null)return;n<t.length-1?(M(n+1),kp(t[n+1])):(M(null),kp(te()))}}},ie=async t=>{t.preventDefault();let n=z(),r=Op().trim();if(!(!n||!r))try{await n.http.user.console(r,e.shard??`shard0`),j(e=>[...e,r]),M(null),ne(``),kp(``)}catch(e){Tm(`command failed:`,e)}},ae=e=>({background:e?`#30363d`:`transparent`,border:`1px solid ${e?`#58a6ff`:`transparent`}`,color:e?`#c9d1d9`:`#8b949e`,"font-size":`12px`,cursor:`pointer`,padding:`2px 10px`,"border-radius":`4px`}),oe=()=>t().flatMap(e=>e.log),N=()=>t().flatMap(e=>e.error),P=()=>t().flatMap(e=>e.results),F={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},se={background:`transparent`,border:`none`,color:`#8b949e`,cursor:`pointer`,padding:`4px`,"border-radius":`4px`,display:`flex`,"align-items":`center`,"justify-content":`center`},ce=()=>{c(!0),requestAnimationFrame(()=>{Sp()&&h&&(h.scrollTop=h.scrollHeight),wp()&&g&&(g.scrollTop=g.scrollHeight)})};return(()=>{var t=ym(),n=t.firstChild,i=n.firstChild,a=i.nextSibling,s=a.nextSibling;return n.nextSibling,I(i,`click`,Np,!0),I(a,`click`,Pp,!0),I(s,`click`,Fp,!0),C(t,f(_,{get when(){return!e.isCollapsed},get children(){var t=vm();return je(e=>v=e,t),C(t,f(_,{get when(){return Sp()},get children(){var e=hm(),t=e.firstChild,n=t.firstChild,i=n.nextSibling,a=t.nextSibling;n.$$click=()=>o()?c(!1):ce(),C(n,(()=>{var e=R(()=>!!o());return()=>e()?f(gi,{size:16}):f(bi,{size:16})})()),i.$$click=()=>r([]),C(i,f(Wi,{size:16})),a.addEventListener(`scroll`,()=>{h&&c(h.scrollHeight-h.scrollTop-h.clientHeight<20)});var s=h;return typeof s==`function`?je(s,a):h=a,C(a,(()=>{var e=R(()=>oe().length===0&&N().length===0);return()=>e()&&bm()})(),null),C(a,f(u,{get each(){return N()},children:e=>(()=>{var t=xm();return t.innerHTML=e,t})()}),null),C(a,f(u,{get each(){return oe()},children:e=>(()=>{var t=Sm();return t.innerHTML=e,t})()}),null),S(t=>{var r=`${x()[0]*100}%`,s=o()?`Pause scrolling`:`Resume scrolling`,c=se,l=se,u={...F};return r!==t.e&&H(e,`width`,t.e=r),s!==t.t&&B(n,`title`,t.t=s),t.a=L(n,c,t.a),t.o=L(i,l,t.o),t.i=L(a,u,t.i),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),C(t,f(_,{get when(){return R(()=>!!Sp())()&&wp()},get children(){var e=gm();return I(e,`pointerdown`,T(0),!0),S(t=>H(e,`background`,p()===0?`#388bfd`:`#21262d`)),e}}),null),C(t,f(_,{get when(){return wp()},get children(){var e=_m(),t=e.firstChild,n=t.nextSibling,r=n.firstChild.nextSibling;r.nextSibling,t.addEventListener(`scroll`,()=>{g&&c(g.scrollHeight-g.scrollTop-g.clientHeight<20)});var i=g;return typeof i==`function`?je(i,t):g=t,C(t,(()=>{var e=R(()=>P().length===0);return()=>e()&&Cm()})(),null),C(t,f(u,{get each(){return P()},children:e=>(()=>{var t=wm();return t.innerHTML=e,t})()}),null),n.addEventListener(`submit`,ie),r.$$keydown=re,r.$$input=e=>{M(null),kp(e.currentTarget.value)},je(e=>jp(e),r),S(n=>{var r=`${x()[1]*100}%`,i={...F};return r!==n.e&&H(e,`width`,n.e=r),n.t=L(t,i,n.t),n},{e:void 0,t:void 0}),S(()=>r.value=Op()),e}}),null),C(t,f(_,{get when(){return R(()=>!!wp())()&&Ep()},get children(){var e=gm();return I(e,`pointerdown`,T(1),!0),S(t=>H(e,`background`,p()===1?`#388bfd`:`#21262d`)),e}}),null),C(t,f(_,{get when(){return Ep()},get children(){return f(Em,{get shard(){return e.shard??null},get width(){return x()[2]}})}}),null),S(e=>H(t,`user-select`,p()===null?`auto`:`none`)),t}}),null),S(e=>{var t=ae(Sp()),n=ae(wp()),r=ae(Ep());return e.e=L(i,t,e.e),e.t=L(a,n,e.t),e.a=L(s,r,e.a),e},{e:void 0,t:void 0,a:void 0}),t})()}N([`input`,`click`,`pointerdown`,`keydown`]);var Om=V(`<div style=display:flex;gap:5px;flex-wrap:wrap>`),km=V(`<div style=width:18px;height:18px;border-radius:50%;cursor:pointer;flex-shrink:0>`),Am=[{label:`Red`,value:1,css:`#ff0000`},{label:`Purple`,value:2,css:`#800080`},{label:`Blue`,value:3,css:`#0000ff`},{label:`Cyan`,value:4,css:`#00ffff`},{label:`Green`,value:5,css:`#008000`},{label:`Yellow`,value:6,css:`#ffff00`},{label:`Orange`,value:7,css:`#ffa500`},{label:`Brown`,value:8,css:`#a52a2a`},{label:`Grey`,value:9,css:`#808080`},{label:`White`,value:10,css:`#ffffff`}];function jm(e){return(()=>{var t=Om();return C(t,f(u,{each:Am,children:t=>(()=>{var n=km();return n.$$click=()=>e.onChange(t.value),S(r=>{var i=t.label,a=t.css,o=e.value===t.value?`0 0 0 2px #0d1117, 0 0 0 4px #c9d1d9`:`none`;return i!==r.e&&B(n,`title`,r.e=i),a!==r.t&&H(n,`background`,r.t=a),o!==r.a&&H(n,`box-shadow`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n})()})),t})()}N([`click`]);function Mm(e){return e?`${Re()}/map/${encodeURIComponent(e)}`:`${Re()}/map`}function Nm(e,t){return t?`${Re()}/room/${encodeURIComponent(t)}/${e}`:`${Re()}/room/${e}`}function Pm(e,t){return t?`${Re()}/room-overview/${encodeURIComponent(t)}/${e}`:`${Re()}/room-overview/${e}`}function Fm(){return`${Re()}/user`}function Im(){return`${Re()}/user/`}function Lm(){return`${Re()}/user/power`}function Rm(){return`${Re()}/user/power/`}function zm(){return`${Re()}/messages`}function Bm(){return`${Re()}/messages/`}function Vm(){return`${Re()}/profile/`}function Hm(){return`${Re()}/room-overview/`}function Um(){return`${Re()}/market`}function Wm(){return`${Re()}/market/`}function Gm(){return window.location.pathname+window.location.search+window.location.hash}function Km(){let e=window.location.pathname;return e===Fm()||e.startsWith(Im())?`user`:e.startsWith(Vm())?`profile`:e===zm()||e.startsWith(Bm())?`messages`:e===Um()||e.startsWith(Wm())?`market`:e.startsWith(Hm())?`room-overview`:`game`}function qm(){let e=window.location.pathname;if(!e.startsWith(Hm()))return null;let t=e.slice(Hm().length).split(`/`).filter(Boolean).map(decodeURIComponent);return t.length>=2?{shard:t[0],room:t[1]}:t.length===1?{shard:null,room:t[0]}:null}function Jm(){let e=window.location.pathname;return e===Lm()||e.startsWith(Rm())?`power`:`overview`}function Ym(){let e=window.location.pathname;return e.startsWith(Bm())&&decodeURIComponent(e.slice(Bm().length))||null}function Xm(){let e=window.location.pathname;return e.startsWith(Vm())&&decodeURIComponent(e.slice(Vm().length))||null}function Zm(){let e=window.location.pathname;if(e===`${Um()}/my`)return{view:`my-orders`,resourceType:null};if(e===`${Um()}/history`)return{view:`history`,resourceType:null};let t=`${Wm()}resource/`;if(e.startsWith(t)){let n=decodeURIComponent(e.slice(t.length));if(n)return{view:`resource`,resourceType:n}}return{view:`all-orders`,resourceType:null}}function Qm(){return new URLSearchParams(window.location.search).get(`shard`)}function $m(){return new URLSearchParams(window.location.search).get(`room`)}function eh(){let e=window.location.pathname;if(e===`${Lm()}/new`)return{view:`new`,id:null};if(e.startsWith(Rm())){let t=decodeURIComponent(e.slice(Rm().length));if(t)return{view:`detail`,id:t}}return{view:`list`,id:null}}var[th,nh]=a(Km()),[rh,ih]=a(Jm()),[ah,oh]=a(Xm()),[sh,ch]=a(Ym()),[lh,uh]=a(Zm().view),[dh,fh]=a(Zm().resourceType),[ph,mh]=a(Qm()),[hh,gh]=a($m()),[_h,vh]=a(eh().view),[yh,bh]=a(eh().id),[xh,Sh]=a(qm()),Ch=Km()===`game`?Gm():`${Re()}/map`;function wh(){Km()===`game`&&(Ch=Gm())}function Th(){wh(),history.pushState(null,``,Fm()),ih(`overview`),vh(`list`),bh(null),nh(`user`)}function Eh(){wh(),history.pushState(null,``,zm()),ch(null),nh(`messages`)}function Dh(e){wh(),history.pushState(null,``,`${Bm()}${encodeURIComponent(e)}`),ch(e),nh(`messages`)}function Oh(){wh(),history.pushState(null,``,Lm()),ih(`power`),bh(null),vh(`list`),nh(`user`)}function kh(){wh(),history.pushState(null,``,`${Lm()}/new`),ih(`power`),bh(null),vh(`new`),nh(`user`)}function Ah(e){wh(),history.pushState(null,``,`${Rm()}${encodeURIComponent(e)}`),ih(`power`),bh(e),vh(`detail`),nh(`user`)}function jh(e){wh(),history.pushState(null,``,`${Vm()}${encodeURIComponent(e)}`),oh(e),nh(`profile`)}function Mh(e,t){let n=new URLSearchParams;e&&n.set(`shard`,e),t&&n.set(`room`,t);let r=n.toString();return r?`?${r}`:``}function Nh(e,t){let n=t===void 0?hh():t;wh(),history.pushState(null,``,`${Um()}${Mh(e??null,n)}`),fh(null),mh(e??null),gh(n),uh(`all-orders`),nh(`market`)}function Ph(e,t,n){let r=n===void 0?hh():n;wh(),history.pushState(null,``,`${Wm()}resource/${encodeURIComponent(e)}${Mh(t??null,r)}`),fh(e),mh(t??null),gh(r),uh(`resource`),nh(`market`)}function Fh(){wh(),history.pushState(null,``,`${Um()}/my`),fh(null),uh(`my-orders`),nh(`market`)}function Ih(){wh(),history.pushState(null,``,`${Um()}/history`),fh(null),uh(`history`),nh(`market`)}function Lh(e,t){wh(),history.pushState(null,``,Pm(e,t)),Sh({room:e,shard:t}),nh(`room-overview`)}function Rh(){history.pushState(null,``,Ch),nh(`game`)}function zh(e,t){let n=Nm(e,t);Ch=n,history.pushState(null,``,n),nh(`game`)}typeof window<`u`&&window.addEventListener(`popstate`,()=>{nh(Km()),ih(Jm()),oh(Xm()),ch(Ym());let e=Zm();uh(e.view),fh(e.resourceType),mh(Qm()),gh($m());let t=eh();vh(t.view),bh(t.id),Sh(qm())});var Bh=V(`<span title="View user profile"style=cursor:pointer>`),Vh=new Set([`Invader`,`Source Keeper`]);function Hh(e){let t=()=>!!e.username&&!Vh.has(e.username);return f(_,{get when(){return t()},get fallback(){return R(()=>e.username??e.fallback)},get children(){var t=Bh();return t.addEventListener(`mouseleave`,t=>t.currentTarget.style.color=e.color??`inherit`),t.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),t.$$click=t=>{t.stopPropagation(),jh(e.username)},C(t,()=>e.children??e.username),S(n=>L(t,{color:e.color??`inherit`,...e.style},n)),t}})}N([`click`]);var Uh=V(`<div>`),Wh=V(`<div style=font-variant-numeric:tabular-nums>`),Gh=V(`<span style=font-variant-numeric:tabular-nums;font-weight:400> / `),Kh=V(`<div style="background:#21262d;border-top:1px solid #30363d;font-size:10px"><div style="padding:4px 8px;background:#161b22;color:#8b949e;font-weight:600;display:flex;justify-content:space-between"><span>Store Contents</span></div><div style="display:grid;grid-template-columns:1fr 1fr;gap:1px;background:#21262d">`),qh=V(`<div style="padding:3px 8px;background:#0d1117;color:#8b949e">`),Jh=V(`<div style="padding:3px 8px;background:#0d1117;color:#c9d1d9;font-variant-numeric:tabular-nums">`),Yh=V(`<div>Owner`),Xh=V(`<div>Hits`),Zh=V(`<div style=font-variant-numeric:tabular-nums> / `),Qh=V(`<div>Time to live`),$h=V(`<div>Fatigue`),eg=V(`<div style="background:#21262d;border-top:1px solid #30363d;font-size:10px"><div style="padding:4px 8px;background:#161b22;color:#8b949e;font-weight:600">Body (<!>)</div><div style=display:flex;flex-wrap:wrap;gap:3px;padding:8px;background:#0d1117></div><div style="display:flex;flex-wrap:wrap;gap:2px 10px;padding:0 8px 8px;background:#0d1117">`),tg=V(`<div><div>`),ng=V(`<div style=width:11px;height:11px;border-radius:50%;flex-shrink:0>`),rg=V(`<span style=font-size:10px;font-variant-numeric:tabular-nums><span style=color:#8b949e>×</span><span>`),ig=V(`<div style=display:flex;gap:6px><button style="flex:1;border-radius:4px;padding:5px 8px;font-size:11px;transition:background 150ms ease, color 150ms ease, border-color 150ms ease">Apply color</button><button style="border-radius:4px;padding:5px 8px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background 150ms ease, color 150ms ease">`),ag=V(`<div style=padding:8px;display:flex;flex-direction:column;gap:8px;background:#0d1117><label>Primary color</label><label>Secondary color`),og=V(`<label>Target room<input style="background:#010409;color:#c9d1d9;border:1px solid #30363d;border-radius:4px;padding:5px 6px;font-size:12px;outline:none"><span style=font-size:10px;color:#484f58>Navigate to target room, then click a tile`),sg=V(`<div>Reserved by`),cg=V(`<div>Reservation`),lg=V(`<div style=font-variant-numeric:tabular-nums> ticks`),ug=V(`<div>Level`),dg=V(`<div>Safe modes`),fg=V(`<div>Power`),pg=V(`<div>Downgrade in`),mg=V(`<div>Safe mode active`),hg=V(`<div style="padding:5px 8px;background:#0d1117;border-top:1px solid #21262d"><div style=display:flex;justify-content:space-between;font-size:10px;margin-bottom:4px><span style=color:#8b949e>RCL <!> → </span><span style=color:#c9d1d9;font-variant-numeric:tabular-nums> / <!> (<!>%)</span></div><div style=height:5px;background:#21262d;border-radius:3px;overflow:hidden><div style=height:100%;background:#58a6ff;border-radius:3px>`),gg=V(`<div style=padding:8px;display:flex;flex-direction:column;gap:6px;background:#0d1117><button style="color:#fff;border:none;border-radius:4px;padding:6px 8px;font-size:12px">Activate safe mode</button><button style="color:#fff;border:none;border-radius:4px;padding:6px 8px;font-size:12px;cursor:pointer">`),_g=V(`<div><div><div>Owner</div><div>`),vg=V(`<div>Cooldown`),yg=V(`<div>Notify when attacked`),bg=V(`<div style=display:flex;align-items:center><button style=background:transparent;border:none;cursor:pointer;padding:0;display:flex;align-items:center>`),xg=V(`<div><div>Energy</div><div style=font-variant-numeric:tabular-nums> / `),Sg=V(`<div><div>Hits</div><div style=font-variant-numeric:tabular-nums> / `),Cg=V(`<div style="padding:5px 8px;background:#0d1117;border-top:1px solid #21262d"><div style=display:flex;justify-content:space-between;font-size:10px;margin-bottom:4px><span style=color:#8b949e>Fill</span><span style=color:#c9d1d9;font-variant-numeric:tabular-nums> / <!> (<!>%)</span></div><div style=height:5px;background:#21262d;border-radius:3px;overflow:hidden><div style=height:100%;background:#ffe87b;border-radius:3px>`),wg=V(`<div style=font-variant-numeric:tabular-nums> `),Tg=V(`<div>Decays in`),Eg=V(`<div>Decay in`),Dg=V(`<div>Energy cap`),Og=V(`<div style="background:#21262d;border-top:1px solid #30363d;font-size:10px"><div style="padding:4px 8px;background:#161b22;color:#8b949e;font-weight:600">Was: </div><div>`),kg=V(`<div style=width:8px;height:8px;border-radius:50%;flex-shrink:0>`),Ag=V(`<button style="background:transparent;border:none;cursor:pointer;padding:0 2px;display:flex;align-items:center;justify-content:center;flex-shrink:0">`),jg=V(`<button title="Watch memory"style="background:transparent;border:none;color:#8b949e;cursor:pointer;padding:0 2px;display:flex;align-items:center;justify-content:center;flex-shrink:0">`),Mg=V(`<div style="border-radius:6px;margin-bottom:6px;overflow:hidden;transition:border-color 150ms ease"><div style="display:flex;align-items:center;gap:7px;padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d"><span style=font-size:11px;font-weight:600;color:#c9d1d9;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:flex;align-items:center;gap:5px></span><span style=font-size:10px;color:#484f58;flex-shrink:0;margin-right:2px>(<!>,<!>)</span><button title=Deselect style="background:transparent;border:none;color:#8b949e;cursor:pointer;padding:0 4px;font-size:14px;line-height:1;display:flex;align-items:center;justify-content:center">×`),Ng=V(`<span style=font-weight:400;color:#8b949e>`),Pg=V(`<div style="padding:3px 8px;border-top:1px solid #21262d;font-size:9px;color:#484f58;font-family:monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer">`),Fg=V(`<div style=flex:1;overflow:auto;min-height:0;padding:8px>`),Ig=V(`<div style=color:#484f58;font-style:italic;font-size:12px>Click a tile to select objects…`),{log:Lg,error:Rg}=P(`SelectionList`),zg={creep:`#f0883e`,spawn:`#58a6ff`,extension:`#79c0ff`,tower:`#3fb950`,container:`#8b949e`,storage:`#d29922`,link:`#a371f7`,rampart:`#58a6ff`,road:`#484f58`,wall:`#21262d`,extractor:`#8b949e`,lab:`#f778ba`,terminal:`#d29922`,observer:`#79c0ff`,powerSpawn:`#f0883e`,nuker:`#f85149`,factory:`#8b949e`,invaderCore:`#f85149`,source:`#d29922`,mineral:`#79c0ff`,deposit:`#d29922`,controller:`#58a6ff`,powerBank:`#f0883e`,portal:`#a371f7`,keeperLair:`#f85149`,energy:`#d29922`},Bg={creep:`Creep`,spawn:`Spawn`,extension:`Extension`,tower:`Tower`,container:`Container`,storage:`Storage`,link:`Link`,rampart:`Rampart`,road:`Road`,wall:`Wall`,extractor:`Extractor`,lab:`Lab`,terminal:`Terminal`,observer:`Observer`,powerSpawn:`Power Spawn`,nuker:`Nuker`,factory:`Factory`,invaderCore:`Invader Core`,source:`Source`,mineral:`Mineral`,deposit:`Deposit`,controller:`Controller`,powerBank:`Power Bank`,portal:`Portal`,keeperLair:`Keeper Lair`,energy:`Energy`,flag:`Flag`},Vg=new Set([`x`,`y`,`type`,`id`,`name`,`user`,`_id`,`room`,`hitsMax`,`energyCapacity`,`body`,`storeCapacity`,`storeCapacityResource`,`invaderHarvested`,`ticksToRegeneration`]),Hg=new Set([`hits`,`energy`,`energyCapacity`,`store`,`progress`,`progressTotal`,`nextDecayTime`,`ticksToRegeneration`,`nextRegenerationTime`]),Ug={hits:`Hits`,energy:`Energy`,progress:`Progress`,progressTotal:`Progress total`,ticksToLive:`Ticks to live`,ticksToDecay:`Ticks to decay`,nextDecayTime:`Decays in`,nextRegenerationTime:`Regens in`,fatigue:`Fatigue`,cooldown:`Cooldown`,mineralType:`Mineral type`,mineralAmount:`Mineral amount`,density:`Density`,notifyWhenAttacked:`Notify when attacked`,isPublic:`Public`,structureType:`Structure type`,level:`Level`,power:`Power`,powerCapacity:`Power capacity`,depositType:`Deposit type`,lastCooldown:`Last cooldown`,resourceType:`Resource type`,amount:`Amount`,decay:`Decay in`,mode:`Mode`,actionLog:`Action log`,store:`Store`};function Wg(e){return Ug[e]?Ug[e]:e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()).trim()}function Gg(e){return typeof e==`number`?String(e):typeof e==`string`?e:typeof e==`boolean`?e?`Yes`:`No`:null}function Kg(e){if(e>=1e6){let t=e/1e6;return`${parseFloat(t.toFixed(2))}M`}if(e>=1e3){let t=e/1e3;return`${parseFloat(t.toFixed(1))}K`}return String(e)}var Y=(e=!1)=>({padding:`3px 8px`,background:`#0d1117`,color:e?`#8b949e`:`#c9d1d9`,overflow:`hidden`,"text-overflow":`ellipsis`,"white-space":`nowrap`}),qg={display:`grid`,"grid-template-columns":`1fr 1fr`,gap:`1px`,background:`#21262d`,"font-size":`10px`};function Jg(e){let t=()=>{let t=e.item.raw,n=[];for(let e in t){if(Vg.has(e))continue;let r=t[e],i=Gg(r);if(!(e===`notifyWhenAttacked`&&r===!1)&&!(e===`off`&&r===!1)){if(e===`hits`&&typeof t.hitsMax==`number`&&(i=`${r} / ${t.hitsMax}`),e===`energy`&&typeof t.energyCapacity==`number`&&(i=`${r} / ${t.energyCapacity}`),e===`nextDecayTime`&&typeof r==`number`){let e=Ae();e!==null&&(i=String(r-e))}if(e===`nextRegenerationTime`&&typeof r==`number`){let e=Ae();e!==null&&(i=String(r-e))}i!==null&&n.push({key:e,label:Wg(e),value:i})}}return n.sort((e,t)=>!Hg.has(e.key)-+!Hg.has(t.key)),n};return f(_,{get when(){return t().length>0},get children(){var e=Uh();return C(e,f(u,{get each(){return t()},children:e=>[(()=>{var t=Uh();return C(t,()=>e.label),S(e=>L(t,Y(!0),e)),t})(),(()=>{var t=Wh();return C(t,()=>e.value),S(e=>L(t,{...Y()},e)),t})()]})),S(t=>L(e,qg,t)),e}})}function Yg(e){let t=()=>{let t=e.store||{},n=[];for(let e in t)n.push([e,t[e]]);return n},n=()=>{let t=e.store||{},n=0;for(let e in t)n+=t[e];return n};return f(_,{get when(){return t().length>0},get children(){var r=Kh(),i=r.firstChild;i.firstChild;var a=i.nextSibling;return C(i,f(_,{get when(){return e.capacity!=null},get children(){var t=Gh(),r=t.firstChild;return C(t,n,r),C(t,()=>e.capacity,null),t}}),null),C(a,f(u,{get each(){return t()},children:([e,t])=>[(()=>{var t=qh();return C(t,e),t})(),(()=>{var e=Jh();return C(e,t),e})()]})),r}})}var Xg={tough:`#4c4c4c`,move:`#a9b7c6`,work:`#ffe56d`,carry:`#777777`,attack:`#f93842`,ranged_attack:`#5d80b2`,heal:`#65fd62`,claim:`#b99cfb`};function Zg(e){let t=()=>e.item.raw,n=()=>typeof t().user==`string`?t().user:null,r=()=>{let e=n();return e?nf()?.[e]?.username??null:null},i=()=>{let e=n();return e?r()??e:null},a=()=>typeof t().hits==`number`?t().hits:null,o=()=>typeof t().hitsMax==`number`?t().hitsMax:null,s=()=>{let e=t().ageTime,n=Ae();return typeof e==`number`&&n!==null?Math.max(0,e-n):null},c=()=>typeof t().fatigue==`number`?t().fatigue:null,l=()=>t().store,d=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null,p=()=>t().body??[],m=()=>{let e=new Map;for(let t of p())e.set(t.type,(e.get(t.type)??0)+1);return[...e.entries()].map(([e,t])=>({type:e,count:t}))};return(()=>{var e=tg(),t=e.firstChild;return C(t,f(_,{get when(){return i()},get children(){return[(()=>{var e=Yh();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Uh();return C(e,f(Hh,{get username(){return r()},get fallback(){return i()}})),S(t=>L(e,Y(),t)),e})()]}}),null),C(t,f(_,{get when(){return R(()=>a()!==null)()&&o()!==null},get children(){return[(()=>{var e=Xh();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Zh(),t=e.firstChild;return C(e,a,t),C(e,o,null),S(t=>L(e,{...Y()},t)),e})()]}}),null),C(t,f(_,{get when(){return s()!==null},get children(){return[(()=>{var e=Qh();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Wh();return C(e,s),S(t=>L(e,{...Y()},t)),e})()]}}),null),C(t,f(_,{get when(){return c()!==null},get children(){return[(()=>{var e=$h();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Wh();return C(e,c),S(t=>L(e,{...Y(),color:c()>0?`#e3b341`:void 0},t)),e})()]}}),null),C(e,f(Yg,{get store(){return l()},get capacity(){return d()}}),null),C(e,f(_,{get when(){return p().length>0},get children(){var e=eg(),t=e.firstChild,n=t.firstChild.nextSibling;n.nextSibling;var r=t.nextSibling,i=r.nextSibling;return C(t,()=>p().length,n),C(r,f(u,{get each(){return p()},children:e=>(()=>{var t=ng();return S(n=>{var r=e.type.replace(`_`,` `),i=Xg[e.type]??`#484f58`,a=e.hits===0?.25:1;return r!==n.e&&B(t,`title`,n.e=r),i!==n.t&&H(t,`background`,n.t=i),a!==n.a&&H(t,`opacity`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),C(i,f(u,{get each(){return m()},children:({type:e,count:t})=>(()=>{var n=rg(),r=n.firstChild,i=r.firstChild,a=r.nextSibling;return C(r,t,i),C(a,()=>e.replace(`_`,` `).toUpperCase()),S(t=>H(a,`color`,Xg[e]??`#484f58`)),n})()})),e}}),null),S(e=>L(t,qg,e)),e})()}function Qg(e){let t=()=>e.item.raw,n=()=>typeof t().name==`string`?t().name:``,r=()=>typeof t().room==`string`?t().room:``,i=()=>typeof t().color==`number`?t().color:1,o=()=>typeof t().secondaryColor==`number`?t().secondaryColor:1,[c,l]=a(i()),[u,d]=a(o());s(()=>{l(i()),d(o())});let p=()=>c()!==i()||u()!==o(),m=()=>{let e=z();if(!e)return;let t=c(),i=u();Lg(`changeFlagColor: name="${n()}" room=${r()} primary=${t} secondary=${i}`),e.http.game.changeFlagColor(r(),n(),t,i,af()??void 0).then(()=>Lg(`changeFlagColor OK`)).catch(e=>Rg(`changeFlagColor FAILED:`,e))},h=()=>{let t=$f();return t?.type===`moveFlag`&&t.id===e.item.id},g=()=>{if(h()){ep(null);return}ep({type:`moveFlag`,id:e.item.id,name:n(),room:r(),color:c(),secondaryColor:u(),targetRoom:sf()??r()})},v=()=>{let t=$f();return t?.type===`moveFlag`&&t.id===e.item.id?t:null},y={display:`flex`,"flex-direction":`column`,gap:`5px`,"font-size":`11px`,color:`#8b949e`};return(()=>{var e=ag(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return n.firstChild,C(t,f(jm,{get value(){return c()},onChange:l}),null),C(n,f(jm,{get value(){return u()},onChange:d}),null),C(e,f(_,{get when(){return!J()},get children(){return[(()=>{var e=ig(),t=e.firstChild,n=t.nextSibling;return t.addEventListener(`mouseleave`,e=>{p()&&(e.currentTarget.style.background=`#238636`)}),t.addEventListener(`mouseenter`,e=>{p()&&(e.currentTarget.style.background=`#2ea043`)}),t.$$click=m,n.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=h()?`#c9d1d9`:`#8b949e`}),n.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=`#c9d1d9`}),n.$$click=g,C(n,(()=>{var e=R(()=>!!h());return()=>e()?f(Ji,{size:13}):f(fi,{size:13})})()),S(e=>{var r=!p(),i=p()?`#238636`:`#161b22`,a=p()?`#fff`:`#484f58`,o=`1px solid ${p()?`#238636`:`#30363d`}`,s=p()?`pointer`:`not-allowed`,c=h()?`Abort move`:`Move flag`,l=h()?`#30363d`:`#21262d`,u=h()?`#c9d1d9`:`#8b949e`,d=`1px solid ${h()?`#8b949e`:`#30363d`}`;return r!==e.e&&(t.disabled=e.e=r),i!==e.t&&H(t,`background`,e.t=i),a!==e.a&&H(t,`color`,e.a=a),o!==e.o&&H(t,`border`,e.o=o),s!==e.i&&H(t,`cursor`,e.i=s),c!==e.n&&B(n,`title`,e.n=c),l!==e.s&&H(n,`background`,e.s=l),u!==e.h&&H(n,`color`,e.h=u),d!==e.r&&H(n,`border`,e.r=d),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),e})(),f(_,{get when(){return v()},children:e=>(()=>{var t=og(),n=t.firstChild.nextSibling;return n.nextSibling,n.$$input=t=>ep({...e(),targetRoom:t.currentTarget.value.toUpperCase()}),S(e=>L(t,y,e)),S(()=>n.value=e().targetRoom),t})()})]}}),null),S(e=>{var r=y,i=y;return e.e=L(t,r,e.e),e.t=L(n,i,e.t),e},{e:void 0,t:void 0}),e})()}function $g(e){let t=()=>e.item.raw,n=()=>typeof t().level==`number`?t().level:0,r=()=>typeof t().progress==`number`?t().progress:null,i=()=>typeof t().progressTotal==`number`?t().progressTotal:ss[n()]??null,o=()=>typeof t().downgradeTime==`number`?t().downgradeTime:null,s=()=>typeof t().safeModeAvailable==`number`?t().safeModeAvailable:0,c=()=>typeof t().safeMode==`number`?t().safeMode:null,l=()=>t().isPowerEnabled===!0,u=()=>t().reservation,d=()=>typeof t().user==`string`?t().user:null,p=()=>{let e=d();return e?Kd()?.username??e:null},m=()=>{let e=o(),t=Ae();return e!==null&&t!==null?Math.max(0,e-t):null},h=()=>{let e=m();if(e===null)return`—`;let t=cs[n()];return t!==void 0&&e>=t?`Max`:String(e)},g=()=>d()!==null&&d()===U()?._id,[v,y]=a(!1),b=null,x=()=>{let n=z();n&&n.http.game.addObjectIntent(e.item.id,sf()??t().room??``,`activateSafeMode`,{id:e.item.id},af()).catch(e=>Rg(`activateSafeMode failed:`,e))},w=()=>{if(!v()){y(!0),b=setTimeout(()=>y(!1),3e3);return}b&&=(clearTimeout(b),null),y(!1);let n=z();n&&n.http.game.addObjectIntent(e.item.id,sf()??t().room??``,`unclaim`,{id:e.item.id},af()).catch(e=>Rg(`unclaim failed:`,e))};return(()=>{var e=_g(),t=e.firstChild,a=t.firstChild,o=a.nextSibling;return C(o,f(Hh,{get username(){return Kd()?.username},get fallback(){return p()??`None`}})),C(t,f(_,{get when(){return u()},get children(){return[(()=>{var e=sg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Uh();return C(e,f(Hh,{get username(){return nf()?.[u().user]?.username},get fallback(){return u().user}})),S(t=>L(e,Y(),t)),e})(),(()=>{var e=cg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=lg(),t=e.firstChild;return C(e,(()=>{var e=R(()=>Ae()!==null);return()=>e()?Math.max(0,u().endTime-Ae()):u().endTime})(),t),S(t=>L(e,{...Y()},t)),e})()]}}),null),C(t,f(_,{get when(){return n()>0},get children(){return[(()=>{var e=ug();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Uh();return C(e,n),S(t=>L(e,Y(),t)),e})(),(()=>{var e=dg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Uh();return C(e,s),S(t=>L(e,Y(),t)),e})(),(()=>{var e=fg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Uh();return C(e,()=>l()?`Enabled`:`Disabled`),S(t=>L(e,Y(),t)),e})(),(()=>{var e=pg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Wh();return C(e,h),S(t=>L(e,{...Y(),color:h()===`Max`?`#3fb950`:void 0},t)),e})()]}}),null),C(t,f(_,{get when(){return c()!==null},get children(){return[(()=>{var e=mg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=lg(),t=e.firstChild;return C(e,c,t),S(t=>L(e,{...Y()},t)),e})()]}}),null),C(e,f(_,{get when(){return R(()=>n()>0&&n()<8&&r()!==null)()&&i()!==null},get children(){var e=hg(),t=e.firstChild,a=t.firstChild,o=a.firstChild.nextSibling;o.nextSibling;var s=a.nextSibling,c=s.firstChild,l=c.nextSibling,u=l.nextSibling.nextSibling;u.nextSibling;var d=t.nextSibling.firstChild;return C(a,n,o),C(a,()=>n()+1,null),C(s,()=>Kg(r()),c),C(s,()=>Kg(i()),l),C(s,()=>(r()/i()*100).toFixed(1),u),S(e=>H(d,`width`,`${Math.min(100,r()/i()*100)}%`)),e}}),null),C(e,f(_,{get when(){return R(()=>!!g())()&&!J()},get children(){var e=gg(),t=e.firstChild,n=t.nextSibling;return t.addEventListener(`mouseleave`,e=>{s()>0&&(e.currentTarget.style.background=`#1f6feb`)}),t.addEventListener(`mouseenter`,e=>{s()>0&&(e.currentTarget.style.background=`#388bfd`)}),t.$$click=x,n.addEventListener(`mouseleave`,e=>{v()||(e.currentTarget.style.background=`#f85149`)}),n.addEventListener(`mouseenter`,e=>{v()||(e.currentTarget.style.background=`#da3633`)}),n.$$click=w,C(n,()=>v()?`Confirm unclaim`:`Unclaim`),S(e=>{var r=s()===0,i=s()>0?`#1f6feb`:`#161b22`,a=s()>0?`pointer`:`not-allowed`,o=s()>0?1:.5,c=v()?`#da3633`:`#f85149`;return r!==e.e&&(t.disabled=e.e=r),i!==e.t&&H(t,`background`,e.t=i),a!==e.a&&H(t,`cursor`,e.a=a),o!==e.o&&H(t,`opacity`,e.o=o),c!==e.i&&H(n,`background`,e.i=c),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),S(e=>{var n=qg,r=Y(!0),i=Y();return e.e=L(t,n,e.e),e.t=L(a,r,e.t),e.a=L(o,i,e.a),e},{e:void 0,t:void 0,a:void 0}),e})()}function e_(e){let t=()=>e.item.raw,n=()=>t().store?.energy??0,r=()=>t().storeCapacityResource?.energy??0,i=()=>typeof t().hits==`number`?t().hits:null,a=()=>typeof t().hitsMax==`number`?t().hitsMax:null,o=()=>{if(typeof t().cooldown==`number`)return t().cooldown;let e=t().cooldownTime,n=Ae();return typeof e==`number`&&n!==null?Math.max(0,e-n):null},s=()=>t().notifyWhenAttacked===!0,c=()=>typeof t().user==`string`?t().user:null,l=()=>c()!==null&&c()===U()?._id,u=()=>{let n=z();n&&n.http.game.addObjectIntent(e.item.id,t().room,`notifyWhenAttacked`,{enabled:!s()}).catch(e=>Rg(`notifyWhenAttacked failed:`,e))};return(()=>{var e=xg(),t=e.firstChild,c=t.nextSibling,d=c.firstChild;return C(c,n,d),C(c,r,null),C(e,f(_,{get when(){return R(()=>i()!==null)()&&a()!==null},get children(){return[(()=>{var e=Xh();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Zh(),t=e.firstChild;return C(e,i,t),C(e,a,null),S(t=>L(e,{...Y()},t)),e})()]}}),null),C(e,f(_,{get when(){return o()!==null},get children(){return[(()=>{var e=vg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Wh();return C(e,o),S(t=>L(e,{...Y()},t)),e})()]}}),null),C(e,f(_,{get when(){return R(()=>!!l())()&&!J()},get children(){return[(()=>{var e=yg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=bg(),t=e.firstChild;return t.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=s()?`#3fb950`:`#484f58`}),t.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=s()?`#56d364`:`#8b949e`}),t.$$click=u,C(t,(()=>{var e=R(()=>!!s());return()=>e()?f(ur,{size:12}):f(cr,{size:12})})()),S(n=>{var r={...Y()},i=s()?`Notifications on — click to disable`:`Notifications off — click to enable`,a=s()?`#3fb950`:`#484f58`;return n.e=L(e,r,n.e),i!==n.t&&B(t,`title`,n.t=i),a!==n.a&&H(t,`color`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),e})()]}}),null),S(n=>{var r=qg,i=Y(!0),a={...Y()};return n.e=L(e,r,n.e),n.t=L(t,i,n.t),n.a=L(c,a,n.a),n},{e:void 0,t:void 0,a:void 0}),e})()}function t_(e){let t=()=>e.item.raw,n=()=>typeof t().hits==`number`?t().hits:null,r=()=>typeof t().hitsMax==`number`?t().hitsMax:null,i=()=>t().store,a=()=>{if(typeof t().storeCapacity==`number`)return t().storeCapacity;let e=t().storeCapacityResource;if(e){let t=0;for(let n in e)t+=e[n];return t}return null},o=()=>{let e=i();if(!e)return 0;let t=0;for(let n in e)t+=e[n];return t},s=()=>{let e=a();return!e||e===0?0:Math.min(100,o()/e*100)};return(()=>{var e=Uh();return C(e,f(_,{get when(){return R(()=>n()!==null)()&&r()!==null},get children(){var e=Sg(),t=e.firstChild,i=t.nextSibling,a=i.firstChild;return C(i,n,a),C(i,r,null),S(n=>{var r=qg,a=Y(!0),o={...Y()};return n.e=L(e,r,n.e),n.t=L(t,a,n.t),n.a=L(i,o,n.a),n},{e:void 0,t:void 0,a:void 0}),e}}),null),C(e,f(_,{get when(){return a()!==null},get children(){var e=Cg(),t=e.firstChild,n=t.firstChild.nextSibling,r=n.firstChild,i=r.nextSibling,c=i.nextSibling.nextSibling;c.nextSibling;var l=t.nextSibling.firstChild;return C(n,()=>Kg(o()),r),C(n,()=>Kg(a()),i),C(n,()=>s().toFixed(1),c),S(e=>H(l,`width`,`${s()}%`)),e}}),null),C(e,f(Yg,{get store(){return i()},capacity:null}),null),e})()}function n_(e){let t=()=>e.item.raw,n=()=>{let e=t().decayTime;if(typeof e!=`number`)return null;let n=Ae();return n===null?e:Math.max(0,e-n)},r=()=>{let e=t().power;if(typeof e==`number`)return e;let n=t().store;return typeof n?.power==`number`?n.power:null},i=()=>typeof t().hits==`number`?t().hits:null,a=()=>typeof t().hitsMax==`number`?t().hitsMax:null;return(()=>{var e=Uh();return C(e,f(_,{get when(){return r()!==null},get children(){return[(()=>{var e=fg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Wh();return C(e,r),S(t=>L(e,{...Y()},t)),e})()]}}),null),C(e,f(_,{get when(){return i()!==null},get children(){return[(()=>{var e=Xh();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=wg(),t=e.firstChild;return C(e,i,t),C(e,(()=>{var e=R(()=>a()!==null);return()=>e()?`/ ${a()}`:``})(),null),S(t=>L(e,{...Y()},t)),e})()]}}),null),C(e,f(_,{get when(){return n()!==null},get children(){return[(()=>{var e=Tg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Wh();return C(e,n),S(t=>L(e,{...Y()},t)),e})()]}}),null),S(t=>L(e,qg,t)),e})()}function r_(e){let t=()=>e.item.raw,n=()=>{let e=t().decayTime;if(typeof e!=`number`)return null;let n=Ae();return n===null?e:Math.max(0,e-n)},r=()=>typeof t().user==`string`?t().user:null,i=()=>{let e=r();return e?nf()?.[e]?.username??null:null},a=()=>{let e=r();return e?i()??e:null},o=()=>t().structure,s=()=>typeof o()?.type==`string`?o().type:null,c=()=>typeof o()?.hits==`number`?o().hits:null,l=()=>typeof o()?.hitsMax==`number`?o().hitsMax:null,u=()=>typeof o()?.level==`number`?o().level:null,d=()=>typeof o()?.energy==`number`?o().energy:null,p=()=>typeof o()?.energyCapacity==`number`?o().energyCapacity:null,m=()=>t().store,h=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null;return(()=>{var e=tg(),t=e.firstChild;return C(t,f(_,{get when(){return n()!==null},get children(){return[(()=>{var e=Eg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Wh();return C(e,n),S(t=>L(e,{...Y()},t)),e})()]}}),null),C(t,f(_,{get when(){return a()},get children(){return[(()=>{var e=Yh();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Uh();return C(e,f(Hh,{get username(){return i()},get fallback(){return a()}})),S(t=>L(e,Y(),t)),e})()]}}),null),C(e,f(_,{get when(){return s()},get children(){var e=Og(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return C(t,s,null),C(n,f(_,{get when(){return l()!==null},get children(){return[(()=>{var e=Xh();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Zh(),t=e.firstChild;return C(e,()=>c()??0,t),C(e,l,null),S(t=>L(e,{...Y()},t)),e})()]}}),null),C(n,f(_,{get when(){return u()!==null},get children(){return[(()=>{var e=ug();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Wh();return C(e,u),S(t=>L(e,{...Y()},t)),e})()]}}),null),C(n,f(_,{get when(){return p()!==null},get children(){return[(()=>{var e=Dg();return S(t=>L(e,Y(!0),t)),e})(),(()=>{var e=Zh(),t=e.firstChild;return C(e,()=>d()??0,t),C(e,p,null),S(t=>L(e,{...Y()},t)),e})()]}}),null),S(e=>L(n,qg,e)),e}}),null),C(e,f(Yg,{get store(){return m()},get capacity(){return h()}}),null),S(e=>L(t,qg,e)),e})()}var i_={creep:Zg,flag:Qg,controller:$g,spawn:e_,extension:e_,tower:e_,link:e_,storage:t_,terminal:t_,container:t_,lab:t_,factory:t_,nuker:t_,powerSpawn:t_,powerBank:n_,ruin:r_};function a_(e){let t=()=>zg[e.item.type]??`#c9d1d9`,n=()=>Bg[e.item.type]??e.item.type,r=()=>e.item.type===`creep`,i=()=>e.item.type===`flag`,o=()=>{if(!r())return!1;let t=e.item.raw,n=typeof t.user==`string`?t.user:null;return n!==null&&n===U()?._id},s=()=>{if(r()||i()||e.item.type===`controller`)return!1;let t=e.item.raw,n=typeof t.user==`string`?t.user:null;return n===null?Kd()?.userId===U()?._id:n===U()?._id},c=()=>i_[e.item.type]||Jg,[l,u]=a(!1),d=null,[p,m]=a(!1),h=null,[g,v]=a(!1),y=null,b=t=>{if(t.stopPropagation(),!g()){v(!0),y=setTimeout(()=>v(!1),3e3);return}y&&=(clearTimeout(y),null),v(!1);let n=z();if(!n)return;let r=e.item.id,i=e.item.raw;n.http.game.removeFlag(i.room,i.name,af()??void 0).then(()=>Vd(r)).catch(()=>{})},x=t=>{if(t.stopPropagation(),!p()){m(!0),h=setTimeout(()=>m(!1),3e3);return}h&&=(clearTimeout(h),null),m(!1);let n=z();if(!n)return;let r=e.item.id,i=e.item.raw,a=(typeof i.room==`string`?i.room:null)??sf()??``;if(e.item.type===`constructionSite`)n.http.game.removeConstructionSite(a,[r],af()??void 0).then(()=>Vd(r)).catch(e=>Rg(`removeConstructionSite failed:`,e));else{let e=typeof i.user==`string`?i.user:Kd()?.userId??``;n.http.game.addObjectIntent(`room`,a,`destroyStructure`,[{id:r,roomName:a,user:e}],af()).then(()=>Vd(r)).catch(e=>Rg(`destroyStructure failed:`,e))}},w=t=>{if(t.stopPropagation(),!l()){u(!0),d=setTimeout(()=>u(!1),3e3);return}d&&=(clearTimeout(d),null),u(!1);let n=z();if(!n)return;let r=e.item.id;n.http.game.addObjectIntent(r,sf()??e.item.raw.room??``,`suicide`,{id:r},af()).then(()=>Vd(r)).catch(e=>Rg(`suicide failed:`,e))};return(()=>{var a=Mg(),u=a.firstChild,d=u.firstChild,m=d.nextSibling,h=m.firstChild.nextSibling,v=h.nextSibling.nextSibling;v.nextSibling;var y=m.nextSibling;return C(u,f(_,{get when(){return R(()=>!r())()&&!i()},get children(){var e=kg();return S(n=>H(e,`background`,t())),e}}),d),C(d,f(_,{get when(){return i()},get fallback(){return R(n)},get children(){return f(Hr,{size:12})}}),null),C(d,f(_,{get when(){return R(()=>typeof e.item.raw.name==`string`)()&&e.item.raw.name},children:e=>(()=>{var t=Ng();return C(t,()=>e()),t})()}),null),C(m,()=>e.item.raw.x,h),C(m,()=>e.item.raw.y,v),C(u,f(_,{get when(){return R(()=>!!o())()&&!J()},get children(){return[(()=>{var e=Ag();return e.addEventListener(`mouseleave`,e=>{l()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{l()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=w,C(e,f(Wi,{size:13})),S(t=>{var n=l()?`Click again to confirm suicide`:`Suicide`,r=l()?`#f85149`:`#8b949e`;return n!==t.e&&B(e,`title`,t.e=n),r!==t.t&&H(e,`color`,t.t=r),t},{e:void 0,t:void 0}),e})(),(()=>{var t=jg();return t.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),t.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),t.$$click=()=>{Gp(e.item.id,e.item.raw.name),Dp(!0)},C(t,f(Rr,{size:13})),t})()]}}),y),C(u,f(_,{get when(){return R(()=>!!s())()&&!J()},get children(){var t=Ag();return t.addEventListener(`mouseleave`,e=>{p()||(e.currentTarget.style.color=`#8b949e`)}),t.addEventListener(`mouseenter`,e=>{p()||(e.currentTarget.style.color=`#f85149`)}),t.$$click=x,C(t,f(Wi,{size:13})),S(n=>{var r=p()?`Click again to confirm`:e.item.type===`constructionSite`?`Remove construction site`:`Destroy structure`,i=p()?`#f85149`:`#8b949e`;return r!==n.e&&B(t,`title`,n.e=r),i!==n.t&&H(t,`color`,n.t=i),n},{e:void 0,t:void 0}),t}}),y),C(u,f(_,{get when(){return R(()=>!!i())()&&!J()},get children(){var e=Ag();return e.addEventListener(`mouseleave`,e=>{g()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{g()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=b,C(e,f(Wi,{size:13})),S(t=>{var n=g()?`Click again to confirm deletion`:`Delete flag`,r=g()?`#f85149`:`#8b949e`;return n!==t.e&&B(e,`title`,t.e=n),r!==t.t&&H(e,`color`,t.t=r),t},{e:void 0,t:void 0}),e}}),y),y.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),y.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#fff`),y.$$click=()=>Vd(e.item.id),C(a,f(de,{get component(){return c()},get item(){return e.item}}),null),C(a,f(_,{get when(){return e.item.id},children:e=>(()=>{var t=Pg();return t.$$click=()=>navigator.clipboard?.writeText(e()),C(t,e),S(()=>B(t,`title`,e())),t})()}),null),S(e=>H(a,`border`,`1px solid ${o()&&l()||p()||g()?`#f85149`:`#30363d`}`)),a})()}function o_(){return(()=>{var e=Fg();return C(e,f(_,{get when(){return Rd().length>0},get fallback(){return Ig()},get children(){return f(u,{get each(){return Rd()},children:e=>f(a_,{item:e})})}})),e})()}N([`click`,`input`]);var s_=V(`<div style="padding:3px 0;color:#8b949e">Reserved by`),c_=V(`<div style="padding:3px 0;color:#c9d1d9">`),l_=V(`<div style="padding:3px 0;color:#8b949e">Expires in`),u_=V(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums"> ticks`),d_=V(`<div style="padding:3px 0;color:#8b949e">RCL`),f_=V(`<span style=color:#8b949e>(<!>%)`),p_=V(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums">`),m_=V(`<div style="display:grid;grid-template-columns:repeat(3, 1fr);gap:4px;margin-top:8px">`),h_=V(`<div style="padding:8px;border-bottom:1px solid #30363d;flex-shrink:0"><div style="padding:4px 8px;background:#161b22;border-radius:6px;border:1px solid #30363d"><div style=font-size:10px;font-weight:600;color:#8b949e;text-transform:uppercase;letter-spacing:0.04em;margin-bottom:4px> Room</div><div style=font-size:13px;font-weight:600;color:#c9d1d9></div><div style="display:grid;grid-template-columns:auto 1fr;row-gap:1px;margin-top:4px;font-size:11px"><div style="padding:3px 0;color:#8b949e">Shard</div><div style="padding:3px 0;color:#c9d1d9"></div><div style="padding:3px 0;color:#8b949e">Tick</div><div style="padding:3px 0;color:#c9d1d9"></div><div style="padding:3px 0;color:#8b949e">Tick duration</div><div style="padding:3px 0;color:#c9d1d9"></div><div style="padding:3px 0;color:#8b949e">Objects</div><div style="padding:3px 0;color:#c9d1d9"></div><div style="padding:3px 0;color:#8b949e">Owner</div><div style="padding:3px 0;color:#c9d1d9"></div></div><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px;color:#c9d1d9;cursor:pointer;margin-top:6px><span>Creep-Namen</span><input type=checkbox></label><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px;color:#c9d1d9;cursor:pointer;margin-top:4px><span>Room Visuals</span><input type=checkbox>`),g_=V(`<span>`),__=V(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;display:flex;align-items:center;justify-content:center">`),v_=[{mode:`view`,label:`View`,icon:()=>f(Rr,{size:14})},{mode:`flag`,label:`Flag`,icon:()=>f(Hr,{size:14})},{mode:`build`,label:`Build`,icon:()=>f(Jr,{size:14})}];function y_(e){return(()=>{var t=h_(),n=t.firstChild.firstChild.nextSibling,r=n.nextSibling,i=r.firstChild.nextSibling,a=i.nextSibling.nextSibling,o=a.nextSibling.nextSibling,s=o.nextSibling.nextSibling,c=s.nextSibling.nextSibling,l=r.nextSibling,d=l.firstChild.nextSibling,p=l.nextSibling.firstChild.nextSibling;return C(n,()=>e.room),C(i,()=>e.shard??`—`),C(a,()=>Ae()??`—`),C(o,(()=>{var e=R(()=>!!Fe());return()=>e()?`${Fe()}ms`:`—`})()),C(s,()=>Wd()??`—`),C(c,f(Hh,{get username(){return Kd()?.username},fallback:`—`,color:`#c9d1d9`})),C(r,f(_,{get when(){return R(()=>!Kd())()&&Qd()},get children(){return[s_(),(()=>{var e=c_();return C(e,f(Hh,{get username(){return nf()?.[Qd().user]?.username},get fallback(){return Qd().user},color:`#c9d1d9`})),e})(),l_(),(()=>{var e=u_(),t=e.firstChild;return C(e,(()=>{var e=R(()=>Ae()!==null);return()=>e()?Math.max(0,Qd().endTime-Ae()):`—`})(),t),e})()]}}),null),C(r,f(_,{get when(){return R(()=>Jd()!==null)()&&Jd()>0},get children(){return[d_(),(()=>{var e=p_();return C(e,f(_,{get when(){return R(()=>Jd()<8)()&&Xd()!==null},get fallback(){return(()=>{var e=g_();return C(e,Jd),e})()},get children(){return[R(()=>Jd()),` → `,R(()=>Jd()+1),`\xA0`,(()=>{var e=f_(),t=e.firstChild.nextSibling;return t.nextSibling,C(e,()=>(Xd()/(ss[Jd()]??1)*100).toFixed(1),t),e})()]}})),e})()]}}),null),d.addEventListener(`change`,e=>Ct(e.currentTarget.checked)),p.addEventListener(`change`,e=>gt(e.currentTarget.checked)),C(t,f(_,{get when(){return!ge()},get children(){var e=m_();return C(e,f(u,{each:v_,children:e=>{let t=()=>!J()&&qf()===e.mode;return(()=>{var n=__();return n.$$click=()=>{J()&&Df(),Jf(e.mode)},C(n,()=>e.icon()),S(r=>{var i=e.label,a=`1px solid ${t()?`#58a6ff`:`#30363d`}`,o=t()?`#1f6feb33`:`#161b22`,s=t()?`#c9d1d9`:`#8b949e`;return i!==r.e&&B(n,`title`,r.e=i),a!==r.t&&H(n,`border`,r.t=a),o!==r.a&&H(n,`background`,r.a=o),s!==r.o&&H(n,`color`,r.o=s),r},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()}})),e}}),null),S(()=>d.checked=Tt()),S(()=>p.checked=Kn()),t})()}N([`click`]);var b_=V(`<div style=margin-bottom:8px><select style="width:100%;padding:5px 8px;background:#161b22;border:1px solid #30363d;border-radius:6px;color:#c9d1d9;font-size:12px;cursor:pointer">`),x_=V(`<div style="padding:8px;border-bottom:1px solid #30363d;flex-shrink:0"><div style="padding:4px 8px;background:#161b22;border-radius:6px;border:1px solid #30363d"><div style=font-size:10px;font-weight:600;color:#8b949e;text-transform:uppercase;letter-spacing:0.04em;margin-bottom:4px>Map</div><div style="display:grid;grid-template-columns:auto 1fr;row-gap:1px;font-size:11px;margin-bottom:8px"><div style="padding:3px 0;color:#8b949e">Zoom</div><div style="padding:3px 0;color:#c9d1d9"></div><div style="padding:3px 0;color:#8b949e">Live</div><div style="padding:3px 0;color:#c9d1d9"></div></div><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px><span>Show room names</span><input type=checkbox></label><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px;color:#c9d1d9;cursor:pointer;margin-top:4px><span>Show unclaimable rooms</span><input type=checkbox></label><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px;color:#c9d1d9;cursor:pointer;margin-top:4px><span>Show map visuals</span><input type=checkbox></label><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px;color:#c9d1d9;cursor:pointer;margin-top:4px><span>Room decorations</span><input type=checkbox></label></div><div style="display:grid;grid-template-columns:repeat(3, 1fr);gap:4px;margin-top:8px">`),S_=V(`<option>`),C_=V(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;font-size:11px;font-weight:600">`),w_=[{mode:`owner`,label:`Owner`},{mode:`mineral`,label:`Mineral`},{mode:`none`,label:`None`}];function T_(e){let t=()=>(e.zoom??1)>=Dn,n=()=>ve()?.serverData?.shards?.filter(e=>e!==null)??[],r=()=>we()===!1&&n().length>1;return(()=>{var i=x_(),a=i.firstChild,o=a.firstChild.nextSibling,s=o.firstChild.nextSibling,c=s.nextSibling.nextSibling,l=o.nextSibling,d=l.firstChild.nextSibling,p=l.nextSibling,m=p.firstChild.nextSibling,h=p.nextSibling,g=h.firstChild.nextSibling,v=h.nextSibling.firstChild.nextSibling,y=a.nextSibling;return C(i,f(_,{get when(){return r()},get children(){var t=b_(),r=t.firstChild;return r.addEventListener(`change`,t=>e.onShardChange?.(t.currentTarget.value)),C(r,f(u,{get each(){return n()},children:e=>(()=>{var t=S_();return t.value=e,C(t,e),t})()})),S(()=>r.value=e.shard??``),t}}),a),C(s,()=>e.zoom?.toFixed(2)??`—`),C(c,()=>e.subsActive?`Yes`:`No`),d.addEventListener(`change`,e=>xt(e.currentTarget.checked)),m.addEventListener(`change`,e=>yn(e.currentTarget.checked)),g.addEventListener(`change`,e=>Rt(e.currentTarget.checked)),v.addEventListener(`change`,e=>xn(e.currentTarget.checked)),C(y,f(u,{each:w_,children:e=>{let t=()=>jn()===e.mode;return(()=>{var n=C_();return n.$$click=()=>Tn(e.mode),C(n,()=>e.label),S(e=>{var r=`1px solid ${t()?`#58a6ff`:`#30363d`}`,i=t()?`#1f6feb33`:`#161b22`,a=t()?`#c9d1d9`:`#8b949e`;return r!==e.e&&H(n,`border`,e.e=r),i!==e.t&&H(n,`background`,e.t=i),a!==e.a&&H(n,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),n})()}})),S(e=>{var n=t()?`#c9d1d9`:`#484f58`,r=t()?`pointer`:`default`,i=!t();return n!==e.e&&H(l,`color`,e.e=n),r!==e.t&&H(l,`cursor`,e.t=r),i!==e.a&&(d.disabled=e.a=i),e},{e:void 0,t:void 0,a:void 0}),S(()=>d.checked=kt()),S(()=>m.checked=vt()),S(()=>g.checked=Nt()),S(()=>v.checked=Ut()),i})()}N([`click`]);var E_=V(`<img width=12 height=12 alt style="border-radius:2px;flex:0 0 auto;display:block">`),D_=V(`<div style="padding:3px 8px;color:#484f58">None`),O_=V(`<div style="padding:3px 8px;color:#c9d1d9;display:flex;align-items:center;gap:4px;min-width:0">`),k_=V(`<div style="margin:8px 8px 0;border-radius:6px;overflow:hidden"><div style="padding:4px 8px;background:#161b22;border-bottom:1px solid #21262d;font-size:10px;font-weight:600;color:#8b949e;text-transform:uppercase;letter-spacing:0.04em">`),A_=V(`<div style="padding:6px 8px;font-size:11px;color:#484f58;font-style:italic">None`),j_=V(`<div style="padding:3px 8px;color:#8b949e">Reservation`),M_=V(`<div style="padding:3px 8px;color:#8b949e">Mineral`),N_=V(`<div style="padding:3px 8px;color:#79c0ff">`),P_=V(`<div style="padding:3px 8px;color:#8b949e">Density`),F_=V(`<div style="padding:3px 8px;color:#c9d1d9">`),I_=V(`<div style=font-size:11px><div style="display:flex;align-items:center;gap:6px;padding:5px 8px;font-weight:600;color:#c9d1d9;font-size:12px;border-bottom:1px solid #21262d"><span style=overflow:hidden;text-overflow:ellipsis;white-space:nowrap></span></div><div style="display:grid;grid-template-columns:auto 1fr;align-items:center;row-gap:1px;column-gap:0">`),L_=V(`<span title="Controller level"style="margin-left:auto;padding:0 7px;line-height:17px;background:#21262d;border-radius:4px;color:#c9d1d9;font-size:11px;font-variant-numeric:tabular-nums">`),R_=V(`<div style="padding:3px 8px;color:#8b949e">Owner`),z_=V(`<div style=display:flex;align-items:center;gap:4px;align-self:flex-end;color:#8b949e><span>—`),B_=V(`<div style="padding:5px 8px;border-top:1px solid #21262d;display:flex;flex-direction:column;gap:3px"><div style=color:#8b949e>Sign</div><div style=color:#c9d1d9;font-style:italic>“<!>”</div><div style=align-self:flex-end;color:#484f58;font-size:10px>`),V_=[`Low`,`Medium`,`High`,`Ultra`];function H_(e){return V_[e-1]??String(e)}function U_(e){let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate(),i=t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,second:`2-digit`});return r?`Today at ${i}`:`${t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}, ${i}`}function W_(e){let t=y(()=>`data:image/svg+xml,${encodeURIComponent(pt(e.badge))}`);return(()=>{var e=E_();return S(()=>B(e,`src`,t())),e})()}function G_(e){return f(_,{get when(){return e.name},get fallback(){return D_()},children:t=>(()=>{var n=O_();return C(n,f(_,{get when(){return e.badge},children:e=>f(W_,{get badge(){return e()}})}),null),C(n,f(Hh,{get username(){return t()},color:`#c9d1d9`,style:{overflow:`hidden`,"text-overflow":`ellipsis`,"white-space":`nowrap`}}),null),n})()})}function K_(e){return(()=>{var t=k_(),n=t.firstChild;return C(n,()=>e.label),C(t,f(_,{get when(){return e.info},get fallback(){return A_()},children:e=>(()=>{var t=I_(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return C(r,()=>e().room),C(n,f(_,{get when(){return e().level},children:e=>(()=>{var t=L_();return C(t,e),t})()}),null),C(i,f(_,{get when(){return e().reservation},get fallback(){return[R_(),f(G_,{get name(){return e().owner},get badge(){return e().badge}})]},get children(){return[j_(),f(G_,{get name(){return e().reservation},get badge(){return e().badge}})]}}),null),C(i,f(_,{get when(){return e().mineral},get children(){return[M_(),(()=>{var t=N_();return C(t,()=>e().mineral),t})(),P_(),(()=>{var t=F_();return C(t,()=>H_(e().density??0)),t})()]}}),null),C(t,f(_,{get when(){return e().sign},children:e=>(()=>{var t=B_(),n=t.firstChild.nextSibling,r=n.firstChild.nextSibling;r.nextSibling;var i=n.nextSibling;return C(n,()=>e().text,r),C(t,f(_,{get when(){return e().username||e().badge},get children(){var t=z_();return t.firstChild,C(t,f(_,{get when(){return e().badge},children:e=>f(W_,{get badge(){return e()}})}),null),C(t,f(Hh,{get username(){return e().username},color:`#8b949e`}),null),t}}),i),C(i,()=>U_(e().datetime)),t})()}),null),t})()}),null),S(n=>{var r=`1px solid ${e.dim?`#21262d`:`#30363d`}`,i=e.dim?.6:1;return r!==n.e&&H(t,`border`,n.e=r),i!==n.t&&H(t,`opacity`,n.t=i),n},{e:void 0,t:void 0}),t})()}var q_=V(`<span style=color:#8b949e;font-size:11px>Checking…`),J_=V(`<div style=margin-top:8px><div style="padding:6px 8px;font-size:11px;font-weight:600;color:#c9d1d9;margin-bottom:6px">Your flags`),Y_=V(`<div style=flex:1;overflow:auto;min-height:0;padding:8px><div style="border-radius:6px;border:1px solid #30363d;overflow:hidden;background:#0d1117"><div style="padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d;font-size:11px;font-weight:600;color:#c9d1d9">Create flag</div><div style=padding:8px;display:flex;flex-direction:column;gap:8px><label>Name<input placeholder="Flag name"style="background:#010409;color:#c9d1d9;border-radius:4px;padding:5px 6px;font-size:12px;outline:none"></label><label>Primary color</label><label>Secondary color</label><div style=color:#484f58;font-size:11px;line-height:1.4>`),X_=V(`<span style=color:#f85149;font-size:11px>`),Z_=V(`<div style=margin-top:8px;color:#484f58;font-style:italic;font-size:12px>No flags.`),Q_=V(`<div style="border-radius:6px;border:1px solid #30363d;margin-bottom:6px;overflow:hidden"><div style="display:flex;align-items:center;gap:7px;padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d"><div style=width:8px;height:8px;border-radius:50%;flex-shrink:0></div><span style=font-size:11px;font-weight:600;color:#c9d1d9;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap></span><span style=font-size:10px;color:#8b949e;flex-shrink:0></span><span style=font-size:10px;color:#484f58;flex-shrink:0;margin-left:4px>(<!>,<!>)`),{error:$_}=P(`flag`),ev={};for(let[e,t]of Object.entries(Gf))ev[t]=e;function tv(){let e=e=>{Xf({...Yf(),...e})},[t,n]=a(null),[r,i]=a(!1),o=null,c=t=>{t.http.game.genUniqueFlagName().then(t=>{e({name:t.name}),n(null)}).catch(e=>{$_(`gen unique name failed:`,e)})};s(()=>{if(qf()!==`flag`)return;let e=z();if(!e)return;let t=m(()=>Yf().name.trim());if(!t){c(e);return}e.http.game.checkUniqueFlagName(t).then(()=>{n(null)}).catch(()=>{c(e)})});let l=t=>{e({name:t}),n(null),o&&clearTimeout(o);let r=t.trim();if(!r){i(!1);return}i(!0),o=setTimeout(()=>{let e=z();if(!e){i(!1);return}e.http.game.checkUniqueFlagName(r).then(()=>{n(null)}).catch(e=>{n(e.message)}).finally(()=>{i(!1)})},300)},d=()=>Gf[Yf().color]??1,p=()=>Gf[Yf().secondaryColor]??1,h=t=>{e({color:ev[t]??`COLOR_WHITE`})},g=t=>{e({secondaryColor:ev[t]??`COLOR_WHITE`})},v=()=>{let e=he(),t=[];for(let[n,r]of Object.entries(e))r&&typeof r==`object`&&`room`in r&&`x`in r&&`y`in r&&t.push([n,r]);return t},y=e=>e===void 0||e<0||e>=En.length?`#8b949e`:`#${En[e].toString(16).padStart(6,`0`)}`,b={display:`flex`,"flex-direction":`column`,gap:`5px`,"font-size":`11px`,color:`#8b949e`};return(()=>{var e=Y_(),n=e.firstChild.firstChild.nextSibling.firstChild,i=n.firstChild.nextSibling,a=n.nextSibling;a.firstChild;var o=a.nextSibling;o.firstChild;var s=o.nextSibling;return i.$$input=e=>l(e.currentTarget.value),C(n,f(_,{get when(){return t()},children:e=>(()=>{var t=X_();return C(t,e),t})()}),null),C(n,f(_,{get when(){return r()},get children(){return q_()}}),null),C(a,f(jm,{get value(){return d()},onChange:h}),null),C(o,f(jm,{get value(){return p()},onChange:g}),null),C(s,(()=>{var e=R(()=>!!Zf());return()=>e()?`Marked at x=${Zf().tx}, y=${Zf().ty}. Click again to create the flag, or click elsewhere to move the mark.`:`Click a position in the room to mark it.`})()),C(e,f(_,{get when(){return v().length>0},get fallback(){return Z_()},get children(){var e=J_();return e.firstChild,C(e,f(u,{get each(){return v()},children:([e,t])=>(()=>{var n=Q_(),r=n.firstChild.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling,s=o.firstChild.nextSibling,c=s.nextSibling.nextSibling;return c.nextSibling,C(i,e),C(a,()=>t.room),C(o,()=>t.x,s),C(o,()=>t.y,c),S(e=>H(r,`background`,y(t.color))),n})()}),null),e}}),null),S(e=>{var r=b,s=`1px solid ${t()?`#f85149`:`#30363d`}`,c=b,l=b;return e.e=L(n,r,e.e),s!==e.t&&H(i,`border`,e.t=s),e.a=L(a,c,e.a),e.o=L(o,l,e.o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),S(()=>i.value=Yf().name),e})()}N([`input`]);var nv=V(`<span style=color:#8b949e>…`),rv=V(`<span style=color:#3fb950>✓`),iv=V(`<span style=color:#f85149>✗`),av=V(`<div style=font-size:10px;color:#f85149>`),ov=V(`<div style="margin-top:8px;border-radius:6px;border:1px solid #30363d;overflow:hidden;background:#0d1117"><div style="padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d;font-size:11px;font-weight:600;color:#c9d1d9">Spawn name</div><div style=padding:8px;display:flex;flex-direction:column;gap:6px><div style=display:flex;gap:6px;align-items:center><input type=text style="flex:1;background:#010409;color:#c9d1d9;border-radius:4px;padding:5px 7px;font-size:12px;outline:none;transition:border-color 150ms ease"><span style=font-size:14px;flex-shrink:0;width:14px;text-align:center>`),sv=V(`<div style=flex:1;overflow:auto;min-height:0;padding:8px><div style="border-radius:6px;border:1px solid #30363d;overflow:hidden;background:#0d1117;margin-bottom:8px"><div style="padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d;font-size:11px;font-weight:600;color:#c9d1d9">Controller Level </div><div style=padding:8px;font-size:11px;color:#8b949e></div></div><div style="border-radius:6px;border:1px solid #30363d;overflow:hidden;background:#0d1117"><div style="padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d;font-size:11px;font-weight:600;color:#c9d1d9">Structures</div></div><div style="margin-top:8px;padding:0 4px"><div style=color:#484f58;font-style:italic;font-size:12px>`),cv=V(`<div style="padding:6px 8px;display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid #21262d;font-size:11px;color:#c9d1d9"><span style=text-transform:capitalize></span><span style=color:#8b949e>`);function lv(e){let t=Object.keys(Kf),[i,o]=a(`idle`),[c,l]=a(``),d=null,p=(e,t)=>{let n=Kf[e];return n?E()===`empty`&&e===`spawn`?Math.max(n[t]??0,1):n[t]??0:0},m=(e,t)=>{let n=p(e,t);if(n===2500)return 1/0;let r=ef()[e]??0;return Math.max(0,n-r)},h=()=>tp().structureType===`spawn`;s(r(()=>tp().structureType,(t,r)=>{if(t!==`spawn`||t===r)return;let i=z();if(!i)return;o(`loading`),l(``);let a=!1;n(()=>{a=!0}),i.http.game.genUniqueObjectName(`spawn`,e.shard).then(e=>{a||(np({structureType:`spawn`,structureName:e.name}),o(`valid`))}).catch(()=>{a||(np({structureType:`spawn`,structureName:`Spawn1`}),o(`idle`))})}));let g=t=>{if(d&&clearTimeout(d),!t.trim()){o(`invalid`),l(`Name cannot be empty`);return}o(`loading`),l(``),d=setTimeout(()=>{let n=z();n&&n.http.game.checkUniqueObjectName(`spawn`,t.trim(),e.shard).then(e=>{e.error?(o(`invalid`),l(e.error)):(o(`valid`),l(``))}).catch(()=>{o(`invalid`),l(`Could not validate name`)})},400)},v=e=>{np({structureType:`spawn`,structureName:e}),g(e)},y=e=>{np({structureType:e,structureName:``}),o(`idle`),l(``)},b=()=>{switch(i()){case`loading`:return nv();case`valid`:return rv();case`invalid`:return iv();default:return null}};return(()=>{var e=sv(),n=e.firstChild,r=n.firstChild;r.firstChild;var a=r.nextSibling,o=n.nextSibling;o.firstChild;var s=o.nextSibling,l=s.firstChild;return C(r,()=>Jd()??`?`,null),C(a,()=>{let e=E();return e===`empty`?`World is empty — place a spawn to claim this room.`:e===`lost`?`You lost all your spawns — respawn to continue.`:Jd()==null?`No controller — roads and containers only.`:`RCL ${Jd()} — Select a structure type and click a tile to build.`}),C(o,f(u,{each:t,children:e=>{let t=()=>Jd()??0,n=()=>p(e,t()),r=()=>ef()[e]??0,i=()=>tp().structureType===e,a=()=>n()===2500,o=()=>!a()&&m(e,t())<=0;return f(_,{get when(){return n()>0},get children(){var t=cv(),s=t.firstChild,c=s.nextSibling;return t.$$click=()=>!o()&&y(e),C(s,()=>e.replace(/([A-Z])/g,` $1`).trim(),null),C(s,()=>i()&&` ✓`,null),C(c,(()=>{var e=R(()=>!!a());return()=>e()?`${r()}/∞`:`${r()}/${n()}`})(),null),C(c,()=>o()&&` (Max)`,null),S(e=>{var n=i()?`#1f3158`:`transparent`,r=o()?`default`:`pointer`,a=o()?.5:1;return n!==e.e&&H(t,`background`,e.e=n),r!==e.t&&H(t,`cursor`,e.t=r),a!==e.a&&H(t,`opacity`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),t}})}}),null),C(e,f(_,{get when(){return h()},get children(){var e=ov(),t=e.firstChild.nextSibling,n=t.firstChild.firstChild,r=n.nextSibling;return n.$$input=e=>v(e.currentTarget.value),C(r,b),C(t,f(_,{get when(){return R(()=>i()===`invalid`)()&&c()},get children(){var e=av();return C(e,c),e}}),null),S(e=>H(n,`border`,`1px solid ${i()===`invalid`?`#f85149`:i()===`valid`?`#238636`:`#30363d`}`)),S(()=>n.value=tp().structureName??``),e}}),s),C(l,()=>tp().structureType?`Click a tile in the room to build.`:`Select a structure type, then click a tile.`),e})()}N([`input`,`click`]);var uv=V(`<div style="padding:8px;border-bottom:1px solid #30363d;flex-shrink:0"><div style=display:flex;flex-direction:column;gap:6px><div style=font-size:11px><div></div><div style=font-size:10px;color:#484f58;margin-top:2px>~</div></div><div style=display:flex;gap:3px><button type=button style="flex:1.5;padding:4px;border-radius:4px;border:1px solid #30363d;font-size:11px"></button></div><div style=display:flex;align-items:center;gap:6px><span style=font-size:10px;color:#8b949e;white-space:nowrap>Speed</span><select style="flex:1;background:#161b22;color:#8b949e;border:1px solid #30363d;border-radius:4px;padding:3px 6px;font-size:11px;cursor:pointer">`),dv=V(`<button type=button>`),fv=V(`<option>/s`),pv=[.5,1,2,5,10,20],mv=[{delta:-100,label:`-100`},{delta:-10,label:`-10`}],hv=[{delta:10,label:`+10`},{delta:100,label:`+100`}];function gv(e){return{flex:`1`,padding:`4px`,"border-radius":`4px`,border:`1px solid #30363d`,background:`#161b22`,color:e?`#484f58`:`#8b949e`,cursor:e?`not-allowed`:`pointer`,"font-size":`11px`}}function _v(){let e=()=>{let e=mf(),t=uf(),n=Fe()??3e3,r=(e-t)*n;return new Date(Date.now()-r).toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})};return(()=>{var t=uv(),n=t.firstChild.firstChild,r=n.firstChild,i=r.nextSibling;i.firstChild;var a=n.nextSibling,o=a.firstChild,s=a.nextSibling.firstChild.nextSibling;return C(r,(()=>{var e=R(()=>!!bf());return()=>e()?`Loading…`:`Tick ${uf()}`})()),C(i,e,null),C(a,f(u,{each:mv,children:e=>(()=>{var t=dv();return t.$$click=()=>kf(e.delta),C(t,()=>e.label),S(e=>{var n=bf(),r=gv(bf());return n!==e.e&&(t.disabled=e.e=n),e.t=L(t,r,e.t),e},{e:void 0,t:void 0}),t})()}),o),I(o,`click`,Af,!0),C(o,()=>gf()?`⏸`:`▶`),C(a,f(u,{each:hv,children:e=>(()=>{var t=dv();return t.$$click=()=>kf(e.delta),C(t,()=>e.label),S(e=>{var n=bf(),r=gv(bf());return n!==e.e&&(t.disabled=e.e=n),e.t=L(t,r,e.t),e},{e:void 0,t:void 0}),t})()}),null),s.addEventListener(`change`,e=>Mf(parseFloat(e.currentTarget.value))),C(s,f(u,{each:pv,children:e=>(()=>{var t=fv(),n=t.firstChild;return t.value=e,C(t,e,n),t})()})),S(e=>{var t=bf()?`#f0883e`:`#c9d1d9`,n=bf(),i=gf()?`#1a3a2a`:`#161b22`,a=gf()?`#3fb950`:`#8b949e`,s=bf()?`not-allowed`:`pointer`;return t!==e.e&&H(r,`color`,e.e=t),n!==e.t&&(o.disabled=e.t=n),i!==e.a&&H(o,`background`,e.a=i),a!==e.o&&H(o,`color`,e.o=a),s!==e.i&&H(o,`cursor`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),S(()=>s.value=vf()),t})()}N([`click`]);var vv=V(`<div style=padding-bottom:8px;overflow:auto;min-height:0>`),yv=V(`<div style=display:flex;flex-direction:row;height:100%;background:#0d1117><div style="width:32px;height:100%;display:flex;flex-direction:column;align-items:center;border-right:1px solid #30363d;padding:8px 0;cursor:pointer"></div><div style=flex:1;display:flex;flex-direction:column;overflow:hidden><div style="padding:6px 10px;border-bottom:1px solid #30363d;font-size:12px;font-weight:600;color:#8b949e;display:flex;justify-content:space-between;align-items:center"><span>Properties`),bv=V(`<button style=background:transparent;border:none;color:#8b949e;font-size:14px;cursor:pointer;padding:4px>`),xv=V(`<button style=background:transparent;border:none;color:#8b949e;font-size:11px;cursor:pointer>Collapse`);function Sv(e){return f(_,{get when(){return qf()===`flag`},get fallback(){return f(_,{get when(){return qf()===`build`},get fallback(){return f(o_,{})},get children(){return f(lv,{get shard(){return e.shard}})}})},get children(){return f(tv,{})}})}function Cv(e){let t=()=>{e.onToggle?.()},n=t=>{t.stopPropagation(),e.onToggle?.()};return(()=>{var r=yv(),i=r.firstChild,a=i.nextSibling,o=a.firstChild;return o.firstChild,i.$$click=t,C(i,(()=>{var t=R(()=>!!e.onToggle);return()=>t()&&(()=>{var t=bv();return t.$$click=n,C(t,()=>e.isCollapsed?`▶`:`◀`),t})()})()),C(o,(()=>{var t=R(()=>!!e.onToggle);return()=>t()&&(()=>{var e=xv();return e.$$click=n,e})()})(),null),C(a,f(_,{get when(){return e.mapMode},get fallback(){return f(y_,{get room(){return e.room??`—`},get shard(){return e.shard??null}})},get children(){return f(T_,{get zoom(){return e.mapZoom},get subsActive(){return e.mapSubsActive},get shard(){return e.shard},get onShardChange(){return e.onShardChange}})}}),null),C(a,f(_,{get when(){return R(()=>!e.mapMode)()&&J()},get children(){return f(_v,{})}}),null),C(a,f(_,{get when(){return e.mapMode},get fallback(){return f(Sv,{get shard(){return e.shard}})},get children(){var t=vv();return C(t,f(K_,{label:`Selected`,get info(){return e.selectedRoomInfo??null}}),null),C(t,f(K_,{label:`Cursor`,get info(){return e.hoveredRoomInfo??null},dim:!0}),null),t}}),null),r})()}N([`click`]);var wv=V(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>CPU:</span><span style=color:#c9d1d9>`),Tv=V(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Memory:</span><span style=color:#c9d1d9>`),Ev=V(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Zoom:</span><span style=color:#c9d1d9>%`),Dv=V(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Subs:</span><span>`),Ov=V(`<div style="display:flex;gap:16px;padding:6px 16px;font-size:12px;color:#8b949e;align-items:center">`);function kv(e){let[t,r]=a(null);i(()=>{let e=z();if(!e)return;let t=new rt;t.add(e.stores.user.subscribe(`cpu`)),t.add(e.stores.user.on(`user:cpu`,e=>{r(e)})),n(()=>{t.dispose()})});let o=()=>{let e=t();if(!e)return`—`;let n=U()?.cpu??`?`;return`${e.cpu.toFixed(0)} / ${n}`},s=()=>{let e=t();return e?`${(e.memory/1024).toFixed(1)} KB`:`—`};return(()=>{var n=Ov();return C(n,f(_,{get when(){return t()!==null},get children(){return[(()=>{var e=wv(),t=e.firstChild.nextSibling;return C(t,o),e})(),(()=>{var e=Tv(),t=e.firstChild.nextSibling;return C(t,s),e})()]}}),null),C(n,f(_,{get when(){return R(()=>e.mapZoom!==null)()&&e.mapZoom!==void 0},get children(){return[(()=>{var t=Ev(),n=t.firstChild.nextSibling,r=n.firstChild;return C(n,()=>(e.mapZoom*100).toFixed(0),r),t})(),(()=>{var t=Dv(),n=t.firstChild.nextSibling;return C(n,()=>e.mapSubsActive===!1?`paused`:`active`),S(t=>H(n,`color`,e.mapSubsActive===!1?`#e3b341`:`#3fb950`)),t})()]}}),null),n})()}var Av=V(`<div style=width:100%;height:100%;overflow:auto;background:#0d1117;color:#c9d1d9><div style="margin:0 auto;padding:24px 16px 48px">`);function jv(e){return(()=>{var t=Av(),n=t.firstChild;return C(n,()=>e.children),S(t=>H(n,`max-width`,e.maxWidth??`1040px`)),t})()}var Mv=V(`<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 0;border-bottom:1px solid #21262d"><div><div style=font-size:13px;color:#c9d1d9></div></div><button style="flex-shrink:0;margin-left:24px;width:40px;height:20px;border-radius:10px;border:none;cursor:pointer;position:relative;transition:background 0.15s"><div style="position:absolute;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left 0.15s">`),Nv=V(`<div style=font-size:11px;color:#8b949e;margin-top:3px>`),Pv=V(`<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 0;border-bottom:1px solid #21262d;gap:24px"><div><div style=font-size:13px;color:#c9d1d9></div></div><select style="flex-shrink:0;background:#21262d;color:#c9d1d9;border:1px solid #30363d;border-radius:4px;padding:4px 8px;font-size:12px;cursor:pointer">`),Fv=V(`<option>`),Iv=V(`<div style=margin-bottom:24px><div style=font-size:10px;font-weight:700;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;margin-bottom:4px>`),Lv=V(`<div style="display:flex;align-items:center;justify-content:space-between;gap:24px;padding:10px 0;border-bottom:1px solid #21262d"><div style=font-size:13px;color:#c9d1d9></div><div style=font-size:12px;color:#8b949e;text-align:right>`),Rv=V(`<div style="display:flex;align-items:center;padding:0 0 14px;border-bottom:1px solid #30363d;margin-bottom:24px"><h1 style=margin:0;font-size:22px;font-weight:600;color:#c9d1d9>Settings</h1><div style=flex:1></div><button title=Close style="display:flex;align-items:center;padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer">`),zv=V(`<div style=display:flex;flex-direction:column;gap:4px><label style=font-size:13px;font-weight:500>Structure theme</label><select style="background:#2a2a2a;color:#eee;border:1px solid #444;border-radius:4px;padding:4px 8px;font-size:13px"><option value=vector>Vector (procedural)</option><option value=default>Default (sprites)`),Bv=V(`<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 0;border-bottom:1px solid #21262d"><div><div style=font-size:13px;color:#c9d1d9>Clear all caches</div><div style=font-size:11px;color:#8b949e;margin-top:3px>Deletes IndexedDB, Cache API, and localStorage. Session is kept. Page reloads afterwards.</div></div><button style="flex-shrink:0;margin-left:24px;padding:6px 14px;border-radius:6px;border:1px solid #da3633;background:transparent;font-size:12px">`),Vv=V(`<div style=max-width:480px>`);function Hv(e){return(()=>{var t=Mv(),n=t.firstChild,r=n.firstChild,i=n.nextSibling,a=i.firstChild;return C(r,()=>e.label),C(n,(()=>{var t=R(()=>!!e.description);return()=>t()&&(()=>{var t=Nv();return C(t,()=>e.description),t})()})(),null),i.$$click=()=>e.onChange(!e.value),S(t=>{var n=e.value?`#238636`:`#30363d`,r=e.value?`22px`:`2px`;return n!==t.e&&H(i,`background`,t.e=n),r!==t.t&&H(a,`left`,t.t=r),t},{e:void 0,t:void 0}),t})()}function Uv(e){return(()=>{var t=Pv(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return C(r,()=>e.label),C(n,(()=>{var t=R(()=>!!e.description);return()=>t()&&(()=>{var t=Nv();return C(t,()=>e.description),t})()})(),null),i.addEventListener(`change`,t=>e.onChange(Number(t.currentTarget.value))),C(i,f(u,{get each(){return e.options},children:e=>(()=>{var t=Fv();return C(t,()=>e.label),S(()=>t.value=String(e.value)),t})()})),S(()=>i.value=String(e.value)),t})()}function Wv(e){return(()=>{var t=Iv(),n=t.firstChild;return C(n,()=>e.title),C(t,()=>e.children,null),t})()}function Gv(e){return(()=>{var t=Lv(),n=t.firstChild,r=n.nextSibling;return C(n,()=>e.label),C(r,()=>e.value),t})()}var Kv=[{value:5,label:`5 min`},{value:10,label:`10 min`},{value:30,label:`30 min`},{value:60,label:`1 hour`},{value:180,label:`3 hours`},{value:360,label:`6 hours`},{value:720,label:`12 hours`},{value:1440,label:`24 hours`},{value:4320,label:`3 days`}],qv=[{value:0,label:`Immediately`},{value:10,label:`Every 10 min`},{value:30,label:`Every 30 min`},{value:60,label:`Every 1 hour`},{value:180,label:`Every 3 hours`},{value:360,label:`Every 6 hours`},{value:720,label:`Every 12 hours`},{value:1440,label:`Every 24 hours`},{value:4320,label:`Every 3 days`},{value:1e5,label:`Never`}];function Jv(e){let t=le(),[n,r]=a(!1);async function i(e){let t=z();if(t)try{await t.http.user.notifyPrefs(e),await t.stores.user.refreshMe()}catch(e){A(`Failed to save notification preference: ${e.message}`,`error`)}}async function o(){r(!0);try{await Ce(),A(`All caches cleared. Reloading…`,`success`,2e3),setTimeout(()=>window.location.reload(),1500)}catch{A(`Failed to clear caches.`,`error`),r(!1)}}return f(jv,{maxWidth:`600px`,get children(){return[(()=>{var t=Rv(),n=t.firstChild.nextSibling.nextSibling;return n.$$click=()=>e.onClose(),C(n,f(Ji,{size:16})),t})(),(()=>{var e=Vv();return C(e,f(Wv,{title:`Layout`,get children(){return f(Hv,{label:`Widescreen mode`,description:`Sidebar spans full height; console sits below the room view only. When off, the console spans the full width below both the view and the sidebar.`,get value(){return Jt()},onChange:Bt})}}),null),C(e,f(Wv,{title:`Room View`,get children(){return[f(Hv,{label:`Terrain effects`,description:`Swamp glow and wall noise texture overlay.`,get value(){return Ot()},onChange:It}),f(Hv,{label:`Room decorations`,description:`Load player-activated theme decorations (floor, wall, road colors) from the server.`,get value(){return Ut()},onChange:xn}),f(Hv,{label:`Dark overlay + lights`,description:`Darken the room and add per-object light glows.`,get value(){return Hn()},onChange:qt}),(()=>{var e=zv(),t=e.firstChild.nextSibling;return t.addEventListener(`change`,e=>Pt(e.currentTarget.value)),S(()=>t.value=Yt()),e})()]}}),null),C(e,f(_,{get when(){return!ge()},get children(){return f(Wv,{title:`Notifications`,get children(){return(()=>{let e=()=>U()?.notifyPrefs??{},t=()=>!e().disabled;return[f(Hv,{label:`Email notifications`,description:`Send email notifications for game events.`,get value(){return t()},onChange:e=>void i({disabled:!e})}),f(_,{get when(){return t()},get children(){return[f(Uv,{label:`Send interval`,description:`Notifications are grouped and mailed out at this interval.`,get value(){return e().interval??60},options:Kv,onChange:e=>void i({interval:e})}),f(Hv,{label:`Send when online`,description:`Send notifications even while you are active in the game.`,get value(){return e().sendOnline??!1},onChange:e=>void i({sendOnline:e})}),f(Uv,{label:`Notify on errors`,description:`Send a notification when your script throws an error.`,get value(){return e().errorsInterval??30},options:qv,onChange:e=>void i({errorsInterval:e})}),f(Hv,{label:`Notify on new messages`,description:`Send a notification when you receive a new in-game message.`,get value(){return!(e().disabledOnMessages??!1)},onChange:e=>void i({disabledOnMessages:!e})})]}})]})()}})}}),null),C(e,f(Wv,{title:`Data`,get children(){var e=Bv(),t=e.firstChild;t.firstChild.nextSibling;var r=t.nextSibling;return r.$$click=o,C(r,()=>n()?`Clearing…`:`Clear`),S(e=>{var t=n(),i=n()?`#8b949e`:`#f85149`,a=n()?`default`:`pointer`,o=n()?.6:1;return t!==e.e&&(r.disabled=e.e=t),i!==e.t&&H(r,`color`,e.t=i),a!==e.a&&H(r,`cursor`,e.a=a),o!==e.o&&H(r,`opacity`,e.o=o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e}}),null),C(e,f(Wv,{title:`About`,get children(){return[f(Gv,{label:`Client version`,get value(){return T()}}),R(()=>t&&f(Gv,{label:`Mod version`,get value(){return`${t.version} (${t.kind})`}}))]}}),null),e})()]}})}N([`click`]);var Yv=V(`<div style="position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);max-width:min(520px, calc(100% - 48px));max-height:calc(100% - 48px);z-index:20;display:flex;background:#161b22;border:1px solid #30363d;border-radius:8px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);animation:motd-in 0.25s ease"><button title=Dismiss style=position:absolute;top:8px;right:8px;padding:4px;border-radius:4px;border:none;background:transparent;color:#8b949e;cursor:pointer;display:flex;align-items:center></button><div style="padding:20px 36px 20px 20px;overflow:auto;color:#c9d1d9;font-size:13px;line-height:1.6">`),Xv=15e3;function Zv(e){let t,r=()=>{t!==void 0&&(clearTimeout(t),t=void 0)},a=()=>{r(),t=setTimeout(()=>e.onClose(),Xv)};return i(a),n(r),(()=>{var t=Yv(),n=t.firstChild,i=n.nextSibling;return t.addEventListener(`mouseleave`,a),t.addEventListener(`mouseenter`,r),n.$$click=()=>e.onClose(),C(n,f(Ji,{size:16})),S(()=>i.innerHTML=e.text),t})()}N([`click`]);var Qv=V(`<img width=20 height=20 style=display:block;border-radius:3px>`),$v=V(`<img width=15 height=15 style=display:block;border-radius:2px>`),ey=V(`<span>`),ty=V(`<span>Settings`),ny=V(`<span>Respawn`),ry=V(`<span>Logout`),iy=V(`<div style="position:absolute;top:calc(100% + 4px);right:0;min-width:180px;background:#161b22;border:1px solid #30363d;border-radius:6px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);z-index:100;overflow:hidden;padding:4px">`),ay=V(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:200;display:flex;align-items:center;justify-content:center><div style="width:min(440px, calc(100% - 48px));background:#161b22;border:1px solid #30363d;border-radius:8px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);padding:20px"><div style=font-size:16px;font-weight:600;color:#f85149;margin-bottom:12px>Respawn?</div><p style="font-size:13px;color:#c9d1d9;line-height:1.5;margin:0 0 10px">All your buildings and creeps will become unowned so that you can reset your spawn in any vacant room on the map.</p><p style="font-size:13px;color:#8b949e;line-height:1.5;margin:0 0 18px"><b style=color:#c9d1d9>Note:</b> you will NOT be able to spawn again in the same room within 3 days of the initial spawn placement.</p><div style=display:flex;justify-content:flex-end;gap:8px><button style="padding:7px 14px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;font-size:13px">Cancel</button><button style="padding:7px 14px;border-radius:4px;border:1px solid #da3633;background:#da3633;color:#fff;font-size:13px;font-weight:600">`),oy=V(`<div style=font-size:12px;color:#f85149;margin-bottom:12px>`),sy=V(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:200;display:flex;align-items:center;justify-content:center><form style="width:min(420px, calc(100% - 48px));background:#161b22;border:1px solid #30363d;border-radius:8px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);padding:20px"><div style=font-size:16px;font-weight:600;color:#c9d1d9;margin-bottom:16px></div><div style=display:flex;justify-content:flex-end;gap:8px;margin-top:4px><button type=button style="padding:7px 14px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;font-size:13px">Cancel</button><button type=submit style="padding:7px 14px;border-radius:4px;border:1px solid #238636;background:#238636;color:#fff;font-size:13px;font-weight:600">`),cy=V(`<div style="position:relative;margin:0 16px 0 8px"><button title=Account style="padding:5px 8px;border-radius:4px;border:1px solid #30363d;color:#c9d1d9;cursor:pointer;display:flex;align-items:center;gap:6px;font-size:13px"><span style=font-weight:600;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap>`),ly=V(`<label style=display:block;margin-bottom:12px><span style=display:block;font-size:12px;color:#8b949e;margin-bottom:4px></span><input type=password style="width:100%;padding:7px 10px;border-radius:4px;border:1px solid #30363d;background:#0d1117;color:#c9d1d9;font-size:13px">`),uy=V(`<button style="width:100%;display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:4px;border:none;cursor:pointer;font-size:13px;text-align:left">`);function dy(e){let[t,r]=a(!1),[i,o]=a(!1),[c,l]=a(!1),[u,d]=a(!1),[p,m]=a(``),[h,g]=a(``),[v,b]=a(``),[x,w]=a(!1),T=()=>Me()===`password`||Me()===`steam`||Me()===`discord`,E=()=>U()?.password===!0,D=y(()=>E()&&p().length===0?`Enter your current password.`:h().length<8?`New password must be at least 8 characters.`:h()===v()?null:`Passwords don't match.`),O,k=y(()=>{let e=U()?.badge;return e?`data:image/svg+xml,${encodeURIComponent(pt(e))}`:null});s(()=>{if(!t())return;let e=e=>{O&&!O.contains(e.target)&&r(!1)},i=e=>{e.key===`Escape`&&r(!1)};document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),n(()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)})});function j(){let e=z();e&&(l(!0),e.http.user.respawn().then(()=>{A(`Respawn successful`,`success`),Ee()}).catch(e=>A(`Respawn failed: ${e.message}`,`error`)).finally(()=>{l(!1),o(!1)}))}function ee(){m(``),g(``),b(``),d(!0)}function M(){let e=z();if(!e||D())return;let t=!E();w(!0),e.http.user.password(h(),p()).then(()=>{A(t?`Password set`:`Password changed`,`success`),d(!1),t&&e.stores.user.refreshMe()}).catch(e=>A(`Password ${t?`setup`:`change`} failed: ${e.message}`,`error`)).finally(()=>w(!1))}return(()=>{var n=cy(),a=n.firstChild,s=a.firstChild;return je(e=>O=e,n),a.$$click=()=>r(e=>!e),C(a,f(_,{get when(){return k()},get children(){var e=Qv();return S(()=>B(e,`src`,k())),e}}),s),C(s,()=>U()?.username??`…`),C(a,f(gr,{size:14}),null),C(n,f(_,{get when(){return t()},get children(){var t=iy();return C(t,f(py,{onClick:()=>{r(!1),e.onOpenBadgePicker()},get children(){return[f(_,{get when(){return k()},get fallback(){return f(Ii,{size:15})},get children(){var e=$v();return S(()=>B(e,`src`,k())),e}}),(()=>{var e=ey();return C(e,()=>U()?.badge?`Edit Badge`:`Create Badge`),e})()]}}),null),C(t,f(py,{onClick:()=>{r(!1),e.onOpenSettings()},get children(){return[f(Mi,{size:15}),ty()]}}),null),C(t,f(_,{get when(){return T()},get children(){return f(py,{onClick:()=>{r(!1),ee()},get children(){return[f(Xr,{size:15}),(()=>{var e=ey();return C(e,()=>E()?`Change password`:`Set password`),e})()]}})}}),null),C(t,f(py,{onClick:()=>{r(!1),o(!0)},get children(){return[f(Oi,{size:15}),ny()]}}),null),C(t,f(py,{onClick:()=>{r(!1),be()},danger:!0,get children(){return[f(oi,{size:15}),ry()]}}),null),t}}),null),C(n,f(_,{get when(){return i()},get children(){var e=ay(),t=e.firstChild.firstChild.nextSibling.nextSibling;t.firstChild;var n=t.nextSibling.firstChild,r=n.nextSibling;return e.$$click=e=>{e.target===e.currentTarget&&!c()&&o(!1)},n.$$click=()=>o(!1),r.$$click=j,C(r,()=>c()?`Respawning…`:`Respawn`),S(e=>{var t=c(),i=c()?`default`:`pointer`,a=c(),o=c()?`default`:`pointer`,s=c()?.6:1;return t!==e.e&&(n.disabled=e.e=t),i!==e.t&&H(n,`cursor`,e.t=i),a!==e.a&&(r.disabled=e.a=a),o!==e.o&&H(r,`cursor`,e.o=o),s!==e.i&&H(r,`opacity`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),C(n,f(_,{get when(){return u()},get children(){var e=sy(),t=e.firstChild,n=t.firstChild,r=n.nextSibling,i=r.firstChild,a=i.nextSibling;return e.$$click=e=>{e.target===e.currentTarget&&!x()&&d(!1)},t.addEventListener(`submit`,e=>{e.preventDefault(),M()}),C(n,()=>E()?`Change password`:`Set password`),C(t,f(_,{get when(){return E()},get children(){return f(fy,{label:`Current password`,get value(){return p()},onInput:m,autofocus:!0})}}),r),C(t,f(fy,{label:`New password`,get value(){return h()},onInput:g,get autofocus(){return!E()}}),r),C(t,f(fy,{label:`Confirm new password`,get value(){return v()},onInput:b}),r),C(t,f(_,{get when(){return R(()=>!!D())()&&(h()||v())},get children(){var e=oy();return C(e,D),e}}),r),i.$$click=()=>d(!1),C(a,()=>x()?`Saving…`:`Save`),S(e=>{var t=x(),n=x()?`default`:`pointer`,r=x()||D()!=null,o=x()||D()!=null?`default`:`pointer`,s=x()||D()!=null?.6:1;return t!==e.e&&(i.disabled=e.e=t),n!==e.t&&H(i,`cursor`,e.t=n),r!==e.a&&(a.disabled=e.a=r),o!==e.o&&H(a,`cursor`,e.o=o),s!==e.i&&H(a,`opacity`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),S(e=>H(a,`background`,t()?`#21262d`:`#161b22`)),n})()}function fy(e){return(()=>{var t=ly(),n=t.firstChild,r=n.nextSibling;return C(n,()=>e.label),r.$$input=t=>e.onInput(t.currentTarget.value),S(()=>r.autofocus=e.autofocus),S(()=>r.value=e.value),t})()}function py(e){let[t,n]=a(!1);return(()=>{var r=uy();return r.addEventListener(`mouseleave`,()=>n(!1)),r.addEventListener(`mouseenter`,()=>n(!0)),r.$$click=()=>e.onClick(),C(r,()=>e.children),S(n=>{var i=t()?`#21262d`:`transparent`,a=e.danger?`#f85149`:`#c9d1d9`;return i!==n.e&&H(r,`background`,n.e=i),a!==n.t&&H(r,`color`,n.t=a),n},{e:void 0,t:void 0}),r})()}N([`click`,`input`]);function my(){return{isDesktop:M(),isEmbedded:ce(),isXxscreepsMode:ue(),isPrivateServer:we(),hasHistory:(ve()?.serverData?.historyChunkSize??0)>0,hasMarket:!0,hasMessaging:!0}}var hy=V(`<div style=position:relative;width:84px;height:84px;flex-shrink:0><svg width=84 height=84 style=transform:rotate(-90deg)><circle cx=42 cy=42 r=38 fill=none stroke-width=8 opacity=0.2></circle><circle cx=42 cy=42 r=38 fill=none stroke-width=8 stroke-linecap=round></circle></svg><div style=position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center><div style=font-size:26px;font-weight:700;line-height:1></div><div style=font-size:10px;font-weight:300;letter-spacing:0.5px>`),gy=`#4DB6AC`,_y=`#A7FFEB`,vy=`#C54444`,yy=`#FF9A9A`;function by(e){let t=2*Math.PI*(76/2),n=()=>`${Math.max(0,Math.min(1,e.fraction))*t} ${t}`;return(()=>{var t=hy(),r=t.firstChild,i=r.firstChild,a=i.nextSibling,o=r.nextSibling,s=o.firstChild,c=s.nextSibling;return C(s,()=>e.value),C(c,()=>e.label),S(r=>{var s=e.tooltip,c=e.ring,l=e.ring,u=n(),d=e.text;return s!==r.e&&B(t,`title`,r.e=s),c!==r.t&&B(i,`stroke`,r.t=c),l!==r.a&&B(a,`stroke`,r.a=l),u!==r.o&&B(a,`stroke-dasharray`,r.o=u),d!==r.i&&H(o,`color`,r.i=d),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),t})()}var xy=V(`<img alt style=display:block;border-radius:3px;flex-shrink:0>`);function Sy(e){let t=()=>e.badge?`data:image/svg+xml,${encodeURIComponent(pt(e.badge))}`:null;return f(_,{get when(){return t()},get children(){var n=xy();return S(r=>{var i=t(),a=e.size??24,o=e.size??24;return i!==r.e&&B(n,`src`,r.e=i),a!==r.t&&B(n,`width`,r.t=a),o!==r.a&&B(n,`height`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n}})}var Cy=V(`<button style="position:absolute;top:50%;right:4px;transform:translateY(-50%);display:flex;align-items:center;padding:2px;border-radius:3px;border:1px solid #30363d;background:#21262d;color:#8b949e;cursor:pointer;line-height:0">`),wy=V(`<div style="position:relative;padding:4px 0;text-align:center;font-size:12px;font-family:monospace;color:#c9d1d9;line-height:1.2;border-top:1px solid #30363d">`),Ty=V(`<div role=button tabindex=0 style="padding:0;border:1px solid #30363d;border-radius:6px;overflow:hidden;background:#161b22;cursor:pointer;line-height:0"><canvas style=display:block>`),Ey=3;function Dy(e,t,n,r){if(!t.length)return;e.fillStyle=dn(n);let i=Ey-r*2;for(let[n,a]of t)e.fillRect(n*Ey+r,a*Ey+r,i,i)}function Oy(e,t,n,r){if(t.length){e.fillStyle=dn(n),e.beginPath();for(let[n,i]of t){let t=(n+.5)*Ey,a=(i+.5)*Ey;e.moveTo(t+r,a),e.arc(t,a,r,0,Math.PI*2)}e.fill()}}function ky(e){let t,r=null,a=null,o,s=()=>{let e=t?.getContext(`2d`);if(!e)return;if(e.setTransform(2,0,0,2,0,0),e.fillStyle=dn(nn),e.fillRect(0,0,150,150),r){let t=r.raw;e.fillStyle=dn(zn);for(let n=0;n<2500;n++)t[n]===ot.Wall&&e.fillRect(n%50*Ey,Math.floor(n/50)*Ey,Ey,Ey);e.fillStyle=dn(In);for(let n=0;n<2500;n++)t[n]===ot.Swamp&&e.fillRect(n%50*Ey,Math.floor(n/50)*Ey,Ey,Ey)}let n=a;if(n){Dy(e,n.r??[],kn,0),Dy(e,n.w??[],cn,.5);for(let t of Pn)Oy(e,n[t.key]??[],t.color,t.radius);let t=n,r=o??U()?._id;for(let n in t){if(_n.has(n))continue;let i=t[n];!Array.isArray(i)||i.length===0||Oy(e,i,n===r?Cn:on,1.2)}}};i(()=>{let t=z();if(!t)return;o=e.ownerId,t.stores.room.terrain(e.room,e.shard).then(e=>{r=e,s()}).catch(()=>{});let i=t.stores.map.subscribeMap2(e.room,e.shard),c=t.stores.map.map2data(e.room,e.shard);c&&(a=c,s());let l=t.stores.map.on(`room:map2update`,({room:t,shard:n,data:r})=>{t!==e.room||(n??null)!==(e.shard??null)||(a=r,s())});n(()=>{i.dispose(),l.dispose()})});let c=()=>e.onClick?.();return(()=>{var n=Ty(),r=n.firstChild;return n.$$keydown=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},n.$$click=c,je(e=>t=e,r),B(r,`width`,300),B(r,`height`,300),H(r,`width`,`150px`),H(r,`height`,`150px`),C(n,f(_,{get when(){return e.showLabel!==!1},get children(){var t=wy();return C(t,()=>e.room,null),C(t,f(_,{get when(){return e.onOverview},get children(){var t=Cy();return t.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),t.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),t.$$click=t=>{t.stopPropagation(),e.onOverview?.()},C(t,f(fr,{size:13})),S(()=>B(t,`title`,`Room overview — ${e.room}`)),t}}),null),t}}),null),S(()=>B(n,`title`,e.room+(e.shard?` · ${e.shard}`:``))),n})()}N([`click`,`keydown`]);function Ay(e){if(e==null||!Number.isFinite(e))return`0`;let t=Math.round(e),n=Math.abs(t);return n<1e4?String(t):n<1e6?`${(t/1e3).toPrecision(3)}K`:n<1e9?`${(t/1e6).toPrecision(3)}M`:`${(t/1e9).toPrecision(3)}B`}var jy=V(`<div style="flex:1;min-width:0;background:#161b22;border:1px solid #30363d;border-radius:6px;padding:14px 8px 12px;text-align:center"><div style=color:#8b949e;font-size:11px;text-transform:uppercase;line-height:1.3><br></div><div style=font-size:28px;font-weight:300;margin-top:8px>`),My=V(`<div style=display:flex;gap:10px>`),Ny=[{key:`energyControl`,l1:`Control`,l2:`points`,color:`#A7FFEB`},{key:`energyHarvested`,l1:`Energy`,l2:`harvested`,color:`#ffe56d`},{key:`energyConstruction`,l1:`Energy`,l2:`on construct`,color:`#eeeeee`},{key:`energyCreeps`,l1:`Energy`,l2:`on creeps`,color:`#eeeeee`},{key:`creepsProduced`,l1:`Creeps`,l2:`produced`,color:`#65fd62`},{key:`creepsLost`,l1:`Creeps`,l2:`lost`,color:`#f96e76`},{key:`powerProcessed`,l1:`Power`,l2:`processed`,color:`#E04040`}];function Py(e){return(()=>{var t=jy(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return C(n,()=>e.l1,r),C(n,()=>e.l2,null),C(i,()=>Ay(e.value)),S(t=>H(i,`color`,e.color)),t})()}function Fy(e){let t=e?.stats;if(!t)return null;let n={};for(let e of Ny){let r=t[e.key];r!=null&&(n[e.key]=Array.isArray(r)?r.reduce((e,t)=>e+(t?.value??0),0):Number(r)||0)}return n}function Iy(e){return(()=>{var t=My();return C(t,f(u,{each:Ny,children:t=>f(Py,{get l1(){return t.l1},get l2(){return t.l2},get color(){return t.color},get value(){return e.totals?.[t.key]}})})),t})()}function Ly(e){return e.shards?Object.entries(e.shards).flatMap(([e,t])=>(t??[]).map(t=>({room:t,shard:e}))):(e.rooms??[]).map(e=>({room:e,shard:null}))}var Ry=2.4,zy=1e6,By=1e3;function Vy(e){return Math.floor((e/zy)**(1/Ry))+1}function Hy(e){let t=Vy(e),n=(t-1)**Ry*zy,r=t**Ry*zy;return{level:t,current:e-n,total:r-n}}function Uy(e){return Math.floor((e/By)**(1/2))}function Wy(e){let t=Uy(e),n=t**2*By,r=(t+1)**2*By;return{level:t,current:e-n,total:r-n}}var Gy=[`operator`,`commander`,`executor`],Ky={operator:{name:`operator`,label:`Operator`,description:`A creep working mainly in the rear, at your base, though it can be used as a saboteur in offensive operations.`,underDevelopment:!1},commander:{name:`commander`,label:`Commander`,description:`This power creep is not very useful on its own, but it's a team player. It influences and affects regular creeps, both friendly and hostile.`,underDevelopment:!0},executor:{name:`executor`,label:`Executor`,description:`This creep class prefers working alone. Due to its skills, it's a very effective performer in your economy or as a war machine when defending or attacking.`,underDevelopment:!0}},qy={GENERATE_OPS:1,OPERATE_SPAWN:2,OPERATE_TOWER:3,OPERATE_STORAGE:4,OPERATE_LAB:5,OPERATE_EXTENSION:6,OPERATE_OBSERVER:7,OPERATE_TERMINAL:8,DISRUPT_SPAWN:9,DISRUPT_TOWER:10,DISRUPT_SOURCE:11,SHIELD:12,REGEN_SOURCE:13,REGEN_MINERAL:14,DISRUPT_TERMINAL:15,OPERATE_POWER:16,FORTIFY:17,OPERATE_CONTROLLER:18,OPERATE_FACTORY:19},Jy=[0,2,7,14,22],Yy=[10,11,12,14,22],Xy=[20,21,22,23,24],Zy=(e,t,n,r,i)=>[e,t,n,r,i],Qy=[{id:qy.GENERATE_OPS,name:`GENERATE_OPS`,className:`operator`,icon:Qi,reqLevel:Jy,values:Zy(`1`,`2`,`4`,`6`,`8`),effect:`Generate %s ops resource units.`,cooldown:50},{id:qy.OPERATE_SPAWN,name:`OPERATE_SPAWN`,className:`operator`,icon:Ei,reqLevel:Jy,values:Zy(`10%`,`30%`,`50%`,`65%`,`80%`),effect:`Reduce spawn time by %s.`,duration:1e3,cooldown:300,range:3,ops:100},{id:qy.OPERATE_TOWER,name:`OPERATE_TOWER`,className:`operator`,icon:Mr,reqLevel:Jy,values:Zy(`10%`,`20%`,`30%`,`40%`,`50%`),effect:`Increase damage, repair and heal amount by %s.`,duration:100,cooldown:10,range:3,ops:10},{id:qy.OPERATE_STORAGE,name:`OPERATE_STORAGE`,className:`operator`,icon:Pr,reqLevel:Jy,values:Zy(`500K`,`1M`,`2M`,`4M`,`7M`),effect:`Increase capacity by %s units.`,duration:1e3,cooldown:800,range:3,ops:100},{id:qy.OPERATE_LAB,name:`OPERATE_LAB`,className:`operator`,icon:Wr,reqLevel:Jy,values:Zy(`2`,`4`,`6`,`8`,`10`),effect:`Increase reaction amount by %s units.`,duration:1e3,cooldown:50,range:3,ops:10},{id:qy.OPERATE_EXTENSION,name:`OPERATE_EXTENSION`,className:`operator`,icon:or,reqLevel:Jy,values:Zy(`20%`,`40%`,`60%`,`80%`,`100%`),effect:`Instantly fill %s of all extensions in the room using energy from the target structure.`,cooldown:50,range:3,ops:2},{id:qy.OPERATE_OBSERVER,name:`OPERATE_OBSERVER`,className:`operator`,icon:Rr,reqLevel:Jy,values:Zy(`200`,`400`,`600`,`800`,`1000`),effect:`Grant unlimited range. Effect duration %s ticks.`,cooldown:400,range:3,ops:10},{id:qy.OPERATE_TERMINAL,name:`OPERATE_TERMINAL`,className:`operator`,icon:er,reqLevel:Jy,values:Zy(`10%`,`20%`,`30%`,`40%`,`50%`),effect:`Decrease transfer energy cost and cooldown by %s.`,duration:1e3,cooldown:500,range:3,ops:100},{id:qy.DISRUPT_SPAWN,name:`DISRUPT_SPAWN`,className:`operator`,icon:ir,reqLevel:Jy,values:Zy(`1`,`2`,`3`,`4`,`5`),effect:`Pause spawning process. Effect duration %s ticks.`,cooldown:5,range:20,ops:10},{id:qy.DISRUPT_TOWER,name:`DISRUPT_TOWER`,className:`operator`,icon:Xi,reqLevel:Jy,values:Zy(`10%`,`20%`,`30%`,`40%`,`50%`),effect:`Reduce effectiveness by %s.`,duration:5,cooldown:null,range:50,ops:10},{id:qy.DISRUPT_SOURCE,name:`DISRUPT_SOURCE`,className:`operator`,icon:Er,reqLevel:Jy,values:Zy(`100`,`200`,`300`,`400`,`500`),effect:`Pause energy regeneration. Effect duration %s ticks.`,cooldown:100,range:3,ops:100},{id:qy.SHIELD,name:`SHIELD`,className:`operator`,icon:Ii,reqLevel:Jy,values:Zy(`5K`,`10K`,`15K`,`20K`,`25K`),effect:`Create a temporary non-repairable rampart on the same square with %s hits. Cannot be used on top of another rampart.`,duration:50,cooldown:20},{id:qy.FORTIFY,name:`FORTIFY`,className:`operator`,icon:Pi,reqLevel:Jy,values:Zy(`1`,`2`,`3`,`4`,`5`),effect:`Make a wall or rampart tile invulnerable to all creep attacks and powers. Effect duration %s ticks.`,cooldown:5,range:3,ops:5},{id:qy.OPERATE_FACTORY,name:`OPERATE_FACTORY`,className:`operator`,icon:Br,reqLevel:Jy,values:Zy(`1`,`2`,`3`,`4`,`5`),effect:`Set the factory level to %s. Permanent and cannot be undone; re-apply to renew the effect.`,duration:1e3,cooldown:800,range:3,ops:100},{id:qy.REGEN_SOURCE,name:`REGEN_SOURCE`,className:`operator`,icon:Bi,reqLevel:Yy,values:Zy(`50`,`100`,`150`,`200`,`250`),effect:`Regenerate %s energy units in a source every 15 ticks.`,duration:300,cooldown:100,range:3},{id:qy.REGEN_MINERAL,name:`REGEN_MINERAL`,className:`operator`,icon:Kr,reqLevel:Yy,values:Zy(`2`,`4`,`6`,`8`,`10`),effect:`Regenerate %s mineral units in a deposit every 10 ticks.`,duration:100,cooldown:100,range:3},{id:qy.OPERATE_POWER,name:`OPERATE_POWER`,className:`operator`,icon:nr,reqLevel:Yy,values:Zy(`1`,`2`,`3`,`4`,`5`),effect:`Increase power processing speed of a Power Spawn by %s units per tick.`,duration:1e3,cooldown:800,range:3,ops:200},{id:qy.DISRUPT_TERMINAL,name:`DISRUPT_TERMINAL`,className:`operator`,icon:mi,reqLevel:Xy,values:Zy(``,``,``,``,``),effect:`Block withdrawing resources from the terminal.`,duration:10,cooldown:8,range:50,ops:[50,40,30,20,10]},{id:qy.OPERATE_CONTROLLER,name:`OPERATE_CONTROLLER`,className:`operator`,icon:Ki,reqLevel:Xy,values:Zy(`10`,`20`,`30`,`40`,`50`),effect:`Increase the max energy that can upgrade a Level 8 Controller each tick by %s units.`,duration:1e3,cooldown:800,range:3,ops:200}],$y=Object.fromEntries(Qy.map(e=>[e.id,e]));function eb(e){return Qy.filter(t=>t.className===e)}function tb(e,t){let n=e.values[Math.max(0,Math.min(4,t-1))];return e.effect.replace(`%s`,n)}function nb(e,t){let n=[],r=Array.isArray(e.ops)?e.ops[Math.max(0,Math.min(4,t-1))]:e.ops;return r!=null&&n.push(`ops ${r}`),e.duration!=null&&n.push(`dur ${e.duration}`),e.cooldown===null?n.push(`no cooldown`):e.cooldown!=null&&n.push(`cd ${e.cooldown}`),e.range!=null&&n.push(`rng ${e.range}`),n.join(` · `)}function rb(e){return e.level+1}function ib(e,t){return Uy(e??0)-t.reduce((e,t)=>e+rb(t),0)}var ab=V(`<svg><circle cx=12 cy=12 r=9.5></svg>`,!1,!0,!1),ob=V(`<svg><path d="M12 6.5 L17 16 L7 16 Z"stroke=none></svg>`,!1,!0,!1),sb=V(`<svg><path d="M5 8 L12 4 L19 8"></svg>`,!1,!0,!1),cb=V(`<svg><path d="M5 13 L12 9 L19 13"></svg>`,!1,!0,!1),lb=V(`<svg><path d="M5 18 L12 14 L19 18"></svg>`,!1,!0,!1),ub=V(`<svg><path d="M12 2.5 L15 9 L21.5 12 L15 15 L12 21.5 L9 15 L2.5 12 L9 9 Z"></svg>`,!1,!0,!1),db=V(`<svg viewBox="0 0 24 24"fill=none stroke-width=1.8 stroke-linecap=round stroke-linejoin=round style=display:block;flex-shrink:0>`);function fb(e){let t=()=>e.size??24,n=()=>e.color??`currentColor`;return(()=>{var r=db();return C(r,f(g,{get children(){return[f(d,{get when(){return e.class===`operator`},get children(){return[ab(),(()=>{var e=ob();return S(()=>B(e,`fill`,n())),e})()]}}),f(d,{get when(){return e.class===`commander`},get children(){return[sb(),cb(),lb()]}}),f(d,{get when(){return e.class===`executor`},get children(){return ub()}})]}})),S(e=>{var i=t(),a=t(),o=n();return i!==e.e&&B(r,`width`,e.e=i),a!==e.t&&B(r,`height`,e.t=a),o!==e.a&&B(r,`stroke`,e.a=o),e},{e:void 0,t:void 0,a:void 0}),r})()}var pb=`#161b22`,mb=`#1c2128`,hb=`#30363d`,gb=`#c9d1d9`,X=`#8b949e`,_b=`#58a6ff`,vb=`#238636`,yb=`#FF9A9A`,bb=`#E04040`,xb=V(`<button style="display:inline-flex;align-items:center;gap:6px;padding:8px 16px;border-radius:6px;border:none;font-size:13px;font-weight:600"> Create creep`),Sb=V(`<div style=display:flex;flex-wrap:wrap;gap:6px>`),Cb=V(`<div style=font-size:11px;color:#f0883e>Scheduled for deletion`),wb=V(`<button style=text-align:left;display:flex;flex-direction:column;gap:12px;width:220px;border-radius:8px;padding:16px;cursor:pointer><div style=display:flex;align-items:center;gap:10px><div style=min-width:0;flex:1><div style=font-size:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis></div><div style=font-size:12px> · Lvl `),Tb=V(`<div style=font-size:11px>No powers assigned`),Eb=V(`<span style=display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:5px>`),Db=V(`<div style=display:flex;align-items:center;margin-bottom:16px><div style=flex:1></div><a href=https://docs.screeps.com/power.html target=_blank rel=noopener style=color:#58a6ff;font-size:13px;text-decoration:none>Learn more`),Ob=V(`<div style=display:flex;flex-wrap:wrap;gap:16px>`),kb=V(`<div style=padding:32px;text-align:center>Loading…`),Ab=V(`<div style="border-radius:10px;padding:48px 24px;text-align:center"><div style=display:flex;justify-content:center;gap:28px;margin-bottom:24px></div><p style="font-size:15px;margin:0 0 6px;line-height:1.5">You have no Power Creeps yet.</p><p style="font-size:13px;margin:0 0 24px;line-height:1.5">You need 1 free Power Level in your account to create a new Power Creep.</p><div style=display:flex;align-items:center;justify-content:center;gap:16px><a href=https://docs.screeps.com/power.html target=_blank rel=noopener style=color:#58a6ff;font-size:13px;text-decoration:none>Learn more`);function jb(e){let t=()=>e.free>=1;return(()=>{var n=xb(),r=n.firstChild;return n.$$click=()=>t()&&e.onNew(),C(n,f(Si,{size:16}),r),S(e=>{var r=!t(),i=t()?`Create a new power creep`:`You need 1 free Power Level to create a power creep`,a=t()?vb:`#21262d`,o=t()?`#fff`:X,s=t()?`pointer`:`not-allowed`,c=t()?1:.7;return r!==e.e&&(n.disabled=e.e=r),i!==e.t&&B(n,`title`,e.t=i),a!==e.a&&H(n,`background`,e.a=a),o!==e.o&&H(n,`color`,e.o=o),s!==e.i&&H(n,`cursor`,e.i=s),c!==e.n&&H(n,`opacity`,e.n=c),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),n})()}function Mb(e){let t=()=>e.creep.className,n=()=>Ky[t()]??Ky.operator,r=()=>{let t=e.creep.powers??{};return Object.keys(t).filter(e=>(t[e]?.level??0)>0).map(e=>$y[Number(e)]).filter(Boolean)};return(()=>{var i=wb(),a=i.firstChild,o=a.firstChild,s=o.firstChild,c=s.nextSibling,l=c.firstChild;return i.$$click=()=>e.onSelect(e.creep._id),H(i,`background`,pb),H(i,`border`,`1px solid ${hb}`),H(i,`color`,gb),C(a,f(fb,{get class(){return t()},size:28,color:yb}),o),C(s,()=>e.creep.name),H(c,`color`,X),C(c,()=>n().label,l),C(c,()=>e.creep.level,null),C(i,f(_,{get when(){return r().length},get fallback(){return(()=>{var e=Tb();return H(e,`color`,X),e})()},get children(){var e=Sb();return C(e,f(u,{get each(){return r()},children:e=>(()=>{var t=Eb();return H(t,`background`,mb),H(t,`border`,`1px solid ${hb}`),C(t,f(de,{get component(){return e.icon},size:14,color:bb})),S(()=>B(t,`title`,e.name)),t})()})),e}}),null),C(i,f(_,{get when(){return e.creep.deleteTime},get children(){return Cb()}}),null),i})()}function Nb(e){let t=()=>e.ctx.creeps(),n=()=>(e.nav?.goToNew??kh)(),r=t=>(e.nav?.goToCreep??Ah)(t);return f(_,{get when(){return!e.loading},get fallback(){return(()=>{var e=kb();return H(e,`color`,X),e})()},get children(){return f(_,{get when(){return t().length},get fallback(){return(()=>{var t=Ab(),r=t.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling,s=o.firstChild;return H(t,`background`,pb),H(t,`border`,`1px solid ${hb}`),C(r,f(u,{each:Gy,children:e=>f(fb,{class:e,size:44,color:e===`operator`?yb:hb})})),H(i,`color`,gb),H(a,`color`,X),C(o,f(jb,{get free(){return e.ctx.free()},onNew:n}),s),t})()},get children(){return[(()=>{var t=Db(),r=t.firstChild;return r.nextSibling,C(t,f(jb,{get free(){return e.ctx.free()},onNew:n}),r),t})(),(()=>{var e=Ob();return C(e,f(u,{get each(){return t()},children:e=>f(Mb,{creep:e,onSelect:r})})),e})()]}})}})}N([`click`]);var Pb=V(`<span style=font-size:10px;margin-left:4px>unlocks at Lvl `),Fb=V(`<div style="border-radius:8px;padding:12px 14px;display:flex;flex-direction:column;gap:8px"><div style=display:flex;align-items:center;gap:8px><span style=font-size:12px;font-weight:600;letter-spacing:0.02em;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis></span><span style=font-size:11px>Lv </span></div><div style=display:flex;align-items:center;gap:5px></div><div style=font-size:11px;line-height:1.4></div><div style=font-size:10px>`),Ib=V(`<button style=width:14px;height:14px;border-radius:50%;padding:0;flex-shrink:0;display:flex;align-items:center;justify-content:center>`);function Lb(e){let t=()=>e.stagedLevel??e.currentLevel,n=()=>Math.max(1,t()),r=()=>t()===0,i=()=>t()+1,a=n=>n<=e.currentLevel?`saved`:n<=t()?`staged`:n===i()&&e.editable?e.canIncrement?`next`:`locked`:`empty`;return(()=>{var o=Fb(),s=o.firstChild,c=s.firstChild,l=c.nextSibling;l.firstChild;var d=s.nextSibling,p=d.nextSibling,m=p.nextSibling;return H(o,`background`,mb),H(o,`border`,`1px solid ${hb}`),C(s,f(de,{get component(){return e.def.icon},size:16,get color(){return t()>0?bb:X}}),c),H(c,`color`,gb),C(c,()=>e.def.name),C(l,t,null),C(d,f(u,{each:[1,2,3,4,5],children:t=>{let n=()=>a(t),r=()=>n()===`next`;return(()=>{var i=Ib();return i.$$click=()=>r()&&e.onIncrement?.(),C(i,f(_,{get when(){return n()===`locked`},get children(){return f(ni,{size:8,color:X})}})),S(a=>{var o=!r(),s=n()===`locked`&&e.lockLevel!=null?`Unlocks at creep Lvl ${e.lockLevel}`:r()?`Upgrade to Lv ${t}`:void 0,c=r()?`pointer`:`default`,l=n()===`saved`?bb:n()===`staged`?_b:`transparent`,u=n()===`next`?`1px solid ${_b}`:n()===`locked`?`1px dashed ${hb}`:n()===`saved`||n()===`staged`?`none`:`1px solid ${hb}`;return o!==a.e&&(i.disabled=a.e=o),s!==a.t&&B(i,`title`,a.t=s),c!==a.a&&H(i,`cursor`,a.a=c),l!==a.o&&H(i,`background`,a.o=l),u!==a.i&&H(i,`border`,a.i=u),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),i})()}}),null),C(d,f(_,{get when(){return R(()=>!!(e.editable&&i()<=5&&!e.canIncrement))()&&e.lockLevel!=null},get children(){var t=Pb();return t.firstChild,H(t,`color`,X),C(t,()=>e.lockLevel,null),t}}),null),C(p,()=>tb(e.def,n())),H(m,`color`,X),C(m,()=>nb(e.def,n())),S(e=>{var n=t()>0?gb:X,i=r()?X:gb;return n!==e.e&&H(l,`color`,e.e=n),i!==e.t&&H(p,`color`,e.t=i),e},{e:void 0,t:void 0}),o})()}N([`click`]);var Rb=V(`<div style=font-size:13px;margin-top:8px;line-height:1.5>`),zb=V(`<button style="padding:8px 22px;border-radius:6px;background:transparent;font-size:14px;cursor:pointer">`),Bb=V(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:300;display:flex;align-items:center;justify-content:center><div style="border-radius:10px;padding:24px;max-width:440px;text-align:center;box-shadow:0 8px 24px rgba(0,0,0,0.5)"><div style=font-size:16px;font-weight:600;line-height:1.4></div><div style=display:flex;gap:10px;justify-content:center;margin-top:20px><button style="padding:8px 22px;border-radius:6px;border:none;color:#fff;font-size:14px;font-weight:600;cursor:pointer">`);function Vb(e){i(()=>{let t=t=>{t.key===`Escape`?e.onCancel():t.key===`Enter`&&e.onConfirm()};window.addEventListener(`keydown`,t),n(()=>window.removeEventListener(`keydown`,t))});let t=t=>{t.target===t.currentTarget&&e.onCancel()};return(()=>{var n=Bb(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.firstChild;return n.$$click=t,H(r,`background`,pb),H(r,`border`,`1px solid ${hb}`),H(i,`color`,gb),C(i,()=>e.title),C(r,f(_,{get when(){return e.body},get children(){var t=Rb();return H(t,`color`,X),C(t,()=>e.body),t}}),a),o.$$click=()=>e.onConfirm(),H(o,`background`,_b),C(o,()=>e.confirmLabel??(e.notice?`Close`:`Yes`)),C(a,f(_,{get when(){return!e.notice},get children(){var t=zb();return t.$$click=()=>e.onCancel(),H(t,`border`,`1px solid ${hb}`),H(t,`color`,gb),C(t,()=>e.cancelLabel??`No`),t}}),null),n})()}N([`click`]);var Hb=V(`<div style=border-radius:8px;padding:32px;text-align:center>Power creep not found. <a style=cursor:pointer>Back to list`),Ub=V(`<div style=display:flex;align-items:center;gap:6px><input maxlength=50 style="padding:4px 8px;border-radius:4px;background:#0d1117;font-size:15px;outline:none"><button title="Save name"style=background:transparent;border:none;cursor:pointer></button><button title=Cancel style=background:transparent;border:none;cursor:pointer>`),Wb=V(`<span> → `),Gb=V(`<div style=margin-top:2px> staged`),Kb=V(`<button style="background:transparent;border:1px solid #f0883e;border-radius:6px;color:#f0883e;cursor:pointer;padding:7px 10px;font-size:12px">Cancel deletion`),qb=V(`<div style="background:#21262d;border-radius:6px;padding:8px 12px;font-size:12px;color:#f0883e;margin-bottom:16px">You have reached the maximum creep level (<!>).`),Jb=V(`<div><button style="display:inline-flex;align-items:center;gap:4px;padding:6px 10px;border-radius:4px;background:transparent;font-size:13px;cursor:pointer;margin-bottom:16px"> Back</button><div style="display:flex;align-items:center;gap:14px;border-radius:10px;padding:18px 20px;margin-bottom:16px"><div style=flex:1;min-width:0><div style=font-size:13px;margin-top:2px> · Level <strong></strong></div></div><div style=text-align:right;font-size:12px><div>Free GPL <strong></strong> / </div></div></div><div style="display:grid;grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));gap:12px"></div><div style=display:flex;justify-content:flex-end;gap:10px;margin-top:20px><button style="padding:9px 18px;border-radius:6px;background:transparent;font-size:14px">Reset</button><button style="padding:9px 20px;border-radius:6px;border:none;font-size:14px;font-weight:600">`),Yb=V(`<div style=display:flex;align-items:center;gap:8px><span style=font-size:18px;font-weight:600></span><button title=Rename style=background:transparent;border:none;cursor:pointer;padding:2px>`),Xb=V(`<button title="Delete power creep"style="background:transparent;border-radius:6px;color:#f85149;cursor:pointer;padding:7px 9px;display:flex">`),Zb=V(`<strong> GPL`),Qb=V(`<strong>1 Power Level`);function $b(e){let t=()=>e.ctx.creeps().find(t=>t._id===e.id)??null,n=()=>t()?.className??`operator`,r=()=>(e.nav?.goToList??Oh)(),i=()=>eb(n()),[o,s]=a({}),[c,l]=a(!1),[d,p]=a(!1),[m,h]=a(!1),[g,v]=a(!1),[y,b]=a(!1),[x,w]=a(!1),[T,E]=a(``),D=e=>t()?.powers?.[e]?.level??0,O=e=>o()[e]??D(e),k=()=>{let e=0;for(let t of i())e+=O(t.id)-D(t.id);return e},j=()=>(t()?.level??0)+k(),ee=()=>e.ctx.free()-k(),M=()=>k()>0,te=e=>{let t=O(e.id);return t<5&&j()<25&&ee()>=1&&j()>=e.reqLevel[t]},ne=e=>{let t=O(e.id);return t<5&&j()<e.reqLevel[t]?e.reqLevel[t]:void 0},re=e=>{if(j()>=25){b(!0);return}te(e)&&s({...o(),[e.id]:O(e.id)+1})},ie=async()=>{let n=z(),r=t();if(p(!1),!(!n||!r)){l(!0);try{let t={};for(let e of i()){let n=O(e.id);n>0&&(t[e.id]=n)}await n.http.game.powerCreeps.upgrade(r._id,t),await e.ctx.reload(),await n.stores.user.refreshMe().catch(()=>{}),s({}),A(`Power creep upgraded`,`success`,3e3)}catch(e){A(`Upgrade failed: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}finally{l(!1)}}},ae=async()=>{let n=z(),r=t(),i=T().trim();if(w(!1),!(!n||!r||!i||i===r.name))try{await n.http.game.powerCreeps.rename(r._id,i),await e.ctx.reload()}catch(e){A(`Rename failed: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}},oe=async()=>{let n=z(),i=t();if(v(!1),!(!n||!i))try{await n.http.game.powerCreeps.delete(i._id),await e.ctx.reload(),A(`Power creep "${i.name}" deleted`,`success`,3e3),r()}catch(e){A(`Delete failed: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}},N=async()=>{let n=z(),r=t();if(!(!n||!r))try{await n.http.game.powerCreeps.cancelDelete(r._id),await e.ctx.reload()}catch(e){A(`Failed to cancel deletion: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}};return f(_,{get when(){return t()},get fallback(){return(()=>{var e=Hb(),t=e.firstChild.nextSibling;return H(e,`background`,pb),H(e,`border`,`1px solid ${hb}`),H(e,`color`,X),t.$$click=r,H(t,`color`,_b),e})()},children:t=>(()=>{var a=Jb(),o=a.firstChild,l=o.firstChild,A=o.nextSibling,P=A.firstChild,F=P.firstChild,se=F.firstChild,ce=se.nextSibling,le=P.nextSibling,ue=le.firstChild,de=ue.firstChild.nextSibling;de.nextSibling;var fe=A.nextSibling,I=fe.nextSibling.firstChild,pe=I.nextSibling;return o.$$click=r,H(o,`border`,`1px solid ${hb}`),H(o,`color`,X),C(o,f(br,{size:16}),l),H(A,`background`,pb),H(A,`border`,`1px solid ${hb}`),C(A,f(fb,{get class(){return n()},size:44,color:yb}),P),C(P,f(_,{get when(){return x()},get fallback(){return(()=>{var e=Yb(),n=e.firstChild,r=n.nextSibling;return H(n,`color`,gb),C(n,()=>t().name),r.$$click=()=>{E(t().name),w(!0)},H(r,`color`,X),C(r,f(vi,{size:14})),e})()},get children(){var e=Ub(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling;return t.$$keydown=e=>{e.key===`Enter`&&ae(),e.key===`Escape`&&w(!1)},t.$$input=e=>E(e.currentTarget.value),H(t,`border`,`1px solid ${hb}`),H(t,`color`,gb),n.$$click=()=>void ae(),H(n,`color`,vb),C(n,f(mr,{size:16})),r.$$click=()=>w(!1),H(r,`color`,X),C(r,f(Ji,{size:16})),S(()=>t.value=T()),e}}),F),H(F,`color`,X),C(F,()=>Ky[n()].label,se),H(ce,`color`,gb),C(ce,()=>t().level),C(F,f(_,{get when(){return M()},get children(){var e=Wb();return e.firstChild,H(e,`color`,_b),C(e,j,null),e}}),null),H(le,`color`,X),C(de,()=>Math.max(0,ee())),C(ue,()=>e.ctx.gpl(),null),C(le,f(_,{get when(){return M()},get children(){var e=Gb(),t=e.firstChild;return H(e,`color`,_b),C(e,k,t),e}}),null),C(A,f(_,{get when(){return t().deleteTime},get fallback(){return(()=>{var e=Xb();return e.$$click=()=>v(!0),H(e,`border`,`1px solid ${hb}`),C(e,f(Wi,{size:16})),e})()},get children(){var e=Kb();return e.$$click=()=>void N(),e}}),null),C(a,f(_,{get when(){return j()>=25},get children(){var e=qb(),t=e.firstChild.nextSibling;return t.nextSibling,H(e,`border`,`1px solid ${hb}`),C(e,25,t),e}}),fe),C(fe,f(u,{get each(){return i()},children:e=>f(Lb,{def:e,get currentLevel(){return D(e.id)},get stagedLevel(){return O(e.id)},editable:!0,get canIncrement(){return te(e)},get lockLevel(){return ne(e)},onIncrement:()=>re(e)})})),I.$$click=()=>h(!0),H(I,`border`,`1px solid ${hb}`),pe.$$click=()=>p(!0),C(pe,()=>c()?`Saving…`:`Save changes`),C(a,f(_,{get when(){return d()},get children(){return f(Vb,{title:`This action cannot be undone without deleting the creep.`,get body(){return[`Do you want to proceed and use `,(()=>{var e=Zb(),t=e.firstChild;return H(e,`color`,yb),C(e,()=>j()+1,t),e})(),` for this creep?`]},onConfirm:()=>void ie(),onCancel:()=>p(!1)})}}),null),C(a,f(_,{get when(){return m()},get children(){return f(Vb,{title:`Do you really want to reset all changes?`,onConfirm:()=>{s({}),h(!1)},onCancel:()=>h(!1)})}}),null),C(a,f(_,{get when(){return g()},get children(){return f(Vb,{get title(){return`Do you really want to delete "${t().name}"?`},get body(){return[`You will lose `,(()=>{var e=Qb();return H(e,`color`,bb),e})(),` in your account. The creep's upgrade levels are returned, but the creation level is gone for good.`]},confirmLabel:`Delete`,onConfirm:()=>void oe(),onCancel:()=>v(!1)})}}),null),C(a,f(_,{get when(){return y()},get children(){return f(Vb,{title:`You have reached the maximum creep level`,notice:!0,onConfirm:()=>b(!1),onCancel:()=>b(!1)})}}),null),S(e=>{var t=ee()>0?yb:X,n=!M()||c(),r=M()?gb:X,i=M()?`pointer`:`not-allowed`,a=M()?1:.6,o=!M()||c(),s=M()?vb:`#21262d`,l=M()?`#fff`:X,u=M()?`pointer`:`not-allowed`,d=M()?1:.7;return t!==e.e&&H(de,`color`,e.e=t),n!==e.t&&(I.disabled=e.t=n),r!==e.a&&H(I,`color`,e.a=r),i!==e.o&&H(I,`cursor`,e.o=i),a!==e.i&&H(I,`opacity`,e.i=a),o!==e.n&&(pe.disabled=e.n=o),s!==e.s&&H(pe,`background`,e.s=s),l!==e.h&&H(pe,`color`,e.h=l),u!==e.r&&H(pe,`cursor`,e.r=u),d!==e.d&&H(pe,`opacity`,e.d=d),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),a})()})}N([`click`,`input`,`keydown`]);var ex=V(`<span style=color:#f0883e> (Under development)`),tx=V(`<div style=font-size:11px;text-transform:uppercase;letter-spacing:0.06em;font-weight:700;margin-bottom:12px> powers`),nx=V(`<div style="display:grid;grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));gap:12px">`),rx=V(`<div><div style=display:flex;align-items:center;justify-content:space-between;margin-bottom:20px><button style="display:inline-flex;align-items:center;gap:4px;padding:6px 10px;border-radius:4px;background:transparent;font-size:13px;cursor:pointer"> Back</button><span style=font-size:13px>Creating a power creep uses <strong>1</strong> free Power Level</span></div><div style=border-radius:10px;padding:24px><label style=display:block;font-size:11px;text-transform:uppercase;letter-spacing:0.06em;font-weight:700;margin-bottom:8px>Creep name</label><input placeholder="Enter creep name"maxlength=50 style="width:100%;box-sizing:border-box;padding:9px 12px;border-radius:6px;background:#0d1117;font-size:14px;outline:none;margin-bottom:24px"><div style=font-size:11px;text-transform:uppercase;letter-spacing:0.06em;font-weight:700;margin-bottom:10px>Select class</div><div style=display:flex;gap:12px;margin-bottom:14px></div><p style="font-size:13px;line-height:1.5;margin:0 0 24px"></p></div><div style=display:flex;justify-content:flex-end;margin-top:16px><button style="padding:9px 20px;border-radius:6px;border:none;font-size:14px;font-weight:600">`),ix=V(`<span style=font-size:10px;color:#f0883e>Under development`),ax=V(`<button style="flex:1;display:flex;flex-direction:column;align-items:center;gap:8px;padding:16px 8px;border-radius:8px;cursor:pointer"><span style=font-size:13px;font-weight:600>`),ox=V(`<div style="font-size:13px;text-align:center;padding:24px 0">This class has no powers available yet.`);function sx(e){let[t,n]=a(``),[r,i]=a(`operator`),[o,s]=a(!1),c=()=>Ky[r()],l=()=>!o()&&e.ctx.free()>=1&&t().trim().length>0&&!c().underDevelopment,d=()=>(e.nav?.goToList??Oh)(),p=async()=>{let n=z();if(!n||!l())return;let i=t().trim();s(!0);try{await n.http.game.powerCreeps.create(i,r()),await e.ctx.reload();let t=e.ctx.creeps().find(e=>e.name===i);A(`Power creep "${i}" created`,`success`,3e3),t?(e.nav?.goToCreep??Ah)(t._id):d()}catch(e){A(`Failed to create power creep: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}finally{s(!1)}};return(()=>{var a=rx(),s=a.firstChild,m=s.firstChild,h=m.firstChild,g=m.nextSibling,v=g.firstChild.nextSibling,y=s.nextSibling,b=y.firstChild,x=b.nextSibling,w=x.nextSibling,T=w.nextSibling,E=T.nextSibling,D=y.nextSibling.firstChild;return m.$$click=d,H(m,`border`,`1px solid ${hb}`),H(m,`color`,X),C(m,f(br,{size:16}),h),H(g,`color`,X),H(v,`color`,yb),H(y,`background`,pb),H(y,`border`,`1px solid ${hb}`),H(b,`color`,X),x.$$input=e=>n(e.currentTarget.value),H(x,`border`,`1px solid ${hb}`),H(x,`color`,gb),H(w,`color`,X),C(T,f(u,{each:Gy,children:e=>{let t=Ky[e],n=()=>r()===e;return(()=>{var r=ax(),a=r.firstChild;return r.$$click=()=>i(e),C(r,f(fb,{class:e,size:36,get color(){return n()?yb:X}}),a),C(a,()=>t.label),C(r,f(_,{get when(){return t.underDevelopment},get children(){return ix()}}),null),S(e=>{var t=`1px solid ${n()?_b:hb}`,i=n()?`#1c2d47`:mb,a=n()?gb:X;return t!==e.e&&H(r,`border`,e.e=t),i!==e.t&&H(r,`background`,e.t=i),a!==e.a&&H(r,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),r})()}})),H(E,`color`,X),C(E,()=>c().description,null),C(E,f(_,{get when(){return c().underDevelopment},get children(){return ex()}}),null),C(y,f(_,{get when(){return!c().underDevelopment},get fallback(){return(()=>{var e=ox();return H(e,`color`,X),e})()},get children(){return[(()=>{var e=tx(),t=e.firstChild;return H(e,`color`,X),C(e,()=>c().label,t),e})(),(()=>{var e=nx();return C(e,f(u,{get each(){return eb(r())},children:e=>f(Lb,{def:e,currentLevel:0})})),e})()]}}),null),D.$$click=p,C(D,()=>o()?`Creating…`:`Create creep`),S(t=>{var n=!l(),r=e.ctx.free()<1?`You need 1 free Power Level`:void 0,i=l()?vb:`#21262d`,a=l()?`#fff`:X,o=l()?`pointer`:`not-allowed`,s=l()?1:.7;return n!==t.e&&(D.disabled=t.e=n),r!==t.t&&B(D,`title`,t.t=r),i!==t.a&&H(D,`background`,t.a=i),a!==t.o&&H(D,`color`,t.o=a),o!==t.i&&H(D,`cursor`,t.i=o),s!==t.n&&H(D,`opacity`,t.n=s),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),S(()=>x.value=t()),a})()}N([`click`,`input`]);var cx=V(`<button title=Messages style="display:flex;align-items:center;padding:7px;border-radius:4px;cursor:pointer;border:1px solid #30363d;background:#21262d;color:#c9d1d9">`),lx=V(`<div style="display:flex;align-items:center;gap:10px;padding:0 0 14px;border-bottom:1px solid #30363d;margin-bottom:24px"><h1 style=margin:0;font-size:22px;font-weight:600;color:#c9d1d9></h1><div style=flex:1></div><button style=display:flex;align-items:center;padding:7px;border-radius:4px;cursor:pointer></button><button title=Close style="display:flex;align-items:center;padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer">`),ux=V(`<div style=display:flex;gap:16px;margin-bottom:16px><div><div><div style=font-size:16px;font-weight:600;color:#c9d1d9;margin-bottom:6px>Global Control Level</div><div style=color:#8b949e;font-size:13px><span>Rooms: <strong style=color:#c9d1d9></strong></span><span style=margin-left:14px>CPU: <strong style=color:#c9d1d9></strong></span></div></div></div><div><div><div style=font-size:16px;font-weight:600;color:#c9d1d9;margin-bottom:8px>Global Power Level</div><button title="Manage your power creeps"style="padding:5px 10px;border-radius:4px;border:1px solid #C54444;background:#21262d;color:#ffb7ba;font-size:12px;cursor:pointer">Manage Power Creeps`),dx=V(`<div style=margin-top:24px><div style=color:#8b949e;font-size:11px;text-transform:uppercase;margin-bottom:12px>Rooms`),fx=V(`<div style=color:#c9d1d9;font-size:13px;font-weight:600;margin-bottom:10px>`),px=V(`<div style=margin-bottom:20px><div style=display:flex;flex-wrap:wrap;gap:16px>`),mx=6e4,hx=8,gx=`#161b22`,_x=`#30363d`,vx=`#c9d1d9`,yx=`#8b949e`;function bx(){let[e,t]=a(null),[r,o]=a([]),c=!1;s(()=>{let e=z(),t=U()?._id;!e||!t||c||(c=!0,e.http.user.rooms(t).then(e=>o(Ly(e))).catch(()=>{c=!1}))}),i(()=>{let e=z();if(!e)return;let r=null,i=()=>e.http.user.overview(hx,`energyHarvested`).then(e=>t(e.totals??null));i().then(()=>{r=setInterval(()=>{e.stores.user.refreshMe().catch(()=>{}),i().catch(()=>{})},mx)}).catch(()=>{}),n(()=>{r&&clearInterval(r)})});let l=()=>Hy(U()?.gcl??0),p=()=>Wy(U()?.power??0),m=e=>e.total>0?e.current/e.total:0,h=e=>`Next level: ${Math.floor(e.current).toLocaleString()} / ${Math.floor(e.total).toLocaleString()}`,v={flex:1,display:`flex`,"align-items":`center`,gap:`16px`,background:gx,border:`1px solid ${_x}`,"border-radius":`6px`,padding:`16px`},[y,b]=a([]),[x,w]=a(!1),T=async()=>{let e=z();e&&b((await e.http.game.powerCreeps.list()).list??[])};s(()=>{rh()===`power`&&(w(!0),T().finally(()=>w(!1)),z()?.stores.user.refreshMe().catch(()=>{}))});let E=()=>rh()===`power`?Th():Oh(),D=()=>{let e=new Map;for(let t of r()){let n=e.get(t.shard);n?n.push(t):e.set(t.shard,[t])}return[...e.entries()].sort(([e],[t])=>(e??``).localeCompare(t??``))},O={creeps:y,free:()=>ib(U()?.power,y()),gpl:()=>Uy(U()?.power??0),reload:T},k={goToList:Oh,goToNew:kh,goToCreep:Ah},A=()=>rh()===`power`?`Power Creeps`:`Overview`;return f(jv,{get children(){return[(()=>{var e=lx(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling,i=r.nextSibling;return C(e,f(Sy,{get badge(){return U()?.badge},size:28}),t),C(t,A),C(e,f(Hh,{get username(){return U()?.username},color:yx,style:{"font-size":`14px`}}),n),C(e,f(_,{get when(){return my().hasMessaging},get children(){var e=cx();return I(e,`click`,Eh,!0),C(e,f(ci,{size:16})),e}}),r),r.$$click=E,C(r,f(Qi,{size:16})),I(i,`click`,Rh,!0),C(i,f(Ji,{size:16})),S(e=>{var t=rh()===`power`?`Back to Overview`:`Manage Power Creeps`,n=rh()===`power`?`1px solid #C54444`:`1px solid ${_x}`,i=rh()===`power`?`#2d1a1a`:`#21262d`,a=rh()===`power`?`#ffb7ba`:vx;return t!==e.e&&B(r,`title`,e.e=t),n!==e.t&&H(r,`border`,e.t=n),i!==e.a&&H(r,`background`,e.a=i),a!==e.o&&H(r,`color`,e.o=a),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e})(),f(g,{get children(){return[f(d,{get when(){return rh()===`power`},get children(){return f(g,{get children(){return[f(d,{get when(){return _h()===`list`},get children(){return f(Nb,{ctx:O,get loading(){return x()},nav:k})}}),f(d,{get when(){return _h()===`new`},get children(){return f(sx,{ctx:O,nav:k})}}),f(d,{get when(){return _h()===`detail`},get children(){return f($b,{ctx:O,get id(){return yh()},nav:k})}})]}})}}),f(d,{get when(){return rh()===`overview`},get children(){return[(()=>{var e=ux(),t=e.firstChild,n=t.firstChild,r=n.firstChild.nextSibling.firstChild,i=r.firstChild.nextSibling,a=r.nextSibling.firstChild.nextSibling,o=t.nextSibling,s=o.firstChild,c=s.firstChild.nextSibling;return C(t,f(by,{get value(){return l().level},label:`GCL`,ring:gy,text:_y,get fraction(){return m(l())},get tooltip(){return h(l())}}),n),C(i,()=>l().level),C(a,()=>U()?.cpu??`—`),C(o,f(by,{get value(){return p().level},label:`GPL`,ring:vy,text:yy,get fraction(){return m(p())},get tooltip(){return h(p())}}),s),c.$$click=E,S(e=>{var n=v,r=v;return e.e=L(t,n,e.e),e.t=L(o,r,e.t),e},{e:void 0,t:void 0}),e})(),f(Iy,{get totals(){return e()}}),f(_,{get when(){return r().length},get children(){var e=dx();return e.firstChild,C(e,f(u,{get each(){return D()},children:([e,t])=>(()=>{var n=px(),r=n.firstChild;return C(n,f(_,{when:e,get children(){var t=fx();return C(t,e),t}}),r),C(r,f(u,{each:t,children:e=>f(ky,{get room(){return e.room},get shard(){return e.shard},onClick:()=>zh(e.room,e.shard),onOverview:()=>Lh(e.room,e.shard)})})),n})()}),null),e}})]}})]}})]}})}N([`click`]);var xx=V(`<div style="display:flex;align-items:baseline;gap:6px;flex-shrink:0;padding:5px 12px;border-radius:8px"><span style=font-size:11px;font-weight:600;letter-spacing:0.5px></span><span style=font-size:18px;font-weight:700;line-height:1>`),Sx=V(`<div style="flex:1;min-width:0;background:#161b22;border-radius:6px;padding:12px 8px;text-align:center"><div style=font-size:11px;text-transform:uppercase;line-height:1.3><br></div><div style=font-size:22px;font-weight:300;margin-top:8px>`),Cx=V(`<div style=color:#8b949e;text-align:center;padding:60px>Loading…`),wx=V(`<div style=text-align:center;padding:60px><div style=color:#8b949e;font-size:18px;margin-bottom:16px>User not found</div><button style="padding:7px 12px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer">Back to the world`),Tx=V(`<span title="Your account overview"style=color:#8b949e;cursor:pointer;font-size:13px>Overview`),Ex=V(`<button style="display:flex;align-items:center;gap:6px;padding:7px 12px;border-radius:4px;border:1px solid #388bfd;background:#1f3158;color:#58a6ff;cursor:pointer;font-size:13px;margin-left:6px"> Message`),Dx=V(`<div style="display:flex;align-items:center;gap:10px;padding:0 0 14px;border-bottom:1px solid #30363d;margin-bottom:24px"><h1 style=margin:0;font-size:22px;font-weight:600;color:#c9d1d9></h1><div style=flex:1></div><button title=Close style="display:flex;align-items:center;padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer;margin-left:6px">`),Ox=V(`<div style=color:#8b949e;font-size:11px;text-transform:uppercase;margin-bottom:10px>Current month`),kx=V(`<div style=display:flex;gap:10px;margin-bottom:24px>`),Ax=V(`<select style="padding:4px 8px;border-radius:4px;border:1px solid #30363d;background:#161b22;color:#8b949e;font-size:11px;text-transform:uppercase;cursor:pointer;margin-bottom:10px">`),jx=V(`<div style=margin-top:24px><div style=color:#8b949e;font-size:11px;text-transform:uppercase;margin-bottom:12px>Rooms</div><div style=display:flex;flex-wrap:wrap;gap:16px>`),Mx=V(`<option>`),Nx=`#8b949e`,Px=`#d9b54a`,Fx=`#C54444`,Ix=[{value:8,label:`Last 1 hour`},{value:180,label:`Last 24 hours`},{value:1440,label:`Last 7 days`}];function Lx(){let e=new Date;return`${e.getUTCFullYear()}-${String(e.getUTCMonth()+1).padStart(2,`0`)}`}function Rx(e){let t=e?.list?.[0]??e;return{rank:typeof t?.rank==`number`?t.rank:null,score:typeof t?.score==`number`?t.score:0}}var zx=e=>e==null?`—`:`#${(e+1).toLocaleString()}`,Bx=e=>e.toLocaleString();function Vx(e){return(()=>{var t=xx(),n=t.firstChild,r=n.nextSibling;return C(n,()=>e.label),C(r,()=>e.value),S(i=>{var a=e.tooltip,o=`2px solid ${e.border}`,s=e.color,c=e.color;return a!==i.e&&B(t,`title`,i.e=a),o!==i.t&&H(t,`border`,i.t=o),s!==i.a&&H(n,`color`,i.a=s),c!==i.o&&H(r,`color`,i.o=c),i},{e:void 0,t:void 0,a:void 0,o:void 0}),t})()}function Hx(e){return(()=>{var t=Sx(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return C(n,()=>e.l1,r),C(n,()=>e.l2,null),C(i,()=>e.value),S(r=>{var a=`1px solid ${e.accent}`,o=e.accent,s=e.accent;return a!==r.e&&H(t,`border`,r.e=a),o!==r.t&&H(n,`color`,r.t=o),s!==r.a&&H(i,`color`,r.a=s),r},{e:void 0,t:void 0,a:void 0}),t})()}function Ux(){let[e]=c(()=>ah(),async e=>{let t=z();if(!t)return null;try{return(await t.http.user.find({username:e})).user??null}catch{return null}}),t=()=>e()?._id,[n]=c(t,async e=>{let t=z();if(!t)return[];try{return Ly(await t.http.user.rooms(e))}catch{return[]}}),[r,i]=a(1440),[o]=c(()=>{let e=t();return e?{id:e,interval:r()}:null},async({id:e,interval:t})=>{let n=z();if(!n)return null;try{return Fy(await n.http.user.stats(t,e))}catch{return null}}),[s]=c(()=>e()?e().username:void 0,async e=>{let t=z();if(!t)return null;let n=Lx(),[r,i]=await Promise.all([t.http.leaderboard.find(e,`world`,n).catch(()=>null),t.http.leaderboard.find(e,`power`,n).catch(()=>null)]);return{world:Rx(r),power:Rx(i)}}),l=()=>{let t=U()?.username?.toLowerCase(),n=e()?.username?.toLowerCase();return!!t&&t===n},d=()=>Hy(e()?.gcl??0),p=()=>Wy(e()?.power??0),m=e=>`Next level: ${Math.floor(e.current).toLocaleString()} / ${Math.floor(e.total).toLocaleString()}`;return f(jv,{get children(){return f(_,{get when(){return!e.loading},get fallback(){return Cx()},get children(){return f(_,{get when(){return e()},get fallback(){return(()=>{var e=wx(),t=e.firstChild.nextSibling;return I(t,`click`,Rh,!0),e})()},children:e=>[(()=>{var t=Dx(),n=t.firstChild,r=n.nextSibling,i=r.nextSibling;return C(t,f(Sy,{get badge(){return e().badge},size:28}),n),C(n,()=>e().username),C(t,f(_,{get when(){return l()},get children(){var e=Tx();return e.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=Nx),e.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),I(e,`click`,Th,!0),e}}),r),C(t,f(Vx,{label:`GCL`,get value(){return d().level},color:_y,border:gy,get tooltip(){return m(d())}}),i),C(t,f(Vx,{label:`GPL`,get value(){return p().level},color:yy,border:vy,get tooltip(){return m(p())}}),i),C(t,f(_,{get when(){return R(()=>!l())()&&my().hasMessaging},get children(){var t=Ex(),n=t.firstChild;return t.$$click=()=>Dh(e().username),C(t,f(ci,{size:14}),n),S(()=>B(t,`title`,`Message ${e().username}`)),t}}),i),I(i,`click`,Rh,!0),C(i,f(Ji,{size:16})),t})(),Ox(),(()=>{var e=kx();return C(e,f(Hx,{l1:`Expansion`,l2:`rank`,accent:Px,get value(){return zx(s()?.world.rank??null)}}),null),C(e,f(Hx,{l1:`Control`,l2:`points`,accent:Px,get value(){return Bx(s()?.world.score??0)}}),null),C(e,f(Hx,{l1:`Power`,l2:`rank`,accent:Fx,get value(){return zx(s()?.power.rank??null)}}),null),C(e,f(Hx,{l1:`Power`,l2:`points`,accent:Fx,get value(){return Bx(s()?.power.score??0)}}),null),e})(),(()=>{var e=Ax();return e.addEventListener(`change`,e=>i(Number(e.currentTarget.value))),C(e,f(u,{each:Ix,children:e=>(()=>{var t=Mx();return C(t,()=>e.label),S(()=>t.value=e.value),t})()})),S(()=>e.value=r()),e})(),f(Iy,{get totals(){return o()}}),f(_,{get when(){return n()?.length},get children(){var t=jx(),r=t.firstChild.nextSibling;return C(r,f(u,{get each(){return n()},children:t=>f(ky,{get room(){return t.room},get shard(){return t.shard},get ownerId(){return e()._id},onClick:()=>zh(t.room,t.shard),onOverview:()=>Lh(t.room,t.shard)})})),t}})]})}})}})}N([`click`]);var Wx=V(`<div style="display:flex;align-items:center;border-top:1px solid #30363d;padding:10px 0"><div style=width:190px;flex-shrink:0;color:#c9d1d9;font-size:13px></div><div style=display:flex;flex:1;min-width:0;align-items:center>`),Gx=V(`<div style=flex:1;min-width:0;display:flex;justify-content:center;align-items:center;height:16px><div style=border-radius:50%>`),Kx=V(`<span style=color:#8b949e;font-size:15px;font-weight:400;margin-left:10px>`),qx=V(`<div style="display:flex;align-items:center;gap:18px;background:#161b22;border:1px solid #30363d;border-radius:8px;padding:16px 20px;margin-bottom:20px"><button title=Back style="display:flex;align-items:center;justify-content:center;width:38px;height:38px;flex-shrink:0;border-radius:50%;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer"></button><div style=flex:1;min-width:0><h1 style=margin:0;font-size:26px;font-weight:600;color:#d9b54a>Room `),Jx=V(`<div style="background:#161b22;border:1px solid #30363d;border-radius:8px;padding:16px 20px;margin-top:20px"><div style=display:flex;align-items:center;margin-bottom:4px><h2 style=margin:0;font-size:18px;font-weight:600;color:#d9b54a>Graph</h2><div style=flex:1></div><select style="padding:4px 8px;border-radius:4px;border:1px solid #30363d;background:#161b22;color:#8b949e;font-size:12px;cursor:pointer">`),Yx=V(`<div style=color:#8b949e;font-size:14px;margin-top:6px>Unclaimed room`),Xx=V(`<div style=display:flex;align-items:center;gap:8px;margin-top:6px;color:#8b949e;font-size:14px><span>Owner:`),Zx=V(`<option>`),Qx=V(`<div style=color:#8b949e;text-align:center;padding:40px>Loading…`),$x=[{value:8,label:`1 hour`,unit:`m`},{value:180,label:`24 hours`,unit:`h`},{value:1440,label:`7 days`,unit:`d`}],eS=[{key:`energyHarvested`,label:`Energy harvested`,color:`#ffe56d`},{key:`energyConstruction`,label:`Construction points`,color:`#eeeeee`},{key:`energyControl`,label:`Control points`,color:`#A7FFEB`},{key:`energyCreeps`,label:`Energy spent on creeps`,color:`#eeeeee`},{key:`creepsProduced`,label:`Creeps produced`,color:`#65fd62`},{key:`creepsLost`,label:`Creeps lost`,color:`#f96e76`}],tS=e=>$x.find(t=>t.value===e)?.unit??`d`;function nS(e,t,n){let r=t-1-e;return r===0?`0`:`-${r}${n}`}function rS(e){let t=()=>e.buckets.reduce((e,t)=>Math.max(e,t.value??0),0),n=()=>e.buckets.length;return(()=>{var r=Wx(),i=r.firstChild,a=i.nextSibling;return C(i,()=>e.label),C(a,f(u,{get each(){return e.buckets},children:(r,i)=>{let a=t(),o=a>0&&r.value>0?Math.max(.18,r.value/a):.07,s=r.value>0?7:3;return(()=>{var t=Gx(),a=t.firstChild;return H(a,`width`,`${s}px`),H(a,`height`,`${s}px`),S(s=>{var c=`${nS(i(),n(),e.unit)}: ${Ay(r.value)}`,l=e.color,u=String(o);return c!==s.e&&B(t,`title`,s.e=c),l!==s.t&&H(a,`background`,s.t=l),u!==s.a&&H(a,`opacity`,s.a=u),s},{e:void 0,t:void 0,a:void 0}),t})()}})),r})()}function iS(){let[e,t]=a(1440),[n]=c(()=>{let t=xh();return t?{room:t.room,shard:t.shard,interval:e()}:null},async({room:e,shard:t,interval:n})=>{let r=z();if(!r)return null;try{return await r.http.game.roomOverview(e,n,t)}catch{return null}}),[r]=c(()=>n()?.owner?.username??null,async e=>{let t=z();if(t)try{return(await t.http.user.find({username:e}))?.user?._id}catch{return}}),i=()=>xh()?.room??``,o=()=>xh()?.shard??null,s=()=>Fy({ok:1,stats:n()?.stats}),l=e=>n()?.stats?.[e]??[];return f(jv,{get children(){return[(()=>{var e=qx(),t=e.firstChild,a=t.nextSibling,s=a.firstChild;return s.firstChild,I(t,`click`,Rh,!0),C(t,f(br,{size:20})),C(s,i,null),C(s,f(_,{get when(){return o()},get children(){var e=Kx();return C(e,o),e}}),null),C(a,f(_,{get when(){return n()?.owner},get fallback(){return Yx()},children:e=>(()=>{var t=Xx();return t.firstChild,C(t,f(Sy,{get badge(){return e().badge},size:18}),null),C(t,f(Hh,{get username(){return e().username},color:`#58a6ff`}),null),t})()}),null),C(e,f(ky,{get room(){return i()},get shard(){return o()},get ownerId(){return r()},showLabel:!1,onClick:()=>zh(i(),o())}),null),e})(),f(Iy,{get totals(){return s()}}),(()=>{var r=Jx(),i=r.firstChild.firstChild.nextSibling.nextSibling;return i.addEventListener(`change`,e=>t(Number(e.currentTarget.value))),C(i,f(u,{each:$x,children:e=>(()=>{var t=Zx();return C(t,()=>e.label),S(()=>t.value=e.value),t})()})),C(r,f(_,{get when(){return!n.loading},get fallback(){return Qx()},get children(){return f(u,{each:eS,children:t=>f(rS,{get label(){return t.label},get color(){return t.color},get buckets(){return l(t.key)},get unit(){return tS(e())}})})}}),null),S(()=>i.value=e()),r})()]}})}N([`click`]);var aS=V(`<div style="color:#8b949e;padding:24px 0;text-align:center">Loading…`),oS=V(`<div style="color:#f85149;padding:24px 0">Failed to load messages.`),sS=V(`<div style=display:flex;flex-direction:column;gap:2px>`),cS=V(`<div>`),lS=V(`<div style="color:#8b949e;padding:32px 0;text-align:center">No messages yet. You can send a message from another player's profile page.`),uS=V(`<span style=font-style:italic>You: `),dS=V(`<div style=width:8px;height:8px;border-radius:50%;background:#388bfd;flex-shrink:0>`),fS=V(`<div role=button tabindex=0 style=display:flex;align-items:center;gap:12px;padding:12px;border-radius:6px;cursor:pointer><div style=flex:1;min-width:0><div style=display:flex;align-items:baseline;gap:8px;margin-bottom:2px><span style=color:#c9d1d9></span><span style=color:#8b949e;font-size:12px;margin-left:auto;flex-shrink:0></span></div><div style=color:#8b949e;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis>`),pS=V(`<div style="color:#8b949e;padding:24px 0;text-align:center">No messages yet.`),mS=V(`<div style=display:flex;flex-direction:column;gap:12px;margin-bottom:24px>`),hS=V(`<div style=display:flex;flex-direction:column;gap:0><div style=display:flex;align-items:center;gap:8px;margin-bottom:16px><button title="Back to inbox"style="display:flex;align-items:center;gap:4px;padding:5px 10px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer;font-size:13px"> Inbox</button><h2 style=margin:0;font-size:16px;font-weight:600;color:#c9d1d9></h2><button title="View profile"style="display:flex;align-items:center;gap:4px;padding:5px 10px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer;font-size:13px;margin-left:auto">Profile </button></div><div style="border-top:1px solid #30363d;padding-top:12px"><textarea placeholder="Write a message… (Ctrl+Enter to send)"rows=3 style="width:100%;background:#161b22;border:1px solid #30363d;border-radius:6px;color:#c9d1d9;padding:8px 12px;font-size:14px;resize:vertical;box-sizing:border-box;font-family:inherit;outline:none"></textarea><div style=display:flex;align-items:center;gap:8px;margin-top:8px;justify-content:flex-end><span style=color:#8b949e;font-size:12px>Markdown supported · Ctrl+Enter to send</span><button style="display:flex;align-items:center;gap:6px;padding:7px 14px;border-radius:4px;border:none;font-size:14px"> Send`),gS=V(`<div style=display:flex;gap:10px;align-items:flex-start><div style=flex-shrink:0;margin-top:2px></div><div style=flex:1;min-width:0><div style="border-radius:6px;padding:8px 12px;color:#c9d1d9;font-size:14px;white-space:pre-wrap;word-break:break-word"></div><div style=color:#8b949e;font-size:11px;margin-top:4px>`),_S=V(`<div style="width:24px;height:24px;background:#161b22;border-radius:3px;border:1px solid #30363d">`),vS=V(`<div style="display:flex;align-items:center;gap:10px;padding:0 0 14px;border-bottom:1px solid #30363d;margin-bottom:24px"><h1 style=margin:0;font-size:22px;font-weight:600;color:#c9d1d9>Messages</h1><div style=flex:1></div><button title=Close style="display:flex;align-items:center;padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer">`),yS=V(`<div style="color:#8b949e;padding:32px 0;text-align:center">User not found. <span style=color:#58a6ff;cursor:pointer>Back to inbox`),bS=`#30363d`,xS=`#8b949e`,SS=`#161b22`;function CS(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?`Just now`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:n<7*864e5?`${Math.floor(n/864e5)}d ago`:t.toLocaleDateString()}function wS(e,t){return e.length>t?e.slice(0,t)+`…`:e}function TS(e){let[t]=c(()=>z(),e=>e.http.user.messages.index());return(()=>{var n=cS();return C(n,f(_,{get when(){return t.loading},get children(){return aS()}}),null),C(n,f(_,{get when(){return t.error},get children(){return oS()}}),null),C(n,f(_,{get when(){return R(()=>!t.loading)()&&t()},get children(){return f(_,{get when(){return(t()?.messages?.length??0)>0},get fallback(){return lS()},get children(){var n=sS();return C(n,f(u,{get each(){return t().messages},children:n=>{let r=()=>t().users[n._id],i=()=>n.message.type===`in`&&n.message.unread;return(()=>{var t=fS(),a=t.firstChild,o=a.firstChild,s=o.firstChild,c=s.nextSibling,l=o.nextSibling;return t.$$keydown=t=>t.key===`Enter`&&e.onSelect({username:r()?.username??n._id,id:n._id}),t.$$click=()=>e.onSelect({username:r()?.username??n._id,id:n._id}),C(t,f(Sy,{get badge(){return r()?.badge},size:32}),a),C(s,()=>r()?.username??n._id),C(c,()=>CS(n.message.date)),C(l,f(_,{get when(){return n.message.type===`out`},get children(){return uS()}}),null),C(l,()=>wS(n.message.text,120),null),C(t,f(_,{get when(){return i()},get children(){return dS()}}),null),S(e=>{var n=`1px solid ${i()?`#388bfd`:bS}`,r=i()?`#0d1b2e`:`transparent`,a=i()?600:400;return n!==e.e&&H(t,`border`,e.e=n),r!==e.t&&H(t,`background`,e.t=r),a!==e.a&&H(s,`font-weight`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),t})()}})),n}})}}),null),n})()}function ES(e){let[t,n]=a([]),[r,i]=a(!0),[o,c]=a(``),[l,d]=a(!1);s(()=>{let t=z();t&&(i(!0),t.http.user.messages.list(e.respondent.id).then(e=>n(e.messages??[])).finally(()=>i(!1)))});let p=async()=>{let t=z(),r=o().trim();if(!(!t||!r||l())){d(!0);try{await t.http.user.messages.send(e.respondent.id,r),c(``),n((await t.http.user.messages.list(e.respondent.id)).messages??[])}finally{d(!1)}}};return(()=>{var n=hS(),i=n.firstChild,a=i.firstChild,s=a.firstChild,d=a.nextSibling,m=d.nextSibling;m.firstChild;var h=i.nextSibling,g=h.firstChild,v=g.nextSibling.firstChild.nextSibling,y=v.firstChild;return a.$$click=()=>e.onBack(),C(a,f(br,{size:14}),s),C(d,()=>e.respondent.username),m.$$click=()=>jh(e.respondent.username),C(m,f(Ir,{size:12}),null),C(n,f(_,{get when(){return r()},get children(){return aS()}}),h),C(n,f(_,{get when(){return R(()=>!r())()&&t().length===0},get children(){return pS()}}),h),C(n,f(_,{get when(){return!r()},get children(){var e=mS();return C(e,f(u,{get each(){return t()},children:e=>{let t=()=>e.type===`out`;return(()=>{var n=gS(),r=n.firstChild,i=r.nextSibling.firstChild,a=i.nextSibling;return C(r,f(_,{get when(){return t()},get fallback(){return _S()},get children(){return f(Sy,{get badge(){return U()?.badge},size:24})}})),C(i,()=>e.text),C(a,()=>CS(e.date)),S(e=>{var n=t()?`#1f3158`:SS,r=`1px solid ${t()?`#388bfd33`:bS}`,o=t()?`right`:`left`;return n!==e.e&&H(i,`background`,e.e=n),r!==e.t&&H(i,`border`,e.t=r),o!==e.a&&H(a,`text-align`,e.a=o),e},{e:void 0,t:void 0,a:void 0}),n})()}})),e}}),h),g.$$keydown=e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),p())},g.$$input=e=>c(e.currentTarget.value),v.$$click=()=>void p(),C(v,f(Ai,{size:14}),y),S(e=>{var t=!o().trim()||l(),n=!o().trim()||l()?`#21262d`:`#238636`,r=!o().trim()||l()?xS:`#fff`,i=!o().trim()||l()?`default`:`pointer`;return t!==e.e&&(v.disabled=e.e=t),n!==e.t&&H(v,`background`,e.t=n),r!==e.a&&H(v,`color`,e.a=r),i!==e.o&&H(v,`cursor`,e.o=i),e},{e:void 0,t:void 0,a:void 0,o:void 0}),S(()=>g.value=o()),n})()}function DS(){let[e]=c(()=>sh(),async e=>{let t=z();if(!t)return null;try{let n=await t.http.user.find({username:e});return n.user?{username:n.user.username,id:n.user._id}:null}catch{return null}});return f(jv,{maxWidth:`720px`,get children(){return[(()=>{var e=vS(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling;return C(e,f(Sy,{get badge(){return U()?.badge},size:28}),t),C(e,f(Hh,{get username(){return U()?.username},color:xS,style:{"font-size":`14px`}}),n),I(r,`click`,Rh,!0),C(r,f(Ji,{size:16})),e})(),f(_,{get when(){return sh()},get fallback(){return f(TS,{onSelect:e=>Dh(e.username)})},get children(){return f(_,{get when(){return!e.loading},get fallback(){return aS()},get children(){return f(_,{get when(){return e()},get fallback(){return(()=>{var e=yS(),t=e.firstChild.nextSibling;return I(t,`click`,Eh,!0),e})()},get children(){return f(ES,{get respondent(){return e()},onBack:Eh})}})}})}})]}})}N([`click`,`keydown`,`input`]);var OS=`#161b22`,kS=`#1c2129`,Z=`#30363d`,Q=`#c9d1d9`,$=`#8b949e`,AS=`#58a6ff`,jS=`#3fb950`,MS=`#f85149`;function NS(e){return e==null?`—`:Math.round(e).toLocaleString(`en-US`)}function PS(e){return e==null?`—`:e.toLocaleString(`en-US`,{minimumFractionDigits:3,maximumFractionDigits:3})}function FS(){return(ve()?.serverData?.shards??[]).filter(e=>e!=null)}function IS(){return ph()??FS()[0]??null}function LS(){return FS().length>1}var RS={token:`subscription token`,energy:`energy`,power:`power`,H:`hydrogen`,O:`oxygen`,U:`utrium`,L:`lemergium`,K:`keanium`,Z:`zynthium`,X:`catalyst`,OH:`hydroxide`,ZK:`zynthium keanite`,UL:`utrium lemergite`,G:`ghodium`,UH:`utrium hydride`,UO:`utrium oxide`,KH:`keanium hydride`,KO:`keanium oxide`,LH:`lemergium hydride`,LO:`lemergium oxide`,ZH:`zynthium hydride`,ZO:`zynthium oxide`,GH:`ghodium hydride`,GO:`ghodium oxide`,UH2O:`utrium acid`,UHO2:`utrium alkalide`,KH2O:`keanium acid`,KHO2:`keanium alkalide`,LH2O:`lemergium acid`,LHO2:`lemergium alkalide`,ZH2O:`zynthium acid`,ZHO2:`zynthium alkalide`,GH2O:`ghodium acid`,GHO2:`ghodium alkalide`,XUH2O:`catalyzed utrium acid`,XUHO2:`catalyzed utrium alkalide`,XKH2O:`catalyzed keanium acid`,XKHO2:`catalyzed keanium alkalide`,XLH2O:`catalyzed lemergium acid`,XLHO2:`catalyzed lemergium alkalide`,XZH2O:`catalyzed zynthium acid`,XZHO2:`catalyzed zynthium alkalide`,XGH2O:`catalyzed ghodium acid`,XGHO2:`catalyzed ghodium alkalide`,ops:`ops`,silicon:`silicon`,metal:`metal`,biomass:`biomass`,mist:`mist`,utrium_bar:`utrium bar`,lemergium_bar:`lemergium bar`,zynthium_bar:`zynthium bar`,keanium_bar:`keanium bar`,ghodium_melt:`ghodium melt`,oxidant:`oxidant`,reductant:`reductant`,purifier:`purifier`,battery:`battery`,composite:`composite`,crystal:`crystal`,liquid:`liquid`,wire:`wire`,switch:`switch`,transistor:`transistor`,microchip:`microchip`,circuit:`circuit`,device:`device`,cell:`cell`,phlegm:`phlegm`,tissue:`tissue`,muscle:`muscle`,organoid:`organoid`,organism:`organism`,alloy:`alloy`,tube:`tube`,fixtures:`fixtures`,frame:`frame`,hydraulics:`hydraulics`,machine:`machine`,condensate:`condensate`,concentrate:`concentrate`,extract:`extract`,spirit:`spirit`,emanation:`emanation`,essence:`essence`},zS=Object.keys(RS);function BS(e){return RS[e]??e}var VS={metal:[`wire`,`switch`,`transistor`,`microchip`,`circuit`,`device`],biomass:[`cell`,`phlegm`,`tissue`,`muscle`,`organoid`,`organism`],silicon:[`alloy`,`tube`,`fixtures`,`frame`,`hydraulics`,`machine`],mist:[`condensate`,`concentrate`,`extract`,`spirit`,`emanation`,`essence`]},HS={utrium_bar:`U`,lemergium_bar:`L`,zynthium_bar:`Z`,keanium_bar:`K`,ghodium_melt:`G`,oxidant:`O`,reductant:`H`,purifier:`X`,battery:`energy`},US={ops:14255163,token:15911244},WS=(()=>{let e={};for(let t in VS)for(let n of VS[t])e[n]=fn[t];for(let t in HS){let n=HS[t];e[t]=n===`energy`?wt:Un[n]}return{...e,...US}})();function GS(e){if(Un[e]!=null)return Un[e];if(fn[e]!=null)return fn[e];if(WS[e]!=null)return WS[e];let t=(e.startsWith(`X`)?e.slice(1):e)[0];return Un[t]==null?Et:Un[t]}var KS=V(`<span style="display:inline-block;border-radius:50%;border:1px solid rgba(255, 255, 255, 0.25);vertical-align:middle;flex:none">`);function qS(e){let t=()=>e.size??18,n=()=>`#${GS(e.resourceType).toString(16).padStart(6,`0`)}`;return(()=>{var r=KS();return S(i=>{var a=BS(e.resourceType),o=`${t()}px`,s=`${t()}px`,c=n();return a!==i.e&&B(r,`title`,i.e=a),o!==i.t&&H(r,`width`,i.t=o),s!==i.a&&H(r,`height`,i.a=s),c!==i.o&&H(r,`background`,i.o=c),i},{e:void 0,t:void 0,a:void 0,o:void 0}),r})()}var JS=V(`<div style="display:grid;grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));gap:8px">`),YS=V(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load the market — this server may not support it.`),XS=V(`<button style="display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:6px;cursor:pointer;text-align:left"><span style=flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap></span><span style=font-size:13px> `);function ZS(e){let[t,n]=a({}),[r,i]=a(!0),[o,c]=a(null),l=0;return s(()=>{let t=e.shard,r=z();if(!r)return;let a=++l;i(!0),r.http.game.market.ordersIndex(t).then(e=>{if(a!==l)return;let t={};for(let n of e.list??[])t[n._id]=n.count;n(t),c(null)}).catch(e=>{a===l&&c(e instanceof Error?e.message:String(e))}).finally(()=>{a===l&&i(!1)})}),f(_,{get when(){return!o()},get fallback(){return(()=>{var e=YS();return H(e,`background`,OS),H(e,`border`,`1px solid ${Z}`),H(e,`color`,$),e})()},get children(){var n=JS();return C(n,f(u,{each:zS,children:n=>{let r=()=>t()[n]??0;return(()=>{var t=XS(),i=t.firstChild,a=i.nextSibling,o=a.firstChild;return t.addEventListener(`mouseleave`,e=>e.currentTarget.style.background=OS),t.addEventListener(`mouseenter`,e=>e.currentTarget.style.background=kS),t.$$click=()=>Ph(n,e.shard),H(t,`border`,`1px solid ${Z}`),H(t,`background`,OS),H(t,`color`,Q),C(t,f(qS,{resourceType:n,size:20}),i),C(i,()=>BS(n)),C(a,r,o),C(a,()=>r()===1?`order`:`orders`,null),S(e=>H(a,`color`,r()>0?Q:$)),t})()}})),S(e=>H(n,`opacity`,r()?.6:1)),n}})}N([`click`]);var QS=V(`<div style=border-radius:8px;margin-bottom:16px;overflow:hidden><div style="display:flex;align-items:center;padding:11px 16px"><span style=font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:0.05em></span><div style=flex:1></div></div><div style="padding:4px 16px 12px">`);function $S(e){return(()=>{var t=QS(),n=t.firstChild,r=n.firstChild;r.nextSibling;var i=n.nextSibling;return H(t,`background`,OS),H(t,`border`,`1px solid ${Z}`),H(n,`border-bottom`,`1px solid ${Z}`),H(n,`background`,kS),C(r,()=>e.title),C(n,()=>e.right,null),C(i,()=>e.children),S(n=>{var i=e.accent?`3px solid ${e.accent}`:`1px solid ${Z}`,a=e.accent??`#c9d1d9`;return i!==n.e&&H(t,`border-left`,n.e=i),a!==n.t&&H(r,`color`,n.t=a),n},{e:void 0,t:void 0}),t})()}function eC(e){return e%2==1?`rgba(255, 255, 255, 0.022)`:`transparent`}var tC=V(`<div style="border-radius:6px;padding:10px 14px;margin-bottom:16px;font-size:13px">A special item that activates 60 days of CPU subscription for its owner.`),nC=V(`<div style=display:flex;align-items:center;gap:10px;margin-bottom:16px><label style=font-size:13px>Target room</label><input placeholder="e.g. W1N1"style="padding:6px 8px;border-radius:4px;width:120px"><span style=font-size:12px>shows shipping range to each order's room`),rC=V(`<div>`),iC=V(`<div><div style=display:flex;align-items:center;gap:12px;margin-bottom:16px><button style="display:flex;align-items:center;gap:4px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Resources</button><div style=flex:1></div><button title=Refresh style="display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Refresh</button></div><div style=display:flex;align-items:center;gap:10px;margin-bottom:16px><h2 style=margin:0;font-size:20px;font-weight:600>`),aC=V(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load orders for this resource.`),oC=V(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right></tr></thead><tbody>`),sC=V(`<span style=font-size:12px> `),cC=V(`<div style="font-size:13px;padding:10px 0">No orders`),lC=V(`<a href=# style=text-decoration:none>`),uC=V(`<td style="padding:7px 0">`),dC=V(`<td style=padding-right:6px>`),fC=V(`<tr style=text-align:right><td style="text-align:left;font-family:monospace;padding:7px 8px 7px 6px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0">`),pC=V(`<span>—`),mC=V(`<th style=font-weight:400;cursor:pointer;user-select:none;white-space:nowrap>`),hC=V(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right><th style="text-align:left;font-weight:400;padding:0 0 7px 6px">Date</th><th style="font-weight:400;padding:0 0 7px">Transactions</th><th style="font-weight:400;padding:0 0 7px">Total volume</th><th style="font-weight:400;padding:0 6px 7px 0">Price (avg ± stddev)</th></tr></thead><tbody>`),gC=V(`<div style="font-size:13px;padding:10px 0">No history`),_C=V(`<tr style=text-align:right><td style="text-align:left;padding:7px 0 7px 6px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 6px 7px 0"> <span>± `);function vC(e,t){if(!e)return;let n=Wn(e),r=Wn(t);if(!(!n||!r))return Math.max(Math.abs(n.x-r.x),Math.abs(n.y-r.y))}function yC(e,t){let n=t[0]===`-`,r=t.slice(1);return[...e].sort((e,t)=>{let i=e[r],a=t[r],o;return o=typeof i==`number`||typeof a==`number`?(Number(i)||0)-(Number(a)||0):String(i??``).localeCompare(String(a??``)),n?-o:o})}function bC(e){let[t,n]=a([]),[r,i]=a([]),[o,c]=a([]),[l,u]=a(hh()??``),[d,p]=a(!0),[m,h]=a(null),g=()=>e.resourceType===`token`,v=0,b=()=>{let t=z(),r=e.resourceType;if(!t||!r)return;let a=++v;p(!0),t.http.game.market.orders(r,e.shard).then(e=>{if(a!==v)return;let t=e.list??[];n(t.filter(e=>e.type===`sell`)),i(t.filter(e=>e.type===`buy`)),h(null)}).catch(e=>{a===v&&h(e instanceof Error?e.message:String(e))}).finally(()=>{a===v&&p(!1)}),t.http.game.market.stats(r,e.shard).then(e=>{a===v&&c(e.stats??[])}).catch(()=>{a===v&&c([])})};s(()=>{e.resourceType,e.shard,b()});let x=e=>{let t=l().trim().toUpperCase(),n=/^[WE]\d+[NS]\d+$/.test(t);return e.map(e=>({...e,range:n?vC(e.roomName,t):void 0}))},w=y(()=>x(t())),T=y(()=>x(r()));return(()=>{var t=iC(),n=t.firstChild,r=n.firstChild,i=r.firstChild,a=r.nextSibling.nextSibling,s=a.firstChild,c=n.nextSibling,p=c.firstChild;return r.$$click=()=>Nh(e.shard),H(r,`border`,`1px solid ${Z}`),H(r,`color`,Q),C(r,f(br,{size:14}),i),a.$$click=b,H(a,`border`,`1px solid ${Z}`),H(a,`color`,Q),C(a,f(wi,{size:14}),s),C(c,f(qS,{get resourceType(){return e.resourceType??``},size:26}),p),H(p,`color`,Q),C(p,()=>BS(e.resourceType??``)),C(t,f(_,{get when(){return g()},get children(){var e=tC();return H(e,`background`,OS),H(e,`border`,`1px solid ${Z}`),H(e,`color`,$),e}}),null),C(t,f(_,{get when(){return!m()},get fallback(){return(()=>{var e=aC();return H(e,`background`,OS),H(e,`border`,`1px solid ${Z}`),H(e,`color`,$),e})()},get children(){return[f(_,{get when(){return!g()},get children(){var e=nC(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling;return H(t,`color`,$),n.$$input=e=>u(e.currentTarget.value),H(n,`border`,`1px solid ${Z}`),H(n,`background`,OS),H(n,`color`,Q),H(r,`color`,$),S(()=>n.value=l()),e}}),(()=>{var t=rC();return C(t,f(xC,{title:`Selling`,accent:jS,get rows(){return w()},defaultSort:`+price`,get showRoom(){return!g()},get shard(){return e.shard}}),null),C(t,f(xC,{title:`Buying`,accent:MS,get rows(){return T()},defaultSort:`-price`,get showRoom(){return!g()},get shard(){return e.shard}}),null),C(t,f(CC,{get stats(){return o()}}),null),S(e=>H(t,`opacity`,d()?.6:1)),t})()]}}),null),t})()}function xC(e){let[t,n]=a(e.defaultSort),r=y(()=>yC(e.rows,t())),i=e=>{n(t=>t===`+${e}`?`-${e}`:`+${e}`)};return f($S,{get title(){return e.title},get accent(){return e.accent},get right(){return(()=>{var t=sC(),n=t.firstChild;return H(t,`color`,$),C(t,()=>e.rows.length,n),C(t,()=>e.rows.length===1?`order`:`orders`,null),t})()},get children(){return f(_,{get when(){return e.rows.length},get fallback(){return(()=>{var e=cC();return H(e,`color`,$),e})()},get children(){var n=oC(),a=n.firstChild,o=a.firstChild,s=a.nextSibling;return H(o,`color`,$),C(o,f(SC,{label:`Order ID`,col:`_id`,get sort(){return t()},onClick:i,align:`left`}),null),C(o,f(SC,{label:`Price`,col:`price`,get sort(){return t()},onClick:i}),null),C(o,f(SC,{label:`Available`,col:`amount`,get sort(){return t()},onClick:i}),null),C(o,f(SC,{label:`Remaining`,col:`remainingAmount`,get sort(){return t()},onClick:i}),null),C(o,f(_,{get when(){return e.showRoom},get children(){return[f(SC,{label:`Room`,col:`roomName`,get sort(){return t()},onClick:i}),f(SC,{label:`Range`,col:`range`,get sort(){return t()},onClick:i})]}}),null),C(s,f(u,{get each(){return r()},children:(t,n)=>(()=>{var r=fC(),i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return H(i,`color`,$),C(i,()=>t._id),C(a,()=>PS(t.price)),H(o,`color`,Q),C(o,()=>NS(t.amount)),H(s,`color`,$),C(s,()=>NS(t.remainingAmount)),C(r,f(_,{get when(){return e.showRoom},get children(){return[(()=>{var n=uC();return C(n,f(_,{get when(){return t.roomName},get fallback(){return(()=>{var e=pC();return H(e,`color`,$),e})()},get children(){var n=lC();return n.$$click=n=>{n.preventDefault(),zh(t.roomName,e.shard)},H(n,`color`,AS),C(n,()=>t.roomName),n}})),n})(),(()=>{var e=dC();return H(e,`color`,$),C(e,()=>t.range??`—`),e})()]}}),null),S(t=>{var i=eC(n()),o=e.accent;return i!==t.e&&H(r,`background`,t.e=i),o!==t.t&&H(a,`color`,t.t=o),t},{e:void 0,t:void 0}),r})()})),n}})}})}function SC(e){let t=()=>e.sort===`+${e.col}`||e.sort===`-${e.col}`,n=()=>e.sort===`+${e.col}`?` ▲`:e.sort===`-${e.col}`?` ▼`:``;return(()=>{var r=mC();return r.$$click=()=>e.onClick(e.col),H(r,`border-bottom`,`1px solid ${Z}`),C(r,()=>e.label,null),C(r,n,null),S(n=>{var i=e.align??`right`,a=t()?Q:$,o=e.align===`left`?`0 0 7px 6px`:`0 0 7px`;return i!==n.e&&H(r,`text-align`,n.e=i),a!==n.t&&H(r,`color`,n.t=a),o!==n.a&&H(r,`padding`,n.a=o),n},{e:void 0,t:void 0,a:void 0}),r})()}function CC(e){return f($S,{title:`Price history`,get children(){return f(_,{get when(){return e.stats.length},get fallback(){return(()=>{var e=gC();return H(e,`color`,$),e})()},get children(){var t=hC(),n=t.firstChild,r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=n.nextSibling;return H(r,`color`,$),H(i,`border-bottom`,`1px solid ${Z}`),H(a,`border-bottom`,`1px solid ${Z}`),H(o,`border-bottom`,`1px solid ${Z}`),H(s,`border-bottom`,`1px solid ${Z}`),C(c,f(u,{get each(){return e.stats},children:(e,t)=>(()=>{var n=_C(),r=n.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling,s=o.firstChild,c=s.nextSibling;return c.firstChild,H(r,`color`,$),C(r,()=>e.date),H(i,`color`,Q),C(i,()=>NS(e.transactions)),H(a,`color`,Q),C(a,()=>NS(e.volume)),H(o,`color`,Q),C(o,()=>PS(e.avgPrice),s),H(c,`color`,$),C(c,()=>PS(e.stddevPrice),null),S(e=>H(n,`background`,eC(t()))),n})()})),t}})}})}N([`click`,`input`]);var wC=V(`<div style=display:flex;justify-content:flex-end;margin-bottom:12px><button title=Refresh style="display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Refresh`),TC=V(`<div>`),EC=V(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load your orders.`),DC=V(`<div style=border-radius:8px;padding:32px;text-align:center>You have no orders. Create one with the in-game Market API.`),OC=V(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right><th style="text-align:left;font-weight:400;padding:0 0 7px 6px">Order ID</th><th style="text-align:left;font-weight:400;padding:0 0 7px">Resource</th><th style="font-weight:400;padding:0 0 7px">Type</th><th style="font-weight:400;padding:0 0 7px">Active</th><th style="font-weight:400;padding:0 0 7px">Price</th><th style="font-weight:400;padding:0 0 7px">Available</th><th style="font-weight:400;padding:0 0 7px">Remaining</th><th style="font-weight:400;padding:0 0 7px">Total</th><th style="font-weight:400;padding:0 6px 7px 0">Room</th></tr></thead><tbody>`),kC=V(`<span style=font-size:12px> `),AC=V(`<a href=# style=text-decoration:none>`),jC=V(`<tr style=text-align:right><td style="text-align:left;font-family:monospace;padding:7px 8px 7px 6px"></td><td style="text-align:left;padding:7px 0"><a href=# style=display:inline-flex;align-items:center;gap:8px;text-decoration:none></a></td><td style="padding:7px 0"></td><td style="padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="padding:7px 6px 7px 0">`),MC=V(`<span>—`);function NC(){let[e,t]=a([]),[n,r]=a(!0),[o,s]=a(null),c=()=>{let e=z();e&&(r(!0),e.http.game.market.myOrders().then(e=>{e.shards?t(Object.entries(e.shards).map(([e,t])=>({shard:e,orders:t}))):t([{shard:null,orders:e.list??[]}]),s(null)}).catch(e=>s(e instanceof Error?e.message:String(e))).finally(()=>r(!1)))};i(c);let l=()=>e().reduce((e,t)=>e+t.orders.length,0),d=()=>e().length>1;return f(_,{get when(){return!o()},get fallback(){return(()=>{var e=EC();return H(e,`background`,OS),H(e,`border`,`1px solid ${Z}`),H(e,`color`,$),e})()},get children(){return[(()=>{var e=wC(),t=e.firstChild,n=t.firstChild;return t.$$click=c,H(t,`border`,`1px solid ${Z}`),H(t,`color`,Q),C(t,f(wi,{size:14}),n),e})(),f(_,{get when(){return l()},get fallback(){return(()=>{var e=DC();return H(e,`background`,OS),H(e,`border`,`1px solid ${Z}`),H(e,`color`,$),e})()},get children(){var t=TC();return C(t,f(u,{get each(){return e()},children:e=>f(_,{get when(){return e.orders.length},get children(){return f($S,{get title(){return R(()=>!!d())()?e.shard??`My orders`:`My orders`},get right(){return(()=>{var t=kC(),n=t.firstChild;return H(t,`color`,$),C(t,()=>e.orders.length,n),C(t,()=>e.orders.length===1?`order`:`orders`,null),t})()},get children(){var t=OC(),n=t.firstChild,r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,d=l.nextSibling,p=d.nextSibling,m=p.nextSibling,h=n.nextSibling;return H(r,`color`,$),H(i,`border-bottom`,`1px solid ${Z}`),H(a,`border-bottom`,`1px solid ${Z}`),H(o,`border-bottom`,`1px solid ${Z}`),H(s,`border-bottom`,`1px solid ${Z}`),H(c,`border-bottom`,`1px solid ${Z}`),H(l,`border-bottom`,`1px solid ${Z}`),H(d,`border-bottom`,`1px solid ${Z}`),H(p,`border-bottom`,`1px solid ${Z}`),H(m,`border-bottom`,`1px solid ${Z}`),C(h,f(u,{get each(){return e.orders},children:(t,n)=>(()=>{var r=jC(),i=r.firstChild,a=i.nextSibling,o=a.firstChild,s=a.nextSibling,c=s.nextSibling,l=c.nextSibling,u=l.nextSibling,d=u.nextSibling,p=d.nextSibling,m=p.nextSibling;return H(i,`color`,$),C(i,()=>t._id),o.$$click=n=>{n.preventDefault(),Ph(t.resourceType,e.shard)},H(o,`color`,AS),C(o,f(qS,{get resourceType(){return t.resourceType},size:16}),null),C(o,()=>BS(t.resourceType),null),C(s,()=>t.type===`sell`?`Selling`:`Buying`),C(c,()=>t.active?`Yes`:`No`),H(l,`color`,Q),C(l,()=>PS(t.price)),H(u,`color`,Q),C(u,()=>NS(t.amount)),H(d,`color`,$),C(d,()=>NS(t.remainingAmount)),H(p,`color`,$),C(p,()=>NS(t.totalAmount)),C(m,f(_,{get when(){return t.roomName},get fallback(){return(()=>{var e=MC();return H(e,`color`,$),e})()},get children(){var n=AC();return n.$$click=n=>{n.preventDefault(),zh(t.roomName,e.shard)},H(n,`color`,AS),C(n,()=>t.roomName),n}})),S(e=>{var i=eC(n()),a=t.type===`sell`?jS:MS,o=t.active?jS:MS;return i!==e.e&&H(r,`background`,e.e=i),a!==e.t&&H(s,`color`,e.t=a),o!==e.a&&H(c,`color`,e.a=o),e},{e:void 0,t:void 0,a:void 0}),r})()})),t}})}})})),S(e=>H(t,`opacity`,n()?.6:1)),t}})]}})}N([`click`]);var PC=V(`<div style=display:flex;justify-content:flex-end;margin-bottom:12px><button title=Refresh style="display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Refresh`),FC=V(`<th style="text-align:left;font-weight:400;padding:0 0 7px">Shard`),IC=V(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right><th style="text-align:left;font-weight:400;padding:0 0 7px 6px">Date</th><th style="font-weight:400;padding:0 0 7px">Tick</th><th style="text-align:left;font-weight:400;padding:0 12px 7px">Description</th><th style="font-weight:400;padding:0 0 7px">Change</th><th style="font-weight:400;padding:0 6px 7px 0">Balance</th></tr></thead><tbody>`),LC=V(`<button style="display:flex;align-items:center;gap:4px;padding:6px 12px;border-radius:4px;background:#21262d;cursor:pointer"> Newer`),RC=V(`<button style="display:flex;align-items:center;gap:4px;padding:6px 12px;border-radius:4px;background:#21262d;cursor:pointer">Older `),zC=V(`<div style=display:flex;justify-content:space-between;margin-top:16px>`),BC=V(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load your history.`),VC=V(`<div style=border-radius:8px;padding:32px;text-align:center>Your market history is empty.`),HC=V(`<td style="text-align:left;padding:7px 0">`),UC=V(`<tr style=text-align:right><td style="text-align:left;padding:7px 0 7px 6px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="text-align:left;padding:7px 12px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 6px 7px 0">`),WC=V(`<span>`);function GC(e){switch(e.type){case`market.buy`:return`Resources bought via market order`;case`market.sell`:return`Resources sold via market order`;case`market.fee`:return`Market fee`;default:return e.type.replace(/[._]/g,` `)}}function KC(e){let t=new Date(e);return isNaN(t.getTime())?e:t.toLocaleString()}function qC(){let[e,t]=a([]),[n,r]=a(0),[o,s]=a(!1),[c,l]=a(!0),[d,p]=a(null),m=e=>{let n=z();n&&(l(!0),n.http.user.moneyHistory(e).then(n=>{t(n.list??[]),r(n.page??e),s(n.hasMore??!1),p(null)}).catch(e=>p(e instanceof Error?e.message:String(e))).finally(()=>l(!1)))};return i(()=>m(0)),f(_,{get when(){return!d()},get fallback(){return(()=>{var e=BC();return H(e,`background`,OS),H(e,`border`,`1px solid ${Z}`),H(e,`color`,$),e})()},get children(){return[(()=>{var e=PC(),t=e.firstChild,r=t.firstChild;return t.$$click=()=>m(n()),H(t,`border`,`1px solid ${Z}`),H(t,`color`,Q),C(t,f(wi,{size:14}),r),e})(),f(_,{get when(){return e().length},get fallback(){return(()=>{var e=VC();return H(e,`background`,OS),H(e,`border`,`1px solid ${Z}`),H(e,`color`,$),e})()},get children(){return[f($S,{title:`Credit history`,get children(){var t=IC(),n=t.firstChild,r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,l=s.nextSibling,d=n.nextSibling;return H(r,`color`,$),H(i,`border-bottom`,`1px solid ${Z}`),C(r,f(_,{get when(){return LS()},get children(){var e=FC();return H(e,`border-bottom`,`1px solid ${Z}`),e}}),a),H(a,`border-bottom`,`1px solid ${Z}`),H(o,`border-bottom`,`1px solid ${Z}`),H(s,`border-bottom`,`1px solid ${Z}`),H(l,`border-bottom`,`1px solid ${Z}`),C(d,f(u,{get each(){return e()},children:(e,t)=>(()=>{var n=UC(),r=n.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return H(r,`color`,$),C(r,()=>KC(e.date)),C(n,f(_,{get when(){return LS()},get children(){var t=HC();return H(t,`color`,$),C(t,()=>e.shard??`—`),t}}),i),H(i,`color`,$),C(i,()=>e.tick),H(a,`color`,Q),C(a,()=>GC(e)),C(o,()=>e.change>0?`+`:``,null),C(o,()=>PS(e.change),null),H(s,`color`,Q),C(s,()=>PS(e.balance)),S(r=>{var i=eC(t()),a=e.change>0?jS:e.change<0?MS:$;return i!==r.e&&H(n,`background`,r.e=i),a!==r.t&&H(o,`color`,r.t=a),r},{e:void 0,t:void 0}),n})()})),S(e=>H(t,`opacity`,c()?.6:1)),t}}),(()=>{var e=zC();return C(e,f(_,{get when(){return n()>0},get fallback(){return WC()},get children(){var e=LC(),t=e.firstChild;return e.$$click=()=>m(n()-1),H(e,`border`,`1px solid ${Z}`),H(e,`color`,Q),C(e,f(Sr,{size:14}),t),e}}),null),C(e,f(_,{get when(){return o()},get children(){var e=RC();return e.firstChild,e.$$click=()=>m(n()+1),H(e,`border`,`1px solid ${Z}`),H(e,`color`,Q),C(e,f(wr,{size:14}),null),e}}),null),e})()]}})]}})}N([`click`]);var JC=V(`<label style=display:flex;align-items:center;gap:8px;font-size:13px>Shard<select style="padding:6px 8px;border-radius:4px;cursor:pointer">`),YC=V(`<div style="display:flex;align-items:center;gap:12px;padding:0 0 14px;margin-bottom:8px"><h1 style=margin:0;font-size:22px;font-weight:600>Market</h1><div style=flex:1></div><button title=Close style=display:flex;align-items:center;padding:7px;border-radius:4px;background:#21262d;cursor:pointer>`),XC=V(`<div style=display:flex;gap:4px;margin-bottom:20px>`),ZC=V(`<option>`),QC=V(`<button style="padding:8px 16px;border:none;background:transparent;font-size:14px;cursor:pointer;margin-bottom:-1px">`);function $C(){let e=()=>lh()===`all-orders`||lh()===`resource`,t=e=>{lh()===`resource`&&dh()?Ph(dh(),e):Nh(e)};return f(jv,{get children(){return[(()=>{var n=YC(),r=n.firstChild,i=r.nextSibling.nextSibling;return H(n,`border-bottom`,`1px solid ${Z}`),H(r,`color`,Q),C(n,f(_,{get when(){return R(()=>!!e())()&&LS()},get children(){var e=JC(),n=e.firstChild.nextSibling;return H(e,`color`,$),n.addEventListener(`change`,e=>t(e.currentTarget.value)),H(n,`border`,`1px solid ${Z}`),H(n,`background`,OS),H(n,`color`,Q),C(n,f(u,{get each(){return FS()},children:e=>(()=>{var t=ZC();return t.value=e,C(t,e),t})()})),S(()=>n.value=IS()??``),e}}),i),I(i,`click`,Rh,!0),H(i,`border`,`1px solid ${Z}`),H(i,`color`,Q),C(i,f(Ji,{size:16})),n})(),(()=>{var t=XC();return H(t,`border-bottom`,`1px solid ${Z}`),C(t,f(ew,{label:`All orders`,get active(){return e()},onClick:()=>Nh(IS())}),null),C(t,f(ew,{label:`My orders`,get active(){return lh()===`my-orders`},onClick:Fh}),null),C(t,f(ew,{label:`History`,get active(){return lh()===`history`},onClick:Ih}),null),t})(),f(g,{get children(){return[f(d,{get when(){return lh()===`resource`},get children(){return f(bC,{get resourceType(){return dh()},get shard(){return IS()}})}}),f(d,{get when(){return lh()===`my-orders`},get children(){return f(NC,{})}}),f(d,{get when(){return lh()===`history`},get children(){return f(qC,{})}}),f(d,{get when(){return lh()===`all-orders`},get children(){return f(ZS,{get shard(){return IS()}})}})]}})]}})}function ew(e){return(()=>{var t=QC();return t.$$click=()=>e.onClick(),C(t,()=>e.label),S(n=>{var r=`2px solid ${e.active?AS:`transparent`}`,i=e.active?Q:$,a=e.active?600:400;return r!==n.e&&H(t,`border-bottom`,n.e=r),i!==n.t&&H(t,`color`,n.t=i),a!==n.a&&H(t,`font-weight`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()}N([`click`]);var tw=V(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:200;display:flex;align-items:center;justify-content:center><div style="background:#161b22;border:1px solid #30363d;border-radius:10px;width:540px;max-height:90vh;display:flex;flex-direction:column;overflow:hidden"><div style="display:flex;align-items:center;justify-content:space-between;padding:14px 20px;border-bottom:1px solid #30363d;flex-shrink:0"><span style=font-size:15px;font-weight:600;color:#c9d1d9>Edit Badge</span><button style="background:transparent;border:none;color:#8b949e;cursor:pointer;line-height:1;padding:2px 6px"></button></div><div style=overflow:auto;flex:1;padding:20px><div style=display:flex;gap:16px;margin-bottom:20px><div style=flex-shrink:0><div style=font-size:11px;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;margin-bottom:8px;font-weight:700>Preview</div><img width=96 height=96 style=display:block></div><div style=flex:1;min-width:0><div style=font-size:11px;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;margin-bottom:8px;font-weight:700>Badge Design</div><div style="display:grid;grid-template-columns:repeat(6, 1fr);gap:4px"></div></div></div><div style=margin-bottom:20px><div style=font-size:11px;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;margin-bottom:8px;font-weight:700>Colors</div><div style=display:flex;gap:6px;margin-bottom:10px></div><div style="display:grid;grid-template-columns:repeat(20, 1fr);gap:2px;margin-bottom:10px"></div><div style=display:flex;align-items:center;gap:8px><div style="width:24px;height:24px;border-radius:4px;border:1px solid rgba(255,255,255,0.2);flex-shrink:0"></div><input type=text maxlength=7 placeholder=#rrggbb style="width:90px;padding:4px 8px;border-radius:4px;background:#0d1117;color:#c9d1d9;font-size:12px;font-family:monospace;outline:none"></div></div><div style=margin-bottom:16px><div style=display:flex;align-items:baseline;gap:8px;margin-bottom:6px><span style=font-size:11px;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;font-weight:700>Variation</span><span style=font-size:12px;color:#c9d1d9></span></div><input type=range min=-100 max=100 style=width:100%;accent-color:#58a6ff></div><label style=display:flex;align-items:center;gap:8px;cursor:pointer;font-size:13px;color:#c9d1d9><input type=checkbox style=accent-color:#58a6ff;width:14px;height:14px>Rotate / Flip</label></div><div style="display:flex;justify-content:flex-end;gap:8px;padding:14px 20px;border-top:1px solid #30363d;flex-shrink:0"><button style="padding:8px 16px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#8b949e;font-size:13px">Cancel</button><button style="padding:8px 16px;border-radius:6px;border:none;background:#238636;color:#fff;font-size:13px;font-weight:600">`),nw=V(`<button style=border-radius:4px;padding:3px;cursor:pointer;display:flex;align-items:center;justify-content:center><img width=48 height=48 style=display:block>`),rw=V(`<button style="display:flex;align-items:center;gap:6px;padding:5px 10px;border-radius:6px;font-size:12px;cursor:pointer"><div style="width:12px;height:12px;border-radius:50%;border:1px solid rgba(255,255,255,0.2);flex-shrink:0">`),iw=V(`<button style=width:100%;aspect-ratio:1;border-radius:2px;cursor:pointer;padding:0;outline:none>`),aw={};for(let e=1;e<=24;e++){let t=pt({type:e,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1});aw[e]=`data:image/svg+xml,${encodeURIComponent(t)}`}function ow(e){return typeof e==`string`?e:lt[e]?.rgb??`#000000`}function sw(e){return typeof e==`number`?Math.max(0,Math.min(79,e)):e}var cw=[{slot:1,label:`Background`},{slot:2,label:`Primary`},{slot:3,label:`Secondary`}],lw=Array.from({length:24},(e,t)=>t+1),uw=/^#[0-9a-f]{6}$/i;function dw(e){let[t,n]=a(m(()=>typeof e.badge.type==`number`?e.badge.type:1)),[r,i]=a(m(()=>sw(e.badge.color1))),[o,c]=a(m(()=>sw(e.badge.color2))),[l,d]=a(m(()=>sw(e.badge.color3))),[p,h]=a(m(()=>e.badge.param??0)),[g,_]=a(m(()=>e.badge.flip??!1)),[v,b]=a(1),[x,w]=a(!1),[T,E]=a(m(()=>ow(sw(e.badge.color1)))),D=e=>e===1?r():e===2?o():l(),O=e=>{let t=v();t===1?i(e):t===2?c(e):d(e)};s(()=>{E(ow(D(v())))});let k=e=>{let t=D(v());return typeof t==`number`?t===e:t.toLowerCase()===(lt[e]?.rgb??``).toLowerCase()},j=()=>({type:t(),color1:ow(r()),color2:ow(o()),color3:ow(l()),param:p(),flip:g()}),ee=y(()=>{let e=pt(j());return`data:image/svg+xml,${encodeURIComponent(e)}`}),M=e=>{if(E(e),!uw.test(e))return;let t=lt.findIndex(t=>t.rgb.toLowerCase()===e.toLowerCase());O(t>=0?t:e)},te=async()=>{let t=z();if(t){w(!0);try{await t.http.user.badge(j()),await t.stores.user.refreshMe(),e.onClose(),e.onSaved?.(),A(`Badge saved`,`success`,3e3)}catch(e){A(`Failed to save badge: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}finally{w(!1)}}},ne=t=>{t.target===t.currentTarget&&e.onClose()};return(()=>{var r=tw(),i=r.firstChild.firstChild,a=i.firstChild.nextSibling,o=i.nextSibling,s=o.firstChild,c=s.firstChild,l=c.firstChild.nextSibling,d=c.nextSibling.firstChild.nextSibling,m=s.nextSibling,y=m.firstChild.nextSibling,w=y.nextSibling,E=w.nextSibling.firstChild,A=E.nextSibling,j=m.nextSibling,re=j.firstChild,ie=re.firstChild.nextSibling,ae=re.nextSibling,oe=j.nextSibling.firstChild,N=o.nextSibling.firstChild,P=N.nextSibling;return r.$$click=ne,a.$$click=()=>e.onClose(),C(a,f(Ji,{size:18})),C(d,f(u,{each:lw,children:e=>(()=>{var r=nw(),i=r.firstChild;return r.$$click=()=>n(e),S(n=>{var a=t()===e?`#1f3a2a`:`#0d1117`,o=`1px solid ${t()===e?`#238636`:`#21262d`}`,s=t()===e?ee():aw[e];return a!==n.e&&H(r,`background`,n.e=a),o!==n.t&&H(r,`border`,n.t=o),s!==n.a&&B(i,`src`,n.a=s),n},{e:void 0,t:void 0,a:void 0}),r})()})),C(y,f(u,{each:cw,children:({slot:e,label:t})=>(()=>{var n=rw(),r=n.firstChild;return n.$$click=()=>b(e),C(n,t,null),S(t=>{var i=`1px solid ${v()===e?`#58a6ff`:`#30363d`}`,a=v()===e?`#1c2d47`:`transparent`,o=v()===e?`#58a6ff`:`#8b949e`,s=ow(D(e));return i!==t.e&&H(n,`border`,t.e=i),a!==t.t&&H(n,`background`,t.t=a),o!==t.a&&H(n,`color`,t.a=o),s!==t.o&&H(r,`background`,t.o=s),t},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()})),C(w,f(u,{each:lt,children:e=>(()=>{var t=iw();return t.$$click=()=>O(e.index),S(n=>{var r=e.rgb,i=e.rgb,a=k(e.index)?`2px solid #fff`:`1px solid transparent`;return r!==n.e&&B(t,`title`,n.e=r),i!==n.t&&H(t,`background`,n.t=i),a!==n.a&&H(t,`border`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),A.$$input=e=>M(e.currentTarget.value),C(ie,p),ae.$$input=e=>h(+e.currentTarget.value),oe.addEventListener(`change`,e=>_(e.currentTarget.checked)),N.$$click=()=>e.onClose(),P.$$click=te,C(P,()=>x()?`Saving…`:`Save Badge`),S(e=>{var t=ee(),n=uw.test(T())?T():ow(D(v())),r=`1px solid ${uw.test(T())?`#30363d`:`#f85149`}`,i=x(),a=x()?`not-allowed`:`pointer`,o=x(),s=x()?`not-allowed`:`pointer`,c=x()?.7:1;return t!==e.e&&B(l,`src`,e.e=t),n!==e.t&&H(E,`background`,e.t=n),r!==e.a&&H(A,`border`,e.a=r),i!==e.o&&(N.disabled=e.o=i),a!==e.i&&H(N,`cursor`,e.i=a),o!==e.n&&(P.disabled=e.n=o),s!==e.s&&H(P,`cursor`,e.s=s),c!==e.h&&H(P,`opacity`,e.h=c),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),S(()=>A.value=T()),S(()=>ae.value=p()),S(()=>oe.checked=g()),r})()}N([`click`,`input`]);var fw=V(`<button style="padding:7px;border-radius:4px;margin:0 4px;display:flex;align-items:center">`),pw=V(`<button title="World Map"style="position:absolute;top:8px;left:8px;z-index:5;padding:12px;border-radius:6px;border:1px solid #30363d;background:rgba(33,38,45,0.85);color:#c9d1d9;cursor:pointer;display:flex;align-items:center">`),mw=V(`<button title="Room overview"style="position:absolute;top:66px;left:8px;z-index:5;padding:12px;border-radius:6px;border:1px solid #30363d;background:rgba(33,38,45,0.85);color:#c9d1d9;cursor:pointer;display:flex;align-items:center">`),hw=V(`<button title=History style=position:absolute;top:124px;left:8px;z-index:5;padding:12px;border-radius:6px;color:#c9d1d9;display:flex;align-items:center>`),gw=V(`<div style=flex:1;position:relative;overflow:hidden>`),_w=V(`<div style="border-top:1px solid #30363d;overflow:hidden;position:relative"><div style=position:absolute;top:0;left:0;width:100%;height:4px;cursor:row-resize;z-index:10;background:#21262d>`),vw=V(`<div style="border-left:1px solid #30363d;overflow:hidden;position:relative"><div style=position:absolute;top:0;left:0;width:4px;height:100%;cursor:col-resize;z-index:10;background:#21262d>`),yw=V(`<div style=display:flex;flex:1;overflow:hidden><div style=display:flex;flex-direction:column;flex:1;overflow:hidden>`),bw=V(`<div style=position:absolute;top:0;left:0;right:0;bottom:0;z-index:10;overflow:hidden>`),xw=V(`<div style=width:100%;height:100%;display:flex;flex-direction:column;overflow:hidden;background:#0d1117><div style="display:flex;border-bottom:1px solid #30363d;align-items:center"><div style=flex:1></div></div><div style=flex:1;position:relative;overflow:hidden;display:flex;flex-direction:column>`),Sw=V(`<button title=Login style="padding:7px;border-radius:4px;border:none;background:#238636;color:#fff;cursor:pointer;margin:0 16px 0 8px;display:flex;align-items:center">`),Cw=V(`<div style=display:flex;flex-direction:column;flex:1;overflow:hidden><div style=display:flex;flex:1;overflow:hidden>`),ww=b(()=>Qe(()=>import(`./CodePanel-DbI1p64i.js`).then(e=>({default:e.CodePanel})),__vite__mapDeps([0,1,2,3,4,5,6,7]))),Tw=b(()=>Qe(()=>import(`./MapViewer-DRGfQymU.js`).then(e=>({default:e.MapViewer})),__vite__mapDeps([8,1,2,3,4,5,6,7,9]))),Ew={type:1,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1};function Dw(){return new URLSearchParams(window.location.search).get(`shard`)}function Ow(){let e=`${Re()}/room/`,t=window.location.pathname;if(!t.startsWith(e))return{room:null,shard:null,tick:null};let n=t.slice(e.length).split(`/`).filter(Boolean),r=n.length>=2?n[1]:n[0],i=n.length>=2?decodeURIComponent(n[0]):null;if(!r)return{room:null,shard:null,tick:null};let a=r.toUpperCase();if(!Wn(a))return{room:null,shard:null,tick:null};let o=i??Dw(),s=window.location.hash.match(/tick=(\d+)/);return{room:a,shard:o,tick:s?parseInt(s[1],10):null}}function kw(){let e=`${Re()}/map`,t=window.location.pathname;if(t!==e&&!t.startsWith(`${e}/`))return null;let n=t.slice(e.length).replace(/^\//,``);return{shard:(n?decodeURIComponent(n.split(`/`)[0]):null)??Dw()}}function Aw(e){return(()=>{var t=fw();return t.$$click=()=>e.onClick(),C(t,()=>e.children),S(n=>{var r=e.title,i=e.disabled,a=`1px solid ${e.active?`#388bfd`:`#30363d`}`,o=e.active?`#1f3158`:`#21262d`,s=e.disabled?`#484f58`:e.active?`#58a6ff`:`#c9d1d9`,c=e.disabled?`default`:`pointer`;return r!==n.e&&B(t,`title`,n.e=r),i!==n.t&&(t.disabled=n.t=i),a!==n.a&&H(t,`border`,n.a=a),o!==n.o&&H(t,`background`,n.o=o),s!==n.i&&H(t,`color`,n.i=s),c!==n.n&&H(t,`cursor`,n.n=c),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),t})()}function jw(){let e=Ow(),[t,r]=a(e.room??ie(D.room)??`W1N1`),[o,c]=a(e.shard??ie(D.shard)),[l,u]=a(kw()!==null||!e.room),d=()=>ve()?.serverData?.welcomeText??null,[p,h]=a(!1),g=()=>ge()&&l()&&!p()&&d()!==null,[v,y]=a(!1),[b,x]=a(!ge()&&!U()?.badge),[w,T]=a(!1),[E,O]=a(!1);s(()=>{w(),O(!0),Promise.resolve().then(()=>O(!1))}),s(()=>{ge()&&Jf(`view`)}),s(()=>{if(o()!==null||we()!==!1)return;let e=ve()?.serverData?.shards?.[0];e&&c(e)});let[k,A]=a(void 0),[j,M]=a(null),[te,re]=a(null),ae=ie(D.mapZoom),[N,P]=a(e.room&&ae?Number(ae):null),[F,se]=a(null),ce=()=>ve()?.serverData?.historyChunkSize??(we()??!0?20:100),le=e.tick;s(()=>{let e=Ae();if(e===null||le===null)return;let t=le;le=null,Ef(e,ve()?.serverData?.historyKeepTicks,ce()),Of(t)}),s(()=>{th()!==`game`&&(T(!1),y(!1))}),s(()=>{if(m(l))return;let e=Nm(t(),o());J()?history.replaceState(null,``,`${e}#tick=${uf()}`):history.replaceState(null,``,e)});let[ue,de]=a(Se(D.sidebarWidth,300)),[fe,pe]=a(Se(D.sidebarWidth,300)),[me,L]=a(Se(D.consoleHeight,220)),[he,_e]=a(Se(D.consoleHeight,220)),[ye,xe]=a(!1),[Ce,Te]=a(!1),B=()=>ue()<=32,Ee=()=>me()<=32,V=()=>{ue()>32?(pe(ue()),de(32)):de(fe())},De=()=>{me()>32?(_e(me()),L(32)):L(he())},Oe=e=>{e.preventDefault(),xe(!0);let t=e.clientX,n=ue(),r=e=>{let r=e.clientX-t;de(Math.max(32,Math.min(500,n-r)))},i=()=>{xe(!1),ee(D.sidebarWidth,ue()),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},ke=e=>{e.preventDefault(),Te(!0);let t=e.clientY,n=me(),r=e=>{let r=e.clientY-t;L(Math.max(32,Math.min(500,n-r)))},i=()=>{Te(!1),ee(D.consoleHeight,me()),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},je=(e,t)=>{z()?.stores.navigation.navigateTo(e,t)},Me=()=>{let e=kw();if(e){u(!0),e.shard!==null&&c(e.shard),m(J)&&Df();return}let{room:t,shard:n,tick:i}=Ow();t&&(r(t),c(n),u(!1),i===null?m(J)&&Df():le=i)};s(e=>{let t=th();return t===`game`&&e!==void 0&&e!==`game`&&Me(),t});let Ne=e=>{c(e),ne(D.shard,e),history.pushState(null,``,Mm(e))},Pe=e=>{m(J)&&Df(),A(e),u(!0),history.pushState(null,``,Mm(o()))};i(()=>{!Ow().room&&!kw()&&history.replaceState(null,``,Mm(o())),window.addEventListener(`popstate`,Me),n(()=>window.removeEventListener(`popstate`,Me));let e=z()?.stores.navigation;if(e){let t=e.on(`navigation:change`,e=>{e.room!==null&&(m(J)&&Df(),r(e.room),c(e.shard),u(!1),M(null),re(null),ne(D.room,e.room),e.shard?ne(D.shard,e.shard):oe(D.shard),history.pushState(null,``,Nm(e.room,e.shard)))});n(()=>t.dispose())}let i=e=>{if(!pn(e.target)){if(e.key===`o`||e.key===`O`){T(e=>!e),y(!1);return}(e.key===`l`||e.key===`L`)&&Np(),(e.key===`c`||e.key===`C`)&&Pp(),(e.key===`y`||e.key===`Y`)&&Fp(),l()||(e.key===`1`&&Jf(`view`),ge()||(e.key===`2`&&Jf(`flag`),e.key===`3`&&Jf(`build`)),e.key===`m`&&Pe(t()))}};window.addEventListener(`keydown`,i),n(()=>window.removeEventListener(`keydown`,i))});let Fe=()=>(()=>{var e=gw();return C(e,f(_,{get when(){return w()},get children(){return f(ww,{onClose:()=>T(!1)})}}),null),C(e,f(_,{get when(){return!l()},get fallback(){return f(Tw,{get shard(){return o()},get originRoom(){return k()},get initialZoom(){return N()??void 0},onNavigateToRoom:e=>je(e,o()),onHoveredRoomChanged:M,onSelectedRoomChanged:re,onZoomChanged:e=>{P(e),ee(D.mapZoom,e)},onSubscriptionStateChanged:se})},get children(){return[f(vp,{get room(){return t()},get shard(){return o()},onNavigate:je}),(()=>{var e=pw();return e.$$click=()=>Pe(t()),C(e,f(ui,{size:24})),e})(),(()=>{var e=mw();return e.$$click=()=>Lh(t(),o()),C(e,f(fr,{size:24})),e})(),f(_,{get when(){return my().hasHistory},get children(){var e=hw();return e.$$click=()=>J()?Df():Ae()!==null&&Ef(Ae(),ve()?.serverData?.historyKeepTicks,ce()),C(e,f(Or,{size:24})),S(t=>{var n=!J()&&Ae()===null,r=`1px solid ${J()?`#58a6ff`:`#30363d`}`,i=J()?`rgba(31,111,235,0.85)`:`rgba(33,38,45,0.85)`,a=!J()&&Ae()===null?`not-allowed`:`pointer`,o=!J()&&Ae()===null?.4:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&H(e,`border`,t.t=r),i!==t.a&&H(e,`background`,t.a=i),a!==t.o&&H(e,`cursor`,t.o=a),o!==t.i&&H(e,`opacity`,t.i=o),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}})]}}),null),C(e,f(_,{get when(){return g()},get children(){return f(Zv,{get text(){return d()},onClose:()=>h(!0)})}}),null),e})(),Ie=()=>f(_,{get when(){return!ge()},get children(){var e=_w(),t=e.firstChild;return t.$$pointerdown=ke,C(e,f(Dm,{get shard(){return o()},get isCollapsed(){return Ee()},onToggle:De}),null),S(t=>{var n=`${me()}px`,r=Ce()?`none`:`height 0.15s ease`;return n!==t.e&&H(e,`height`,t.e=n),r!==t.t&&H(e,`transition`,t.t=r),t},{e:void 0,t:void 0}),e}}),Le=e=>(()=>{var n=vw(),r=n.firstChild;return r.$$pointerdown=Oe,C(n,f(Cv,{get isCollapsed(){return B()},onToggle:V,get mapMode(){return l()},get hoveredRoomInfo(){return j()},get selectedRoomInfo(){return te()},get room(){return t()},get shard(){return o()},get mapZoom(){return N()},get mapSubsActive(){return F()},onShardChange:Ne}),null),S(t=>{var r=w()?`0`:`${ue()}px`,i=e&&!(E()||ye())?`width 0.15s ease`:`none`;return r!==t.e&&H(n,`width`,t.e=r),i!==t.t&&H(n,`transition`,t.t=i),t},{e:void 0,t:void 0}),n})();return(()=>{var e=xw(),n=e.firstChild,r=n.firstChild,i=n.nextSibling;return C(n,f(No,{}),r),C(n,f(_,{get when(){return!ge()||l()},get children(){return f(kv,{get mapZoom(){return R(()=>!!l())()?N():null},get mapSubsActive(){return R(()=>!!l())()?F():null}})}}),r),C(n,f(Aw,{get title(){return th()===`user`?`Close overview`:`Overview`},get active(){return th()===`user`},get disabled(){return ge()},onClick:()=>th()===`user`?Rh():Th(),get children(){return f(Qr,{size:16})}}),null),C(n,f(_,{get when(){return R(()=>!ge())()&&my().hasMarket},get children(){return f(Aw,{get title(){return th()===`market`?`Close Market`:`Market`},get active(){return th()===`market`},onClick:()=>th()===`market`?Rh():Nh(o(),l()?null:t()),get children(){return f(Ri,{size:16})}})}}),null),C(n,f(_,{get when(){return!ge()},get children(){return f(Aw,{title:`Code Editor`,get active(){return w()},onClick:()=>{th()!==`game`&&Rh(),T(e=>!e),y(!1)},get children(){return f(Ar,{size:16})}})}}),null),C(n,f(_,{get when(){return!ge()},get fallback(){return[f(Aw,{title:`Settings`,get active(){return v()},onClick:()=>{th()!==`game`&&Rh(),y(e=>!e),T(!1)},get children(){return f(Mi,{size:16})}}),(()=>{var e=Sw();return I(e,`click`,be,!0),C(e,f(ii,{size:16})),e})()]},get children(){return f(dy,{onOpenSettings:()=>{th()!==`game`&&Rh(),y(!0),T(!1)},onOpenBadgePicker:()=>x(!0)})}}),null),C(i,f(_,{get when(){return Jt()},get fallback(){return(()=>{var e=Cw(),t=e.firstChild;return C(t,Fe,null),C(t,()=>Le(!0),null),C(e,Ie,null),e})()},get children(){var e=yw(),t=e.firstChild;return C(t,Fe,null),C(t,Ie,null),C(e,()=>Le(!1),null),e}}),null),C(i,f(_,{get when(){return th()===`user`||th()===`profile`||th()===`messages`||th()===`market`||th()===`room-overview`||v()},get children(){var e=bw();return C(e,f(_,{get when(){return th()===`user`},get children(){return f(bx,{})}}),null),C(e,f(_,{get when(){return th()===`profile`},get children(){return f(Ux,{})}}),null),C(e,f(_,{get when(){return th()===`messages`},get children(){return f(DS,{})}}),null),C(e,f(_,{get when(){return th()===`market`},get children(){return f($C,{})}}),null),C(e,f(_,{get when(){return th()===`room-overview`},get children(){return f(iS,{})}}),null),C(e,f(_,{get when(){return v()},get children(){return f(Jv,{onClose:()=>y(!1)})}}),null),e}}),null),C(e,f(xp,{}),null),C(e,f(_,{get when(){return b()},get children(){return f(dw,{get badge(){return U()?.badge??Ew},onClose:()=>x(!1)})}}),null),e})()}N([`click`,`pointerdown`]);var Mw=V(`<div style=width:100%;height:100%>`),{log:Nw}=P(`app`);function Pw(){let e=new URLSearchParams(window.location.search).get(`guest`);return e===null?null:e.startsWith(`http`)?e:re(ae.url)??`https://screeps.com`}function Fw(){let e=my();if(e.isXxscreepsMode||Pw()!==null)return!0;let t=e.isEmbedded?j():re(ae.url);if(e.isDesktop)return!!t;let n=re(ae.token);return!!(t&&n)}function Iw(){let e=()=>pe()===`connected`&&z()!==null,t=my(),n=t.isDesktop,[r,o]=a(Fw());return i(async()=>{try{if(pe()===`idle`&&(await Le().catch(()=>{}),pe()!==`connected`)){if(t.isXxscreepsMode){let e=j();Nw(`xxscreeps mode — auto-connecting as guest to ${e}`),await ke({url:e,auth:`guest`,storage:null}).catch(()=>{})}else if(!t.isEmbedded){let e=Pw();e&&(Nw(`?guest param — auto-connecting as guest to ${e}`),await ke({url:e,auth:`guest`,storage:null}).catch(()=>{}))}}}finally{o(!1)}}),(()=>{var t=Mw();return C(t,(()=>{var t=R(()=>!!e());return()=>t()?f(jw,{}):R(()=>!!r())()?f(To,{}):f(n?Co:Ba,{})})(),null),C(t,f(Do,{}),null),C(t,f(Ao,{}),null),t})()}M()&&(await Oe(),await Qe(()=>import(`./init-BkMwFmiF.js`),__vite__mapDeps([10,3,4])));var Lw=document.getElementById(`root`);if(!Lw)throw Error(`Root element not found`);Ne(()=>f(Iw,{}),Lw);
|