screeps-client 0.7.4 → 0.9.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-Bi3XPaKx.js → CodePanel-y0GapZz1.js} +1 -1
- package/dist/embedded/_client/MapViewer-BWm4-U-8.js +1 -0
- package/dist/embedded/_client/index-CIL3shc9.js +19 -0
- package/dist/embedded/index.html +1 -1
- package/dist/{xxscreeps-mod/_client/CodePanel-C1_2NSto.js → standalone/_client/CodePanel-xr0YpZbf.js} +1 -1
- package/dist/standalone/_client/MapViewer-CLPXCgLE.js +1 -0
- package/dist/standalone/_client/index-V8ZxVMK9.js +19 -0
- package/dist/standalone/index.html +1 -1
- package/dist/{standalone/_client/CodePanel-BU8lj9Lg.js → xxscreeps-mod/_client/CodePanel-Bu4s43Y2.js} +1 -1
- package/dist/xxscreeps-mod/_client/MapViewer-F52NQQmA.js +1 -0
- package/dist/xxscreeps-mod/_client/index-BbGdwuON.js +19 -0
- package/dist/xxscreeps-mod/index.html +1 -1
- package/package.json +1 -1
- package/dist/embedded/_client/MapViewer-PlEeWriH.js +0 -1
- package/dist/embedded/_client/index-mOFrrLBB.js +0 -19
- package/dist/standalone/_client/MapViewer-pnfc3Uhb.js +0 -1
- package/dist/standalone/_client/index-C0afJplS.js +0 -19
- package/dist/xxscreeps-mod/_client/MapViewer-BIb_DMMc.js +0 -1
- package/dist/xxscreeps-mod/_client/index-DKLACUsG.js +0 -19
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./decompress-DIM550rx.js","./rolldown-runtime-QTnfLwEv.js","./CodePanel-Bu4s43Y2.js","./vendor-codemirror-B_kaIH0M.js","./MapViewer-F52NQQmA.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,b as s,c,d as l,f as u,g as d,h as f,l as p,m,p as h,s as g,u as _,v,w as y,x as b,y as x}from"./vendor-codemirror-B_kaIH0M.js";import{n as S,t as C}from"./decompress-DIM550rx.js";import{a as w,c as T,d as E,f as D,h as O,i as k,l as ee,m as te,n as ne,o as A,p as re,r as ie,s as ae,t as oe,u as j}from"./vendor-pixi-DCKL8Yf2.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 se=new Set([`className`,`value`,`readOnly`,`noValidate`,`formNoValidate`,`isMap`,`noModule`,`playsInline`,`adAuctionHeaders`,`allowFullscreen`,`browsingTopics`,`defaultChecked`,`defaultMuted`,`defaultSelected`,`disablePictureInPicture`,`disableRemotePlayback`,`preservesPitch`,`shadowRootClonable`,`shadowRootCustomElementRegistry`,`shadowRootDelegatesFocus`,`shadowRootSerializable`,`sharedStorageWritable`,...`allowfullscreen.async.alpha.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.hidden.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.adauctionheaders.browsingtopics.credentialless.defaultchecked.defaultmuted.defaultselected.defer.disablepictureinpicture.disableremoteplayback.preservespitch.shadowrootclonable.shadowrootcustomelementregistry.shadowrootdelegatesfocus.shadowrootserializable.sharedstoragewritable`.split(`.`)]),ce=new Set([`innerHTML`,`textContent`,`innerText`,`children`]),le=Object.assign(Object.create(null),{className:`class`,htmlFor:`for`}),ue=Object.assign(Object.create(null),{class:`className`,novalidate:{$:`noValidate`,FORM:1},formnovalidate:{$:`formNoValidate`,BUTTON:1,INPUT:1},ismap:{$:`isMap`,IMG:1},nomodule:{$:`noModule`,SCRIPT:1},playsinline:{$:`playsInline`,VIDEO:1},readonly:{$:`readOnly`,INPUT:1,TEXTAREA:1},adauctionheaders:{$:`adAuctionHeaders`,IFRAME:1},allowfullscreen:{$:`allowFullscreen`,IFRAME:1},browsingtopics:{$:`browsingTopics`,IMG:1},defaultchecked:{$:`defaultChecked`,INPUT:1},defaultmuted:{$:`defaultMuted`,AUDIO:1,VIDEO:1},defaultselected:{$:`defaultSelected`,OPTION:1},disablepictureinpicture:{$:`disablePictureInPicture`,VIDEO:1},disableremoteplayback:{$:`disableRemotePlayback`,AUDIO:1,VIDEO:1},preservespitch:{$:`preservesPitch`,AUDIO:1,VIDEO:1},shadowrootclonable:{$:`shadowRootClonable`,TEMPLATE:1},shadowrootdelegatesfocus:{$:`shadowRootDelegatesFocus`,TEMPLATE:1},shadowrootserializable:{$:`shadowRootSerializable`,TEMPLATE:1},sharedstoragewritable:{$:`sharedStorageWritable`,IFRAME:1,IMG:1}});function de(e,t){let n=ue[e];return typeof n==`object`?n[t]?n.$:void 0:n}var fe=new Set([`beforeinput`,`click`,`dblclick`,`contextmenu`,`focusin`,`focusout`,`input`,`keydown`,`keyup`,`mousedown`,`mousemove`,`mouseout`,`mouseover`,`mouseup`,`pointerdown`,`pointermove`,`pointerout`,`pointerover`,`pointerup`,`touchend`,`touchmove`,`touchstart`]),pe=new Set(`altGlyph.altGlyphDef.altGlyphItem.animate.animateColor.animateMotion.animateTransform.circle.clipPath.color-profile.cursor.defs.desc.ellipse.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.filter.font.font-face.font-face-format.font-face-name.font-face-src.font-face-uri.foreignObject.g.glyph.glyphRef.hkern.image.line.linearGradient.marker.mask.metadata.missing-glyph.mpath.path.pattern.polygon.polyline.radialGradient.rect.set.stop.svg.switch.symbol.text.textPath.tref.tspan.use.view.vkern`.split(`.`)),me={xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`},M=e=>d(()=>e());function he(e,t,n){let r=n.length,i=t.length,a=r,o=0,s=0,c=t[i-1].nextSibling,l=null;for(;o<i||s<a;){if(t[o]===n[s]){o++,s++;continue}for(;t[i-1]===n[a-1];)i--,a--;if(i===o){let t=a<r?s?n[s-1].nextSibling:n[a-s]:c;for(;s<a;)e.insertBefore(n[s++],t)}else if(a===s)for(;o<i;)(!l||!l.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[a-1]&&n[s]===t[i-1]){let r=t[--i].nextSibling;e.insertBefore(n[s++],t[o++].nextSibling),e.insertBefore(n[--a],r),t[i]=n[a]}else{if(!l){l=new Map;let e=s;for(;e<a;)l.set(n[e],e++)}let r=l.get(t[o]);if(r!=null)if(s<r&&r<a){let c=o,u=1,d;for(;++c<i&&c<a&&!((d=l.get(t[c]))==null||d!==r+u);)u++;if(u>r-s){let i=t[o];for(;s<r;)e.insertBefore(n[s++],i)}else e.replaceChild(n[s++],t[o++])}else o++;else t[o++].remove()}}}var ge=`_$DX_DELEGATE`;function _e(e,t,n,r={}){if(!t)throw Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");let i;return v(r=>{i=r,t===document?e():R(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{i(),t.textContent=``}}function N(e,t,n,i){let a,o=()=>{if(De())throw Error(`Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.`);let t=i?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`template`):document.createElement(`template`);return t.innerHTML=e,n?t.content.firstChild.firstChild:i?t.firstChild:t.content.firstChild},s=t?()=>r(()=>document.importNode(a||=o(),!0)):()=>(a||=o()).cloneNode(!0);return s.cloneNode=s,s}function P(e,t=window.document){let n=t[ge]||(t[ge]=new Set);for(let r=0,i=e.length;r<i;r++){let i=e[r];n.has(i)||(n.add(i),t.addEventListener(i,je))}}function F(e,t,n){De(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function ve(e,t,n,r){De(e)||(r==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r))}function ye(e,t,n){De(e)||(n?e.setAttribute(t,``):e.removeAttribute(t))}function be(e,t){De(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function xe(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){let r=n[0];e.addEventListener(t,n[0]=t=>r.call(e,n[1],t))}else e.addEventListener(t,n,typeof n!=`function`&&n)}function Se(e,t,n={}){let r=Object.keys(t||{}),i=Object.keys(n),a,o;for(a=0,o=i.length;a<o;a++){let r=i[a];!r||r===`undefined`||t[r]||(ke(e,r,!1),delete n[r])}for(a=0,o=r.length;a<o;a++){let i=r[a],o=!!t[i];!i||i===`undefined`||n[i]===o||!o||(ke(e,i,!0),n[i]=o)}return n}function I(e,t,n){if(!t)return n?F(e,`style`):t;let r=e.style;if(typeof t==`string`)return r.cssText=t;typeof n==`string`&&(r.cssText=n=void 0),n||={},t||={};let i,a;for(a in n)t[a]??r.removeProperty(a),delete n[a];for(a in t)i=t[a],i!==n[a]&&(r.setProperty(a,i),n[a]=i);return n}function L(e,t,n){n==null?e.style.removeProperty(t):e.style.setProperty(t,n)}function Ce(e,t={},n,r){let i={};return r||o(()=>i.children=Me(e,t.children,i.children)),o(()=>typeof t.ref==`function`&&we(t.ref,e)),o(()=>Te(e,t,n,!0,i,!0)),i}function we(e,t,n){return r(()=>e(t,n))}function R(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return Me(e,t,r,n);o(r=>Me(e,t(),r,n),r)}function Te(e,t,n,r,i={},a=!1){t||={};for(let r in i)if(!(r in t)){if(r===`children`)continue;i[r]=Ae(e,r,null,i[r],n,a,t)}for(let o in t){if(o===`children`){r||Me(e,t.children);continue}let s=t[o];i[o]=Ae(e,o,s,i[o],n,a,t)}}function Ee(e){let t,r,i=De();if(!i||!(t=n.registry.get(r=Ie()))){if(i)throw n.done=!0,Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${r}\n${e?e().outerHTML:``}`);return e()}return n.completed&&n.completed.add(t),n.registry.delete(r),t}function De(e){return!!n.context&&!n.done&&(!e||e.isConnected)}function Oe(e){return e.toLowerCase().replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function ke(e,t,n){let r=t.trim().split(/\s+/);for(let t=0,i=r.length;t<i;t++)e.classList.toggle(r[t],n)}function Ae(e,t,n,r,i,a,o){let s,c,l,u,d;if(t===`style`)return I(e,n,r);if(t===`classList`)return Se(e,n,r);if(n===r)return r;if(t===`ref`)a||n(e);else if(t.slice(0,3)===`on:`){let i=t.slice(3);r&&e.removeEventListener(i,r,typeof r!=`function`&&r),n&&e.addEventListener(i,n,typeof n!=`function`&&n)}else if(t.slice(0,10)===`oncapture:`){let i=t.slice(10);r&&e.removeEventListener(i,r,!0),n&&e.addEventListener(i,n,!0)}else if(t.slice(0,2)===`on`){let i=t.slice(2).toLowerCase(),a=fe.has(i);if(!a&&r){let t=Array.isArray(r)?r[0]:r;e.removeEventListener(i,t)}(a||n)&&(xe(e,i,n,a),a&&P([i]))}else if(t.slice(0,5)===`attr:`)F(e,t.slice(5),n);else if(t.slice(0,5)===`bool:`)ye(e,t.slice(5),n);else if((d=t.slice(0,5)===`prop:`)||(l=ce.has(t))||!i&&((u=de(t,e.tagName))||(c=se.has(t)))||(s=e.nodeName.includes(`-`)||`is`in o)){if(d)t=t.slice(5),c=!0;else if(De(e))return n;t===`class`||t===`className`?be(e,n):s&&!c&&!l?e[Oe(t)]=n:e[u||t]=n}else{let r=i&&t.indexOf(`:`)>-1&&me[t.split(`:`)[0]];r?ve(e,r,t,n):F(e,le[t]||t,n)}return n}function je(e){if(n.registry&&n.events&&n.events.find(([t,n])=>n===e))return;let t=e.target,r=`$$${e.type}`,i=e.target,a=e.currentTarget,o=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),s=()=>{let n=t[r];if(n&&!t.disabled){let i=t[`${r}Data`];if(i===void 0?n.call(t,e):n.call(t,i,e),e.cancelBubble)return}return t.host&&typeof t.host!=`string`&&!t.host._$host&&t.contains(e.target)&&o(t.host),!0},c=()=>{for(;s()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),n.registry&&!n.done&&(n.done=_$HY.done=!0),e.composedPath){let n=e.composedPath();o(n[0]);for(let e=0;e<n.length-2&&(t=n[e],s());e++){if(t._$host){t=t._$host,c();break}if(t.parentNode===a)break}}else c();o(i)}function Me(e,t,n,r,i){let a=De(e);if(a){!n&&(n=[...e.childNodes]);let t=[];for(let e=0;e<n.length;e++){let r=n[e];r.nodeType===8&&r.data.slice(0,2)===`!$`?r.remove():t.push(r)}n=t}for(;typeof n==`function`;)n=n();if(t===n)return n;let s=typeof t,c=r!==void 0;if(e=c&&n[0]&&n[0].parentNode||e,s===`string`||s===`number`){if(a||s===`number`&&(t=t.toString(),t===n))return n;if(c){let i=n[0];i&&i.nodeType===3?i.data!==t&&(i.data=t):i=document.createTextNode(t),n=Fe(e,n,r,i)}else n=n!==``&&typeof n==`string`?e.firstChild.data=t:e.textContent=t}else if(t==null||s===`boolean`){if(a)return n;n=Fe(e,n,r)}else if(s===`function`)return o(()=>{let i=t();for(;typeof i==`function`;)i=i();n=Me(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let s=[],l=n&&Array.isArray(n);if(Ne(s,t,n,i))return o(()=>n=Me(e,s,n,r,!0)),()=>n;if(a){if(!s.length)return n;if(r===void 0)return n=[...e.childNodes];let t=s[0];if(t.parentNode!==e)return n;let i=[t];for(;(t=t.nextSibling)!==r;)i.push(t);return n=i}if(s.length===0){if(n=Fe(e,n,r),c)return n}else l?n.length===0?Pe(e,s,r):he(e,n,s):(n&&Fe(e),Pe(e,s));n=s}else if(t.nodeType){if(a&&t.parentNode)return n=c?[t]:t;if(Array.isArray(n)){if(c)return n=Fe(e,n,r,t);Fe(e,n,null,t)}else n==null||n===``||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}else console.warn(`Unrecognized value. Skipped inserting`,t);return n}function Ne(e,t,n,r){let i=!1;for(let a=0,o=t.length;a<o;a++){let o=t[a],s=n&&n[e.length],c;if(!(o==null||o===!0||o===!1))if((c=typeof o)==`object`&&o.nodeType)e.push(o);else if(Array.isArray(o))i=Ne(e,o,s)||i;else if(c===`function`)if(r){for(;typeof o==`function`;)o=o();i=Ne(e,Array.isArray(o)?o:[o],Array.isArray(s)?s:[s])||i}else e.push(o),i=!0;else{let t=String(o);s&&s.nodeType===3&&s.data===t?e.push(s):e.push(document.createTextNode(t))}}return i}function Pe(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function Fe(e,t,n,r){if(n===void 0)return e.textContent=``;let i=r||document.createTextNode(``);if(t.length){let r=!1;for(let a=t.length-1;a>=0;a--){let o=t[a];if(i!==o){let t=o.parentNode===e;!r&&!a?t?e.replaceChild(i,o):e.insertBefore(i,n):t&&o.remove()}else r=!0}}else e.insertBefore(i,n);return[i]}function Ie(){return n.getNextContextId()}var Le=`http://www.w3.org/2000/svg`;function Re(e,t=!1,n=void 0){return t?document.createElementNS(Le,e):document.createElement(e,{is:n})}function ze(e,t){let i=d(e);return d(()=>{let e=i();switch(typeof e){case`function`:return Object.assign(e,{[g]:!0}),r(()=>e(t));case`string`:let i=pe.has(e),a=n.context?Ee():Re(e,i,r(()=>t.is));return Ce(a,t,i),a}})}function Be(e){let[,n]=t(e,[`component`]);return ze(()=>e.component,n)}var Ve=class e{fn;constructor(e){this.fn=e}static create(t){return t===!0?new e(console.debug.bind(console)):typeof t==`function`?new e(t):new e(null)}child(t){if(!this.fn)return this;let n=this.fn;return new e((...e)=>n(`[screeps:${t}]`,...e))}log(...e){this.fn?.(...e)}};function He(e){return{signin:(t,n)=>e.request(`POST`,`/api/auth/signin`,{email:t,password:n}),me:()=>e.request(`GET`,`/api/auth/me`),queryToken:t=>e.request(`GET`,`/api/auth/query-token`,{token:t}),steamTicket:(t,n)=>e.request(`POST`,`/api/auth/steam-ticket`,{ticket:t,...n==null?{}:{useNativeAuth:n}}),modInfo:()=>e.request(`GET`,`/api/authmod`)}}function Ue(e){return{list:()=>e.request(`GET`,`/api/game/power-creeps/list`),create:(t,n)=>e.request(`POST`,`/api/game/power-creeps/create`,{name:t,className:n}),delete:t=>e.request(`POST`,`/api/game/power-creeps/delete`,{id:t}),cancelDelete:t=>e.request(`POST`,`/api/game/power-creeps/cancel-delete`,{id:t}),upgrade:(t,n)=>e.request(`POST`,`/api/game/power-creeps/upgrade`,{id:t,powers:n}),rename:(t,n)=>e.request(`POST`,`/api/game/power-creeps/rename`,{id:t,name:n}),experimentation:()=>e.request(`POST`,`/api/game/power-creeps/experimentation`)}}function z(e,t){return t&&(e.shard=t),e}function We(e,t){return{roomTerrain:(t,n)=>e.request(`GET`,`/api/game/room-terrain`,z({room:t,encoded:1},n)),roomObjects:(t,n)=>e.request(`GET`,`/api/game/room-objects`,z({room:t},n)),roomDecorations:t?()=>Promise.resolve(t):(t,n)=>e.request(`GET`,`/api/game/room-decorations`,z({room:t},n)),roomStatus:(t,n)=>e.request(`GET`,`/api/game/room-status`,z({room:t},n)),roomOverview:(t,n=8,r)=>e.request(`GET`,`/api/game/room-overview`,z({room:t,interval:n},r)),time:t=>e.request(`GET`,`/api/game/time`,z({},t)),worldSize:t=>e.request(`GET`,`/api/game/world-size`,z({},t)),mapStats:(t,n,r)=>e.request(`POST`,`/api/game/map-stats`,z({rooms:t,statName:n},r)),roomsTerrain:(t,n)=>{let r=new URLSearchParams({encoded:`true`});return n&&r.set(`shard`,n),e.request(`POST`,`/api/game/rooms?${r}`,{rooms:t})},createFlag:(t,n,r,i,a,o,s)=>e.request(`POST`,`/api/game/create-flag`,z({room:t,x:n,y:r,name:i,color:a,secondaryColor:o},s)),genUniqueFlagName:()=>e.request(`POST`,`/api/game/gen-unique-flag-name`),checkUniqueFlagName:t=>e.request(`POST`,`/api/game/check-unique-flag-name`,{name:t}),changeFlagColor:(t,n,r,i)=>e.request(`POST`,`/api/game/change-flag-color`,{room:t,name:n,color:r,secondaryColor:i}),removeFlag:(t,n)=>e.request(`POST`,`/api/game/remove-flag`,{room:t,name:n}),genUniqueObjectName:(t,n)=>e.request(`POST`,`/api/game/gen-unique-object-name`,z({type:t},n)),checkUniqueObjectName:(t,n,r)=>e.request(`POST`,`/api/game/check-unique-object-name`,z({type:t,name:n},r)),placeSpawn:(t,n,r,i,a)=>e.request(`POST`,`/api/game/place-spawn`,z({room:t,x:n,y:r,...i?{name:i}:{}},a)),createConstruction:(t,n,r,i,a,o)=>e.request(`POST`,`/api/game/create-construction`,z({room:t,x:n,y:r,structureType:i,...a?{name:a}:{}},o)),removeConstructionSite:(t,n,r)=>e.request(`POST`,`/api/game/add-object-intent`,z({_id:`room`,room:t,name:`removeConstructionSite`,intent:n.map(e=>({id:e,roomName:t}))},r)),addObjectIntent:(t,n,r,i,a)=>e.request(`POST`,`/api/game/add-object-intent`,z({_id:t,room:n,name:r,intent:i},a)),addGlobalIntent:(t,n)=>e.request(`POST`,`/api/game/add-global-intent`,{name:t,intent:n}),roomHistory:(t,n,r)=>r?e.request(`GET`,`/room-history/${encodeURIComponent(r)}/${encodeURIComponent(t)}/${n}.json`):e.request(`GET`,`/room-history`,{room:t,time:n}),setNotifyWhenAttacked:(t,n)=>e.request(`POST`,`/api/game/set-notify-when-attacked`,{_id:t,enabled:n}),createInvader:(t,n,r,i,a,o)=>e.request(`POST`,`/api/game/create-invader`,{room:t,x:n,y:r,size:i,type:a,...o==null?{}:{boosted:o}}),removeInvader:t=>e.request(`POST`,`/api/game/remove-invader`,{_id:t}),tick:()=>e.request(`GET`,`/api/game/tick`),powerCreeps:Ue(e),market:{ordersIndex:t=>e.request(`GET`,`/api/game/market/orders-index`,z({},t)),myOrders:()=>e.request(`GET`,`/api/game/market/my-orders`),orders:(t,n)=>e.request(`GET`,`/api/game/market/orders`,z({resourceType:t},n)),stats:(t,n)=>e.request(`GET`,`/api/game/market/stats`,z({resourceType:t},n))},shards:{info:()=>e.request(`GET`,`/api/game/shards/info`)}}}function Ge(e){return{send:(t,n)=>e.request(`POST`,`/api/user/messages/send`,{respondent:t,text:n}),list:t=>e.request(`GET`,`/api/user/messages/list`,{respondent:t}),index:()=>e.request(`GET`,`/api/user/messages/index`),markRead:t=>e.request(`POST`,`/api/user/messages/mark-read`,{id:t}),unreadCount:()=>e.request(`GET`,`/api/user/messages/unread-count`)}}function Ke(e,t){return t&&(e.shard=t),e}function qe(e){return{branches:()=>e.request(`GET`,`/api/user/branches`),code:{get:t=>e.request(`GET`,`/api/user/code`,t?{branch:t}:{}),set:(t,n)=>e.request(`POST`,`/api/user/code`,{branch:t,modules:n,_hash:Date.now()})},memory:{get:(t,n)=>e.request(`GET`,`/api/user/memory`,Ke({path:t},n)),set:(t,n,r)=>e.request(`POST`,`/api/user/memory`,Ke({path:t,value:n},r)),segment:{get:(t,n)=>e.request(`GET`,`/api/user/memory-segment`,Ke({segment:t},n)),set:(t,n,r)=>e.request(`POST`,`/api/user/memory-segment`,Ke({segment:t,data:n},r))}},console:(t,n)=>e.request(`POST`,`/api/user/console`,Ke({expression:t},n)),stats:t=>e.request(`GET`,`/api/user/stats`,{interval:t}),rooms:t=>e.request(`GET`,`/api/user/rooms`,{id:t}),overview:(t,n)=>e.request(`GET`,`/api/user/overview`,{interval:t,statName:n}),worldStatus:()=>e.request(`GET`,`/api/user/world-status`),worldStartRoom:t=>e.request(`GET`,`/api/user/world-start-room`,Ke({},t)),find:t=>e.request(`GET`,`/api/user/find`,t),moneyHistory:t=>e.request(`GET`,`/api/user/money-history`,t==null?{}:{page:t}),respawn:()=>e.request(`POST`,`/api/user/respawn`),respawnProhibitedRooms:()=>e.request(`GET`,`/api/user/respawn-prohibited-rooms`),badge:t=>e.request(`POST`,`/api/user/badge`,{badge:t}),setActiveBranch:(t,n)=>e.request(`POST`,`/api/user/set-active-branch`,{activeName:t,branch:n}),cloneBranch:(t,n,r)=>e.request(`POST`,`/api/user/clone-branch`,{newName:t,...n?{branch:n}:{},...r==null?{}:{defaultModules:r}}),deleteBranch:t=>e.request(`POST`,`/api/user/delete-branch`,{branch:t}),notifyPrefs:t=>e.request(`POST`,`/api/user/notify-prefs`,t),tutorialDone:()=>e.request(`POST`,`/api/user/tutorial-done`),email:t=>e.request(`POST`,`/api/user/email`,{email:t}),setSteamVisible:t=>e.request(`POST`,`/api/user/set-steam-visible`,{visible:t}),password:(t,n)=>e.request(`POST`,`/api/user/password`,{password:t,...n==null?{}:{oldPassword:n}}),messages:Ge(e)}}function Je(e){return{list:(t=10,n=`world`,r=0,i)=>e.request(`GET`,`/api/leaderboard/list`,{limit:t,mode:n,offset:r,season:i}),find:(t,n=`world`,r=``)=>e.request(`GET`,`/api/leaderboard/find`,{username:t,mode:n,season:r}),seasons:()=>e.request(`GET`,`/api/leaderboard/seasons`)}}function Ye(e){return{pvp:(t=100)=>e.request(`GET`,`/api/experimental/pvp`,{interval:t}),nukes:()=>e.request(`GET`,`/api/experimental/nukes`)}}function Xe(e){return{checkEmail:t=>e.request(`GET`,`/api/register/check-email`,{email:t}),checkUsername:t=>e.request(`GET`,`/api/register/check-username`,{username:t}),setUsername:(t,n)=>e.request(`POST`,`/api/register/set-username`,{username:t,...n==null?{}:{email:n}}),submit:(t,n,r,i)=>e.request(`POST`,`/api/register/submit`,{username:t,email:n,password:r,...i==null?{}:{modules:i}})}}var Ze=class extends EventTarget{baseUrl;authStrategy;logger;serverPassword;token=null;rateLimits=new Map;authenticating=!1;auth;register;game;user;leaderboard;experimental;constructor(e){super(),this.baseUrl=e.url.endsWith(`/`)?e.url:`${e.url}/`,this.authStrategy=e.auth,this.logger=e.logger??Ve.create(),this.serverPassword=e.serverPassword??null,this.auth=He(this),this.register=Xe(this),this.game=We(this,e.decorationsMock),this.user=qe(this),this.leaderboard=Je(this),this.experimental=Ye(this)}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}on(e,t){let n=e=>t(e.detail);return this.addEventListener(e,n),{dispose:()=>{this.removeEventListener(e,n)}}}async authenticate(){this.logger.log(`authenticate`),this.authenticating=!0;try{this.token=await this.authStrategy.authenticate(this),this.logger.log(`authenticated`)}finally{this.authenticating=!1}}setToken(e){this.token=e}async request(e,t,n,r=!1){this.logger.log(e,t);let i=new URL(t.startsWith(`/`)?t.slice(1):t,this.baseUrl),a={};this.token&&(a[`X-Token`]=this.token,a[`X-Username`]=this.token),this.serverPassword&&(a[`X-Server-Password`]=this.serverPassword);let o={method:e,headers:a};if(e===`GET`&&n)for(let[e,t]of Object.entries(n))t!=null&&i.searchParams.set(e,String(t));else n&&(a[`Content-Type`]=`application/json`,o.body=JSON.stringify(n));let s=await fetch(i.toString(),o),c=s.headers.get(`x-token`);if(c&&(this.token=c,this.emit(`http:tokenRefresh`,{token:c})),this.updateRateLimit(t,s),s.status===401&&!r&&!this.authenticating)return await this.authenticate(),this.request(e,t,n,!0);if(!s.ok&&s.status!==304){let n=``;try{n=await s.text()}catch{}let r=Error(`HTTP ${s.status}: ${n}`);throw this.emit(`http:error`,{method:e,path:t,status:s.status,error:r}),r}this.emit(`http:success`,{method:e,path:t,status:s.status});let l=await s.json();if(typeof l.error==`string`){let n=Error(`Screeps API error: ${l.error}`);throw this.emit(`http:error`,{method:e,path:t,status:s.status,error:n}),n}return typeof l.data==`string`&&l.data.startsWith(`gz:`)&&(l.data=await C(l.data)),l}updateRateLimit(e,t){let n=t.headers.get(`x-ratelimit-limit`),r=t.headers.get(`x-ratelimit-remaining`),i=t.headers.get(`x-ratelimit-reset`);n&&r&&i&&this.rateLimits.set(e,{limit:parseInt(n,10),remaining:parseInt(r,10),reset:parseInt(i,10)})}};async function Qe(e){let t=typeof e==`string`?e:e.data;if(t.startsWith(`gz:`)&&(t=JSON.stringify(await S(t))),t.startsWith(`[`)){let[e,n]=JSON.parse(t);return{kind:`channel`,message:{channel:e,data:n}}}let[n,...r]=t.split(` `);switch(n){case`auth`:return{kind:`server`,command:{type:`auth`,status:r[0],token:r[1]}};case`time`:return{kind:`server`,command:{type:`time`,time:parseInt(r[0],10)}};case`protocol`:return{kind:`server`,command:{type:`protocol`,protocol:parseInt(r[0],10)}};case`package`:return{kind:`server`,command:{type:`package`,package:parseInt(r[0],10)}};default:throw Error(`Unknown server command: ${n}`)}}var $e=class{wsUrl;WS;logger;ws=null;token=null;authed=!1;_connected=!1;reconnecting=!1;authSub=null;queue=[];subs=new Map;listeners=new Map;MAX_RETRIES=10;MAX_DELAY_MS=6e4;_intentionalClose=!1;constructor(e){let t=e.url.replace(/^http/,`ws`).replace(/\/$/,``);this.wsUrl=`${t}/socket/websocket`,this.WS=e.WebSocket??globalThis.WebSocket,this.logger=e.logger??Ve.create()}get isConnected(){return this._connected}setToken(e){this.token=e}connect(e){return this.logger.log(`connect`,this.wsUrl),this.reconnecting||(this._intentionalClose=!1),this.token=e,this.authSub?.dispose(),this.authSub=null,new Promise((e,t)=>{this.ws=new this.WS(this.wsUrl),this.ws.onopen=()=>{this.logger.log(`WebSocket opened`),this._connected=!0,this.reconnecting=!1,this.rawSend(`auth ${this.token}`),this.authSub=this.once(`auth`,n=>{let r=n;if(r.status===`ok`){for(this.logger.log(`auth ok`),this.authed=!0,r.token&&(this.token=r.token,this.emit(`socket:tokenRefresh`,{token:r.token}));this.queue.length;)this.rawSend(this.queue.shift());this.emit(`connected`,{}),e()}else this.logger.log(`auth failed`),t(Error(`WebSocket auth failed`))})},this.ws.onclose=()=>{this.logger.log(`WebSocket closed`),this._connected=!1,this.authed=!1,this.authSub?.dispose(),this.authSub=null,this.emit(`disconnected`,{willReconnect:this.reconnecting}),this.scheduleReconnect()},this.ws.onerror=e=>{this._connected||t(e)},this.ws.onmessage=e=>{this.handleMessage(e).catch(t=>{let n=typeof e.data==`string`?e.data.slice(0,200):`(binary)`;this.logger.log(`message parse error`,t instanceof Error?t.stack??t.message:String(t),`raw:`,n),this.emit(`socket:error`,t instanceof Error?t:Error(String(t)))})}})}disconnect(){this.logger.log(`disconnect`),this._intentionalClose=!0,this.reconnecting=!1,this.ws?.close(),this.ws=null,this._connected=!1,this.authed=!1,this.queue.length=0}activeSubs(){return Array.from(this.subs.entries()).map(([e,t])=>`${e}(${t})`).join(`, `)||`(none)`}subscribe(e){let t=this.subs.get(e)??0;return this.subs.set(e,t+1),t===0?(this.logger.log(`subscribe`,e,`active:`,this.activeSubs()),this.sendOrQueue(`subscribe ${e}`)):this.logger.log(`subscribe`,e,`(refs: ${t+1})`,`active:`,this.activeSubs()),{dispose:()=>this.doUnsubscribe(e)}}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),{dispose:()=>{this.listeners.get(e)?.delete(t)}}}once(e,t){let n=this.on(e,e=>{n.dispose(),t(e)});return n}doUnsubscribe(e){let t=this.subs.get(e)??0;t<=1?(this.subs.delete(e),this.authed&&this.rawSend(`unsubscribe ${e}`),this.logger.log(`unsubscribe`,e,`active:`,this.activeSubs())):(this.subs.set(e,t-1),this.logger.log(`unsubscribe`,e,`(refs: ${t-1})`,`active:`,this.activeSubs()))}rawSend(e){this.ws?.send(e)}sendOrQueue(e){this.authed?this.rawSend(e):this.queue.push(e)}emit(e,t){this.listeners.get(e)?.forEach(n=>{try{n(t)}catch(t){this.logger.log(`listener error on channel`,e,t instanceof Error?t.stack??t.message:String(t))}})}async handleMessage(e){let t=await Qe(e);t.kind===`server`?this.emit(t.command.type,t.command):this.emit(t.message.channel,t.message.data)}async scheduleReconnect(){if(this.reconnecting||this._intentionalClose)return;if(!this.token){this.reconnecting=!1;return}this.reconnecting=!0;let e=0;for(;e<this.MAX_RETRIES&&this.reconnecting&&!this._intentionalClose;){let t=Math.min(2**e*100,this.MAX_DELAY_MS);if(this.logger.log(`reconnect attempt ${e+1}/${this.MAX_RETRIES} in ${t}ms`),await new Promise(e=>setTimeout(e,t)),!this.reconnecting||this._intentionalClose)return;try{if(await this.connect(this.token),this._intentionalClose){this.ws?.close(),this.ws=null;return}for(let e of this.subs.keys())this.rawSend(`subscribe ${e}`);return}catch{e++}}this.reconnecting=!1,e>=this.MAX_RETRIES&&!this._intentionalClose&&this.emit(`socket:error`,Error(`WebSocket reconnection failed after ${this.MAX_RETRIES} retries`))}},et=class{memory=new Map;storage;namespace;constructor(e,t){this.namespace=e,this.storage=t}memKey(e){return`${this.namespace}/${e}`}get(e){let t=this.memory.get(this.memKey(e));if(t){if(t.expires!==void 0&&Date.now()>t.expires){this.memory.delete(this.memKey(e));return}return t.data}}set(e,t,n){this.memory.set(this.memKey(e),{data:t,expires:n===void 0?void 0:Date.now()+n})}delete(e){this.memory.delete(this.memKey(e))}async getPersistent(e){return this.storage?this.storage.get(`${this.namespace}/${e}`):null}async setPersistent(e,t){this.storage&&await this.storage.set(`${this.namespace}/${e}`,t)}async deletePersistent(e){this.storage&&await this.storage.delete(`${this.namespace}/${e}`)}clearMemory(){this.memory.clear()}async clearPersistent(){this.storage&&await this.storage.clear()}async clearAll(){this.clearMemory(),await this.clearPersistent()}},tt=class extends EventTarget{logger;constructor(e){super(),this.logger=e??Ve.create()}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}on(e,t){this.logger.log(`on "${e}"`);let n=e=>t(e.detail);return this.addEventListener(e,n),{dispose:()=>{this.logger.log(`off "${e}"`),this.removeEventListener(e,n)}}}},nt=function(e){return e[e.Plain=0]=`Plain`,e[e.Wall=1]=`Wall`,e[e.Swamp=2]=`Swamp`,e}({}),rt=class e{raw;constructor(e){this.raw=e}static fromEncodedString(t){let n=new Uint8Array(2500);for(let e=0;e<2500;e++){let r=parseInt(t[e],10);n[e]=r===3?1:r}return new e(n)}get(e,t){return this.raw[t*50+e]}};function it(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function at(e,t){let n={...e};for(let e in t){let r=t[e];r===null?delete n[e]:it(r)&&it(n[e])?n[e]=at(n[e],r):n[e]=r}return n}var ot=class extends tt{http;socket;cache;roomObjects=new Map;roomUsers=new Map;roomSubCount=new Map;lastFlagsString=new Map;parseFlagsString(e,t){if(!e||e.length===0)return[];let n=[],r=e.split(`|`);for(let e of r){let r=e.split(`~`);if(r.length!==5)continue;let[i,a,o,s,c]=r,l=parseInt(a,10),u=parseInt(o,10),d=parseInt(s,10),f=parseInt(c,10);isNaN(l)||isNaN(u)||isNaN(d)||isNaN(f)||n.push({_id:i,type:`flag`,room:t,name:i,x:d,y:f,color:l,secondaryColor:u})}return n}constructor(e,t,n,r){super(r),this.http=e,this.socket=t,this.cache=n}async terrain(e,t){let n=`terrain/${t}/${e}`,r=this.cache.get(n);if(r)return this.logger.log(`terrain`,e,t,`(memory cache hit)`),r;let i=await this.cache.getPersistent(n);if(i){this.logger.log(`terrain`,e,t,`(persistent cache hit)`);let r=new rt(i);return this.cache.set(n,r),r}this.logger.log(`terrain`,e,t,`(fetching)`);let a=(await this.http.game.roomTerrain(e,t??void 0)).terrain[0];if(!a)throw Error(`No terrain data for room ${e} shard ${t}`);let o=rt.fromEncodedString(a.terrain);return this.cache.set(n,o),await this.cache.setPersistent(n,o.raw),this.emit(`room:terrainavailable`,{room:e,shard:t,terrain:o}),o}async terrainBulk(e,t){let n=new Map,r=[];for(let i of e){let e=this.cache.get(`terrain/${t}/${i}`);e?n.set(i,e):r.push(i)}if(r.length===0)return n;let i=[];if(await Promise.all(r.map(async e=>{let r=`terrain/${t}/${e}`,a=await this.cache.getPersistent(r);if(a){let t=new rt(a);this.cache.set(r,t),n.set(e,t)}else i.push(e)})),i.length===0)return n;this.logger.log(`terrainBulk`,`fetching ${i.length} rooms`,t);let a=await this.http.game.roomsTerrain(i,t??void 0);return await Promise.all(a.rooms.map(async e=>{let r=rt.fromEncodedString(e.terrain),i=`terrain/${t}/${e.room}`;this.cache.set(i,r),await this.cache.setPersistent(i,r.raw),this.emit(`room:terrainavailable`,{room:e.room,shard:t,terrain:r}),n.set(e.room,r)})),n}objects(e,t){let n=this.roomObjects.get(`${e}/${t}`);return n?{...n}:null}async fetchObjects(e,t){let n=`${e}/${t}`,r=await this.http.game.roomObjects(e,t??void 0),i={};for(let e of r.objects)e&&typeof e==`object`&&`_id`in e&&(i[e._id]=e);this.roomObjects.set(n,i);let a=this.roomUsers.get(n);this.emit(`room:update`,{room:e,shard:t,gameTime:void 0,objects:i,diff:i,visual:``,users:a})}activeRooms(){return Array.from(this.roomSubCount.entries()).map(([e,t])=>`${e}(${t})`).join(`, `)||`(none)`}subscribe(e,t){let n=`${e}/${t}`,r=this.roomSubCount.get(n)??0;this.roomSubCount.set(n,r+1),this.logger.log(`subscribe`,e,t,`(refs: ${r+1})`,`active:`,this.activeRooms());let i=t?`room:${t}/${e}`:`room:${e}`,a=t?`err@room:${t}/${e}`:`err@room:${e}`,o=this.socket.subscribe(i),s=this.socket.on(a,n=>{let r=typeof n==`string`?n:JSON.stringify(n);this.logger.log(`room error`,e,t,r),this.emit(`room:error`,{room:e,shard:t,message:r})}),c=this.socket.on(i,r=>{let i=r,a={...this.roomObjects.get(n)??{}};if(i.objects==null)i.objects===null&&this.logger.log(`room update has null objects field`,e,t,`gameTime: ${i.gameTime}`);else for(let[e,t]of Object.entries(i.objects))t===null?delete a[e]:a[e]?a[e]=at(a[e],t):a[e]=t;let o={...i.objects??{}};if(`flags`in i){let t=i.flags??``;if(t!==(this.lastFlagsString.get(n)??``)){this.lastFlagsString.set(n,t);let r=this.parseFlagsString(t,e),i=new Map;for(let e of r)i.set(e.name,e);for(let t in a)a[t]?.type===`flag`&&!i.has(t)&&(delete a[t],o[t]=null,this.logger.log(`[flag:room] removed ${t} @ ${e}`));for(let[t,n]of i){let r=a[t];(!r||r.x!==n.x||r.y!==n.y||r.color!==n.color||r.secondaryColor!==n.secondaryColor)&&(a[t]=n,o[t]=n,this.logger.log(`[flag:room] ${r?`changed`:`added`} ${t} @ ${e} (${n.x},${n.y})`))}}}if(i.users){let e=this.roomUsers.get(n)??{};this.roomUsers.set(n,{...e,...i.users})}this.roomObjects.set(n,a);let s=this.roomUsers.get(n);this.emit(`room:update`,{room:e,shard:t,gameTime:i.gameTime,objects:a,diff:o,visual:i.visual??``,users:s})});return{dispose:()=>{o.dispose(),c.dispose(),s.dispose();let r=(this.roomSubCount.get(n)??1)-1;r<=0?(this.roomSubCount.delete(n),this.roomObjects.delete(n),this.roomUsers.delete(n),this.lastFlagsString.delete(n),this.logger.log(`unsubscribe`,e,t,`(last ref)`,`active:`,this.activeRooms())):(this.roomSubCount.set(n,r),this.logger.log(`unsubscribe`,e,t,`(refs: ${r})`,`active:`,this.activeRooms()))}}}},st=class extends tt{http;socket;cache;console=[];maxConsoleSize;_cpu=null;get cpu(){return this._cpu}_userInfo=null;get userInfo(){return this._userInfo}_userId=null;get userId(){return this._userId}_worldStatus=null;get worldStatusValue(){return this._worldStatus}_mePromise=null;constructor(e,t,n,r,i=100){super(r),this.http=e,this.socket=t,this.cache=n,this.maxConsoleSize=i}async me(){let e=this.cache.get(`user/me`);return e?(this._userId=e._id,this._userInfo=e,e):this._mePromise?this._mePromise:(this.logger.log(`fetch me`),this._mePromise=this.http.auth.me().then(e=>{let t=e;return this._userId=t._id,this._userInfo=t,this.cache.set(`user/me`,t,6e4),this.emit(`user:me`,t),t}).finally(()=>{this._mePromise=null}),this._mePromise)}async refreshMe(){return this.logger.log(`refresh me`),this.cache.delete(`user/me`),this.me()}async worldStatus(){let e=this.cache.get(`user/worldStatus`);if(e)return this._worldStatus=e,e;this.logger.log(`fetch world status`);let t=await this.http.user.worldStatus();return this._worldStatus=t.status,this.cache.set(`user/worldStatus`,t.status,6e4),this.emit(`user:worldStatus`,{status:t.status}),t.status}async refreshWorldStatus(){return this.logger.log(`refresh world status`),this.cache.delete(`user/worldStatus`),this.worldStatus()}subscribe(e){this.logger.log(`subscribe`,e);let t=null,n=null,r=!1;return(async()=>{try{let i=this._userId??(await this.me())._id;if(r)return;let a=`user:${i}/${e}`;t=this.socket.subscribe(a),n=this.socket.on(a,t=>{if(e===`cpu`)this._cpu=t,this.emit(`user:cpu`,this._cpu);else if(e===`console`){let e=t,n={log:e.messages?.log??[],results:e.messages?.results??[],error:e.messages?.error??[]};e.error&&n.error.push(e.error),this.console.push(n),this.console.length>this.maxConsoleSize&&this.console.splice(0,this.console.length-this.maxConsoleSize),this.emit(`user:console`,{messages:n})}else e===`code`&&this.emit(`user:code`,t)})}catch(e){r||this.dispatchEvent(new ErrorEvent(`error`,{error:e instanceof Error?e:Error(String(e))}))}})(),{dispose:()=>{this.logger.log(`unsubscribe`,e),r=!0,t?.dispose(),n?.dispose()}}}subscribeMemory(e,t){this.logger.log(`subscribe memory`,e);let n=null,r=null,i=!1;return(async()=>{try{let a=this._userId??(await this.me())._id;if(i)return;let o=`user:${a}/memory/${t?`${t}/`:``}${e}`;n=this.socket.subscribe(o),r=this.socket.on(o,n=>{if(typeof n==`string`&&n.startsWith(`gz:`)){(async()=>{try{let{decompressZlib:r}=await O(async()=>{let{decompressZlib:e}=await import(`./decompress-DIM550rx.js`).then(e=>e.r);return{decompressZlib:e}},__vite__mapDeps([0,1]),import.meta.url),i=await r(n);this.emit(`user:memory`,{path:e,shard:t??null,value:i})}catch(e){this.logger.log(`memory decompress failed`,e)}})();return}if(n===`[object Object]`){this.logger.log(`memory object placeholder`,e),this.emit(`user:memory`,{path:e,shard:t??null,value:{__screeps_object__:!0}});return}let r=n;if(n===`undefined`)r=void 0;else if(typeof n==`string`)try{r=JSON.parse(n)}catch{}this.logger.log(`memory value received`,e,r),this.emit(`user:memory`,{path:e,shard:t??null,value:r})})}catch(e){i||this.dispatchEvent(new ErrorEvent(`error`,{error:e instanceof Error?e:Error(String(e))}))}})(),{dispose:()=>{this.logger.log(`unsubscribe memory`,e),i=!0,n?.dispose(),r?.dispose()}}}subscribeMapVisual(e){this.logger.log(`subscribe mapVisual`,e);let t=null,n=null,r=!1;return(async()=>{try{let i=this._userId??(await this.me())._id;if(r)return;let a=e?`mapVisual:${i}/${e}`:`mapVisual:${i}`;t=this.socket.subscribe(a),n=this.socket.on(a,t=>{this.emit(`user:mapVisual`,{shard:e,data:typeof t==`string`?t:``})})}catch(e){r||this.dispatchEvent(new ErrorEvent(`error`,{error:e instanceof Error?e:Error(String(e))}))}})(),{dispose:()=>{this.logger.log(`unsubscribe mapVisual`,e),r=!0,t?.dispose(),n?.dispose()}}}subscribeUserStream(){this.logger.log(`subscribe user stream`);let e=null,t=null,n=!1;return(async()=>{try{let r=this._userId??(await this.me())._id;if(n)return;let i=`user:${r}`;e=this.socket.subscribe(i),t=this.socket.on(i,e=>{let t=e;if(t&&typeof t==`object`&&`flags`in t){let e=t.flags;if(e&&typeof e==`object`)for(let[t,n]of Object.entries(e)){let e=n;if(e&&typeof e==`object`){let n=e.room??`unknown`,r=e.x??`?`,i=e.y??`?`;this.logger.log(`[flag:user] ${t} @ ${n} (${r},${i})`)}}}this.emit(`user:stream`,t)})}catch(e){n||this.dispatchEvent(new ErrorEvent(`error`,{error:e instanceof Error?e:Error(String(e))}))}})(),{dispose:()=>{this.logger.log(`unsubscribe user stream`),n=!0,e?.dispose(),t?.dispose()}}}},ct=class extends tt{http;cache;socketSubs=[];_version=null;get versionInfo(){return this._version}get isPrivateServer(){return this._version?(this._version.serverData?.shards?.length??0)===0:null}_shards=null;get shardList(){return this._shards}constructor(e,t,n,r){super(r),this.http=e,this.cache=n,this.socketSubs.push(t.on(`connected`,()=>{this.emit(`server:connected`,{})})),this.socketSubs.push(t.on(`disconnected`,e=>{let t=e;this.emit(`server:disconnected`,{willReconnect:t.willReconnect})})),this.socketSubs.push(t.on(`socket:error`,e=>{this.emit(`server:error`,{error:e instanceof Error?e:Error(String(e))})}))}destroy(){for(let e of this.socketSubs)e.dispose();this.socketSubs.length=0}async version(){let e=this.cache.get(`server/version`);if(e)return e;let t=await this.http.request(`GET`,`/api/version`);return this._version=t,this.cache.set(`server/version`,t,5*6e4),this.emit(`server:version`,t),t}async refreshVersion(){return this.cache.delete(`server/version`),this.version()}async shards(){let e=this.cache.get(`server/shards`);if(e)return e;let t=await this.http.request(`GET`,`/api/game/shards/info`);return this._shards=t.shards,this.cache.set(`server/shards`,t.shards,5*6e4),this.emit(`server:shards`,t.shards),t.shards}async refreshShards(){return this.cache.delete(`server/shards`),this.shards()}async worldInfo(e){let t=`server/world/${e??`default`}`,n=this.cache.get(t);if(n)return n;let r={};e&&(r.shard=e);let{width:i,height:a}=await this.http.request(`GET`,`/api/game/world-size`,r);this.logger.log(`worldInfo shard=${e??`none`} — raw size: ${i}x${a}`);let o=-i,s=-1,c=-a,l=-1;try{let e=(await this.http.request(`POST`,`/api/game/map-stats`,{rooms:[`W0N0`,`E0N0`,`W0S0`,`E0S0`],statName:`owner0`,...r})).stats??{},t=[`W0N0`,`E0N0`,`W0S0`,`E0S0`].filter(t=>t in e);this.logger.log(`worldInfo corner probe — found: [${t.length?t.join(`, `):`none`}]`),(`E0N0`in e||`E0S0`in e)&&(o=-Math.ceil(i/2),s=Math.floor(i/2)-1),(`W0S0`in e||`E0S0`in e)&&(c=-Math.ceil(a/2),l=Math.floor(a/2)-1)}catch(e){this.logger.log(`worldInfo corner probe failed — keeping W/N defaults:`,e)}this.logger.log(`worldInfo computed bounds — x: [${o}, ${s}] y: [${c}, ${l}]`);let u={shard:e??null,width:i,height:a,minX:o,maxX:s,minY:c,maxY:l};return this.cache.set(t,u,10*6e4),u}invalidateWorldInfo(e){this.cache.delete(`server/world/${e??`default`}`)}},lt=class{memory=new Map;adapter;maxEntries;namespace;accessSeq=0;constructor(e){this.adapter=e.adapter,this.maxEntries=e.maxEntries,this.namespace=e.namespace}key(e,t){return`${t??`_`}/${e}`}adapterKey(e){return`map2/${e}`}tick(){return++this.accessSeq}serialize(e){let t={data:e.data,lastSeen:e.lastSeen,lastAccess:e.lastAccess};return new TextEncoder().encode(JSON.stringify(t))}deserialize(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}getMemory(e,t){let n=this.memory.get(this.key(e,t));return n?(n.lastAccess=this.tick(),n.data):null}async get(e,t){let n=this.getMemory(e,t);if(n)return n;if(!this.adapter)return null;let r=this.key(e,t),i=await this.adapter.get(this.adapterKey(r));if(!i)return null;let a=this.deserialize(i);return a?(this.memory.set(r,{data:a.data,lastSeen:a.lastSeen,lastAccess:this.tick()}),a.data):null}async put(e,t,n){let r=this.key(e,t),i={data:n,lastSeen:Date.now(),lastAccess:this.tick()};this.memory.set(r,i),await this.pruneIfNeeded(),this.adapter&&await this.adapter.set(this.adapterKey(r),this.serialize(i))}async pruneIfNeeded(){if(this.memory.size<=this.maxEntries)return;let e=[...this.memory.entries()].sort((e,t)=>e[1].lastAccess-t[1].lastAccess).slice(0,this.memory.size-this.maxEntries);for(let[t]of e)this.memory.delete(t),this.adapter&&await this.adapter.delete(this.adapterKey(t))}};function ut(e){let t=Object.keys(e).sort(),n={};for(let r of t){let t=e[r];n[r]=t?[...t].sort((e,t)=>e[0]-t[0]||e[1]-t[1]):null}return JSON.stringify(n)}var dt=class extends tt{socket;storage;maxSubscriptions;active=new Map;waitlist=[];keyStates=new Map;warnedAboutWaitlist=!1;constructor(e,t,n={},r){super(r),this.socket=e,this.storage=t,this.maxSubscriptions=n.maxSubscriptions??500,this.socket.on(`connected`,()=>this.onReconnect())}map2data(e,t){return this.storage.getMemory(e,t)}subscribeMap2(e,t){let n=`${e}/${t}`,r=this.active.get(n);if(r){r.refCount++,this.logger.log(`subscribeMap2`,e,t,`(active, refs: ${r.refCount})`);let i=this.getOrCreateKeyState(n,`active`);return this.emitWarmStart(e,t),this.makeSubscription(e,t,n,i)}let i=this.waitlist.find(e=>e.key===n);if(i){i.refCount++,this.logger.log(`subscribeMap2`,e,t,`(pending, refs: ${i.refCount})`);let r=this.getOrCreateKeyState(n,`pending`);return this.emitWarmStart(e,t),this.makeSubscription(e,t,n,r)}if(this.active.size<this.maxSubscriptions){this.activateKey(e,t,n,1),this.logger.log(`subscribeMap2`,e,t,`(new active)`);let r=this.getOrCreateKeyState(n,`active`);return this.emit(`room:map2state`,{room:e,shard:t,status:`active`}),this.emitWarmStart(e,t),this.makeSubscription(e,t,n,r)}this.waitlist.push({key:n,room:e,shard:t,refCount:1}),this.logger.log(`subscribeMap2`,e,t,`(new pending)`);let a=this.getOrCreateKeyState(n,`pending`);return this.emit(`room:map2state`,{room:e,shard:t,status:`pending`}),this.emitWarmStart(e,t),this.warnedAboutWaitlist||=(this.logger.log(`subscription limit (${this.maxSubscriptions}) reached — `,`some rooms are on a waitlist and will be promoted as slots free up.`),!0),this.makeSubscription(e,t,n,a)}activateKey(e,t,n,r){let i=t?`roomMap2:${t}/${e}`:`roomMap2:${e}`,a=this.socket.subscribe(i),o=this.storage.getMemory(e,t),s={room:e,shard:t,refCount:r,socketSub:a,listenerSub:void 0,lastHash:o?ut(o):null};s.listenerSub=this.socket.on(i,n=>{let r=n,i=ut(r);s.lastHash!==i&&(s.lastHash=i,this.storage.put(e,t,r),this.emit(`room:map2update`,{room:e,shard:t,data:r,source:`live`}))}),this.active.set(n,s)}promoteNext(){let e=this.waitlist.shift();if(!e)return;this.activateKey(e.room,e.shard,e.key,e.refCount),this.logger.log(`promoteNext`,e.room,e.shard,`(promoted from waitlist)`);let t=this.keyStates.get(e.key);t&&(t.status=`active`,t.statusHandlers.forEach(e=>e(`active`))),this.emit(`room:map2state`,{room:e.room,shard:e.shard,status:`active`})}getOrCreateKeyState(e,t){let n=this.keyStates.get(e);return n||(n={status:t,statusHandlers:new Set},this.keyStates.set(e,n)),n}makeSubscription(e,t,n,r){let i=!1;return{status:()=>r.status,cachedData:()=>this.storage.getMemory(e,t),onStatusChange:e=>(r.statusHandlers.add(e),{dispose:()=>{r.statusHandlers.delete(e)}}),dispose:()=>{i||(i=!0,this.disposeSubscription(e,t,n))}}}disposeSubscription(e,t,n){let r=this.waitlist.findIndex(e=>e.key===n);if(r>=0){let i=this.waitlist[r];i.refCount--,this.logger.log(`unsubscribeMap2`,e,t,`(pending, refs: ${i.refCount})`),i.refCount<=0&&(this.waitlist.splice(r,1),this.keyStates.delete(n),this.logger.log(`unsubscribeMap2`,e,t,`(removed from waitlist)`));return}let i=this.active.get(n);i&&(i.refCount--,this.logger.log(`unsubscribeMap2`,e,t,`(active, refs: ${i.refCount})`),i.refCount<=0&&(i.socketSub.dispose(),i.listenerSub.dispose(),this.active.delete(n),this.keyStates.delete(n),this.logger.log(`unsubscribeMap2`,e,t,`(deactivated, promoting next)`),this.promoteNext()))}emitWarmStart(e,t){let n=`${e}/${t}`,r=this.storage.getMemory(e,t);r?queueMicrotask(()=>{this.isSubscribed(n)&&this.emit(`room:map2update`,{room:e,shard:t,data:r,source:`cache`})}):this.storage.get(e,t).then(r=>{r&&this.isSubscribed(n)&&this.emit(`room:map2update`,{room:e,shard:t,data:r,source:`cache`})})}onReconnect(){this.logger.log(`onReconnect —`,this.active.size,`active,`,this.waitlist.length,`pending`);for(let e of this.active.values())e.lastHash=null,this.emit(`room:map2state`,{room:e.room,shard:e.shard,status:`active`});for(let e of this.waitlist)this.emit(`room:map2state`,{room:e.room,shard:e.shard,status:`pending`})}isSubscribed(e){return this.active.has(e)||this.waitlist.some(t=>t.key===e)}},ft=class extends tt{http;debounceMs;minIntervalMs;pending=new Map;timer=null;lastFlushTime=0;constructor(e,t=100,n=500,r){super(r),this.http=e,this.debounceMs=t,this.minIntervalMs=n}request(e,t,n){if(e.length===0)return;let r=JSON.stringify([t,n??`shard0`]),i=this.pending.get(r);i||(i={rooms:new Set,statName:t,shard:n??`shard0`},this.pending.set(r,i));for(let t of e)i.rooms.add(t);this.timer&&clearTimeout(this.timer);let a=Date.now()-this.lastFlushTime,o=Math.max(this.debounceMs,this.minIntervalMs-a);this.timer=setTimeout(()=>this.flush(),o)}async flush(){let e=new Map(this.pending);this.pending.clear(),this.timer=null,this.lastFlushTime=Date.now();for(let[,t]of e){let e=[...t.rooms];try{let n=await this.http.request(`POST`,`/api/game/map-stats`,{rooms:e,statName:t.statName,shard:t.shard}),r=n.users??{};for(let[e,i]of Object.entries(n.stats)){let n=this.buildData(i,r);this.emit(`mapStats:room`,{room:e,shard:t.shard===`shard0`?null:t.shard,stat:n})}for(let r of e)n.stats[r]||this.emit(`mapStats:room`,{room:r,shard:t.shard===`shard0`?null:t.shard,stat:{}})}catch(e){this.logger.log(`mapStats fetch failed:`,e)}}}buildData(e,t){let n,r;for(let t=0;t<3;t++){let i=e[`minerals${t}`];if(i){n=i.type,r=i.density;break}}let i=e.own?.user,a=e.sign?.user;return{own:e.own,mineral:n,density:r,username:i?t[i]?.username:void 0,safeMode:e.safeMode,badge:i?t[i]?.badge:void 0,status:e.status,sign:e.sign?{user:e.sign.user,text:e.sign.text,datetime:e.sign.datetime,username:a?t[a]?.username:void 0,badge:a?t[a]?.badge:void 0}:void 0}}},pt=class extends tt{_history=[];_index=-1;maxHistory;constructor(e=50,t){super(t),this.maxHistory=e}navigateTo(e,t){this._history=this._history.slice(0,this._index+1),this._history.push({room:e,shard:t}),this._history.length>this.maxHistory?this._history.shift():this._index++,this.emit(`navigation:change`,this.current())}back(){return this.canBack()?(this._index--,this.emit(`navigation:change`,this.current()),!0):!1}forward(){return this.canForward()?(this._index++,this.emit(`navigation:change`,this.current()),!0):!1}canBack(){return this._index>0}canForward(){return this._index<this._history.length-1}current(){return{room:this._history[this._index]?.room??null,shard:this._history[this._index]?.shard??null,index:this._index,history:[...this._history]}}},mt=class{http;socket;stores;cache;logger;tokenRefreshIntervalMs;tokenSyncSubs=[];tokenRefreshTimer=null;lastHttpActivity=0;refreshInFlight=!1;constructor(e){let t;try{t=new URL(e.url).hostname}catch{throw TypeError(`ScreepsClient: invalid url "${e.url}"`)}this.logger=Ve.create(e.debug),this.logger.log(`[screeps:client] init ${e.url}`),this.cache=new et(t,e.storage??null),this.http=new Ze({url:e.url,auth:e.auth,logger:this.logger.child(`http`),serverPassword:e.serverPassword,decorationsMock:e.decorationsMock}),this.socket=new $e({url:e.url,WebSocket:e.WebSocket,logger:this.logger.child(`socket`)});let n=new lt({adapter:e.storage??null,namespace:t,maxEntries:e.map2?.maxCacheEntries??1e4});this.stores={room:new ot(this.http,this.socket,this.cache,this.logger.child(`room`)),user:new st(this.http,this.socket,this.cache,this.logger.child(`user`)),server:new ct(this.http,this.socket,this.cache,this.logger.child(`server`)),map:new dt(this.socket,n,{maxSubscriptions:e.map2?.maxSubscriptions??500},this.logger.child(`map`)),mapStats:new ft(this.http,100,500,this.logger.child(`mapStats`)),navigation:new pt(50,this.logger.child(`navigation`))},this.tokenRefreshIntervalMs=e.tokenRefresh===!1?null:e.tokenRefresh?.intervalMs??3e4,this.wireTokenSync()}wireTokenSync(){this.tokenSyncSubs.push(this.http.on(`http:tokenRefresh`,({token:e})=>{this.socket.setToken(e)})),this.tokenSyncSubs.push(this.socket.on(`socket:tokenRefresh`,e=>{let t=e;this.http.setToken(t.token)})),this.tokenSyncSubs.push(this.http.on(`http:success`,()=>{this.lastHttpActivity=Date.now()}))}get isConnected(){return this.socket.isConnected}async connect(){this.logger.log(`[screeps:client] connect`),await this.http.authenticate(),await this.socket.connect(this.http.token),await Promise.all([this.stores.user.me(),this.stores.user.worldStatus(),this.stores.server.version()]),this.startTokenRefresh()}disconnect(){this.logger.log(`[screeps:client] disconnect`),this.stopTokenRefresh(),this.socket.disconnect()}startTokenRefresh(){if(this.tokenRefreshIntervalMs===null||this.tokenRefreshTimer!==null)return;let e=this.tokenRefreshIntervalMs;this.lastHttpActivity=Date.now();let t=Math.max(1e3,Math.floor(e/2));this.tokenRefreshTimer=setInterval(()=>{Date.now()-this.lastHttpActivity<e||this.refreshTokenNow()},t)}stopTokenRefresh(){this.tokenRefreshTimer!==null&&(clearInterval(this.tokenRefreshTimer),this.tokenRefreshTimer=null)}async refreshTokenNow(){if(!this.refreshInFlight){this.refreshInFlight=!0;try{this.logger.log(`[screeps:client] token refresh (idle)`),await this.stores.user.refreshWorldStatus()}catch(e){this.logger.log(`[screeps:client] token refresh failed`,e)}finally{this.refreshInFlight=!1}}}async clearCache(){this.logger.log(`[screeps:client] clearCache`),await this.cache.clearAll()}},ht=class{token;constructor(e){this.token=e.token}async authenticate(e){return this.token}},gt=class{email;password;constructor(e){this.email=e.email,this.password=e.password}async authenticate(e){return(await e.auth.signin(this.email,this.password)).token}},_t=class{async authenticate(e){return`guest`}},vt=1,yt=`data`,bt=class{namespace;db=null;openPromise=null;constructor(e){this.namespace=e}get dbName(){return`screeps:${this.namespace}`}open(){return this.db?Promise.resolve(this.db):(this.openPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,vt);n.onupgradeneeded=()=>{n.result.createObjectStore(yt)},n.onsuccess=()=>{this.db=n.result,this.openPromise=null,e(n.result)},n.onerror=()=>t(n.error),n.onblocked=()=>t(Error(`IndexedDB open blocked: ${this.dbName}`))}),this.openPromise)}async get(e){let t=await this.open();return new Promise((n,r)=>{let i=t.transaction(yt,`readonly`).objectStore(yt).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async set(e,t){let n=await this.open();return new Promise((r,i)=>{let a=n.transaction(yt,`readwrite`).objectStore(yt).put(t,e);a.onsuccess=()=>r(),a.onerror=()=>i(a.error)})}async delete(e){let t=await this.open();return new Promise((n,r)=>{let i=t.transaction(yt,`readwrite`).objectStore(yt).delete(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async clear(){let e=await this.open();return new Promise((t,n)=>{let r=e.transaction(yt,`readwrite`).objectStore(yt).clear();r.onsuccess=()=>t(),r.onerror=()=>n(r.error)})}},xt=class{subs=[];add(e){this.subs.push(e)}dispose(){for(let e of this.subs)e.dispose();this.subs.length=0}},St=5*6e4;function Ct(e,t){try{return`screeps:${e}:${new URL(t).hostname}`}catch{return`screeps:${e}:${t}`}}function wt(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return Date.now()>n.expires?(sessionStorage.removeItem(e),null):n.data}catch{return null}}function Tt(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(e,JSON.stringify({data:t,expires:Date.now()+St}))}catch{}}function Et(e){return e.endsWith(`/`)?e:`${e}/`}async function Dt(e){let t=Ct(`version`,e),n=wt(t);if(n)return n;let r=await fetch(`${Et(e)}api/version`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();return Tt(t,i),i}async function Ot(e){let t=Ct(`authmod`,e),n=wt(t);if(n)return n;let r=await fetch(`${Et(e)}api/authmod`);if(!r.ok)return null;let i=await r.json();return i.ok?(Tt(t,i),i):null}async function kt(e,t){let n=new URLSearchParams({username:t}),r=await fetch(`${Et(e)}api/register/check-username?${n}`);if(!r.ok)throw Error(`HTTP ${r.status}`);return r.json()}async function At(e,t){let n=new URLSearchParams({email:t}),r=await fetch(`${Et(e)}api/register/check-email?${n}`);if(!r.ok)throw Error(`HTTP ${r.status}`);return r.json()}async function jt(e,t,n,r){let i=await fetch(`${Et(e)}api/register/submit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:t,email:n,password:r})});if(!i.ok)throw Error(`HTTP ${i.status}`);return i.json()}function Mt(e,t){return e.serverData.features.find(e=>e.name===t)}function Nt(e){return Mt(e,`screepsmod-auth`)}var Pt={ok:1,decorations:[{_id:`5fd719f496a97dbdd2f57bea`,user:`58356f6fc8012784246abb7e`,active:{strokeWidth:`30`,foregroundColor:`#6A88FF`,foregroundAlpha:1,backgroundColor:`#5261A0`,backgroundBrightness:`1`,strokeColor:`#465EC4`,strokeBrightness:`1`,strokeLighting:`1`,foregroundBrightness:`1`,world:!0,tileScale:1,shard:`shard1`,room:`E2S49`},decoration:{_id:`5eea71d952fdab816c74e50c`,graphics:[],description:`звездочки`,rarityMultiplier:1,type:`wallLandscape`,foregroundUrl:`https://s3.amazonaws.com/static.screeps.com/decorations/0e53bc662a2688275b9c6766cf946031b19bf0b.png`,theme:`5e908ece62339b0045ac2d0e`,rarity:4,name:`W-00031:WI:X`,group:`5edf121e1f95b4047880e2ef`,steamItemDefId:4415,enabled:!0,groupDescription:`Controllable brightness.`,preview:{original:`https://s3.amazonaws.com/static.screeps.com/decorations/6c5533fd1f83ecadb8cf105fdda95fa4687114b.png`,"128x128":`https://s3.amazonaws.com/static.screeps.com/decorations/919410fbd3c74c697d7396ba0636b2d33ca3fa5.png`,"256x256":`https://s3.amazonaws.com/static.screeps.com/decorations/16f3453e69387abfe110050532d9e7c67e8fc41.png`}}},{_id:`60086a96a6ad8c744554e05c`,user:`58356f6fc8012784246abb7e`,active:{floorBackgroundColor:`#F67BFF`,floorBackgroundBrightness:.98,floorForegroundColor:`#F67BFF`,floorForegroundAlpha:.87,swampColor:`#4073A3`,swampStrokeColor:`#CC7DD2`,swampStrokeWidth:30,roadsColor:`#E9A7EE`,roadsBrightness:.41,tileScale:1,floorForegroundBrightness:.42,world:!0,shard:`shard1`,room:`E2S49`},decoration:{_id:`5eea668452fdab5ea674e1ca`,graphics:[],description:`калейдоскоп`,rarityMultiplier:1,type:`floorLandscape`,floorForegroundUrl:`https://s3.amazonaws.com/static.screeps.com/decorations/7e3d680d2f48b1ff244a95e564275536fe4ed61.png`,theme:`5e908ed162339b0045ac2d0f`,rarity:4,name:`F-00065:AL:X`,group:`5ee9016d961c4e27734cf301`,steamItemDefId:3606,enabled:!0,groupDescription:`Adjustable brightness.`,preview:{original:`https://s3.amazonaws.com/static.screeps.com/decorations/da7256631a2a2c8568221ad1f0bef0bb5525a7.png`,"128x128":`https://s3.amazonaws.com/static.screeps.com/decorations/3c0f0da6b41e413bdc4f66a01eed62b5b252c29.png`,"256x256":`https://s3.amazonaws.com/static.screeps.com/decorations/80c9978b58403e13b4a28f47ef1422e895c04fe.png`}}},{_id:`5fbab429b2f60e0fae891bcb`,user:`58356f6fc8012784246abb7e`,active:{lighting:!0,position:`below`,width:256,height:256,syncRotate:!0,animation:`blink`,brightness:`1`,nameFilter:`ecarry*`,exclude:!1,firstColor:`#FFFFFF`,firstAlpha:1,secondColor:`#FFFFFF`,secondAlpha:`1`,flip:!1,color:`#1fe265`,alpha:.79},decoration:{_id:`5f2ab6c1ad10bf3222df1b4f`,graphics:[{url:`https://s3.amazonaws.com/static.screeps.com/decorations/a23d96123d27bf163babe0a29a54de003aea568.svg`,color:`color`,alpha:`alpha`,visible:``}],description:`38.svg`,rarityMultiplier:1,type:`creep`,theme:`5ee3db64961c4e98dc4cf121`,rarity:5,name:`C-00071:CC:X`,group:`5eec306d0042094b2845f7d6`,steamItemDefId:57779,enabled:!0,groupDescription:`Choose your own color.`,preview:{original:`https://s3.amazonaws.com/static.screeps.com/decorations/3a7853ca055d7ae5738852f6f73f27389594e2e.png`,"128x128":`https://s3.amazonaws.com/static.screeps.com/decorations/8557cffe9216525092427f90b9847ef5bdcd6c8.png`,"256x256":`https://s3.amazonaws.com/static.screeps.com/decorations/e198e4f909cdb99f11a8cc7bc9f7e7a733faeca.png`}}}]},Ft={1:{calc(e=0){let t=0,n=0;e>0&&(t=e*30/100),e<0&&(n=-e*30/100),this.path1=`M 50 ${100-t} L ${n} 50 H ${100-n} Z`,this.path2=`M ${n} 50 H ${100-n} L 50 ${t} Z`}},2:{calc(e=0){let t=0,n=0;e>0&&(t=e*30/100),e<0&&(n=-e*30/100),this.path1=`M ${t} ${n} L 50 50 L ${100-t} ${n} V -1 H -1 Z`,this.path2=`M ${t} ${100-n} L 50 50 L ${100-t} ${100-n} V 101 H -1 Z`}},3:{calc(e=0){let t=Math.PI/4+Math.PI/4*(e+100)/200,n=-Math.PI/2,r=Math.PI/2+Math.PI/3,i=Math.PI/2-Math.PI/3;this.path1=`M 50 50 L ${50+100*Math.cos(n-t/2)} ${50+100*Math.sin(n-t/2)} L ${50+100*Math.cos(n+t/2)} ${50+100*Math.sin(n+t/2)} Z`,this.path2=`M 50 50 L ${50+100*Math.cos(r-t/2)} ${50+100*Math.sin(r-t/2)} L ${50+100*Math.cos(r+t/2)} ${50+100*Math.sin(r+t/2)} Z M 50 50 L ${50+100*Math.cos(i-t/2)} ${50+100*Math.sin(i-t/2)} L ${50+100*Math.cos(i+t/2)} ${50+100*Math.sin(i+t/2)}`},flip:`rotate180`},4:{calc(e=0){e+=100;let t=50-e*30/200,n=50+e*30/200;this.path1=`M 0 ${n} H 100 V 100 H 0 Z`,this.path2=e>0?`M 0 ${t} H 100 V ${n} H 0 Z`:``},flip:`rotate90`},5:{calc(e=0){e+=100;let t=50-e*10/200-10,n=50+e*10/200+10;this.path1=`M ${t} 0 H ${n} V 100 H ${t} Z`,this.path2=`M 0 ${t} H 100 V ${n} H 0 Z`},flip:`rotate45`},6:{calc(e=0){let t=5+(e+100)*8/200;this.path1=`M ${50-t} 0 H ${50+t} V 100 H ${50-t}`,this.path2=`M ${20-t} 0 H ${20+t} V 100 H ${20-t} Z M ${80-t} 0 H ${80+t} V 100 H ${80-t} Z`},flip:`rotate90`},7:{calc(e=0){let t=20+e*10/100;this.path1=`M 0 50 Q 25 30 50 50 T 100 50 V 100 H 0 Z`,this.path2=`M 0 ${50-t} Q 25 ${30-t} 50 ${50-t} T 100 ${50-t} V ${50+t} Q 75 ${70+t} 50 ${50+t} T 0 ${50+t} Z`},flip:`rotate90`},8:{calc(e=0){let t=e*20/100;this.path1=`M 0 50 H 100 V 100 H 0 Z`,this.path2=`M 0 50 Q 50 ${t} 100 50 Q 50 ${100-t} 0 50 Z`},flip:`rotate90`},9:{calc(e=0){let t=0,n=50;e>0&&(t+=e/100*20),e<0&&(n+=e/100*30),this.path1=`M 50 ${t} L 100 ${t+70} V 101 H 0 V ${t+70} Z`,this.path2=`M 50 ${t+n} L 100 ${t+n+70} V 101 H 0 V ${t+n+70} Z`},flip:`rotate180`},10:{calc(e=0){let t=30,n=7;e>0&&(t+=e*50/100),e<0&&(n-=e*20/100),this.path1=`M ${50+n+t} ${50-t} A ${t} ${t} 0 0 0 ${50+n+t} ${50+t} H 101 V ${50-t} Z`,this.path2=`M ${50-n-t} ${50-t} A ${t} ${t} 0 0 1 ${50-n-t} ${50+t} H -1 V ${50-t} Z`},flip:`rotate90`},11:{calc(e=0){let t=30,n=30,r=50-50*Math.cos(Math.PI/4),i=50-50*Math.sin(Math.PI/4);e>0&&(t+=e*25/100,n+=e*25/100),e<0&&(n-=e*50/100),this.path1=`M ${r} ${i} Q ${t} 50 ${r} ${100-i} H 0 V ${i} Z M ${100-r} ${i} Q ${100-t} 50 ${100-r} ${100-i} H 100 V ${i} Z`,this.path2=`M ${r} ${i} Q 50 ${n} ${100-r} ${i} V 0 H ${r} Z M ${r} ${100-i} Q 50 ${100-n} ${100-r} ${100-i} V 100 H ${r} Z`},flip:`rotate90`},12:{calc(e=0){let t=30,n=35;e>0&&(t+=e*30/100),e<0&&(n+=e*15/100),this.path1=`M 0 ${t} H 100 V 100 H 0 Z`,this.path2=`M 0 ${t} H ${n} V 100 H 0 Z M 100 ${t} H ${100-n} V 100 H 100 Z`},flip:`rotate180`},13:{calc(e=0){let t=30,n=0;e>0&&(t+=e*50/100),e<0&&(n-=e*20/100),this.path1=`M 0 0 H 50 V 100 H 0 Z`,this.path2=`M ${50-t} ${50-n-t} A ${t} ${t} 0 0 0 ${50+t} ${50-t-n} V 0 H ${50-t} Z`},flip:`rotate180`},14:{calc(e=0){let t=Math.PI/4;t+=e*Math.PI/4/100,this.path1=`M 50 0 Q 50 50 ${50+50*Math.cos(t)} ${50+50*Math.sin(t)} H 100 V 0 H 50 Z`,this.path2=`M 50 0 Q 50 50 ${50-50*Math.cos(t)} ${50+50*Math.sin(t)} H 0 V 0 H 50 Z`},flip:`rotate180`},15:{calc(e=0){let t=13+e*6/100;this.path1=`M ${-30-t} 110 A ${80+t} ${80+t} 0 0 1 ${130+t} 110 H ${130-t} A ${80-t} ${80-t} 0 1 0 ${-30+t} 110`,this.path2=`M ${5-t} 110 A ${45+t} ${45+t} 0 0 1 ${95+t} 110 H ${95-t} A ${45-t} ${45-t} 0 1 0 ${5+t} 110`},flip:`rotate180`},16:{calc(e=0){let t=30*Math.PI/180,n=25;e>0&&(t+=30*Math.PI/180*e/100),e<0&&(n+=e*25/100),this.path1=``;for(let e=0;e<3;e++){let r=e*Math.PI*2/3+t/2-Math.PI/2,i=e*Math.PI*2/3-t/2-Math.PI/2;this.path1+=`M ${50+100*Math.cos(r)} ${50+100*Math.sin(r)} L ${50+100*Math.cos(i)} ${50+100*Math.sin(i)} L ${50+n*Math.cos(i)} ${50+n*Math.sin(i)} A ${n} ${n} 0 0 1 ${50+n*Math.cos(r)} ${50+n*Math.sin(r)} Z`}this.path2=``;for(let e=0;e<3;e++){let r=e*Math.PI*2/3+t/2+Math.PI/2,i=e*Math.PI*2/3-t/2+Math.PI/2;this.path2+=`M ${50+100*Math.cos(r)} ${50+100*Math.sin(r)} L ${50+100*Math.cos(i)} ${50+100*Math.sin(i)} L ${50+n*Math.cos(i)} ${50+n*Math.sin(i)} A ${n} ${n} 0 0 1 ${50+n*Math.cos(r)} ${50+n*Math.sin(r)} Z`}}},17:{calc(e=0){let t=35,n=45;e>0&&(t+=e*20/100),e<0&&(n-=e*30/100),this.path1=`M 50 45 L ${50-t} ${n+45} H ${50+t} Z`,this.path2=`M 50 0 L ${50-t} ${n} H ${50+t} Z`}},18:{calc(e=0){let t=90*Math.PI/180,n=10;e>0&&(t-=60/180*Math.PI*e/100),e<0&&(n-=e*15/100),this.path1=``,this.path2=``;for(let e=0;e<3;e++){let r=Math.PI*2/3*e+t/2-Math.PI/2,i=Math.PI*2/3*e-t/2-Math.PI/2,a=`M ${50+100*Math.cos(r)} ${50+100*Math.sin(r)} L ${50+100*Math.cos(i)} ${50+100*Math.sin(i)} L ${50+n*Math.cos((r+i)/2)} ${50+n*Math.sin((r+i)/2)} Z`;e?this.path2+=a:this.path1+=a}},flip:`rotate180`},19:{calc(e=0){let t=20,n=60;n+=e*20/100,t+=e*20/100,this.path1=`M 50 -10 L ${50-n} 100 H ${50+n} Z`,this.path2=``,t>0&&(this.path2=`M 50 0 L ${50-t} 100 H ${50+t} Z`)},flip:`rotate180`},20:{calc(e=0){let t=10,n=20;e>0&&(t+=e*20/100),e<0&&(n+=e*40/100),this.path1=`M 0 ${50-n} H ${50-t} V 100 H 0 Z`,this.path2=`M ${50+t} 0 V ${50+n} H 100 V 0 Z`},flip:`rotate90`},21:{calc(e=0){let t=40,n=50;e>0&&(t-=e*20/100),e<0&&(n+=e*20/100),this.path1=`M 50 ${n} Q ${50+t} 0 50 0 T 50 ${n} Z M 50 ${100-n} Q ${50+t} 100 50 100 T 50 ${100-n} Z`,this.path2=`M ${n} 50 Q 0 ${50+t} 0 50 T ${n} 50 Z M ${100-n} 50 Q 100 ${50+t} 100 50 T ${100-n} 50 Z`},flip:`rotate45`},22:{calc(e=0){let t=20;t+=e*10/100,this.path1=`M ${50-t} ${50-t} H ${50+t} V ${50+t} H ${50-t} Z`,this.path2=``;for(let e=-4;e<4;e++)for(let n=-4;n<4;n++){let r=(e+n)%2;this.path2+=`M ${50-t-t*2*e} ${50-t-t*2*(n+r)} h ${-t*2} v ${t*2} h ${t*2} Z`}},flip:`rotate45`},23:{calc(e=0){let t=17,n=25;e>0&&(t+=e*35/100),e<0&&(n-=e*23/100),this.path1=``;for(let e=-4;e<=4;e++)this.path1+=`M ${50-t*e*2} ${50-n} l ${-t} ${-n} l ${-t} ${n} l ${t} ${n} Z`;this.path2=``;for(let e=-4;e<=4;e++)this.path2+=`M ${50-t*e*2} ${50+n} l ${-t} ${-n} l ${-t} ${n} l ${t} ${n} Z`},flip:`rotate90`},24:{calc(e=0){let t=50,n=45;e>0&&(t+=e*60/100),e<0&&(n+=e*30/100),this.path1=`M 0 ${n} L 50 70 L 100 ${n} V 100 H 0 Z`,this.path2=`M 50 0 L ${50+t} 100 H 100 V ${n} L 50 70 L 0 ${n} V 100 H ${50-t} Z`},flip:`rotate180`}};function It(e){let t=Math.round(e).toString(16);return t.length<2?`0`+t:t}function Lt(e,t,n){let r=(1-Math.abs(2*n-1))*t,i=e/60,a=r*(1-Math.abs(i%2-1)),o=0,s=0,c=0;!Number.isNaN(e)&&e!=null&&(i>=0&&i<1?(o=r,s=a,c=0):i>=1&&i<2?(o=a,s=r,c=0):i>=2&&i<3?(o=0,s=r,c=a):i>=3&&i<4?(o=0,s=a,c=r):i>=4&&i<5?(o=a,s=0,c=r):i>=5&&i<6&&(o=r,s=0,c=a));let l=n-r/2,u=(o+l)*255,d=(s+l)*255,f=(c+l)*255;return`#`+It(u)+It(d)+It(f)}function Rt(){let e=[],t=0;e.push({index:t++,rgb:Lt(0,0,.8)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Lt(n*360/19,.6,.8)});e.push({index:t++,rgb:Lt(0,0,.5)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Lt(n*360/19,.7,.5)});e.push({index:t++,rgb:Lt(0,0,.3)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Lt(n*360/19,.4,.3)});e.push({index:t++,rgb:Lt(0,0,.1)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Lt(n*360/19,.5,.1)});return e}var zt=Rt();function Bt(e){if(typeof e==`string`)return e;if(typeof e==`number`){let t=zt[e];return t?t.rgb:`#000000`}return`#000000`}function Vt(e){let t=Bt(e.color1),n=Bt(e.color2),r=Bt(e.color3),i=e.param??0;if(typeof e.type==`number`){let t=Ft[e.type];t&&t.calc(i)}let a=0;if(e.flip&&typeof e.type==`number`){let t=Ft[e.type];t?.flip===`rotate180`&&(a=180),t?.flip===`rotate90`&&(a=90),t?.flip===`rotate45`&&(a=45)}let o,s;if(typeof e.type==`number`){let t=Ft[e.type];o=t?.path1??``,s=t?.path2??``}else o=e.type.path1,s=e.type.path2;let c=`<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 100 100" shape-rendering="geometricPrecision">`;return c+=`<defs><clipPath id="clip"><circle cx="50" cy="50" r="50"/></clipPath></defs>`,c+=`<g transform="rotate(${a} 50 50)">`,c+=`<rect x="0" y="0" width="100" height="100" fill="${t}" clip-path="url(#clip)"/>`,o&&(c+=`<path d="${o}" fill="${n}" clip-path="url(#clip)"/>`),s&&(c+=`<path d="${s}" fill="${r}" clip-path="url(#clip)"/>`),c+=`<circle cx="50" cy="50" r="47.5" fill="transparent" stroke="#000" stroke-width="5"/>`,c+=`</g></svg>`,c}var[Ht,Ut]=x([]),Wt=0;function B(e,t=`success`,n=4e3){let r=Wt++;Ut(i=>[...i,{id:r,message:e,type:t,duration:n}]),setTimeout(()=>{Ut(e=>e.filter(e=>e.id!==r))},n)}var Gt=!0;function Kt(){return!0}function qt(){return Gt}function Jt(){return window.location.origin}function Yt(){return`0.9.0`}function Xt(){return typeof window>`u`?null:window.__SCREEPS_CLIENT_EMBEDDED__??null}function Zt(){return``}function Qt(e){let t=`[${e}]`;return{log:()=>{},warn:()=>{},error:(...e)=>console.error(t,...e)}}var V={room:`screeps:room`,shard:`screeps:shard`,sidebarWidth:`screeps:sidebarWidth`,consoleHeight:`screeps:consoleHeight`,consoleSplit:`screeps:consoleSplit`,consoleWeights:`screeps:consoleWeights`,memoryWatches:`screeps:memoryWatches`,mapZoom:`screeps:mapZoom`,widescreenMode:`screeps:settings:widescreenMode`,showCreepLabels:`screeps:settings:showCreepLabels`,showMapRoomNames:`screeps:settings:showMapRoomNames`,showUnclaimableRooms:`screeps:settings:showUnclaimableRooms`,terrainEffects:`screeps:settings:terrainEffects`,showRoomDecorations:`screeps:settings:showRoomDecorations`,roomDarkOverlay:`screeps:settings:roomDarkOverlay`,showRoomVisuals:`screeps:settings:showRoomVisuals`,spriteTheme:`screeps:settings:spriteTheme`,showMapVisuals:`screeps:settings:showMapVisuals`},H={url:`screeps:url`,token:`screeps:token`,serverPassword:`screeps:serverPassword`,authMethod:`screeps:authMethod`};function $t(e){return localStorage.getItem(e)}function en(e,t){localStorage.setItem(e,t)}function tn(e){localStorage.removeItem(e)}function nn(e,t){let n=localStorage.getItem(e);if(n===null)return t;let r=Number(n);return Number.isFinite(r)&&r!==0?r:t}function rn(e,t){localStorage.setItem(e,String(t))}function an(e,t){let n=localStorage.getItem(e);if(n===null)return t;try{return JSON.parse(n)}catch{return t}}function on(e,t){localStorage.setItem(e,JSON.stringify(t))}function sn(e){return sessionStorage.getItem(e)}function cn(e,t){sessionStorage.setItem(e,t)}function ln(e){sessionStorage.removeItem(e)}async function un(){if(localStorage.clear(),indexedDB.databases){let e=await indexedDB.databases();await Promise.all(e.map(e=>e.name?new Promise(t=>{let n=indexedDB.deleteDatabase(e.name);n.onsuccess=()=>t(),n.onerror=()=>t(),n.onblocked=()=>t()}):Promise.resolve()))}if(`caches`in window){let e=await caches.keys();await Promise.all(e.map(e=>caches.delete(e)))}}var{log:U}=Qt(`client`),[W,dn]=x(null),[fn,pn]=x(`idle`),[mn,hn]=x(null),[G,gn]=x(null),[_n,vn]=x(null),[K,yn]=x(null),[bn,xn]=x(null),[Sn,Cn]=x(!1),[wn,Tn]=x(null),[En,Dn]=x(null),[On,kn]=x({}),[An,jn]=x(null),Mn=1e3,Nn=15e3,Pn=null,Fn=0;function In(){Pn===null&&(U(`world status polling: start`),Pn=setInterval(()=>{let e=W();e&&e.stores.user.refreshWorldStatus().catch(()=>{})},Mn))}function Ln(){Pn!==null&&(U(`world status polling: stop`),clearInterval(Pn),Pn=null)}function Rn(e){e===`empty`||e===`lost`||Date.now()<Fn?In():Ln()}function zn(){Fn=Date.now()+Nn,In()}var Bn=-1,Vn=-1,Hn=[],Un=5;function Wn(e){if(e===void 0)return;let t=Date.now();if(Bn>=0&&e>Bn){let e=t-Vn;if(e>0){Hn.push(e),Hn.length>Un&&Hn.shift();let t=Hn.reduce((e,t)=>e+t,0)/Hn.length;xn(Math.round(t))}}Bn=e,Vn=t}function Gn(){Bn=-1,Vn=-1,Hn.length=0,xn(null)}var Kn=()=>{let e=_n();return e?(e.serverData?.shards?.length??0)===0:null};async function qn(e){Kt()&&(e={...e,url:Jt()}),U(`connecting to ${e.url} (auth: ${e.auth})`),pn(`connecting`),hn(null);try{let t;if(e.auth===`guest`)t=new _t,Cn(!0);else if(e.auth===`password`){if(!e.email||!e.password)throw Error(`Email and password are required`);t=new gt({email:e.email,password:e.password})}else{if(!e.token)throw Error(`Token is required`);t=new ht({token:e.token})}let n=new mt({url:e.url,auth:t,storage:e.storage??new bt(`screeps-client`),debug:!1,serverPassword:e.serverPassword,decorationsMock:Pt});n.http.on(`http:tokenRefresh`,({token:e})=>{U(`token refreshed`),cn(H.token,e)}),n.http.on(`http:error`,({method:e,path:t,error:n})=>{U(`http error:`,e,t,n.message),B(`Request failed: ${e} ${t} — ${n.message}`,`error`,6e3)}),n.stores.server.on(`server:disconnected`,e=>{U(`server disconnected (willReconnect: ${e.willReconnect})`),e.willReconnect||(pn(`idle`),dn(null),gn(null),vn(null),Fn=0,Rn(null))}),n.stores.server.on(`server:error`,e=>{U(`server error:`,e.error.message),hn(e.error.message),pn(`error`)}),n.stores.user.on(`user:me`,e=>{U(`user: ${e.username} (id: ${e._id})`),gn(e)}),n.stores.server.on(`server:version`,e=>{U(`server version: ${e.package??`unknown`}`),vn(e)}),n.stores.user.on(`user:stream`,e=>{if(e&&typeof e==`object`&&`flags`in e){let t=e.flags;t&&typeof t==`object`&&kn(t)}}),n.stores.user.on(`user:worldStatus`,({status:e})=>{U(`world status: ${e}`),jn(e),Rn(e)}),await n.connect(),n.stores.user.subscribeUserStream(),dn(n),pn(`connected`),U(`connected to ${e.url}`),n.stores.server.worldInfo().then(e=>{Dn(e),U(`world: ${e.width}x${e.height} x[${e.minX},${e.maxX}] y[${e.minY},${e.maxY}]`)}).catch(()=>{}),cn(H.url,e.url);let r=e.authMethod??e.auth;Tn(r),cn(H.authMethod,r),n.http.token&&cn(H.token,n.http.token),e.serverPassword?cn(H.serverPassword,e.serverPassword):ln(H.serverPassword)}catch(e){let t=e instanceof Error?e.message:String(e);throw U(`connection failed:`,t),hn(t),pn(`error`),dn(null),e}}async function Jn(){let e=Kt()?Jt():sn(H.url),t=sn(H.token);if(!e||!t)return;let n=sn(H.serverPassword)??void 0,r=sn(H.authMethod);U(`auto-connect: ${e}`);try{t===`guest`?await qn({url:e,auth:`guest`,storage:null,serverPassword:n}):await qn({url:e,auth:`token`,token:t,serverPassword:n,authMethod:r??`token`})}catch{U(`auto-connect failed — clearing stored token`),ln(H.token)}}function Yn(){U(`disconnecting`);let e=W();e&&e.disconnect(),dn(null),pn(`idle`),hn(null),gn(null),vn(null),yn(null),Cn(!1),Tn(null),Dn(null),kn({}),jn(null),Fn=0,Rn(null),Gn(),ln(H.token),ln(H.url),ln(H.serverPassword),ln(H.authMethod)}var Xn={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`},Zn=N(`<svg>`),Qn=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),$n=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),er=e=>{let t=$n(e);return t.charAt(0).toUpperCase()+t.slice(1)},tr=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),q=e=>{let[n,r]=t(e,[`color`,`size`,`strokeWidth`,`children`,`class`,`name`,`iconNode`,`absoluteStrokeWidth`]);return(()=>{var e=Zn();return Ce(e,i(Xn,{get width(){return n.size??Xn.width},get height(){return n.size??Xn.height},get stroke(){return n.color??Xn.stroke},get"stroke-width"(){return M(()=>!!n.absoluteStrokeWidth)()?Number(n.strokeWidth??Xn[`stroke-width`])*24/Number(n.size):Number(n.strokeWidth??Xn[`stroke-width`])},get class(){return tr(`lucide`,`lucide-icon`,...n.name==null?[]:[`lucide-${Qn(er(n.name))}`,`lucide-${Qn(n.name)}`],n.class==null?``:n.class)}},r),!0,!0),R(e,m(l,{get each(){return n.iconNode},children:([e,t])=>m(Be,i({component:e},t))})),e})()},nr=[[`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`}]],rr=e=>m(q,i(e,{iconNode:nr,name:`bell-off`})),ir=[[`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`}]],ar=e=>m(q,i(e,{iconNode:ir,name:`bell`})),or=[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]],sr=e=>m(q,i(e,{iconNode:or,name:`check`})),cr=[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]],lr=e=>m(q,i(e,{iconNode:cr,name:`chevron-down`})),ur=[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]],dr=e=>m(q,i(e,{iconNode:ur,name:`chevron-right`})),fr=[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]],pr=e=>m(q,i(e,{iconNode:fr,name:`chevron-left`})),mr=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]],hr=e=>m(q,i(e,{iconNode:mr,name:`clock`})),gr=[[`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`}]],_r=e=>m(q,i(e,{iconNode:gr,name:`code-xml`})),vr=[[`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`}]],yr=e=>m(q,i(e,{iconNode:vr,name:`eye`})),br=[[`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`}]],xr=e=>m(q,i(e,{iconNode:br,name:`flag`})),Sr=[[`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`}]],Cr=e=>m(q,i(e,{iconNode:Sr,name:`hammer`})),wr=[[`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`}]],Tr=e=>m(q,i(e,{iconNode:wr,name:`key-round`})),Er=[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]],Dr=e=>m(q,i(e,{iconNode:Er,name:`layout-grid`})),Or=[[`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`}]],kr=e=>m(q,i(e,{iconNode:Or,name:`loader`})),Ar=[[`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`}]],jr=e=>m(q,i(e,{iconNode:Ar,name:`log-in`})),Mr=[[`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`}]],Nr=e=>m(q,i(e,{iconNode:Mr,name:`log-out`})),Pr=[[`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`}]],Fr=e=>m(q,i(e,{iconNode:Pr,name:`map`})),Ir=[[`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`}]],Lr=e=>m(q,i(e,{iconNode:Ir,name:`move`})),Rr=[[`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`}]],zr=e=>m(q,i(e,{iconNode:Rr,name:`pause`})),Br=[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]],Vr=e=>m(q,i(e,{iconNode:Br,name:`play`})),Hr=[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]],Ur=e=>m(q,i(e,{iconNode:Hr,name:`plus`})),Wr=[[`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`}]],Gr=e=>m(q,i(e,{iconNode:Wr,name:`refresh-cw`})),Kr=[[`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`}]],qr=e=>m(q,i(e,{iconNode:Kr,name:`rotate-ccw`})),Jr=[[`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`}]],Yr=e=>m(q,i(e,{iconNode:Jr,name:`settings`})),Xr=[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]],Zr=e=>m(q,i(e,{iconNode:Xr,name:`terminal`})),Qr=[[`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`}]],$r=e=>m(q,i(e,{iconNode:Qr,name:`trash-2`})),ei=[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]],ti=e=>m(q,i(e,{iconNode:ei,name:`x`})),ni=N(`<span style=font-size:11px;display:inline-flex;align-items:center;gap:3px>`),ri=N(`<div style="color:#3fb950;font-size:14px;text-align:center;padding:8px 0">Account created! Logging you in…`),ii=N(`<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>`),ai=N(`<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>`),oi=N(`<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>`),si=N(`<span style=font-size:11px;color:#f85149>Passwords don't match`),ci=N(`<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>`),li=N(`<button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),ui=N(`<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`),di=N(`<form style=display:flex;flex-direction:column;gap:16px><h2 style=margin:0;font-size:20px>Create Account`),fi=N(`<div style=color:#f85149;font-size:13px>`),pi=N(`<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">`),mi=N(`<button type=button style=background:none;border:none;color:#58a6ff;font-size:12px;cursor:pointer;padding:0>Create account`),hi=N(`<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`),gi=N(`<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>`),_i=N(`<div style=color:#8b949e;font-size:12px;margin-top:-8px>`),vi=N(`<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>`),yi=N(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#1b2838;color:#c7d5e0;font-weight:600>Login with Steam`),bi=N(`<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)`),xi=N(`<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><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"></label><button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),Si=N(`<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>`),Ci=N(`<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">`),wi=N(`<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>`),Ti=N(`<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>`),Ei=N(`<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>`),Di=N(`<span style="font-size:11px;padding:2px 8px;border-radius:12px;background:#21262d;border:1px solid #30363d;color:#8b949e;font-family:monospace">`),Oi={padding:`8px 12px`,"border-radius":`6px`,border:`1px solid #30363d`,background:`#0d1117`,color:`#c9d1d9`};function ki(e){let[t,n]=x(null),[r,i]=x(null),[a,o]=x(null);return f(()=>{let t=e();n(null),i(null),o(null);let r=!1,a=setTimeout(async()=>{try{let e=await Dt(t);if(r)return;if(n(e),o(null),Nt(e)){let e=await Ot(t);r||i(e)}}catch{r||(o(`Could not reach server`),n(null))}},400);y(()=>{r=!0,clearTimeout(a)})}),{serverVersion:t,authModInfo:r,serverError:a}}function Ai(e,t,n){let[r,i]=x(`idle`);return f(()=>{let r=t();if(!r){i(`idle`);return}i(`checking`);let a=!1,o=setTimeout(async()=>{try{let t=await n(e(),r);a||i(t.error?`taken`:`available`)}catch{a||i(`error`)}},500);y(()=>{a=!0,clearTimeout(o)})}),r}function ji(e){let t={idle:null,checking:{children:`Checking…`,color:`#8b949e`},available:{children:[m(sr,{size:12}),` Available`],color:`#3fb950`},taken:{children:[m(ti,{size:12}),` Already taken`],color:`#f85149`},error:{children:`Could not verify`,color:`#d29922`}},n=()=>t[e.state];return m(u,{get when(){return n()},get children(){var e=ni();return R(e,()=>n().children),o(t=>L(e,`color`,n().color)),e}})}function Mi(e){let[t,n]=x(``),[r,i]=x(``),[a,s]=x(``),[c,l]=x(``),[d,f]=x(!1),[p,h]=x(null),[g,_]=x(!1),v=Ai(()=>e.url,t,kt),y=Ai(()=>e.url,r,At),b=()=>c()!==``&&a()!==c(),S=()=>!d()&&t()!==``&&r()!==``&&a().length>=4&&a()===c()&&v()!==`taken`&&v()!==`checking`&&y()!==`taken`&&y()!==`checking`,C=async n=>{if(n.preventDefault(),S()){f(!0),h(null);try{let n=await jt(e.url,t(),r(),a());if(n.error){h(n.error);return}_(!0),setTimeout(()=>e.onSuccess(r(),a()),1500)}catch(e){h(e instanceof Error?e.message:`Registration failed`)}finally{f(!1)}}};return(()=>{var f=di();return f.firstChild,f.addEventListener(`submit`,C),R(f,m(u,{get when(){return g()},get children(){return ri()}}),null),R(f,m(u,{get when(){return!g()},get children(){return[(()=>{var e=ii(),r=e.firstChild;r.firstChild;var i=r.nextSibling;return R(r,m(ji,{get state(){return v()}}),null),i.$$input=e=>n(e.currentTarget.value),o(e=>{var t=Oi,n=d();return e.e=I(i,t,e.e),n!==e.t&&(i.disabled=e.t=n),e},{e:void 0,t:void 0}),o(()=>i.value=t()),e})(),(()=>{var e=ai(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return R(t,m(ji,{get state(){return y()}}),null),n.$$input=e=>i(e.currentTarget.value),o(e=>{var t=Oi,r=d();return e.e=I(n,t,e.e),r!==e.t&&(n.disabled=e.t=r),e},{e:void 0,t:void 0}),o(()=>n.value=r()),e})(),(()=>{var e=oi(),t=e.firstChild.nextSibling;return t.$$input=e=>s(e.currentTarget.value),o(e=>{var n=Oi,r=d();return e.e=I(t,n,e.e),r!==e.t&&(t.disabled=e.t=r),e},{e:void 0,t:void 0}),o(()=>t.value=a()),e})(),(()=>{var e=ci(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return R(t,m(u,{get when(){return b()},get children(){return si()}}),null),n.$$input=e=>l(e.currentTarget.value),o(e=>{var t={...Oi,border:b()?`1px solid #f85149`:`1px solid #30363d`},r=d();return e.e=I(n,t,e.e),r!==e.t&&(n.disabled=e.t=r),e},{e:void 0,t:void 0}),o(()=>n.value=c()),e})(),M(()=>M(()=>!!p())()&&(()=>{var e=fi();return R(e,p),e})()),(()=>{var e=li();return R(e,()=>d()?`Creating account…`:`Create Account`),o(t=>{var n=!S(),r=S()?`pointer`:`not-allowed`,i=S()?1:.5;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&L(e,`cursor`,t.t=r),i!==t.a&&L(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})(),(()=>{var t=ui();return t.$$click=()=>e.onCancel(),t})()]}}),null),f})()}function Ni(){let e=Kt(),t=qt(),[n,r]=x(`login`),[i,a]=x(`password`),[s,c]=x(e?Jt():window.location.origin),[d,f]=x(``),[p,h]=x(``),[g,_]=x(``),[v,b]=x(``),{serverVersion:S,authModInfo:C,serverError:w}=ki(s),T=()=>S()?.serverData?.welcomeText??null,E=()=>(S()?.serverData?.features??[]).filter(e=>e.name!==`auth`&&e.version!=null),D=()=>{let e=S();return e?Nt(e)?.authTypes?.includes(`steam`)??!0:!0},O=()=>C()?.allowRegistration===!0||(S()?.serverData?.features??[]).some(e=>e.name===`official-like`),k=()=>{let e=s().replace(/\/$/,``),t=window.open(`${e}/api/auth/steam`,`screeps-steam-auth`,`width=800,height=600,left=200,top=100`),n=t=>{try{let n=JSON.parse(t.data);n.token&&(i(),qn({url:e,auth:`token`,authMethod:`steam`,token:n.token,serverPassword:v()||void 0,storage:null}))}catch{}},r=setInterval(()=>{t?.closed&&i()},500),i=()=>{clearInterval(r),window.removeEventListener(`message`,n)};window.addEventListener(`message`,n),y(i)},ee=async e=>{e.preventDefault(),await qn({url:s(),auth:i(),email:d()||void 0,password:p()||void 0,token:g()||void 0,serverPassword:v()||void 0,storage:null})},te=async e=>{e.preventDefault(),await qn({url:s(),auth:`guest`,serverPassword:v()||void 0,storage:null})},ne=async(e,t)=>{try{await qn({url:s(),auth:`password`,email:e,password:t,serverPassword:v()||void 0,storage:null})}catch{r(`login`),a(`password`),f(e),h(t)}},A=()=>fn()===`connecting`;return(()=>{var y=Ci(),x=y.firstChild;return R(y,m(u,{get when(){return T()},get children(){var e=pi();return o(()=>e.innerHTML=T()),e}}),x),R(x,m(u,{get when(){return n()===`register`},get children(){return m(Mi,{get url(){return s()},get serverPassword(){return v()},onSuccess:ne,onCancel:()=>r(`login`)})}}),null),R(x,m(u,{get when(){return n()===`login`},get children(){var n=xi(),l=n.firstChild;l.firstChild;var y=l.nextSibling,x=y.firstChild;x.firstChild.nextSibling;var S=x.nextSibling,C=y.nextSibling;return n.addEventListener(`submit`,ee),R(l,m(u,{get when(){return O()},get children(){var e=mi();return e.$$click=()=>r(`register`),e}}),null),R(n,m(u,{when:!e,get children(){var e=hi(),t=e.firstChild,n=t.nextSibling;return t.$$click=()=>a(`password`),n.$$click=()=>a(`token`),o(e=>{var r=i()===`password`?`#238636`:`transparent`,a=i()===`token`?`#238636`:`transparent`;return r!==e.e&&L(t,`background`,e.e=r),a!==e.t&&L(n,`background`,e.t=a),e},{e:void 0,t:void 0}),e}}),y),R(n,m(u,{when:!e,get children(){return[(()=>{var e=gi(),t=e.firstChild.nextSibling;return t.$$input=e=>c(e.currentTarget.value),o(e=>I(t,Oi,e)),o(()=>t.value=s()),e})(),m(u,{get when(){return w()},get children(){var e=_i();return R(e,w),e}})]}}),y),R(n,(()=>{var e=M(()=>i()===`password`);return()=>e()?[(()=>{var e=wi(),t=e.firstChild.nextSibling;return t.$$input=e=>f(e.currentTarget.value),o(e=>I(t,Oi,e)),o(()=>t.value=d()),e})(),(()=>{var e=Ti(),t=e.firstChild.nextSibling;return t.$$input=e=>h(e.currentTarget.value),o(e=>I(t,Oi,e)),o(()=>t.value=p()),e})()]:(()=>{var e=Ei(),t=e.firstChild.nextSibling;return t.$$input=e=>_(e.currentTarget.value),o(e=>I(t,Oi,e)),o(()=>t.value=g()),e})()})(),y),S.$$input=e=>b(e.currentTarget.value),R(n,(()=>{var e=M(()=>!!mn());return()=>e()&&(()=>{var e=fi();return R(e,mn),e})()})(),C),R(C,()=>A()?`Connecting…`:`Connect`),R(n,m(u,{get when(){return D()},get children(){return[(()=>{var e=vi();return e.firstChild.nextSibling.nextSibling,e})(),(()=>{var e=yi();return e.$$click=k,o(t=>{var n=A(),r=A()?`not-allowed`:`pointer`,i=A()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&L(e,`cursor`,t.t=r),i!==t.a&&L(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})()]}}),null),R(n,m(u,{when:!e||t,get children(){var e=bi();return e.addEventListener(`mouseleave`,e=>{e.currentTarget.style.borderColor=`#30363d`}),e.addEventListener(`mouseenter`,e=>{A()||(e.currentTarget.style.borderColor=`#8b949e`)}),e.$$click=te,o(t=>{var n=A(),r=A()?`not-allowed`:`pointer`,i=A()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&L(e,`cursor`,t.t=r),i!==t.a&&L(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),o(e=>{var t=Oi,n=A(),r=A()?`not-allowed`:`pointer`,i=A()?.6:1;return e.e=I(S,t,e.e),n!==e.t&&(C.disabled=e.t=n),r!==e.a&&L(C,`cursor`,e.a=r),i!==e.o&&L(C,`opacity`,e.o=i),e},{e:void 0,t:void 0,a:void 0,o:void 0}),o(()=>S.value=v()),n}}),null),R(y,m(u,{get when(){return E().length>0},get children(){var e=Si(),t=e.firstChild.nextSibling;return R(t,m(l,{get each(){return E()},children:e=>(()=>{var t=Di();return R(t,()=>e.name,null),R(t,(()=>{var t=M(()=>!!e.version);return()=>t()?` ${e.version}`:``})(),null),t})()})),e}}),null),y})()}P([`input`,`click`]);var Pi=N(`<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 Fi(){return(()=>{var e=Pi();return e.firstChild.nextSibling,e})()}var Ii=N(`<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`),Li=N(`<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 Ri(){let e=()=>{switch(fn()){case`connected`:return`#238636`;case`connecting`:return`#d29922`;case`error`:return`#f85149`;default:return`#8b949e`}};return(()=>{var t=Li(),n=t.firstChild.firstChild,r=n.nextSibling;return R(r,(()=>{var e=M(()=>fn()===`connected`);return()=>e()?`Online`:fn()})()),R(t,m(u,{get when(){return Sn()},get children(){return Ii()}}),null),o(t=>L(n,`background-color`,e())),t})()}var zi=class{container;hoverGraphics;pendingGraphics;selectionContainer;selectionGraphics=new Map;selectionTypes=new Map;selectionVisuals=new Map;ticker=null;tickerCallback=null;constructor(e){this.container=new E,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 E,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()}},Bi=.2,Vi=3,Hi=class{displaySprite;renderer;rt;scene;gradientTexture;lights=new Map;dirty=!1;destroyed=!1;constructor(e){this.renderer=e,this.gradientTexture=Ui(),this.rt=oe.create({width:600,height:600}),this.scene=new E;let t=new w;t.rect(0,0,600,600),t.fill({color:0,alpha:Bi}),this.scene.addChild(t),this.displaySprite=new j(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 j(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 Ui(){let e=Vi*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(),D.from(n)}var J=48,Wi=128,Gi={terrain:0,objects:10,animations:20,darkOverlay:30,visuals:40,hover:50,nav:60},Ki=new Set([`road`,`constructedWall`,`rampart`]),qi=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 E({sortableChildren:!0}),this.app.stage.addChild(this.world),this.lighting=new Hi(this.app.renderer),this.darkOverlay=this.lighting.displaySprite,this.darkOverlay.label=`darkOverlay`,this.darkOverlay.zIndex=Gi.darkOverlay,this.world.addChild(this.darkOverlay),this.lightLayer=new E,this.lightLayer.label=`lightLayer`,this.hoverLayer=new zi(e.ticker),this.hoverLayer.container.zIndex=Gi.hover,this.world.addChild(this.hoverLayer.container),this.navOverlay=new E,this.navOverlay.zIndex=Gi.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 ee;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?Wi:0;if(t<=n){let r=n/2-t/2;e?this.world.x=Math.min(r+Wi,Math.max(r-Wi,this.world.x)):this.world.x=r}else{let e=n-t-J-i,r=J+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+Wi,Math.max(n-Wi,this.world.y)):this.world.y=n}else{let e=r-t-J-i,n=J+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-J,i=J;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-J,r=J;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 te(0,0),n=new te(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 te(u.clientX,u.clientY),n=new te(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 te(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 re(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,J,600,[18,300,J-6,282,J-6,318],e.west),t(600,0,J,600,[J-18,300,6,282,6,318],e.east),t(0,-48,600,J,[300,18,282,J-6,318,J-6],e.north),t(0,600,600,J,[300,J-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`&&Ki.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}))}},Ji=856343,Yi=1448738,Xi=1843496,Zi=Ji,Qi=7039337,$i=3159613,ea={tough:5000268,move:11122630,work:16770413,carry:7829367,attack:16332866,ranged_attack:6127794,heal:6684002,claim:12164347},ta=5809919,na=7979263,ra=4176208,ia=9147550,aa=13801762,oa=10711543,sa=16218298,ca=16273737,la=15763518,ua=2172461,da=Qi,fa=12283502,pa=[16777215,16711680,8388736,255,65535,32768,16776960,16753920,10824234,8421504,16777215],ma={creep:la,spawn:ta,extension:na,tower:ra,container:ia,storage:aa,link:oa,rampart:ta,road:da,constructedWall:ua,extractor:ia,lab:sa,terminal:aa,observer:na,powerSpawn:la,nuker:ca,factory:ia,invaderCore:ca,source:aa,mineral:na,deposit:aa,controller:ta,powerBank:la,portal:oa},ha=16771195,ga=ha,_a=na,va=ha,ya=na,ba=ha,xa=ha,Sa=ca,Ca=ra,wa=na,Ta=9419667,Ea=7245682,Da=12116924,Oa=12283502,ka=9787480,Aa=14721184,ja=Xi,Ma=13684944,Y=1579032,Na=5592405,Pa=11184810,Fa=9419667,X=16771195,Ia=16069959,La={energy:X,power:Ia,H:13421772,O:16777215,U:5822457,L:62626,K:10514943,Z:16631694,X:11568379,G:16777215},Ra=5617743,za=9099642,Ba=11680314,Va=14049376;function Ha(e){return e}function Ua(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 Wa(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 Ga(e,t){let n=Qi,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)!==nt.Wall&&r(e,0,`up`),t.get(e,49)!==nt.Wall&&r(e,49,`down`);for(let e=0;e<50;e++)t.get(0,e)!==nt.Wall&&r(0,e,`left`),t.get(49,e)!==nt.Wall&&r(49,e,`right`)}function Ka(e){let t=new w;return t.rect(0,0,600,600),t.fill(e.floorColor),t}function qa(e,t){let n=new w,r={color:t.swampBorderColor,width:12*t.swampBorderWidth,alignment:0,cap:`round`,join:`round`};return Wa(n,e,nt.Swamp,e=>e.stroke(r)),Wa(n,e,nt.Swamp,e=>e.fill(t.swampFillColor)),n}function Ja(e,t){let n=new w,r={color:t.wallBorderColor,width:12*t.wallBorderWidth,alignment:0,cap:`round`,join:`round`};return Wa(n,e,nt.Wall,e=>e.stroke(r)),Wa(n,e,nt.Wall,e=>e.fill(t.wallFillColor)),Ga(n,e),n.rect(0,0,600,600),n.stroke({width:1,color:$i}),n}function Ya(e,t){let n=new w;return n.label=`swampGlow`,Wa(n,e,nt.Swamp,e=>e.fill(t.swampGlowColor)),n.alpha=.45,n.filters=[new ae({strength:5,quality:3})],n}function Xa(e,t,n){let r=new w;Wa(r,e,nt.Wall,e=>e.fill(n.wallNoiseColor)),r.alpha=.5,r.filters=[new A({noise:.12,seed:1})],r.filterArea=new re(0,0,600,600);let i=t.generateTexture({target:r,frame:r.filterArea});r.filters=null,r.destroy();let a=new j(i);return a.label=`wallNoise`,a}function Za(e,t,n){let r=Ua(n),i=new E,a=Xa(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(Ka(r)),i.addChild(qa(e,r)),i.addChild(Ja(e,r)),i.addChild(Ya(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;T.load(Ha(e)).then(e=>{if(i.destroyed)return;let n=new k({texture:e,width:600,height:600});n.tint=t,n.alpha=r,n.tileScale.set(a),i.addChildAt(n,2)}).catch(()=>{})}if(n?.wallTextureUrl){let{wallTextureUrl:t,wallTextureTint:r=16777215,wallTextureAlpha:a=1,wallTextureTileScale:o=1}=n;T.load(Ha(t)).then(t=>{if(i.destroyed)return;let n=new k({texture:t,width:600,height:600});n.tint=r,n.alpha=a,n.tileScale.set(o);let s=new w;Wa(s,e,nt.Wall,e=>e.fill(16777215)),i.addChild(s),n.mask=s,i.addChild(n)}).catch(()=>{})}return i}function Qa(e,t){e.getChildByLabel(`swampGlow`).visible=t,e.getChildByLabel(`wallNoise`).visible=t}function $a(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 eo(e){return parseInt(e.replace(`#`,``),16)}function to(e,t){if(e==null)return t;let n=Number(e);return isNaN(n)?t:n}function no(e,t,n){let r=n.terrain??{};e.floorBackgroundColor&&(r.floorColor=$a(e.floorBackgroundColor,to(e.floorBackgroundBrightness,1))),e.swampColor&&(r.swampFillColor=eo(e.swampColor)),e.swampStrokeColor&&(r.swampBorderColor=eo(e.swampStrokeColor)),e.swampStrokeWidth!=null&&(r.swampBorderWidth=to(e.swampStrokeWidth,50)/250),e.roadsColor&&(n.roadColor=$a(e.roadsColor,to(e.roadsBrightness,1))),t.floorForegroundUrl&&(r.floorTextureUrl=t.floorForegroundUrl,e.floorForegroundColor&&(r.floorTextureTint=$a(e.floorForegroundColor,to(e.floorForegroundBrightness,1))),r.floorTextureAlpha=to(e.floorForegroundAlpha,1),r.floorTextureTileScale=to(e.tileScale??t.tileScale,1)),n.terrain=r}function ro(e,t,n){let r=n.terrain??{};e.backgroundColor&&(r.wallFillColor=$a(e.backgroundColor,to(e.backgroundBrightness,1))),e.strokeColor&&(r.wallBorderColor=$a(e.strokeColor,to(e.strokeBrightness,1))),e.strokeWidth!=null&&(r.wallBorderWidth=to(e.strokeWidth,10)/250),t.foregroundUrl&&(r.wallTextureUrl=t.foregroundUrl,e.foregroundColor&&(r.wallTextureTint=$a(e.foregroundColor,to(e.foregroundBrightness,1))),r.wallTextureAlpha=to(e.foregroundAlpha,1),r.wallTextureTileScale=to(e.tileScale??t.tileScale,1)),n.terrain=r}function io(e){let t={};for(let n of e.decorations){let e=n.decoration.type;e===`floorLandscape`?no(n.active,n.decoration,t):e===`wallLandscape`&&ro(n.active,n.decoration,t)}return t}function ao(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=n,r.src=e})}var oo=class{cache=new Map;pending=new Map;getKey(e){return JSON.stringify(e)}has(e){return this.cache.has(this.getKey(e))}getOrCreate(e){let t=this.getKey(e),n=this.cache.get(t);if(n)return Promise.resolve(n);let r=this.pending.get(t);if(r)return r;let i=this.buildTexture(e,t);return this.pending.set(t,i),i.then(()=>{this.pending.delete(t)}).catch(()=>{this.pending.delete(t)}),i}async buildTexture(e,t){let n=Vt(e),r=new Blob([n],{type:`image/svg+xml;charset=utf-8`}),i=URL.createObjectURL(r);try{let e=window.devicePixelRatio||1,n=128*Math.max(2,e),r=await ao(i),a=document.createElement(`canvas`);a.width=n,a.height=n,a.getContext(`2d`).drawImage(r,0,0,n,n);let o=D.from(a);return this.cache.set(t,o),o}finally{URL.revokeObjectURL(i)}}destroy(){for(let e of this.cache.values())e.destroyed||e.destroy(!0);this.cache.clear(),this.pending.clear()}},so={1:200,2:45e3,3:135e3,4:405e3,5:1215e3,6:3645e3,7:10935e3},co={1:2e4,2:1e4,3:2e4,4:4e4,5:8e4,6:12e4,7:15e4,8:2e5},lo=new oo,uo=12*.44,fo=12*.28,po=50,mo=32,ho=12/mo,go=12/2-12*.44,_o=2,vo=12*1.2/mo,yo=5,bo=2.5,xo=2,So=2.6,Co=2,wo=12,To=15790320,Eo=1710618,Do=12*.42,Oo=12*.3,ko=1,Ao={H:2236962,O:2236962},jo={biomass:8695826,metal:9793372,mist:14314485,silicon:5023717},Mo=.2,No=12*.42,Po=32,Fo=9/Po,Io=8,Lo=1600,Ro=16776428,zo=4473924,Bo=1.7999999999999998;function Vo(e,t){return t<=0?Io:Io*Math.max(0,Math.min(1,e/t))}function Ho(e){let t=e%Lo/Lo;return .5-.5*Math.cos(t*Math.PI*2)}function Uo(e){return Qo(X,Ro,Ho(e))}function Wo(e,t,n){e.clear();let r=t<=0,i=Io/2,a=Io*.25;if(e.roundRect(6-i,6-i,Io,Io,a),e.fill(Y),r)e.roundRect(6-i,6-i,Io,Io,a),e.stroke({width:Bo,color:Qo(Y,zo,Ho(n))});else{let r=t/2;e.roundRect(6-r,6-r,t,t,t*.25),e.fill(Uo(n))}}function Go(e,t){let n=e.__sourceGraphics;n&&(e.__sourceSize=t,Wo(n,t,performance.now()))}function Ko(e){return{energy:typeof e.energy==`number`?e.energy:0,capacity:typeof e.energyCapacity==`number`?e.energyCapacity:3e3}}var qo=12*.3,Jo=1.44,Yo=qo-Jo/2,Xo=12*.42,Zo=1500;function Qo(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 $o(e,t){e.clear(),e.circle(12/2,12/2,qo),e.stroke({width:Jo,color:t,alpha:.95})}var es=12*.975,ts=2.16,ns=Math.PI/3,rs=1;function is(e,t){e.clear();for(let n=0;n<3;n++){let r=n*(2*Math.PI/3)+ns/2,i=r+2*Math.PI/3-ns;e.arc(0,0,es,r,i),e.stroke({width:ts,color:t,cap:`round`})}}function as(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 os=12*.5,ss=1.2000000000000002;function cs(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 ls(e){let t=e.spawning;return!t||typeof t!=`object`?null:`${String(t.name)}:${String(t.needTime)}:${String(t.remainingTime)}:${String(t.spawnTime)}`}function us(e,t,n){return Math.max(0,Math.min(1,1-(t-n)/e))}function ds(e,t){if(e.clear(),t===null||(e.circle(6,6,os),e.stroke({width:ss,color:16777215,alpha:.12}),t<=0))return;let n=-Math.PI/2,r=n+Math.min(1,t)*Math.PI*2;e.moveTo(6+os*Math.cos(n),6+os*Math.sin(n)),e.arc(6,6,os,n,r),e.stroke({width:ss,color:X,alpha:.95,cap:`round`})}function fs(e,t,n){return n.flatMap(([n,r])=>[e+n*12,t+r*12])}function ps(e,t,n,r){n-t<.001||(e.moveTo(uo*Math.cos(t),uo*Math.sin(t)),e.arc(0,0,uo,t,n),e.lineTo(fo*Math.cos(n),fo*Math.sin(n)),e.arc(0,0,fo,n,t,!0),e.closePath(),e.fill(r))}function ms(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 hs(e,t){return t<=0||e<=0?0:fo*.8*Math.min(1,e/t)}function gs(e,t){let n=e.__creepFillGraphics;n&&(n.clear(),t>0&&(n.circle(0,0,t),n.fill(ha)))}function _s(e){return ma[e]??13226457}function vs(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 ys(e){return e>=200?1.15:e>=100?.85:.7}function bs(e,t){return t<=0||e<=0?0:Oo*ys(t)*Math.min(1,e/t)}var xs=12*.25,Ss=12*.3;function Cs(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function ws(e,t){let n=e.__linkFillGraphics;if(!n||(n.clear(),t<=0))return;let r=xs*t,i=Ss*t;n.poly([6,6-i,6+r,6,6,6+i,6-r,6]),n.fill(X)}function Ts(e,t,n,r){let i=ys(n),a=new w;a.circle(6,6,Do*i),a.fill(Y),a.circle(6,6,Do*i),a.stroke({width:ko*i,color:r}),a.circle(6,6,Oo*i),a.fill(Pa),e.addChild(a);let o=new w,s=bs(t,n);s>0&&(o.circle(6,6,s),o.fill(X)),e.addChild(o),e.__fillGraphics=o}function Es(e,t){let n=e.__fillGraphics;n&&(n.clear(),t>0&&(n.circle(6,6,t),n.fill(X)))}var Ds=-12*.4,Os=-12*.3,ks=12*.8,As=12*.6,js=.4,Ms=.3,Ns=Math.PI/6,Ps=Math.PI/2;function Fs(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 Is=12*.45,Ls=12*.6,Rs=12*.275,zs=12*.2,Bs=.5;function Vs(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function Hs(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(X);return}let i=.5,a=As*t;n.rect(Ds+i,Os+As-a+i,ks-i*2,a-i*2),n.fill(X)}var Us=0,Ws=-12*.1,Gs=12,Ks=12*1.2,qs=[`energy`,`power`];function Js(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=qs.indexOf(e),r=qs.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:La[e]??7105644,amount:t})),used:o,capacity:t,dominant:i}}function Ys(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(X);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 Xs(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 Zs(e,t){return t<=0||e<=0?0:Ls*Math.min(1,e/t)}function Qs(e,t){let n=e.__containerFillG;n&&(n.clear(),Ys(n,Rs,zs+Ls,Is,t,e.__containerBands,e.__containerUsed??0,Bs))}function $s(e,t){return t<=0||e<=0?0:Ks*Math.min(1,e/t)}function ec(e,t){let n=e.__storageFillG;n&&(n.clear(),Ys(n,Us,Ws+Ks,Gs,t,e.__storageBands,e.__storageUsed??0))}function tc(e){return La[e]??7105644}function Z(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}var nc=12*.35;function rc(e,t){let n=e.__terminalFillG;if(n&&(n.clear(),t>0)){let r=nc*t;n.rect(6-r,6-r,r*2,r*2),n.fill(e.__terminalFillColor??16771195)}}var ic=12*.025,ac=12*.36,oc=12*.05,sc=12*.8,cc=12*.9,lc=12*.25,uc=2e3,dc=3e3;function fc(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:uc,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]:dc;return{energy:r,energyCap:i,mineralType:a,mineral:o,mineralCap:s}}function pc(e,t,n){let r=e.__labMineralG;r&&(r.clear(),n>0)&&(r.circle(6,6-ic,ac*n),r.fill(e.__labMineralColor??7105644));let i=e.__labEnergyG;if(i&&(i.clear(),t>0)){let e=.5;i.rect(oc+e,sc+e,(cc-e*2)*t,lc-e*2),i.fill(X)}}var mc=3e5,hc=5e3,gc=-.8,_c=.2,vc=.4,yc=-.34,bc=.34,xc=.27,Sc=.45;function Cc(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:mc,ghodium:typeof t.G==`number`?t.G:0,ghodiumCap:typeof n.G==`number`?n.G:hc}}function wc(e,t,n){let r=e.__nukerEnergyG;if(r&&(r.clear(),t>0)){let e=_c-gc,n=_c-e*t,i=vc*(n-gc)/e;r.poly([6+i*12,6+n*12,6+vc*12,6+_c*12,6-vc*12,6+_c*12,6-i*12,6+n*12]),r.fill(X)}let i=e.__nukerGhodiumG;if(i&&(i.clear(),n>0)){let e=6+yc*12,t=6+xc*12,r=(bc-yc)*12,a=(Sc-xc)*12;i.rect(e,t,r*n,a),i.fill(tc(`G`))}}var Tc=8,Ec=12*.4,Dc=12*.5,Oc=.22,kc=12*.25,Ac=12*.32,jc=12*.24,Mc=12*.28,Nc=12*.38,Pc=12*.36,Fc=5,Ic=16777215;function Lc(){let e=2*Math.PI/Tc,t=[];for(let n=0;n<Tc;n++){let r=-Math.PI/2+n*e,i=r-Oc,a=r+Oc,o=r-e+Oc;for(let e=0;e<=3;e++){let n=o+(i-o)*(e/3);t.push(6+Ec*Math.cos(n),6+Ec*Math.sin(n))}for(let e=0;e<=3;e++){let n=i+(a-i)*(e/3);t.push(6+Dc*Math.cos(n),6+Dc*Math.sin(n))}}return t}var Rc=Lc();function zc(e){return typeof e.cooldown==`number`&&e.cooldown>0}function Bc(e,t){e.clear(),e.poly(Rc),e.fill(Y),e.poly(Rc),e.stroke({width:12*.06,color:t})}function Vc(e,t){e.clear();let n=.14,r=2*Math.PI/Fc-n;for(let i=0;i<Fc;i++){let a=-Math.PI/2+i*(2*Math.PI/Fc)+n/2,o=a+r;e.moveTo(6+kc*Math.cos(a),6+kc*Math.sin(a)),e.arc(6,6,Ac,a,o),e.arc(6,6,kc,o,a,!0),e.closePath(),e.fill(i<t?Pa:Na)}}function Hc(e,t){return t<=0||e<=0?0:Mc*Math.min(1,e/t)}function Uc(e,t){let n=e.__factoryFillG;n&&(n.clear(),Ys(n,Nc,Pc+Mc,jc,t,e.__factoryBands,e.__factoryUsed??0,.5))}var Wc=12*.65,Gc=Wc,Kc=12*.42;function qc(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 Jc(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 Yc(e,t){let n=e.user;return typeof n!=`string`||!t?!1:n!==t}function Xc(e,t=!0,n,r,i,a,o,s){let c=new E,l=new w,u=_s(e.type),d=typeof e.user==`string`?e.user:void 0,f=d!==void 0&&n!==void 0&&d!==n?fa:Fa;switch(e.type){case`creep`:{let t=2*Math.PI,r=new E;r.position.set(6,6),r.rotation=-Math.PI/2;let o=Yc(e,n);if(o){let e=new w;e.circle(0,0,uo+.75),e.stroke({width:1.5,color:fa}),r.addChild(e)}let s=new w;s.circle(0,0,uo),s.fill(Ji),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/po*t,g=d/po*t,_=f/po*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,T=new w;h>0&&ps(T,-h/2,v,ea.work??16770413);let D=v;for(let e of p){let n=(m[e]??0)/po*t/2;ps(T,D,D+n,ea[e]??7829367),D+=n}ps(T,y,b,ja),g>0&&ps(T,b,x,ea.move??11122630),ps(T,x,S,ja);let O=C;for(let e of p){let n=(m[e]??0)/po*t/2;ps(T,O-n,O,ea[e]??7829367),O-=n}r.addChild(T);let k=new w;k.circle(0,0,fo),k.fill(Yi),r.addChild(k);let ee=typeof e.user==`string`?e.user:void 0,te=ee?a?.[ee]?.badge:void 0;if(te&&i){let e=new j;e.anchor.set(.5,.5);let t=fo*2;e.width=t,e.height=t,e.rotation=Math.PI/2,r.addChild(e),c.__creepBadgeSprite=e,i.getOrCreate(te).then(t=>{e.destroyed||(e.texture=t)}).catch(()=>{})}else if(o){let e=new w;e.circle(0,0,fo*.82),e.fill({color:fa,alpha:.9}),r.addChild(e),c.__creepForeignMark=e}let{used:ne,capacity:A}=ms(e),re=hs(ne,A),ie=new w;re>0&&(ie.circle(0,0,re),ie.fill(ha)),r.addChild(ie),c.__creepFillGraphics=ie,c.__creepUsed=ne,c.__creepCapacity=A;let ae=(uo+fo)/2,oe=(uo-fo)*.45,se=new w;se.moveTo(uo,0),se.lineTo(ae,-oe),se.lineTo(ae,oe),se.closePath(),se.fill(Ma),r.addChild(se),c.addChild(r),c.__bodyContainer=r;break}case`extension`:{let{energy:t,capacity:n}=vs(e);Ts(c,t,n,f),c.__extEnergy=t,c.__extCapacity=n;break}case`spawn`:{l.circle(6,6,12*.65),l.fill(Y),l.circle(6,6,12*.65),l.stroke({width:12*.1,color:13421772}),l.circle(6,6,12*.4),l.fill(X),c.sortableChildren=!0;let t=new w;t.zIndex=1;let n=cs(e,0),r=n?us(n.needTime,n.endTime,0):null;ds(t,r),c.addChild(t);let i=c;i.__spawnRing=t,i.__spawnRatio=r,n&&(i.__spawnNeedTime=n.needTime,i.__spawnEndTime=n.endTime),i.__spawnSig=ls(e);break}case`powerSpawn`:l.circle(6,6,12*.65),l.fill(Y),l.circle(6,6,12*.65),l.stroke({width:12*.1,color:Ia}),l.circle(6,6,12*.4),l.fill(X);break;case`source`:{let{energy:t,capacity:n}=Ko(e),r=Vo(t,n),i=new w;Wo(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?Ta:Oa,a=r?Ea:ka,o=r?Da:Aa,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;as(d,6,6,Yo,s,l,i),c.addChild(d),c.__csFillGraphics=d;let f=new w;$o(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 j;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]??D.EMPTY)}).catch(()=>{})}else{let e=La[t]??7979263,n=Ao[t]??16777215,r=new w;r.circle(6,6,No),r.fill(e),c.addChild(r);let i=new ne({text:t,style:{fontSize:Po,fill:n,fontWeight:`bold`}});i.anchor.set(.5,.5),i.scale.set(Fo),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=jo[t];for(let e of[`deposit/${t}/shape`,`deposit/${t}/fill`]){let t=e.endsWith(`/fill`),n=new j;n.anchor.set(.5,.5),n.x=6,n.y=6,i!==void 0&&(n.tint=i),t&&(n.alpha=Mo),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]??D.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 j;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 j;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,Jc(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]??D.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]??D.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+Wc*Math.cos(t),6+Wc*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;qc(a,6,6,Gc,Kc,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,Kc),p.fill(Y)):(p.circle(6,6,Kc),p.fill(3028031),p.circle(6,6,Kc),p.stroke({width:12*.04,color:8027781}),p.circle(6,6,12*.16),p.fill(10133672)),c.addChild(p),d&&i){let e=new j;e.anchor.set(.5,.5),e.width=Kc*2,e.height=Kc*2,e.position.set(6,6);let t=new w;t.circle(6,6,Kc),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(X);break;case`road`:break;case`constructedWall`:break;case`rampart`:break;case`tower`:{let{energy:t,capacity:n}=vs(e),r=o?.tower;if(r&&s){let e=12*r.tileScale,i=new j;i.anchor.set(.5,.5),i.position.set(6,6),i.tint=f,c.addChild(i);let a=new E;a.position.set(6,6),c.addChild(a);let l=new j;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},Hs(c,Vs(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]??D.EMPTY),!l.destroyed){let t=e.textures[r.bodyFrame]??D.EMPTY;l.texture=t,c.destroyed||d(t)}}).catch(()=>{});break}let i=new w;i.circle(6,6,12*.6),i.fill(Y),i.circle(6,6,12*.6),i.stroke({width:12*.05,color:f}),c.addChild(i);let a=new E;a.position.set(6,6);let l=new w;l.rect(Ds,Os,ks,As),l.fill(Y),a.addChild(l);let u=new w;a.addChild(u),c.__towerFillGraphics=u,c.__towerEnergy=t,c.__towerCapacity=n,Hs(c,Vs(t,n));let d=new w;d.rect(Ds,Os,ks,As),d.stroke({width:1,color:Na}),a.addChild(d);let p=new w;p.rect(-12*.2,-12*.9,12*.4,12*.5),p.fill(Pa),p.rect(-12*.2,-12*.9,12*.4,12*.5),p.stroke({width:12*.07,color:Y}),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}=Js(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 j;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]??D.EMPTY)}).catch(()=>{})}let u=new w;c.addChild(u),c.__storageFillG=u,c.__storageBands=n,c.__storageUsed=r,c.__storageCapacity=i,ec(c,$s(r,i));break}let{bands:n,used:r,capacity:i}=Js(e),a=fs(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(Y),l.poly(a),l.stroke({width:12*.05,color:f}),l.rect(6-12*.5,6-12*.6,12,12*1.2),l.fill(Na),c.addChild(l);let u=new w;c.addChild(u),c.__storageFillG=u,c.__storageBands=n,c.__storageUsed=r,c.__storageCapacity=i,ec(c,$s(r,i));let d=new w;d.rect(6-12*.5,6-12*.6,12,12*1.2),d.stroke({width:12*.1,color:Y}),c.addChild(d);break}case`terminal`:{let t=fs(6,6,[[0,-.8],[.55,-.55],[.8,0],[.55,.55],[0,.8],[-.55,.55],[-.8,0],[-.55,-.55],[0,-.8]]),n=fs(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(Y),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(Pa),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.fill(Na),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.stroke({width:12*.1,color:Y}),c.addChild(l);let{used:r,capacity:i,dominant:a}=Js(e),o=new w;c.addChild(o);let s=c;s.__terminalFillG=o,s.__terminalDominant=a??void 0,s.__terminalFillColor=a?tc(a):X,s.__terminalUsed=r,s.__terminalCapacity=i,rc(s,Z(r,i));break}case`link`:{let t=fs(6,6,[[0,-.5],[.4,0],[0,.5],[-.4,0],[0,-.5]]),n=fs(6,6,[[0,-.3],[.25,0],[0,.3],[-.25,0],[0,-.3]]);l.poly(t),l.fill(Y),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(Na),c.addChild(l);let{energy:r,capacity:i}=vs(e),a=new w;c.addChild(a);let o=c;o.__linkFillGraphics=a,o.__linkEnergy=r,o.__linkCapacity=i,ws(o,Cs(r,i));break}case`lab`:{let t=6-12*.025;l.circle(6,t,12*.55),l.fill(Y),l.circle(6,t,12*.55),l.stroke({width:12*.05,color:f}),l.circle(6,t,12*.4),l.fill(Na),c.addChild(l);let{energy:n,energyCap:r,mineralType:i,mineral:a,mineralCap:o}=fc(e),s=new w;c.addChild(s);let u=new w;u.rect(6-12*.45,9.6,12*.9,12*.25),u.fill(Y),u.poly(fs(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?tc(i):void 0,p.__labEnergy=n,p.__labEnergyCap=r,p.__labMineral=a,p.__labMineralCap=o,pc(p,Z(n,r),Z(a,o));break}case`container`:{let{bands:t,used:n,capacity:r}=Js(e);l.rect(Rs,zs,Is,Ls),l.fill(Y),l.rect(Rs+Bs,zs+Bs,Is-Bs*2,Ls-Bs*2),l.fill(Na),c.addChild(l);let i=new w;c.addChild(i),c.__containerFillG=i,c.__containerBands=t,c.__containerUsed=n,c.__containerCapacity=r,Qs(c,Zs(n,r));let a=new w;a.rect(Rs,zs,Is,Ls),a.stroke({width:12*.1,color:Y}),c.addChild(a);break}case`observer`:l.circle(6,6,12*.45),l.fill(Y),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=fs(6,6,[[0,-1],[-.47,.2],[-.5,.5],[.5,.5],[.47,.2],[0,-1]]),n=fs(6,6,[[0,-.8],[-.4,.2],[.4,.2],[0,-.8]]);l.poly(t),l.fill(Y),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(Na),l.poly(n),l.stroke({width:12*.01,color:f}),c.addChild(l);let{energy:r,energyCap:i,ghodium:a,ghodiumCap:o}=Cc(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,wc(d,Z(r,i),Z(a,o));break}case`factory`:{let t=typeof e.level==`number`?e.level:0,{bands:n,used:r,capacity:i}=Js(e),a=new w;Bc(a,f),c.addChild(a),l.rect(Nc,Pc,jc,Mc),l.fill(Na),c.addChild(l);let o=new w;Vc(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.__factoryActive=zc(e),u.__factoryGlowColor=f,Uc(u,Hc(r,i));break}case`extractor`:{let e=new w;e.position.set(6,6),is(e,d===void 0?ia:f),c.addChild(e),c.__extractorRing=e;break}case`invaderCore`:l.circle(6,6,12*.45),l.fill(Y),l.circle(6,6,12*.45),l.stroke({width:12*.05,color:f}),l.circle(6,6,12*.35),l.fill(Na);break;case`flag`:{let n=typeof e.color==`number`?e.color:0,r=typeof e.secondaryColor==`number`?e.secondaryColor:0,i=pa[n]??pa[0],a=pa[r]??pa[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 j;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]??D.EMPTY)}).catch(()=>{}),r!==n){let e=new j;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]??D.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 ne({text:e.name,style:{fontSize:mo,fill:16777215}});n.scale.set(ho),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?Ta:fa,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?Ta:fa,i=o?.tombstone;if(i&&s){let e=12*i.tileScale,t=()=>s.getOrLoad(o.atlasUrl),n=new j;n.anchor.set(.5,.5),n.x=6,n.y=6,n.width=e,n.height=e,c.addChild(n);let a=new j;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]??D.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]??D.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(Y),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}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`&&c.addChild(l),e.type===`creep`&&typeof e.name==`string`){let r=Yc(e,n),i;if(r){let t=typeof e.user==`string`?e.user:void 0;i=t?a?.[t]?.username??t:`Hostile`}else i=e.name;let o=new ne({text:i,style:{fontSize:mo,fill:r?fa:16777215}});o.scale.set(ho),o.anchor.set(.5,1),o.x=6,o.y=go-_o,o.visible=t,c.__nameLabel=o,c.addChild(o)}return c.zIndex=(e.type===`creep`?100:e.type===`flag`?200:0)+(e.type===`flag`?o?.flag?.zIndex??0:e.type===`controller`?o?.controller?.zIndex??0:e.type===`tombstone`?o?.tombstone?.zIndex??0:e.type===`mineral`?o?.mineral?.zIndex??0:e.type===`extractor`?rs:o?.sprites[e.type]?.zIndex??0),c.position.set(e.x*12,e.y*12),c}function Zc(e){e.destroy({children:!0})}function Qc(e){let t=new ne({text:e.length>wo?e.slice(0,wo):e,style:{fontSize:mo,fill:Eo,fontWeight:`600`}});t.scale.set(vo),t.anchor.set(.5,.5);let n=t.width,r=t.height,i=n+yo*2,a=r+bo*2,o=a/2,s=new w;s.roundRect(-i/2,-a/2,i,a,o),s.fill(To),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+So),s.lineTo(xo,a/2-.1),s.closePath(),s.fill(To),s.moveTo(-2,a/2-.1),s.lineTo(0,a/2+So),s.lineTo(xo,a/2-.1),s.stroke({width:.4,color:1118481,alpha:.55});let c=new E;return c.addChild(s),c.addChild(t),c.pivot.set(0,a/2+So),c}var $c=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;EXT_ANIM_DURATION=300;instantMode=!1;lastWorldScale=1;showLabels;currentUserId;badge;badgeCache=lo;users;activeTheme=null;atlasCache=null;roadColor=da;lighting=null;constructor(e,t=!0,n,r,i){this.showLabels=t,this.currentUserId=n,this.badge=r,this.users=i,this.container=new E,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 ae({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()}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/Zo);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=Fs(t.rotation,e.__towerAimAngle,Ms):(e.__towerAimUntil!==void 0&&(e.__towerIdlePhase=t.rotation-i*js,e.__towerAimUntil=void 0,e.__towerAimAngle=void 0),t.rotation=i*js+(e.__towerIdlePhase??0))}e.__extractorRing&&(e.__extractorRing.rotation=i*Ns),e.__csRingGraphics&&e.__csColorDark!==void 0&&e.__csColorLight!==void 0&&$o(e.__csRingGraphics,Qo(e.__csColorDark,e.__csColorLight,a)),e.__factoryGearG&&e.__factoryActive&&Bc(e.__factoryGearG,Qo(e.__factoryGlowColor??9419667,Ic,.5*a))}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&&Wo(t,e.__sourceSize??Io,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,Xo),i.fill({color:X,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=co[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=Qo(16777215,Qo(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,Es,bs(n,r),bs(i,a))}startLinkAnimation(e,t,n,r,i,a){this.startFill(e,t,ws,Cs(n,r),Cs(i,a))}startCreepFillAnimation(e,t,n,r,i,a){this.startFill(e,t,gs,hs(n,r),hs(i,a))}startTowerFillAnimation(e,t,n,r,i,a){this.startFill(e,t,Hs,Vs(n,r),Vs(i,a))}startStorageFillAnimation(e,t,n,r,i,a){this.startFill(e,t,ec,$s(n,r),$s(i,a))}startContainerFillAnimation(e,t,n,r,i,a){this.startFill(e,t,Qs,Zs(n,r),Zs(i,a))}startTerminalFillAnimation(e,t,n,r,i,a){this.startFill(e,t,rc,Z(n,r),Z(i,a))}startFactoryFillAnimation(e,t,n,r,i,a){this.startFill(e,t,Uc,Hc(n,r),Hc(i,a))}startLabFillAnimation(e,t,n,r,i,a,o,s,c,l){this.startFill(e,t,pc,Z(n,r),Z(o,s),Z(i,a),Z(c,l))}startNukerFillAnimation(e,t,n,r,i,a,o,s,c,l){this.startFill(e,t,wc,Z(n,r),Z(o,s),Z(i,a),Z(c,l))}startSourceAnimation(e,t,n,r,i,a){this.startFill(e,t,Go,Vo(n,r),Vo(i,a))}update(e,t,n,r){n&&(this.users=n),r!==void 0&&(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),Zc(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}=ms(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)}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),Zc(r),this.objects.delete(n);let e=Xc(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}=vs(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}=vs(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}=vs(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}=Js(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 Xs(r.__storageBands,e)||(r.__storageBands=e,ec(r,$s(i,a)))}if(t.type===`container`){let{bands:e,used:i,capacity:a}=Js(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 Xs(r.__containerBands,e)||(r.__containerBands=e,Qs(r,Zs(i,a)))}if(t.type===`terminal`){let{used:e,capacity:i,dominant:a}=Js(t),o=a??void 0;if(r.__terminalDominant!==o&&(r.__terminalDominant=o,r.__terminalFillColor=o?tc(o):X,rc(r,Z(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)}}if(t.type===`lab`){let{energy:e,energyCap:i,mineralType:a,mineral:o,mineralCap:s}=fc(t),c=a??void 0;if(r.__labMineralType!==c&&(r.__labMineralType=c,r.__labMineralColor=a?tc(a):void 0,pc(r,Z(e,i),Z(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)}}if(t.type===`nuker`){let{energy:e,energyCap:i,ghodium:a,ghodiumCap:o}=Cc(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===`factory`){let{bands:e,used:i,capacity:a}=Js(t),o=typeof t.level==`number`?t.level:0,s=zc(t);if(r.__factoryLevel!==o&&r.__factoryRingG&&(r.__factoryLevel=o,Vc(r.__factoryRingG,o)),r.__factoryActive!==s&&(r.__factoryActive=s,!s&&r.__factoryGearG&&Bc(r.__factoryGearG,r.__factoryGlowColor??9419667)),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 Xs(r.__factoryBands,e)||(r.__factoryBands=e,Uc(r,Hc(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),Zc(r),this.objects.delete(n);let e=Xc(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}),Jc(r,e,i,a)):r.__ctrlSegGraphics&&qc(r.__ctrlSegGraphics,12/2,12/2,Gc,Kc,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}=Ko(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&&as(r.__csFillGraphics,12/2,12/2,Yo,e,n,r.__csColor??9419667),r.__csProgress=e,r.__csProgressTotal=n)}}else{let e=Xc(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}=ms(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)}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),Zc(i),this.objects.delete(n);let e=Xc(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}=vs(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}=vs(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}=vs(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),Zc(i),this.objects.delete(n);let e=Xc(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}),Jc(i,e,t,a)):i.__ctrlSegGraphics&&qc(i.__ctrlSegGraphics,12/2,12/2,Gc,Kc,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}=Ko(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&&as(i.__csFillGraphics,12/2,12/2,Yo,e,t,i.__csColor??9419667),i.__csProgress=e,i.__csProgressTotal=t)}}else{let e=Xc(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),Zc(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?ls(n):null;if(r!==t.__spawnSig){t.__spawnSig=r;let e=n&&r?cs(n,this.currentGameTime):null;t.__spawnNeedTime=e?.needTime,t.__spawnEndTime=e?.endTime}let i=t.__spawnNeedTime!==void 0&&t.__spawnEndTime!==void 0?us(t.__spawnNeedTime,t.__spawnEndTime,this.currentGameTime):null;i!==t.__spawnRatio&&(ds(t.__spawnRing,i),t.__spawnRatio=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(Y);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:Ra,alpha:.4}:{color:Ba,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,za),i(r,Va)}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(ho/t),e.__nameLabel.anchor.y===0?e.__nameLabel.y=12.600000000000001:e.__nameLabel.y=go-_o/t),e.__sayBubble&&!e.__sayBubble.destroyed&&(e.__sayBubble.scale.set(1/t),e.__sayBubble.position.set(12/2,go-Co/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||!Yc(n,this.currentUserId))continue;let r=typeof n.user==`string`?n.user:void 0,i=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`||!Yc(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 j;o.anchor.set(.5,.5);let s=fo*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)+Ps,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=Qc(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)}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())Zc(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}},el=2,tl=3,nl=12*.45,rl=.55;function il(e,t){return{cx:e*12+12/2,cy:t*12+12/2}}var al=class{container;graphics;animations=[];ticker=null;tickerCallback=null;constructor(e){this.container=new E,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=il(e,t),o=il(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:ga,width:el,glowAtSource:!0})}addUpgradeController(e,t,n,r,i){let a=il(e,t),o=il(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:_a,width:el})}addTransfer(e,t,n,r,i){let a=il(e,t),o=il(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:ba,width:el})}addBuild(e,t,n,r,i){let a=il(e,t),o=il(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:va,width:el})}addRepair(e,t,n,r,i){let a=il(e,t),o=il(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:ya,width:el})}addLinkTransfer(e,t,n,r,i){let a=il(e,t),o=il(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:xa,width:el})}addTowerBeam(e,t,n,r,i,a){let o=il(e,t),s=il(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:tl})}addTowerAttack(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,Sa)}addTowerHeal(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,Ca)}addTowerRepair(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,wa)}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)*rl,n=r.width/el*nl*(.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()}},ol=e=>(e+.5)*12,sl={dashed:[.3*12,.25*12],dotted:[.1*12,.2*12]},cl=2400;function ll(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 ul(e){if(typeof e!=`string`)return`sans-serif`;let t=e.match(/^[0-9.]+(px)?\s+(.+)$/);return t?t[2]:`sans-serif`}var dl=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=D.from(this.canvas,!0),this.lastPhysSize=r,this.sprite=new j(this.texture),this.sprite.scale.set(600/r),this.container=new E,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),cl)}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=D.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`?sl.dotted:t.lineStyle===`dashed`?sl.dashed:[]),r.beginPath(),r.moveTo(ol(e.x1),ol(e.y1)),r.lineTo(ol(e.x2),ol(e.y2)),r.stroke(),r.restore()}drawCircle(e,t,n){let{ctx:r}=this;r.save(),r.globalAlpha=n,r.setLineDash(t.lineStyle===`dotted`?sl.dotted:t.lineStyle===`dashed`?sl.dashed:[]),r.beginPath(),r.arc(ol(e.x),ol(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`?sl.dotted:t.lineStyle===`dashed`?sl.dashed:[]),r.beginPath(),r.rect(ol(e.x),ol(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`?sl.dotted:t.lineStyle===`dashed`?sl.dashed:[]),r.beginPath(),r.moveTo(ol(e.points[0][0]),ol(e.points[0][1]));for(let t=1;t<e.points.length;t++)r.lineTo(ol(e.points[t][0]),ol(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=ll(t.font)*12,a=ul(t.font),o=t.align??`left`,s=ol(e.x),c=ol(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})}};function fl(e,t){let n=localStorage.getItem(e),[r,i]=x(n===null?t:n===`true`);return[r,t=>{i(t),localStorage.setItem(e,String(t))}]}function pl(e,t){let[n,r]=x(localStorage.getItem(e)??t);return[n,t=>{r(t),localStorage.setItem(e,t)}]}var[ml,hl]=fl(V.widescreenMode,!0),[gl,_l]=fl(V.showCreepLabels,!0),[vl,yl]=fl(V.showMapRoomNames,!1),[bl,xl]=fl(V.showUnclaimableRooms,!0),[Sl,Cl]=fl(V.terrainEffects,!0),[wl,Tl]=fl(V.showRoomDecorations,!1),[El,Dl]=fl(V.roomDarkOverlay,!0),[Ol,kl]=fl(V.showRoomVisuals,!0),[Al,jl]=pl(V.spriteTheme,`default`),[Ml,Nl]=fl(V.showMapVisuals,!0),Pl=Yt(),Fl=Pl?`?v=${encodeURIComponent(Pl)}`:``,Il={id:`default`,name:`Default`,atlasUrl:`${Zt()}/themes/default/sprite-0.json${Fl}`,sprites:{storage:{layers:[{frame:`storage/shell`,tint:`owner`},{frame:`storage/fill`}],tileScale:1.75}},controller:{backgroundFrame:`controller/background`,segmentFrame:`controller/segment`,tileScale:2},flag:{mainFrame:`flag/main`,secondFrame:`flag/second`,tileScale:3,zIndex:5},tombstone:{shellFrame:`grave/shell`,crossFrame:`grave/cross`,tileScale:1,zIndex:4},deposit:{tileScale:1.2},mineral:{tileScale:2.6},tower:{ringFrame:`tower/ring`,bodyFrame:`tower/body`,tileScale:2.5,fill:{x:-39,yMin:-25,width:78,heightMax:58,rx:12,ry:12}}},Ll=class{cache=new Map;pending=new Map;frames=new Map;getOrLoad(e){let t=this.cache.get(e);if(t)return Promise.resolve(t);let n=this.pending.get(e);if(n)return n;let r=T.load(e).then(t=>(this.cache.set(e,t),this.frames.set(e,Rl(t)),this.pending.delete(e),t)).catch(t=>{throw this.pending.delete(e),t});return this.pending.set(e,r),r}getTexture(e,t){return this.frames.get(e)?.[t]}destroy(){for(let[,e]of this.cache){for(let t of e.linkedSheets??[])t.destroy(!0);e.destroy(!0)}this.cache.clear(),this.frames.clear(),this.pending.clear()}};function Rl(e){let t={...e.textures};for(let n of e.linkedSheets??[])Object.assign(t,n.textures);return t}var zl=new Ll,Bl=Symbol(`store-raw`),Vl=Symbol(`store-node`),Hl=Symbol(`store-has`),Ul=Symbol(`store-self`),Wl={onStoreNodeUpdate:null};function Gl(e){let t=e[c];if(!t&&(Object.defineProperty(e,c,{value:t=new Proxy(e,$l)}),!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 Kl(e){let t;return typeof e==`object`&&!!e&&(e[c]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function ql(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[Bl])return n;if(!Kl(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=ql(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=ql(i,t))!==i&&(e[a]=r))}return e}function Jl(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Yl(e,t,n){if(e[t])return e[t];let[r,i]=x(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function Xl(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===c||t===Vl?n:(delete n.value,delete n.writable,n.get=()=>e[c][t],n)}function Zl(e){s()&&Yl(Jl(e,Vl),Ul)()}function Ql(e){return Zl(e),Reflect.ownKeys(e)}var $l={get(e,t,n){if(t===Bl)return e;if(t===c)return n;if(t===p)return Zl(e),n;let r=Jl(e,Vl),i=r[t],a=i?i():e[t];if(t===Vl||t===Hl||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);s()&&(typeof a!=`function`||e.hasOwnProperty(t))&&!(n&&n.get)&&(a=Yl(r,t,a)())}return Kl(a)?Gl(a):a},has(e,t){return t===Bl||t===c||t===p||t===Vl||t===Hl||t===`__proto__`?!0:(s()&&Yl(Jl(e,Hl),t)(),t in e)},set(){return console.warn(`Cannot mutate a Store directly`),!0},deleteProperty(){return console.warn(`Cannot mutate a Store directly`),!0},ownKeys:Ql,getOwnPropertyDescriptor:Xl};function eu(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;Wl.onStoreNodeUpdate&&Wl.onStoreNodeUpdate(e,t,n,i),n===void 0?(delete e[t],e[Hl]&&e[Hl][t]&&i!==void 0&&e[Hl][t].$()):(e[t]=n,e[Hl]&&e[Hl][t]&&i===void 0&&e[Hl][t].$());let o=Jl(e,Vl),s;if((s=Yl(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=Yl(o,`length`,a))&&s.$(e.length)}(s=o[Ul])&&s.$()}function tu(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];nu(i)||eu(e,i,t[i])}}function nu(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function ru(e,t){if(typeof t==`function`&&(t=t(e)),t=ql(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&&eu(e,n,r)}eu(e,`length`,r)}else tu(e,t)}function iu(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&&nu(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++)iu(e,[r[i]].concat(t),n);return}else if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&iu(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)iu(e,[r].concat(t),n);return}else if(t.length>1){iu(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=ql(a),r===void 0||Kl(i)&&Kl(a)&&!Array.isArray(a)?tu(i,a):eu(e,r,a))}function au(...[e,t]){let n=ql(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=Gl(n);_.registerGraph({value:n,name:t&&t.name});function a(...e){h(()=>{r&&e.length===1?ru(n,e[0]):iu(n,e)})}return[i,a]}var ou=Symbol(`store-root`);function su(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function cu(e,t,n,r,i){if(su(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==ou&&(!Kl(e)||!Kl(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){eu(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++)cu(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++)eu(a,n,e[n]);for(;n<e.length;n++)eu(a,n,f[n]),cu(e[n],a,n,r,i);a.length>e.length&&eu(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?(eu(a,n,f[n]),cu(e[n],a,n,r,i)):eu(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)cu(e[t],a,t,r,i);a.length>e.length&&eu(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)su(s[t])||cu(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&&eu(a,c[t],void 0)}function lu(e,t={}){let{merge:n,key:r=`id`}=t,i=ql(e);return e=>{if(!Kl(e)||!Kl(i))return i;let t=cu(i,{[ou]:e},ou,n,r);return t===void 0?e:t}}var uu=new WeakMap;function du(e,t){let[n,r]=au(t),i={id:e,type:t.type,raw:n};return uu.set(i,e=>r(lu(e,{key:`_id`,merge:!1}))),i}var[fu,pu]=x([]);function mu(){pu([])}function hu(e){pu(t=>t.filter(t=>t.id!==e))}function gu(e,t){let n=fu(),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&&uu.get(a)?.(e)}i.push(a)}r&&pu(i)}function _u(e){let t=fu();if(t.length===0)return;let n=!1,r=[];for(let i of t){let t=e[i.id];if(!t){n=!0;continue}uu.get(i)?.(t),r.push(i)}n&&pu(r)}var[vu,yu]=x(null),[bu,xu]=x(null),[Su,Cu]=x(null),[wu,Tu]=x(null),[Eu,Du]=x(null),[Ou,ku]=x({}),[Au,ju]=x(null),[Mu,Nu]=x(null),[Pu,Fu]=x(null);function Iu(e,t,n){return isNaN(n.minX)||isNaN(n.maxX)||isNaN(n.minY)||isNaN(n.maxY)?!0:e>=n.minX&&e<=n.maxX&&t>=n.minY&&t<=n.maxY}function Lu(e){let t=e.match(/^([WE])(\d+)([NS])(\d+)$/);if(!t)return null;let[,n,r,i,a]=t;return{x:n===`W`?-(parseInt(r,10)+1):parseInt(r,10),y:i===`N`?-(parseInt(a,10)+1):parseInt(a,10)}}function Ru(e,t){let n=e<0?`W`:`E`,r=t<0?`N`:`S`;return`${n}${e<0?-e-1:e}${r}${t<0?-t-1:t}`}function zu(e){return e===0||e<0&&(e+1)%10==0||e>0&&e%10==0}function Bu(e,t){return zu(e)||zu(t)}function Vu(e,t){let n=e<0?Math.abs(e+1)%10:Math.abs(e)%10,r=t<0?Math.abs(t+1)%10:Math.abs(t)%10;return n>=4&&n<=6&&r>=4&&r<=6}function Hu(e){let t=e;if(!t)return!1;let n=t.tagName??``;return n===`INPUT`||n===`TEXTAREA`?!0:t.isContentEditable===!0}function Uu(e){let t=t=>{if(Hu(t.target))return;let n=e.currentRoom(),r=n?Lu(n):null;if(!r)return;let i=e.worldBounds(),a=(e,t)=>!i||Iu(e,t,i);switch(t.key){case`ArrowLeft`:t.preventDefault(),a(r.x-1,r.y)&&e.onMove(r.x-1,r.y);break;case`ArrowRight`:t.preventDefault(),a(r.x+1,r.y)&&e.onMove(r.x+1,r.y);break;case`ArrowUp`:t.preventDefault(),a(r.x,r.y-1)&&e.onMove(r.x,r.y-1);break;case`ArrowDown`:t.preventDefault(),a(r.x,r.y+1)&&e.onMove(r.x,r.y+1);break}};window.addEventListener(`keydown`,t),y(()=>window.removeEventListener(`keydown`,t))}var[Q,Wu]=x(!1),[Gu,Ku]=x(0),[qu,Ju]=x(0),[Yu,Xu]=x(0),[Zu,Qu]=x(!1),[$u,ed]=x(1),[td,nd]=x(!1),rd=null;function id(){rd!==null&&(clearInterval(rd),rd=null)}function ad(){id(),rd=setInterval(()=>{let e=Gu()+1;e>Yu()?(id(),Qu(!1)):Ku(e)},Math.max(50,Math.round(1e3/$u())))}function od(e){let t=e,n=Math.max(0,t-2e5);Xu(t),Ju(n),Ku(e),Qu(!1),id(),Wu(!0)}function sd(){id(),Qu(!1),Wu(!1)}function cd(e){Ku(Math.max(qu(),Math.min(Yu(),e)))}function ld(e){cd(Gu()+e)}function ud(){Zu()?(id(),Qu(!1)):(Qu(!0),ad())}function dd(e){ed(e),Zu()&&ad()}var fd=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{let i=t-this.chunkSize;if(i<0)throw Error(`No history data available before tick ${t}`);n=await this.loadChunk(i),t=i;let a=Object.keys(n.ticks).map(Number).filter(e=>e>=t),o=a.length>0?Math.max(...a):t;r=o,e=o}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}}},pd=N(`<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`),md=N(`<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`),hd=N(`<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`),gd=N(`<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`),_d=N(`<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`),vd=N(`<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:yd,warn:bd,error:xd}=Qt(`build`),Sd={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},Cd={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}},[wd,Td]=x(`view`),[Ed,Dd]=x({name:``,color:`COLOR_WHITE`,secondaryColor:`COLOR_WHITE`}),[Od,kd]=x(null),[Ad,jd]=x(null),[Md,Nd]=x({structureType:``,structureName:``});v(()=>{f(()=>{let e=Md().structureType;if(!e)return;let t=Su()??0,n=Cd[e];if(!n)return;let r=An()===`empty`&&e===`spawn`?Math.max(n[t]??0,1):n[t]??0;r!==2500&&(Ou()[e]??0)>=r&&(Nd({structureType:``,structureName:``}),Pd())})});function Pd(){kd(null)}function Fd(){jd(null)}function Id(){Nd({structureType:``,structureName:``})}function Ld(e,t){let n=W(),r=Md(),i=Od();if(!n||!r.structureType||!i){bd(`missing requirements`,{hasClient:!!n,structureType:r.structureType,pending:i});return}if(An()===`empty`&&r.structureType===`spawn`){yd(`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(()=>(yd(`spawn placed`),B(`Spawn placed successfully`,`success`),Pd(),n.stores.user.refreshWorldStatus())).catch(e=>{xd(`place spawn failed:`,e),B(`Failed to place spawn: ${e.message}`,`error`)});return}yd(`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(()=>{yd(`construction site created`),B(`Construction site for ${r.structureType} created`,`success`),Pd()}).catch(e=>{xd(`create construction failed:`,e),B(`Failed to create construction site: ${e.message}`,`error`)})}function Rd(){Td(`view`),Pd(),Fd(),Id()}function zd(){Td(`view`),Pd(),r(Ad)?.type!==`moveFlag`&&Fd(),Id()}function Bd(){let e=wd(),t=Od(),n=Ad(),r=An();if(r===`empty`)return(()=>{var e=pd(),t=e.firstChild.nextSibling;return t.$$click=()=>{Td(`build`),Nd({structureType:`spawn`,structureName:``})},e})();if(r===`lost`)return(()=>{var e=md(),t=e.firstChild.nextSibling;return t.$$click=()=>{let e=W();e&&e.http.user.respawn().then(()=>{B(`Respawn successful`,`success`),zn()}).catch(e=>{B(`Respawn failed: ${e.message}`,`error`)})},e})();if(n?.type===`moveFlag`)return(()=>{var e=hd(),t=e.firstChild,r=t.firstChild.nextSibling;return r.nextSibling,t.nextSibling,R(t,()=>n.name,r),R(t,()=>n.targetRoom,null),e})();if(e===`flag`)return(()=>{var e=gd(),n=e.firstChild;return n.nextSibling,R(n,t?`Click again to confirm position`:`Click to choose flag position`),e})();if(e===`build`){let e=Md(),t=Su(),n=Ou(),r=e.structureType;if(!r)return(()=>{var e=_d();return e.firstChild.nextSibling.nextSibling,e})();let i=Cd[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=vd(),t=e.firstChild;return t.nextSibling.nextSibling,R(t,`Click to build ${o} (${s})`),e})()}return null}P([`click`]);var Vd=N(`<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>`),Hd=N(`<div style=width:100%;height:100%;position:relative><div style=width:100%;height:100%>`),Ud=N(`<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">`),Wd=N(`<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:Gd,error:Kd}=Qt(`room`);function qd(e,t,n=4){e.http.game.genUniqueFlagName().then(r=>{if(r.name===t&&n>0){setTimeout(()=>qd(e,t,n-1),200);return}Dd(e=>({...e,name:r.name}))}).catch(e=>Kd(`gen unique flag name failed:`,e))}function Jd(e){let t=e=>e==="default"?Il:null,n,i=null,s=null,c=null,l=null,d=null,[p,h]=x(null),[g,_]=x(null),[v,b]=x(null),[S,C]=x(null),[w,T]=x(``),[E,D]=x(Gu());f(()=>D(Gu()));let O=null;return a(async()=>{n&&h(await qi.create(n))}),y(()=>{O!==null&&clearTimeout(O),i?.destroy(),i=null,c?.destroy(),c=null,l?.destroy(),l=null;let e=p();e&&e.destroy()}),f(()=>{let t=W();if(!t||Q())return;let n=e.room,i=e.shard;Gd(`navigate → ${n} (shard=${i??`default`})`),_(null),b(null),C(null),T(``),yn(null),mu(),Fu(n),Nu(i),yu(null),xu(null),Cu(null),Tu(null),Du(null),ku({}),ju(null);let a=new xt,o=!1;t.stores.room.terrain(n,i).then(e=>{o||(Gd(`terrain loaded — ${n}`),_({room:n,data:e}))}).catch(e=>{o||Kd(`terrain load failed for ${n}:`,e)}),r(wl)&&t.http.game.roomDecorations(n,i).then(e=>{o||(Gd(`decorations loaded — ${n}: ${e.decorations.length} item(s)`),b({room:n,decoration:io(e)}))}).catch(e=>{o||Gd(`no decorations for ${n}: ${e}`)}),a.add(t.stores.room.subscribe(n,i)),a.add(t.stores.room.on(`room:error`,e=>{B(`Room subscription error (${e.room}): ${e.message}`,`error`,8e3)})),a.add(t.stores.room.on(`room:update`,e=>{let t=0,r={},i=0,a=null,o=null,s=null;for(let n in e.objects){t++;let c=e.objects[n];if(!c)continue;let l=c.type;if(typeof l==`string`)if(l===`constructionSite`){let e=c.structureType;typeof e==`string`&&(r[e]=(r[e]||0)+1)}else r[l]=(r[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||Gd(`objects loaded — ${n}: ${t} objects, tick=${e.gameTime}`),C({objects:e.objects,diff:e.diff,users:e.users}),T(e.visual),yn(e.gameTime??null),Wn(e.gameTime),yu(t),xu(o),Cu(i||null),Tu(a),Du(s),ku(r),ju(e.users??null)})),y(()=>{Gd(`leaving ${n}`),o=!0,a.dispose()})}),f(()=>{let t=W();if(!t||!Q())return;T(``);let n=e.room,i=e.shard,a=Kn()??!0,o=_n()?.serverData?.historyChunkSize??(a?20:100),s=r(Au)??void 0,c=new fd(n,i,t.http,o);f(()=>{let e=Gu(),t=!1;nd(!0),c.getStateAtTick(e).then(e=>{if(t)return;if(nd(!1),e.clampedTo!==void 0){Xu(e.clampedTo),cd(e.clampedTo);return}C({objects:e.objects,diff:void 0,users:s}),yn(e.gameTime);let n=0,r={},i=0,a=null,o=null,c=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:s?.[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`&&(c={user:e.user,endTime:e.endTime})}}yu(n),xu(o),Cu(i||null),Tu(a),Du(c),ku(r)}).catch(n=>{t||(nd(!1),B(`History load failed for tick ${e}: ${n.message}`,`error`,5e3))}),y(()=>{t=!0})})}),f(()=>{let t=p();if(!t)return;e.room,e.shard,zd(),t.hoverLayer.clearPendingTile();let n=r(Ad);n?.type===`moveFlag`?jd({...n,targetRoom:e.room}):t.resetView(),d?.destroy(),d=null,t.clear(),t.resetView(),i?.destroy(),i=null,c?.destroy(),c=null,l?.destroy(),l=null;let a=r(g);if(a&&a.room===e.room){Gd(`terrain applied immediately (pre-loaded) — ${e.room}`);let n=r(v);d=Za(a.data,t.app.renderer,n?.room===e.room?n.decoration.terrain:void 0),Qa(d,r(Sl)),d.zIndex=Gi.terrain,t.world.addChild(d),t.bringNavOverlayToTop()}let o=e.room,s=e.shard,u=Lu(o),f=r(()=>e.onNavigate),m=r(En);if(u&&f){let e=(e,t)=>!m||Iu(e,t,m),n=e=>{Gd(`navigate requested: ${o} → ${e}`),f(e,s)};t.setupNavigationZones({west:e(u.x-1,u.y)?()=>n(Ru(u.x-1,u.y)):void 0,east:e(u.x+1,u.y)?()=>n(Ru(u.x+1,u.y)):void 0,north:e(u.x,u.y-1)?()=>n(Ru(u.x,u.y-1)):void 0,south:e(u.x,u.y+1)?()=>n(Ru(u.x,u.y+1)):void 0})}}),f(()=>{let t=p();if(!t)return;let n=r(()=>e.room),i=r(()=>e.shard),a=Lu(n);if(a&&e.onNavigate){let r=e.onNavigate,o=En(),s=(e,t)=>!o||Iu(e,t,o),c=e=>{Gd(`navigate requested: ${n} → ${e}`),r(e,i)};Uu({currentRoom:()=>e.room,worldBounds:En,onMove:(e,t)=>c(Ru(e,t))}),t.setupNavigationZones({west:s(a.x-1,a.y)?()=>c(Ru(a.x-1,a.y)):void 0,east:s(a.x+1,a.y)?()=>c(Ru(a.x+1,a.y)):void 0,north:s(a.x,a.y-1)?()=>c(Ru(a.x,a.y-1)):void 0,south:s(a.x,a.y+1)?()=>c(Ru(a.x,a.y+1)):void 0})}}),f(()=>{let e=wd(),t=p();e===`view`&&t&&(Pd(),t.hoverLayer.clearPendingTile())}),f(()=>{let e=p(),t=Od();e&&(t?e.hoverLayer.setPendingTile(t.tx,t.ty):e.hoverLayer.clearPendingTile())}),f(()=>{let t=p(),n=g();if(!t||!n||n.room!==e.room)return;if(d?.parent){Gd(`terrain already in scene, skipping — ${e.room}`);return}Gd(`terrain applied (async) — ${e.room}`);let i=r(v);d=Za(n.data,t.app.renderer,i?.room===e.room?i.decoration.terrain:void 0),Qa(d,r(Sl)),t.world.addChildAt(d,0),t.bringNavOverlayToTop()}),f(()=>{if(wl())return;b(null);let t=r(p),n=r(g);!t||!n||n.room!==e.room||d?.parent&&(d.destroy(),d=Za(n.data,t.app.renderer),Qa(d,r(Sl)),t.world.addChildAt(d,0),t.bringNavOverlayToTop(),i?.setRoadColor(da))}),f(()=>{let t=p(),n=v(),a=r(g);!t||!n||n.room!==e.room||!a||a.room!==e.room||d?.parent&&(Gd(`decoration arrived, rebuilding terrain layer — ${e.room}`),d.destroy(),d=Za(a.data,t.app.renderer,n.decoration.terrain),Qa(d,r(Sl)),t.world.addChildAt(d,0),t.bringNavOverlayToTop(),i&&n.decoration.roadColor!=null&&i.setRoadColor(n.decoration.roadColor))}),f(()=>{let n=p(),a=S();if(!n)return;if(!a){i?.clear(),c?.clear(),n.clearLighting();return}let{objects:o,diff:u,users:d}=a,f=i?u:void 0;if(!i){Gd(`object layer created — ${e.room}`),i=new $c(n.app.ticker,gl(),G()?._id,G()?.badge,d),i.setTheme(t(r(Al)),zl),i.setInstantMode(r(Q));let a=r(v);a?.room===e.room&&a.decoration.roadColor!=null&&i.setRoadColor(a.decoration.roadColor),i.setLightingLayer(n.lighting),i.container.label=`objects`,i.container.zIndex=Gi.objects,n.world.addChild(i.container),c=new al(n.app.ticker),c.container.label=`animations`,c.container.zIndex=Gi.animations,n.world.addChild(c.container),l=new dl(n.app.renderer,n.world,n.app.ticker),l.container.zIndex=Gi.visuals,n.world.addChild(l.container),n.setTileHandlers((e,t)=>{},(t,r,a)=>{let o=e.room,s=e.shard,c=wd(),l=Ad();if(l?.type===`moveFlag`){let e=W();if(!e)return;let{name:n,room:i,color:a,secondaryColor:o,targetRoom:c}=l;e.http.game.removeFlag(i,n).then(()=>e.http.game.createFlag(c,t,r,n,a,o,s??void 0)).then(()=>{B(`Flag "${n}" moved`,`success`),Fd()}).catch(e=>{Kd(`move flag failed:`,e),B(`Failed to move flag "${n}"`,`error`),Fd()});return}if(c===`flag`){let e=Od();if(!e||e.tx!==t||e.ty!==r){kd({tx:t,ty:r}),n.hoverLayer.setPendingTile(t,r);return}let i=W();if(!i)return;let a=Ed(),c=a.name.trim();if(!c){B(`Flag name is required`,`error`);return}let l=Sd[a.color]??0,u=Sd[a.secondaryColor]??0;i.http.game.createFlag(o,t,r,c,l,u,s??void 0).then(()=>{B(`Flag "${c}" created`,`success`),Pd(),n.hoverLayer.clearPendingTile(),qd(i,c)}).catch(e=>Kd(`create flag failed:`,e));return}if(c===`build`){if(!a&&!Md().structureType){B(`Select a structure type first`,`error`);return}if(a){if(!i)return;let e=i.getObjectsAtTile(t,r).filter(({obj:e})=>e.type===`constructionSite`);if(e.length===0){B(`No construction sites on this tile`,`error`);return}let a=W();if(!a)return;a.http.game.removeConstructionSite(o,e.map(({id:e})=>e),s??void 0).then(()=>{B(`Removed ${e.length} construction site${e.length>1?`s`:``}`,`success`),Pd(),n.hoverLayer.clearPendingTile()}).catch(e=>{Kd(`remove construction sites failed:`,e),B(`Failed to remove construction sites: ${e.message}`,`error`)});return}kd({tx:t,ty:r}),n.hoverLayer.setPendingTile(t,r),Ld(o,s);return}if(Pd(),n.hoverLayer.clearPendingTile(),!i)return;let u=i.getObjectsAtTile(t,r);if(u.length===0){a||(pu([]),n.hoverLayer.clearSelection());return}let d=[...fu()];if(a){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})=>du(e,t));d=[...d,...e]}}else d=u.map(({id:e,obj:t})=>du(e,t));pu(d);let f=d.map(({id:e,type:t})=>({id:e,type:t,visual:i.getVisualById(e)})).filter(e=>e.visual!=null);n.hoverLayer.setSelectedObjects(f)},()=>{let e=wd();(e===`build`||e===`flag`||Ad()?.type===`moveFlag`)&&(Rd(),n.hoverLayer.clearPendingTile())})}f?gu(f,o):_u(o);let m=Q()?Math.round(1e3/r($u)):bn()??2e3,h=m*.6,g=Math.round(m*.9);i.setMoveDuration(g),s={objects:o,users:d},i.update(o,f,d,K()??void 0),i.setShowLabels(r(gl));let _=new Set;if(c){c.clear();for(let e in o){let t=o[e];if(!t)continue;let n=t.actionLog;if(!n)continue;if(t.type===`tower`){let r=n.attack,a=n.heal,o=n.repair;r&&c.addTowerAttack(t.x,t.y,r.x,r.y,h),a&&c.addTowerHeal(t.x,t.y,a.x,a.y,h),o&&c.addTowerRepair(t.x,t.y,o.x,o.y,h);let s=r??a??o;s&&i?.triggerTowerAim(e,s.x,s.y,h);continue}if(t.type===`link`){let e=n.transferEnergy;e&&c.addLinkTransfer(t.x,t.y,e.x,e.y,h);continue}if(t.type!==`creep`)continue;let r=n.harvest;r&&c.addHarvest(r.x,r.y,t.x,t.y,h);let a=n.upgradeController;a&&c.addUpgradeController(t.x,t.y,a.x,a.y,h);let s=n.build;s&&(c.addBuild(t.x,t.y,s.x,s.y,h),i?.triggerBuildAt(s.x,s.y,h));let l=n.repair;l&&c.addRepair(t.x,t.y,l.x,l.y,h);let u=n.transfer;u&&c.addTransfer(t.x,t.y,u.x,u.y,h);let d=n.say;d&&typeof d.message==`string`&&d.message.length>0&&(i?.triggerSay(e,d.message),_.add(e))}}i.pruneSayBubblesExcept(_),r(El)&&n.updateLighting(o)}),f(()=>{let e=w();l?.update(Ol()?e:``)}),f(()=>{i?.setInstantMode(Q())}),f(()=>{let e=Sl();d&&Qa(d,e)}),f(()=>{let e=p();if(!e)return;let t=El();e.darkOverlay.visible=t,e.lightLayer.visible=t,t||e.clearLighting()}),f(()=>{let e=t(Al());i&&(i.setTheme(e,zl),s&&(i.clear(),i.update(s.objects,void 0,s.users)))}),(()=>{var e=Hd(),t=e.firstChild;return we(e=>n=e,t),R(e,(()=>{var e=M(()=>!!Bd());return()=>e()&&(()=>{var e=Ud();return R(e,Bd),o(t=>L(e,`pointer-events`,An()===`empty`||An()===`lost`?`auto`:`none`)),e})()})(),null),R(e,(()=>{var e=M(()=>!Q()&&K()!==null);return()=>e()&&(()=>{var e=Wd();return e.firstChild,R(e,K,null),e})()})(),null),R(e,m(u,{get when(){return Q()},get children(){var e=Vd(),t=e.firstChild,n=t.nextSibling.firstChild,r=n.nextSibling,i=r.nextSibling;return t.$$input=e=>{let t=parseInt(e.currentTarget.value,10);D(t),O!==null&&clearTimeout(O),O=setTimeout(()=>{O=null,cd(t)},150)},R(n,qu),R(r,(()=>{var e=M(()=>!!td());return()=>e()?`Loading…`:`Tick ${Gu()}`})()),R(i,Yu),o(e=>{var n=qu(),i=Yu(),a=td()?`#f0883e`:`#8b949e`;return n!==e.e&&F(t,`min`,e.e=n),i!==e.t&&F(t,`max`,e.t=i),a!==e.a&&L(r,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),o(()=>t.value=E()),e}}),null),e})()}P([`input`]);var Yd=N(`<div style=position:fixed;bottom:16px;right:16px;display:flex;flex-direction:column;gap:8px;z-index:9999;pointer-events:none>`),Xd=N(`<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 Zd(){return(()=>{var e=Yd();return R(e,m(l,{get each(){return Ht()},children:e=>(()=>{var t=Xd();return R(t,()=>e.message),o(n=>L(t,`background`,e.type===`error`?`#da3633`:`#238636`)),t})()})),e})()}var[Qd,$d]=x(!0),[ef,tf]=x(!0),[nf,rf]=x(!1),[af,of]=x(``),sf;function cf(e){sf=e}function lf(e){of(e),tf(!0),requestAnimationFrame(()=>{sf?.focus();let t=e.length;sf?.setSelectionRange(t,t)})}function uf(){$d(e=>!e)}function df(){tf(e=>!e)}function ff(){rf(e=>!e)}var[pf,mf]=x(an(V.memoryWatches,[])),[hf,gf]=x(null),[_f,vf]=au({});function yf(e){let t=e.trim();t&&(mf(e=>e.includes(t)?e:[...e,t]),on(V.memoryWatches,pf()))}function bf(e){mf(t=>t.filter(t=>t!==e)),on(V.memoryWatches,pf())}function xf(){gf(null)}function Sf(e,t){gf({creepId:e,name:t})}function Cf(e,t){let n=[...t];if(e){let t=`creeps.${e.name}`;n.includes(t)||n.push(t)}return n}function wf(e){let t=new Map,n=()=>{let n=W();if(!n)return;let r=new Set(Cf(hf(),pf()));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))};f(()=>{pf(),hf(),n()});let r=W(),i=null;return r?i=r.stores.user.on(`user:memory`,e=>{console.log(`[memoryStore] user:memory received`,e.path,e.value),vf(e.path,e.value),console.log(`[memoryStore] memoryValues after set:`,JSON.stringify(_f))}):console.warn(`[memoryStore] no client available when initMemorySubscriptions called`),y(()=>{for(let e of t.values())e.dispose();t.clear(),i?.dispose()}),n(),()=>{for(let e of t.values())e.dispose();t.clear(),i?.dispose()}}v(()=>{f(()=>{let e=hf();e&&(fu().some(t=>t.id===e.creepId)||xf())})});var Tf=N(`<button style=color:#8b949e>`),Ef=N(`<span style=width:18px;flex-shrink:0>`),Df=N(`<span style=color:#484f58;font-style:italic>{…}`),Of=N(`<span style=color:#484f58;font-style:italic>`),kf=N(`<button title=Reload>`),Af=N(`<span title="Click to edit"style=cursor:text;flex:1>`),jf=N(`<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">`),Mf=N(`<button title=Save style=color:#3fb950>`),Nf=N(`<button title=Discard style=color:#f85149>`),Pf=N(`<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:Ff}=Qt(`MemoryTree`);function If(e){return typeof e==`object`&&!!e&&`__screeps_object__`in e}var Lf={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},Rf={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 zf(e){return e.replace(/^Memory\.?/,``)}function Bf(e){let[t,n]=x((e.depth??0)<2),r=()=>e.depth??0,[i,s]=x(!1),[c,d]=x(``),[f,p]=x(!1),[h,g]=x(void 0),_=()=>If(e.value)&&h()!==void 0?h():e.value,v=()=>{let e=_();return!If(e)&&typeof e==`object`&&!!e},y=()=>v()?Object.entries(_()):[],b=()=>y().length,S=async()=>{p(!0);try{let t=W();if(!t)return;let n=zf(e.path),r=await t.http.user.memory.get(n,e.shard);g(r.data===`[object Object]`?{__screeps_object__:!0}:r.data)}catch(e){Ff(`fetch memory failed`,e)}finally{p(!1)}},C=()=>{g(void 0),S()};a(()=>{t()&&If(e.value)&&h()===void 0&&S()});let w=async()=>{if(If(e.value)&&h()===void 0){await S(),n(!0);return}t()&&g(void 0),n(e=>!e)},T=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=W();if(!r)return;let i=zf(e.path);try{await r.http.user.memory.set(i,n,e.shard)}catch(e){Ff(`set memory failed`,e),s(!1);return}s(!1),e.onRefresh?.()},E=()=>{let e=_();return v()?`#c9d1d9`:typeof e==`string`?`#3fb950`:typeof e==`number`?`#79c0ff`:typeof e==`boolean`?`#a371f7`:`#8b949e`},D=()=>{let e=_();return e===null?`null`:e===void 0?`undefined`:typeof e==`string`?JSON.stringify(e):String(e)};return(()=>{var n=Pf(),a=n.firstChild,p=a.firstChild,h=p.nextSibling.nextSibling;return R(a,m(u,{get when(){return v()||If(_())},get children(){var e=Tf();return e.$$click=()=>void w(),R(e,m(u,{get when(){return f()},get children(){return m(kr,{size:12,style:{animation:`spin 1s linear infinite`}})}}),null),R(e,m(u,{get when(){return!f()},get children(){return m(u,{get when(){return t()},get fallback(){return m(dr,{size:12})},get children(){return m(lr,{size:12})}})}}),null),o(n=>{var r={...Rf},i=t()?`Collapse`:`Expand`,a=f();return n.e=I(e,r,n.e),i!==n.t&&F(e,`title`,n.t=i),a!==n.a&&(e.disabled=n.a=a),n},{e:void 0,t:void 0,a:void 0}),e}}),p),R(a,m(u,{get when(){return M(()=>!v())()&&!If(_())},get children(){return Ef()}}),p),R(p,()=>e.label),R(a,m(u,{get when(){return If(_())},get children(){return Df()}}),h),R(a,m(u,{get when(){return v()},get children(){var e=Of();return R(e,(()=>{var e=M(()=>!!Array.isArray(_()));return()=>e()?`[${b()}]`:`{${b()}}`})()),e}}),h),R(a,m(u,{get when(){return M(()=>!!If(e.value))()&&!f()},get children(){var e=kf();return e.$$click=()=>C(),R(e,m(Gr,{size:11})),o(t=>I(e,Rf,t)),e}}),h),R(a,m(u,{get when(){return M(()=>!v())()&&!If(_())},get children(){return[m(u,{get when(){return!i()},get children(){var e=Af();return e.$$click=()=>{d(D()),s(!0)},R(e,D),o(t=>L(e,`color`,E())),e}}),m(u,{get when(){return i()},get children(){return[(()=>{var e=jf();return e.$$keydown=e=>{e.key===`Enter`&&T(),e.key===`Escape`&&s(!1)},e.$$input=e=>d(e.currentTarget.value),o(()=>e.value=c()),e})(),(()=>{var e=Mf();return e.$$mousedown=e=>{e.preventDefault(),T()},R(e,m(sr,{size:12})),o(t=>I(e,{...Rf},t)),e})(),(()=>{var e=Nf();return e.$$mousedown=e=>{e.preventDefault(),s(!1)},R(e,m(ti,{size:12})),o(t=>I(e,{...Rf},t)),e})()]}})]}}),h),h.$$click=()=>lf(`Memory.${zf(e.path)} = `),R(h,m(Zr,{size:11})),R(n,m(u,{get when(){return M(()=>!!v())()&&t()},get children(){return m(l,{get each(){return y()},children:([t,n])=>m(Bf,{value:n,path:Array.isArray(_())?`${e.path}[${t}]`:`${e.path}.${t}`,label:t,get shard(){return e.shard},get depth(){return r()+1},get onRefresh(){return M(()=>!!If(e.value))()?C:e.onRefresh}})})}}),null),o(t=>{var i={"padding-left":r()>0?`14px`:`0`,...Lf},a=Rf,o=`Insert Memory.${zf(e.path)} = into console`;return t.e=I(n,i,t.e),t.t=I(h,a,t.t),o!==t.a&&F(h,`title`,t.a=o),t},{e:void 0,t:void 0,a:void 0}),n})()}function Vf(e){return m(Bf,{get value(){return e.value},get path(){return e.path},get label(){return e.label},get shard(){return e.shard},depth:0})}P([`click`,`input`,`keydown`,`mousedown`]);var Hf=N(`<div style=color:#484f58;font-style:italic>No paths watched — add one below.`),Uf=N(`<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`),Wf=N(`<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">`),Gf=N(`<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">`),Kf=N(`<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>`),qf=N(`<div style=width:4px;flex-shrink:0;cursor:col-resize>`),Jf=N(`<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`),Yf=N(`<div style=flex:1;display:flex;overflow:hidden>`),Xf=N(`<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
|
+
`),Zf=N(`<div style=color:#484f58;font-style:italic>No log output yet…`),Qf=N(`<div style=margin-bottom:4px;color:#f85149;white-space:pre-wrap;word-break:break-word>`),$f=N(`<div style=margin-bottom:4px;color:#c9d1d9;white-space:pre-wrap;word-break:break-word>`),ep=N(`<div style=color:#484f58;font-style:italic>No command results yet…`),tp=N(`<div style=margin-bottom:4px;color:#58a6ff;white-space:pre-wrap;word-break:break-word>`),{error:np}=Qt(`console`);function rp(e){let[t,n]=x(``),r=()=>e.shard??Mu();a(()=>{wf(r())});let i={"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 a=Uf(),c=a.firstChild,d=c.nextSibling,f=d.firstChild,p=f.nextSibling,h=p.firstChild;return R(c,m(u,{get when(){return hf()},children:e=>{let t=`creeps.${e().name}`;return(()=>{var e=Wf(),n=e.firstChild.firstChild,i=n.nextSibling.nextSibling;return R(n,t),xe(i,`click`,xf,!0),R(i,m(ti,{size:12})),R(e,m(Vf,{get value(){return _f[t]},path:`Memory.${t}`,label:t,get shard(){return r()}}),null),o(e=>I(i,s,e)),e})()}}),null),R(c,m(l,{get each(){return pf()},children:e=>(()=>{var t=Gf(),n=t.firstChild.firstChild,i=n.nextSibling;return R(n,e),i.$$click=()=>bf(e),R(i,m(ti,{size:12})),R(t,m(Vf,{get value(){return _f[e]},path:`Memory.${e}`,label:e,get shard(){return r()}}),null),o(e=>I(i,s,e)),t})()}),null),R(c,m(u,{get when(){return M(()=>pf().length===0)()&&!hf()},get children(){return Hf()}}),null),d.addEventListener(`submit`,e=>{e.preventDefault(),yf(t()),n(``)}),f.$$input=e=>n(e.currentTarget.value),R(p,m(Ur,{size:14}),h),o(t=>{var n=`${e.width*100}%`,r={...i};return n!==t.e&&L(a,`width`,t.e=n),t.t=I(c,r,t.t),t},{e:void 0,t:void 0}),o(()=>f.value=t()),a})()}function ip(e){let[t,n]=x([]),[r,i]=x(!0),[s,c]=x(an(V.consoleWeights,[1,1,1])),[d,p]=x(null),h,g,_,v=0;a(()=>{let e=W();if(!e)return;let t=new xt;t.add(e.stores.user.subscribe(`console`)),t.add(e.stores.user.on(`user:console`,e=>{let t=e.messages,r={id:v++,log:t.log??[],results:t.results??[],error:t.error??[]};n(e=>{let t=[...e,r];return t.length>200?t.slice(t.length-200):t})})),y(()=>t.dispose())}),f(()=>{t(),r()&&requestAnimationFrame(()=>{Qd()&&h&&(h.scrollTop=h.scrollHeight),ef()&&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?.()};f(()=>{b(Qd(),ef(),nf())});let S=()=>{let e=s(),t=[Qd(),ef(),nf()],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)};f(()=>{on(V.consoleWeights,s())});let C=e=>t=>{t.preventDefault(),t.stopPropagation(),p(e),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,w),window.addEventListener(`pointerup`,T,{once:!0})},w=e=>{let t=d();if(t===null)return;let n=_;if(!n)return;let r=n.getBoundingClientRect(),i=Math.max(.02,Math.min(.98,(e.clientX-r.left)/r.width)),a=[...s()],o=[Qd(),ef(),nf()];if(t===0){let e=o[0],t=o[1];if(!e||!t)return;a[0]=i/(1-i),a[1]=1,c(a)}else{let e=o[1],t=o[2];if(!e||!t)return;a[1]=i/(1-i),a[2]=1,c(a)}},T=()=>{p(null),document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,w)},[E,D]=x([]),[O,k]=x(null),[ee,te]=x(``),ne=e=>{let t=E();if(t.length!==0){if(e.key===`ArrowUp`){e.preventDefault();let n=O();n===null?(te(af()),k(t.length-1),of(t[t.length-1])):n>0&&(k(n-1),of(t[n-1]))}else if(e.key===`ArrowDown`){e.preventDefault();let n=O();if(n===null)return;n<t.length-1?(k(n+1),of(t[n+1])):(k(null),of(ee()))}}},A=async t=>{t.preventDefault();let n=W(),r=af().trim();if(!(!n||!r))try{await n.http.user.console(r,e.shard??`shard0`),D(e=>[...e,r]),k(null),te(``),of(``)}catch(e){np(`command failed:`,e)}},re=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`}),ie=()=>t().flatMap(e=>e.log),ae=()=>t().flatMap(e=>e.error),oe=()=>t().flatMap(e=>e.results),j={"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=()=>{i(!0),requestAnimationFrame(()=>{Qd()&&h&&(h.scrollTop=h.scrollHeight),ef()&&g&&(g.scrollTop=g.scrollHeight)})};return(()=>{var t=Xf(),a=t.firstChild,s=a.firstChild,c=s.nextSibling,f=c.nextSibling;return a.nextSibling,xe(s,`click`,uf,!0),xe(c,`click`,df,!0),xe(f,`click`,ff,!0),R(t,m(u,{get when(){return!e.isCollapsed},get children(){var t=Yf();return we(e=>_=e,t),R(t,m(u,{get when(){return Qd()},get children(){var e=Kf(),t=e.firstChild,a=t.firstChild,s=a.nextSibling,c=t.nextSibling;a.$$click=()=>r()?i(!1):ce(),R(a,(()=>{var e=M(()=>!!r());return()=>e()?m(zr,{size:16}):m(Vr,{size:16})})()),s.$$click=()=>n([]),R(s,m($r,{size:16})),c.addEventListener(`scroll`,()=>{h&&i(h.scrollHeight-h.scrollTop-h.clientHeight<20)});var u=h;return typeof u==`function`?we(u,c):h=c,R(c,(()=>{var e=M(()=>ie().length===0&&ae().length===0);return()=>e()&&Zf()})(),null),R(c,m(l,{get each(){return ae()},children:e=>(()=>{var t=Qf();return t.innerHTML=e,t})()}),null),R(c,m(l,{get each(){return ie()},children:e=>(()=>{var t=$f();return t.innerHTML=e,t})()}),null),o(t=>{var n=`${S()[0]*100}%`,i=r()?`Pause scrolling`:`Resume scrolling`,o=se,l=se,u={...j};return n!==t.e&&L(e,`width`,t.e=n),i!==t.t&&F(a,`title`,t.t=i),t.a=I(a,o,t.a),t.o=I(s,l,t.o),t.i=I(c,u,t.i),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),R(t,m(u,{get when(){return M(()=>!!Qd())()&&ef()},get children(){var e=qf();return xe(e,`pointerdown`,C(0),!0),o(t=>L(e,`background`,d()===0?`#388bfd`:`#21262d`)),e}}),null),R(t,m(u,{get when(){return ef()},get children(){var e=Jf(),t=e.firstChild,n=t.nextSibling,r=n.firstChild.nextSibling;r.nextSibling,t.addEventListener(`scroll`,()=>{g&&i(g.scrollHeight-g.scrollTop-g.clientHeight<20)});var a=g;return typeof a==`function`?we(a,t):g=t,R(t,(()=>{var e=M(()=>oe().length===0);return()=>e()&&ep()})(),null),R(t,m(l,{get each(){return oe()},children:e=>(()=>{var t=tp();return t.innerHTML=e,t})()}),null),n.addEventListener(`submit`,A),r.$$keydown=ne,r.$$input=e=>{k(null),of(e.currentTarget.value)},we(e=>cf(e),r),o(n=>{var r=`${S()[1]*100}%`,i={...j};return r!==n.e&&L(e,`width`,n.e=r),n.t=I(t,i,n.t),n},{e:void 0,t:void 0}),o(()=>r.value=af()),e}}),null),R(t,m(u,{get when(){return M(()=>!!ef())()&&nf()},get children(){var e=qf();return xe(e,`pointerdown`,C(1),!0),o(t=>L(e,`background`,d()===1?`#388bfd`:`#21262d`)),e}}),null),R(t,m(u,{get when(){return nf()},get children(){return m(rp,{get shard(){return e.shard??null},get width(){return S()[2]}})}}),null),o(e=>L(t,`user-select`,d()===null?`auto`:`none`)),t}}),null),o(e=>{var t=re(Qd()),n=re(ef()),r=re(nf());return e.e=I(s,t,e.e),e.t=I(c,n,e.t),e.a=I(f,r,e.a),e},{e:void 0,t:void 0,a:void 0}),t})()}P([`input`,`click`,`pointerdown`,`keydown`]);var ap=N(`<div style=display:flex;gap:5px;flex-wrap:wrap>`),op=N(`<div style=width:18px;height:18px;border-radius:50%;cursor:pointer;flex-shrink:0>`),sp=[{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 cp(e){return(()=>{var t=ap();return R(t,m(l,{each:sp,children:t=>(()=>{var n=op();return n.$$click=()=>e.onChange(t.value),o(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&&F(n,`title`,r.e=i),a!==r.t&&L(n,`background`,r.t=a),o!==r.a&&L(n,`box-shadow`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n})()})),t})()}P([`click`]);var lp=N(`<div>`),up=N(`<div style=font-variant-numeric:tabular-nums>`),dp=N(`<span style=font-variant-numeric:tabular-nums;font-weight:400> / `),fp=N(`<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">`),pp=N(`<div style="padding:3px 8px;background:#0d1117;color:#8b949e">`),mp=N(`<div style="padding:3px 8px;background:#0d1117;color:#c9d1d9;font-variant-numeric:tabular-nums">`),hp=N(`<div>Owner`),gp=N(`<div>Hits`),_p=N(`<div style=font-variant-numeric:tabular-nums> / `),vp=N(`<div>Time to live`),yp=N(`<div>Fatigue`),bp=N(`<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">`),xp=N(`<div><div>`),Sp=N(`<div style=width:11px;height:11px;border-radius:50%;flex-shrink:0>`),Cp=N(`<span style=font-size:10px;font-variant-numeric:tabular-nums><span style=color:#8b949e>×</span><span>`),wp=N(`<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">`),Tp=N(`<div style=padding:8px;display:flex;flex-direction:column;gap:8px;background:#0d1117><label>Primary color</label><label>Secondary color`),Ep=N(`<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`),Dp=N(`<div>Reserved by`),Op=N(`<div>Reservation`),kp=N(`<div style=font-variant-numeric:tabular-nums> ticks`),Ap=N(`<div>Level`),jp=N(`<div>Safe modes`),Mp=N(`<div>Power`),Np=N(`<div>Downgrade in`),Pp=N(`<div>Safe mode active`),Fp=N(`<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>`),Ip=N(`<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">`),Lp=N(`<div><div><div>Owner</div><div>`),Rp=N(`<div>Cooldown`),zp=N(`<div>Notify when attacked`),Bp=N(`<div style=display:flex;align-items:center><button style=background:transparent;border:none;cursor:pointer;padding:0;display:flex;align-items:center>`),Vp=N(`<div><div>Energy</div><div style=font-variant-numeric:tabular-nums> / `),Hp=N(`<div><div>Hits</div><div style=font-variant-numeric:tabular-nums> / `),Up=N(`<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>`),Wp=N(`<div>Decay in`),Gp=N(`<div>Energy cap`),Kp=N(`<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>`),qp=N(`<div style=width:8px;height:8px;border-radius:50%;flex-shrink:0>`),Jp=N(`<button style="background:transparent;border:none;cursor:pointer;padding:0 2px;display:flex;align-items:center;justify-content:center;flex-shrink:0">`),Yp=N(`<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">`),Xp=N(`<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">×`),Zp=N(`<span style=font-weight:400;color:#8b949e>`),Qp=N(`<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">`),$p=N(`<div style=flex:1;overflow:auto;min-height:0;padding:8px>`),em=N(`<div style=color:#484f58;font-style:italic;font-size:12px>Click a tile to select objects…`),{log:tm,error:nm}=Qt(`SelectionList`),rm={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`,energy:`#d29922`},im={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`,energy:`Energy`,flag:`Flag`},am=new Set([`x`,`y`,`type`,`id`,`name`,`user`,`_id`,`room`,`hitsMax`,`energyCapacity`,`body`,`storeCapacity`,`storeCapacityResource`,`invaderHarvested`,`ticksToRegeneration`]),om=new Set([`hits`,`energy`,`energyCapacity`,`store`,`progress`,`progressTotal`,`nextDecayTime`,`ticksToRegeneration`,`nextRegenerationTime`]),sm={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 cm(e){return sm[e]?sm[e]:e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()).trim()}function lm(e){return typeof e==`number`?String(e):typeof e==`string`?e:typeof e==`boolean`?e?`Yes`:`No`:null}function um(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 $=(e=!1)=>({padding:`3px 8px`,background:`#0d1117`,color:e?`#8b949e`:`#c9d1d9`,overflow:`hidden`,"text-overflow":`ellipsis`,"white-space":`nowrap`}),dm={display:`grid`,"grid-template-columns":`1fr 1fr`,gap:`1px`,background:`#21262d`,"font-size":`10px`};function fm(e){let t=()=>{let t=e.item.raw,n=[];for(let e in t){if(am.has(e))continue;let r=t[e],i=lm(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=K();e!==null&&(i=String(r-e))}if(e===`nextRegenerationTime`&&typeof r==`number`){let e=K();e!==null&&(i=String(r-e))}i!==null&&n.push({key:e,label:cm(e),value:i})}}return n.sort((e,t)=>!om.has(e.key)-+!om.has(t.key)),n};return m(u,{get when(){return t().length>0},get children(){var e=lp();return R(e,m(l,{get each(){return t()},children:e=>[(()=>{var t=lp();return R(t,()=>e.label),o(e=>I(t,$(!0),e)),t})(),(()=>{var t=up();return R(t,()=>e.value),o(e=>I(t,{...$()},e)),t})()]})),o(t=>I(e,dm,t)),e}})}function pm(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 m(u,{get when(){return t().length>0},get children(){var r=fp(),i=r.firstChild;i.firstChild;var a=i.nextSibling;return R(i,m(u,{get when(){return e.capacity!=null},get children(){var t=dp(),r=t.firstChild;return R(t,n,r),R(t,()=>e.capacity,null),t}}),null),R(a,m(l,{get each(){return t()},children:([e,t])=>[(()=>{var t=pp();return R(t,e),t})(),(()=>{var e=mp();return R(e,t),e})()]})),r}})}var mm={tough:`#4c4c4c`,move:`#a9b7c6`,work:`#ffe56d`,carry:`#777777`,attack:`#f93842`,ranged_attack:`#5d80b2`,heal:`#65fd62`,claim:`#b99cfb`};function hm(e){let t=()=>e.item.raw,n=()=>typeof t().user==`string`?t().user:null,r=()=>{let e=n();return e?Au()?.[e]?.username??e:null},i=()=>typeof t().hits==`number`?t().hits:null,a=()=>typeof t().hitsMax==`number`?t().hitsMax:null,s=()=>{let e=t().ageTime,n=K();return typeof e==`number`&&n!==null?Math.max(0,e-n):null},c=()=>typeof t().fatigue==`number`?t().fatigue:null,d=()=>t().store,f=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null,p=()=>t().body??[],h=()=>{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=xp(),t=e.firstChild;return R(t,m(u,{get when(){return r()},get children(){return[(()=>{var e=hp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=lp();return R(e,r),o(t=>I(e,$(),t)),e})()]}}),null),R(t,m(u,{get when(){return M(()=>i()!==null)()&&a()!==null},get children(){return[(()=>{var e=gp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=_p(),t=e.firstChild;return R(e,i,t),R(e,a,null),o(t=>I(e,{...$()},t)),e})()]}}),null),R(t,m(u,{get when(){return s()!==null},get children(){return[(()=>{var e=vp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=up();return R(e,s),o(t=>I(e,{...$()},t)),e})()]}}),null),R(t,m(u,{get when(){return c()!==null},get children(){return[(()=>{var e=yp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=up();return R(e,c),o(t=>I(e,{...$(),color:c()>0?`#e3b341`:void 0},t)),e})()]}}),null),R(e,m(pm,{get store(){return d()},get capacity(){return f()}}),null),R(e,m(u,{get when(){return p().length>0},get children(){var e=bp(),t=e.firstChild,n=t.firstChild.nextSibling;n.nextSibling;var r=t.nextSibling,i=r.nextSibling;return R(t,()=>p().length,n),R(r,m(l,{get each(){return p()},children:e=>(()=>{var t=Sp();return o(n=>{var r=e.type.replace(`_`,` `),i=mm[e.type]??`#484f58`,a=e.hits===0?.25:1;return r!==n.e&&F(t,`title`,n.e=r),i!==n.t&&L(t,`background`,n.t=i),a!==n.a&&L(t,`opacity`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),R(i,m(l,{get each(){return h()},children:({type:e,count:t})=>(()=>{var n=Cp(),r=n.firstChild,i=r.firstChild,a=r.nextSibling;return R(r,t,i),R(a,()=>e.replace(`_`,` `).toUpperCase()),o(t=>L(a,`color`,mm[e]??`#484f58`)),n})()})),e}}),null),o(e=>I(t,dm,e)),e})()}function gm(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,a=()=>typeof t().secondaryColor==`number`?t().secondaryColor:1,[s,c]=x(i()),[l,d]=x(a());f(()=>{c(i()),d(a())});let p=()=>s()!==i()||l()!==a(),h=()=>{let e=W();if(!e)return;let t=s(),i=l();tm(`changeFlagColor: name="${n()}" room=${r()} primary=${t} secondary=${i}`),e.http.game.changeFlagColor(r(),n(),t,i).then(()=>tm(`changeFlagColor OK`)).catch(e=>nm(`changeFlagColor FAILED:`,e))},g=()=>{let t=Ad();return t?.type===`moveFlag`&&t.id===e.item.id},_=()=>{if(g()){jd(null);return}jd({type:`moveFlag`,id:e.item.id,name:n(),room:r(),color:s(),secondaryColor:l(),targetRoom:Pu()??r()})},v=()=>{let t=Ad();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=Tp(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return n.firstChild,R(t,m(cp,{get value(){return s()},onChange:c}),null),R(n,m(cp,{get value(){return l()},onChange:d}),null),R(e,m(u,{get when(){return!Q()},get children(){return[(()=>{var e=wp(),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=h,n.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=g()?`#c9d1d9`:`#8b949e`}),n.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=`#c9d1d9`}),n.$$click=_,R(n,(()=>{var e=M(()=>!!g());return()=>e()?m(ti,{size:13}):m(Lr,{size:13})})()),o(e=>{var r=!p(),i=p()?`#238636`:`#161b22`,a=p()?`#fff`:`#484f58`,o=`1px solid ${p()?`#238636`:`#30363d`}`,s=p()?`pointer`:`not-allowed`,c=g()?`Abort move`:`Move flag`,l=g()?`#30363d`:`#21262d`,u=g()?`#c9d1d9`:`#8b949e`,d=`1px solid ${g()?`#8b949e`:`#30363d`}`;return r!==e.e&&(t.disabled=e.e=r),i!==e.t&&L(t,`background`,e.t=i),a!==e.a&&L(t,`color`,e.a=a),o!==e.o&&L(t,`border`,e.o=o),s!==e.i&&L(t,`cursor`,e.i=s),c!==e.n&&F(n,`title`,e.n=c),l!==e.s&&L(n,`background`,e.s=l),u!==e.h&&L(n,`color`,e.h=u),d!==e.r&&L(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})(),m(u,{get when(){return v()},children:e=>(()=>{var t=Ep(),n=t.firstChild.nextSibling;return n.nextSibling,n.$$input=t=>jd({...e(),targetRoom:t.currentTarget.value.toUpperCase()}),o(e=>I(t,y,e)),o(()=>n.value=e().targetRoom),t})()})]}}),null),o(e=>{var r=y,i=y;return e.e=I(t,r,e.e),e.t=I(n,i,e.t),e},{e:void 0,t:void 0}),e})()}function _m(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:so[n()]??null,a=()=>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,d=()=>t().reservation,f=()=>typeof t().user==`string`?t().user:null,p=()=>{let e=f();return e?bu()?.username??e:null},h=()=>{let e=a(),t=K();return e!==null&&t!==null?Math.max(0,e-t):null},g=()=>{let e=h();if(e===null)return`—`;let t=co[n()];return t!==void 0&&e>=t?`Max`:String(e)},_=()=>f()!==null&&f()===G()?._id,[v,y]=x(!1),b=null,S=()=>{let n=W();n&&n.http.game.addObjectIntent(e.item.id,Pu()??t().room??``,`activateSafeMode`,{id:e.item.id},Mu()).catch(e=>nm(`activateSafeMode failed:`,e))},C=()=>{if(!v()){y(!0),b=setTimeout(()=>y(!1),3e3);return}b&&=(clearTimeout(b),null),y(!1);let n=W();n&&n.http.game.addObjectIntent(e.item.id,Pu()??t().room??``,`unclaim`,{id:e.item.id},Mu()).catch(e=>nm(`unclaim failed:`,e))};return(()=>{var e=Lp(),t=e.firstChild,a=t.firstChild,f=a.nextSibling;return R(f,()=>p()??`None`),R(t,m(u,{get when(){return d()},get children(){return[(()=>{var e=Dp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=lp();return R(e,()=>Au()?.[d().user]?.username??d().user),o(t=>I(e,$(),t)),e})(),(()=>{var e=Op();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=kp(),t=e.firstChild;return R(e,(()=>{var e=M(()=>K()!==null);return()=>e()?Math.max(0,d().endTime-K()):d().endTime})(),t),o(t=>I(e,{...$()},t)),e})()]}}),null),R(t,m(u,{get when(){return n()>0},get children(){return[(()=>{var e=Ap();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=lp();return R(e,n),o(t=>I(e,$(),t)),e})(),(()=>{var e=jp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=lp();return R(e,s),o(t=>I(e,$(),t)),e})(),(()=>{var e=Mp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=lp();return R(e,()=>l()?`Enabled`:`Disabled`),o(t=>I(e,$(),t)),e})(),(()=>{var e=Np();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=up();return R(e,g),o(t=>I(e,{...$(),color:g()===`Max`?`#3fb950`:void 0},t)),e})()]}}),null),R(t,m(u,{get when(){return c()!==null},get children(){return[(()=>{var e=Pp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=kp(),t=e.firstChild;return R(e,c,t),o(t=>I(e,{...$()},t)),e})()]}}),null),R(e,m(u,{get when(){return M(()=>n()>0&&n()<8&&r()!==null)()&&i()!==null},get children(){var e=Fp(),t=e.firstChild,a=t.firstChild,s=a.firstChild.nextSibling;s.nextSibling;var c=a.nextSibling,l=c.firstChild,u=l.nextSibling,d=u.nextSibling.nextSibling;d.nextSibling;var f=t.nextSibling.firstChild;return R(a,n,s),R(a,()=>n()+1,null),R(c,()=>um(r()),l),R(c,()=>um(i()),u),R(c,()=>(r()/i()*100).toFixed(1),d),o(e=>L(f,`width`,`${Math.min(100,r()/i()*100)}%`)),e}}),null),R(e,m(u,{get when(){return M(()=>!!_())()&&!Q()},get children(){var e=Ip(),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=S,n.addEventListener(`mouseleave`,e=>{v()||(e.currentTarget.style.background=`#f85149`)}),n.addEventListener(`mouseenter`,e=>{v()||(e.currentTarget.style.background=`#da3633`)}),n.$$click=C,R(n,()=>v()?`Confirm unclaim`:`Unclaim`),o(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&&L(t,`background`,e.t=i),a!==e.a&&L(t,`cursor`,e.a=a),o!==e.o&&L(t,`opacity`,e.o=o),c!==e.i&&L(n,`background`,e.i=c),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),o(e=>{var n=dm,r=$(!0),i=$();return e.e=I(t,n,e.e),e.t=I(a,r,e.t),e.a=I(f,i,e.a),e},{e:void 0,t:void 0,a:void 0}),e})()}function vm(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,s=()=>typeof t().cooldown==`number`?t().cooldown:null,c=()=>t().notifyWhenAttacked===!0,l=()=>typeof t().user==`string`?t().user:null,d=()=>l()!==null&&l()===G()?._id,f=()=>{let n=W();n&&n.http.game.addObjectIntent(e.item.id,t().room,`notifyWhenAttacked`,{enabled:!c()}).catch(e=>nm(`notifyWhenAttacked failed:`,e))};return(()=>{var e=Vp(),t=e.firstChild,l=t.nextSibling,p=l.firstChild;return R(l,n,p),R(l,r,null),R(e,m(u,{get when(){return M(()=>i()!==null)()&&a()!==null},get children(){return[(()=>{var e=gp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=_p(),t=e.firstChild;return R(e,i,t),R(e,a,null),o(t=>I(e,{...$()},t)),e})()]}}),null),R(e,m(u,{get when(){return s()!==null},get children(){return[(()=>{var e=Rp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=up();return R(e,s),o(t=>I(e,{...$()},t)),e})()]}}),null),R(e,m(u,{get when(){return M(()=>!!d())()&&!Q()},get children(){return[(()=>{var e=zp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=Bp(),t=e.firstChild;return t.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=c()?`#3fb950`:`#484f58`}),t.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=c()?`#56d364`:`#8b949e`}),t.$$click=f,R(t,(()=>{var e=M(()=>!!c());return()=>e()?m(ar,{size:12}):m(rr,{size:12})})()),o(n=>{var r={...$()},i=c()?`Notifications on — click to disable`:`Notifications off — click to enable`,a=c()?`#3fb950`:`#484f58`;return n.e=I(e,r,n.e),i!==n.t&&F(t,`title`,n.t=i),a!==n.a&&L(t,`color`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),e})()]}}),null),o(n=>{var r=dm,i=$(!0),a={...$()};return n.e=I(e,r,n.e),n.t=I(t,i,n.t),n.a=I(l,a,n.a),n},{e:void 0,t:void 0,a:void 0}),e})()}function ym(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},s=()=>{let e=i();if(!e)return 0;let t=0;for(let n in e)t+=e[n];return t},c=()=>{let e=a();return!e||e===0?0:Math.min(100,s()/e*100)};return(()=>{var e=lp();return R(e,m(u,{get when(){return M(()=>n()!==null)()&&r()!==null},get children(){var e=Hp(),t=e.firstChild,i=t.nextSibling,a=i.firstChild;return R(i,n,a),R(i,r,null),o(n=>{var r=dm,a=$(!0),o={...$()};return n.e=I(e,r,n.e),n.t=I(t,a,n.t),n.a=I(i,o,n.a),n},{e:void 0,t:void 0,a:void 0}),e}}),null),R(e,m(u,{get when(){return a()!==null},get children(){var e=Up(),t=e.firstChild,n=t.firstChild.nextSibling,r=n.firstChild,i=r.nextSibling,l=i.nextSibling.nextSibling;l.nextSibling;var u=t.nextSibling.firstChild;return R(n,()=>um(s()),r),R(n,()=>um(a()),i),R(n,()=>c().toFixed(1),l),o(e=>L(u,`width`,`${c()}%`)),e}}),null),R(e,m(pm,{get store(){return i()},capacity:null}),null),e})()}function bm(e){let t=()=>e.item.raw,n=()=>{let e=t().decayTime;if(typeof e!=`number`)return null;let n=K();return n===null?e:Math.max(0,e-n)},r=()=>typeof t().user==`string`?t().user:null,i=()=>{let e=r();return e?Au()?.[e]?.username??e:null},a=()=>t().structure,s=()=>typeof a()?.type==`string`?a().type:null,c=()=>typeof a()?.hits==`number`?a().hits:null,l=()=>typeof a()?.hitsMax==`number`?a().hitsMax:null,d=()=>typeof a()?.level==`number`?a().level:null,f=()=>typeof a()?.energy==`number`?a().energy:null,p=()=>typeof a()?.energyCapacity==`number`?a().energyCapacity:null,h=()=>t().store,g=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null;return(()=>{var e=xp(),t=e.firstChild;return R(t,m(u,{get when(){return n()!==null},get children(){return[(()=>{var e=Wp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=up();return R(e,n),o(t=>I(e,{...$()},t)),e})()]}}),null),R(t,m(u,{get when(){return i()},get children(){return[(()=>{var e=hp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=lp();return R(e,i),o(t=>I(e,$(),t)),e})()]}}),null),R(e,m(u,{get when(){return s()},get children(){var e=Kp(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return R(t,s,null),R(n,m(u,{get when(){return l()!==null},get children(){return[(()=>{var e=gp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=_p(),t=e.firstChild;return R(e,()=>c()??0,t),R(e,l,null),o(t=>I(e,{...$()},t)),e})()]}}),null),R(n,m(u,{get when(){return d()!==null},get children(){return[(()=>{var e=Ap();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=up();return R(e,d),o(t=>I(e,{...$()},t)),e})()]}}),null),R(n,m(u,{get when(){return p()!==null},get children(){return[(()=>{var e=Gp();return o(t=>I(e,$(!0),t)),e})(),(()=>{var e=_p(),t=e.firstChild;return R(e,()=>f()??0,t),R(e,p,null),o(t=>I(e,{...$()},t)),e})()]}}),null),o(e=>I(n,dm,e)),e}}),null),R(e,m(pm,{get store(){return h()},get capacity(){return g()}}),null),o(e=>I(t,dm,e)),e})()}var xm={creep:hm,flag:gm,controller:_m,spawn:vm,extension:vm,tower:vm,link:vm,storage:ym,terminal:ym,container:ym,lab:ym,factory:ym,nuker:ym,powerSpawn:ym,ruin:bm};function Sm(e){let t=()=>rm[e.item.type]??`#c9d1d9`,n=()=>im[e.item.type]??e.item.type,r=()=>e.item.type===`creep`,i=()=>e.item.type===`flag`,a=()=>{if(!r())return!1;let t=e.item.raw,n=typeof t.user==`string`?t.user:null;return n!==null&&n===G()?._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?bu()?.userId===G()?._id:n===G()?._id},c=()=>xm[e.item.type]||fm,[l,d]=x(!1),f=null,[p,h]=x(!1),g=null,[_,v]=x(!1),y=null,b=t=>{if(t.stopPropagation(),!_()){v(!0),y=setTimeout(()=>v(!1),3e3);return}y&&=(clearTimeout(y),null),v(!1);let n=W();if(!n)return;let r=e.item.id,i=e.item.raw;n.http.game.removeFlag(i.room,i.name).then(()=>hu(r)).catch(()=>{})},S=t=>{if(t.stopPropagation(),!p()){h(!0),g=setTimeout(()=>h(!1),3e3);return}g&&=(clearTimeout(g),null),h(!1);let n=W();if(!n)return;let r=e.item.id,i=e.item.raw,a=(typeof i.room==`string`?i.room:null)??Pu()??``;if(e.item.type===`constructionSite`)n.http.game.removeConstructionSite(a,[r],Mu()??void 0).then(()=>hu(r)).catch(e=>nm(`removeConstructionSite failed:`,e));else{let e=typeof i.user==`string`?i.user:bu()?.userId??``;n.http.game.addObjectIntent(`room`,a,`destroyStructure`,[{id:r,roomName:a,user:e}],Mu()).then(()=>hu(r)).catch(e=>nm(`destroyStructure failed:`,e))}},C=t=>{if(t.stopPropagation(),!l()){d(!0),f=setTimeout(()=>d(!1),3e3);return}f&&=(clearTimeout(f),null),d(!1);let n=W();if(!n)return;let r=e.item.id;n.http.game.addObjectIntent(r,Pu()??e.item.raw.room??``,`suicide`,{id:r},Mu()).then(()=>hu(r)).catch(e=>nm(`suicide failed:`,e))};return(()=>{var d=Xp(),f=d.firstChild,h=f.firstChild,g=h.nextSibling,v=g.firstChild.nextSibling,y=v.nextSibling.nextSibling;y.nextSibling;var x=g.nextSibling;return R(f,m(u,{get when(){return M(()=>!r())()&&!i()},get children(){var e=qp();return o(n=>L(e,`background`,t())),e}}),h),R(h,m(u,{get when(){return i()},get fallback(){return M(n)},get children(){return m(xr,{size:12})}}),null),R(h,m(u,{get when(){return M(()=>typeof e.item.raw.name==`string`)()&&e.item.raw.name},children:e=>(()=>{var t=Zp();return R(t,()=>e()),t})()}),null),R(g,()=>e.item.raw.x,v),R(g,()=>e.item.raw.y,y),R(f,m(u,{get when(){return M(()=>!!a())()&&!Q()},get children(){return[(()=>{var e=Jp();return e.addEventListener(`mouseleave`,e=>{l()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{l()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=C,R(e,m($r,{size:13})),o(t=>{var n=l()?`Click again to confirm suicide`:`Suicide`,r=l()?`#f85149`:`#8b949e`;return n!==t.e&&F(e,`title`,t.e=n),r!==t.t&&L(e,`color`,t.t=r),t},{e:void 0,t:void 0}),e})(),(()=>{var t=Yp();return t.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),t.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),t.$$click=()=>{Sf(e.item.id,e.item.raw.name),rf(!0)},R(t,m(yr,{size:13})),t})()]}}),x),R(f,m(u,{get when(){return M(()=>!!s())()&&!Q()},get children(){var t=Jp();return t.addEventListener(`mouseleave`,e=>{p()||(e.currentTarget.style.color=`#8b949e`)}),t.addEventListener(`mouseenter`,e=>{p()||(e.currentTarget.style.color=`#f85149`)}),t.$$click=S,R(t,m($r,{size:13})),o(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&&F(t,`title`,n.e=r),i!==n.t&&L(t,`color`,n.t=i),n},{e:void 0,t:void 0}),t}}),x),R(f,m(u,{get when(){return M(()=>!!i())()&&!Q()},get children(){var e=Jp();return e.addEventListener(`mouseleave`,e=>{_()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{_()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=b,R(e,m($r,{size:13})),o(t=>{var n=_()?`Click again to confirm deletion`:`Delete flag`,r=_()?`#f85149`:`#8b949e`;return n!==t.e&&F(e,`title`,t.e=n),r!==t.t&&L(e,`color`,t.t=r),t},{e:void 0,t:void 0}),e}}),x),x.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),x.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#fff`),x.$$click=()=>hu(e.item.id),R(d,m(Be,{get component(){return c()},get item(){return e.item}}),null),R(d,m(u,{get when(){return e.item.id},children:e=>(()=>{var t=Qp();return t.$$click=()=>navigator.clipboard?.writeText(e()),R(t,e),o(()=>F(t,`title`,e())),t})()}),null),o(e=>L(d,`border`,`1px solid ${a()&&l()||p()||_()?`#f85149`:`#30363d`}`)),d})()}function Cm(){return(()=>{var e=$p();return R(e,m(u,{get when(){return fu().length>0},get fallback(){return em()},get children(){return m(l,{get each(){return fu()},children:e=>m(Sm,{item:e})})}})),e})()}P([`click`,`input`]);var wm=N(`<div style="padding:3px 0;color:#8b949e">Reserved by`),Tm=N(`<div style="padding:3px 0;color:#c9d1d9">`),Em=N(`<div style="padding:3px 0;color:#8b949e">Expires in`),Dm=N(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums"> ticks`),Om=N(`<div style="padding:3px 0;color:#8b949e">RCL`),km=N(`<span style=color:#8b949e>(<!>%)`),Am=N(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums">`),jm=N(`<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></label></div><div style=display:grid;gap:4px;margin-top:8px><button type=button title=History style="padding:5px 8px;border-radius:6px;display:flex;align-items:center;justify-content:center">`),Mm=N(`<span>`),Nm=N(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;display:flex;align-items:center;justify-content:center">`),Pm=[{mode:`view`,label:`View`,icon:()=>m(yr,{size:14})},{mode:`flag`,label:`Flag`,icon:()=>m(xr,{size:14})},{mode:`build`,label:`Build`,icon:()=>m(Cr,{size:14})}];function Fm(e){return(()=>{var t=jm(),n=t.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling,a=i.firstChild.nextSibling,s=a.nextSibling.nextSibling,c=s.nextSibling.nextSibling,d=c.nextSibling.nextSibling,f=d.nextSibling.nextSibling,p=i.nextSibling,h=p.firstChild.nextSibling,g=p.nextSibling.firstChild.nextSibling,_=n.nextSibling,v=_.firstChild;return R(r,()=>e.room),R(a,()=>e.shard??`—`),R(s,()=>K()??`—`),R(c,(()=>{var e=M(()=>!!bn());return()=>e()?`${bn()}ms`:`—`})()),R(d,()=>vu()??`—`),R(f,()=>bu()?.username??`—`),R(i,m(u,{get when(){return M(()=>!bu())()&&Eu()},get children(){return[wm(),(()=>{var e=Tm();return R(e,()=>Au()?.[Eu().user]?.username??Eu().user),e})(),Em(),(()=>{var e=Dm(),t=e.firstChild;return R(e,(()=>{var e=M(()=>K()!==null);return()=>e()?Math.max(0,Eu().endTime-K()):`—`})(),t),e})()]}}),null),R(i,m(u,{get when(){return M(()=>Su()!==null)()&&Su()>0},get children(){return[Om(),(()=>{var e=Am();return R(e,m(u,{get when(){return M(()=>Su()<8)()&&wu()!==null},get fallback(){return(()=>{var e=Mm();return R(e,Su),e})()},get children(){return[M(()=>Su()),` → `,M(()=>Su()+1),`\xA0`,(()=>{var e=km(),t=e.firstChild.nextSibling;return t.nextSibling,R(e,()=>(wu()/(so[Su()]??1)*100).toFixed(1),t),e})()]}})),e})()]}}),null),h.addEventListener(`change`,e=>_l(e.currentTarget.checked)),g.addEventListener(`change`,e=>kl(e.currentTarget.checked)),R(_,m(u,{get when(){return!Sn()},get children(){return m(l,{each:Pm,children:e=>{let t=()=>!Q()&&wd()===e.mode;return(()=>{var n=Nm();return n.$$click=()=>{Q()&&sd(),Td(e.mode)},R(n,()=>e.icon()),o(r=>{var i=e.label,a=`1px solid ${t()?`#58a6ff`:`#30363d`}`,o=t()?`#1f6feb33`:`#161b22`,s=t()?`#c9d1d9`:`#8b949e`;return i!==r.e&&F(n,`title`,r.e=i),a!==r.t&&L(n,`border`,r.t=a),o!==r.a&&L(n,`background`,r.a=o),s!==r.o&&L(n,`color`,r.o=s),r},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()}})}}),v),v.$$click=()=>Q()?sd():K()!==null&&od(K()),R(v,m(hr,{size:14})),o(e=>{var t=`repeat(${Sn()?2:4}, 1fr)`,n=!Q()&&K()===null,r=Sn()?`span 2`:void 0,i=`1px solid ${Q()?`#58a6ff`:`#30363d`}`,a=Q()?`#1f6feb33`:`#161b22`,o=Q()?`#c9d1d9`:`#8b949e`,s=!Q()&&K()===null?`not-allowed`:`pointer`,c=!Q()&&K()===null?.4:1;return t!==e.e&&L(_,`grid-template-columns`,e.e=t),n!==e.t&&(v.disabled=e.t=n),r!==e.a&&L(v,`grid-column`,e.a=r),i!==e.o&&L(v,`border`,e.o=i),a!==e.i&&L(v,`background`,e.i=a),o!==e.n&&L(v,`color`,e.n=o),s!==e.s&&L(v,`cursor`,e.s=s),c!==e.h&&L(v,`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}),o(()=>h.checked=gl()),o(()=>g.checked=Ol()),t})()}P([`click`]);var[Im,Lm]=x(`owner`),Rm=3,zm=Rm*50,Bm=4;function Vm(e,t,n){let r=Lu(e);return r?[r.x*zm+t*Rm,r.y*zm+n*Rm]:null}var Hm=3*Rm,Um=2.5*Rm,Wm=1*Rm,Gm=2*Rm;function Km(e,t,n,r){let i=!0,a=n;for(let o=0;o<t.length-1;o++){let[s,c]=t[o],[l,u]=t[o+1],d=l-s,f=u-c,p=Math.sqrt(d*d+f*f);if(p<.001)continue;let m=d/p,h=f/p,g=0;for(;g<p;){let t=Math.min(a,p-g);if(i){let n=s+m*g,r=c+h*g;e.moveTo(n,r),e.lineTo(n+m*t,r+h*t)}g+=t,a-=t,a<.001&&(i=!i,a=i?n:r)}}}function qm(e,t,n){let r=Math.max(32,Math.ceil(2*Math.PI*n/2)),i=[];for(let a=0;a<=r;a++){let o=a/r*2*Math.PI;i.push([e+Math.cos(o)*n,t+Math.sin(o)*n])}return i}var Jm=class{container;g;constructor(){this.container=new E,this.container.label=`mapVisuals`,this.g=new w,this.container.addChild(this.g)}update(e){let t=this.container.removeChildren();for(let e of t)e!==this.g&&e.destroy();if(this.g.clear(),this.container.addChild(this.g),!e)return;let n=this.g;for(let t of e.split(`
|
|
19
|
+
`)){if(!t.trim())continue;let e;try{e=JSON.parse(t)}catch{continue}let r=e.s??{},i=r.opacity??.5;switch(e.t){case`l`:this.drawLine(n,e,r,i);break;case`c`:this.drawCircle(n,e,r,i);break;case`r`:this.drawRect(n,e,r,i);break;case`p`:this.drawPoly(n,e,r,i);break;case`t`:this.drawText(e,r,i);break}}}clear(){let e=this.container.removeChildren();for(let t of e)t!==this.g&&t.destroy();this.g.clear(),this.container.addChild(this.g)}drawLine(e,t,n,r){let i=Vm(t.n1,t.x1,t.y1),a=Vm(t.n2,t.x2,t.y2);if(!i||!a)return;let o=n.color??`#ffffff`,s=(n.width??.5)*Rm;n.lineStyle===`dashed`?Km(e,[i,a],Hm*(n.width??.5),Um*(n.width??.5)):n.lineStyle===`dotted`?Km(e,[i,a],Wm*(n.width??.5),Gm*(n.width??.5)):(e.moveTo(i[0],i[1]),e.lineTo(a[0],a[1])),e.stroke({color:o,width:s,alpha:r})}drawCircle(e,t,n,r){let i=Vm(t.n,t.x,t.y);if(!i)return;let[a,o]=i,s=(n.radius??10)*Rm,c=!!(n.fill&&n.fill!==`transparent`),l=!!(n.stroke&&n.strokeWidth),u=(n.strokeWidth??.5)*Rm;c&&(e.circle(a,o,s),e.fill({color:n.fill,alpha:r})),l&&(n.lineStyle===`dashed`?Km(e,qm(a,o,s),Hm*(n.strokeWidth??.5),Um*(n.strokeWidth??.5)):n.lineStyle===`dotted`?Km(e,qm(a,o,s),Wm*(n.strokeWidth??.5),Gm*(n.strokeWidth??.5)):e.circle(a,o,s),e.stroke({color:n.stroke,width:u,alpha:r}))}drawRect(e,t,n,r){let i=Vm(t.n,t.x,t.y),a=Vm(t.n,t.x+t.w,t.y),o=Vm(t.n,t.x+t.w,t.y+t.h),s=Vm(t.n,t.x,t.y+t.h);if(!i||!a||!o||!s)return;let c=!!(n.fill&&n.fill!==`transparent`),l=!!(n.stroke&&n.strokeWidth),u=[i,a,o,s,i],d=u.flatMap(e=>e),f=(n.strokeWidth??.5)*Rm;c&&(e.poly(d.slice(0,8),!0),e.fill({color:n.fill,alpha:r})),l&&(n.lineStyle===`dashed`?Km(e,u,Hm*(n.strokeWidth??.5),Um*(n.strokeWidth??.5)):n.lineStyle===`dotted`?Km(e,u,Wm*(n.strokeWidth??.5),Gm*(n.strokeWidth??.5)):e.poly(d.slice(0,8),!0),e.stroke({color:n.stroke,width:f,alpha:r}))}drawPoly(e,t,n,r){if(!t.points||t.points.length===0)return;let i=!!(n.fill&&n.fill!==`transparent`),a=!!(n.stroke&&n.strokeWidth);if(!i&&!a)return;let o=[];for(let{n:e,x:n,y:r}of t.points){let t=Vm(e,n,r);if(!t)return;o.push(t)}let s=o.flatMap(e=>e),c=(n.strokeWidth??.5)*Rm;if(i&&(e.poly(s,!0),e.fill({color:n.fill,alpha:r})),a){if(n.lineStyle===`dashed`){let t=o[0],r=o[o.length-1];Km(e,t[0]===r[0]&&t[1]===r[1]?o:[...o,t],Hm*(n.strokeWidth??.5),Um*(n.strokeWidth??.5))}else if(n.lineStyle===`dotted`){let t=o[0],r=o[o.length-1];Km(e,t[0]===r[0]&&t[1]===r[1]?o:[...o,t],Wm*(n.strokeWidth??.5),Gm*(n.strokeWidth??.5))}else e.poly(s,!0);e.stroke({color:n.stroke,width:c,alpha:r})}}drawText(e,t,n){let r=Vm(e.n,e.x,e.y);if(!r)return;let[i,a]=r,o=t.fontSize??10,s=t.fontFamily??`sans-serif`,c=o*Rm,l=t.align??`center`,u=new ie({fill:t.color??`#ffffff`,fontSize:c*Bm,fontFamily:s,align:l,...t.fontStyle?{fontStyle:t.fontStyle}:{},...t.fontVariant?{fontVariant:t.fontVariant}:{},...t.stroke&&t.strokeWidth?{stroke:{color:t.stroke,width:t.strokeWidth*Rm*Bm}}:{}});if(t.backgroundColor&&t.backgroundColor!==`transparent`){let r=(t.backgroundPadding??2)*Rm,o=new ne({text:e.text,style:u});o.scale.set(1/Bm);let s=o.width,c=o.height;o.destroy();let d=i-(l===`center`?.5:+(l===`right`))*s-r,f=a-c/2-r,p=new w;p.rect(d,f,s+r*2,c+r*2),p.fill({color:t.backgroundColor,alpha:n}),this.container.addChild(p)}let d=new ne({text:e.text,style:u});d.scale.set(1/Bm),d.anchor.x=l===`center`?.5:+(l===`right`),d.anchor.y=.5,d.position.set(i,a),d.alpha=n,this.container.addChild(d)}destroy(){let e=this.container.removeChildren();for(let t of e)t!==this.g&&t.destroy();this.g.destroy(),this.container.destroy()}},{warn:Ym}=Qt(`terrainCache`),Xm=`screeps-terrain-v1`;async function Zm(e,t,n){try{let r=await caches.open(Xm),i=`/terrain/${e}_${t}_z${n}.webp`,a=new Request(i),o=await r.match(a);if(o){let e=await o.arrayBuffer(),t=o.headers.get(`Content-Type`)??`image/webp`;return new Blob([e],{type:t})}}catch(e){Ym(`get failed:`,e)}return null}async function Qm(e,t,n,r){try{let i=await caches.open(Xm),a=`/terrain/${e}_${t}_z${n}.webp`,o=new Request(a),s=new Response(r);await i.put(o,s)}catch(e){Ym(`save failed:`,e)}}var $m=null;async function eh(e){if($m!==!1)try{let t=await createImageBitmap(e);return $m=!0,t}catch(e){if($m===!0)throw e;$m=!1}let t=URL.createObjectURL(e);try{let e=new Image;return e.src=t,await e.decode(),await createImageBitmap(e)}finally{URL.revokeObjectURL(t)}}function th(e){return new Worker(``+new URL(`terrain.worker-CiQZPqa4.js`,import.meta.url).href,{name:e?.name})}var{warn:nh}=Qt(`MapRenderer`),rh=[50,60,70,80,90,100,105,120],ih=1,ah=.5,oh=50,sh=2600,ch=5,lh=.2,uh=5,dh=ha,fh=16777215,ph=na,mh=la,hh=16720418,gh=16777215,_h=ra,vh=fa,yh=4486980,bh=8921634,xh=new Set([`w`,`r`,`pb`,`p`,`s`,`c`,`m`,`k`,`d`]),Sh=[80,104,128,160],Ch=class{app;world;boundsGraphics=null;selectionGraphics=null;safeModeGraphics=null;mapVisualLayer=null;safeModeRooms=new Set;activeRooms=new Map;roomPool=[];terrainBaked=new Set;terrainData=new Map;worker;pendingBakes=new Map;nextBakeId=0;currentShard=`shard0`;callbacks;resizeObserver=null;_destroyed=!1;showRoomNames=!1;worldBoundsSet=null;lastVisibleBounds=null;animTargetX=0;animTargetY=0;isAnimating=!1;overlayMode=`owner`;showUnclaimableOverlay=!0;isDragging=!1;hasDragged=!1;dragStartX=0;dragStartY=0;dragWorldX=0;dragWorldY=0;isPinching=!1;pinchPivotWorldX=0;pinchPivotWorldY=0;pinchStartDist=0;pinchStartScale=0;lastVisibleKey=``;visibleDebounceTimer=null;selectedRoom=null;currentUserId=null;badgeCache=new oo;constructor(e){this.app=new ee,this.callbacks=e,this.worker=new th,this.worker.onmessage=e=>{let t=e.data;if(t.kind===`cache`){Qm(t.shard,t.roomName,t.lod,new Blob([t.cacheBytes],{type:t.cacheType||`image/webp`}));return}let n=this.pendingBakes.get(t.id);n&&(this.pendingBakes.delete(t.id),n.resolve(t.bitmap))}}async init(e){let t=e.parentElement??e,{width:n,height:r}=t.getBoundingClientRect();await this.app.init({canvas:e,width:n,height:r,background:Zi,antialias:!1,preference:`webgl`}),this.resizeObserver=new ResizeObserver(e=>{let{width:t,height:n}=e[0].contentRect,r=this.app.screen.width,i=this.app.screen.height;this.app.renderer.resize(t,n),this.world.x+=(t-r)/2,this.world.y+=(n-i)/2}),this.resizeObserver.observe(t),this.world=new E,this.app.stage.addChild(this.world),this.boundsGraphics=new w,this.world.addChild(this.boundsGraphics),this.selectionGraphics=new w,this.world.addChild(this.selectionGraphics),this.safeModeGraphics=new w,this.world.addChild(this.safeModeGraphics),this.mapVisualLayer=new Jm,this.world.addChild(this.mapVisualLayer.container),this.setupInteraction(),this.app.ticker.add(()=>{if(this.isAnimating){let e=this.animTargetX-this.world.x,t=this.animTargetY-this.world.y;Math.abs(e)<.5&&Math.abs(t)<.5?(this.world.x=this.animTargetX,this.world.y=this.animTargetY,this.isAnimating=!1):(this.world.x+=e*.2,this.world.y+=t*.2)}this.checkVisibleRooms()})}get zoom(){return this.world?.scale.x??1}setZoom(e){if(!this.world||(e=Math.max(lh,Math.min(uh,e)),e===this.world.scale.x))return;let t=this.app.screen.width/2,n=this.app.screen.height/2;this.applyZoomAt(e,t,n)}applyZoomAt(e,t,n){let r=this.world.scale.x,i=this.getLOD(),a=this.zoom>=ih,o=this.zoom>=ah,s=(t-this.world.x)/r,c=(n-this.world.y)/r;this.world.scale.set(e),this.world.x=t-s*e,this.world.y=n-c*e,this.getLOD()!==i&&this.applyLOD(),(e>=ih!==a||e>=.5!==o)&&this.updateAllNameLabels(),this.updateAllRoomScales(e),this.callbacks.onZoomChanged?.(e),this.setSelectedRoom(this.selectedRoom),this.redrawSafeMode()}centerOn(e,t,n=!1){let r=e*150+150/2,i=t*150+150/2,a=this.world.scale.x,o=this.app.screen.width/2-r*a,s=this.app.screen.height/2-i*a;n?(this.animTargetX=o,this.animTargetY=s,this.isAnimating=!0):(this.isAnimating=!1,this.world.x=o,this.world.y=s)}async getTerrainBitmap(e,t,n){let r=this.currentShard;try{let i=await Zm(r,e,t);if(i)return await eh(i);let a=this.nextBakeId++,o=new Promise((n,r)=>{this.pendingBakes.set(a,{roomName:e,lod:t,resolve:n,reject:r})});return this.worker.postMessage({id:a,roomName:e,lod:t,raw:n,shard:r}),await o}catch(e){return nh(`error getting terrain bitmap:`,e),null}}async setRoomTerrain(e,t){let n=t.raw,r=!1;for(let e=0;e<n.length;e++)if(n[e]!==0){r=!0;break}if(!r){this.terrainBaked.add(e);return}let i=this.getOrCreate(e),a=this.getLOD();this.terrainData.set(e,n);let o=await this.getTerrainBitmap(e,a,n);if(!o)return;if(!this.activeRooms.has(e)){o.close();return}let s=D.from(o);a===0?(i.texLo&&!i.texLo.destroyed&&(i.terrainSprite.texture===i.texLo&&(i.terrainSprite.texture=D.EMPTY),i.texLo.destroy(!0)),i.texLo=s):(i.texHi&&!i.texHi.destroyed&&(i.terrainSprite.texture===i.texHi&&(i.terrainSprite.texture=D.EMPTY),i.texHi.destroy(!0)),i.texHi=s),i.terrainSprite.width=150,i.terrainSprite.height=150,this.terrainBaked.add(e),this.ensureCurrentLod(e,i)}getLOD(){return this.zoom<ih?0:1}ensureCurrentLod(e,t){let n=this.getLOD()===1,r=n?t.texHi:t.texLo;if(r&&!r.destroyed){t.terrainSprite.texture=r;return}let i=this.terrainData.get(e);if(i)return this.getTerrainBitmap(e,+!!n,i).then(r=>{if(!r)return;if(!this.activeRooms.has(e)){r.close();return}let i=D.from(r);n?t.texHi=i:t.texLo=i,this.getLOD()===1===n&&(t.terrainSprite.texture=i)})}async applyLOD(){let e=[];for(let[t,n]of this.activeRooms){if(!this.terrainBaked.has(t))continue;let r=this.ensureCurrentLod(t,n);r&&e.push(r)}await Promise.all(e)}setRoomMap2(e,t,n=`live`){let r=this.getOrCreate(e);r.lastMap2Data=t,r.lastMap2Source=n,this.drawMap2(r,t,n)}drawMap2(e,t,n){let r=e.map2Graphics;r.alpha=n===`cache`?.6:1,r.clear();let i=t.r??[];for(let[e,t]of i)r.rect(e*3,t*3,3,3);i.length&&r.fill(Qi);let a=t.w??[];for(let[e,t]of a)r.rect(e*3+.5,t*3+.5,2,2);a.length&&r.fill(e.ownerState===`other`?bh:yh);let o=t.s??[];for(let[e,t]of o)r.circle((e+.5)*3,(t+.5)*3,2.5);o.length&&r.fill(dh);let s=t.c??[];for(let[e,t]of s)r.circle((e+.5)*3,(t+.5)*3,2);s.length&&r.fill(fh);let c=t.m??[];for(let[e,t]of c)r.circle((e+.5)*3,(t+.5)*3,2);c.length&&r.fill(ph);let l=t.k??[];for(let[e,t]of l)r.circle((e+.5)*3,(t+.5)*3,2);l.length&&r.fill(mh);let u=t.pb??[];for(let[e,t]of u)r.circle((e+.5)*3,(t+.5)*3,2.5);u.length&&r.fill(hh);let d=t.d??[];for(let[e,t]of d)r.circle((e+.5)*3,(t+.5)*3,2.5);d.length&&r.fill(gh);let f=t;for(let e in f){if(xh.has(e))continue;let t=f[e];if(!Array.isArray(t)||t.length===0)continue;for(let[e,n]of t)r.circle((e+.5)*3,(n+.5)*3,1);let n=e===this.currentUserId?_h:vh;r.fill(n)}}clearRoomMap2(e){this.activeRooms.get(e)?.map2Graphics.clear()}clearAllMap2(){for(let e of this.activeRooms.values())e.map2Graphics.clear()}setRoomOwned(e,t){let n=this.activeRooms.get(e);if(!n)return;n.ownerState!==t&&(n.ownerState=t,n.lastMap2Data&&this.drawMap2(n,n.lastMap2Data,n.lastMap2Source??`live`));let r=n.ownerOverlay;r.clear(),t===`other`?(r.rect(0,0,150,150),r.fill({color:10027008,alpha:.18})):t===`own`&&(r.rect(0,0,150,150),r.fill({color:102,alpha:.35})),r.visible=this.showUnclaimableOverlay}setUnclaimableOverlayVisible(e){if(this.showUnclaimableOverlay!==e){this.showUnclaimableOverlay=e;for(let t of this.activeRooms.values())t.ownerOverlay.visible=e}}async setRoomBadge(e,t,n){let r=this.activeRooms.get(e);if(r){if(!t){r.badgeSprite&&=(r.container.removeChild(r.badgeSprite),r.badgeSprite.destroy(),void 0),r.badgeLevel=void 0;return}try{let i=await this.badgeCache.getOrCreate(t);if(!this.activeRooms.has(e))return;if(r.badgeSprite){if(r.badgeSprite.texture===i){r.badgeLevel=n,this.applyBadgeSize(r,this.zoom),this.applyOverlayMode(r);return}r.badgeSprite.texture=i}else{let e=new j(i);e.anchor.set(.5),e.x=150/2,e.y=150/2;let t=r.container.getChildIndex(r.nameLabel);r.container.addChildAt(e,t),r.badgeSprite=e}r.badgeLevel=n,this.applyBadgeSize(r,this.zoom),this.applyOverlayMode(r)}catch(t){nh(`failed to load badge for`,e,t)}}}applyBadgeSize(e,t){if(!e.badgeSprite||e.badgeLevel===void 0)return;let n=(rh[e.badgeLevel-1]??24)*Math.min(1,t);e.badgeSprite.width=n/t,e.badgeSprite.height=n/t}setOverlayMode(e){if(this.overlayMode!==e){this.overlayMode=e;for(let e of this.activeRooms.values())this.applyOverlayMode(e)}}setRoomMineral(e,t,n){let r=this.activeRooms.get(e);if(r){if(!t||!n){r.mineralSprite&&=(r.container.removeChild(r.mineralSprite),r.mineralSprite.destroy(),void 0),r.mineralType=void 0,r.mineralDensity=void 0;return}if(r.mineralDensity=n,!r.mineralSprite||r.mineralType!==t){r.mineralSprite&&(r.container.removeChild(r.mineralSprite),r.mineralSprite.destroy());let e=`mineral/${t}`,n=new j;n.anchor.set(.5),n.x=150/2,n.y=150/2;let i=r.container.getChildIndex(r.nameLabel);r.container.addChildAt(n,i),r.mineralSprite=n,r.mineralType=t;let a=zl.getTexture(Il.atlasUrl,e);a?n.texture=a:zl.getOrLoad(Il.atlasUrl).then(t=>{n.destroyed||(n.texture=t.textures[e]??D.EMPTY)}).catch(()=>{})}this.applyMineralSize(r,this.zoom),this.applyOverlayMode(r)}}applyOverlayMode(e){e.badgeSprite&&(e.badgeSprite.visible=this.overlayMode===`owner`),e.mineralSprite&&(e.mineralSprite.visible=this.overlayMode===`mineral`)}applyMineralSize(e,t){if(!e.mineralSprite||e.mineralDensity===void 0)return;let n=Sh[e.mineralDensity-1]??52,r=14/t,i=Math.max(n,r);e.mineralSprite.width=i,e.mineralSprite.height=i}updateNameLabelScale(e,t){let n=.3/Math.sqrt(t),r=12/(36*t);e.nameLabel.scale.set(Math.max(n,r))}updateAllRoomScales(e){for(let t of this.activeRooms.values())this.applyBadgeSize(t,e),this.updateNameLabelScale(t,e),this.applyMineralSize(t,e)}setCurrentUser(e){this.currentUserId=e}setMapVisual(e){this.mapVisualLayer?.update(e),this.mapVisualLayer&&(this.world.removeChild(this.mapVisualLayer.container),this.world.addChild(this.mapVisualLayer.container))}clearMapVisual(){this.mapVisualLayer?.clear()}setMapVisualVisible(e){this.mapVisualLayer&&(this.mapVisualLayer.container.visible=e)}setSelectedRoom(e){if(this.selectedRoom=e,!this.selectionGraphics||(this.selectionGraphics.clear(),this.world.removeChild(this.selectionGraphics),this.world.addChild(this.selectionGraphics),!e))return;let t=Lu(e);if(!t)return;let n=t.x*150,r=t.y*150;this.selectionGraphics.rect(n,r,150,150);let i=Math.max(2,Math.ceil(2/this.zoom));this.selectionGraphics.stroke({color:16777215,width:i,alignment:0})}setRoomSafeMode(e,t){t?this.safeModeRooms.add(e):this.safeModeRooms.delete(e),this.redrawSafeMode()}redrawSafeMode(){if(!this.safeModeGraphics||(this.safeModeGraphics.clear(),this.safeModeRooms.size===0))return;let e=Math.max(1,Math.ceil(1/this.zoom));for(let t of this.safeModeRooms){let n=Lu(t);if(!n)continue;let r=n.x*150,i=n.y*150;this.safeModeGraphics.rect(r,i,150,150),this.safeModeGraphics.stroke({color:16776960,width:e,alignment:1,alpha:.5})}this.world.removeChild(this.safeModeGraphics),this.world.addChild(this.safeModeGraphics)}setBounds(e,t,n,r){if(!this.boundsGraphics)return;this.worldBoundsSet={minX:e,maxX:t,minY:n,maxY:r},this.boundsGraphics.clear();let i=e*150,a=n*150,o=(t-e+1)*150,s=(r-n+1)*150;this.boundsGraphics.rect(i,a,o,s),this.boundsGraphics.stroke({color:$i,width:6,alignment:0}),this.updateAllNameLabels()}clearBounds(){this.worldBoundsSet=null,this.boundsGraphics?.clear(),this.updateAllNameLabels()}setShowRoomNames(e){this.showRoomNames=e,this.updateAllNameLabels()}hasRoom(e){return this.terrainBaked.has(e)}markRoomFetched(e){this.terrainBaked.add(e)}clearRoom(e){let t=this.activeRooms.get(e);t&&(t.texLo&&!t.texLo.destroyed&&t.texLo.destroy(!0),t.texHi&&!t.texHi.destroyed&&t.texHi.destroy(!0),t.texLo=null,t.texHi=null,t.terrainSprite.texture=D.EMPTY,t.map2Graphics.clear(),t.ownerOverlay.clear(),t.badgeSprite&&=(t.container.removeChild(t.badgeSprite),t.badgeSprite.destroy(),void 0),t.mineralSprite&&=(t.container.removeChild(t.mineralSprite),t.mineralSprite.destroy(),void 0),t.mineralType=void 0,t.mineralDensity=void 0,t.container.visible=!1,this.safeModeRooms.delete(e),this.terrainBaked.delete(e),this.terrainData.delete(e),this.activeRooms.delete(e),this.roomPool.length<sh?this.roomPool.push(t):(this.world.removeChild(t.container),t.container.destroy({children:!0,context:!0})))}clearInvisibleRooms(e){let t=this.lastVisibleBounds;for(let n of[...this.activeRooms.keys()])if(!e.has(n)){if(t){let e=Lu(n);if(e&&e.x>=t.rxMin-oh&&e.x<=t.rxMax+oh&&e.y>=t.ryMin-oh&&e.y<=t.ryMax+oh)continue}this.clearRoom(n)}}destroy(){if(!this._destroyed){this._destroyed=!0,this.resizeObserver?.disconnect(),this.resizeObserver=null,this.visibleDebounceTimer!==null&&(clearTimeout(this.visibleDebounceTimer),this.visibleDebounceTimer=null);for(let[,e]of this.activeRooms)e.texLo&&!e.texLo.destroyed&&e.texLo.destroy(!0),e.texHi&&!e.texHi.destroyed&&e.texHi.destroy(!0);this.activeRooms.clear(),this.safeModeRooms.clear();for(let e of this.roomPool)e.texLo&&!e.texLo.destroyed&&e.texLo.destroy(!0),e.texHi&&!e.texHi.destroyed&&e.texHi.destroy(!0);this.roomPool.length=0,this.terrainBaked.clear(),this.terrainData.clear(),this.worker.terminate(),this.pendingBakes.clear(),this.badgeCache.destroy(),this.mapVisualLayer?.destroy(),this.mapVisualLayer=null;try{this.app.destroy(!1,{children:!0,context:!0})}catch(e){nh(`destroy error (ignored):`,e)}}}getOrCreate(e){let t=this.activeRooms.get(e);if(t)return t;let n=Lu(e);if(!n)throw Error(`MapRenderer: invalid room "${e}"`);let r;if(this.roomPool.length>0)r=this.roomPool.pop();else{let e=new E;e.cullable=!0;let t=new j(D.EMPTY),n=new w,i=new w;e.addChild(t),e.addChild(n),e.addChild(i);let a=new ne({text:``,style:{fontSize:36,fill:9147550,fontFamily:`ui-monospace, monospace`}});a.scale.set(.25),a.x=2,a.y=2,e.addChild(a),this.world.addChild(e),r={container:e,terrainSprite:t,texLo:null,texHi:null,map2Graphics:n,ownerOverlay:i,ownerState:`none`,nameLabel:a}}return r.container.x=n.x*150,r.container.y=n.y*150,r.container.visible=!0,r.nameLabel.text=e,r.nameLabel.visible=this.showRoomNames&&this.zoom>=.5&&this.nameLabelShouldShow(n.x,n.y),this.updateNameLabelScale(r,this.zoom),r.badgeSprite&&(r.container.removeChild(r.badgeSprite),r.badgeSprite.destroy(),r.badgeSprite=void 0),r.mineralSprite&&(r.container.removeChild(r.mineralSprite),r.mineralSprite.destroy(),r.mineralSprite=void 0),r.mineralType=void 0,r.mineralDensity=void 0,this.safeModeGraphics&&(this.world.removeChild(this.safeModeGraphics),this.world.addChild(this.safeModeGraphics)),this.selectionGraphics&&(this.world.removeChild(this.selectionGraphics),this.world.addChild(this.selectionGraphics)),this.activeRooms.set(e,r),r}nameLabelShouldShow(e,t){let n=this.worldBoundsSet;return!(n&&(e<n.minX||e>n.maxX||t<n.minY||t>n.maxY))}updateAllNameLabels(){let e=this.showRoomNames&&this.zoom>=.5;for(let[t,n]of this.activeRooms){if(!e){n.nameLabel.visible=!1;continue}let r=Lu(t);r&&(n.nameLabel.visible=this.nameLabelShouldShow(r.x,r.y))}}setupInteraction(){let e=this.app.canvas;e.style.touchAction=`none`,e.style.userSelect=`none`;let t=new Map;e.addEventListener(`pointermove`,n=>{if(!t.has(n.pointerId)){if(!this.isDragging&&!this.isPinching){let t=e.getBoundingClientRect();this.emitHover(n.clientX-t.left,n.clientY-t.top)}return}if(t.set(n.pointerId,{x:n.clientX,y:n.clientY}),this.isPinching&&t.size===2){let n=[...t.values()],r=e.getBoundingClientRect(),i=(n[0].x+n[1].x)/2-r.left,a=(n[0].y+n[1].y)/2-r.top,o=Math.hypot(n[1].x-n[0].x,n[1].y-n[0].y),s=Math.max(lh,Math.min(uh,this.pinchStartScale*(o/this.pinchStartDist))),c=this.getLOD(),l=this.zoom>=ih,u=this.zoom>=ah;this.world.scale.set(s),this.world.x=i-this.pinchPivotWorldX*s,this.world.y=a-this.pinchPivotWorldY*s,this.getLOD()!==c&&this.applyLOD(),(s>=ih!==l||s>=.5!==u)&&this.updateAllNameLabels(),this.updateAllRoomScales(s),this.callbacks.onZoomChanged?.(s),this.setSelectedRoom(this.selectedRoom),this.redrawSafeMode();return}if(this.isDragging){let e=n.clientX-this.dragStartX,t=n.clientY-this.dragStartY;(Math.abs(e)>3||Math.abs(t)>3)&&(this.hasDragged=!0);let r=this.worldBoundsSet;if(r){let n=this.world.scale.x,i=50-(r.maxX+1)*150*n,a=this.app.screen.width-50-r.minX*150*n,o=50-(r.maxY+1)*150*n,s=this.app.screen.height-50-r.minY*150*n;this.world.x=this.rubberBand(this.dragWorldX+e,i,a),this.world.y=this.rubberBand(this.dragWorldY+t,o,s)}else this.world.x=this.dragWorldX+e,this.world.y=this.dragWorldY+t}}),e.addEventListener(`pointerleave`,()=>{!this.isDragging&&!this.isPinching&&this.callbacks.onRoomHover(null)}),e.addEventListener(`pointerdown`,n=>{if(n.preventDefault(),this.isAnimating=!1,t.set(n.pointerId,{x:n.clientX,y:n.clientY}),e.setPointerCapture(n.pointerId),t.size>=2){this.isDragging=!1,this.isPinching=!0;let n=[...t.values()],r=e.getBoundingClientRect(),i=(n[0].x+n[1].x)/2-r.left,a=(n[0].y+n[1].y)/2-r.top;this.pinchStartDist=Math.hypot(n[1].x-n[0].x,n[1].y-n[0].y),this.pinchStartScale=this.world.scale.x,this.pinchPivotWorldX=(i-this.world.x)/this.pinchStartScale,this.pinchPivotWorldY=(a-this.world.y)/this.pinchStartScale}else this.isPinching=!1,this.isDragging=!0,this.hasDragged=!1,this.dragStartX=n.clientX,this.dragStartY=n.clientY,this.dragWorldX=this.world.x,this.dragWorldY=this.world.y}),e.addEventListener(`pointerup`,n=>{if(t.delete(n.pointerId),e.releasePointerCapture(n.pointerId),this.isPinching){t.size<2&&(this.isPinching=!1,this.isDragging=!1,this.springBack());return}if(this.isDragging){if(this.isDragging=!1,!this.hasDragged){let t=e.getBoundingClientRect(),r=this.screenToRoom(n.clientX-t.left,n.clientY-t.top);r&&this.callbacks.onRoomClick(r)}this.springBack()}}),e.addEventListener(`pointercancel`,n=>{t.delete(n.pointerId),e.releasePointerCapture(n.pointerId),(this.isPinching||this.isDragging)&&(this.isPinching=!1,this.isDragging=!1,this.springBack())}),e.addEventListener(`wheel`,e=>{if(e.preventDefault(),this.isDragging||this.isPinching)return;this.isAnimating=!1;let t=this.world.scale.x,n=e.deltaY<0?1.1:.9,r=Math.max(lh,Math.min(uh,t*n));this.applyZoomAt(r,e.offsetX,e.offsetY)},{passive:!1})}rubberBand(e,t,n){let r=n-t;if(r<=0||e>=t&&e<=n)return e;let i=.55;return e<t?t-(1-1/((t-e)*i/r+1))*r*i:n+(1-1/((e-n)*i/r+1))*r*i}springBack(){let e=this.worldBoundsSet;if(!e)return;let t=this.world.scale.x,n=this.app.screen.width,r=this.app.screen.height,i=this.world.x+e.minX*150*t,a=this.world.x+(e.maxX+1)*150*t,o=this.world.y+e.minY*150*t,s=this.world.y+(e.maxY+1)*150*t,c=this.world.x,l=this.world.y;a<50?c+=50-a:i>n-50&&(c-=i-(n-50)),s<50?l+=50-s:o>r-50&&(l-=o-(r-50)),(c!==this.world.x||l!==this.world.y)&&(this.animTargetX=c,this.animTargetY=l,this.isAnimating=!0)}screenToRoom(e,t){let n=this.world.scale.x,r=(e-this.world.x)/n,i=(t-this.world.y)/n;return Ru(Math.floor(r/150),Math.floor(i/150))}emitHover(e,t){this.callbacks.onRoomHover(this.screenToRoom(e,t))}lastCheckX=0;lastCheckY=0;lastCheckScale=0;checkVisibleRooms(){let e=this.world.scale.x,t=this.world.x,n=this.world.y;if(this.lastCheckX===t&&this.lastCheckY===n&&this.lastCheckScale===e)return;this.lastCheckX=t,this.lastCheckY=n,this.lastCheckScale=e;let r=-t/e,i=-n/e,a=(this.app.screen.width-t)/e,o=(this.app.screen.height-n)/e,s=Math.floor(r/150)-1,c=Math.ceil(a/150),l=Math.floor(i/150)-1,u=Math.ceil(o/150);this.lastVisibleBounds={rxMin:s,rxMax:c,ryMin:l,ryMax:u};let d=[],f=this.worldBoundsSet,p=f?Math.max(s,f.minX):s,m=f?Math.min(c,f.maxX):c,h=f?Math.max(l,f.minY):l,g=f?Math.min(u,f.maxY):u;for(let e=p;e<=m;e++)for(let t=h;t<=g;t++){let n=Ru(e,t);n&&d.push(n)}let _=`${s},${l},${c},${u}`;_!==this.lastVisibleKey&&(this.lastVisibleKey=_,this.visibleDebounceTimer!==null&&clearTimeout(this.visibleDebounceTimer),this.visibleDebounceTimer=setTimeout(()=>{this.visibleDebounceTimer=null,this.callbacks.onVisibleRoomsChanged(d)},ch))}},wh=N(`<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></div><div style="display:grid;grid-template-columns:repeat(3, 1fr);gap:4px;margin-top:8px">`),Th=N(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;font-size:11px;font-weight:600">`),Eh=[{mode:`owner`,label:`Owner`},{mode:`mineral`,label:`Mineral`},{mode:`none`,label:`None`}];function Dh(e){let t=()=>(e.zoom??1)>=ah;return(()=>{var n=wh(),r=n.firstChild,i=r.firstChild.nextSibling,a=i.firstChild.nextSibling,s=a.nextSibling.nextSibling,c=i.nextSibling,u=c.firstChild.nextSibling,d=c.nextSibling,f=d.firstChild.nextSibling,p=d.nextSibling.firstChild.nextSibling,h=r.nextSibling;return R(a,()=>e.zoom?.toFixed(2)??`—`),R(s,()=>e.subsActive?`Yes`:`No`),u.addEventListener(`change`,e=>yl(e.currentTarget.checked)),f.addEventListener(`change`,e=>xl(e.currentTarget.checked)),p.addEventListener(`change`,e=>Nl(e.currentTarget.checked)),R(h,m(l,{each:Eh,children:e=>{let t=()=>Im()===e.mode;return(()=>{var n=Th();return n.$$click=()=>Lm(e.mode),R(n,()=>e.label),o(e=>{var r=`1px solid ${t()?`#58a6ff`:`#30363d`}`,i=t()?`#1f6feb33`:`#161b22`,a=t()?`#c9d1d9`:`#8b949e`;return r!==e.e&&L(n,`border`,e.e=r),i!==e.t&&L(n,`background`,e.t=i),a!==e.a&&L(n,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),n})()}})),o(e=>{var n=t()?`#c9d1d9`:`#484f58`,r=t()?`pointer`:`default`,i=!t();return n!==e.e&&L(c,`color`,e.e=n),r!==e.t&&L(c,`cursor`,e.t=r),i!==e.a&&(u.disabled=e.a=i),e},{e:void 0,t:void 0,a:void 0}),o(()=>u.checked=vl()),o(()=>f.checked=bl()),o(()=>p.checked=Ml()),n})()}P([`click`]);var Oh=N(`<img width=12 height=12 alt style="border-radius:2px;flex:0 0 auto;display:block">`),kh=N(`<div style="padding:3px 8px;color:#484f58">None`),Ah=N(`<div style="padding:3px 8px;color:#c9d1d9;display:flex;align-items:center;gap:4px;min-width:0"><span style=overflow:hidden;text-overflow:ellipsis;white-space:nowrap>`),jh=N(`<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">`),Mh=N(`<div style="padding:6px 8px;font-size:11px;color:#484f58;font-style:italic">None`),Nh=N(`<div style="padding:3px 8px;color:#8b949e">Reservation`),Ph=N(`<div style="padding:3px 8px;color:#8b949e">Mineral`),Fh=N(`<div style="padding:3px 8px;color:#79c0ff">`),Ih=N(`<div style="padding:3px 8px;color:#8b949e">Density`),Lh=N(`<div style="padding:3px 8px;color:#c9d1d9">`),Rh=N(`<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">`),zh=N(`<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">`),Bh=N(`<div style="padding:3px 8px;color:#8b949e">Owner`),Vh=N(`<div style=display:flex;align-items:center;gap:4px;align-self:flex-end;color:#8b949e><span>—</span><span>`),Hh=N(`<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>`),Uh=[`Low`,`Medium`,`High`,`Ultra`];function Wh(e){return Uh[e-1]??String(e)}function Gh(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 Kh(e){let t=d(()=>`data:image/svg+xml,${encodeURIComponent(Vt(e.badge))}`);return(()=>{var e=Oh();return o(()=>F(e,`src`,t())),e})()}function qh(e){return m(u,{get when(){return e.name},get fallback(){return kh()},children:t=>(()=>{var n=Ah(),r=n.firstChild;return R(n,m(u,{get when(){return e.badge},children:e=>m(Kh,{get badge(){return e()}})}),r),R(r,t),n})()})}function Jh(e){return(()=>{var t=jh(),n=t.firstChild;return R(n,()=>e.label),R(t,m(u,{get when(){return e.info},get fallback(){return Mh()},children:e=>(()=>{var t=Rh(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return R(r,()=>e().room),R(n,m(u,{get when(){return e().level},children:e=>(()=>{var t=zh();return R(t,e),t})()}),null),R(i,m(u,{get when(){return e().reservation},get fallback(){return[Bh(),m(qh,{get name(){return e().owner},get badge(){return e().badge}})]},get children(){return[Nh(),m(qh,{get name(){return e().reservation},get badge(){return e().badge}})]}}),null),R(i,m(u,{get when(){return e().mineral},get children(){return[Ph(),(()=>{var t=Fh();return R(t,()=>e().mineral),t})(),Ih(),(()=>{var t=Lh();return R(t,()=>Wh(e().density??0)),t})()]}}),null),R(t,m(u,{get when(){return e().sign},children:e=>(()=>{var t=Hh(),n=t.firstChild.nextSibling,r=n.firstChild.nextSibling;r.nextSibling;var i=n.nextSibling;return R(n,()=>e().text,r),R(t,m(u,{get when(){return e().username||e().badge},get children(){var t=Vh(),n=t.firstChild.nextSibling;return R(t,m(u,{get when(){return e().badge},children:e=>m(Kh,{get badge(){return e()}})}),n),R(n,()=>e().username),t}}),i),R(i,()=>Gh(e().datetime)),t})()}),null),t})()}),null),o(n=>{var r=`1px solid ${e.dim?`#21262d`:`#30363d`}`,i=e.dim?.6:1;return r!==n.e&&L(t,`border`,n.e=r),i!==n.t&&L(t,`opacity`,n.t=i),n},{e:void 0,t:void 0}),t})()}var Yh=N(`<span style=color:#8b949e;font-size:11px>Checking…`),Xh=N(`<div style=margin-top:8px><div style="padding:6px 8px;font-size:11px;font-weight:600;color:#c9d1d9;margin-bottom:6px">Your flags`),Zh=N(`<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>`),Qh=N(`<span style=color:#f85149;font-size:11px>`),$h=N(`<div style=margin-top:8px;color:#484f58;font-style:italic;font-size:12px>No flags.`),eg=N(`<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:tg}=Qt(`flag`),ng={};for(let[e,t]of Object.entries(Sd))ng[t]=e;function rg(){let e=e=>{Dd({...Ed(),...e})},[t,n]=x(null),[i,a]=x(!1),s=null,c=t=>{t.http.game.genUniqueFlagName().then(t=>{e({name:t.name}),n(null)}).catch(e=>{tg(`gen unique name failed:`,e)})};f(()=>{if(wd()!==`flag`)return;let e=W();if(!e)return;let t=r(()=>Ed().name.trim());if(!t){c(e);return}e.http.game.checkUniqueFlagName(t).then(()=>{n(null)}).catch(()=>{c(e)})});let d=t=>{e({name:t}),n(null),s&&clearTimeout(s);let r=t.trim();if(!r){a(!1);return}a(!0),s=setTimeout(()=>{let e=W();if(!e){a(!1);return}e.http.game.checkUniqueFlagName(r).then(()=>{n(null)}).catch(e=>{n(e.message)}).finally(()=>{a(!1)})},300)},p=()=>Sd[Ed().color]??1,h=()=>Sd[Ed().secondaryColor]??1,g=t=>{e({color:ng[t]??`COLOR_WHITE`})},_=t=>{e({secondaryColor:ng[t]??`COLOR_WHITE`})},v=()=>{let e=On(),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>=pa.length?`#8b949e`:`#${pa[e].toString(16).padStart(6,`0`)}`,b={display:`flex`,"flex-direction":`column`,gap:`5px`,"font-size":`11px`,color:`#8b949e`};return(()=>{var e=Zh(),n=e.firstChild.firstChild.nextSibling.firstChild,r=n.firstChild.nextSibling,a=n.nextSibling;a.firstChild;var s=a.nextSibling;s.firstChild;var c=s.nextSibling;return r.$$input=e=>d(e.currentTarget.value),R(n,m(u,{get when(){return t()},children:e=>(()=>{var t=Qh();return R(t,e),t})()}),null),R(n,m(u,{get when(){return i()},get children(){return Yh()}}),null),R(a,m(cp,{get value(){return p()},onChange:g}),null),R(s,m(cp,{get value(){return h()},onChange:_}),null),R(c,(()=>{var e=M(()=>!!Od());return()=>e()?`Marked at x=${Od().tx}, y=${Od().ty}. Click again to create the flag, or click elsewhere to move the mark.`:`Click a position in the room to mark it.`})()),R(e,m(u,{get when(){return v().length>0},get fallback(){return $h()},get children(){var e=Xh();return e.firstChild,R(e,m(l,{get each(){return v()},children:([e,t])=>(()=>{var n=eg(),r=n.firstChild.firstChild,i=r.nextSibling,a=i.nextSibling,s=a.nextSibling,c=s.firstChild.nextSibling,l=c.nextSibling.nextSibling;return l.nextSibling,R(i,e),R(a,()=>t.room),R(s,()=>t.x,c),R(s,()=>t.y,l),o(e=>L(r,`background`,y(t.color))),n})()}),null),e}}),null),o(e=>{var i=b,o=`1px solid ${t()?`#f85149`:`#30363d`}`,c=b,l=b;return e.e=I(n,i,e.e),o!==e.t&&L(r,`border`,e.t=o),e.a=I(a,c,e.a),e.o=I(s,l,e.o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),o(()=>r.value=Ed().name),e})()}P([`input`]);var ig=N(`<span style=color:#8b949e>…`),ag=N(`<span style=color:#3fb950>✓`),og=N(`<span style=color:#f85149>✗`),sg=N(`<div style=font-size:10px;color:#f85149>`),cg=N(`<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>`),lg=N(`<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>`),ug=N(`<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 dg(t){let n=Object.keys(Cd),[r,i]=x(`idle`),[a,s]=x(``),c=null,d=(e,t)=>{let n=Cd[e];return n?An()===`empty`&&e===`spawn`?Math.max(n[t]??0,1):n[t]??0:0},p=(e,t)=>{let n=d(e,t);if(n===2500)return 1/0;let r=Ou()[e]??0;return Math.max(0,n-r)},h=()=>Md().structureType===`spawn`;f(e(()=>Md().structureType,(e,n)=>{if(e!==`spawn`||e===n)return;let r=W();if(!r)return;i(`loading`),s(``);let a=!1;y(()=>{a=!0}),r.http.game.genUniqueObjectName(`spawn`,t.shard).then(e=>{a||(Nd({structureType:`spawn`,structureName:e.name}),i(`valid`))}).catch(()=>{a||(Nd({structureType:`spawn`,structureName:`Spawn1`}),i(`idle`))})}));let g=e=>{if(c&&clearTimeout(c),!e.trim()){i(`invalid`),s(`Name cannot be empty`);return}i(`loading`),s(``),c=setTimeout(()=>{let n=W();n&&n.http.game.checkUniqueObjectName(`spawn`,e.trim(),t.shard).then(e=>{e.error?(i(`invalid`),s(e.error)):(i(`valid`),s(``))}).catch(()=>{i(`invalid`),s(`Could not validate name`)})},400)},_=e=>{Nd({structureType:`spawn`,structureName:e}),g(e)},v=e=>{Nd({structureType:e,structureName:``}),i(`idle`),s(``)},b=()=>{switch(r()){case`loading`:return ig();case`valid`:return ag();case`invalid`:return og();default:return null}};return(()=>{var e=lg(),t=e.firstChild,i=t.firstChild;i.firstChild;var s=i.nextSibling,c=t.nextSibling;c.firstChild;var f=c.nextSibling,g=f.firstChild;return R(i,()=>Su()??`?`,null),R(s,()=>{let e=An();return e===`empty`?`World is empty — place a spawn to claim this room.`:e===`lost`?`You lost all your spawns — respawn to continue.`:Su()==null?`No controller — roads and containers only.`:`RCL ${Su()} — Select a structure type and click a tile to build.`}),R(c,m(l,{each:n,children:e=>{let t=()=>Su()??0,n=()=>d(e,t()),r=()=>Ou()[e]??0,i=()=>Md().structureType===e,a=()=>n()===2500,s=()=>!a()&&p(e,t())<=0;return m(u,{get when(){return n()>0},get children(){var t=ug(),c=t.firstChild,l=c.nextSibling;return t.$$click=()=>!s()&&v(e),R(c,()=>e.replace(/([A-Z])/g,` $1`).trim(),null),R(c,()=>i()&&` ✓`,null),R(l,(()=>{var e=M(()=>!!a());return()=>e()?`${r()}/∞`:`${r()}/${n()}`})(),null),R(l,()=>s()&&` (Max)`,null),o(e=>{var n=i()?`#1f3158`:`transparent`,r=s()?`default`:`pointer`,a=s()?.5:1;return n!==e.e&&L(t,`background`,e.e=n),r!==e.t&&L(t,`cursor`,e.t=r),a!==e.a&&L(t,`opacity`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),t}})}}),null),R(e,m(u,{get when(){return h()},get children(){var e=cg(),t=e.firstChild.nextSibling,n=t.firstChild.firstChild,i=n.nextSibling;return n.$$input=e=>_(e.currentTarget.value),R(i,b),R(t,m(u,{get when(){return M(()=>r()===`invalid`)()&&a()},get children(){var e=sg();return R(e,a),e}}),null),o(e=>L(n,`border`,`1px solid ${r()===`invalid`?`#f85149`:r()===`valid`?`#238636`:`#30363d`}`)),o(()=>n.value=Md().structureName??``),e}}),f),R(g,()=>Md().structureType?`Click a tile in the room to build.`:`Select a structure type, then click a tile.`),e})()}P([`input`,`click`]);var fg=N(`<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">`),pg=N(`<button type=button>`),mg=N(`<option>/s`),hg=[.5,1,2,5,10,20],gg=[{delta:-100,label:`-100`},{delta:-10,label:`-10`}],_g=[{delta:10,label:`+10`},{delta:100,label:`+100`}];function vg(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 yg(){let e=()=>{let e=Yu(),t=Gu(),n=bn()??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=fg(),n=t.firstChild.firstChild,r=n.firstChild,i=r.nextSibling;i.firstChild;var a=n.nextSibling,s=a.firstChild,c=a.nextSibling.firstChild.nextSibling;return R(r,(()=>{var e=M(()=>!!td());return()=>e()?`Loading…`:`Tick ${Gu()}`})()),R(i,e,null),R(a,m(l,{each:gg,children:e=>(()=>{var t=pg();return t.$$click=()=>ld(e.delta),R(t,()=>e.label),o(e=>{var n=td(),r=vg(td());return n!==e.e&&(t.disabled=e.e=n),e.t=I(t,r,e.t),e},{e:void 0,t:void 0}),t})()}),s),xe(s,`click`,ud,!0),R(s,()=>Zu()?`⏸`:`▶`),R(a,m(l,{each:_g,children:e=>(()=>{var t=pg();return t.$$click=()=>ld(e.delta),R(t,()=>e.label),o(e=>{var n=td(),r=vg(td());return n!==e.e&&(t.disabled=e.e=n),e.t=I(t,r,e.t),e},{e:void 0,t:void 0}),t})()}),null),c.addEventListener(`change`,e=>dd(parseFloat(e.currentTarget.value))),R(c,m(l,{each:hg,children:e=>(()=>{var t=mg(),n=t.firstChild;return t.value=e,R(t,e,n),t})()})),o(e=>{var t=td()?`#f0883e`:`#c9d1d9`,n=td(),i=Zu()?`#1a3a2a`:`#161b22`,a=Zu()?`#3fb950`:`#8b949e`,o=td()?`not-allowed`:`pointer`;return t!==e.e&&L(r,`color`,e.e=t),n!==e.t&&(s.disabled=e.t=n),i!==e.a&&L(s,`background`,e.a=i),a!==e.o&&L(s,`color`,e.o=a),o!==e.i&&L(s,`cursor`,e.i=o),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),o(()=>c.value=$u()),t})()}P([`click`]);var bg=N(`<div style=padding-bottom:8px;overflow:auto;min-height:0>`),xg=N(`<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`),Sg=N(`<button style=background:transparent;border:none;color:#8b949e;font-size:14px;cursor:pointer;padding:4px>`),Cg=N(`<button style=background:transparent;border:none;color:#8b949e;font-size:11px;cursor:pointer>Collapse`);function wg(e){return m(u,{get when(){return wd()===`flag`},get fallback(){return m(u,{get when(){return wd()===`build`},get fallback(){return m(Cm,{})},get children(){return m(dg,{get shard(){return e.shard}})}})},get children(){return m(rg,{})}})}function Tg(e){let t=()=>{e.onToggle?.()},n=t=>{t.stopPropagation(),e.onToggle?.()};return(()=>{var r=xg(),i=r.firstChild,a=i.nextSibling,o=a.firstChild;return o.firstChild,i.$$click=t,R(i,(()=>{var t=M(()=>!!e.onToggle);return()=>t()&&(()=>{var t=Sg();return t.$$click=n,R(t,()=>e.isCollapsed?`▶`:`◀`),t})()})()),R(o,(()=>{var t=M(()=>!!e.onToggle);return()=>t()&&(()=>{var e=Cg();return e.$$click=n,e})()})(),null),R(a,m(u,{get when(){return e.mapMode},get fallback(){return m(Fm,{get room(){return e.room??`—`},get shard(){return e.shard??null}})},get children(){return m(Dh,{get zoom(){return e.mapZoom},get subsActive(){return e.mapSubsActive}})}}),null),R(a,m(u,{get when(){return M(()=>!e.mapMode)()&&Q()},get children(){return m(yg,{})}}),null),R(a,m(u,{get when(){return e.mapMode},get fallback(){return m(wg,{get shard(){return e.shard}})},get children(){var t=bg();return R(t,m(Jh,{label:`Selected`,get info(){return e.selectedRoomInfo??null}}),null),R(t,m(Jh,{label:`Cursor`,get info(){return e.hoveredRoomInfo??null},dim:!0}),null),t}}),null),r})()}P([`click`]);var Eg=N(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>CPU:</span><span style=color:#c9d1d9>`),Dg=N(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Memory:</span><span style=color:#c9d1d9>`),Og=N(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Zoom:</span><span style=color:#c9d1d9>%`),kg=N(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Subs:</span><span>`),Ag=N(`<div style="display:flex;gap:16px;padding:6px 16px;font-size:12px;color:#8b949e;align-items:center">`);function jg(e){let[t,n]=x(null);a(()=>{let e=W();if(!e)return;let t=new xt;t.add(e.stores.user.subscribe(`cpu`)),t.add(e.stores.user.on(`user:cpu`,e=>{n(e)})),y(()=>{t.dispose()})});let r=()=>{let e=t();if(!e)return`—`;let n=G()?.cpu??`?`;return`${e.cpu.toFixed(0)} / ${n}`},i=()=>{let e=t();return e?`${(e.memory/1024).toFixed(1)} KB`:`—`};return(()=>{var n=Ag();return R(n,m(u,{get when(){return t()!==null},get children(){return[(()=>{var e=Eg(),t=e.firstChild.nextSibling;return R(t,r),e})(),(()=>{var e=Dg(),t=e.firstChild.nextSibling;return R(t,i),e})()]}}),null),R(n,m(u,{get when(){return M(()=>e.mapZoom!==null)()&&e.mapZoom!==void 0},get children(){return[(()=>{var t=Og(),n=t.firstChild.nextSibling,r=n.firstChild;return R(n,()=>(e.mapZoom*100).toFixed(0),r),t})(),(()=>{var t=kg(),n=t.firstChild.nextSibling;return R(n,()=>e.mapSubsActive===!1?`paused`:`active`),o(t=>L(n,`color`,e.mapSubsActive===!1?`#e3b341`:`#3fb950`)),t})()]}}),null),n})()}var Mg=N(`<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">`),Ng=N(`<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>`),Pg=N(`<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">`),Fg=N(`<button style=width:100%;aspect-ratio:1;border-radius:2px;cursor:pointer;padding:0;outline:none>`),Ig={};for(let e=1;e<=24;e++){let t=Vt({type:e,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1});Ig[e]=`data:image/svg+xml,${encodeURIComponent(t)}`}function Lg(e){return typeof e==`string`?e:zt[e]?.rgb??`#000000`}function Rg(e){return typeof e==`number`?Math.max(0,Math.min(79,e)):e}var zg=[{slot:1,label:`Background`},{slot:2,label:`Primary`},{slot:3,label:`Secondary`}],Bg=Array.from({length:24},(e,t)=>t+1),Vg=/^#[0-9a-f]{6}$/i;function Hg(e){let[t,n]=x(r(()=>typeof e.badge.type==`number`?e.badge.type:1)),[i,a]=x(r(()=>Rg(e.badge.color1))),[s,c]=x(r(()=>Rg(e.badge.color2))),[u,p]=x(r(()=>Rg(e.badge.color3))),[h,g]=x(r(()=>e.badge.param??0)),[_,v]=x(r(()=>e.badge.flip??!1)),[y,b]=x(1),[S,C]=x(!1),[w,T]=x(r(()=>Lg(Rg(e.badge.color1)))),E=e=>e===1?i():e===2?s():u(),D=e=>{let t=y();t===1?a(e):t===2?c(e):p(e)};f(()=>{T(Lg(E(y())))});let O=e=>{let t=E(y());return typeof t==`number`?t===e:t.toLowerCase()===(zt[e]?.rgb??``).toLowerCase()},k=()=>({type:t(),color1:Lg(i()),color2:Lg(s()),color3:Lg(u()),param:h(),flip:_()}),ee=d(()=>{let e=Vt(k());return`data:image/svg+xml,${encodeURIComponent(e)}`}),te=e=>{if(T(e),!Vg.test(e))return;let t=zt.findIndex(t=>t.rgb.toLowerCase()===e.toLowerCase());D(t>=0?t:e)},ne=async()=>{let t=W();if(t){C(!0);try{await t.http.user.badge(k()),await t.stores.user.refreshMe(),e.onClose(),e.onSaved?.(),B(`Badge saved`,`success`,3e3)}catch(e){B(`Failed to save badge: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}finally{C(!1)}}},A=t=>{t.target===t.currentTarget&&e.onClose()};return(()=>{var r=Mg(),i=r.firstChild.firstChild,a=i.firstChild.nextSibling,s=i.nextSibling,c=s.firstChild,u=c.firstChild,d=u.firstChild.nextSibling,f=u.nextSibling.firstChild.nextSibling,p=c.nextSibling,x=p.firstChild.nextSibling,C=x.nextSibling,T=C.nextSibling.firstChild,k=T.nextSibling,re=p.nextSibling,ie=re.firstChild,ae=ie.firstChild.nextSibling,oe=ie.nextSibling,j=re.nextSibling.firstChild,se=s.nextSibling.firstChild,ce=se.nextSibling;return r.$$click=A,a.$$click=()=>e.onClose(),R(a,m(ti,{size:18})),R(f,m(l,{each:Bg,children:e=>(()=>{var r=Ng(),i=r.firstChild;return r.$$click=()=>n(e),o(n=>{var a=t()===e?`#1f3a2a`:`#0d1117`,o=`1px solid ${t()===e?`#238636`:`#21262d`}`,s=t()===e?ee():Ig[e];return a!==n.e&&L(r,`background`,n.e=a),o!==n.t&&L(r,`border`,n.t=o),s!==n.a&&F(i,`src`,n.a=s),n},{e:void 0,t:void 0,a:void 0}),r})()})),R(x,m(l,{each:zg,children:({slot:e,label:t})=>(()=>{var n=Pg(),r=n.firstChild;return n.$$click=()=>b(e),R(n,t,null),o(t=>{var i=`1px solid ${y()===e?`#58a6ff`:`#30363d`}`,a=y()===e?`#1c2d47`:`transparent`,o=y()===e?`#58a6ff`:`#8b949e`,s=Lg(E(e));return i!==t.e&&L(n,`border`,t.e=i),a!==t.t&&L(n,`background`,t.t=a),o!==t.a&&L(n,`color`,t.a=o),s!==t.o&&L(r,`background`,t.o=s),t},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()})),R(C,m(l,{each:zt,children:e=>(()=>{var t=Fg();return t.$$click=()=>D(e.index),o(n=>{var r=e.rgb,i=e.rgb,a=O(e.index)?`2px solid #fff`:`1px solid transparent`;return r!==n.e&&F(t,`title`,n.e=r),i!==n.t&&L(t,`background`,n.t=i),a!==n.a&&L(t,`border`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),k.$$input=e=>te(e.currentTarget.value),R(ae,h),oe.$$input=e=>g(+e.currentTarget.value),j.addEventListener(`change`,e=>v(e.currentTarget.checked)),se.$$click=()=>e.onClose(),ce.$$click=ne,R(ce,()=>S()?`Saving…`:`Save Badge`),o(e=>{var t=ee(),n=Vg.test(w())?w():Lg(E(y())),r=`1px solid ${Vg.test(w())?`#30363d`:`#f85149`}`,i=S(),a=S()?`not-allowed`:`pointer`,o=S(),s=S()?`not-allowed`:`pointer`,c=S()?.7:1;return t!==e.e&&F(d,`src`,e.e=t),n!==e.t&&L(T,`background`,e.t=n),r!==e.a&&L(k,`border`,e.a=r),i!==e.o&&(se.disabled=e.o=i),a!==e.i&&L(se,`cursor`,e.i=a),o!==e.n&&(ce.disabled=e.n=o),s!==e.s&&L(ce,`cursor`,e.s=s),c!==e.h&&L(ce,`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}),o(()=>k.value=w()),o(()=>oe.value=h()),o(()=>j.checked=_()),r})()}P([`click`,`input`]);var Ug=N(`<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">`),Wg=N(`<div style=font-size:11px;color:#8b949e;margin-top:3px>`),Gg=N(`<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>`),Kg=N(`<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>`),qg=N(`<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)`),Jg=N(`<img width=40 height=40 style=display:block>`),Yg=N(`<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 0;border-bottom:1px solid #21262d"><div style=display:flex;align-items:center;gap:12px><span style=font-size:13px;color:#c9d1d9></span></div><button style="padding:6px 14px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#c9d1d9;font-size:12px;cursor:pointer;flex-shrink:0">`),Xg=N(`<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">`),Zg=N(`<div style="position:absolute;inset:0px;background:rgba(13, 17, 23, 0.96);z-index:100;display:flex;flex-direction:column;overflow:hidden"><div style="display:flex;align-items:center;justify-content:space-between;padding:14px 24px;border-bottom:1px solid #30363d;flex-shrink:0"><span style=font-size:15px;font-weight:600;color:#c9d1d9>Settings</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 24px"><div style=max-width:480px>`),Qg={type:1,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1};function $g(e){return(()=>{var t=Ug(),n=t.firstChild,r=n.firstChild,i=n.nextSibling,a=i.firstChild;return R(r,()=>e.label),R(n,(()=>{var t=M(()=>!!e.description);return()=>t()&&(()=>{var t=Wg();return R(t,()=>e.description),t})()})(),null),i.$$click=()=>e.onChange(!e.value),o(t=>{var n=e.value?`#238636`:`#30363d`,r=e.value?`22px`:`2px`;return n!==t.e&&L(i,`background`,t.e=n),r!==t.t&&L(a,`left`,t.t=r),t},{e:void 0,t:void 0}),t})()}function e_(e){return(()=>{var t=Gg(),n=t.firstChild;return R(n,()=>e.title),R(t,()=>e.children,null),t})()}function t_(e){return(()=>{var t=Kg(),n=t.firstChild,r=n.nextSibling;return R(n,()=>e.label),R(r,()=>e.value),t})()}function n_(e){let t=Xt(),n=!Sn()&&!G()?.badge,[r,i]=x(n),[a,s]=x(!1),c=d(()=>{let e=G()?.badge;if(!e)return null;let t=Vt(e);return`data:image/svg+xml,${encodeURIComponent(t)}`});async function l(){s(!0);try{await un(),B(`All caches cleared. Reloading…`,`success`,2e3),setTimeout(()=>window.location.reload(),1500)}catch{B(`Failed to clear caches.`,`error`),s(!1)}}return(()=>{var s=Zg(),d=s.firstChild,f=d.firstChild.nextSibling,p=d.nextSibling,h=p.firstChild;return f.$$click=()=>e.onClose(),R(f,m(ti,{size:18})),R(s,m(u,{get when(){return r()},get children(){return m(Hg,{get badge(){return G()?.badge??Qg},onClose:()=>i(!1),onSaved:n?()=>e.onClose():void 0})}}),p),R(h,m(e_,{title:`Layout`,get children(){return m($g,{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 ml()},onChange:hl})}}),null),R(h,m(e_,{title:`Room View`,get children(){return[m($g,{label:`Terrain effects`,description:`Swamp glow and wall noise texture overlay.`,get value(){return Sl()},onChange:Cl}),m($g,{label:`Room decorations`,description:`Load player-activated theme decorations (floor, wall, road colors) from the server.`,get value(){return wl()},onChange:Tl}),m($g,{label:`Dark overlay + lights`,description:`Darken the room and add per-object light glows.`,get value(){return El()},onChange:Dl}),(()=>{var e=qg(),t=e.firstChild.nextSibling;return t.addEventListener(`change`,e=>jl(e.currentTarget.value)),o(()=>t.value=Al()),e})()]}}),null),R(h,m(u,{get when(){return!Sn()},get children(){return m(e_,{title:`Player Badge`,get children(){var e=Yg(),t=e.firstChild,n=t.firstChild,r=t.nextSibling;return R(t,m(u,{get when(){return c()},get children(){var e=Jg();return o(()=>F(e,`src`,c())),e}}),n),R(n,()=>G()?.username??``),r.$$click=()=>i(!0),R(r,()=>c()?`Edit Badge`:`Create Badge`),e}})}}),null),R(h,m(e_,{title:`Data`,get children(){var e=Xg(),t=e.firstChild;t.firstChild.nextSibling;var n=t.nextSibling;return n.$$click=l,R(n,()=>a()?`Clearing…`:`Clear`),o(e=>{var t=a(),r=a()?`#8b949e`:`#f85149`,i=a()?`default`:`pointer`,o=a()?.6:1;return t!==e.e&&(n.disabled=e.e=t),r!==e.t&&L(n,`color`,e.t=r),i!==e.a&&L(n,`cursor`,e.a=i),o!==e.o&&L(n,`opacity`,e.o=o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e}}),null),R(h,m(e_,{title:`About`,get children(){return[m(t_,{label:`Client version`,get value(){return Yt()}}),M(()=>t&&m(t_,{label:`Mod version`,get value(){return`${t.version} (${t.kind})`}}))]}}),null),s})()}P([`click`]);var r_=N(`<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">`),i_=15e3;function a_(e){let t,n=()=>{t!==void 0&&(clearTimeout(t),t=void 0)},r=()=>{n(),t=setTimeout(()=>e.onClose(),i_)};return a(r),y(n),(()=>{var t=r_(),i=t.firstChild,a=i.nextSibling;return t.addEventListener(`mouseleave`,r),t.addEventListener(`mouseenter`,n),i.$$click=()=>e.onClose(),R(i,m(ti,{size:16})),o(()=>a.innerHTML=e.text),t})()}P([`click`]);var o_=N(`<img width=20 height=20 style=display:block;border-radius:3px>`),s_=N(`<span>Settings`),c_=N(`<span>`),l_=N(`<span>Respawn`),u_=N(`<span>Logout`),d_=N(`<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">`),f_=N(`<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">`),p_=N(`<div style=font-size:12px;color:#f85149;margin-bottom:12px>`),m_=N(`<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">`),h_=N(`<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>`),g_=N(`<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">`),__=N(`<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 v_(e){let[t,n]=x(!1),[r,i]=x(!1),[a,s]=x(!1),[c,l]=x(!1),[p,h]=x(``),[g,_]=x(``),[v,b]=x(``),[S,C]=x(!1),w=()=>wn()===`password`||wn()===`steam`,T=()=>G()?.password===!0,E=d(()=>T()&&p().length===0?`Enter your current password.`:g().length<8?`New password must be at least 8 characters.`:g()===v()?null:`Passwords don't match.`),D,O=d(()=>{let e=G()?.badge;return e?`data:image/svg+xml,${encodeURIComponent(Vt(e))}`:null});f(()=>{if(!t())return;let e=e=>{D&&!D.contains(e.target)&&n(!1)},r=e=>{e.key===`Escape`&&n(!1)};document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,r),y(()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,r)})});function k(){let e=W();e&&(s(!0),e.http.user.respawn().then(()=>{B(`Respawn successful`,`success`),zn()}).catch(e=>B(`Respawn failed: ${e.message}`,`error`)).finally(()=>{s(!1),i(!1)}))}function ee(){h(``),_(``),b(``),l(!0)}function te(){let e=W();if(!e||E())return;let t=!T();C(!0),e.http.user.password(g(),p()).then(()=>{B(t?`Password set`:`Password changed`,`success`),l(!1),t&&e.stores.user.refreshMe()}).catch(e=>B(`Password ${t?`setup`:`change`} failed: ${e.message}`,`error`)).finally(()=>C(!1))}return(()=>{var s=h_(),d=s.firstChild,f=d.firstChild;return we(e=>D=e,s),d.$$click=()=>n(e=>!e),R(d,m(u,{get when(){return O()},get children(){var e=o_();return o(()=>F(e,`src`,O())),e}}),f),R(f,()=>G()?.username??`…`),R(d,m(lr,{size:14}),null),R(s,m(u,{get when(){return t()},get children(){var t=d_();return R(t,m(b_,{onClick:()=>{n(!1),e.onOpenSettings()},get children(){return[m(Yr,{size:15}),s_()]}}),null),R(t,m(u,{get when(){return w()},get children(){return m(b_,{onClick:()=>{n(!1),ee()},get children(){return[m(Tr,{size:15}),(()=>{var e=c_();return R(e,()=>T()?`Change password`:`Set password`),e})()]}})}}),null),R(t,m(b_,{onClick:()=>{n(!1),i(!0)},get children(){return[m(qr,{size:15}),l_()]}}),null),R(t,m(b_,{onClick:()=>{n(!1),Yn()},danger:!0,get children(){return[m(Nr,{size:15}),u_()]}}),null),t}}),null),R(s,m(u,{get when(){return r()},get children(){var e=f_(),t=e.firstChild.firstChild.nextSibling.nextSibling;t.firstChild;var n=t.nextSibling.firstChild,r=n.nextSibling;return e.$$click=e=>{e.target===e.currentTarget&&!a()&&i(!1)},n.$$click=()=>i(!1),r.$$click=k,R(r,()=>a()?`Respawning…`:`Respawn`),o(e=>{var t=a(),i=a()?`default`:`pointer`,o=a(),s=a()?`default`:`pointer`,c=a()?.6:1;return t!==e.e&&(n.disabled=e.e=t),i!==e.t&&L(n,`cursor`,e.t=i),o!==e.a&&(r.disabled=e.a=o),s!==e.o&&L(r,`cursor`,e.o=s),c!==e.i&&L(r,`opacity`,e.i=c),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),R(s,m(u,{get when(){return c()},get children(){var e=m_(),t=e.firstChild,n=t.firstChild,r=n.nextSibling,i=r.firstChild,a=i.nextSibling;return e.$$click=e=>{e.target===e.currentTarget&&!S()&&l(!1)},t.addEventListener(`submit`,e=>{e.preventDefault(),te()}),R(n,()=>T()?`Change password`:`Set password`),R(t,m(u,{get when(){return T()},get children(){return m(y_,{label:`Current password`,get value(){return p()},onInput:h,autofocus:!0})}}),r),R(t,m(y_,{label:`New password`,get value(){return g()},onInput:_,get autofocus(){return!T()}}),r),R(t,m(y_,{label:`Confirm new password`,get value(){return v()},onInput:b}),r),R(t,m(u,{get when(){return M(()=>!!E())()&&(g()||v())},get children(){var e=p_();return R(e,E),e}}),r),i.$$click=()=>l(!1),R(a,()=>S()?`Saving…`:`Save`),o(e=>{var t=S(),n=S()?`default`:`pointer`,r=S()||E()!=null,o=S()||E()!=null?`default`:`pointer`,s=S()||E()!=null?.6:1;return t!==e.e&&(i.disabled=e.e=t),n!==e.t&&L(i,`cursor`,e.t=n),r!==e.a&&(a.disabled=e.a=r),o!==e.o&&L(a,`cursor`,e.o=o),s!==e.i&&L(a,`opacity`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),o(e=>L(d,`background`,t()?`#21262d`:`#161b22`)),s})()}function y_(e){return(()=>{var t=g_(),n=t.firstChild,r=n.nextSibling;return R(n,()=>e.label),r.$$input=t=>e.onInput(t.currentTarget.value),o(()=>r.autofocus=e.autofocus),o(()=>r.value=e.value),t})()}function b_(e){let[t,n]=x(!1);return(()=>{var r=__();return r.addEventListener(`mouseleave`,()=>n(!1)),r.addEventListener(`mouseenter`,()=>n(!0)),r.$$click=()=>e.onClick(),R(r,()=>e.children),o(n=>{var i=t()?`#21262d`:`transparent`,a=e.danger?`#f85149`:`#c9d1d9`;return i!==n.e&&L(r,`background`,n.e=i),a!==n.t&&L(r,`color`,n.t=a),n},{e:void 0,t:void 0}),r})()}P([`click`,`input`]);var x_=N(`<button style="padding:7px;border-radius:4px;cursor:pointer;margin:0 4px;display:flex;align-items:center">`),S_=N(`<button style="padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;margin:0 2px;display:flex;align-items:center">`),C_=N(`<div style=flex:1;position:relative;overflow:hidden>`),w_=N(`<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>`),T_=N(`<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>`),E_=N(`<div style=display:flex;flex:1;overflow:hidden><div style=display:flex;flex-direction:column;flex:1;overflow:hidden>`),D_=N(`<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>`),O_=N(`<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">`),k_=N(`<div style=display:flex;flex-direction:column;flex:1;overflow:hidden><div style=display:flex;flex:1;overflow:hidden>`),A_=b(()=>O(()=>import(`./CodePanel-Bu4s43Y2.js`).then(e=>({default:e.CodePanel})),__vite__mapDeps([2,3]),import.meta.url)),j_=b(()=>O(()=>import(`./MapViewer-F52NQQmA.js`).then(e=>({default:e.MapViewer})),__vite__mapDeps([4,3]),import.meta.url));function M_(){let e=Zt(),t=window.location.pathname.match(RegExp(`^${e}/room/([A-Za-z0-9]+)`));if(!t)return{room:null,shard:null,tick:null};let n=t[1].toUpperCase();if(!Lu(n))return{room:null,shard:null,tick:null};let r=new URLSearchParams(window.location.search).get(`shard`),i=window.location.hash.match(/tick=(\d+)/);return{room:n,shard:r,tick:i?parseInt(i[1],10):null}}function N_(e,t){return`${Zt()}/room/${e}${t?`?shard=${encodeURIComponent(t)}`:``}`}function P_(e){return`${Zt()}/map${e?`?shard=${encodeURIComponent(e)}`:``}`}function F_(){return window.location.pathname.startsWith(`${Zt()}/map`)?{shard:new URLSearchParams(window.location.search).get(`shard`)}:null}function I_(e){return(()=>{var t=x_();return t.$$click=()=>e.onClick(),R(t,()=>e.children),o(n=>{var r=e.title,i=`1px solid ${e.active?`#388bfd`:`#30363d`}`,a=e.active?`#1f3158`:`#21262d`,o=e.active?`#58a6ff`:`#c9d1d9`;return r!==n.e&&F(t,`title`,n.e=r),i!==n.t&&L(t,`border`,n.t=i),a!==n.a&&L(t,`background`,n.a=a),o!==n.o&&L(t,`color`,n.o=o),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t})()}function L_(e){return(()=>{var t=S_();return t.$$click=()=>e.onClick(),R(t,()=>e.children),o(n=>{var r=e.title,i=e.disabled,a=e.disabled?`#484f58`:`#c9d1d9`,o=e.disabled?`default`:`pointer`;return r!==n.e&&F(t,`title`,n.e=r),i!==n.t&&(t.disabled=n.t=i),a!==n.a&&L(t,`color`,n.a=a),o!==n.o&&L(t,`cursor`,n.o=o),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t})()}function R_(){let e=M_(),[t,n]=x(e.room??$t(V.room)??`W1N1`),[i,s]=x(e.shard??$t(V.shard)),[c,l]=x(F_()!==null||!e.room),d=()=>_n()?.serverData?.welcomeText??null,[p,h]=x(!1),g=()=>Sn()&&c()&&!p()&&d()!==null,[_,v]=x(!Sn()&&!G()?.badge),[b,S]=x(!1),[C,w]=x(!1);f(()=>{b(),w(!0),Promise.resolve().then(()=>w(!1))}),f(()=>{Sn()&&Td(`view`)}),f(()=>{if(i()!==null||Kn()!==!1)return;let e=_n()?.serverData?.shards?.[0];e&&s(e)});let[T,E]=x(void 0),[D,O]=x(null),[k,ee]=x(null),te=$t(V.mapZoom),[ne,A]=x(e.room&&te?Number(te):null),[re,ie]=x(null),[ae,oe]=x(!1),[j,se]=x(!1),ce=e.tick;f(()=>{let e=K();if(e===null||ce===null)return;let t=ce;ce=null,od(e),cd(t)}),f(()=>{if(r(c))return;let e=N_(t(),i());Q()?history.replaceState(null,``,`${e}#tick=${Gu()}`):history.replaceState(null,``,e)});let[le,ue]=x(nn(V.sidebarWidth,300)),[de,fe]=x(nn(V.sidebarWidth,300)),[pe,me]=x(nn(V.consoleHeight,220)),[he,ge]=x(nn(V.consoleHeight,220)),[_e,N]=x(!1),[P,F]=x(!1),ve=()=>le()<=32,ye=()=>pe()<=32,be=()=>{le()>32?(fe(le()),ue(32)):ue(de())},Se=()=>{pe()>32?(ge(pe()),me(32)):me(he())},I=e=>{e.preventDefault(),N(!0);let t=e.clientX,n=le(),r=e=>{let r=e.clientX-t;ue(Math.max(32,Math.min(500,n-r)))},i=()=>{N(!1),rn(V.sidebarWidth,le()),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},Ce=e=>{e.preventDefault(),F(!0);let t=e.clientY,n=pe(),r=e=>{let r=e.clientY-t;me(Math.max(32,Math.min(500,n-r)))},i=()=>{F(!1),rn(V.consoleHeight,pe()),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},we=(e,t)=>{W()?.stores.navigation.navigateTo(e,t)},Te=e=>{E(e),l(!0),history.pushState(null,``,P_(i()))},Ee=()=>{c()?(l(!1),O(null),ee(null),history.pushState(null,``,N_(t(),i()))):Te(t())};a(()=>{!M_().room&&!F_()&&history.replaceState(null,``,P_(i()));let e=()=>{let e=F_();if(e){l(!0),e.shard!==null&&s(e.shard),r(Q)&&sd();return}let{room:t,shard:i,tick:a}=M_();t&&(n(t),s(i),l(!1),a===null?r(Q)&&sd():ce=a)};window.addEventListener(`popstate`,e),y(()=>window.removeEventListener(`popstate`,e));let a=W()?.stores.navigation;if(a){let e=a.on(`navigation:change`,e=>{e.room!==null&&(n(e.room),s(e.shard),l(!1),O(null),ee(null),oe(a.canBack()),se(a.canForward()),en(V.room,e.room),e.shard?en(V.shard,e.shard):tn(V.shard),history.pushState(null,``,N_(e.room,e.shard)))});y(()=>e.dispose())}let o=e=>{if(!Hu(e.target)){if(e.key===`o`||e.key===`O`){S(e=>!e),v(!1);return}(e.key===`l`||e.key===`L`)&&uf(),(e.key===`c`||e.key===`C`)&&df(),(e.key===`y`||e.key===`Y`)&&ff(),c()||(e.key===`1`&&Td(`view`),Sn()||(e.key===`2`&&Td(`flag`),e.key===`3`&&Td(`build`)),e.key===`m`&&Te(t()))}};window.addEventListener(`keydown`,o),y(()=>window.removeEventListener(`keydown`,o))});let De=()=>(()=>{var e=C_();return R(e,m(u,{get when(){return _()},get children(){return m(n_,{onClose:()=>v(!1)})}}),null),R(e,m(u,{get when(){return b()},get children(){return m(A_,{onClose:()=>S(!1)})}}),null),R(e,m(u,{get when(){return!c()},get fallback(){return m(j_,{get shard(){return i()},get originRoom(){return T()},get initialZoom(){return ne()??void 0},onNavigateToRoom:e=>we(e,i()),onHoveredRoomChanged:O,onSelectedRoomChanged:ee,onZoomChanged:e=>{A(e),rn(V.mapZoom,e)},onSubscriptionStateChanged:ie})},get children(){return m(Jd,{get room(){return t()},get shard(){return i()},onNavigate:we})}}),null),R(e,m(u,{get when(){return g()},get children(){return m(a_,{get text(){return d()},onClose:()=>h(!0)})}}),null),e})(),Oe=()=>m(u,{get when(){return!Sn()},get children(){var e=w_(),t=e.firstChild;return t.$$pointerdown=Ce,R(e,m(ip,{get shard(){return i()},get isCollapsed(){return ye()},onToggle:Se}),null),o(t=>{var n=`${pe()}px`,r=P()?`none`:`height 0.15s ease`;return n!==t.e&&L(e,`height`,t.e=n),r!==t.t&&L(e,`transition`,t.t=r),t},{e:void 0,t:void 0}),e}}),ke=e=>(()=>{var n=T_(),r=n.firstChild;return r.$$pointerdown=I,R(n,m(Tg,{get isCollapsed(){return ve()},onToggle:be,get mapMode(){return c()},get hoveredRoomInfo(){return D()},get selectedRoomInfo(){return k()},get room(){return t()},get shard(){return i()},get mapZoom(){return ne()},get mapSubsActive(){return re()}}),null),o(t=>{var r=b()?`0`:`${le()}px`,i=e&&!(C()||_e())?`width 0.15s ease`:`none`;return r!==t.e&&L(n,`width`,t.e=r),i!==t.t&&L(n,`transition`,t.t=i),t},{e:void 0,t:void 0}),n})();return(()=>{var e=D_(),t=e.firstChild,n=t.firstChild;return R(t,m(Ri,{}),n),R(t,m(u,{get when(){return!Sn()||c()},get children(){return m(jg,{get mapZoom(){return M(()=>!!c())()?ne():null},get mapSubsActive(){return M(()=>!!c())()?re():null}})}}),n),R(t,m(L_,{title:`Back`,get disabled(){return!ae()},onClick:()=>W()?.stores.navigation.back(),get children(){return m(pr,{size:16})}}),null),R(t,m(L_,{title:`Forward`,get disabled(){return!j()},onClick:()=>W()?.stores.navigation.forward(),get children(){return m(dr,{size:16})}}),null),R(t,m(I_,{get title(){return c()?`Room View`:`Map`},get active(){return c()},onClick:Ee,get children(){return M(()=>!!c())()?m(Dr,{size:16}):m(Fr,{size:16})}}),null),R(t,m(u,{get when(){return!Sn()},get children(){return m(I_,{title:`Code Editor`,get active(){return b()},onClick:()=>{S(e=>!e),v(!1)},get children(){return m(_r,{size:16})}})}}),null),R(t,m(u,{get when(){return!Sn()},get fallback(){return[m(I_,{title:`Settings`,get active(){return _()},onClick:()=>{v(e=>!e),S(!1)},get children(){return m(Yr,{size:16})}}),(()=>{var e=O_();return xe(e,`click`,Yn,!0),R(e,m(jr,{size:16})),e})()]},get children(){return m(v_,{onOpenSettings:()=>{v(!0),S(!1)}})}}),null),R(e,m(u,{get when(){return ml()},get fallback(){return(()=>{var e=k_(),t=e.firstChild;return R(t,De,null),R(t,()=>ke(!0),null),R(e,Oe,null),e})()},get children(){var e=E_(),t=e.firstChild;return R(t,De,null),R(t,Oe,null),R(e,()=>ke(!1),null),e}}),null),R(e,m(Zd,{}),null),e})()}P([`click`,`pointerdown`]);var z_=N(`<div style=width:100%;height:100%>`),{log:B_}=Qt(`app`);function V_(){let e=new URLSearchParams(window.location.search).get(`guest`);return e===null?null:e.startsWith(`http`)?e:sn(H.url)??`https://screeps.com`}function H_(){if(qt()||V_()!==null)return!0;let e=Kt()?Jt():sn(H.url),t=sn(H.token);return!!(e&&t)}function U_(){let e=()=>fn()===`connected`&&W()!==null,[t,n]=x(H_());return a(async()=>{try{if(fn()===`idle`&&(await Jn().catch(()=>{}),fn()!==`connected`)){if(qt()){let e=Jt();B_(`xxscreeps mode — auto-connecting as guest to ${e}`),await qn({url:e,auth:`guest`,storage:null}).catch(()=>{})}else if(!Kt()){let e=V_();e&&(B_(`?guest param — auto-connecting as guest to ${e}`),await qn({url:e,auth:`guest`,storage:null}).catch(()=>{}))}}}finally{n(!1)}}),(()=>{var n=z_();return R(n,(()=>{var n=M(()=>!!e());return()=>n()?m(R_,{}):M(()=>!!t())()?m(Fi,{}):m(Ni,{})})()),n})()}var W_=document.getElementById(`root`);if(!W_)throw Error(`Root element not found`);_e(()=>m(U_,{}),W_);export{we as S,B as _,Bu as a,L as b,Lu as c,bl as d,W as f,Qt as g,En as h,Ru as i,vl as l,G as m,Im as n,Vu as o,Dn as p,Uu as r,Iu as s,Ch as t,Ml as u,P as v,N as x,R as y};
|