screeps-client 0.11.0 → 0.12.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.
Files changed (22) hide show
  1. package/dist/embedded/_client/{CodePanel-Bd6QSYMn.js → CodePanel-D5ETgtFO.js} +1 -1
  2. package/dist/{standalone/_client/MapViewer-prnyDfOQ.js → embedded/_client/MapViewer-DFQ7jJZw.js} +1 -1
  3. package/dist/embedded/_client/index-EZziD5mv.js +19 -0
  4. package/dist/embedded/_client/vendor-codemirror-B6f_i0wP.js +34 -0
  5. package/dist/embedded/index.html +2 -2
  6. package/dist/standalone/_client/{CodePanel-DbJqelUg.js → CodePanel-DzUWmwLB.js} +1 -1
  7. package/dist/{embedded/_client/MapViewer-Dfluj-CU.js → standalone/_client/MapViewer-yzB_3QH9.js} +1 -1
  8. package/dist/standalone/_client/index-D88gazCV.js +19 -0
  9. package/dist/standalone/_client/vendor-codemirror-B6f_i0wP.js +34 -0
  10. package/dist/standalone/index.html +2 -2
  11. package/dist/xxscreeps-mod/_client/{CodePanel-DtNhdpy3.js → CodePanel-CcplJf29.js} +1 -1
  12. package/dist/xxscreeps-mod/_client/{MapViewer-C2ReOrlB.js → MapViewer-PPsdyxO4.js} +1 -1
  13. package/dist/xxscreeps-mod/_client/index-CPAabLyi.js +19 -0
  14. package/dist/xxscreeps-mod/_client/vendor-codemirror-B6f_i0wP.js +34 -0
  15. package/dist/xxscreeps-mod/index.html +2 -2
  16. package/package.json +1 -1
  17. package/dist/embedded/_client/index-RyMzFHC0.js +0 -19
  18. package/dist/embedded/_client/vendor-codemirror-_J5SxhJL.js +0 -34
  19. package/dist/standalone/_client/index-yH_pBmNP.js +0 -19
  20. package/dist/standalone/_client/vendor-codemirror-_J5SxhJL.js +0 -34
  21. package/dist/xxscreeps-mod/_client/index-D--0q0A1.js +0 -19
  22. package/dist/xxscreeps-mod/_client/vendor-codemirror-_J5SxhJL.js +0 -34
@@ -0,0 +1,19 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_client/decompress-DIM550rx.js","_client/rolldown-runtime-QTnfLwEv.js","_client/CodePanel-D5ETgtFO.js","_client/vendor-codemirror-B6f_i0wP.js","_client/MapViewer-DFQ7jJZw.js"])))=>i.map(i=>d[i]);
2
+ import{A as e,C as t,D as n,E as r,O as i,S as a,T as o,_ as s,b as c,c as l,d as u,f as d,g as f,h as p,j as m,k as h,l as g,m as _,p as v,s as y,u as b,v as x,w as S,x as C,y as w}from"./vendor-codemirror-B6f_i0wP.js";import{n as T,t as E}from"./decompress-DIM550rx.js";import{_ as D,a as O,c as ee,d as k,f as A,g as te,h as ne,i as re,l as ie,m as j,n as ae,o as oe,p as M,r as se,s as ce,t as le,u as ue}from"./vendor-pixi-D8ed7Ewt.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 de=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(`.`)]),fe=new Set([`innerHTML`,`textContent`,`innerText`,`children`]),pe=Object.assign(Object.create(null),{className:`class`,htmlFor:`for`}),me=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 he(e,t){let n=me[e];return typeof n==`object`?n[t]?n.$:void 0:n}var ge=new Set([`beforeinput`,`click`,`dblclick`,`contextmenu`,`focusin`,`focusout`,`input`,`keydown`,`keyup`,`mousedown`,`mousemove`,`mouseout`,`mouseover`,`mouseup`,`pointerdown`,`pointermove`,`pointerout`,`pointerover`,`pointerup`,`touchend`,`touchmove`,`touchstart`]),_e=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(`.`)),ve={xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`},N=e=>x(()=>e());function ye(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 be=`_$DX_DELEGATE`;function xe(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 C(r=>{i=r,t===document?e():z(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{i(),t.textContent=``}}function P(e,t,n,r){let i,a=()=>{if(je())throw Error(`Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.`);let t=r?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`template`):document.createElement(`template`);return t.innerHTML=e,n?t.content.firstChild.firstChild:r?t.firstChild:t.content.firstChild},o=t?()=>m(()=>document.importNode(i||=a(),!0)):()=>(i||=a()).cloneNode(!0);return o.cloneNode=o,o}function F(e,t=window.document){let n=t[be]||(t[be]=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,Fe))}}function I(e,t,n){je(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function Se(e,t,n,r){je(e)||(r==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r))}function Ce(e,t,n){je(e)||(n?e.setAttribute(t,``):e.removeAttribute(t))}function we(e,t){je(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function Te(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 Ee(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]||(Ne(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||(Ne(e,i,!0),n[i]=o)}return n}function L(e,t,n){if(!t)return n?I(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 R(e,t,n){n==null?e.style.removeProperty(t):e.style.setProperty(t,n)}function De(e,t={},n,r){let i={};return r||w(()=>i.children=Ie(e,t.children,i.children)),w(()=>typeof t.ref==`function`&&Oe(t.ref,e)),w(()=>ke(e,t,n,!0,i,!0)),i}function Oe(e,t,n){return m(()=>e(t,n))}function z(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return Ie(e,t,r,n);w(r=>Ie(e,t(),r,n),r)}function ke(e,t,n,r,i={},a=!1){t||={};for(let r in i)if(!(r in t)){if(r===`children`)continue;i[r]=Pe(e,r,null,i[r],n,a,t)}for(let o in t){if(o===`children`){r||Ie(e,t.children);continue}let s=t[o];i[o]=Pe(e,o,s,i[o],n,a,t)}}function Ae(e){let t,n,r=je();if(!r||!(t=h.registry.get(n=Be()))){if(r)throw h.done=!0,Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${n}\n${e?e().outerHTML:``}`);return e()}return h.completed&&h.completed.add(t),h.registry.delete(n),t}function je(e){return!!h.context&&!h.done&&(!e||e.isConnected)}function Me(e){return e.toLowerCase().replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Ne(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 Pe(e,t,n,r,i,a,o){let s,c,l,u,d;if(t===`style`)return L(e,n,r);if(t===`classList`)return Ee(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=ge.has(i);if(!a&&r){let t=Array.isArray(r)?r[0]:r;e.removeEventListener(i,t)}(a||n)&&(Te(e,i,n,a),a&&F([i]))}else if(t.slice(0,5)===`attr:`)I(e,t.slice(5),n);else if(t.slice(0,5)===`bool:`)Ce(e,t.slice(5),n);else if((d=t.slice(0,5)===`prop:`)||(l=fe.has(t))||!i&&((u=he(t,e.tagName))||(c=de.has(t)))||(s=e.nodeName.includes(`-`)||`is`in o)){if(d)t=t.slice(5),c=!0;else if(je(e))return n;t===`class`||t===`className`?we(e,n):s&&!c&&!l?e[Me(t)]=n:e[u||t]=n}else{let r=i&&t.indexOf(`:`)>-1&&ve[t.split(`:`)[0]];r?Se(e,r,t,n):I(e,pe[t]||t,n)}return n}function Fe(e){if(h.registry&&h.events&&h.events.find(([t,n])=>n===e))return;let t=e.target,n=`$$${e.type}`,r=e.target,i=e.currentTarget,a=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),o=()=>{let r=t[n];if(r&&!t.disabled){let i=t[`${n}Data`];if(i===void 0?r.call(t,e):r.call(t,i,e),e.cancelBubble)return}return t.host&&typeof t.host!=`string`&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},s=()=>{for(;o()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),h.registry&&!h.done&&(h.done=_$HY.done=!0),e.composedPath){let n=e.composedPath();a(n[0]);for(let e=0;e<n.length-2&&(t=n[e],o());e++){if(t._$host){t=t._$host,s();break}if(t.parentNode===i)break}}else s();a(r)}function Ie(e,t,n,r,i){let a=je(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 o=typeof t,s=r!==void 0;if(e=s&&n[0]&&n[0].parentNode||e,o===`string`||o===`number`){if(a||o===`number`&&(t=t.toString(),t===n))return n;if(s){let i=n[0];i&&i.nodeType===3?i.data!==t&&(i.data=t):i=document.createTextNode(t),n=ze(e,n,r,i)}else n=n!==``&&typeof n==`string`?e.firstChild.data=t:e.textContent=t}else if(t==null||o===`boolean`){if(a)return n;n=ze(e,n,r)}else if(o===`function`)return w(()=>{let i=t();for(;typeof i==`function`;)i=i();n=Ie(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let o=[],c=n&&Array.isArray(n);if(Le(o,t,n,i))return w(()=>n=Ie(e,o,n,r,!0)),()=>n;if(a){if(!o.length)return n;if(r===void 0)return n=[...e.childNodes];let t=o[0];if(t.parentNode!==e)return n;let i=[t];for(;(t=t.nextSibling)!==r;)i.push(t);return n=i}if(o.length===0){if(n=ze(e,n,r),s)return n}else c?n.length===0?Re(e,o,r):ye(e,n,o):(n&&ze(e),Re(e,o));n=o}else if(t.nodeType){if(a&&t.parentNode)return n=s?[t]:t;if(Array.isArray(n)){if(s)return n=ze(e,n,r,t);ze(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 Le(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=Le(e,o,s)||i;else if(c===`function`)if(r){for(;typeof o==`function`;)o=o();i=Le(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 Re(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function ze(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 Be(){return h.getNextContextId()}var Ve=`http://www.w3.org/2000/svg`;function He(e,t=!1,n=void 0){return t?document.createElementNS(Ve,e):document.createElement(e,{is:n})}function Ue(e,t){let n=x(e);return x(()=>{let e=n();switch(typeof e){case`function`:return Object.assign(e,{[y]:!0}),m(()=>e(t));case`string`:let n=_e.has(e),r=h.context?Ae():He(e,n,m(()=>t.is));return De(r,t,n),r}})}function We(t){let[,n]=e(t,[`component`]);return Ue(()=>t.component,n)}var Ge=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 Ke(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 qe(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 Je(e,t){return t&&(e.shard=t),e}function Ye(e,t){return{roomTerrain:(t,n)=>e.request(`GET`,`/api/game/room-terrain`,Je({room:t,encoded:1},n)),roomObjects:(t,n)=>e.request(`GET`,`/api/game/room-objects`,Je({room:t},n)),roomDecorations:t?()=>Promise.resolve(t):(t,n)=>e.request(`GET`,`/api/game/room-decorations`,Je({room:t},n)),roomStatus:(t,n)=>e.request(`GET`,`/api/game/room-status`,Je({room:t},n)),roomOverview:(t,n=8,r)=>e.request(`GET`,`/api/game/room-overview`,Je({room:t,interval:n},r)),time:t=>e.request(`GET`,`/api/game/time`,Je({},t)),worldSize:t=>e.request(`GET`,`/api/game/world-size`,Je({},t)),mapStats:(t,n,r)=>e.request(`POST`,`/api/game/map-stats`,Je({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`,Je({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`,Je({type:t},n)),checkUniqueObjectName:(t,n,r)=>e.request(`POST`,`/api/game/check-unique-object-name`,Je({type:t,name:n},r)),placeSpawn:(t,n,r,i,a)=>e.request(`POST`,`/api/game/place-spawn`,Je({room:t,x:n,y:r,...i?{name:i}:{}},a)),createConstruction:(t,n,r,i,a,o)=>e.request(`POST`,`/api/game/create-construction`,Je({room:t,x:n,y:r,structureType:i,...a?{name:a}:{}},o)),removeConstructionSite:(t,n,r)=>e.request(`POST`,`/api/game/add-object-intent`,Je({_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`,Je({_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:qe(e),market:{ordersIndex:t=>e.request(`GET`,`/api/game/market/orders-index`,Je({},t)),myOrders:()=>e.request(`GET`,`/api/game/market/my-orders`),orders:(t,n)=>e.request(`GET`,`/api/game/market/orders`,Je({resourceType:t},n)),stats:(t,n)=>e.request(`GET`,`/api/game/market/stats`,Je({resourceType:t},n))},shards:{info:()=>e.request(`GET`,`/api/game/shards/info`)}}}function Xe(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 Ze(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`,Ze({path:t},n)),set:(t,n,r)=>e.request(`POST`,`/api/user/memory`,Ze({path:t,value:n},r)),segment:{get:(t,n)=>e.request(`GET`,`/api/user/memory-segment`,Ze({segment:t},n)),set:(t,n,r)=>e.request(`POST`,`/api/user/memory-segment`,Ze({segment:t,data:n},r))}},console:(t,n)=>e.request(`POST`,`/api/user/console`,Ze({expression:t},n)),stats:t=>e.request(`GET`,`/api/user/stats`,{interval:t}),rooms:t=>e.request(`GET`,`/api/user/rooms`,{id:t},{silent:!0}),overview:(t,n)=>e.request(`GET`,`/api/user/overview`,{interval:t,statName:n},{silent:!0}),worldStatus:()=>e.request(`GET`,`/api/user/world-status`),worldStartRoom:t=>e.request(`GET`,`/api/user/world-start-room`,Ze({},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:Xe(e)}}function $e(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 et(e){return{pvp:(t=100)=>e.request(`GET`,`/api/experimental/pvp`,{interval:t}),nukes:()=>e.request(`GET`,`/api/experimental/nukes`)}}function tt(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 nt=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??Ge.create(),this.serverPassword=e.serverPassword??null,this.auth=Ke(this),this.register=tt(this),this.game=Ye(this,e.decorationsMock),this.user=Qe(this),this.leaderboard=$e(this),this.experimental=et(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={}){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.isRetry&&!this.authenticating)return await this.authenticate(),this.request(e,t,n,{...r,isRetry:!0});if(!s.ok&&s.status!==304){let n=``;try{n=await s.text()}catch{}let i=Error(`HTTP ${s.status}: ${n}`);throw this.emit(`http:error`,{method:e,path:t,status:s.status,error:i,silent:r.silent}),i}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,silent:r.silent}),n}return typeof l.data==`string`&&l.data.startsWith(`gz:`)&&(l.data=await E(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 rt(e){let t=typeof e==`string`?e:e.data;if(t.startsWith(`gz:`)&&(t=JSON.stringify(await T(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 it=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??Ge.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 rt(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`))}},at=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()}},ot=class extends EventTarget{logger;constructor(e){super(),this.logger=e??Ge.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)}}}},st=function(e){return e[e.Plain=0]=`Plain`,e[e.Wall=1]=`Wall`,e[e.Swamp=2]=`Swamp`,e}({}),ct=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 lt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ut(e,t){let n={...e};for(let e in t){let r=t[e];r===null?delete n[e]:lt(r)&&lt(n[e])?n[e]=ut(n[e],r):n[e]=r}return n}var dt=class extends ot{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 ct(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=ct.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 ct(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=ct.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]=ut(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()))}}}},ft=class extends ot{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 D(async()=>{let{decompressZlib:e}=await import(`./decompress-DIM550rx.js`).then(e=>e.r);return{decompressZlib:e}},__vite__mapDeps([0,1])),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()}}}},pt=class extends ot{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`}`)}},mt=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 ht(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 gt=class extends ot{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?ht(o):null};s.listenerSub=this.socket.on(i,n=>{let r=n,i=ht(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)}},_t=class extends ot{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}}},vt=class extends ot{_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]}}},yt=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=Ge.create(e.debug),this.logger.log(`[screeps:client] init ${e.url}`),this.cache=new at(t,e.storage??null),this.http=new nt({url:e.url,auth:e.auth,logger:this.logger.child(`http`),serverPassword:e.serverPassword,decorationsMock:e.decorationsMock}),this.socket=new it({url:e.url,WebSocket:e.WebSocket,logger:this.logger.child(`socket`)});let n=new mt({adapter:e.storage??null,namespace:t,maxEntries:e.map2?.maxCacheEntries??1e4});this.stores={room:new dt(this.http,this.socket,this.cache,this.logger.child(`room`)),user:new ft(this.http,this.socket,this.cache,this.logger.child(`user`)),server:new pt(this.http,this.socket,this.cache,this.logger.child(`server`)),map:new gt(this.socket,n,{maxSubscriptions:e.map2?.maxSubscriptions??500},this.logger.child(`map`)),mapStats:new _t(this.http,100,500,this.logger.child(`mapStats`)),navigation:new vt(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()}},bt=class{token;constructor(e){this.token=e.token}async authenticate(e){return this.token}},xt=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}},St=class{async authenticate(e){return`guest`}},Ct=1,wt=`data`,Tt=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,Ct);n.onupgradeneeded=()=>{n.result.createObjectStore(wt)},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(wt,`readonly`).objectStore(wt).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(wt,`readwrite`).objectStore(wt).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(wt,`readwrite`).objectStore(wt).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(wt,`readwrite`).objectStore(wt).clear();r.onsuccess=()=>t(),r.onerror=()=>n(r.error)})}},Et=class{subs=[];add(e){this.subs.push(e)}dispose(){for(let e of this.subs)e.dispose();this.subs.length=0}},Dt=5*6e4;function Ot(e,t){try{return`screeps:${e}:${new URL(t).hostname}`}catch{return`screeps:${e}:${t}`}}function kt(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 At(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(e,JSON.stringify({data:t,expires:Date.now()+Dt}))}catch{}}function jt(e){return e.endsWith(`/`)?e:`${e}/`}async function Mt(e){let t=Ot(`version`,e),n=kt(t);if(n)return n;let r=await fetch(`${jt(e)}api/version`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();return At(t,i),i}async function Nt(e){let t=Ot(`authmod`,e),n=kt(t);if(n)return n;let r=await fetch(`${jt(e)}api/authmod`);if(!r.ok)return null;let i=await r.json();return i.ok?(At(t,i),i):null}async function Pt(e,t){let n=new URLSearchParams({username:t}),r=await fetch(`${jt(e)}api/register/check-username?${n}`);if(!r.ok)throw Error(`HTTP ${r.status}`);return r.json()}async function Ft(e,t){let n=new URLSearchParams({email:t}),r=await fetch(`${jt(e)}api/register/check-email?${n}`);if(!r.ok)throw Error(`HTTP ${r.status}`);return r.json()}async function It(e,t,n,r){let i=await fetch(`${jt(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 Lt(e,t){return e.serverData.features.find(e=>e.name===t)}function Rt(e){return Lt(e,`screepsmod-auth`)}var zt={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`}}}]},Bt={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 Vt(e){let t=Math.round(e).toString(16);return t.length<2?`0`+t:t}function Ht(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`#`+Vt(u)+Vt(d)+Vt(f)}function Ut(){let e=[],t=0;e.push({index:t++,rgb:Ht(0,0,.8)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Ht(n*360/19,.6,.8)});e.push({index:t++,rgb:Ht(0,0,.5)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Ht(n*360/19,.7,.5)});e.push({index:t++,rgb:Ht(0,0,.3)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Ht(n*360/19,.4,.3)});e.push({index:t++,rgb:Ht(0,0,.1)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Ht(n*360/19,.5,.1)});return e}var Wt=Ut();function Gt(e){if(typeof e==`string`)return e;if(typeof e==`number`){let t=Wt[e];return t?t.rgb:`#000000`}return`#000000`}function Kt(e){let t=Gt(e.color1),n=Gt(e.color2),r=Gt(e.color3),i=e.param??0;if(typeof e.type==`number`){let t=Bt[e.type];t&&t.calc(i)}let a=0;if(e.flip&&typeof e.type==`number`){let t=Bt[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=Bt[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[qt,Jt]=a([]),Yt=0;function B(e,t=`success`,n=4e3){let r=Yt++;Jt(i=>[...i,{id:r,message:e,type:t,duration:n}]),setTimeout(()=>{Jt(e=>e.filter(e=>e.id!==r))},n)}var Xt=!1;function Zt(){return!0}function Qt(){return Xt}function $t(){return window.location.origin}function en(){return`0.12.0`}function tn(){return typeof window>`u`?null:window.__SCREEPS_CLIENT_EMBEDDED__??null}function nn(){let e=`/client/`;return e.startsWith(`.`)?``:e.replace(/\/$/,``)}function rn(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`},an={url:`screeps:url`,token:`screeps:token`,serverPassword:`screeps:serverPassword`,authMethod:`screeps:authMethod`};function on(e){return localStorage.getItem(e)}function sn(e,t){localStorage.setItem(e,t)}function cn(e){localStorage.removeItem(e)}function ln(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 un(e,t){localStorage.setItem(e,String(t))}function dn(e,t){let n=localStorage.getItem(e);if(n===null)return t;try{return JSON.parse(n)}catch{return t}}function fn(e,t){localStorage.setItem(e,JSON.stringify(t))}function pn(e){return sessionStorage.getItem(e)}function mn(e,t){sessionStorage.setItem(e,t)}function hn(e){sessionStorage.removeItem(e)}async function gn(){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:_n}=rn(`client`),[H,vn]=a(null),[yn,bn]=a(`idle`),[xn,Sn]=a(null),[U,Cn]=a(null),[wn,Tn]=a(null),[En,Dn]=a(null),[On,kn]=a(null),[An,jn]=a(!1),[Mn,Nn]=a(null),[Pn,Fn]=a(null),[In,Ln]=a({}),[Rn,zn]=a(null),Bn=1e3,Vn=15e3,Hn=null,Un=0;function Wn(){Hn===null&&(_n(`world status polling: start`),Hn=setInterval(()=>{let e=H();e&&e.stores.user.refreshWorldStatus().catch(()=>{})},Bn))}function Gn(){Hn!==null&&(_n(`world status polling: stop`),clearInterval(Hn),Hn=null)}function Kn(e){e===`empty`||e===`lost`||Date.now()<Un?Wn():Gn()}function qn(){Un=Date.now()+Vn,Wn()}var Jn=-1,Yn=-1,Xn=[],Zn=5;function Qn(e){if(e===void 0)return;let t=Date.now();if(Jn>=0&&e>Jn){let e=t-Yn;if(e>0){Xn.push(e),Xn.length>Zn&&Xn.shift();let t=Xn.reduce((e,t)=>e+t,0)/Xn.length;kn(Math.round(t))}}Jn=e,Yn=t}function $n(){Jn=-1,Yn=-1,Xn.length=0,kn(null)}var er=()=>{let e=wn();return e?(e.serverData?.shards?.length??0)===0:null};async function tr(e){Zt()&&(e={...e,url:$t()}),_n(`connecting to ${e.url} (auth: ${e.auth})`),bn(`connecting`),Sn(null);try{let t;if(e.auth===`guest`)t=new St,jn(!0);else if(e.auth===`password`){if(!e.email||!e.password)throw Error(`Email and password are required`);t=new xt({email:e.email,password:e.password})}else{if(!e.token)throw Error(`Token is required`);t=new bt({token:e.token})}let n=new yt({url:e.url,auth:t,storage:e.storage??new Tt(`screeps-client`),debug:!1,serverPassword:e.serverPassword,decorationsMock:zt});n.http.on(`http:tokenRefresh`,({token:e})=>{_n(`token refreshed`),mn(an.token,e)}),n.http.on(`http:error`,({method:e,path:t,error:n,silent:r})=>{_n(`http error:`,e,t,n.message),r||B(`Request failed: ${e} ${t} — ${n.message}`,`error`,6e3)}),n.stores.server.on(`server:disconnected`,e=>{_n(`server disconnected (willReconnect: ${e.willReconnect})`),e.willReconnect||(bn(`idle`),vn(null),Cn(null),Tn(null),Un=0,Kn(null))}),n.stores.server.on(`server:error`,e=>{_n(`server error:`,e.error.message),Sn(e.error.message),bn(`error`)}),n.stores.user.on(`user:me`,e=>{_n(`user: ${e.username} (id: ${e._id})`),Cn(e)}),n.stores.server.on(`server:version`,e=>{_n(`server version: ${e.package??`unknown`}`),Tn(e)}),n.stores.user.on(`user:stream`,e=>{if(e&&typeof e==`object`&&`flags`in e){let t=e.flags;t&&typeof t==`object`&&Ln(t)}}),n.stores.user.on(`user:worldStatus`,({status:e})=>{_n(`world status: ${e}`),zn(e),Kn(e)}),await n.connect(),n.stores.user.subscribeUserStream(),vn(n),bn(`connected`),_n(`connected to ${e.url}`),n.stores.server.worldInfo().then(e=>{Fn(e),_n(`world: ${e.width}x${e.height} x[${e.minX},${e.maxX}] y[${e.minY},${e.maxY}]`)}).catch(()=>{}),mn(an.url,e.url);let r=e.authMethod??e.auth;Nn(r),mn(an.authMethod,r),n.http.token&&mn(an.token,n.http.token),e.serverPassword?mn(an.serverPassword,e.serverPassword):hn(an.serverPassword)}catch(e){let t=e instanceof Error?e.message:String(e);throw _n(`connection failed:`,t),Sn(t),bn(`error`),vn(null),e}}async function nr(){let e=Zt()?$t():pn(an.url),t=pn(an.token);if(!e||!t)return;let n=pn(an.serverPassword)??void 0,r=pn(an.authMethod);_n(`auto-connect: ${e}`);try{t===`guest`?await tr({url:e,auth:`guest`,storage:null,serverPassword:n}):await tr({url:e,auth:`token`,token:t,serverPassword:n,authMethod:r??`token`})}catch{_n(`auto-connect failed — clearing stored token`),hn(an.token)}}function rr(){_n(`disconnecting`);let e=H();e&&e.disconnect(),vn(null),bn(`idle`),Sn(null),Cn(null),Tn(null),Dn(null),jn(!1),Nn(null),Fn(null),Ln({}),zn(null),Un=0,Kn(null),$n(),hn(an.token),hn(an.url),hn(an.serverPassword),hn(an.authMethod)}var ir={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`},ar=P(`<svg>`),or=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),sr=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),cr=e=>{let t=sr(e);return t.charAt(0).toUpperCase()+t.slice(1)},lr=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),W=t=>{let[n,r]=e(t,[`color`,`size`,`strokeWidth`,`children`,`class`,`name`,`iconNode`,`absoluteStrokeWidth`]);return(()=>{var e=ar();return De(e,o(ir,{get width(){return n.size??ir.width},get height(){return n.size??ir.height},get stroke(){return n.color??ir.stroke},get"stroke-width"(){return N(()=>!!n.absoluteStrokeWidth)()?Number(n.strokeWidth??ir[`stroke-width`])*24/Number(n.size):Number(n.strokeWidth??ir[`stroke-width`])},get class(){return lr(`lucide`,`lucide-icon`,...n.name==null?[]:[`lucide-${or(cr(n.name))}`,`lucide-${or(n.name)}`],n.class==null?``:n.class)}},r),!0,!0),z(e,f(u,{get each(){return n.iconNode},children:([e,t])=>f(We,o({component:e},t))})),e})()},ur=[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]],dr=e=>f(W,o(e,{iconNode:ur,name:`arrow-left-right`})),fr=[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`path`,{d:`M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z`,key:`1l2ple`}],[`path`,{d:`M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z`,key:`1wam0m`}]],pr=e=>f(W,o(e,{iconNode:fr,name:`atom`})),mr=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.9 4.9 14.2 14.2`,key:`1m5liu`}]],hr=e=>f(W,o(e,{iconNode:mr,name:`ban`})),gr=[[`path`,{d:`m11 7-3 5h4l-3 5`,key:`b4a64w`}],[`path`,{d:`M14.856 6H16a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.935`,key:`lre1cr`}],[`path`,{d:`M22 14v-4`,key:`14q9d5`}],[`path`,{d:`M5.14 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2.936`,key:`13q5k0`}]],_r=e=>f(W,o(e,{iconNode:gr,name:`battery-charging`})),vr=[[`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`}]],yr=e=>f(W,o(e,{iconNode:vr,name:`bell-off`})),br=[[`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`}]],xr=e=>f(W,o(e,{iconNode:br,name:`bell`})),Sr=[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]],Cr=e=>f(W,o(e,{iconNode:Sr,name:`check`})),wr=[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]],Tr=e=>f(W,o(e,{iconNode:wr,name:`chevron-down`})),Er=[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]],Dr=e=>f(W,o(e,{iconNode:Er,name:`chevron-right`})),Or=[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]],kr=e=>f(W,o(e,{iconNode:Or,name:`chevron-left`})),Ar=[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]],jr=e=>f(W,o(e,{iconNode:Ar,name:`chevrons-left`})),Mr=[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]],Nr=e=>f(W,o(e,{iconNode:Mr,name:`chevrons-right`})),Pr=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]],Fr=e=>f(W,o(e,{iconNode:Pr,name:`circle-slash`})),Ir=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]],Lr=e=>f(W,o(e,{iconNode:Ir,name:`clock`})),Rr=[[`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`}]],zr=e=>f(W,o(e,{iconNode:Rr,name:`code-xml`})),Br=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]],Vr=e=>f(W,o(e,{iconNode:Br,name:`crosshair`})),Hr=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]],Ur=e=>f(W,o(e,{iconNode:Hr,name:`database`})),Wr=[[`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`}]],Gr=e=>f(W,o(e,{iconNode:Wr,name:`eye`})),Kr=[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M16 16h.01`,key:`1f9h7w`}],[`path`,{d:`M3 19a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a.5.5 0 0 0-.769-.422l-4.462 2.844A.5.5 0 0 1 15 10.5v-2a.5.5 0 0 0-.769-.422L9.77 10.922A.5.5 0 0 1 9 10.5V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z`,key:`1iv0i2`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]],qr=e=>f(W,o(e,{iconNode:Kr,name:`factory`})),Jr=[[`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`}]],Yr=e=>f(W,o(e,{iconNode:Jr,name:`flag`})),Xr=[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]],Zr=e=>f(W,o(e,{iconNode:Xr,name:`flask-conical`})),Qr=[[`path`,{d:`M6 3h12l4 6-10 13L2 9Z`,key:`1pcd5k`}],[`path`,{d:`M11 3 8 9l4 13 4-13-3-6`,key:`1fcu3u`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]],$r=e=>f(W,o(e,{iconNode:Qr,name:`gem`})),ei=[[`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`}]],ti=e=>f(W,o(e,{iconNode:ei,name:`hammer`})),ni=[[`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`}]],ri=e=>f(W,o(e,{iconNode:ni,name:`key-round`})),ii=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]],ai=e=>f(W,o(e,{iconNode:ii,name:`layout-dashboard`})),oi=[[`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`}]],si=e=>f(W,o(e,{iconNode:oi,name:`layout-grid`})),ci=[[`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`}]],li=e=>f(W,o(e,{iconNode:ci,name:`loader`})),ui=[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]],di=e=>f(W,o(e,{iconNode:ui,name:`lock`})),fi=[[`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`}]],pi=e=>f(W,o(e,{iconNode:fi,name:`log-in`})),mi=[[`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`}]],hi=e=>f(W,o(e,{iconNode:mi,name:`log-out`})),gi=[[`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`}]],_i=e=>f(W,o(e,{iconNode:gi,name:`map`})),vi=[[`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`}]],yi=e=>f(W,o(e,{iconNode:vi,name:`move`})),bi=[[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}],[`path`,{d:`m17 13 5 5m-5 0 5-5`,key:`im3w4b`}]],xi=e=>f(W,o(e,{iconNode:bi,name:`package-x`})),Si=[[`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`}]],Ci=e=>f(W,o(e,{iconNode:Si,name:`pause`})),wi=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]],Ti=e=>f(W,o(e,{iconNode:wi,name:`pencil`})),Ei=[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]],Di=e=>f(W,o(e,{iconNode:Ei,name:`play`})),Oi=[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]],ki=e=>f(W,o(e,{iconNode:Oi,name:`plus`})),Ai=[[`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`}]],ji=e=>f(W,o(e,{iconNode:Ai,name:`refresh-cw`})),Mi=[[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z`,key:`m3kijz`}],[`path`,{d:`m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z`,key:`1fmvmk`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0`,key:`1f8sc4`}],[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}]],Ni=e=>f(W,o(e,{iconNode:Mi,name:`rocket`})),Pi=[[`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`}]],Fi=e=>f(W,o(e,{iconNode:Pi,name:`rotate-ccw`})),Ii=[[`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`}]],Li=e=>f(W,o(e,{iconNode:Ii,name:`settings`})),Ri=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]],zi=e=>f(W,o(e,{iconNode:Ri,name:`shield-check`})),Bi=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]],Vi=e=>f(W,o(e,{iconNode:Bi,name:`shield`})),Hi=[[`path`,{d:`m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7`,key:`ztvudi`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}],[`path`,{d:`M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4`,key:`2ebpfo`}],[`path`,{d:`M2 7h20`,key:`1fcdvo`}],[`path`,{d:`M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7`,key:`6c3vgh`}]],Ui=e=>f(W,o(e,{iconNode:Hi,name:`store`})),Wi=[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]],Gi=e=>f(W,o(e,{iconNode:Wi,name:`sun`})),Ki=[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]],qi=e=>f(W,o(e,{iconNode:Ki,name:`terminal`})),Ji=[[`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`}]],Yi=e=>f(W,o(e,{iconNode:Ji,name:`trash-2`})),Xi=[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]],Zi=e=>f(W,o(e,{iconNode:Xi,name:`trending-up`})),Qi=[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]],$i=e=>f(W,o(e,{iconNode:Qi,name:`x`})),ea=[[`path`,{d:`M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317`,key:`193nxd`}],[`path`,{d:`M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773`,key:`27a7lr`}],[`path`,{d:`M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643`,key:`1e0qe9`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]],ta=e=>f(W,o(e,{iconNode:ea,name:`zap-off`})),na=[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]],ra=e=>f(W,o(e,{iconNode:na,name:`zap`})),ia=P(`<span style=font-size:11px;display:inline-flex;align-items:center;gap:3px>`),aa=P(`<div style="color:#3fb950;font-size:14px;text-align:center;padding:8px 0">Account created! Logging you in…`),oa=P(`<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>`),sa=P(`<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>`),ca=P(`<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>`),la=P(`<span style=font-size:11px;color:#f85149>Passwords don't match`),ua=P(`<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>`),da=P(`<button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),fa=P(`<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`),pa=P(`<form style=display:flex;flex-direction:column;gap:16px><h2 style=margin:0;font-size:20px>Create Account`),ma=P(`<div style=color:#f85149;font-size:13px>`),ha=P(`<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">`),ga=P(`<button type=button style=background:none;border:none;color:#58a6ff;font-size:12px;cursor:pointer;padding:0>Create account`),_a=P(`<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`),va=P(`<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>`),ya=P(`<div style=color:#8b949e;font-size:12px;margin-top:-8px>`),ba=P(`<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>`),xa=P(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#1b2838;color:#c7d5e0;font-weight:600>Login with Steam`),Sa=P(`<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)`),Ca=P(`<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>`),wa=P(`<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>`),Ta=P(`<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">`),Ea=P(`<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>`),Da=P(`<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>`),Oa=P(`<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>`),ka=P(`<span style="font-size:11px;padding:2px 8px;border-radius:12px;background:#21262d;border:1px solid #30363d;color:#8b949e;font-family:monospace">`),Aa={padding:`8px 12px`,"border-radius":`6px`,border:`1px solid #30363d`,background:`#0d1117`,color:`#c9d1d9`};function ja(e){let[t,r]=a(null),[i,o]=a(null),[c,l]=a(null);return s(()=>{let t=e();r(null),o(null),l(null);let i=!1,a=setTimeout(async()=>{try{let e=await Mt(t);if(i)return;if(r(e),l(null),Rt(e)){let e=await Nt(t);i||o(e)}}catch{i||(l(`Could not reach server`),r(null))}},400);n(()=>{i=!0,clearTimeout(a)})}),{serverVersion:t,authModInfo:i,serverError:c}}function Ma(e,t,r){let[i,o]=a(`idle`);return s(()=>{let i=t();if(!i){o(`idle`);return}o(`checking`);let a=!1,s=setTimeout(async()=>{try{let t=await r(e(),i);a||o(t.error?`taken`:`available`)}catch{a||o(`error`)}},500);n(()=>{a=!0,clearTimeout(s)})}),i}function Na(e){let t={idle:null,checking:{children:`Checking…`,color:`#8b949e`},available:{children:[f(Cr,{size:12}),` Available`],color:`#3fb950`},taken:{children:[f($i,{size:12}),` Already taken`],color:`#f85149`},error:{children:`Could not verify`,color:`#d29922`}},n=()=>t[e.state];return f(v,{get when(){return n()},get children(){var e=ia();return z(e,()=>n().children),w(t=>R(e,`color`,n().color)),e}})}function Pa(e){let[t,n]=a(``),[r,i]=a(``),[o,s]=a(``),[c,l]=a(``),[u,d]=a(!1),[p,m]=a(null),[h,g]=a(!1),_=Ma(()=>e.url,t,Pt),y=Ma(()=>e.url,r,Ft),b=()=>c()!==``&&o()!==c(),x=()=>!u()&&t()!==``&&r()!==``&&o().length>=4&&o()===c()&&_()!==`taken`&&_()!==`checking`&&y()!==`taken`&&y()!==`checking`,S=async n=>{if(n.preventDefault(),x()){d(!0),m(null);try{let n=await It(e.url,t(),r(),o());if(n.error){m(n.error);return}g(!0),setTimeout(()=>e.onSuccess(r(),o()),1500)}catch(e){m(e instanceof Error?e.message:`Registration failed`)}finally{d(!1)}}};return(()=>{var a=pa();return a.firstChild,a.addEventListener(`submit`,S),z(a,f(v,{get when(){return h()},get children(){return aa()}}),null),z(a,f(v,{get when(){return!h()},get children(){return[(()=>{var e=oa(),r=e.firstChild;r.firstChild;var i=r.nextSibling;return z(r,f(Na,{get state(){return _()}}),null),i.$$input=e=>n(e.currentTarget.value),w(e=>{var t=Aa,n=u();return e.e=L(i,t,e.e),n!==e.t&&(i.disabled=e.t=n),e},{e:void 0,t:void 0}),w(()=>i.value=t()),e})(),(()=>{var e=sa(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return z(t,f(Na,{get state(){return y()}}),null),n.$$input=e=>i(e.currentTarget.value),w(e=>{var t=Aa,r=u();return e.e=L(n,t,e.e),r!==e.t&&(n.disabled=e.t=r),e},{e:void 0,t:void 0}),w(()=>n.value=r()),e})(),(()=>{var e=ca(),t=e.firstChild.nextSibling;return t.$$input=e=>s(e.currentTarget.value),w(e=>{var n=Aa,r=u();return e.e=L(t,n,e.e),r!==e.t&&(t.disabled=e.t=r),e},{e:void 0,t:void 0}),w(()=>t.value=o()),e})(),(()=>{var e=ua(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return z(t,f(v,{get when(){return b()},get children(){return la()}}),null),n.$$input=e=>l(e.currentTarget.value),w(e=>{var t={...Aa,border:b()?`1px solid #f85149`:`1px solid #30363d`},r=u();return e.e=L(n,t,e.e),r!==e.t&&(n.disabled=e.t=r),e},{e:void 0,t:void 0}),w(()=>n.value=c()),e})(),N(()=>N(()=>!!p())()&&(()=>{var e=ma();return z(e,p),e})()),(()=>{var e=da();return z(e,()=>u()?`Creating account…`:`Create Account`),w(t=>{var n=!x(),r=x()?`pointer`:`not-allowed`,i=x()?1:.5;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&R(e,`cursor`,t.t=r),i!==t.a&&R(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})(),(()=>{var t=fa();return t.$$click=()=>e.onCancel(),t})()]}}),null),a})()}function Fa(){let e=Zt(),t=Qt(),[r,i]=a(`login`),[o,s]=a(`password`),[c,l]=a(e?$t():window.location.origin),[d,p]=a(``),[m,h]=a(``),[g,_]=a(``),[y,b]=a(``),{serverVersion:x,authModInfo:S,serverError:C}=ja(c),T=()=>x()?.serverData?.welcomeText??null,E=()=>(x()?.serverData?.features??[]).filter(e=>e.name!==`auth`&&e.version!=null),D=()=>{let e=x();return e?Rt(e)?.authTypes?.includes(`steam`)??!0:!0},O=()=>S()?.allowRegistration===!0||(x()?.serverData?.features??[]).some(e=>e.name===`official-like`),ee=()=>{let e=c().replace(/\/$/,``),t=window.open(`${e}/api/auth/steam`,`screeps-steam-auth`,`width=800,height=600,left=200,top=100`),r=t=>{try{let n=JSON.parse(t.data);n.token&&(a(),tr({url:e,auth:`token`,authMethod:`steam`,token:n.token,serverPassword:y()||void 0,storage:null}))}catch{}},i=setInterval(()=>{t?.closed&&a()},500),a=()=>{clearInterval(i),window.removeEventListener(`message`,r)};window.addEventListener(`message`,r),n(a)},k=async e=>{e.preventDefault(),await tr({url:c(),auth:o(),email:d()||void 0,password:m()||void 0,token:g()||void 0,serverPassword:y()||void 0,storage:null})},A=async e=>{e.preventDefault(),await tr({url:c(),auth:`guest`,serverPassword:y()||void 0,storage:null})},te=async(e,t)=>{try{await tr({url:c(),auth:`password`,email:e,password:t,serverPassword:y()||void 0,storage:null})}catch{i(`login`),s(`password`),p(e),h(t)}},ne=()=>yn()===`connecting`;return(()=>{var n=Ta(),a=n.firstChild;return z(n,f(v,{get when(){return T()},get children(){var e=ha();return w(()=>e.innerHTML=T()),e}}),a),z(a,f(v,{get when(){return r()===`register`},get children(){return f(Pa,{get url(){return c()},get serverPassword(){return y()},onSuccess:te,onCancel:()=>i(`login`)})}}),null),z(a,f(v,{get when(){return r()===`login`},get children(){var n=Ca(),r=n.firstChild;r.firstChild;var a=r.nextSibling,u=a.firstChild;u.firstChild.nextSibling;var x=u.nextSibling,S=a.nextSibling;return n.addEventListener(`submit`,k),z(r,f(v,{get when(){return O()},get children(){var e=ga();return e.$$click=()=>i(`register`),e}}),null),z(n,f(v,{when:!e,get children(){var e=_a(),t=e.firstChild,n=t.nextSibling;return t.$$click=()=>s(`password`),n.$$click=()=>s(`token`),w(e=>{var r=o()===`password`?`#238636`:`transparent`,i=o()===`token`?`#238636`:`transparent`;return r!==e.e&&R(t,`background`,e.e=r),i!==e.t&&R(n,`background`,e.t=i),e},{e:void 0,t:void 0}),e}}),a),z(n,f(v,{when:!e,get children(){return[(()=>{var e=va(),t=e.firstChild.nextSibling;return t.$$input=e=>l(e.currentTarget.value),w(e=>L(t,Aa,e)),w(()=>t.value=c()),e})(),f(v,{get when(){return C()},get children(){var e=ya();return z(e,C),e}})]}}),a),z(n,(()=>{var e=N(()=>o()===`password`);return()=>e()?[(()=>{var e=Ea(),t=e.firstChild.nextSibling;return t.$$input=e=>p(e.currentTarget.value),w(e=>L(t,Aa,e)),w(()=>t.value=d()),e})(),(()=>{var e=Da(),t=e.firstChild.nextSibling;return t.$$input=e=>h(e.currentTarget.value),w(e=>L(t,Aa,e)),w(()=>t.value=m()),e})()]:(()=>{var e=Oa(),t=e.firstChild.nextSibling;return t.$$input=e=>_(e.currentTarget.value),w(e=>L(t,Aa,e)),w(()=>t.value=g()),e})()})(),a),x.$$input=e=>b(e.currentTarget.value),z(n,(()=>{var e=N(()=>!!xn());return()=>e()&&(()=>{var e=ma();return z(e,xn),e})()})(),S),z(S,()=>ne()?`Connecting…`:`Connect`),z(n,f(v,{get when(){return D()},get children(){return[(()=>{var e=ba();return e.firstChild.nextSibling.nextSibling,e})(),(()=>{var e=xa();return e.$$click=ee,w(t=>{var n=ne(),r=ne()?`not-allowed`:`pointer`,i=ne()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&R(e,`cursor`,t.t=r),i!==t.a&&R(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})()]}}),null),z(n,f(v,{when:!e||t,get children(){var e=Sa();return e.addEventListener(`mouseleave`,e=>{e.currentTarget.style.borderColor=`#30363d`}),e.addEventListener(`mouseenter`,e=>{ne()||(e.currentTarget.style.borderColor=`#8b949e`)}),e.$$click=A,w(t=>{var n=ne(),r=ne()?`not-allowed`:`pointer`,i=ne()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&R(e,`cursor`,t.t=r),i!==t.a&&R(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),w(e=>{var t=Aa,n=ne(),r=ne()?`not-allowed`:`pointer`,i=ne()?.6:1;return e.e=L(x,t,e.e),n!==e.t&&(S.disabled=e.t=n),r!==e.a&&R(S,`cursor`,e.a=r),i!==e.o&&R(S,`opacity`,e.o=i),e},{e:void 0,t:void 0,a:void 0,o:void 0}),w(()=>x.value=y()),n}}),null),z(n,f(v,{get when(){return E().length>0},get children(){var e=wa(),t=e.firstChild.nextSibling;return z(t,f(u,{get each(){return E()},children:e=>(()=>{var t=ka();return z(t,()=>e.name,null),z(t,(()=>{var t=N(()=>!!e.version);return()=>t()?` ${e.version}`:``})(),null),t})()})),e}}),null),n})()}F([`input`,`click`]);var Ia=P(`<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 La(){return(()=>{var e=Ia();return e.firstChild.nextSibling,e})()}var Ra=P(`<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`),za=P(`<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 Ba(){let e=()=>{switch(yn()){case`connected`:return`#238636`;case`connecting`:return`#d29922`;case`error`:return`#f85149`;default:return`#8b949e`}};return(()=>{var t=za(),n=t.firstChild.firstChild,r=n.nextSibling;return z(r,(()=>{var e=N(()=>yn()===`connected`);return()=>e()?`Online`:yn()})()),z(t,f(v,{get when(){return An()},get children(){return Ra()}}),null),w(t=>R(n,`background-color`,e())),t})()}var Va=class{container;hoverGraphics;pendingGraphics;selectionContainer;selectionGraphics=new Map;selectionTypes=new Map;selectionVisuals=new Map;ticker=null;tickerCallback=null;constructor(e){this.container=new M,this.container.label=`hoverHighlight`,this.container.eventMode=`none`,this.hoverGraphics=new O,this.hoverGraphics.eventMode=`none`,this.container.addChild(this.hoverGraphics),this.pendingGraphics=new O,this.pendingGraphics.eventMode=`none`,this.container.addChild(this.pendingGraphics),this.selectionContainer=new M,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 O;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()}},Ha=.2,Ua=3,Wa=class{displaySprite;renderer;rt;scene;gradientTexture;lights=new Map;dirty=!1;destroyed=!1;constructor(e){this.renderer=e,this.gradientTexture=Ga(),this.rt=le.create({width:600,height:600}),this.scene=new M;let t=new O;t.rect(0,0,600,600),t.fill({color:0,alpha:Ha}),this.scene.addChild(t),this.displaySprite=new A(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 A(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 Ga(){let e=Ua*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(),j.from(n)}var Ka=48,qa=128,Ja={terrain:0,objects:10,animations:20,darkOverlay:30,visuals:40,hover:50,nav:60},Ya=new Set([`road`,`constructedWall`,`rampart`]),Xa=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 M({sortableChildren:!0}),this.app.stage.addChild(this.world),this.lighting=new Wa(this.app.renderer),this.darkOverlay=this.lighting.displaySprite,this.darkOverlay.label=`darkOverlay`,this.darkOverlay.zIndex=Ja.darkOverlay,this.world.addChild(this.darkOverlay),this.lightLayer=new M,this.lightLayer.label=`lightLayer`,this.hoverLayer=new Va(e.ticker),this.hoverLayer.container.zIndex=Ja.hover,this.world.addChild(this.hoverLayer.container),this.navOverlay=new M,this.navOverlay.zIndex=Ja.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 k;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?qa:0;if(t<=n){let r=n/2-t/2;e?this.world.x=Math.min(r+qa,Math.max(r-qa,this.world.x)):this.world.x=r}else{let e=n-t-Ka-i,r=Ka+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+qa,Math.max(n-qa,this.world.y)):this.world.y=n}else{let e=r-t-Ka-i,n=Ka+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-Ka,i=Ka;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-Ka,r=Ka;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 O;o.x=e,o.y=t,o.hitArea=new ne(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,Ka,600,[18,300,Ka-6,282,Ka-6,318],e.west),t(600,0,Ka,600,[Ka-18,300,6,282,6,318],e.east),t(0,-48,600,Ka,[300,18,282,Ka-6,318,Ka-6],e.north),t(0,600,600,Ka,[300,Ka-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`&&Ya.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}))}},Za=856343,Qa=1448738,$a=1843496,eo=Za,to=7039337,no=3159613,ro={tough:5000268,move:11122630,work:16770413,carry:7829367,attack:16332866,ranged_attack:6127794,heal:6684002,claim:12164347},io=5809919,ao=7979263,oo=4176208,so=9147550,co=13801762,lo=10711543,uo=16218298,fo=16273737,po=15763518,mo=2172461,ho=to,go=12283502,_o=[16777215,16711680,8388736,255,65535,32768,16776960,16753920,10824234,8421504,16777215],vo={creep:po,spawn:io,extension:ao,tower:oo,container:so,storage:co,link:lo,rampart:io,road:ho,constructedWall:mo,extractor:so,lab:uo,terminal:co,observer:ao,powerSpawn:po,nuker:fo,factory:so,invaderCore:fo,source:co,mineral:ao,deposit:co,controller:io,powerBank:po,portal:lo},yo=16771195,bo=yo,xo=ao,So=yo,Co=ao,wo=yo,To=yo,Eo=fo,Do=oo,Oo=ao,ko=16777215,Ao=9419667,jo=7245682,Mo=12116924,No=12283502,Po=9787480,Fo=14721184,Io=$a,Lo=13684944,Ro=4067858,zo=14440008,Bo=11940394,G=1579032,Vo=5592405,Ho=11184810,Uo=9419667,Wo=16771195,Go=16069959,Ko=7105644,qo={energy:Wo,power:Go,H:13421772,O:16777215,U:5822457,L:62626,K:10514943,Z:16631694,X:11568379,G:16777215},Jo={biomass:8695826,metal:9793372,mist:14314485,silicon:5023717},Yo=5617743,Xo=9099642,Zo=11680314,Qo=14049376;function $o(e){return e}function es(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 ts(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 ns(e,t){let n=to,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)!==st.Wall&&r(e,0,`up`),t.get(e,49)!==st.Wall&&r(e,49,`down`);for(let e=0;e<50;e++)t.get(0,e)!==st.Wall&&r(0,e,`left`),t.get(49,e)!==st.Wall&&r(49,e,`right`)}function rs(e){let t=new O;return t.rect(0,0,600,600),t.fill(e.floorColor),t}function is(e,t){let n=new O,r={color:t.swampBorderColor,width:12*t.swampBorderWidth,alignment:0,cap:`round`,join:`round`};return ts(n,e,st.Swamp,e=>e.stroke(r)),ts(n,e,st.Swamp,e=>e.fill(t.swampFillColor)),n}function as(e,t){let n=new O,r={color:t.wallBorderColor,width:12*t.wallBorderWidth,alignment:0,cap:`round`,join:`round`};return ts(n,e,st.Wall,e=>e.stroke(r)),ts(n,e,st.Wall,e=>e.fill(t.wallFillColor)),ns(n,e),n.rect(0,0,600,600),n.stroke({width:1,color:no}),n}function os(e,t){let n=new O;return n.label=`swampGlow`,ts(n,e,st.Swamp,e=>e.fill(t.swampGlowColor)),n.alpha=.45,n.filters=[new ce({strength:5,quality:3})],n}function ss(e,t,n){let r=new O;ts(r,e,st.Wall,e=>e.fill(n.wallNoiseColor)),r.alpha=.5,r.filters=[new oe({noise:.12,seed:1})],r.filterArea=new ne(0,0,600,600);let i=t.generateTexture({target:r,frame:r.filterArea});r.filters=null,r.destroy();let a=new A(i);return a.label=`wallNoise`,a}function cs(e,t,n){let r=es(n),i=new M,a=ss(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(rs(r)),i.addChild(is(e,r)),i.addChild(as(e,r)),i.addChild(os(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;ee.load($o(e)).then(e=>{if(i.destroyed)return;let n=new re({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;ee.load($o(t)).then(t=>{if(i.destroyed)return;let n=new re({texture:t,width:600,height:600});n.tint=r,n.alpha=a,n.tileScale.set(o);let s=new O;ts(s,e,st.Wall,e=>e.fill(16777215)),i.addChild(s),n.mask=s,i.addChild(n)}).catch(()=>{})}return i}function ls(e,t){e.getChildByLabel(`swampGlow`).visible=t,e.getChildByLabel(`wallNoise`).visible=t}function us(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 ds(e){return parseInt(e.replace(`#`,``),16)}function fs(e,t){if(e==null)return t;let n=Number(e);return isNaN(n)?t:n}function ps(e,t,n){let r=n.terrain??{};e.floorBackgroundColor&&(r.floorColor=us(e.floorBackgroundColor,fs(e.floorBackgroundBrightness,1))),e.swampColor&&(r.swampFillColor=ds(e.swampColor)),e.swampStrokeColor&&(r.swampBorderColor=ds(e.swampStrokeColor)),e.swampStrokeWidth!=null&&(r.swampBorderWidth=fs(e.swampStrokeWidth,50)/250),e.roadsColor&&(n.roadColor=us(e.roadsColor,fs(e.roadsBrightness,1))),t.floorForegroundUrl&&(r.floorTextureUrl=t.floorForegroundUrl,e.floorForegroundColor&&(r.floorTextureTint=us(e.floorForegroundColor,fs(e.floorForegroundBrightness,1))),r.floorTextureAlpha=fs(e.floorForegroundAlpha,1),r.floorTextureTileScale=fs(e.tileScale??t.tileScale,1)),n.terrain=r}function ms(e,t,n){let r=n.terrain??{};e.backgroundColor&&(r.wallFillColor=us(e.backgroundColor,fs(e.backgroundBrightness,1))),e.strokeColor&&(r.wallBorderColor=us(e.strokeColor,fs(e.strokeBrightness,1))),e.strokeWidth!=null&&(r.wallBorderWidth=fs(e.strokeWidth,10)/250),t.foregroundUrl&&(r.wallTextureUrl=t.foregroundUrl,e.foregroundColor&&(r.wallTextureTint=us(e.foregroundColor,fs(e.foregroundBrightness,1))),r.wallTextureAlpha=fs(e.foregroundAlpha,1),r.wallTextureTileScale=fs(e.tileScale??t.tileScale,1)),n.terrain=r}function hs(e){let t={};for(let n of e.decorations){let e=n.decoration.type;e===`floorLandscape`?ps(n.active,n.decoration,t):e===`wallLandscape`&&ms(n.active,n.decoration,t)}return t}function gs(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=n,r.src=e})}var _s=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=Kt(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 gs(i),a=document.createElement(`canvas`);a.width=n,a.height=n,a.getContext(`2d`).drawImage(r,0,0,n,n);let o=j.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()}},vs={1:200,2:45e3,3:135e3,4:405e3,5:1215e3,6:3645e3,7:10935e3},ys={1:2e4,2:1e4,3:2e4,4:4e4,5:8e4,6:12e4,7:15e4,8:2e5},bs=new _s,xs=12*.44,Ss=12*.28,Cs=50,ws=32,Ts=12/ws,Es=12/2-12*.44,Ds=2,Os=12*1.2/ws,ks=5,As=2.5,js=2,Ms=2.6,Ns=2,Ps=12,Fs=15790320,Is=1710618,Ls=12*.42,Rs=12*.3,zs=1,Bs={H:2236962,O:2236962},Vs=.2,Hs=12*.42,Us=32,Ws=9/Us,Gs=8,Ks=1600,qs=16776428,Js=4473924,Ys=1.7999999999999998;function Xs(e,t){return t<=0?Gs:Gs*Math.max(0,Math.min(1,e/t))}function Zs(e){let t=e%Ks/Ks;return .5-.5*Math.cos(t*Math.PI*2)}function Qs(e){return sc(Wo,qs,Zs(e))}function $s(e,t,n){e.clear();let r=t<=0,i=Gs/2,a=Gs*.25;if(e.roundRect(6-i,6-i,Gs,Gs,a),e.fill(G),r)e.roundRect(6-i,6-i,Gs,Gs,a),e.stroke({width:Ys,color:sc(G,Js,Zs(n))});else{let r=t/2;e.roundRect(6-r,6-r,t,t,t*.25),e.fill(Qs(n))}}function ec(e,t){let n=e.__sourceGraphics;n&&(e.__sourceSize=t,$s(n,t,performance.now()))}function tc(e){return{energy:typeof e.energy==`number`?e.energy:0,capacity:typeof e.energyCapacity==`number`?e.energyCapacity:3e3}}var nc=12*.3,rc=1.44,ic=nc-rc/2,ac=12*.42,oc=1500;function sc(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 cc(e,t){e.clear(),e.circle(12/2,12/2,nc),e.stroke({width:rc,color:t,alpha:.95})}var lc=12*.975,uc=2.16,dc=Math.PI/3,fc=1;function pc(e,t){e.clear();for(let n=0;n<3;n++){let r=n*(2*Math.PI/3)+dc/2,i=r+2*Math.PI/3-dc;e.arc(0,0,lc,r,i),e.stroke({width:uc,color:t,cap:`round`})}}function mc(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 hc=12*.5,gc=1.2000000000000002;function _c(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 vc(e){let t=e.spawning;return!t||typeof t!=`object`?null:`${String(t.name)}:${String(t.needTime)}:${String(t.remainingTime)}:${String(t.spawnTime)}`}function yc(e,t,n){return Math.max(0,Math.min(1,1-(t-n)/e))}function bc(e,t){if(e.clear(),t===null||(e.circle(6,6,hc),e.stroke({width:gc,color:16777215,alpha:.12}),t<=0))return;let n=-Math.PI/2,r=n+Math.min(1,t)*Math.PI*2;e.moveTo(6+hc*Math.cos(n),6+hc*Math.sin(n)),e.arc(6,6,hc,n,r),e.stroke({width:gc,color:Wo,alpha:.95,cap:`round`})}function xc(e,t,n){return n.flatMap(([n,r])=>[e+n*12,t+r*12])}function Sc(e,t,n,r){n-t<.001||(e.moveTo(xs*Math.cos(t),xs*Math.sin(t)),e.arc(0,0,xs,t,n),e.lineTo(Ss*Math.cos(n),Ss*Math.sin(n)),e.arc(0,0,Ss,n,t,!0),e.closePath(),e.fill(r))}var Cc=[[0,-.3],[.22,.05],[.15,.2],[-.15,.2],[-.22,.05]],wc=12*.073,Tc=null;function Ec(){if(Tc)return Tc;let e=xc(12/2,12/2,Cc),t=new ue({type:`linear`,start:{x:.5,y:0},end:{x:.5,y:1},colorStops:[{offset:0,color:zo},{offset:1,color:Bo}]});return Tc=new ie().poly(e).fill(t).poly(e).stroke({width:wc,color:Ro,alignment:.5,join:`miter`,miterLimit:6}),Tc}function Dc(e){e.addChild(new O({context:Ec()}))}function Oc(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 kc(e,t){return t<=0||e<=0?0:Ss*.8*Math.min(1,e/t)}function Ac(e,t){let n=e.__creepFillGraphics;n&&(n.clear(),t>0&&(n.circle(0,0,t),n.fill(yo)))}function jc(e){return vo[e]??13226457}function Mc(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 Nc(e){return e>=200?1.15:e>=100?.85:.7}function Pc(e,t){return t<=0||e<=0?0:Rs*Nc(t)*Math.min(1,e/t)}var Fc=12*.25,Ic=12*.3;function Lc(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function Rc(e,t){let n=e.__linkFillGraphics;if(!n||(n.clear(),t<=0))return;let r=Fc*t,i=Ic*t;n.poly([6,6-i,6+r,6,6,6+i,6-r,6]),n.fill(Wo)}function zc(e,t,n,r){let i=Nc(n),a=new O;a.circle(6,6,Ls*i),a.fill(G),a.circle(6,6,Ls*i),a.stroke({width:zs*i,color:r}),a.circle(6,6,Rs*i),a.fill(Ho),e.addChild(a);let o=new O,s=Pc(t,n);s>0&&(o.circle(6,6,s),o.fill(Wo)),e.addChild(o),e.__fillGraphics=o}function Bc(e,t){let n=e.__fillGraphics;n&&(n.clear(),t>0&&(n.circle(6,6,t),n.fill(Wo)))}var Vc=-12*.4,Hc=-12*.3,Uc=12*.8,Wc=12*.6,Gc=.4,Kc=.3,qc=Math.PI/2,Jc=Math.PI/2;function Yc(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 Xc=12*.45,Zc=12*.6,Qc=12*.275,$c=12*.2,el=.5;function tl(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function nl(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(Wo);return}let i=.5,a=Wc*t;n.rect(Vc+i,Hc+Wc-a+i,Uc-i*2,a-i*2),n.fill(Wo)}var rl=0,il=-12*.1,al=12,ol=12*1.2,sl=[`energy`,`power`];function cl(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=sl.indexOf(e),r=sl.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:qo[e]??7105644,amount:t})),used:o,capacity:t,dominant:i}}function ll(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(Wo);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 ul(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 dl(e,t){return t<=0||e<=0?0:Zc*Math.min(1,e/t)}function fl(e,t){let n=e.__containerFillG;n&&(n.clear(),ll(n,Qc,$c+Zc,Xc,t,e.__containerBands,e.__containerUsed??0,el))}function pl(e,t){return t<=0||e<=0?0:ol*Math.min(1,e/t)}function ml(e,t){let n=e.__storageFillG;n&&(n.clear(),ll(n,rl,il+ol,al,t,e.__storageBands,e.__storageUsed??0))}function hl(e){return qo[e]??7105644}function gl(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}var _l=12*.35;function vl(e,t){let n=e.__terminalFillG;if(n&&(n.clear(),t>0)){let r=_l*t;n.rect(6-r,6-r,r*2,r*2),n.fill(e.__terminalFillColor??16771195)}}var yl=16777215,bl=.55,xl=[[[0,-.65],[-.45,-.45],[.45,-.45]],[[.65,0],[.45,-.45],[.45,.45]],[[0,.65],[.45,.45],[-.45,.45]],[[-.65,0],[-.45,.45],[-.45,-.45]]];function Sl(e,t,n){for(let r of xl)e.poly(xc(t,n,r)),e.fill({color:yl,alpha:bl})}var Cl=12*.025,wl=12*.36,Tl=12*.05,El=12*.8,Dl=12*.9,Ol=12*.25,kl=2e3,Al=3e3,jl=16777215,Ml=12*.55,Nl=12*.16,Pl=12*.07,Fl=.22,Il=.5;function Ll(e,t,n){e.circle(t,n,Ml),e.stroke({width:Nl,color:jl,alpha:Fl}),e.circle(t,n,Ml),e.stroke({width:Pl,color:jl,alpha:Il})}function Rl(e){return typeof e.cooldownTime==`number`?e.cooldownTime:0}function zl(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:kl,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]:Al;return{energy:r,energyCap:i,mineralType:a,mineral:o,mineralCap:s}}function Bl(e,t,n){let r=e.__labMineralG;r&&(r.clear(),n>0)&&(r.circle(6,6-Cl,wl*n),r.fill(e.__labMineralColor??7105644));let i=e.__labEnergyG;if(i&&(i.clear(),t>0)){let e=.5;i.rect(Tl+e,El+e,(Dl-e*2)*t,Ol-e*2),i.fill(Wo)}}var Vl=3e5,Hl=5e3,Ul=-.8,Wl=.2,Gl=.4,Kl=-.34,ql=.34,Jl=.27,Yl=.45;function Xl(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:Vl,ghodium:typeof t.G==`number`?t.G:0,ghodiumCap:typeof n.G==`number`?n.G:Hl}}function Zl(e,t,n){let r=e.__nukerEnergyG;if(r&&(r.clear(),t>0)){let e=Wl-Ul,n=Wl-e*t,i=Gl*(n-Ul)/e;r.poly([6+i*12,6+n*12,6+Gl*12,6+Wl*12,6-Gl*12,6+Wl*12,6-i*12,6+n*12]),r.fill(Wo)}let i=e.__nukerGhodiumG;if(i&&(i.clear(),n>0)){let e=6+Kl*12,t=6+Jl*12,r=(ql-Kl)*12,a=(Yl-Jl)*12;i.rect(e,t,r*n,a),i.fill(hl(`G`))}}var Ql=100,$l=12*.51,eu=12*.12;function tu(e){let t=e.store&&typeof e.store==`object`?e.store:{},n=e.storeCapacityResource&&typeof e.storeCapacityResource==`object`?e.storeCapacityResource:{};return{power:typeof t.power==`number`?t.power:0,powerCap:typeof n.power==`number`?n.power:Ql}}function nu(e,t){if(e.clear(),!(t<=0)){if(t>=1)e.circle(6,6,$l);else{let n=-Math.PI/2,r=n+t*Math.PI*2;e.moveTo(6+$l*Math.cos(n),6+$l*Math.sin(n)),e.arc(6,6,$l,n,r)}e.stroke({width:eu,color:Go})}}function ru(e,t){e.__powerSpawnPowerG&&nu(e.__powerSpawnPowerG,t)}var iu=5e3,au=12/100,ou=1.2000000000000002,su=3346705,cu=6710886,lu=2e3,uu=15998771,du=13832226,fu=9240589,pu=[-45,-75,45,-75,75,-45,75,45,45,75,-45,75,-75,45,-75,-45];function mu(e){if(typeof e.power==`number`)return e.power;let t=e.store&&typeof e.store==`object`?e.store:{};return typeof t.power==`number`?t.power:0}function hu(e){return Math.sqrt(Math.max(0,e)/iu*3e3/Math.PI)*1.5*au}function gu(e){let t=e%lu/lu;return t<1/3?sc(uu,du,t*3):t<2/3?sc(du,fu,(t-1/3)*3):sc(fu,uu,(t-2/3)*3)}function _u(e,t,n){if(e.clear(),t<=0)return;let r=t*(.8+.2*Math.cos(n%lu/lu*2*Math.PI));e.circle(6,6,r),e.fill(gu(n)),e.circle(6,6,r),e.stroke({width:ou,color:fu})}var vu=8,yu=12*.4,bu=12*.5,xu=.22,Su=12*.25,Cu=12*.32,wu=12*.24,Tu=12*.28,Eu=12*.38,Du=12*.36,Ou=5,ku=16777215;function Au(){let e=2*Math.PI/vu,t=[];for(let n=0;n<vu;n++){let r=-Math.PI/2+n*e,i=r-xu,a=r+xu,o=r-e+xu;for(let e=0;e<=3;e++){let n=o+(i-o)*(e/3);t.push(6+yu*Math.cos(n),6+yu*Math.sin(n))}for(let e=0;e<=3;e++){let n=i+(a-i)*(e/3);t.push(6+bu*Math.cos(n),6+bu*Math.sin(n))}}return t}var ju=Au();function Mu(e){return typeof e.cooldown==`number`&&e.cooldown>0}function Nu(e,t){e.clear(),e.poly(ju),e.fill(G),e.poly(ju),e.stroke({width:12*.06,color:t})}function Pu(e,t){e.clear();let n=.14,r=2*Math.PI/Ou-n;for(let i=0;i<Ou;i++){let a=-Math.PI/2+i*(2*Math.PI/Ou)+n/2,o=a+r;e.moveTo(6+Su*Math.cos(a),6+Su*Math.sin(a)),e.arc(6,6,Cu,a,o),e.arc(6,6,Su,o,a,!0),e.closePath(),e.fill(i<t?Ho:Vo)}}function Fu(e,t){return t<=0||e<=0?0:Tu*Math.min(1,e/t)}function Iu(e,t){let n=e.__factoryFillG;n&&(n.clear(),ll(n,Eu,Du+Tu,wu,t,e.__factoryBands,e.__factoryUsed??0,.5))}var Lu=12*.65,Ru=Lu,zu=12*.42;function Bu(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 Vu(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 Hu(e,t){let n=e.user;return typeof n!=`string`||!t?!1:n!==t}var Uu=`2`;function Wu(e,t){let n=typeof e.user==`string`?e.user:void 0;return n?n===Uu?!0:t?.[n]?.username===`Invader`:!1}function Gu(e,t=!0,n,r,i,a,o,s){let c=new M,l=new O,u=jc(e.type),d=typeof e.user==`string`?e.user:void 0,f=d!==void 0&&n!==void 0&&d!==n?go:Uo;switch(e.type){case`creep`:{if(Wu(e,a)){Dc(c);break}let t=2*Math.PI,r=new M;r.position.set(6,6),r.rotation=-Math.PI/2;let o=Hu(e,n);if(o){let e=new O;e.circle(0,0,xs+.75),e.stroke({width:1.5,color:go}),r.addChild(e)}let s=new O;s.circle(0,0,xs),s.fill(Za),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/Cs*t,g=d/Cs*t,_=f/Cs*t,v=h/2,y=v+_/2,b=Math.PI-g/2,x=Math.PI+g/2,S=t-h/2-_/2,C=t-h/2,w=new O;h>0&&Sc(w,-h/2,v,ro.work??16770413);let T=v;for(let e of p){let n=(m[e]??0)/Cs*t/2;Sc(w,T,T+n,ro[e]??7829367),T+=n}Sc(w,y,b,Io),g>0&&Sc(w,b,x,ro.move??11122630),Sc(w,x,S,Io);let E=C;for(let e of p){let n=(m[e]??0)/Cs*t/2;Sc(w,E-n,E,ro[e]??7829367),E-=n}r.addChild(w);let D=new O;D.circle(0,0,Ss),D.fill(Qa),r.addChild(D);let ee=typeof e.user==`string`?e.user:void 0,k=ee?a?.[ee]?.badge:void 0;if(k&&i){let e=new A;e.anchor.set(.5,.5);let t=Ss*2;e.width=t,e.height=t,e.rotation=Math.PI/2,r.addChild(e),c.__creepBadgeSprite=e,i.getOrCreate(k).then(t=>{e.destroyed||(e.texture=t)}).catch(()=>{})}else if(o){let e=new O;e.circle(0,0,Ss*.82),e.fill({color:go,alpha:.9}),r.addChild(e),c.__creepForeignMark=e}let{used:te,capacity:ne}=Oc(e),re=kc(te,ne),ie=new O;re>0&&(ie.circle(0,0,re),ie.fill(yo)),r.addChild(ie),c.__creepFillGraphics=ie,c.__creepUsed=te,c.__creepCapacity=ne;let j=(xs+Ss)/2,ae=(xs-Ss)*.45,oe=new O;oe.moveTo(xs,0),oe.lineTo(j,-ae),oe.lineTo(j,ae),oe.closePath(),oe.fill(Lo),r.addChild(oe),c.addChild(r),c.__bodyContainer=r;break}case`extension`:{let{energy:t,capacity:n}=Mc(e);zc(c,t,n,f),c.__extEnergy=t,c.__extCapacity=n;break}case`spawn`:{l.circle(6,6,12*.65),l.fill(G),l.circle(6,6,12*.65),l.stroke({width:12*.1,color:13421772}),l.circle(6,6,12*.4),l.fill(Wo),c.sortableChildren=!0;let t=new O;t.zIndex=1;let n=_c(e,0),r=n?yc(n.needTime,n.endTime,0):null;bc(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=vc(e);break}case`powerSpawn`:{l.circle(6,6,12*.65),l.fill(G),l.circle(6,6,12*.65),l.stroke({width:12*.1,color:Go}),l.circle(6,6,12*.4),l.fill(Wo),c.sortableChildren=!0;let t=new O;t.zIndex=1;let{power:n,powerCap:r}=tu(e);nu(t,gl(n,r)),c.addChild(t);let i=c;i.__powerSpawnPowerG=t,i.__powerSpawnPower=n,i.__powerSpawnPowerCap=r;break}case`source`:{let{energy:t,capacity:n}=tc(e),r=Xs(t,n),i=new O;$s(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?Ao:No,a=r?jo:Po,o=r?Mo:Fo,s=typeof e.progress==`number`?e.progress:0,l=typeof e.progressTotal==`number`?e.progressTotal:1,u=new O;c.addChild(u),c.__csBuildGlow=u;let d=new O;mc(d,6,6,ic,s,l,i),c.addChild(d),c.__csFillGraphics=d;let f=new O;cc(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 A;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]??j.EMPTY)}).catch(()=>{})}else{let e=qo[t]??7979263,n=Bs[t]??16777215,r=new O;r.circle(6,6,Hs),r.fill(e),c.addChild(r);let i=new ae({text:t,style:{fontSize:Us,fill:n,fontWeight:`bold`}});i.anchor.set(.5,.5),i.scale.set(Ws),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 A;n.anchor.set(.5,.5),n.x=6,n.y=6,i!==void 0&&(n.tint=i),t&&(n.alpha=Vs),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]??j.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 A;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 A;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,Vu(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]??j.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]??j.EMPTY;for(let e of l)e.destroyed||(e.texture=t)}).catch(()=>{})}else{let e=new O,i=[];for(let e=0;e<8;e++){let t=-Math.PI/2+e*Math.PI/4;i.push(6+Lu*Math.cos(t),6+Lu*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 O;Bu(a,6,6,Ru,zu,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 O;if(d?(p.circle(6,6,zu),p.fill(G)):(p.circle(6,6,zu),p.fill(3028031),p.circle(6,6,zu),p.stroke({width:12*.04,color:8027781}),p.circle(6,6,12*.16),p.fill(10133672)),c.addChild(p),d&&i){let e=new A;e.anchor.set(.5,.5),e.width=zu*2,e.height=zu*2,e.position.set(6,6);let t=new O;t.circle(6,6,zu),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(Wo);break;case`road`:break;case`constructedWall`:break;case`rampart`:break;case`tower`:{let{energy:t,capacity:n}=Mc(e),r=o?.tower;if(r&&s){let e=12*r.tileScale,i=new A;i.anchor.set(.5,.5),i.position.set(6,6),i.tint=f,c.addChild(i);let a=new M;a.position.set(6,6),c.addChild(a);let l=new A;l.anchor.set(.5,.5),a.addChild(l);let u=new O;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},nl(c,tl(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]??j.EMPTY),!l.destroyed){let t=e.textures[r.bodyFrame]??j.EMPTY;l.texture=t,c.destroyed||d(t)}}).catch(()=>{});break}let i=new O;i.circle(6,6,12*.6),i.fill(G),i.circle(6,6,12*.6),i.stroke({width:12*.05,color:f}),c.addChild(i);let a=new M;a.position.set(6,6);let l=new O;l.rect(Vc,Hc,Uc,Wc),l.fill(G),a.addChild(l);let u=new O;a.addChild(u),c.__towerFillGraphics=u,c.__towerEnergy=t,c.__towerCapacity=n,nl(c,tl(t,n));let d=new O;d.rect(Vc,Hc,Uc,Wc),d.stroke({width:1,color:Vo}),a.addChild(d);let p=new O;p.rect(-12*.2,-12*.9,12*.4,12*.5),p.fill(Ho),p.rect(-12*.2,-12*.9,12*.4,12*.5),p.stroke({width:12*.07,color:G}),a.addChild(p),c.addChild(a),c.__barrelContainer=a;break}case`storage`:{let t=o?.sprites.storage;if(t&&s){let{bands:n,used:r,capacity:i}=cl(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 A;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]??j.EMPTY)}).catch(()=>{})}let u=new O;c.addChild(u),c.__storageFillG=u,c.__storageBands=n,c.__storageUsed=r,c.__storageCapacity=i,ml(c,pl(r,i));break}let{bands:n,used:r,capacity:i}=cl(e),a=xc(6,6,[[-.6,-.7],[0,-.8],[.6,-.7],[.65,0],[.6,.7],[0,.8],[-.6,.7],[-.65,0],[-.6,-.7]]);l.poly(a),l.fill(G),l.poly(a),l.stroke({width:12*.05,color:f}),l.rect(6-12*.5,6-12*.6,12,12*1.2),l.fill(Vo),c.addChild(l);let u=new O;c.addChild(u),c.__storageFillG=u,c.__storageBands=n,c.__storageUsed=r,c.__storageCapacity=i,ml(c,pl(r,i));let d=new O;d.rect(6-12*.5,6-12*.6,12,12*1.2),d.stroke({width:12*.1,color:G}),c.addChild(d);break}case`terminal`:{let t=xc(6,6,[[0,-.8],[.55,-.55],[.8,0],[.55,.55],[0,.8],[-.55,.55],[-.8,0],[-.55,-.55],[0,-.8]]),n=xc(6,6,[[0,-.65],[.45,-.45],[.65,0],[.45,.45],[0,.65],[-.45,.45],[-.65,0],[-.45,-.45],[0,-.65]]);l.poly(t),l.fill(G),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(Ho),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.fill(Vo),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.stroke({width:12*.1,color:G}),c.addChild(l);let{used:r,capacity:i,dominant:a}=cl(e),o=new O;c.addChild(o);let s=c;s.__terminalFillG=o,s.__terminalDominant=a??void 0,s.__terminalFillColor=a?hl(a):Wo,s.__terminalUsed=r,s.__terminalCapacity=i,vl(s,gl(r,i));let u=new O;Sl(u,6,6),u.alpha=0,c.addChild(u),s.__terminalCooldownG=u,s.__terminalCooldownTime=Rl(e);break}case`link`:{let t=xc(6,6,[[0,-.5],[.4,0],[0,.5],[-.4,0],[0,-.5]]),n=xc(6,6,[[0,-.3],[.25,0],[0,.3],[-.25,0],[0,-.3]]);l.poly(t),l.fill(G),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(Vo),c.addChild(l);let{energy:r,capacity:i}=Mc(e),a=new O;c.addChild(a);let o=c;o.__linkFillGraphics=a,o.__linkEnergy=r,o.__linkCapacity=i,Rc(o,Lc(r,i));break}case`lab`:{let t=6-12*.025;l.circle(6,t,12*.55),l.fill(G),l.circle(6,t,12*.55),l.stroke({width:12*.05,color:f}),l.circle(6,t,12*.4),l.fill(Vo),c.addChild(l);let{energy:n,energyCap:r,mineralType:i,mineral:a,mineralCap:o}=zl(e),s=new O;c.addChild(s);let u=new O;u.rect(6-12*.45,9.6,12*.9,12*.25),u.fill(G),u.poly(xc(6,6,[[-.45,.3],[-.45,.55],[.45,.55],[.45,.3]])),u.stroke({width:12*.05,color:f}),c.addChild(u);let d=new O;c.addChild(d);let p=c;p.__labMineralG=s,p.__labEnergyG=d,p.__labMineralType=i??void 0,p.__labMineralColor=i?hl(i):void 0,p.__labEnergy=n,p.__labEnergyCap=r,p.__labMineral=a,p.__labMineralCap=o,Bl(p,gl(n,r),gl(a,o));let m=new O;Ll(m,6,t),m.alpha=0,c.addChild(m),p.__labCooldownG=m,p.__labCooldownTime=Rl(e);break}case`container`:{let{bands:t,used:n,capacity:r}=cl(e);l.rect(Qc,$c,Xc,Zc),l.fill(G),l.rect(Qc+el,$c+el,Xc-el*2,Zc-el*2),l.fill(Vo),c.addChild(l);let i=new O;c.addChild(i),c.__containerFillG=i,c.__containerBands=t,c.__containerUsed=n,c.__containerCapacity=r,fl(c,dl(n,r));let a=new O;a.rect(Qc,$c,Xc,Zc),a.stroke({width:12*.1,color:G}),c.addChild(a);break}case`observer`:l.circle(6,6,12*.45),l.fill(G),l.circle(6,6,12*.45),l.stroke({width:12*.05,color:f}),l.circle(8.7,6,12*.2),l.fill(f);break;case`nuker`:{let t=xc(6,6,[[0,-1],[-.47,.2],[-.5,.5],[.5,.5],[.47,.2],[0,-1]]),n=xc(6,6,[[0,-.8],[-.4,.2],[.4,.2],[0,-.8]]);l.poly(t),l.fill(G),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(Vo),l.poly(n),l.stroke({width:12*.01,color:f}),c.addChild(l);let{energy:r,energyCap:i,ghodium:a,ghodiumCap:o}=Xl(e),s=new O;c.addChild(s);let u=new O;c.addChild(u);let d=c;d.__nukerEnergyG=s,d.__nukerGhodiumG=u,d.__nukerEnergy=r,d.__nukerEnergyCap=i,d.__nukerGhodium=a,d.__nukerGhodiumCap=o,Zl(d,gl(r,i),gl(a,o));break}case`factory`:{let t=typeof e.level==`number`?e.level:0,{bands:n,used:r,capacity:i}=cl(e),a=new O;Nu(a,f),c.addChild(a),l.rect(Eu,Du,wu,Tu),l.fill(Vo),c.addChild(l);let o=new O;Pu(o,t),c.addChild(o);let s=new O;c.addChild(s);let u=c;u.__factoryGearG=a,u.__factoryRingG=o,u.__factoryFillG=s,u.__factoryBands=n,u.__factoryUsed=r,u.__factoryCapacity=i,u.__factoryLevel=t,u.__factoryCooldownEnd=Rl(e),u.__factoryGlowColor=f,Iu(u,Fu(r,i));break}case`extractor`:{let t=new O;t.position.set(6,6),pc(t,d===void 0?so:f),c.addChild(t);let n=c;n.__extractorRing=t,n.__extractorActive=Mu(e);break}case`invaderCore`:l.circle(6,6,12*.45),l.fill(G),l.circle(6,6,12*.45),l.stroke({width:12*.05,color:f}),l.circle(6,6,12*.35),l.fill(Vo);break;case`flag`:{let n=typeof e.color==`number`?e.color:0,r=typeof e.secondaryColor==`number`?e.secondaryColor:0,i=_o[n]??_o[0],a=_o[r]??_o[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 A;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]??j.EMPTY)}).catch(()=>{}),r!==n){let e=new A;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]??j.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 ae({text:e.name,style:{fontSize:ws,fill:16777215}});n.scale.set(Ts),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?Ao:go,i=12*.42,a=Math.PI/5,o=new O;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 O;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?Ao:go,i=o?.tombstone;if(i&&s){let e=12*i.tileScale,t=()=>s.getOrLoad(o.atlasUrl),n=new A;n.anchor.set(.5,.5),n.x=6,n.y=6,n.width=e,n.height=e,c.addChild(n);let a=new A;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]??j.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]??j.EMPTY)}).catch(()=>{})}else{let e=12*.62,t=6-e/2,n=e/2,i=new O;i.moveTo(t,4.8),i.arc(6,4.8,n,Math.PI,0,!1),i.lineTo(9.719999999999999,10.92),i.lineTo(t,10.92),i.closePath(),i.fill(G),i.moveTo(t,4.8),i.arc(6,4.8,n,Math.PI,0,!1),i.lineTo(9.719999999999999,10.92),i.lineTo(t,10.92),i.closePath(),i.stroke({width:12*.07,color:r,alpha:.9}),c.addChild(i);let a=12*.18,o=new O;o.moveTo(6-a,6-a*.6),o.lineTo(8.16,7.296),o.moveTo(8.16,6-a*.6),o.lineTo(6-a,7.296),o.stroke({width:12*.09,color:r,cap:`round`}),c.addChild(o)}break}case`powerBank`:{let t=new O,n=[];for(let e=0;e<pu.length;e+=2)n.push(6+pu[e]*au,6+pu[e+1]*au);t.poly(n),t.fill(su),t.poly(n),t.stroke({width:ou,color:cu}),c.addChild(t);let r=mu(e),i=hu(r),a=new O;_u(a,i,performance.now()),c.addChild(a);let o=c;o.__powerBankEllipseG=a,o.__powerBankPower=r,o.__powerBankRadius=i;break}default:l.rect(1,1,10,10),l.fill(u)}if(e.type!==`extension`&&e.type!==`road`&&e.type!==`creep`&&e.type!==`tower`&&e.type!==`controller`&&e.type!==`flag`&&e.type!==`source`&&e.type!==`constructionSite`&&e.type!==`mineral`&&e.type!==`tombstone`&&e.type!==`ruin`&&e.type!==`storage`&&e.type!==`constructedWall`&&e.type!==`rampart`&&e.type!==`container`&&e.type!==`deposit`&&e.type!==`link`&&e.type!==`terminal`&&e.type!==`lab`&&e.type!==`nuker`&&e.type!==`factory`&&e.type!==`powerBank`&&c.addChild(l),e.type===`creep`&&typeof e.name==`string`){let r=Hu(e,n),i;if(r){let t=typeof e.user==`string`?e.user:void 0;i=Wu(e,a)?`Invader`:t?a?.[t]?.username??t:`Hostile`}else i=e.name;let o=new ae({text:i,style:{fontSize:ws,fill:r?go:16777215}});o.scale.set(Ts),o.anchor.set(.5,1),o.x=6,o.y=Es-Ds,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`?fc:o?.sprites[e.type]?.zIndex??0),c.position.set(e.x*12,e.y*12),c}function Ku(e){e.destroy({children:!0})}function qu(e){let t=new ae({text:e.length>Ps?e.slice(0,Ps):e,style:{fontSize:ws,fill:Is,fontWeight:`600`}});t.scale.set(Os),t.anchor.set(.5,.5);let n=t.width,r=t.height,i=n+ks*2,a=r+As*2,o=a/2,s=new O;s.roundRect(-i/2,-a/2,i,a,o),s.fill(Fs),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+Ms),s.lineTo(js,a/2-.1),s.closePath(),s.fill(Fs),s.moveTo(-2,a/2-.1),s.lineTo(0,a/2+Ms),s.lineTo(js,a/2-.1),s.stroke({width:.4,color:1118481,alpha:.55});let c=new M;return c.addChild(s),c.addChild(t),c.pivot.set(0,a/2+Ms),c}var Ju=class{container;objects=new Map;rawObjects=new Map;roadGraphics;rampartGraphics;rampartGlowGraphics;wallGraphics;wallMarkGraphics;ticker=null;tickerCallback=null;fillAnimations=new Map;buildGlowAnimations=new Map;ctrlFlashAnimations=new Map;currentGameTime=0;sayBubbles=new Set;moveDuration=600;tickMs=2e3;lastTickAt=0;EXT_ANIM_DURATION=300;instantMode=!1;lastWorldScale=1;showLabels;currentUserId;badge;badgeCache=bs;users;activeTheme=null;atlasCache=null;roadColor=ho;lighting=null;constructor(e,t=!0,n,r,i){this.showLabels=t,this.currentUserId=n,this.badge=r,this.users=i,this.container=new M,this.container.sortableChildren=!0,this.wallGraphics=new O,this.wallGraphics.zIndex=-3,this.container.addChild(this.wallGraphics),this.wallMarkGraphics=new O,this.wallMarkGraphics.zIndex=-2,this.container.addChild(this.wallMarkGraphics),this.rampartGraphics=new O,this.rampartGraphics.zIndex=150,this.container.addChild(this.rampartGraphics),this.rampartGlowGraphics=new O,this.rampartGlowGraphics.zIndex=149,this.rampartGlowGraphics.filters=[new ce({strength:3,quality:3})],this.container.addChild(this.rampartGlowGraphics),this.roadGraphics=new O,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/oc),o=Math.min(1,(r-this.lastTickAt)/this.tickMs),s=Math.sin(o*Math.PI);for(let e of this.objects.values()){if(e.__barrelContainer){let t=e.__barrelContainer;e.__towerAimUntil!==void 0&&r<e.__towerAimUntil&&e.__towerAimAngle!==void 0?t.rotation=Yc(t.rotation,e.__towerAimAngle,Kc):(e.__towerAimUntil!==void 0&&(e.__towerIdlePhase=t.rotation-i*Gc,e.__towerAimUntil=void 0,e.__towerAimAngle=void 0),t.rotation=i*Gc+(e.__towerIdlePhase??0))}if(e.__extractorRing){let t=e.__extractorActive===!0;t&&!e.__extractorWasActive&&(e.__extractorPhase=e.__extractorRing.rotation-i*qc),t&&(e.__extractorRing.rotation=i*qc+(e.__extractorPhase??0)),e.__extractorWasActive=t}if(e.__csRingGraphics&&e.__csColorDark!==void 0&&e.__csColorLight!==void 0&&cc(e.__csRingGraphics,sc(e.__csColorDark,e.__csColorLight,a)),e.__factoryGearG){let t=(e.__factoryCooldownEnd??0)>this.currentGameTime;t?Nu(e.__factoryGearG,sc(e.__factoryGlowColor??9419667,ku,.5*a)):e.__factoryWasOnCd&&Nu(e.__factoryGearG,e.__factoryGlowColor??9419667),e.__factoryWasOnCd=t}if(e.__labCooldownG){let t=(e.__labCooldownTime??0)>this.currentGameTime;e.__labCooldownG.alpha=t?s:0}if(e.__terminalCooldownG){let t=(e.__terminalCooldownTime??0)>this.currentGameTime;e.__terminalCooldownG.alpha=t?s:0}}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&&$s(t,e.__sourceSize??Gs,r)}for(let e of this.objects.values()){let t=e.__powerBankEllipseG;t&&_u(t,e.__powerBankRadius??0,r)}for(let[e,t]of this.buildGlowAnimations){let n=this.objects.get(e),i=n?.__csBuildGlow;if(!n||!i){this.buildGlowAnimations.delete(e);continue}let a=(r-t.startTime)/t.duration,o;o=a<=0?0:a<.5?a/.5:a<.7?1:a<1?1-(a-.7)/.3:0,i.clear(),o>0&&(i.circle(12/2,12/2,ac),i.fill({color:Wo,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=ys[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=sc(16777215,sc(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,Bc,Pc(n,r),Pc(i,a))}startLinkAnimation(e,t,n,r,i,a){this.startFill(e,t,Rc,Lc(n,r),Lc(i,a))}startCreepFillAnimation(e,t,n,r,i,a){this.startFill(e,t,Ac,kc(n,r),kc(i,a))}startTowerFillAnimation(e,t,n,r,i,a){this.startFill(e,t,nl,tl(n,r),tl(i,a))}startStorageFillAnimation(e,t,n,r,i,a){this.startFill(e,t,ml,pl(n,r),pl(i,a))}startContainerFillAnimation(e,t,n,r,i,a){this.startFill(e,t,fl,dl(n,r),dl(i,a))}startTerminalFillAnimation(e,t,n,r,i,a){this.startFill(e,t,vl,gl(n,r),gl(i,a))}startFactoryFillAnimation(e,t,n,r,i,a){this.startFill(e,t,Iu,Fu(n,r),Fu(i,a))}startLabFillAnimation(e,t,n,r,i,a,o,s,c,l){this.startFill(e,t,Bl,gl(n,r),gl(o,s),gl(i,a),gl(c,l))}startNukerFillAnimation(e,t,n,r,i,a,o,s,c,l){this.startFill(e,t,Zl,gl(n,r),gl(o,s),gl(i,a),gl(c,l))}startSourceAnimation(e,t,n,r,i,a){this.startFill(e,t,ec,Xs(n,r),Xs(i,a))}startPowerSpawnPowerAnimation(e,t,n,r,i,a){this.startFill(e,t,ru,gl(n,r),gl(i,a))}update(e,t,n,r){n&&(this.users=n),r!==void 0&&(r!==this.currentGameTime&&(this.lastTickAt=performance.now()),this.currentGameTime=r);let i=!1,a=!1,o=!1;if(t)for(let n in t)if(t[n]===null){let e=this.rawObjects.get(n);e&&e.type===`road`&&(i=!0),e&&e.type===`constructedWall`&&(a=!0),e&&e.type===`rampart`&&(o=!0);let t=this.objects.get(n);t&&(this.container.removeChild(t),Ku(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}=Oc(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),Ku(r),this.objects.delete(n);let e=Gu(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}=Mc(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}=Mc(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}=Mc(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}=cl(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 ul(r.__storageBands,e)||(r.__storageBands=e,ml(r,pl(i,a)))}if(t.type===`container`){let{bands:e,used:i,capacity:a}=cl(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 ul(r.__containerBands,e)||(r.__containerBands=e,fl(r,dl(i,a)))}if(t.type===`terminal`){let{used:e,capacity:i,dominant:a}=cl(t),o=a??void 0;if(r.__terminalDominant!==o&&(r.__terminalDominant=o,r.__terminalFillColor=o?hl(o):Wo,vl(r,gl(e,i))),r.__terminalUsed!==e||r.__terminalCapacity!==i){let t=r.__terminalUsed??0,a=r.__terminalCapacity??i;r.__terminalUsed=e,r.__terminalCapacity=i,this.startTerminalFillAnimation(n,r,t,a,e,i)}r.__terminalCooldownTime=Rl(t)}if(t.type===`lab`){let{energy:e,energyCap:i,mineralType:a,mineral:o,mineralCap:s}=zl(t),c=a??void 0;if(r.__labMineralType!==c&&(r.__labMineralType=c,r.__labMineralColor=a?hl(a):void 0,Bl(r,gl(e,i),gl(o,s))),r.__labEnergy!==e||r.__labEnergyCap!==i||r.__labMineral!==o||r.__labMineralCap!==s){let t=r.__labEnergy??0,a=r.__labEnergyCap??i,c=r.__labMineral??0,l=r.__labMineralCap??s;r.__labEnergy=e,r.__labEnergyCap=i,r.__labMineral=o,r.__labMineralCap=s,this.startLabFillAnimation(n,r,t,a,c,l,e,i,o,s)}r.__labCooldownTime=Rl(t)}if(t.type===`nuker`){let{energy:e,energyCap:i,ghodium:a,ghodiumCap:o}=Xl(t);if(r.__nukerEnergy!==e||r.__nukerEnergyCap!==i||r.__nukerGhodium!==a||r.__nukerGhodiumCap!==o){let t=r.__nukerEnergy??0,s=r.__nukerEnergyCap??i,c=r.__nukerGhodium??0,l=r.__nukerGhodiumCap??o;r.__nukerEnergy=e,r.__nukerEnergyCap=i,r.__nukerGhodium=a,r.__nukerGhodiumCap=o,this.startNukerFillAnimation(n,r,t,s,c,l,e,i,a,o)}}if(t.type===`powerSpawn`){let{power:e,powerCap:i}=tu(t);if(r.__powerSpawnPower!==e||r.__powerSpawnPowerCap!==i){let t=r.__powerSpawnPower??0,a=r.__powerSpawnPowerCap??i;r.__powerSpawnPower=e,r.__powerSpawnPowerCap=i,this.startPowerSpawnPowerAnimation(n,r,t,a,e,i)}}if(t.type===`extractor`&&(r.__extractorActive=Mu(t)),t.type===`factory`){let{bands:e,used:i,capacity:a}=cl(t),o=typeof t.level==`number`?t.level:0;if(r.__factoryLevel!==o&&r.__factoryRingG&&(r.__factoryLevel=o,Pu(r.__factoryRingG,o)),r.__factoryCooldownEnd=Rl(t),r.__factoryUsed!==i||r.__factoryCapacity!==a){let t=r.__factoryUsed??0,o=r.__factoryCapacity??a;r.__factoryBands=e,r.__factoryUsed=i,r.__factoryCapacity=a,this.startFactoryFillAnimation(n,r,t,o,i,a)}else ul(r.__factoryBands,e)||(r.__factoryBands=e,Iu(r,Fu(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),Ku(r),this.objects.delete(n);let e=Gu(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}),Vu(r,e,i,a)):r.__ctrlSegGraphics&&Bu(r.__ctrlSegGraphics,12/2,12/2,Ru,zu,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}=tc(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&&mc(r.__csFillGraphics,12/2,12/2,ic,e,n,r.__csColor??9419667),r.__csProgress=e,r.__csProgressTotal=n)}if(t.type===`powerBank`){let e=mu(t);r.__powerBankPower!==e&&(r.__powerBankPower=e,r.__powerBankRadius=hu(e))}}else{let e=Gu(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}=Oc(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),Ku(i),this.objects.delete(n);let e=Gu(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}=Mc(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}=Mc(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}=Mc(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),Ku(i),this.objects.delete(n);let e=Gu(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}),Vu(i,e,t,a)):i.__ctrlSegGraphics&&Bu(i.__ctrlSegGraphics,12/2,12/2,Ru,zu,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}=tc(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&&mc(i.__csFillGraphics,12/2,12/2,ic,e,t,i.__csColor??9419667),i.__csProgress=e,i.__csProgressTotal=t)}if(r.type===`powerBank`){let e=typeof r.power==`number`?r.power:0;i.__powerBankPower!==e&&(i.__powerBankPower=e,i.__powerBankRadius=hu(e))}}else{let e=Gu(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),Ku(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?vc(n):null;if(r!==t.__spawnSig){t.__spawnSig=r;let e=n&&r?_c(n,this.currentGameTime):null;t.__spawnNeedTime=e?.needTime,t.__spawnEndTime=e?.endTime}let i=t.__spawnNeedTime!==void 0&&t.__spawnEndTime!==void 0?yc(t.__spawnNeedTime,t.__spawnEndTime,this.currentGameTime):null;i!==t.__spawnRatio&&(bc(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(G);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:Yo,alpha:.4}:{color:Zo,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,Xo),i(r,Qo)}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(Ts/t),e.__nameLabel.anchor.y===0?e.__nameLabel.y=12.600000000000001:e.__nameLabel.y=Es-Ds/t),e.__sayBubble&&!e.__sayBubble.destroyed&&(e.__sayBubble.scale.set(1/t),e.__sayBubble.position.set(12/2,Es-Ns/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||!Hu(n,this.currentUserId))continue;let r=typeof n.user==`string`?n.user:void 0,i=Wu(n,this.users)?`Invader`: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`||!Hu(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 A;o.anchor.set(.5,.5);let s=Ss*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)+Jc,i.__towerAimUntil=performance.now()+r)}triggerSay(e,t){let n=this.objects.get(e);if(!n||n.__sayMessage===t&&n.__sayBubble&&!n.__sayBubble.destroyed)return;n.__sayBubble&&!n.__sayBubble.destroyed&&(n.removeChild(n.__sayBubble),n.__sayBubble.destroy({children:!0}));let r=qu(t);n.addChild(r),n.__sayBubble=r,n.__sayMessage=t,this.applyLabelScale(n),this.sayBubbles.add(e)}setMoveDuration(e){this.moveDuration=Math.max(0,e)}setTickDuration(e){this.tickMs=Math.max(1,e)}pruneSayBubblesExcept(e){if(this.sayBubbles.size!==0)for(let t of this.sayBubbles){if(e.has(t))continue;let n=this.objects.get(t);n?.__sayBubble&&!n.__sayBubble.destroyed&&(n.removeChild(n.__sayBubble),n.__sayBubble.destroy({children:!0})),n&&(n.__sayBubble=void 0,n.__sayMessage=void 0),this.sayBubbles.delete(t)}}setInstantMode(e){if(this.instantMode=e,e){for(let e of this.objects.values())e.__targetX!==void 0&&(e.position.set(e.__targetX,e.__targetY),e.__targetX=void 0,e.__targetY=void 0,e.__moveStartX=void 0,e.__moveStartY=void 0,e.__moveStartT=void 0,e.__moveDur=void 0),e.__sayBubble&&!e.__sayBubble.destroyed&&(e.removeChild(e.__sayBubble),e.__sayBubble.destroy({children:!0}),e.__sayBubble=void 0,e.__sayMessage=void 0);this.sayBubbles.clear();for(let e of this.fillAnimations.values())e.apply(e.visual,e.toA,e.toB);this.fillAnimations.clear(),this.buildGlowAnimations.clear(),this.ctrlFlashAnimations.clear()}}setShowLabels(e){this.showLabels=e;for(let t of this.objects.values())t.__nameLabel&&(t.__nameLabel.visible=e)}getVisualById(e){return this.objects.get(e)}clear(){for(let e of this.objects.values())Ku(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}},Yu=2,Xu=3,Zu=12*.45,Qu=.55;function $u(e,t){return{cx:e*12+12/2,cy:t*12+12/2}}var ed=class{container;graphics;animations=[];ticker=null;tickerCallback=null;constructor(e){this.container=new M,this.graphics=new O,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=$u(e,t),o=$u(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:bo,width:Yu,glowAtSource:!0})}addUpgradeController(e,t,n,r,i){let a=$u(e,t),o=$u(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:xo,width:Yu})}addTransfer(e,t,n,r,i){let a=$u(e,t),o=$u(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:wo,width:Yu})}addBuild(e,t,n,r,i){let a=$u(e,t),o=$u(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:So,width:Yu})}addRepair(e,t,n,r,i){let a=$u(e,t),o=$u(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Co,width:Yu})}addLinkTransfer(e,t,n,r,i){let a=$u(e,t),o=$u(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:To,width:Yu})}addLabReaction(e,t,n,r,i){let a=$u(e,t),o=$u(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:ko,width:Yu})}addTowerBeam(e,t,n,r,i,a){let o=$u(e,t),s=$u(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:Xu})}addTowerAttack(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,Eo)}addTowerHeal(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,Do)}addTowerRepair(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,Oo)}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)*Qu,n=r.width/Yu*Zu*(.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()}},td=e=>(e+.5)*12,nd={dashed:[.3*12,.25*12],dotted:[.1*12,.2*12]},rd=2400;function id(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 ad(e){if(typeof e!=`string`)return`sans-serif`;let t=e.match(/^[0-9.]+(px)?\s+(.+)$/);return t?t[2]:`sans-serif`}var od=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=j.from(this.canvas,!0),this.lastPhysSize=r,this.sprite=new A(this.texture),this.sprite.scale.set(600/r),this.container=new M,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),rd)}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=j.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`?nd.dotted:t.lineStyle===`dashed`?nd.dashed:[]),r.beginPath(),r.moveTo(td(e.x1),td(e.y1)),r.lineTo(td(e.x2),td(e.y2)),r.stroke(),r.restore()}drawCircle(e,t,n){let{ctx:r}=this;r.save(),r.globalAlpha=n,r.setLineDash(t.lineStyle===`dotted`?nd.dotted:t.lineStyle===`dashed`?nd.dashed:[]),r.beginPath(),r.arc(td(e.x),td(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`?nd.dotted:t.lineStyle===`dashed`?nd.dashed:[]),r.beginPath(),r.rect(td(e.x),td(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`?nd.dotted:t.lineStyle===`dashed`?nd.dashed:[]),r.beginPath(),r.moveTo(td(e.points[0][0]),td(e.points[0][1]));for(let t=1;t<e.points.length;t++)r.lineTo(td(e.points[t][0]),td(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=id(t.font)*12,a=ad(t.font),o=t.align??`left`,s=td(e.x),c=td(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 sd(e,t){let n=localStorage.getItem(e),[r,i]=a(n===null?t:n===`true`);return[r,t=>{i(t),localStorage.setItem(e,String(t))}]}function cd(e,t){let[n,r]=a(localStorage.getItem(e)??t);return[n,t=>{r(t),localStorage.setItem(e,t)}]}var[ld,ud]=sd(V.widescreenMode,!0),[dd,fd]=sd(V.showCreepLabels,!0),[pd,md]=sd(V.showMapRoomNames,!1),[hd,gd]=sd(V.showUnclaimableRooms,!0),[_d,vd]=sd(V.terrainEffects,!0),[yd,bd]=sd(V.showRoomDecorations,!1),[xd,Sd]=sd(V.roomDarkOverlay,!0),[Cd,wd]=sd(V.showRoomVisuals,!0),[Td,Ed]=cd(V.spriteTheme,`default`),[Dd,Od]=sd(V.showMapVisuals,!0),kd=en(),Ad=kd?`?v=${encodeURIComponent(kd)}`:``,jd={id:`default`,name:`Default`,atlasUrl:`${nn()}/themes/default/sprite-0.json${Ad}`,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}}},Md=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=ee.load(e).then(t=>(this.cache.set(e,t),this.frames.set(e,Nd(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 Nd(e){let t={...e.textures};for(let n of e.linkedSheets??[])Object.assign(t,n.textures);return t}var Pd=new Md,Fd=Symbol(`store-raw`),Id=Symbol(`store-node`),Ld=Symbol(`store-has`),Rd=Symbol(`store-self`),zd={onStoreNodeUpdate:null};function Bd(e){let t=e[l];if(!t&&(Object.defineProperty(e,l,{value:t=new Proxy(e,Jd)}),!Array.isArray(e))){let n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),a=i!==null&&typeof e==`object`&&!!e&&!Array.isArray(e)&&i!==Object.prototype;if(a){let e=Object.getOwnPropertyDescriptors(i);n.push(...Object.keys(e)),Object.assign(r,e)}for(let i=0,o=n.length;i<o;i++){let o=n[i];a&&o===`constructor`||r[o].get&&Object.defineProperty(e,o,{configurable:!0,enumerable:r[o].enumerable,get:r[o].get.bind(t)})}}return t}function Vd(e){let t;return typeof e==`object`&&!!e&&(e[l]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function Hd(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[Fd])return n;if(!Vd(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let n=0,a=e.length;n<a;n++)i=e[n],(r=Hd(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=Hd(i,t))!==i&&(e[a]=r))}return e}function Ud(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Wd(e,t,n){if(e[t])return e[t];let[r,i]=a(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function Gd(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===l||t===Id?n:(delete n.value,delete n.writable,n.get=()=>e[l][t],n)}function Kd(e){t()&&Wd(Ud(e,Id),Rd)()}function qd(e){return Kd(e),Reflect.ownKeys(e)}var Jd={get(e,n,r){if(n===Fd)return e;if(n===l)return r;if(n===g)return Kd(e),r;let i=Ud(e,Id),a=i[n],o=a?a():e[n];if(n===Id||n===Ld||n===`__proto__`)return o;if(!a){let r=Object.getOwnPropertyDescriptor(e,n);t()&&(typeof o!=`function`||e.hasOwnProperty(n))&&!(r&&r.get)&&(o=Wd(i,n,o)())}return Vd(o)?Bd(o):o},has(e,n){return n===Fd||n===l||n===g||n===Id||n===Ld||n===`__proto__`?!0:(t()&&Wd(Ud(e,Ld),n)(),n in e)},set(){return console.warn(`Cannot mutate a Store directly`),!0},deleteProperty(){return console.warn(`Cannot mutate a Store directly`),!0},ownKeys:qd,getOwnPropertyDescriptor:Gd};function Yd(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;zd.onStoreNodeUpdate&&zd.onStoreNodeUpdate(e,t,n,i),n===void 0?(delete e[t],e[Ld]&&e[Ld][t]&&i!==void 0&&e[Ld][t].$()):(e[t]=n,e[Ld]&&e[Ld][t]&&i===void 0&&e[Ld][t].$());let o=Ud(e,Id),s;if((s=Wd(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=Wd(o,`length`,a))&&s.$(e.length)}(s=o[Rd])&&s.$()}function Xd(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];Zd(i)||Yd(e,i,t[i])}}function Zd(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function Qd(e,t){if(typeof t==`function`&&(t=t(e)),t=Hd(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&&Yd(e,n,r)}Yd(e,`length`,r)}else Xd(e,t)}function $d(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&&Zd(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++)$d(e,[r[i]].concat(t),n);return}else if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&$d(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)$d(e,[r].concat(t),n);return}else if(t.length>1){$d(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=Hd(a),r===void 0||Vd(i)&&Vd(a)&&!Array.isArray(a)?Xd(i,a):Yd(e,r,a))}function ef(...[e,t]){let n=Hd(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=Bd(n);b.registerGraph({value:n,name:t&&t.name});function a(...e){p(()=>{r&&e.length===1?Qd(n,e[0]):$d(n,e)})}return[i,a]}var tf=Symbol(`store-root`);function nf(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function rf(e,t,n,r,i){if(nf(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==tf&&(!Vd(e)||!Vd(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){Yd(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++)rf(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++)Yd(a,n,e[n]);for(;n<e.length;n++)Yd(a,n,f[n]),rf(e[n],a,n,r,i);a.length>e.length&&Yd(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?(Yd(a,n,f[n]),rf(e[n],a,n,r,i)):Yd(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)rf(e[t],a,t,r,i);a.length>e.length&&Yd(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)nf(s[t])||rf(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&&Yd(a,c[t],void 0)}function af(e,t={}){let{merge:n,key:r=`id`}=t,i=Hd(e);return e=>{if(!Vd(e)||!Vd(i))return i;let t=rf(i,{[tf]:e},tf,n,r);return t===void 0?e:t}}var of=new WeakMap;function sf(e,t){let[n,r]=ef(t),i={id:e,type:t.type,raw:n};return of.set(i,e=>r(af(e,{key:`_id`,merge:!1}))),i}var[cf,lf]=a([]);function uf(){lf([])}function df(e){lf(t=>t.filter(t=>t.id!==e))}function ff(e,t){let n=cf(),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&&of.get(a)?.(e)}i.push(a)}r&&lf(i)}function pf(e){let t=cf();if(t.length===0)return;let n=!1,r=[];for(let i of t){let t=e[i.id];if(!t){n=!0;continue}of.get(i)?.(t),r.push(i)}n&&lf(r)}var[mf,hf]=a(null),[gf,_f]=a(null),[vf,yf]=a(null),[bf,xf]=a(null),[Sf,Cf]=a(null),[wf,Tf]=a({}),[Ef,Df]=a(null),[Of,kf]=a(null),[Af,jf]=a(null);function Mf(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 Nf(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 Pf(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 Ff(e){return e===0||e<0&&(e+1)%10==0||e>0&&e%10==0}function If(e,t){return Ff(e)||Ff(t)}function Lf(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 Rf(e){let t=e;if(!t)return!1;let n=t.tagName??``;return n===`INPUT`||n===`TEXTAREA`?!0:t.isContentEditable===!0}function zf(e){let t=t=>{if(Rf(t.target))return;let n=e.currentRoom(),r=n?Nf(n):null;if(!r)return;let i=e.worldBounds(),a=(e,t)=>!i||Mf(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),n(()=>window.removeEventListener(`keydown`,t))}var[K,Bf]=a(!1),[Vf,Hf]=a(0),[Uf,Wf]=a(0),[Gf,Kf]=a(0),[qf,Jf]=a(!1),[Yf,Xf]=a(1),[Zf,Qf]=a(!1),$f=null;function ep(){$f!==null&&(clearInterval($f),$f=null)}function tp(){ep(),$f=setInterval(()=>{let e=Vf()+1;e>Gf()?(ep(),Jf(!1)):Hf(e)},Math.max(50,Math.round(1e3/Yf())))}function np(e){let t=e,n=Math.max(0,t-2e5);Kf(t),Wf(n),Hf(e),Jf(!1),ep(),Bf(!0)}function rp(){ep(),Jf(!1),Bf(!1)}function ip(e){Hf(Math.max(Uf(),Math.min(Gf(),e)))}function ap(e){ip(Vf()+e)}function op(){qf()?(ep(),Jf(!1)):(Jf(!0),tp())}function sp(e){Xf(e),qf()&&tp()}var cp=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}}},lp=P(`<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`),up=P(`<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`),dp=P(`<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`),fp=P(`<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`),pp=P(`<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`),mp=P(`<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:hp,warn:gp,error:_p}=rn(`build`),vp={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},yp={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}},[bp,xp]=a(`view`),[Sp,Cp]=a({name:``,color:`COLOR_WHITE`,secondaryColor:`COLOR_WHITE`}),[wp,Tp]=a(null),[Ep,Dp]=a(null),[Op,kp]=a({structureType:``,structureName:``});C(()=>{s(()=>{let e=Op().structureType;if(!e)return;let t=vf()??0,n=yp[e];if(!n)return;let r=Rn()===`empty`&&e===`spawn`?Math.max(n[t]??0,1):n[t]??0;r!==2500&&(wf()[e]??0)>=r&&(kp({structureType:``,structureName:``}),Ap())})});function Ap(){Tp(null)}function jp(){Dp(null)}function Mp(){kp({structureType:``,structureName:``})}function Np(e,t){let n=H(),r=Op(),i=wp();if(!n||!r.structureType||!i){gp(`missing requirements`,{hasClient:!!n,structureType:r.structureType,pending:i});return}if(Rn()===`empty`&&r.structureType===`spawn`){hp(`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(()=>(hp(`spawn placed`),B(`Spawn placed successfully`,`success`),Ap(),n.stores.user.refreshWorldStatus())).catch(e=>{_p(`place spawn failed:`,e),B(`Failed to place spawn: ${e.message}`,`error`)});return}hp(`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(()=>{hp(`construction site created`),B(`Construction site for ${r.structureType} created`,`success`),Ap()}).catch(e=>{_p(`create construction failed:`,e),B(`Failed to create construction site: ${e.message}`,`error`)})}function Pp(){xp(`view`),Ap(),jp(),Mp()}function Fp(){xp(`view`),Ap(),m(Ep)?.type!==`moveFlag`&&jp(),Mp()}function Ip(){let e=bp(),t=wp(),n=Ep(),r=Rn();if(r===`empty`)return(()=>{var e=lp(),t=e.firstChild.nextSibling;return t.$$click=()=>{xp(`build`),kp({structureType:`spawn`,structureName:``})},e})();if(r===`lost`)return(()=>{var e=up(),t=e.firstChild.nextSibling;return t.$$click=()=>{let e=H();e&&e.http.user.respawn().then(()=>{B(`Respawn successful`,`success`),qn()}).catch(e=>{B(`Respawn failed: ${e.message}`,`error`)})},e})();if(n?.type===`moveFlag`)return(()=>{var e=dp(),t=e.firstChild,r=t.firstChild.nextSibling;return r.nextSibling,t.nextSibling,z(t,()=>n.name,r),z(t,()=>n.targetRoom,null),e})();if(e===`flag`)return(()=>{var e=fp(),n=e.firstChild;return n.nextSibling,z(n,t?`Click again to confirm position`:`Click to choose flag position`),e})();if(e===`build`){let e=Op(),t=vf(),n=wf(),r=e.structureType;if(!r)return(()=>{var e=pp();return e.firstChild.nextSibling.nextSibling,e})();let i=yp[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=mp(),t=e.firstChild;return t.nextSibling.nextSibling,z(t,`Click to build ${o} (${s})`),e})()}return null}F([`click`]);var Lp=P(`<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>`),Rp=P(`<div style=width:100%;height:100%;position:relative><div style=width:100%;height:100%>`),zp=P(`<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">`),Bp=P(`<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:Vp,error:Hp}=rn(`room`);function Up(e,t,n=4){e.http.game.genUniqueFlagName().then(r=>{if(r.name===t&&n>0){setTimeout(()=>Up(e,t,n-1),200);return}Cp(e=>({...e,name:r.name}))}).catch(e=>Hp(`gen unique flag name failed:`,e))}function Wp(e){let t=e=>e==="default"?jd:null,r,o=null,c=null,l=null,u=null,d=null,[p,h]=a(null),[g,_]=a(null),[y,b]=a(null),[x,S]=a(null),[C,T]=a(``),[E,D]=a(Vf());s(()=>D(Vf()));let O=null;return i(async()=>{r&&h(await Xa.create(r))}),n(()=>{O!==null&&clearTimeout(O),o?.destroy(),o=null,l?.destroy(),l=null,u?.destroy(),u=null;let e=p();e&&e.destroy()}),s(()=>{let t=H();if(!t||K())return;let r=e.room,i=e.shard;Vp(`navigate → ${r} (shard=${i??`default`})`),_(null),b(null),S(null),T(``),Dn(null),uf(),jf(r),kf(i),hf(null),_f(null),yf(null),xf(null),Cf(null),Tf({}),Df(null);let a=new Et,o=!1;t.stores.room.terrain(r,i).then(e=>{o||(Vp(`terrain loaded — ${r}`),_({room:r,data:e}))}).catch(e=>{o||Hp(`terrain load failed for ${r}:`,e)}),m(yd)&&t.http.game.roomDecorations(r,i).then(e=>{o||(Vp(`decorations loaded — ${r}: ${e.decorations.length} item(s)`),b({room:r,decoration:hs(e)}))}).catch(e=>{o||Vp(`no decorations for ${r}: ${e}`)}),a.add(t.stores.room.subscribe(r,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,n={},i=0,a=null,o=null,s=null;for(let r in e.objects){t++;let c=e.objects[r];if(!c)continue;let l=c.type;if(typeof l==`string`)if(l===`constructionSite`){let e=c.structureType;typeof e==`string`&&(n[e]=(n[e]||0)+1)}else n[l]=(n[l]||0)+1;if(l===`controller`){if(typeof c.user==`string`){let t=c.user;o={userId:t,username:e.users?.[t]?.username??t},typeof c.level==`number`&&(i=c.level),typeof c.progress==`number`&&(a=c.progress)}let t=c.reservation;t&&typeof t.user==`string`&&typeof t.endTime==`number`&&(s={user:t.user,endTime:t.endTime})}}e.diff||Vp(`objects loaded — ${r}: ${t} objects, tick=${e.gameTime}`),S({objects:e.objects,diff:e.diff,users:e.users}),T(e.visual),Dn(e.gameTime??null),Qn(e.gameTime),hf(t),_f(o),yf(i||null),xf(a),Cf(s),Tf(n),Df(e.users??null)})),n(()=>{Vp(`leaving ${r}`),o=!0,a.dispose()})}),s(()=>{let t=H();if(!t||!K())return;T(``);let r=e.room,i=e.shard,a=er()??!0,o=wn()?.serverData?.historyChunkSize??(a?20:100),c=m(Ef)??void 0,l=new cp(r,i,t.http,o);s(()=>{let e=Vf(),t=!1;Qf(!0),l.getStateAtTick(e).then(e=>{if(t)return;if(Qf(!1),e.clampedTo!==void 0){Kf(e.clampedTo),ip(e.clampedTo);return}S({objects:e.objects,diff:void 0,users:c}),Dn(e.gameTime);let n=0,r={},i=0,a=null,o=null,s=null;for(let t in e.objects){n++;let l=e.objects[t];if(!l)continue;let u=l.type;if(typeof u==`string`)if(u===`constructionSite`){let e=l.structureType;typeof e==`string`&&(r[e]=(r[e]||0)+1)}else r[u]=(r[u]||0)+1;if(u===`controller`){if(typeof l.user==`string`){let e=l.user;o={userId:e,username:c?.[e]?.username??e},typeof l.level==`number`&&(i=l.level),typeof l.progress==`number`&&(a=l.progress)}let e=l.reservation;e&&typeof e.user==`string`&&typeof e.endTime==`number`&&(s={user:e.user,endTime:e.endTime})}}hf(n),_f(o),yf(i||null),xf(a),Cf(s),Tf(r)}).catch(n=>{t||(Qf(!1),B(`History load failed for tick ${e}: ${n.message}`,`error`,5e3))}),n(()=>{t=!0})})}),s(()=>{let t=p();if(!t)return;e.room,e.shard,Fp(),t.hoverLayer.clearPendingTile();let n=m(Ep);n?.type===`moveFlag`?Dp({...n,targetRoom:e.room}):t.resetView(),d?.destroy(),d=null,t.clear(),t.resetView(),o?.destroy(),o=null,l?.destroy(),l=null,u?.destroy(),u=null;let r=m(g);if(r&&r.room===e.room){Vp(`terrain applied immediately (pre-loaded) — ${e.room}`);let n=m(y);d=cs(r.data,t.app.renderer,n?.room===e.room?n.decoration.terrain:void 0),ls(d,m(_d)),d.zIndex=Ja.terrain,t.world.addChild(d),t.bringNavOverlayToTop()}let i=e.room,a=e.shard,s=Nf(i),c=m(()=>e.onNavigate),f=m(Pn);if(s&&c){let e=(e,t)=>!f||Mf(e,t,f),n=e=>{Vp(`navigate requested: ${i} → ${e}`),c(e,a)};t.setupNavigationZones({west:e(s.x-1,s.y)?()=>n(Pf(s.x-1,s.y)):void 0,east:e(s.x+1,s.y)?()=>n(Pf(s.x+1,s.y)):void 0,north:e(s.x,s.y-1)?()=>n(Pf(s.x,s.y-1)):void 0,south:e(s.x,s.y+1)?()=>n(Pf(s.x,s.y+1)):void 0})}}),s(()=>{let t=p();if(!t)return;let n=m(()=>e.room),r=m(()=>e.shard),i=Nf(n);if(i&&e.onNavigate){let a=e.onNavigate,o=Pn(),s=(e,t)=>!o||Mf(e,t,o),c=e=>{Vp(`navigate requested: ${n} → ${e}`),a(e,r)};zf({currentRoom:()=>e.room,worldBounds:Pn,onMove:(e,t)=>c(Pf(e,t))}),t.setupNavigationZones({west:s(i.x-1,i.y)?()=>c(Pf(i.x-1,i.y)):void 0,east:s(i.x+1,i.y)?()=>c(Pf(i.x+1,i.y)):void 0,north:s(i.x,i.y-1)?()=>c(Pf(i.x,i.y-1)):void 0,south:s(i.x,i.y+1)?()=>c(Pf(i.x,i.y+1)):void 0})}}),s(()=>{let e=bp(),t=p();e===`view`&&t&&(Ap(),t.hoverLayer.clearPendingTile())}),s(()=>{let e=p(),t=wp();e&&(t?e.hoverLayer.setPendingTile(t.tx,t.ty):e.hoverLayer.clearPendingTile())}),s(()=>{let t=p(),n=g();if(!t||!n||n.room!==e.room)return;if(d?.parent){Vp(`terrain already in scene, skipping — ${e.room}`);return}Vp(`terrain applied (async) — ${e.room}`);let r=m(y);d=cs(n.data,t.app.renderer,r?.room===e.room?r.decoration.terrain:void 0),ls(d,m(_d)),t.world.addChildAt(d,0),t.bringNavOverlayToTop()}),s(()=>{if(yd())return;b(null);let t=m(p),n=m(g);!t||!n||n.room!==e.room||d?.parent&&(d.destroy(),d=cs(n.data,t.app.renderer),ls(d,m(_d)),t.world.addChildAt(d,0),t.bringNavOverlayToTop(),o?.setRoadColor(ho))}),s(()=>{let t=p(),n=y(),r=m(g);!t||!n||n.room!==e.room||!r||r.room!==e.room||d?.parent&&(Vp(`decoration arrived, rebuilding terrain layer — ${e.room}`),d.destroy(),d=cs(r.data,t.app.renderer,n.decoration.terrain),ls(d,m(_d)),t.world.addChildAt(d,0),t.bringNavOverlayToTop(),o&&n.decoration.roadColor!=null&&o.setRoadColor(n.decoration.roadColor))}),s(()=>{let n=p(),r=x();if(!n)return;if(!r){o?.clear(),l?.clear(),n.clearLighting();return}let{objects:i,diff:a,users:s}=r,d=o?a:void 0;if(!o){Vp(`object layer created — ${e.room}`),o=new Ju(n.app.ticker,dd(),U()?._id,U()?.badge,s),o.setTheme(t(m(Td)),Pd),o.setInstantMode(m(K));let r=m(y);r?.room===e.room&&r.decoration.roadColor!=null&&o.setRoadColor(r.decoration.roadColor),o.setLightingLayer(n.lighting),o.container.label=`objects`,o.container.zIndex=Ja.objects,n.world.addChild(o.container),l=new ed(n.app.ticker),l.container.label=`animations`,l.container.zIndex=Ja.animations,n.world.addChild(l.container),u=new od(n.app.renderer,n.world,n.app.ticker),u.container.zIndex=Ja.visuals,n.world.addChild(u.container),n.setTileHandlers((e,t)=>{},(t,r,i)=>{let a=e.room,s=e.shard,c=bp(),l=Ep();if(l?.type===`moveFlag`){let e=H();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`),jp()}).catch(e=>{Hp(`move flag failed:`,e),B(`Failed to move flag "${n}"`,`error`),jp()});return}if(c===`flag`){let e=wp();if(!e||e.tx!==t||e.ty!==r){Tp({tx:t,ty:r}),n.hoverLayer.setPendingTile(t,r);return}let i=H();if(!i)return;let o=Sp(),c=o.name.trim();if(!c){B(`Flag name is required`,`error`);return}let l=vp[o.color]??0,u=vp[o.secondaryColor]??0;i.http.game.createFlag(a,t,r,c,l,u,s??void 0).then(()=>{B(`Flag "${c}" created`,`success`),Ap(),n.hoverLayer.clearPendingTile(),Up(i,c)}).catch(e=>Hp(`create flag failed:`,e));return}if(c===`build`){if(!i&&!Op().structureType){B(`Select a structure type first`,`error`);return}if(i){if(!o)return;let e=o.getObjectsAtTile(t,r).filter(({obj:e})=>e.type===`constructionSite`);if(e.length===0){B(`No construction sites on this tile`,`error`);return}let i=H();if(!i)return;i.http.game.removeConstructionSite(a,e.map(({id:e})=>e),s??void 0).then(()=>{B(`Removed ${e.length} construction site${e.length>1?`s`:``}`,`success`),Ap(),n.hoverLayer.clearPendingTile()}).catch(e=>{Hp(`remove construction sites failed:`,e),B(`Failed to remove construction sites: ${e.message}`,`error`)});return}Tp({tx:t,ty:r}),n.hoverLayer.setPendingTile(t,r),Np(a,s);return}if(Ap(),n.hoverLayer.clearPendingTile(),!o)return;let u=o.getObjectsAtTile(t,r);if(u.length===0){i||(lf([]),n.hoverLayer.clearSelection());return}let d=[...cf()];if(i){let e=new Set(u.map(e=>e.id));if(d.some(t=>e.has(t.id)))d=d.filter(t=>!e.has(t.id));else{let e=u.filter(({id:e})=>!d.some(t=>t.id===e)).map(({id:e,obj:t})=>sf(e,t));d=[...d,...e]}}else d=u.map(({id:e,obj:t})=>sf(e,t));lf(d);let f=d.map(({id:e,type:t})=>({id:e,type:t,visual:o.getVisualById(e)})).filter(e=>e.visual!=null);n.hoverLayer.setSelectedObjects(f)},()=>{let e=bp();(e===`build`||e===`flag`||Ep()?.type===`moveFlag`)&&(Pp(),n.hoverLayer.clearPendingTile())})}d?ff(d,i):pf(i);let f=K()?Math.round(1e3/m(Yf)):On()??2e3,h=f*.6,g=Math.round(f*.9);o.setMoveDuration(g),o.setTickDuration(f),c={objects:i,users:s},o.update(i,d,s,En()??void 0),o.setShowLabels(m(dd));let _=new Set;if(l){l.clear();for(let e in i){let t=i[e];if(!t)continue;let n=t.actionLog;if(!n)continue;if(t.type===`tower`){let r=n.attack,i=n.heal,a=n.repair;r&&l.addTowerAttack(t.x,t.y,r.x,r.y,h),i&&l.addTowerHeal(t.x,t.y,i.x,i.y,h),a&&l.addTowerRepair(t.x,t.y,a.x,a.y,h);let s=r??i??a;s&&o?.triggerTowerAim(e,s.x,s.y,h);continue}if(t.type===`link`){let e=n.transferEnergy;e&&l.addLinkTransfer(t.x,t.y,e.x,e.y,h);continue}if(t.type===`lab`){let e=n.runReaction??n.reverseReaction;e&&(l.addLabReaction(e.x1,e.y1,t.x,t.y,h),l.addLabReaction(e.x2,e.y2,t.x,t.y,h));continue}if(t.type!==`creep`)continue;let r=n.harvest;r&&l.addHarvest(r.x,r.y,t.x,t.y,h);let a=n.upgradeController;a&&l.addUpgradeController(t.x,t.y,a.x,a.y,h);let s=n.build;s&&(l.addBuild(t.x,t.y,s.x,s.y,h),o?.triggerBuildAt(s.x,s.y,h));let c=n.repair;c&&l.addRepair(t.x,t.y,c.x,c.y,h);let u=n.transfer;u&&l.addTransfer(t.x,t.y,u.x,u.y,h);let d=n.say;d&&typeof d.message==`string`&&d.message.length>0&&(o?.triggerSay(e,d.message),_.add(e))}}o.pruneSayBubblesExcept(_),m(xd)&&n.updateLighting(i)}),s(()=>{let e=C();u?.update(Cd()?e:``)}),s(()=>{o?.setInstantMode(K())}),s(()=>{let e=_d();d&&ls(d,e)}),s(()=>{let e=p();if(!e)return;let t=xd();e.darkOverlay.visible=t,e.lightLayer.visible=t,t||e.clearLighting()}),s(()=>{let e=t(Td());o&&(o.setTheme(e,Pd),c&&(o.clear(),o.update(c.objects,void 0,c.users)))}),(()=>{var e=Rp(),t=e.firstChild;return Oe(e=>r=e,t),z(e,(()=>{var e=N(()=>!!Ip());return()=>e()&&(()=>{var e=zp();return z(e,Ip),w(t=>R(e,`pointer-events`,Rn()===`empty`||Rn()===`lost`?`auto`:`none`)),e})()})(),null),z(e,(()=>{var e=N(()=>!K()&&En()!==null);return()=>e()&&(()=>{var e=Bp();return e.firstChild,z(e,En,null),e})()})(),null),z(e,f(v,{get when(){return K()},get children(){var e=Lp(),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,ip(t)},150)},z(n,Uf),z(r,(()=>{var e=N(()=>!!Zf());return()=>e()?`Loading…`:`Tick ${Vf()}`})()),z(i,Gf),w(e=>{var n=Uf(),i=Gf(),a=Zf()?`#f0883e`:`#8b949e`;return n!==e.e&&I(t,`min`,e.e=n),i!==e.t&&I(t,`max`,e.t=i),a!==e.a&&R(r,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),w(()=>t.value=E()),e}}),null),e})()}F([`input`]);var Gp=P(`<div style=position:fixed;bottom:16px;right:16px;display:flex;flex-direction:column;gap:8px;z-index:9999;pointer-events:none>`),Kp=P(`<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 qp(){return(()=>{var e=Gp();return z(e,f(u,{get each(){return qt()},children:e=>(()=>{var t=Kp();return z(t,()=>e.message),w(n=>R(t,`background`,e.type===`error`?`#da3633`:`#238636`)),t})()})),e})()}var[Jp,Yp]=a(!0),[Xp,Zp]=a(!0),[Qp,$p]=a(!1),[em,tm]=a(``),nm;function rm(e){nm=e}function im(e){tm(e),Zp(!0),requestAnimationFrame(()=>{nm?.focus();let t=e.length;nm?.setSelectionRange(t,t)})}function am(){Yp(e=>!e)}function om(){Zp(e=>!e)}function sm(){$p(e=>!e)}var[cm,lm]=a(dn(V.memoryWatches,[])),[um,dm]=a(null),[fm,pm]=ef({});function mm(e){let t=e.trim();t&&(lm(e=>e.includes(t)?e:[...e,t]),fn(V.memoryWatches,cm()))}function hm(e){lm(t=>t.filter(t=>t!==e)),fn(V.memoryWatches,cm())}function gm(){dm(null)}function _m(e,t){dm({creepId:e,name:t})}function vm(e,t){let n=[...t];if(e){let t=`creeps.${e.name}`;n.includes(t)||n.push(t)}return n}function ym(e){let t=new Map,r=()=>{let n=H();if(!n)return;let r=new Set(vm(um(),cm()));for(let i of r)t.has(i)||t.set(i,n.stores.user.subscribeMemory(i,e));for(let[e,n]of t)r.has(e)||(n.dispose(),t.delete(e))};s(()=>{cm(),um(),r()});let i=H(),a=null;return i?a=i.stores.user.on(`user:memory`,e=>{pm(e.path,e.value)}):console.warn(`[memoryStore] no client available when initMemorySubscriptions called`),n(()=>{for(let e of t.values())e.dispose();t.clear(),a?.dispose()}),r(),()=>{for(let e of t.values())e.dispose();t.clear(),a?.dispose()}}C(()=>{s(()=>{let e=um();e&&(cf().some(t=>t.id===e.creepId)||gm())})});var bm=P(`<button style=color:#8b949e>`),xm=P(`<span style=width:18px;flex-shrink:0>`),Sm=P(`<span style=color:#484f58;font-style:italic>{…}`),Cm=P(`<span style=color:#484f58;font-style:italic>`),wm=P(`<button title=Reload>`),Tm=P(`<span title="Click to edit"style=cursor:text;flex:1>`),Em=P(`<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">`),Dm=P(`<button title=Save style=color:#3fb950>`),Om=P(`<button title=Discard style=color:#f85149>`),km=P(`<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:Am}=rn(`MemoryTree`);function jm(e){return typeof e==`object`&&!!e&&`__screeps_object__`in e}var Mm={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},Nm={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 Pm(e){return e.replace(/^Memory\.?/,``)}function Fm(e){let[t,n]=a((e.depth??0)<2),r=()=>e.depth??0,[o,s]=a(!1),[c,l]=a(``),[d,p]=a(!1),[m,h]=a(void 0),g=()=>jm(e.value)&&m()!==void 0?m():e.value,_=()=>{let e=g();return!jm(e)&&typeof e==`object`&&!!e},y=()=>_()?Object.entries(g()):[],b=()=>y().length,x=async()=>{p(!0);try{let t=H();if(!t)return;let n=Pm(e.path),r=await t.http.user.memory.get(n,e.shard);h(r.data===`[object Object]`?{__screeps_object__:!0}:r.data)}catch(e){Am(`fetch memory failed`,e)}finally{p(!1)}},S=()=>{h(void 0),x()};i(()=>{t()&&jm(e.value)&&m()===void 0&&x()});let C=async()=>{if(jm(e.value)&&m()===void 0){await x(),n(!0);return}t()&&h(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=H();if(!r)return;let i=Pm(e.path);try{await r.http.user.memory.set(i,n,e.shard)}catch(e){Am(`set memory failed`,e),s(!1);return}s(!1),e.onRefresh?.()},E=()=>{let e=g();return _()?`#c9d1d9`:typeof e==`string`?`#3fb950`:typeof e==`number`?`#79c0ff`:typeof e==`boolean`?`#a371f7`:`#8b949e`},D=()=>{let e=g();return e===null?`null`:e===void 0?`undefined`:typeof e==`string`?JSON.stringify(e):String(e)};return(()=>{var n=km(),i=n.firstChild,a=i.firstChild,p=a.nextSibling.nextSibling;return z(i,f(v,{get when(){return _()||jm(g())},get children(){var e=bm();return e.$$click=()=>void C(),z(e,f(v,{get when(){return d()},get children(){return f(li,{size:12,style:{animation:`spin 1s linear infinite`}})}}),null),z(e,f(v,{get when(){return!d()},get children(){return f(v,{get when(){return t()},get fallback(){return f(Dr,{size:12})},get children(){return f(Tr,{size:12})}})}}),null),w(n=>{var r={...Nm},i=t()?`Collapse`:`Expand`,a=d();return n.e=L(e,r,n.e),i!==n.t&&I(e,`title`,n.t=i),a!==n.a&&(e.disabled=n.a=a),n},{e:void 0,t:void 0,a:void 0}),e}}),a),z(i,f(v,{get when(){return N(()=>!_())()&&!jm(g())},get children(){return xm()}}),a),z(a,()=>e.label),z(i,f(v,{get when(){return jm(g())},get children(){return Sm()}}),p),z(i,f(v,{get when(){return _()},get children(){var e=Cm();return z(e,(()=>{var e=N(()=>!!Array.isArray(g()));return()=>e()?`[${b()}]`:`{${b()}}`})()),e}}),p),z(i,f(v,{get when(){return N(()=>!!jm(e.value))()&&!d()},get children(){var e=wm();return e.$$click=()=>S(),z(e,f(ji,{size:11})),w(t=>L(e,Nm,t)),e}}),p),z(i,f(v,{get when(){return N(()=>!_())()&&!jm(g())},get children(){return[f(v,{get when(){return!o()},get children(){var e=Tm();return e.$$click=()=>{l(D()),s(!0)},z(e,D),w(t=>R(e,`color`,E())),e}}),f(v,{get when(){return o()},get children(){return[(()=>{var e=Em();return e.$$keydown=e=>{e.key===`Enter`&&T(),e.key===`Escape`&&s(!1)},e.$$input=e=>l(e.currentTarget.value),w(()=>e.value=c()),e})(),(()=>{var e=Dm();return e.$$mousedown=e=>{e.preventDefault(),T()},z(e,f(Cr,{size:12})),w(t=>L(e,{...Nm},t)),e})(),(()=>{var e=Om();return e.$$mousedown=e=>{e.preventDefault(),s(!1)},z(e,f($i,{size:12})),w(t=>L(e,{...Nm},t)),e})()]}})]}}),p),p.$$click=()=>im(`Memory.${Pm(e.path)} = `),z(p,f(qi,{size:11})),z(n,f(v,{get when(){return N(()=>!!_())()&&t()},get children(){return f(u,{get each(){return y()},children:([t,n])=>f(Fm,{value:n,path:Array.isArray(g())?`${e.path}[${t}]`:`${e.path}.${t}`,label:t,get shard(){return e.shard},get depth(){return r()+1},get onRefresh(){return N(()=>!!jm(e.value))()?S:e.onRefresh}})})}}),null),w(t=>{var i={"padding-left":r()>0?`14px`:`0`,...Mm},a=Nm,o=`Insert Memory.${Pm(e.path)} = into console`;return t.e=L(n,i,t.e),t.t=L(p,a,t.t),o!==t.a&&I(p,`title`,t.a=o),t},{e:void 0,t:void 0,a:void 0}),n})()}function Im(e){return f(Fm,{get value(){return e.value},get path(){return e.path},get label(){return e.label},get shard(){return e.shard},depth:0})}F([`click`,`input`,`keydown`,`mousedown`]);var Lm=P(`<div style=color:#484f58;font-style:italic>No paths watched — add one below.`),Rm=P(`<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`),zm=P(`<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">`),Bm=P(`<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">`),Vm=P(`<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>`),Hm=P(`<div style=width:4px;flex-shrink:0;cursor:col-resize>`),Um=P(`<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>&gt;</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`),Wm=P(`<div style=flex:1;display:flex;overflow:hidden>`),Gm=P(`<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
+ `),Km=P(`<div style=color:#484f58;font-style:italic>No log output yet…`),qm=P(`<div style=margin-bottom:4px;color:#f85149;white-space:pre-wrap;word-break:break-word>`),Jm=P(`<div style=margin-bottom:4px;color:#c9d1d9;white-space:pre-wrap;word-break:break-word>`),Ym=P(`<div style=color:#484f58;font-style:italic>No command results yet…`),Xm=P(`<div style=margin-bottom:4px;color:#58a6ff;white-space:pre-wrap;word-break:break-word>`),{error:Zm}=rn(`console`);function Qm(e){let[t,n]=a(``),r=()=>e.shard??Of();i(()=>{ym(r())});let o={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},s={background:`transparent`,border:`none`,color:`#8b949e`,cursor:`pointer`,padding:`4px`,"border-radius":`4px`,display:`flex`,"align-items":`center`,"justify-content":`center`};return(()=>{var i=Rm(),a=i.firstChild,c=a.nextSibling,l=c.firstChild,d=l.nextSibling,p=d.firstChild;return z(a,f(v,{get when(){return um()},children:e=>{let t=`creeps.${e().name}`;return(()=>{var e=zm(),n=e.firstChild.firstChild,i=n.nextSibling.nextSibling;return z(n,t),Te(i,`click`,gm,!0),z(i,f($i,{size:12})),z(e,f(Im,{get value(){return fm[t]},path:`Memory.${t}`,label:t,get shard(){return r()}}),null),w(e=>L(i,s,e)),e})()}}),null),z(a,f(u,{get each(){return cm()},children:e=>(()=>{var t=Bm(),n=t.firstChild.firstChild,i=n.nextSibling;return z(n,e),i.$$click=()=>hm(e),z(i,f($i,{size:12})),z(t,f(Im,{get value(){return fm[e]},path:`Memory.${e}`,label:e,get shard(){return r()}}),null),w(e=>L(i,s,e)),t})()}),null),z(a,f(v,{get when(){return N(()=>cm().length===0)()&&!um()},get children(){return Lm()}}),null),c.addEventListener(`submit`,e=>{e.preventDefault(),mm(t()),n(``)}),l.$$input=e=>n(e.currentTarget.value),z(d,f(ki,{size:14}),p),w(t=>{var n=`${e.width*100}%`,r={...o};return n!==t.e&&R(i,`width`,t.e=n),t.t=L(a,r,t.t),t},{e:void 0,t:void 0}),w(()=>l.value=t()),i})()}function $m(e){let[t,r]=a([]),[o,c]=a(!0),[l,d]=a(dn(V.consoleWeights,[1,1,1])),[p,m]=a(null),h,g,_,y=0;i(()=>{let e=H();if(!e)return;let t=new Et;t.add(e.stores.user.subscribe(`console`)),t.add(e.stores.user.on(`user:console`,e=>{let t=e.messages,n={id:y++,log:t.log??[],results:t.results??[],error:t.error??[]};r(e=>{let t=[...e,n];return t.length>200?t.slice(t.length-200):t})})),n(()=>t.dispose())}),s(()=>{t(),o()&&requestAnimationFrame(()=>{Jp()&&h&&(h.scrollTop=h.scrollHeight),Xp()&&g&&(g.scrollTop=g.scrollHeight)})});let b=(t,n,r)=>{let i=!t&&!n&&!r;i&&!e.isCollapsed&&e.onToggle?.(),!i&&e.isCollapsed&&e.onToggle?.()};s(()=>{b(Jp(),Xp(),Qp())});let x=()=>{let e=l(),t=[Jp(),Xp(),Qp()],n=t.filter(Boolean).length;if(n===0)return[0,0,0];if(n===1){let e=t.findIndex(Boolean);return[0,0,0].map((t,n)=>+(n===e))}let r=t.map((t,n)=>t?e[n]:0).reduce((e,t)=>e+t,0);if(r===0){let e=1/n;return[0,0,0].map((n,r)=>t[r]?e:0)}return t.map((t,n)=>t?e[n]/r:0)};s(()=>{fn(V.consoleWeights,l())});let S=e=>t=>{t.preventDefault(),t.stopPropagation(),m(e),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,C),window.addEventListener(`pointerup`,T,{once:!0})},C=e=>{let t=p();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=[...l()],o=[Jp(),Xp(),Qp()];if(t===0){let e=o[0],t=o[1];if(!e||!t)return;a[0]=i/(1-i),a[1]=1,d(a)}else{let e=o[1],t=o[2];if(!e||!t)return;a[1]=i/(1-i),a[2]=1,d(a)}},T=()=>{m(null),document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,C)},[E,D]=a([]),[O,ee]=a(null),[k,A]=a(``),te=e=>{let t=E();if(t.length!==0){if(e.key===`ArrowUp`){e.preventDefault();let n=O();n===null?(A(em()),ee(t.length-1),tm(t[t.length-1])):n>0&&(ee(n-1),tm(t[n-1]))}else if(e.key===`ArrowDown`){e.preventDefault();let n=O();if(n===null)return;n<t.length-1?(ee(n+1),tm(t[n+1])):(ee(null),tm(k()))}}},ne=async t=>{t.preventDefault();let n=H(),r=em().trim();if(!(!n||!r))try{await n.http.user.console(r,e.shard??`shard0`),D(e=>[...e,r]),ee(null),A(``),tm(``)}catch(e){Zm(`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),j=()=>t().flatMap(e=>e.error),ae=()=>t().flatMap(e=>e.results),oe={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},M={background:`transparent`,border:`none`,color:`#8b949e`,cursor:`pointer`,padding:`4px`,"border-radius":`4px`,display:`flex`,"align-items":`center`,"justify-content":`center`},se=()=>{c(!0),requestAnimationFrame(()=>{Jp()&&h&&(h.scrollTop=h.scrollHeight),Xp()&&g&&(g.scrollTop=g.scrollHeight)})};return(()=>{var t=Gm(),n=t.firstChild,i=n.firstChild,a=i.nextSibling,s=a.nextSibling;return n.nextSibling,Te(i,`click`,am,!0),Te(a,`click`,om,!0),Te(s,`click`,sm,!0),z(t,f(v,{get when(){return!e.isCollapsed},get children(){var t=Wm();return Oe(e=>_=e,t),z(t,f(v,{get when(){return Jp()},get children(){var e=Vm(),t=e.firstChild,n=t.firstChild,i=n.nextSibling,a=t.nextSibling;n.$$click=()=>o()?c(!1):se(),z(n,(()=>{var e=N(()=>!!o());return()=>e()?f(Ci,{size:16}):f(Di,{size:16})})()),i.$$click=()=>r([]),z(i,f(Yi,{size:16})),a.addEventListener(`scroll`,()=>{h&&c(h.scrollHeight-h.scrollTop-h.clientHeight<20)});var s=h;return typeof s==`function`?Oe(s,a):h=a,z(a,(()=>{var e=N(()=>ie().length===0&&j().length===0);return()=>e()&&Km()})(),null),z(a,f(u,{get each(){return j()},children:e=>(()=>{var t=qm();return t.innerHTML=e,t})()}),null),z(a,f(u,{get each(){return ie()},children:e=>(()=>{var t=Jm();return t.innerHTML=e,t})()}),null),w(t=>{var r=`${x()[0]*100}%`,s=o()?`Pause scrolling`:`Resume scrolling`,c=M,l=M,u={...oe};return r!==t.e&&R(e,`width`,t.e=r),s!==t.t&&I(n,`title`,t.t=s),t.a=L(n,c,t.a),t.o=L(i,l,t.o),t.i=L(a,u,t.i),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),z(t,f(v,{get when(){return N(()=>!!Jp())()&&Xp()},get children(){var e=Hm();return Te(e,`pointerdown`,S(0),!0),w(t=>R(e,`background`,p()===0?`#388bfd`:`#21262d`)),e}}),null),z(t,f(v,{get when(){return Xp()},get children(){var e=Um(),t=e.firstChild,n=t.nextSibling,r=n.firstChild.nextSibling;r.nextSibling,t.addEventListener(`scroll`,()=>{g&&c(g.scrollHeight-g.scrollTop-g.clientHeight<20)});var i=g;return typeof i==`function`?Oe(i,t):g=t,z(t,(()=>{var e=N(()=>ae().length===0);return()=>e()&&Ym()})(),null),z(t,f(u,{get each(){return ae()},children:e=>(()=>{var t=Xm();return t.innerHTML=e,t})()}),null),n.addEventListener(`submit`,ne),r.$$keydown=te,r.$$input=e=>{ee(null),tm(e.currentTarget.value)},Oe(e=>rm(e),r),w(n=>{var r=`${x()[1]*100}%`,i={...oe};return r!==n.e&&R(e,`width`,n.e=r),n.t=L(t,i,n.t),n},{e:void 0,t:void 0}),w(()=>r.value=em()),e}}),null),z(t,f(v,{get when(){return N(()=>!!Xp())()&&Qp()},get children(){var e=Hm();return Te(e,`pointerdown`,S(1),!0),w(t=>R(e,`background`,p()===1?`#388bfd`:`#21262d`)),e}}),null),z(t,f(v,{get when(){return Qp()},get children(){return f(Qm,{get shard(){return e.shard??null},get width(){return x()[2]}})}}),null),w(e=>R(t,`user-select`,p()===null?`auto`:`none`)),t}}),null),w(e=>{var t=re(Jp()),n=re(Xp()),r=re(Qp());return e.e=L(i,t,e.e),e.t=L(a,n,e.t),e.a=L(s,r,e.a),e},{e:void 0,t:void 0,a:void 0}),t})()}F([`input`,`click`,`pointerdown`,`keydown`]);var eh=P(`<div style=display:flex;gap:5px;flex-wrap:wrap>`),th=P(`<div style=width:18px;height:18px;border-radius:50%;cursor:pointer;flex-shrink:0>`),nh=[{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 rh(e){return(()=>{var t=eh();return z(t,f(u,{each:nh,children:t=>(()=>{var n=th();return n.$$click=()=>e.onChange(t.value),w(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&&I(n,`title`,r.e=i),a!==r.t&&R(n,`background`,r.t=a),o!==r.a&&R(n,`box-shadow`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n})()})),t})()}F([`click`]);var ih=P(`<div>`),ah=P(`<div style=font-variant-numeric:tabular-nums>`),oh=P(`<span style=font-variant-numeric:tabular-nums;font-weight:400> / `),sh=P(`<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">`),ch=P(`<div style="padding:3px 8px;background:#0d1117;color:#8b949e">`),lh=P(`<div style="padding:3px 8px;background:#0d1117;color:#c9d1d9;font-variant-numeric:tabular-nums">`),uh=P(`<div>Owner`),dh=P(`<div>Hits`),fh=P(`<div style=font-variant-numeric:tabular-nums> / `),ph=P(`<div>Time to live`),mh=P(`<div>Fatigue`),hh=P(`<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">`),gh=P(`<div><div>`),_h=P(`<div style=width:11px;height:11px;border-radius:50%;flex-shrink:0>`),vh=P(`<span style=font-size:10px;font-variant-numeric:tabular-nums><span style=color:#8b949e>×</span><span>`),yh=P(`<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">`),bh=P(`<div style=padding:8px;display:flex;flex-direction:column;gap:8px;background:#0d1117><label>Primary color</label><label>Secondary color`),xh=P(`<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`),Sh=P(`<div>Reserved by`),Ch=P(`<div>Reservation`),wh=P(`<div style=font-variant-numeric:tabular-nums> ticks`),Th=P(`<div>Level`),Eh=P(`<div>Safe modes`),Dh=P(`<div>Power`),Oh=P(`<div>Downgrade in`),kh=P(`<div>Safe mode active`),Ah=P(`<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>`),jh=P(`<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">`),Mh=P(`<div><div><div>Owner</div><div>`),Nh=P(`<div>Cooldown`),Ph=P(`<div>Notify when attacked`),Fh=P(`<div style=display:flex;align-items:center><button style=background:transparent;border:none;cursor:pointer;padding:0;display:flex;align-items:center>`),Ih=P(`<div><div>Energy</div><div style=font-variant-numeric:tabular-nums> / `),Lh=P(`<div><div>Hits</div><div style=font-variant-numeric:tabular-nums> / `),Rh=P(`<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>`),zh=P(`<div style=font-variant-numeric:tabular-nums> `),Bh=P(`<div>Decays in`),Vh=P(`<div>Decay in`),Hh=P(`<div>Energy cap`),Uh=P(`<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>`),Wh=P(`<div style=width:8px;height:8px;border-radius:50%;flex-shrink:0>`),Gh=P(`<button style="background:transparent;border:none;cursor:pointer;padding:0 2px;display:flex;align-items:center;justify-content:center;flex-shrink:0">`),Kh=P(`<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">`),qh=P(`<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">×`),Jh=P(`<span style=font-weight:400;color:#8b949e>`),Yh=P(`<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">`),Xh=P(`<div style=flex:1;overflow:auto;min-height:0;padding:8px>`),Zh=P(`<div style=color:#484f58;font-style:italic;font-size:12px>Click a tile to select objects…`),{log:Qh,error:$h}=rn(`SelectionList`),eg={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`},tg={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`},ng=new Set([`x`,`y`,`type`,`id`,`name`,`user`,`_id`,`room`,`hitsMax`,`energyCapacity`,`body`,`storeCapacity`,`storeCapacityResource`,`invaderHarvested`,`ticksToRegeneration`]),rg=new Set([`hits`,`energy`,`energyCapacity`,`store`,`progress`,`progressTotal`,`nextDecayTime`,`ticksToRegeneration`,`nextRegenerationTime`]),ig={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 ag(e){return ig[e]?ig[e]:e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()).trim()}function og(e){return typeof e==`number`?String(e):typeof e==`string`?e:typeof e==`boolean`?e?`Yes`:`No`:null}function sg(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 q=(e=!1)=>({padding:`3px 8px`,background:`#0d1117`,color:e?`#8b949e`:`#c9d1d9`,overflow:`hidden`,"text-overflow":`ellipsis`,"white-space":`nowrap`}),cg={display:`grid`,"grid-template-columns":`1fr 1fr`,gap:`1px`,background:`#21262d`,"font-size":`10px`};function lg(e){let t=()=>{let t=e.item.raw,n=[];for(let e in t){if(ng.has(e))continue;let r=t[e],i=og(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=En();e!==null&&(i=String(r-e))}if(e===`nextRegenerationTime`&&typeof r==`number`){let e=En();e!==null&&(i=String(r-e))}i!==null&&n.push({key:e,label:ag(e),value:i})}}return n.sort((e,t)=>!rg.has(e.key)-+!rg.has(t.key)),n};return f(v,{get when(){return t().length>0},get children(){var e=ih();return z(e,f(u,{get each(){return t()},children:e=>[(()=>{var t=ih();return z(t,()=>e.label),w(e=>L(t,q(!0),e)),t})(),(()=>{var t=ah();return z(t,()=>e.value),w(e=>L(t,{...q()},e)),t})()]})),w(t=>L(e,cg,t)),e}})}function ug(e){let t=()=>{let t=e.store||{},n=[];for(let e in t)n.push([e,t[e]]);return n},n=()=>{let t=e.store||{},n=0;for(let e in t)n+=t[e];return n};return f(v,{get when(){return t().length>0},get children(){var r=sh(),i=r.firstChild;i.firstChild;var a=i.nextSibling;return z(i,f(v,{get when(){return e.capacity!=null},get children(){var t=oh(),r=t.firstChild;return z(t,n,r),z(t,()=>e.capacity,null),t}}),null),z(a,f(u,{get each(){return t()},children:([e,t])=>[(()=>{var t=ch();return z(t,e),t})(),(()=>{var e=lh();return z(e,t),e})()]})),r}})}var dg={tough:`#4c4c4c`,move:`#a9b7c6`,work:`#ffe56d`,carry:`#777777`,attack:`#f93842`,ranged_attack:`#5d80b2`,heal:`#65fd62`,claim:`#b99cfb`};function fg(e){let t=()=>e.item.raw,n=()=>typeof t().user==`string`?t().user:null,r=()=>{let e=n();return e?Ef()?.[e]?.username??e:null},i=()=>typeof t().hits==`number`?t().hits:null,a=()=>typeof t().hitsMax==`number`?t().hitsMax:null,o=()=>{let e=t().ageTime,n=En();return typeof e==`number`&&n!==null?Math.max(0,e-n):null},s=()=>typeof t().fatigue==`number`?t().fatigue:null,c=()=>t().store,l=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null,d=()=>t().body??[],p=()=>{let e=new Map;for(let t of d())e.set(t.type,(e.get(t.type)??0)+1);return[...e.entries()].map(([e,t])=>({type:e,count:t}))};return(()=>{var e=gh(),t=e.firstChild;return z(t,f(v,{get when(){return r()},get children(){return[(()=>{var e=uh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ih();return z(e,r),w(t=>L(e,q(),t)),e})()]}}),null),z(t,f(v,{get when(){return N(()=>i()!==null)()&&a()!==null},get children(){return[(()=>{var e=dh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=fh(),t=e.firstChild;return z(e,i,t),z(e,a,null),w(t=>L(e,{...q()},t)),e})()]}}),null),z(t,f(v,{get when(){return o()!==null},get children(){return[(()=>{var e=ph();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ah();return z(e,o),w(t=>L(e,{...q()},t)),e})()]}}),null),z(t,f(v,{get when(){return s()!==null},get children(){return[(()=>{var e=mh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ah();return z(e,s),w(t=>L(e,{...q(),color:s()>0?`#e3b341`:void 0},t)),e})()]}}),null),z(e,f(ug,{get store(){return c()},get capacity(){return l()}}),null),z(e,f(v,{get when(){return d().length>0},get children(){var e=hh(),t=e.firstChild,n=t.firstChild.nextSibling;n.nextSibling;var r=t.nextSibling,i=r.nextSibling;return z(t,()=>d().length,n),z(r,f(u,{get each(){return d()},children:e=>(()=>{var t=_h();return w(n=>{var r=e.type.replace(`_`,` `),i=dg[e.type]??`#484f58`,a=e.hits===0?.25:1;return r!==n.e&&I(t,`title`,n.e=r),i!==n.t&&R(t,`background`,n.t=i),a!==n.a&&R(t,`opacity`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),z(i,f(u,{get each(){return p()},children:({type:e,count:t})=>(()=>{var n=vh(),r=n.firstChild,i=r.firstChild,a=r.nextSibling;return z(r,t,i),z(a,()=>e.replace(`_`,` `).toUpperCase()),w(t=>R(a,`color`,dg[e]??`#484f58`)),n})()})),e}}),null),w(e=>L(t,cg,e)),e})()}function pg(e){let t=()=>e.item.raw,n=()=>typeof t().name==`string`?t().name:``,r=()=>typeof t().room==`string`?t().room:``,i=()=>typeof t().color==`number`?t().color:1,o=()=>typeof t().secondaryColor==`number`?t().secondaryColor:1,[c,l]=a(i()),[u,d]=a(o());s(()=>{l(i()),d(o())});let p=()=>c()!==i()||u()!==o(),m=()=>{let e=H();if(!e)return;let t=c(),i=u();Qh(`changeFlagColor: name="${n()}" room=${r()} primary=${t} secondary=${i}`),e.http.game.changeFlagColor(r(),n(),t,i).then(()=>Qh(`changeFlagColor OK`)).catch(e=>$h(`changeFlagColor FAILED:`,e))},h=()=>{let t=Ep();return t?.type===`moveFlag`&&t.id===e.item.id},g=()=>{if(h()){Dp(null);return}Dp({type:`moveFlag`,id:e.item.id,name:n(),room:r(),color:c(),secondaryColor:u(),targetRoom:Af()??r()})},_=()=>{let t=Ep();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=bh(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return n.firstChild,z(t,f(rh,{get value(){return c()},onChange:l}),null),z(n,f(rh,{get value(){return u()},onChange:d}),null),z(e,f(v,{get when(){return!K()},get children(){return[(()=>{var e=yh(),t=e.firstChild,n=t.nextSibling;return t.addEventListener(`mouseleave`,e=>{p()&&(e.currentTarget.style.background=`#238636`)}),t.addEventListener(`mouseenter`,e=>{p()&&(e.currentTarget.style.background=`#2ea043`)}),t.$$click=m,n.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=h()?`#c9d1d9`:`#8b949e`}),n.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=`#c9d1d9`}),n.$$click=g,z(n,(()=>{var e=N(()=>!!h());return()=>e()?f($i,{size:13}):f(yi,{size:13})})()),w(e=>{var r=!p(),i=p()?`#238636`:`#161b22`,a=p()?`#fff`:`#484f58`,o=`1px solid ${p()?`#238636`:`#30363d`}`,s=p()?`pointer`:`not-allowed`,c=h()?`Abort move`:`Move flag`,l=h()?`#30363d`:`#21262d`,u=h()?`#c9d1d9`:`#8b949e`,d=`1px solid ${h()?`#8b949e`:`#30363d`}`;return r!==e.e&&(t.disabled=e.e=r),i!==e.t&&R(t,`background`,e.t=i),a!==e.a&&R(t,`color`,e.a=a),o!==e.o&&R(t,`border`,e.o=o),s!==e.i&&R(t,`cursor`,e.i=s),c!==e.n&&I(n,`title`,e.n=c),l!==e.s&&R(n,`background`,e.s=l),u!==e.h&&R(n,`color`,e.h=u),d!==e.r&&R(n,`border`,e.r=d),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),e})(),f(v,{get when(){return _()},children:e=>(()=>{var t=xh(),n=t.firstChild.nextSibling;return n.nextSibling,n.$$input=t=>Dp({...e(),targetRoom:t.currentTarget.value.toUpperCase()}),w(e=>L(t,y,e)),w(()=>n.value=e().targetRoom),t})()})]}}),null),w(e=>{var r=y,i=y;return e.e=L(t,r,e.e),e.t=L(n,i,e.t),e},{e:void 0,t:void 0}),e})()}function mg(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:vs[n()]??null,o=()=>typeof t().downgradeTime==`number`?t().downgradeTime:null,s=()=>typeof t().safeModeAvailable==`number`?t().safeModeAvailable:0,c=()=>typeof t().safeMode==`number`?t().safeMode:null,l=()=>t().isPowerEnabled===!0,u=()=>t().reservation,d=()=>typeof t().user==`string`?t().user:null,p=()=>{let e=d();return e?gf()?.username??e:null},m=()=>{let e=o(),t=En();return e!==null&&t!==null?Math.max(0,e-t):null},h=()=>{let e=m();if(e===null)return`—`;let t=ys[n()];return t!==void 0&&e>=t?`Max`:String(e)},g=()=>d()!==null&&d()===U()?._id,[_,y]=a(!1),b=null,x=()=>{let n=H();n&&n.http.game.addObjectIntent(e.item.id,Af()??t().room??``,`activateSafeMode`,{id:e.item.id},Of()).catch(e=>$h(`activateSafeMode failed:`,e))},S=()=>{if(!_()){y(!0),b=setTimeout(()=>y(!1),3e3);return}b&&=(clearTimeout(b),null),y(!1);let n=H();n&&n.http.game.addObjectIntent(e.item.id,Af()??t().room??``,`unclaim`,{id:e.item.id},Of()).catch(e=>$h(`unclaim failed:`,e))};return(()=>{var e=Mh(),t=e.firstChild,a=t.firstChild,o=a.nextSibling;return z(o,()=>p()??`None`),z(t,f(v,{get when(){return u()},get children(){return[(()=>{var e=Sh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ih();return z(e,()=>Ef()?.[u().user]?.username??u().user),w(t=>L(e,q(),t)),e})(),(()=>{var e=Ch();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=wh(),t=e.firstChild;return z(e,(()=>{var e=N(()=>En()!==null);return()=>e()?Math.max(0,u().endTime-En()):u().endTime})(),t),w(t=>L(e,{...q()},t)),e})()]}}),null),z(t,f(v,{get when(){return n()>0},get children(){return[(()=>{var e=Th();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ih();return z(e,n),w(t=>L(e,q(),t)),e})(),(()=>{var e=Eh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ih();return z(e,s),w(t=>L(e,q(),t)),e})(),(()=>{var e=Dh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ih();return z(e,()=>l()?`Enabled`:`Disabled`),w(t=>L(e,q(),t)),e})(),(()=>{var e=Oh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ah();return z(e,h),w(t=>L(e,{...q(),color:h()===`Max`?`#3fb950`:void 0},t)),e})()]}}),null),z(t,f(v,{get when(){return c()!==null},get children(){return[(()=>{var e=kh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=wh(),t=e.firstChild;return z(e,c,t),w(t=>L(e,{...q()},t)),e})()]}}),null),z(e,f(v,{get when(){return N(()=>n()>0&&n()<8&&r()!==null)()&&i()!==null},get children(){var e=Ah(),t=e.firstChild,a=t.firstChild,o=a.firstChild.nextSibling;o.nextSibling;var s=a.nextSibling,c=s.firstChild,l=c.nextSibling,u=l.nextSibling.nextSibling;u.nextSibling;var d=t.nextSibling.firstChild;return z(a,n,o),z(a,()=>n()+1,null),z(s,()=>sg(r()),c),z(s,()=>sg(i()),l),z(s,()=>(r()/i()*100).toFixed(1),u),w(e=>R(d,`width`,`${Math.min(100,r()/i()*100)}%`)),e}}),null),z(e,f(v,{get when(){return N(()=>!!g())()&&!K()},get children(){var e=jh(),t=e.firstChild,n=t.nextSibling;return t.addEventListener(`mouseleave`,e=>{s()>0&&(e.currentTarget.style.background=`#1f6feb`)}),t.addEventListener(`mouseenter`,e=>{s()>0&&(e.currentTarget.style.background=`#388bfd`)}),t.$$click=x,n.addEventListener(`mouseleave`,e=>{_()||(e.currentTarget.style.background=`#f85149`)}),n.addEventListener(`mouseenter`,e=>{_()||(e.currentTarget.style.background=`#da3633`)}),n.$$click=S,z(n,()=>_()?`Confirm unclaim`:`Unclaim`),w(e=>{var r=s()===0,i=s()>0?`#1f6feb`:`#161b22`,a=s()>0?`pointer`:`not-allowed`,o=s()>0?1:.5,c=_()?`#da3633`:`#f85149`;return r!==e.e&&(t.disabled=e.e=r),i!==e.t&&R(t,`background`,e.t=i),a!==e.a&&R(t,`cursor`,e.a=a),o!==e.o&&R(t,`opacity`,e.o=o),c!==e.i&&R(n,`background`,e.i=c),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),w(e=>{var n=cg,r=q(!0),i=q();return e.e=L(t,n,e.e),e.t=L(a,r,e.t),e.a=L(o,i,e.a),e},{e:void 0,t:void 0,a:void 0}),e})()}function hg(e){let t=()=>e.item.raw,n=()=>t().store?.energy??0,r=()=>t().storeCapacityResource?.energy??0,i=()=>typeof t().hits==`number`?t().hits:null,a=()=>typeof t().hitsMax==`number`?t().hitsMax:null,o=()=>{if(typeof t().cooldown==`number`)return t().cooldown;let e=t().cooldownTime,n=En();return typeof e==`number`&&n!==null?Math.max(0,e-n):null},s=()=>t().notifyWhenAttacked===!0,c=()=>typeof t().user==`string`?t().user:null,l=()=>c()!==null&&c()===U()?._id,u=()=>{let n=H();n&&n.http.game.addObjectIntent(e.item.id,t().room,`notifyWhenAttacked`,{enabled:!s()}).catch(e=>$h(`notifyWhenAttacked failed:`,e))};return(()=>{var e=Ih(),t=e.firstChild,c=t.nextSibling,d=c.firstChild;return z(c,n,d),z(c,r,null),z(e,f(v,{get when(){return N(()=>i()!==null)()&&a()!==null},get children(){return[(()=>{var e=dh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=fh(),t=e.firstChild;return z(e,i,t),z(e,a,null),w(t=>L(e,{...q()},t)),e})()]}}),null),z(e,f(v,{get when(){return o()!==null},get children(){return[(()=>{var e=Nh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ah();return z(e,o),w(t=>L(e,{...q()},t)),e})()]}}),null),z(e,f(v,{get when(){return N(()=>!!l())()&&!K()},get children(){return[(()=>{var e=Ph();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=Fh(),t=e.firstChild;return t.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=s()?`#3fb950`:`#484f58`}),t.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=s()?`#56d364`:`#8b949e`}),t.$$click=u,z(t,(()=>{var e=N(()=>!!s());return()=>e()?f(xr,{size:12}):f(yr,{size:12})})()),w(n=>{var r={...q()},i=s()?`Notifications on — click to disable`:`Notifications off — click to enable`,a=s()?`#3fb950`:`#484f58`;return n.e=L(e,r,n.e),i!==n.t&&I(t,`title`,n.t=i),a!==n.a&&R(t,`color`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),e})()]}}),null),w(n=>{var r=cg,i=q(!0),a={...q()};return n.e=L(e,r,n.e),n.t=L(t,i,n.t),n.a=L(c,a,n.a),n},{e:void 0,t:void 0,a:void 0}),e})()}function gg(e){let t=()=>e.item.raw,n=()=>typeof t().hits==`number`?t().hits:null,r=()=>typeof t().hitsMax==`number`?t().hitsMax:null,i=()=>t().store,a=()=>{if(typeof t().storeCapacity==`number`)return t().storeCapacity;let e=t().storeCapacityResource;if(e){let t=0;for(let n in e)t+=e[n];return t}return null},o=()=>{let e=i();if(!e)return 0;let t=0;for(let n in e)t+=e[n];return t},s=()=>{let e=a();return!e||e===0?0:Math.min(100,o()/e*100)};return(()=>{var e=ih();return z(e,f(v,{get when(){return N(()=>n()!==null)()&&r()!==null},get children(){var e=Lh(),t=e.firstChild,i=t.nextSibling,a=i.firstChild;return z(i,n,a),z(i,r,null),w(n=>{var r=cg,a=q(!0),o={...q()};return n.e=L(e,r,n.e),n.t=L(t,a,n.t),n.a=L(i,o,n.a),n},{e:void 0,t:void 0,a:void 0}),e}}),null),z(e,f(v,{get when(){return a()!==null},get children(){var e=Rh(),t=e.firstChild,n=t.firstChild.nextSibling,r=n.firstChild,i=r.nextSibling,c=i.nextSibling.nextSibling;c.nextSibling;var l=t.nextSibling.firstChild;return z(n,()=>sg(o()),r),z(n,()=>sg(a()),i),z(n,()=>s().toFixed(1),c),w(e=>R(l,`width`,`${s()}%`)),e}}),null),z(e,f(ug,{get store(){return i()},capacity:null}),null),e})()}function _g(e){let t=()=>e.item.raw,n=()=>{let e=t().decayTime;if(typeof e!=`number`)return null;let n=En();return n===null?e:Math.max(0,e-n)},r=()=>{let e=t().power;if(typeof e==`number`)return e;let n=t().store;return typeof n?.power==`number`?n.power:null},i=()=>typeof t().hits==`number`?t().hits:null,a=()=>typeof t().hitsMax==`number`?t().hitsMax:null;return(()=>{var e=ih();return z(e,f(v,{get when(){return r()!==null},get children(){return[(()=>{var e=Dh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ah();return z(e,r),w(t=>L(e,{...q()},t)),e})()]}}),null),z(e,f(v,{get when(){return i()!==null},get children(){return[(()=>{var e=dh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=zh(),t=e.firstChild;return z(e,i,t),z(e,(()=>{var e=N(()=>a()!==null);return()=>e()?`/ ${a()}`:``})(),null),w(t=>L(e,{...q()},t)),e})()]}}),null),z(e,f(v,{get when(){return n()!==null},get children(){return[(()=>{var e=Bh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ah();return z(e,n),w(t=>L(e,{...q()},t)),e})()]}}),null),w(t=>L(e,cg,t)),e})()}function vg(e){let t=()=>e.item.raw,n=()=>{let e=t().decayTime;if(typeof e!=`number`)return null;let n=En();return n===null?e:Math.max(0,e-n)},r=()=>typeof t().user==`string`?t().user:null,i=()=>{let e=r();return e?Ef()?.[e]?.username??e:null},a=()=>t().structure,o=()=>typeof a()?.type==`string`?a().type:null,s=()=>typeof a()?.hits==`number`?a().hits:null,c=()=>typeof a()?.hitsMax==`number`?a().hitsMax:null,l=()=>typeof a()?.level==`number`?a().level:null,u=()=>typeof a()?.energy==`number`?a().energy:null,d=()=>typeof a()?.energyCapacity==`number`?a().energyCapacity:null,p=()=>t().store,m=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null;return(()=>{var e=gh(),t=e.firstChild;return z(t,f(v,{get when(){return n()!==null},get children(){return[(()=>{var e=Vh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ah();return z(e,n),w(t=>L(e,{...q()},t)),e})()]}}),null),z(t,f(v,{get when(){return i()},get children(){return[(()=>{var e=uh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ih();return z(e,i),w(t=>L(e,q(),t)),e})()]}}),null),z(e,f(v,{get when(){return o()},get children(){var e=Uh(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return z(t,o,null),z(n,f(v,{get when(){return c()!==null},get children(){return[(()=>{var e=dh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=fh(),t=e.firstChild;return z(e,()=>s()??0,t),z(e,c,null),w(t=>L(e,{...q()},t)),e})()]}}),null),z(n,f(v,{get when(){return l()!==null},get children(){return[(()=>{var e=Th();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=ah();return z(e,l),w(t=>L(e,{...q()},t)),e})()]}}),null),z(n,f(v,{get when(){return d()!==null},get children(){return[(()=>{var e=Hh();return w(t=>L(e,q(!0),t)),e})(),(()=>{var e=fh(),t=e.firstChild;return z(e,()=>u()??0,t),z(e,d,null),w(t=>L(e,{...q()},t)),e})()]}}),null),w(e=>L(n,cg,e)),e}}),null),z(e,f(ug,{get store(){return p()},get capacity(){return m()}}),null),w(e=>L(t,cg,e)),e})()}var yg={creep:fg,flag:pg,controller:mg,spawn:hg,extension:hg,tower:hg,link:hg,storage:gg,terminal:gg,container:gg,lab:gg,factory:gg,nuker:gg,powerSpawn:gg,powerBank:_g,ruin:vg};function bg(e){let t=()=>eg[e.item.type]??`#c9d1d9`,n=()=>tg[e.item.type]??e.item.type,r=()=>e.item.type===`creep`,i=()=>e.item.type===`flag`,o=()=>{if(!r())return!1;let t=e.item.raw,n=typeof t.user==`string`?t.user:null;return n!==null&&n===U()?._id},s=()=>{if(r()||i()||e.item.type===`controller`)return!1;let t=e.item.raw,n=typeof t.user==`string`?t.user:null;return n===null?gf()?.userId===U()?._id:n===U()?._id},c=()=>yg[e.item.type]||lg,[l,u]=a(!1),d=null,[p,m]=a(!1),h=null,[g,_]=a(!1),y=null,b=t=>{if(t.stopPropagation(),!g()){_(!0),y=setTimeout(()=>_(!1),3e3);return}y&&=(clearTimeout(y),null),_(!1);let n=H();if(!n)return;let r=e.item.id,i=e.item.raw;n.http.game.removeFlag(i.room,i.name).then(()=>df(r)).catch(()=>{})},x=t=>{if(t.stopPropagation(),!p()){m(!0),h=setTimeout(()=>m(!1),3e3);return}h&&=(clearTimeout(h),null),m(!1);let n=H();if(!n)return;let r=e.item.id,i=e.item.raw,a=(typeof i.room==`string`?i.room:null)??Af()??``;if(e.item.type===`constructionSite`)n.http.game.removeConstructionSite(a,[r],Of()??void 0).then(()=>df(r)).catch(e=>$h(`removeConstructionSite failed:`,e));else{let e=typeof i.user==`string`?i.user:gf()?.userId??``;n.http.game.addObjectIntent(`room`,a,`destroyStructure`,[{id:r,roomName:a,user:e}],Of()).then(()=>df(r)).catch(e=>$h(`destroyStructure failed:`,e))}},S=t=>{if(t.stopPropagation(),!l()){u(!0),d=setTimeout(()=>u(!1),3e3);return}d&&=(clearTimeout(d),null),u(!1);let n=H();if(!n)return;let r=e.item.id;n.http.game.addObjectIntent(r,Af()??e.item.raw.room??``,`suicide`,{id:r},Of()).then(()=>df(r)).catch(e=>$h(`suicide failed:`,e))};return(()=>{var a=qh(),u=a.firstChild,d=u.firstChild,m=d.nextSibling,h=m.firstChild.nextSibling,_=h.nextSibling.nextSibling;_.nextSibling;var y=m.nextSibling;return z(u,f(v,{get when(){return N(()=>!r())()&&!i()},get children(){var e=Wh();return w(n=>R(e,`background`,t())),e}}),d),z(d,f(v,{get when(){return i()},get fallback(){return N(n)},get children(){return f(Yr,{size:12})}}),null),z(d,f(v,{get when(){return N(()=>typeof e.item.raw.name==`string`)()&&e.item.raw.name},children:e=>(()=>{var t=Jh();return z(t,()=>e()),t})()}),null),z(m,()=>e.item.raw.x,h),z(m,()=>e.item.raw.y,_),z(u,f(v,{get when(){return N(()=>!!o())()&&!K()},get children(){return[(()=>{var e=Gh();return e.addEventListener(`mouseleave`,e=>{l()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{l()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=S,z(e,f(Yi,{size:13})),w(t=>{var n=l()?`Click again to confirm suicide`:`Suicide`,r=l()?`#f85149`:`#8b949e`;return n!==t.e&&I(e,`title`,t.e=n),r!==t.t&&R(e,`color`,t.t=r),t},{e:void 0,t:void 0}),e})(),(()=>{var t=Kh();return t.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),t.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),t.$$click=()=>{_m(e.item.id,e.item.raw.name),$p(!0)},z(t,f(Gr,{size:13})),t})()]}}),y),z(u,f(v,{get when(){return N(()=>!!s())()&&!K()},get children(){var t=Gh();return t.addEventListener(`mouseleave`,e=>{p()||(e.currentTarget.style.color=`#8b949e`)}),t.addEventListener(`mouseenter`,e=>{p()||(e.currentTarget.style.color=`#f85149`)}),t.$$click=x,z(t,f(Yi,{size:13})),w(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&&I(t,`title`,n.e=r),i!==n.t&&R(t,`color`,n.t=i),n},{e:void 0,t:void 0}),t}}),y),z(u,f(v,{get when(){return N(()=>!!i())()&&!K()},get children(){var e=Gh();return e.addEventListener(`mouseleave`,e=>{g()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{g()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=b,z(e,f(Yi,{size:13})),w(t=>{var n=g()?`Click again to confirm deletion`:`Delete flag`,r=g()?`#f85149`:`#8b949e`;return n!==t.e&&I(e,`title`,t.e=n),r!==t.t&&R(e,`color`,t.t=r),t},{e:void 0,t:void 0}),e}}),y),y.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),y.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#fff`),y.$$click=()=>df(e.item.id),z(a,f(We,{get component(){return c()},get item(){return e.item}}),null),z(a,f(v,{get when(){return e.item.id},children:e=>(()=>{var t=Yh();return t.$$click=()=>navigator.clipboard?.writeText(e()),z(t,e),w(()=>I(t,`title`,e())),t})()}),null),w(e=>R(a,`border`,`1px solid ${o()&&l()||p()||g()?`#f85149`:`#30363d`}`)),a})()}function xg(){return(()=>{var e=Xh();return z(e,f(v,{get when(){return cf().length>0},get fallback(){return Zh()},get children(){return f(u,{get each(){return cf()},children:e=>f(bg,{item:e})})}})),e})()}F([`click`,`input`]);var Sg=P(`<div style="padding:3px 0;color:#8b949e">Reserved by`),Cg=P(`<div style="padding:3px 0;color:#c9d1d9">`),wg=P(`<div style="padding:3px 0;color:#8b949e">Expires in`),Tg=P(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums"> ticks`),Eg=P(`<div style="padding:3px 0;color:#8b949e">RCL`),Dg=P(`<span style=color:#8b949e>(<!>%)`),Og=P(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums">`),kg=P(`<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">`),Ag=P(`<span>`),jg=P(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;display:flex;align-items:center;justify-content:center">`),Mg=[{mode:`view`,label:`View`,icon:()=>f(Gr,{size:14})},{mode:`flag`,label:`Flag`,icon:()=>f(Yr,{size:14})},{mode:`build`,label:`Build`,icon:()=>f(ti,{size:14})}];function Ng(e){return(()=>{var t=kg(),n=t.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling,a=i.firstChild.nextSibling,o=a.nextSibling.nextSibling,s=o.nextSibling.nextSibling,c=s.nextSibling.nextSibling,l=c.nextSibling.nextSibling,d=i.nextSibling,p=d.firstChild.nextSibling,m=d.nextSibling.firstChild.nextSibling,h=n.nextSibling,g=h.firstChild;return z(r,()=>e.room),z(a,()=>e.shard??`—`),z(o,()=>En()??`—`),z(s,(()=>{var e=N(()=>!!On());return()=>e()?`${On()}ms`:`—`})()),z(c,()=>mf()??`—`),z(l,()=>gf()?.username??`—`),z(i,f(v,{get when(){return N(()=>!gf())()&&Sf()},get children(){return[Sg(),(()=>{var e=Cg();return z(e,()=>Ef()?.[Sf().user]?.username??Sf().user),e})(),wg(),(()=>{var e=Tg(),t=e.firstChild;return z(e,(()=>{var e=N(()=>En()!==null);return()=>e()?Math.max(0,Sf().endTime-En()):`—`})(),t),e})()]}}),null),z(i,f(v,{get when(){return N(()=>vf()!==null)()&&vf()>0},get children(){return[Eg(),(()=>{var e=Og();return z(e,f(v,{get when(){return N(()=>vf()<8)()&&bf()!==null},get fallback(){return(()=>{var e=Ag();return z(e,vf),e})()},get children(){return[N(()=>vf()),` → `,N(()=>vf()+1),`\xA0`,(()=>{var e=Dg(),t=e.firstChild.nextSibling;return t.nextSibling,z(e,()=>(bf()/(vs[vf()]??1)*100).toFixed(1),t),e})()]}})),e})()]}}),null),p.addEventListener(`change`,e=>fd(e.currentTarget.checked)),m.addEventListener(`change`,e=>wd(e.currentTarget.checked)),z(h,f(v,{get when(){return!An()},get children(){return f(u,{each:Mg,children:e=>{let t=()=>!K()&&bp()===e.mode;return(()=>{var n=jg();return n.$$click=()=>{K()&&rp(),xp(e.mode)},z(n,()=>e.icon()),w(r=>{var i=e.label,a=`1px solid ${t()?`#58a6ff`:`#30363d`}`,o=t()?`#1f6feb33`:`#161b22`,s=t()?`#c9d1d9`:`#8b949e`;return i!==r.e&&I(n,`title`,r.e=i),a!==r.t&&R(n,`border`,r.t=a),o!==r.a&&R(n,`background`,r.a=o),s!==r.o&&R(n,`color`,r.o=s),r},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()}})}}),g),g.$$click=()=>K()?rp():En()!==null&&np(En()),z(g,f(Lr,{size:14})),w(e=>{var t=`repeat(${An()?2:4}, 1fr)`,n=!K()&&En()===null,r=An()?`span 2`:void 0,i=`1px solid ${K()?`#58a6ff`:`#30363d`}`,a=K()?`#1f6feb33`:`#161b22`,o=K()?`#c9d1d9`:`#8b949e`,s=!K()&&En()===null?`not-allowed`:`pointer`,c=!K()&&En()===null?.4:1;return t!==e.e&&R(h,`grid-template-columns`,e.e=t),n!==e.t&&(g.disabled=e.t=n),r!==e.a&&R(g,`grid-column`,e.a=r),i!==e.o&&R(g,`border`,e.o=i),a!==e.i&&R(g,`background`,e.i=a),o!==e.n&&R(g,`color`,e.n=o),s!==e.s&&R(g,`cursor`,e.s=s),c!==e.h&&R(g,`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}),w(()=>p.checked=dd()),w(()=>m.checked=Cd()),t})()}F([`click`]);var[Pg,Fg]=a(`owner`),Ig=3,Lg=Ig*50,Rg=4;function zg(e,t,n){let r=Nf(e);return r?[r.x*Lg+t*Ig,r.y*Lg+n*Ig]:null}var Bg=3*Ig,Vg=2.5*Ig,Hg=1*Ig,Ug=2*Ig;function Wg(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 Gg(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 Kg=class{container;g;constructor(){this.container=new M,this.container.label=`mapVisuals`,this.g=new O,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=zg(t.n1,t.x1,t.y1),a=zg(t.n2,t.x2,t.y2);if(!i||!a)return;let o=n.color??`#ffffff`,s=(n.width??.5)*Ig;n.lineStyle===`dashed`?Wg(e,[i,a],Bg*(n.width??.5),Vg*(n.width??.5)):n.lineStyle===`dotted`?Wg(e,[i,a],Hg*(n.width??.5),Ug*(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=zg(t.n,t.x,t.y);if(!i)return;let[a,o]=i,s=(n.radius??10)*Ig,c=!!(n.fill&&n.fill!==`transparent`),l=!!(n.stroke&&n.strokeWidth),u=(n.strokeWidth??.5)*Ig;c&&(e.circle(a,o,s),e.fill({color:n.fill,alpha:r})),l&&(n.lineStyle===`dashed`?Wg(e,Gg(a,o,s),Bg*(n.strokeWidth??.5),Vg*(n.strokeWidth??.5)):n.lineStyle===`dotted`?Wg(e,Gg(a,o,s),Hg*(n.strokeWidth??.5),Ug*(n.strokeWidth??.5)):e.circle(a,o,s),e.stroke({color:n.stroke,width:u,alpha:r}))}drawRect(e,t,n,r){let i=zg(t.n,t.x,t.y),a=zg(t.n,t.x+t.w,t.y),o=zg(t.n,t.x+t.w,t.y+t.h),s=zg(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)*Ig;c&&(e.poly(d.slice(0,8),!0),e.fill({color:n.fill,alpha:r})),l&&(n.lineStyle===`dashed`?Wg(e,u,Bg*(n.strokeWidth??.5),Vg*(n.strokeWidth??.5)):n.lineStyle===`dotted`?Wg(e,u,Hg*(n.strokeWidth??.5),Ug*(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=zg(e,n,r);if(!t)return;o.push(t)}let s=o.flatMap(e=>e),c=(n.strokeWidth??.5)*Ig;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];Wg(e,t[0]===r[0]&&t[1]===r[1]?o:[...o,t],Bg*(n.strokeWidth??.5),Vg*(n.strokeWidth??.5))}else if(n.lineStyle===`dotted`){let t=o[0],r=o[o.length-1];Wg(e,t[0]===r[0]&&t[1]===r[1]?o:[...o,t],Hg*(n.strokeWidth??.5),Ug*(n.strokeWidth??.5))}else e.poly(s,!0);e.stroke({color:n.stroke,width:c,alpha:r})}}drawText(e,t,n){let r=zg(e.n,e.x,e.y);if(!r)return;let[i,a]=r,o=t.fontSize??10,s=t.fontFamily??`sans-serif`,c=o*Ig,l=t.align??`center`,u=new se({fill:t.color??`#ffffff`,fontSize:c*Rg,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*Ig*Rg}}:{}});if(t.backgroundColor&&t.backgroundColor!==`transparent`){let r=(t.backgroundPadding??2)*Ig,o=new ae({text:e.text,style:u});o.scale.set(1/Rg);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 O;p.rect(d,f,s+r*2,c+r*2),p.fill({color:t.backgroundColor,alpha:n}),this.container.addChild(p)}let d=new ae({text:e.text,style:u});d.scale.set(1/Rg),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:qg}=rn(`terrainCache`),Jg=`screeps-terrain-v1`;async function Yg(e,t,n){try{let r=await caches.open(Jg),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){qg(`get failed:`,e)}return null}async function Xg(e,t,n,r){try{let i=await caches.open(Jg),a=`/terrain/${e}_${t}_z${n}.webp`,o=new Request(a),s=new Response(r);await i.put(o,s)}catch(e){qg(`save failed:`,e)}}var Zg=null;async function Qg(e){if(Zg!==!1)try{let t=await createImageBitmap(e);return Zg=!0,t}catch(e){if(Zg===!0)throw e;Zg=!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 $g(e){return new Worker(`/client/_client/terrain.worker-CiQZPqa4.js`,{name:e?.name})}var e_=2962235,t_=856343,n_=4020797,r_=to,i_=4486980,a_=8921634,o_=oo,s_=go,c_=[{key:`s`,color:yo,radius:2.5},{key:`c`,color:16777215,radius:2},{key:`m`,color:ao,radius:2},{key:`k`,color:po,radius:2},{key:`pb`,color:16720418,radius:2.5},{key:`d`,color:16777215,radius:2.5}],l_=new Set([`w`,`r`,`pb`,`p`,`s`,`c`,`m`,`k`,`d`]);function u_(e){return`#`+e.toString(16).padStart(6,`0`)}var{warn:d_}=rn(`MapRenderer`),f_=3,J=f_*50,p_=[50,60,70,80,90,100,105,120],m_=1,h_=.5,g_=50,__=2600,v_=5,y_=.2,b_=5,x_=[80,104,128,160],S_=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 _s;constructor(e){this.app=new k,this.callbacks=e,this.worker=new $g,this.worker.onmessage=e=>{let t=e.data;if(t.kind===`cache`){Xg(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:eo,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 M,this.app.stage.addChild(this.world),this.boundsGraphics=new O,this.world.addChild(this.boundsGraphics),this.selectionGraphics=new O,this.world.addChild(this.selectionGraphics),this.safeModeGraphics=new O,this.world.addChild(this.safeModeGraphics),this.mapVisualLayer=new Kg,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(y_,Math.min(b_,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>=m_,o=this.zoom>=h_,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>=m_!==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*J+J/2,i=t*J+J/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 Yg(r,e,t);if(i)return await Qg(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 d_(`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=j.from(o);a===0?(i.texLo&&!i.texLo.destroyed&&(i.terrainSprite.texture===i.texLo&&(i.terrainSprite.texture=j.EMPTY),i.texLo.destroy(!0)),i.texLo=s):(i.texHi&&!i.texHi.destroyed&&(i.terrainSprite.texture===i.texHi&&(i.terrainSprite.texture=j.EMPTY),i.texHi.destroy(!0)),i.texHi=s),i.terrainSprite.width=J,i.terrainSprite.height=J,this.terrainBaked.add(e),this.ensureCurrentLod(e,i)}getLOD(){return this.zoom<m_?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=j.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;let i=f_;r.clear();let a=t.r??[];for(let[e,t]of a)r.rect(e*i,t*i,i,i);a.length&&r.fill(r_);let o=t.w??[];for(let[e,t]of o)r.rect(e*i+.5,t*i+.5,i-1,i-1);o.length&&r.fill(e.ownerState===`other`?a_:i_);for(let e of c_){let n=t[e.key]??[];for(let[t,a]of n)r.circle((t+.5)*i,(a+.5)*i,e.radius);n.length&&r.fill(e.color)}let s=t;for(let e in s){if(l_.has(e))continue;let t=s[e];if(!Array.isArray(t)||t.length===0)continue;for(let[e,n]of t)r.circle((e+.5)*i,(n+.5)*i,1);let n=e===this.currentUserId?o_:s_;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,J,J),r.fill({color:10027008,alpha:.18})):t===`own`&&(r.rect(0,0,J,J),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 A(i);e.anchor.set(.5),e.x=J/2,e.y=J/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){d_(`failed to load badge for`,e,t)}}}applyBadgeSize(e,t){if(!e.badgeSprite||e.badgeLevel===void 0)return;let n=(p_[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 A;n.anchor.set(.5),n.x=J/2,n.y=J/2;let i=r.container.getChildIndex(r.nameLabel);r.container.addChildAt(n,i),r.mineralSprite=n,r.mineralType=t;let a=Pd.getTexture(jd.atlasUrl,e);a?n.texture=a:Pd.getOrLoad(jd.atlasUrl).then(t=>{n.destroyed||(n.texture=t.textures[e]??j.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=x_[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=Nf(e);if(!t)return;let n=t.x*J,r=t.y*J;this.selectionGraphics.rect(n,r,J,J);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=Nf(t);if(!n)continue;let r=n.x*J,i=n.y*J;this.safeModeGraphics.rect(r,i,J,J),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*J,a=n*J,o=(t-e+1)*J,s=(r-n+1)*J;this.boundsGraphics.rect(i,a,o,s),this.boundsGraphics.stroke({color:no,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=j.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<__?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=Nf(n);if(e&&e.x>=t.rxMin-g_&&e.x<=t.rxMax+g_&&e.y>=t.ryMin-g_&&e.y<=t.ryMax+g_)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){d_(`destroy error (ignored):`,e)}}}getOrCreate(e){let t=this.activeRooms.get(e);if(t)return t;let n=Nf(e);if(!n)throw Error(`MapRenderer: invalid room "${e}"`);let r;if(this.roomPool.length>0)r=this.roomPool.pop();else{let e=new M;e.cullable=!0;let t=new A(j.EMPTY),n=new O,i=new O;e.addChild(t),e.addChild(n),e.addChild(i);let a=new ae({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*J,r.container.y=n.y*J,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=Nf(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(y_,Math.min(b_,this.pinchStartScale*(o/this.pinchStartDist))),c=this.getLOD(),l=this.zoom>=m_,u=this.zoom>=h_;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>=m_!==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)*J*n,a=this.app.screen.width-50-r.minX*J*n,o=50-(r.maxY+1)*J*n,s=this.app.screen.height-50-r.minY*J*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(y_,Math.min(b_,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*J*t,a=this.world.x+(e.maxX+1)*J*t,o=this.world.y+e.minY*J*t,s=this.world.y+(e.maxY+1)*J*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 Pf(Math.floor(r/J),Math.floor(i/J))}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/J)-1,c=Math.ceil(a/J),l=Math.floor(i/J)-1,u=Math.ceil(o/J);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=Pf(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)},v_))}},C_=P(`<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">`),w_=P(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;font-size:11px;font-weight:600">`),T_=[{mode:`owner`,label:`Owner`},{mode:`mineral`,label:`Mineral`},{mode:`none`,label:`None`}];function E_(e){let t=()=>(e.zoom??1)>=h_;return(()=>{var n=C_(),r=n.firstChild,i=r.firstChild.nextSibling,a=i.firstChild.nextSibling,o=a.nextSibling.nextSibling,s=i.nextSibling,c=s.firstChild.nextSibling,l=s.nextSibling,d=l.firstChild.nextSibling,p=l.nextSibling.firstChild.nextSibling,m=r.nextSibling;return z(a,()=>e.zoom?.toFixed(2)??`—`),z(o,()=>e.subsActive?`Yes`:`No`),c.addEventListener(`change`,e=>md(e.currentTarget.checked)),d.addEventListener(`change`,e=>gd(e.currentTarget.checked)),p.addEventListener(`change`,e=>Od(e.currentTarget.checked)),z(m,f(u,{each:T_,children:e=>{let t=()=>Pg()===e.mode;return(()=>{var n=w_();return n.$$click=()=>Fg(e.mode),z(n,()=>e.label),w(e=>{var r=`1px solid ${t()?`#58a6ff`:`#30363d`}`,i=t()?`#1f6feb33`:`#161b22`,a=t()?`#c9d1d9`:`#8b949e`;return r!==e.e&&R(n,`border`,e.e=r),i!==e.t&&R(n,`background`,e.t=i),a!==e.a&&R(n,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),n})()}})),w(e=>{var n=t()?`#c9d1d9`:`#484f58`,r=t()?`pointer`:`default`,i=!t();return n!==e.e&&R(s,`color`,e.e=n),r!==e.t&&R(s,`cursor`,e.t=r),i!==e.a&&(c.disabled=e.a=i),e},{e:void 0,t:void 0,a:void 0}),w(()=>c.checked=pd()),w(()=>d.checked=hd()),w(()=>p.checked=Dd()),n})()}F([`click`]);var D_=P(`<img width=12 height=12 alt style="border-radius:2px;flex:0 0 auto;display:block">`),O_=P(`<div style="padding:3px 8px;color:#484f58">None`),k_=P(`<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>`),A_=P(`<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">`),j_=P(`<div style="padding:6px 8px;font-size:11px;color:#484f58;font-style:italic">None`),M_=P(`<div style="padding:3px 8px;color:#8b949e">Reservation`),N_=P(`<div style="padding:3px 8px;color:#8b949e">Mineral`),P_=P(`<div style="padding:3px 8px;color:#79c0ff">`),F_=P(`<div style="padding:3px 8px;color:#8b949e">Density`),I_=P(`<div style="padding:3px 8px;color:#c9d1d9">`),L_=P(`<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">`),R_=P(`<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">`),z_=P(`<div style="padding:3px 8px;color:#8b949e">Owner`),B_=P(`<div style=display:flex;align-items:center;gap:4px;align-self:flex-end;color:#8b949e><span>&mdash;</span><span>`),V_=P(`<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>&ldquo;<!>&rdquo;</div><div style=align-self:flex-end;color:#484f58;font-size:10px>`),H_=[`Low`,`Medium`,`High`,`Ultra`];function U_(e){return H_[e-1]??String(e)}function W_(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 G_(e){let t=x(()=>`data:image/svg+xml,${encodeURIComponent(Kt(e.badge))}`);return(()=>{var e=D_();return w(()=>I(e,`src`,t())),e})()}function K_(e){return f(v,{get when(){return e.name},get fallback(){return O_()},children:t=>(()=>{var n=k_(),r=n.firstChild;return z(n,f(v,{get when(){return e.badge},children:e=>f(G_,{get badge(){return e()}})}),r),z(r,t),n})()})}function q_(e){return(()=>{var t=A_(),n=t.firstChild;return z(n,()=>e.label),z(t,f(v,{get when(){return e.info},get fallback(){return j_()},children:e=>(()=>{var t=L_(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return z(r,()=>e().room),z(n,f(v,{get when(){return e().level},children:e=>(()=>{var t=R_();return z(t,e),t})()}),null),z(i,f(v,{get when(){return e().reservation},get fallback(){return[z_(),f(K_,{get name(){return e().owner},get badge(){return e().badge}})]},get children(){return[M_(),f(K_,{get name(){return e().reservation},get badge(){return e().badge}})]}}),null),z(i,f(v,{get when(){return e().mineral},get children(){return[N_(),(()=>{var t=P_();return z(t,()=>e().mineral),t})(),F_(),(()=>{var t=I_();return z(t,()=>U_(e().density??0)),t})()]}}),null),z(t,f(v,{get when(){return e().sign},children:e=>(()=>{var t=V_(),n=t.firstChild.nextSibling,r=n.firstChild.nextSibling;r.nextSibling;var i=n.nextSibling;return z(n,()=>e().text,r),z(t,f(v,{get when(){return e().username||e().badge},get children(){var t=B_(),n=t.firstChild.nextSibling;return z(t,f(v,{get when(){return e().badge},children:e=>f(G_,{get badge(){return e()}})}),n),z(n,()=>e().username),t}}),i),z(i,()=>W_(e().datetime)),t})()}),null),t})()}),null),w(n=>{var r=`1px solid ${e.dim?`#21262d`:`#30363d`}`,i=e.dim?.6:1;return r!==n.e&&R(t,`border`,n.e=r),i!==n.t&&R(t,`opacity`,n.t=i),n},{e:void 0,t:void 0}),t})()}var J_=P(`<span style=color:#8b949e;font-size:11px>Checking…`),Y_=P(`<div style=margin-top:8px><div style="padding:6px 8px;font-size:11px;font-weight:600;color:#c9d1d9;margin-bottom:6px">Your flags`),X_=P(`<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>`),Z_=P(`<span style=color:#f85149;font-size:11px>`),Q_=P(`<div style=margin-top:8px;color:#484f58;font-style:italic;font-size:12px>No flags.`),$_=P(`<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:ev}=rn(`flag`),tv={};for(let[e,t]of Object.entries(vp))tv[t]=e;function nv(){let e=e=>{Cp({...Sp(),...e})},[t,n]=a(null),[r,i]=a(!1),o=null,c=t=>{t.http.game.genUniqueFlagName().then(t=>{e({name:t.name}),n(null)}).catch(e=>{ev(`gen unique name failed:`,e)})};s(()=>{if(bp()!==`flag`)return;let e=H();if(!e)return;let t=m(()=>Sp().name.trim());if(!t){c(e);return}e.http.game.checkUniqueFlagName(t).then(()=>{n(null)}).catch(()=>{c(e)})});let l=t=>{e({name:t}),n(null),o&&clearTimeout(o);let r=t.trim();if(!r){i(!1);return}i(!0),o=setTimeout(()=>{let e=H();if(!e){i(!1);return}e.http.game.checkUniqueFlagName(r).then(()=>{n(null)}).catch(e=>{n(e.message)}).finally(()=>{i(!1)})},300)},d=()=>vp[Sp().color]??1,p=()=>vp[Sp().secondaryColor]??1,h=t=>{e({color:tv[t]??`COLOR_WHITE`})},g=t=>{e({secondaryColor:tv[t]??`COLOR_WHITE`})},_=()=>{let e=In(),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>=_o.length?`#8b949e`:`#${_o[e].toString(16).padStart(6,`0`)}`,b={display:`flex`,"flex-direction":`column`,gap:`5px`,"font-size":`11px`,color:`#8b949e`};return(()=>{var e=X_(),n=e.firstChild.firstChild.nextSibling.firstChild,i=n.firstChild.nextSibling,a=n.nextSibling;a.firstChild;var o=a.nextSibling;o.firstChild;var s=o.nextSibling;return i.$$input=e=>l(e.currentTarget.value),z(n,f(v,{get when(){return t()},children:e=>(()=>{var t=Z_();return z(t,e),t})()}),null),z(n,f(v,{get when(){return r()},get children(){return J_()}}),null),z(a,f(rh,{get value(){return d()},onChange:h}),null),z(o,f(rh,{get value(){return p()},onChange:g}),null),z(s,(()=>{var e=N(()=>!!wp());return()=>e()?`Marked at x=${wp().tx}, y=${wp().ty}. Click again to create the flag, or click elsewhere to move the mark.`:`Click a position in the room to mark it.`})()),z(e,f(v,{get when(){return _().length>0},get fallback(){return Q_()},get children(){var e=Y_();return e.firstChild,z(e,f(u,{get each(){return _()},children:([e,t])=>(()=>{var n=$_(),r=n.firstChild.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling,s=o.firstChild.nextSibling,c=s.nextSibling.nextSibling;return c.nextSibling,z(i,e),z(a,()=>t.room),z(o,()=>t.x,s),z(o,()=>t.y,c),w(e=>R(r,`background`,y(t.color))),n})()}),null),e}}),null),w(e=>{var r=b,s=`1px solid ${t()?`#f85149`:`#30363d`}`,c=b,l=b;return e.e=L(n,r,e.e),s!==e.t&&R(i,`border`,e.t=s),e.a=L(a,c,e.a),e.o=L(o,l,e.o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),w(()=>i.value=Sp().name),e})()}F([`input`]);var rv=P(`<span style=color:#8b949e>…`),iv=P(`<span style=color:#3fb950>✓`),av=P(`<span style=color:#f85149>✗`),ov=P(`<div style=font-size:10px;color:#f85149>`),sv=P(`<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>`),cv=P(`<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>`),lv=P(`<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 uv(e){let t=Object.keys(yp),[i,o]=a(`idle`),[c,l]=a(``),d=null,p=(e,t)=>{let n=yp[e];return n?Rn()===`empty`&&e===`spawn`?Math.max(n[t]??0,1):n[t]??0:0},m=(e,t)=>{let n=p(e,t);if(n===2500)return 1/0;let r=wf()[e]??0;return Math.max(0,n-r)},h=()=>Op().structureType===`spawn`;s(r(()=>Op().structureType,(t,r)=>{if(t!==`spawn`||t===r)return;let i=H();if(!i)return;o(`loading`),l(``);let a=!1;n(()=>{a=!0}),i.http.game.genUniqueObjectName(`spawn`,e.shard).then(e=>{a||(kp({structureType:`spawn`,structureName:e.name}),o(`valid`))}).catch(()=>{a||(kp({structureType:`spawn`,structureName:`Spawn1`}),o(`idle`))})}));let g=t=>{if(d&&clearTimeout(d),!t.trim()){o(`invalid`),l(`Name cannot be empty`);return}o(`loading`),l(``),d=setTimeout(()=>{let n=H();n&&n.http.game.checkUniqueObjectName(`spawn`,t.trim(),e.shard).then(e=>{e.error?(o(`invalid`),l(e.error)):(o(`valid`),l(``))}).catch(()=>{o(`invalid`),l(`Could not validate name`)})},400)},_=e=>{kp({structureType:`spawn`,structureName:e}),g(e)},y=e=>{kp({structureType:e,structureName:``}),o(`idle`),l(``)},b=()=>{switch(i()){case`loading`:return rv();case`valid`:return iv();case`invalid`:return av();default:return null}};return(()=>{var e=cv(),n=e.firstChild,r=n.firstChild;r.firstChild;var a=r.nextSibling,o=n.nextSibling;o.firstChild;var s=o.nextSibling,l=s.firstChild;return z(r,()=>vf()??`?`,null),z(a,()=>{let e=Rn();return e===`empty`?`World is empty — place a spawn to claim this room.`:e===`lost`?`You lost all your spawns — respawn to continue.`:vf()==null?`No controller — roads and containers only.`:`RCL ${vf()} — Select a structure type and click a tile to build.`}),z(o,f(u,{each:t,children:e=>{let t=()=>vf()??0,n=()=>p(e,t()),r=()=>wf()[e]??0,i=()=>Op().structureType===e,a=()=>n()===2500,o=()=>!a()&&m(e,t())<=0;return f(v,{get when(){return n()>0},get children(){var t=lv(),s=t.firstChild,c=s.nextSibling;return t.$$click=()=>!o()&&y(e),z(s,()=>e.replace(/([A-Z])/g,` $1`).trim(),null),z(s,()=>i()&&` ✓`,null),z(c,(()=>{var e=N(()=>!!a());return()=>e()?`${r()}/∞`:`${r()}/${n()}`})(),null),z(c,()=>o()&&` (Max)`,null),w(e=>{var n=i()?`#1f3158`:`transparent`,r=o()?`default`:`pointer`,a=o()?.5:1;return n!==e.e&&R(t,`background`,e.e=n),r!==e.t&&R(t,`cursor`,e.t=r),a!==e.a&&R(t,`opacity`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),t}})}}),null),z(e,f(v,{get when(){return h()},get children(){var e=sv(),t=e.firstChild.nextSibling,n=t.firstChild.firstChild,r=n.nextSibling;return n.$$input=e=>_(e.currentTarget.value),z(r,b),z(t,f(v,{get when(){return N(()=>i()===`invalid`)()&&c()},get children(){var e=ov();return z(e,c),e}}),null),w(e=>R(n,`border`,`1px solid ${i()===`invalid`?`#f85149`:i()===`valid`?`#238636`:`#30363d`}`)),w(()=>n.value=Op().structureName??``),e}}),s),z(l,()=>Op().structureType?`Click a tile in the room to build.`:`Select a structure type, then click a tile.`),e})()}F([`input`,`click`]);var dv=P(`<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">`),fv=P(`<button type=button>`),pv=P(`<option>/s`),mv=[.5,1,2,5,10,20],hv=[{delta:-100,label:`-100`},{delta:-10,label:`-10`}],gv=[{delta:10,label:`+10`},{delta:100,label:`+100`}];function _v(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 vv(){let e=()=>{let e=Gf(),t=Vf(),n=On()??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=dv(),n=t.firstChild.firstChild,r=n.firstChild,i=r.nextSibling;i.firstChild;var a=n.nextSibling,o=a.firstChild,s=a.nextSibling.firstChild.nextSibling;return z(r,(()=>{var e=N(()=>!!Zf());return()=>e()?`Loading…`:`Tick ${Vf()}`})()),z(i,e,null),z(a,f(u,{each:hv,children:e=>(()=>{var t=fv();return t.$$click=()=>ap(e.delta),z(t,()=>e.label),w(e=>{var n=Zf(),r=_v(Zf());return n!==e.e&&(t.disabled=e.e=n),e.t=L(t,r,e.t),e},{e:void 0,t:void 0}),t})()}),o),Te(o,`click`,op,!0),z(o,()=>qf()?`⏸`:`▶`),z(a,f(u,{each:gv,children:e=>(()=>{var t=fv();return t.$$click=()=>ap(e.delta),z(t,()=>e.label),w(e=>{var n=Zf(),r=_v(Zf());return n!==e.e&&(t.disabled=e.e=n),e.t=L(t,r,e.t),e},{e:void 0,t:void 0}),t})()}),null),s.addEventListener(`change`,e=>sp(parseFloat(e.currentTarget.value))),z(s,f(u,{each:mv,children:e=>(()=>{var t=pv(),n=t.firstChild;return t.value=e,z(t,e,n),t})()})),w(e=>{var t=Zf()?`#f0883e`:`#c9d1d9`,n=Zf(),i=qf()?`#1a3a2a`:`#161b22`,a=qf()?`#3fb950`:`#8b949e`,s=Zf()?`not-allowed`:`pointer`;return t!==e.e&&R(r,`color`,e.e=t),n!==e.t&&(o.disabled=e.t=n),i!==e.a&&R(o,`background`,e.a=i),a!==e.o&&R(o,`color`,e.o=a),s!==e.i&&R(o,`cursor`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),w(()=>s.value=Yf()),t})()}F([`click`]);var yv=P(`<div style=padding-bottom:8px;overflow:auto;min-height:0>`),bv=P(`<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`),xv=P(`<button style=background:transparent;border:none;color:#8b949e;font-size:14px;cursor:pointer;padding:4px>`),Sv=P(`<button style=background:transparent;border:none;color:#8b949e;font-size:11px;cursor:pointer>Collapse`);function Cv(e){return f(v,{get when(){return bp()===`flag`},get fallback(){return f(v,{get when(){return bp()===`build`},get fallback(){return f(xg,{})},get children(){return f(uv,{get shard(){return e.shard}})}})},get children(){return f(nv,{})}})}function wv(e){let t=()=>{e.onToggle?.()},n=t=>{t.stopPropagation(),e.onToggle?.()};return(()=>{var r=bv(),i=r.firstChild,a=i.nextSibling,o=a.firstChild;return o.firstChild,i.$$click=t,z(i,(()=>{var t=N(()=>!!e.onToggle);return()=>t()&&(()=>{var t=xv();return t.$$click=n,z(t,()=>e.isCollapsed?`▶`:`◀`),t})()})()),z(o,(()=>{var t=N(()=>!!e.onToggle);return()=>t()&&(()=>{var e=Sv();return e.$$click=n,e})()})(),null),z(a,f(v,{get when(){return e.mapMode},get fallback(){return f(Ng,{get room(){return e.room??`—`},get shard(){return e.shard??null}})},get children(){return f(E_,{get zoom(){return e.mapZoom},get subsActive(){return e.mapSubsActive}})}}),null),z(a,f(v,{get when(){return N(()=>!e.mapMode)()&&K()},get children(){return f(vv,{})}}),null),z(a,f(v,{get when(){return e.mapMode},get fallback(){return f(Cv,{get shard(){return e.shard}})},get children(){var t=yv();return z(t,f(q_,{label:`Selected`,get info(){return e.selectedRoomInfo??null}}),null),z(t,f(q_,{label:`Cursor`,get info(){return e.hoveredRoomInfo??null},dim:!0}),null),t}}),null),r})()}F([`click`]);var Tv=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>CPU:</span><span style=color:#c9d1d9>`),Ev=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Memory:</span><span style=color:#c9d1d9>`),Dv=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Zoom:</span><span style=color:#c9d1d9>%`),Ov=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Subs:</span><span>`),kv=P(`<div style="display:flex;gap:16px;padding:6px 16px;font-size:12px;color:#8b949e;align-items:center">`);function Av(e){let[t,r]=a(null);i(()=>{let e=H();if(!e)return;let t=new Et;t.add(e.stores.user.subscribe(`cpu`)),t.add(e.stores.user.on(`user:cpu`,e=>{r(e)})),n(()=>{t.dispose()})});let o=()=>{let e=t();if(!e)return`—`;let n=U()?.cpu??`?`;return`${e.cpu.toFixed(0)} / ${n}`},s=()=>{let e=t();return e?`${(e.memory/1024).toFixed(1)} KB`:`—`};return(()=>{var n=kv();return z(n,f(v,{get when(){return t()!==null},get children(){return[(()=>{var e=Tv(),t=e.firstChild.nextSibling;return z(t,o),e})(),(()=>{var e=Ev(),t=e.firstChild.nextSibling;return z(t,s),e})()]}}),null),z(n,f(v,{get when(){return N(()=>e.mapZoom!==null)()&&e.mapZoom!==void 0},get children(){return[(()=>{var t=Dv(),n=t.firstChild.nextSibling,r=n.firstChild;return z(n,()=>(e.mapZoom*100).toFixed(0),r),t})(),(()=>{var t=Ov(),n=t.firstChild.nextSibling;return z(n,()=>e.mapSubsActive===!1?`paused`:`active`),w(t=>R(n,`color`,e.mapSubsActive===!1?`#e3b341`:`#3fb950`)),t})()]}}),null),n})()}var jv=P(`<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">`),Mv=P(`<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>`),Nv=P(`<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">`),Pv=P(`<button style=width:100%;aspect-ratio:1;border-radius:2px;cursor:pointer;padding:0;outline:none>`),Fv={};for(let e=1;e<=24;e++){let t=Kt({type:e,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1});Fv[e]=`data:image/svg+xml,${encodeURIComponent(t)}`}function Iv(e){return typeof e==`string`?e:Wt[e]?.rgb??`#000000`}function Lv(e){return typeof e==`number`?Math.max(0,Math.min(79,e)):e}var Rv=[{slot:1,label:`Background`},{slot:2,label:`Primary`},{slot:3,label:`Secondary`}],zv=Array.from({length:24},(e,t)=>t+1),Bv=/^#[0-9a-f]{6}$/i;function Vv(e){let[t,n]=a(m(()=>typeof e.badge.type==`number`?e.badge.type:1)),[r,i]=a(m(()=>Lv(e.badge.color1))),[o,c]=a(m(()=>Lv(e.badge.color2))),[l,d]=a(m(()=>Lv(e.badge.color3))),[p,h]=a(m(()=>e.badge.param??0)),[g,_]=a(m(()=>e.badge.flip??!1)),[v,y]=a(1),[b,S]=a(!1),[C,T]=a(m(()=>Iv(Lv(e.badge.color1)))),E=e=>e===1?r():e===2?o():l(),D=e=>{let t=v();t===1?i(e):t===2?c(e):d(e)};s(()=>{T(Iv(E(v())))});let O=e=>{let t=E(v());return typeof t==`number`?t===e:t.toLowerCase()===(Wt[e]?.rgb??``).toLowerCase()},ee=()=>({type:t(),color1:Iv(r()),color2:Iv(o()),color3:Iv(l()),param:p(),flip:g()}),k=x(()=>{let e=Kt(ee());return`data:image/svg+xml,${encodeURIComponent(e)}`}),A=e=>{if(T(e),!Bv.test(e))return;let t=Wt.findIndex(t=>t.rgb.toLowerCase()===e.toLowerCase());D(t>=0?t:e)},te=async()=>{let t=H();if(t){S(!0);try{await t.http.user.badge(ee()),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{S(!1)}}},ne=t=>{t.target===t.currentTarget&&e.onClose()};return(()=>{var r=jv(),i=r.firstChild.firstChild,a=i.firstChild.nextSibling,o=i.nextSibling,s=o.firstChild,c=s.firstChild,l=c.firstChild.nextSibling,d=c.nextSibling.firstChild.nextSibling,m=s.nextSibling,x=m.firstChild.nextSibling,S=x.nextSibling,T=S.nextSibling.firstChild,ee=T.nextSibling,re=m.nextSibling,ie=re.firstChild,j=ie.firstChild.nextSibling,ae=ie.nextSibling,oe=re.nextSibling.firstChild,M=o.nextSibling.firstChild,se=M.nextSibling;return r.$$click=ne,a.$$click=()=>e.onClose(),z(a,f($i,{size:18})),z(d,f(u,{each:zv,children:e=>(()=>{var r=Mv(),i=r.firstChild;return r.$$click=()=>n(e),w(n=>{var a=t()===e?`#1f3a2a`:`#0d1117`,o=`1px solid ${t()===e?`#238636`:`#21262d`}`,s=t()===e?k():Fv[e];return a!==n.e&&R(r,`background`,n.e=a),o!==n.t&&R(r,`border`,n.t=o),s!==n.a&&I(i,`src`,n.a=s),n},{e:void 0,t:void 0,a:void 0}),r})()})),z(x,f(u,{each:Rv,children:({slot:e,label:t})=>(()=>{var n=Nv(),r=n.firstChild;return n.$$click=()=>y(e),z(n,t,null),w(t=>{var i=`1px solid ${v()===e?`#58a6ff`:`#30363d`}`,a=v()===e?`#1c2d47`:`transparent`,o=v()===e?`#58a6ff`:`#8b949e`,s=Iv(E(e));return i!==t.e&&R(n,`border`,t.e=i),a!==t.t&&R(n,`background`,t.t=a),o!==t.a&&R(n,`color`,t.a=o),s!==t.o&&R(r,`background`,t.o=s),t},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()})),z(S,f(u,{each:Wt,children:e=>(()=>{var t=Pv();return t.$$click=()=>D(e.index),w(n=>{var r=e.rgb,i=e.rgb,a=O(e.index)?`2px solid #fff`:`1px solid transparent`;return r!==n.e&&I(t,`title`,n.e=r),i!==n.t&&R(t,`background`,n.t=i),a!==n.a&&R(t,`border`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),ee.$$input=e=>A(e.currentTarget.value),z(j,p),ae.$$input=e=>h(+e.currentTarget.value),oe.addEventListener(`change`,e=>_(e.currentTarget.checked)),M.$$click=()=>e.onClose(),se.$$click=te,z(se,()=>b()?`Saving…`:`Save Badge`),w(e=>{var t=k(),n=Bv.test(C())?C():Iv(E(v())),r=`1px solid ${Bv.test(C())?`#30363d`:`#f85149`}`,i=b(),a=b()?`not-allowed`:`pointer`,o=b(),s=b()?`not-allowed`:`pointer`,c=b()?.7:1;return t!==e.e&&I(l,`src`,e.e=t),n!==e.t&&R(T,`background`,e.t=n),r!==e.a&&R(ee,`border`,e.a=r),i!==e.o&&(M.disabled=e.o=i),a!==e.i&&R(M,`cursor`,e.i=a),o!==e.n&&(se.disabled=e.n=o),s!==e.s&&R(se,`cursor`,e.s=s),c!==e.h&&R(se,`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}),w(()=>ee.value=C()),w(()=>ae.value=p()),w(()=>oe.checked=g()),r})()}F([`click`,`input`]);var Hv=P(`<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">`),Uv=P(`<div style=font-size:11px;color:#8b949e;margin-top:3px>`),Wv=P(`<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>`),Gv=P(`<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>`),Kv=P(`<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)`),qv=P(`<img width=40 height=40 style=display:block>`),Jv=P(`<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">`),Yv=P(`<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">`),Xv=P(`<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>`),Zv={type:1,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1};function Qv(e){return(()=>{var t=Hv(),n=t.firstChild,r=n.firstChild,i=n.nextSibling,a=i.firstChild;return z(r,()=>e.label),z(n,(()=>{var t=N(()=>!!e.description);return()=>t()&&(()=>{var t=Uv();return z(t,()=>e.description),t})()})(),null),i.$$click=()=>e.onChange(!e.value),w(t=>{var n=e.value?`#238636`:`#30363d`,r=e.value?`22px`:`2px`;return n!==t.e&&R(i,`background`,t.e=n),r!==t.t&&R(a,`left`,t.t=r),t},{e:void 0,t:void 0}),t})()}function $v(e){return(()=>{var t=Wv(),n=t.firstChild;return z(n,()=>e.title),z(t,()=>e.children,null),t})()}function ey(e){return(()=>{var t=Gv(),n=t.firstChild,r=n.nextSibling;return z(n,()=>e.label),z(r,()=>e.value),t})()}function ty(e){let t=tn(),n=!An()&&!U()?.badge,[r,i]=a(n),[o,s]=a(!1),c=x(()=>{let e=U()?.badge;if(!e)return null;let t=Kt(e);return`data:image/svg+xml,${encodeURIComponent(t)}`});async function l(){s(!0);try{await gn(),B(`All caches cleared. Reloading…`,`success`,2e3),setTimeout(()=>window.location.reload(),1500)}catch{B(`Failed to clear caches.`,`error`),s(!1)}}return(()=>{var a=Xv(),s=a.firstChild,u=s.firstChild.nextSibling,d=s.nextSibling,p=d.firstChild;return u.$$click=()=>e.onClose(),z(u,f($i,{size:18})),z(a,f(v,{get when(){return r()},get children(){return f(Vv,{get badge(){return U()?.badge??Zv},onClose:()=>i(!1),onSaved:n?()=>e.onClose():void 0})}}),d),z(p,f($v,{title:`Layout`,get children(){return f(Qv,{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 ld()},onChange:ud})}}),null),z(p,f($v,{title:`Room View`,get children(){return[f(Qv,{label:`Terrain effects`,description:`Swamp glow and wall noise texture overlay.`,get value(){return _d()},onChange:vd}),f(Qv,{label:`Room decorations`,description:`Load player-activated theme decorations (floor, wall, road colors) from the server.`,get value(){return yd()},onChange:bd}),f(Qv,{label:`Dark overlay + lights`,description:`Darken the room and add per-object light glows.`,get value(){return xd()},onChange:Sd}),(()=>{var e=Kv(),t=e.firstChild.nextSibling;return t.addEventListener(`change`,e=>Ed(e.currentTarget.value)),w(()=>t.value=Td()),e})()]}}),null),z(p,f(v,{get when(){return!An()},get children(){return f($v,{title:`Player Badge`,get children(){var e=Jv(),t=e.firstChild,n=t.firstChild,r=t.nextSibling;return z(t,f(v,{get when(){return c()},get children(){var e=qv();return w(()=>I(e,`src`,c())),e}}),n),z(n,()=>U()?.username??``),r.$$click=()=>i(!0),z(r,()=>c()?`Edit Badge`:`Create Badge`),e}})}}),null),z(p,f($v,{title:`Data`,get children(){var e=Yv(),t=e.firstChild;t.firstChild.nextSibling;var n=t.nextSibling;return n.$$click=l,z(n,()=>o()?`Clearing…`:`Clear`),w(e=>{var t=o(),r=o()?`#8b949e`:`#f85149`,i=o()?`default`:`pointer`,a=o()?.6:1;return t!==e.e&&(n.disabled=e.e=t),r!==e.t&&R(n,`color`,e.t=r),i!==e.a&&R(n,`cursor`,e.a=i),a!==e.o&&R(n,`opacity`,e.o=a),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e}}),null),z(p,f($v,{title:`About`,get children(){return[f(ey,{label:`Client version`,get value(){return en()}}),N(()=>t&&f(ey,{label:`Mod version`,get value(){return`${t.version} (${t.kind})`}}))]}}),null),a})()}F([`click`]);var ny=P(`<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">`),ry=15e3;function iy(e){let t,r=()=>{t!==void 0&&(clearTimeout(t),t=void 0)},a=()=>{r(),t=setTimeout(()=>e.onClose(),ry)};return i(a),n(r),(()=>{var t=ny(),n=t.firstChild,i=n.nextSibling;return t.addEventListener(`mouseleave`,a),t.addEventListener(`mouseenter`,r),n.$$click=()=>e.onClose(),z(n,f($i,{size:16})),w(()=>i.innerHTML=e.text),t})()}F([`click`]);var ay=P(`<img width=20 height=20 style=display:block;border-radius:3px>`),oy=P(`<span>Settings`),sy=P(`<span>`),cy=P(`<span>Respawn`),ly=P(`<span>Logout`),uy=P(`<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">`),dy=P(`<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">`),fy=P(`<div style=font-size:12px;color:#f85149;margin-bottom:12px>`),py=P(`<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">`),my=P(`<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>`),hy=P(`<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">`),gy=P(`<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 _y(e){let[t,r]=a(!1),[i,o]=a(!1),[c,l]=a(!1),[u,d]=a(!1),[p,m]=a(``),[h,g]=a(``),[_,y]=a(``),[b,S]=a(!1),C=()=>Mn()===`password`||Mn()===`steam`,T=()=>U()?.password===!0,E=x(()=>T()&&p().length===0?`Enter your current password.`:h().length<8?`New password must be at least 8 characters.`:h()===_()?null:`Passwords don't match.`),D,O=x(()=>{let e=U()?.badge;return e?`data:image/svg+xml,${encodeURIComponent(Kt(e))}`:null});s(()=>{if(!t())return;let e=e=>{D&&!D.contains(e.target)&&r(!1)},i=e=>{e.key===`Escape`&&r(!1)};document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),n(()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)})});function ee(){let e=H();e&&(l(!0),e.http.user.respawn().then(()=>{B(`Respawn successful`,`success`),qn()}).catch(e=>B(`Respawn failed: ${e.message}`,`error`)).finally(()=>{l(!1),o(!1)}))}function k(){m(``),g(``),y(``),d(!0)}function A(){let e=H();if(!e||E())return;let t=!T();S(!0),e.http.user.password(h(),p()).then(()=>{B(t?`Password set`:`Password changed`,`success`),d(!1),t&&e.stores.user.refreshMe()}).catch(e=>B(`Password ${t?`setup`:`change`} failed: ${e.message}`,`error`)).finally(()=>S(!1))}return(()=>{var n=my(),a=n.firstChild,s=a.firstChild;return Oe(e=>D=e,n),a.$$click=()=>r(e=>!e),z(a,f(v,{get when(){return O()},get children(){var e=ay();return w(()=>I(e,`src`,O())),e}}),s),z(s,()=>U()?.username??`…`),z(a,f(Tr,{size:14}),null),z(n,f(v,{get when(){return t()},get children(){var t=uy();return z(t,f(yy,{onClick:()=>{r(!1),e.onOpenSettings()},get children(){return[f(Li,{size:15}),oy()]}}),null),z(t,f(v,{get when(){return C()},get children(){return f(yy,{onClick:()=>{r(!1),k()},get children(){return[f(ri,{size:15}),(()=>{var e=sy();return z(e,()=>T()?`Change password`:`Set password`),e})()]}})}}),null),z(t,f(yy,{onClick:()=>{r(!1),o(!0)},get children(){return[f(Fi,{size:15}),cy()]}}),null),z(t,f(yy,{onClick:()=>{r(!1),rr()},danger:!0,get children(){return[f(hi,{size:15}),ly()]}}),null),t}}),null),z(n,f(v,{get when(){return i()},get children(){var e=dy(),t=e.firstChild.firstChild.nextSibling.nextSibling;t.firstChild;var n=t.nextSibling.firstChild,r=n.nextSibling;return e.$$click=e=>{e.target===e.currentTarget&&!c()&&o(!1)},n.$$click=()=>o(!1),r.$$click=ee,z(r,()=>c()?`Respawning…`:`Respawn`),w(e=>{var t=c(),i=c()?`default`:`pointer`,a=c(),o=c()?`default`:`pointer`,s=c()?.6:1;return t!==e.e&&(n.disabled=e.e=t),i!==e.t&&R(n,`cursor`,e.t=i),a!==e.a&&(r.disabled=e.a=a),o!==e.o&&R(r,`cursor`,e.o=o),s!==e.i&&R(r,`opacity`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),z(n,f(v,{get when(){return u()},get children(){var e=py(),t=e.firstChild,n=t.firstChild,r=n.nextSibling,i=r.firstChild,a=i.nextSibling;return e.$$click=e=>{e.target===e.currentTarget&&!b()&&d(!1)},t.addEventListener(`submit`,e=>{e.preventDefault(),A()}),z(n,()=>T()?`Change password`:`Set password`),z(t,f(v,{get when(){return T()},get children(){return f(vy,{label:`Current password`,get value(){return p()},onInput:m,autofocus:!0})}}),r),z(t,f(vy,{label:`New password`,get value(){return h()},onInput:g,get autofocus(){return!T()}}),r),z(t,f(vy,{label:`Confirm new password`,get value(){return _()},onInput:y}),r),z(t,f(v,{get when(){return N(()=>!!E())()&&(h()||_())},get children(){var e=fy();return z(e,E),e}}),r),i.$$click=()=>d(!1),z(a,()=>b()?`Saving…`:`Save`),w(e=>{var t=b(),n=b()?`default`:`pointer`,r=b()||E()!=null,o=b()||E()!=null?`default`:`pointer`,s=b()||E()!=null?.6:1;return t!==e.e&&(i.disabled=e.e=t),n!==e.t&&R(i,`cursor`,e.t=n),r!==e.a&&(a.disabled=e.a=r),o!==e.o&&R(a,`cursor`,e.o=o),s!==e.i&&R(a,`opacity`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),w(e=>R(a,`background`,t()?`#21262d`:`#161b22`)),n})()}function vy(e){return(()=>{var t=hy(),n=t.firstChild,r=n.nextSibling;return z(n,()=>e.label),r.$$input=t=>e.onInput(t.currentTarget.value),w(()=>r.autofocus=e.autofocus),w(()=>r.value=e.value),t})()}function yy(e){let[t,n]=a(!1);return(()=>{var r=gy();return r.addEventListener(`mouseleave`,()=>n(!1)),r.addEventListener(`mouseenter`,()=>n(!0)),r.$$click=()=>e.onClick(),z(r,()=>e.children),w(n=>{var i=t()?`#21262d`:`transparent`,a=e.danger?`#f85149`:`#c9d1d9`;return i!==n.e&&R(r,`background`,n.e=i),a!==n.t&&R(r,`color`,n.t=a),n},{e:void 0,t:void 0}),r})()}F([`click`,`input`]);function by(){return`${nn()}/overview`}function xy(){return`${nn()}/profile/`}function Sy(){return`${nn()}/market`}function Cy(){return`${nn()}/market/`}function wy(){return`${nn()}/power`}function Ty(){return`${nn()}/power/`}function Ey(){return window.location.pathname+window.location.search+window.location.hash}function Dy(){let e=window.location.pathname;return e===by()?`overview`:e.startsWith(xy())?`profile`:e===Sy()||e.startsWith(Cy())?`market`:e===wy()||e.startsWith(Ty())?`power`:`game`}function Oy(){let e=window.location.pathname;return e.startsWith(xy())&&decodeURIComponent(e.slice(xy().length))||null}function ky(){let e=window.location.pathname;if(e===`${Sy()}/my`)return{view:`my-orders`,resourceType:null};if(e===`${Sy()}/history`)return{view:`history`,resourceType:null};let t=`${Cy()}resource/`;if(e.startsWith(t)){let n=decodeURIComponent(e.slice(t.length));if(n)return{view:`resource`,resourceType:n}}return{view:`all-orders`,resourceType:null}}function Ay(){return new URLSearchParams(window.location.search).get(`shard`)}function jy(){let e=window.location.pathname;if(e===`${wy()}/new`)return{view:`new`,id:null};if(e.startsWith(Ty())){let t=decodeURIComponent(e.slice(Ty().length));if(t)return{view:`detail`,id:t}}return{view:`list`,id:null}}var[My,Ny]=a(Dy()),[Py,Fy]=a(Oy()),[Iy,Ly]=a(ky().view),[Ry,zy]=a(ky().resourceType),[By,Vy]=a(Ay()),[Hy,Uy]=a(jy().view),[Wy,Gy]=a(jy().id),Ky=Dy()===`game`?Ey():`${nn()}/map`;function qy(){Dy()===`game`&&(Ky=Ey())}function Jy(){qy(),history.pushState(null,``,by()),Ny(`overview`)}function Yy(e){return e?`?shard=${encodeURIComponent(e)}`:``}function Xy(e){qy(),history.pushState(null,``,`${Sy()}${Yy(e??null)}`),zy(null),Vy(e??null),Ly(`all-orders`),Ny(`market`)}function Zy(e,t){qy(),history.pushState(null,``,`${Cy()}resource/${encodeURIComponent(e)}${Yy(t??null)}`),zy(e),Vy(t??null),Ly(`resource`),Ny(`market`)}function Qy(){qy(),history.pushState(null,``,`${Sy()}/my`),zy(null),Ly(`my-orders`),Ny(`market`)}function $y(){qy(),history.pushState(null,``,`${Sy()}/history`),zy(null),Ly(`history`),Ny(`market`)}function eb(){qy(),history.pushState(null,``,wy()),Gy(null),Uy(`list`),Ny(`power`)}function tb(){qy(),history.pushState(null,``,`${wy()}/new`),Gy(null),Uy(`new`),Ny(`power`)}function nb(e){qy(),history.pushState(null,``,`${Ty()}${encodeURIComponent(e)}`),Gy(e),Uy(`detail`),Ny(`power`)}function rb(){history.pushState(null,``,Ky),Ny(`game`)}function ib(e,t){let n=`${nn()}/room/${e}${t?`?shard=${encodeURIComponent(t)}`:``}`;Ky=n,history.pushState(null,``,n),Ny(`game`)}typeof window<`u`&&window.addEventListener(`popstate`,()=>{Ny(Dy()),Fy(Oy());let e=ky();Ly(e.view),zy(e.resourceType),Vy(Ay());let t=jy();Uy(t.view),Gy(t.id)});var ab=P(`<button style="padding:7px;border-radius:4px;cursor:pointer;margin:0 4px;display:flex;align-items:center">`),ob=P(`<button style="padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;margin:0 2px;display:flex;align-items:center">`),sb=P(`<div style=flex:1;position:relative;overflow:hidden>`),cb=P(`<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>`),lb=P(`<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>`),ub=P(`<div style=display:flex;flex:1;overflow:hidden><div style=display:flex;flex-direction:column;flex:1;overflow:hidden>`),db=P(`<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>`),fb=P(`<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">`),pb=P(`<div style=display:flex;flex-direction:column;flex:1;overflow:hidden><div style=display:flex;flex:1;overflow:hidden>`),mb=S(()=>D(()=>import(`./CodePanel-D5ETgtFO.js`).then(e=>({default:e.CodePanel})),__vite__mapDeps([2,3]))),hb=S(()=>D(()=>import(`./MapViewer-DFQ7jJZw.js`).then(e=>({default:e.MapViewer})),__vite__mapDeps([4,3])));function gb(){let e=nn(),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(!Nf(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 _b(e,t){return`${nn()}/room/${e}${t?`?shard=${encodeURIComponent(t)}`:``}`}function vb(e){return`${nn()}/map${e?`?shard=${encodeURIComponent(e)}`:``}`}function yb(){return window.location.pathname.startsWith(`${nn()}/map`)?{shard:new URLSearchParams(window.location.search).get(`shard`)}:null}function bb(e){return(()=>{var t=ab();return t.$$click=()=>e.onClick(),z(t,()=>e.children),w(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&&I(t,`title`,n.e=r),i!==n.t&&R(t,`border`,n.t=i),a!==n.a&&R(t,`background`,n.a=a),o!==n.o&&R(t,`color`,n.o=o),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t})()}function xb(e){return(()=>{var t=ob();return t.$$click=()=>e.onClick(),z(t,()=>e.children),w(n=>{var r=e.title,i=e.disabled,a=e.disabled?`#484f58`:`#c9d1d9`,o=e.disabled?`default`:`pointer`;return r!==n.e&&I(t,`title`,n.e=r),i!==n.t&&(t.disabled=n.t=i),a!==n.a&&R(t,`color`,n.a=a),o!==n.o&&R(t,`cursor`,n.o=o),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t})()}function Sb(){let e=gb(),[t,r]=a(e.room??on(V.room)??`W1N1`),[o,c]=a(e.shard??on(V.shard)),[l,u]=a(yb()!==null||!e.room),d=()=>wn()?.serverData?.welcomeText??null,[p,h]=a(!1),g=()=>An()&&l()&&!p()&&d()!==null,[_,y]=a(!An()&&!U()?.badge),[b,x]=a(!1),[S,C]=a(!1);s(()=>{b(),C(!0),Promise.resolve().then(()=>C(!1))}),s(()=>{An()&&xp(`view`)}),s(()=>{if(o()!==null||er()!==!1)return;let e=wn()?.serverData?.shards?.[0];e&&c(e)});let[T,E]=a(void 0),[D,O]=a(null),[ee,k]=a(null),A=on(V.mapZoom),[te,ne]=a(e.room&&A?Number(A):null),[re,ie]=a(null),[j,ae]=a(!1),[oe,M]=a(!1),se=e.tick;s(()=>{let e=En();if(e===null||se===null)return;let t=se;se=null,np(e),ip(t)}),s(()=>{if(m(l))return;let e=_b(t(),o());K()?history.replaceState(null,``,`${e}#tick=${Vf()}`):history.replaceState(null,``,e)});let[ce,le]=a(ln(V.sidebarWidth,300)),[ue,de]=a(ln(V.sidebarWidth,300)),[fe,pe]=a(ln(V.consoleHeight,220)),[me,he]=a(ln(V.consoleHeight,220)),[ge,_e]=a(!1),[ve,ye]=a(!1),be=()=>ce()<=32,xe=()=>fe()<=32,P=()=>{ce()>32?(de(ce()),le(32)):le(ue())},F=()=>{fe()>32?(he(fe()),pe(32)):pe(me())},I=e=>{e.preventDefault(),_e(!0);let t=e.clientX,n=ce(),r=e=>{let r=e.clientX-t;le(Math.max(32,Math.min(500,n-r)))},i=()=>{_e(!1),un(V.sidebarWidth,ce()),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},Se=e=>{e.preventDefault(),ye(!0);let t=e.clientY,n=fe(),r=e=>{let r=e.clientY-t;pe(Math.max(32,Math.min(500,n-r)))},i=()=>{ye(!1),un(V.consoleHeight,fe()),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},Ce=(e,t)=>{H()?.stores.navigation.navigateTo(e,t)},we=e=>{E(e),u(!0),history.pushState(null,``,vb(o()))},Ee=()=>{l()?(u(!1),O(null),k(null),history.pushState(null,``,_b(t(),o()))):we(t())};i(()=>{!gb().room&&!yb()&&history.replaceState(null,``,vb(o()));let e=()=>{let e=yb();if(e){u(!0),e.shard!==null&&c(e.shard),m(K)&&rp();return}let{room:t,shard:n,tick:i}=gb();t&&(r(t),c(n),u(!1),i===null?m(K)&&rp():se=i)};window.addEventListener(`popstate`,e),n(()=>window.removeEventListener(`popstate`,e));let i=H()?.stores.navigation;if(i){let e=i.on(`navigation:change`,e=>{e.room!==null&&(r(e.room),c(e.shard),u(!1),O(null),k(null),ae(i.canBack()),M(i.canForward()),sn(V.room,e.room),e.shard?sn(V.shard,e.shard):cn(V.shard),history.pushState(null,``,_b(e.room,e.shard)))});n(()=>e.dispose())}let a=e=>{if(!Rf(e.target)){if(e.key===`o`||e.key===`O`){x(e=>!e),y(!1);return}(e.key===`l`||e.key===`L`)&&am(),(e.key===`c`||e.key===`C`)&&om(),(e.key===`y`||e.key===`Y`)&&sm(),l()||(e.key===`1`&&xp(`view`),An()||(e.key===`2`&&xp(`flag`),e.key===`3`&&xp(`build`)),e.key===`m`&&we(t()))}};window.addEventListener(`keydown`,a),n(()=>window.removeEventListener(`keydown`,a))});let L=()=>(()=>{var e=sb();return z(e,f(v,{get when(){return _()},get children(){return f(ty,{onClose:()=>y(!1)})}}),null),z(e,f(v,{get when(){return b()},get children(){return f(mb,{onClose:()=>x(!1)})}}),null),z(e,f(v,{get when(){return!l()},get fallback(){return f(hb,{get shard(){return o()},get originRoom(){return T()},get initialZoom(){return te()??void 0},onNavigateToRoom:e=>Ce(e,o()),onHoveredRoomChanged:O,onSelectedRoomChanged:k,onZoomChanged:e=>{ne(e),un(V.mapZoom,e)},onSubscriptionStateChanged:ie})},get children(){return f(Wp,{get room(){return t()},get shard(){return o()},onNavigate:Ce})}}),null),z(e,f(v,{get when(){return g()},get children(){return f(iy,{get text(){return d()},onClose:()=>h(!0)})}}),null),e})(),De=()=>f(v,{get when(){return!An()},get children(){var e=cb(),t=e.firstChild;return t.$$pointerdown=Se,z(e,f($m,{get shard(){return o()},get isCollapsed(){return xe()},onToggle:F}),null),w(t=>{var n=`${fe()}px`,r=ve()?`none`:`height 0.15s ease`;return n!==t.e&&R(e,`height`,t.e=n),r!==t.t&&R(e,`transition`,t.t=r),t},{e:void 0,t:void 0}),e}}),Oe=e=>(()=>{var n=lb(),r=n.firstChild;return r.$$pointerdown=I,z(n,f(wv,{get isCollapsed(){return be()},onToggle:P,get mapMode(){return l()},get hoveredRoomInfo(){return D()},get selectedRoomInfo(){return ee()},get room(){return t()},get shard(){return o()},get mapZoom(){return te()},get mapSubsActive(){return re()}}),null),w(t=>{var r=b()?`0`:`${ce()}px`,i=e&&!(S()||ge())?`width 0.15s ease`:`none`;return r!==t.e&&R(n,`width`,t.e=r),i!==t.t&&R(n,`transition`,t.t=i),t},{e:void 0,t:void 0}),n})();return(()=>{var e=db(),t=e.firstChild,n=t.firstChild;return z(t,f(Ba,{}),n),z(t,f(v,{get when(){return!An()||l()},get children(){return f(Av,{get mapZoom(){return N(()=>!!l())()?te():null},get mapSubsActive(){return N(()=>!!l())()?re():null}})}}),n),z(t,f(xb,{title:`Back`,get disabled(){return!j()},onClick:()=>H()?.stores.navigation.back(),get children(){return f(kr,{size:16})}}),null),z(t,f(xb,{title:`Forward`,get disabled(){return!oe()},onClick:()=>H()?.stores.navigation.forward(),get children(){return f(Dr,{size:16})}}),null),z(t,f(bb,{get title(){return l()?`Room View`:`Map`},get active(){return l()},onClick:Ee,get children(){return N(()=>!!l())()?f(si,{size:16}):f(_i,{size:16})}}),null),z(t,f(v,{get when(){return!An()},get children(){return f(bb,{title:`Overview`,onClick:Jy,get children(){return f(ai,{size:16})}})}}),null),z(t,f(v,{get when(){return!An()},get children(){return f(bb,{title:`Market`,onClick:()=>Xy(o()),get children(){return f(Ui,{size:16})}})}}),null),z(t,f(v,{get when(){return!An()},get children(){return f(bb,{title:`Code Editor`,get active(){return b()},onClick:()=>{x(e=>!e),y(!1)},get children(){return f(zr,{size:16})}})}}),null),z(t,f(v,{get when(){return!An()},get fallback(){return[f(bb,{title:`Settings`,get active(){return _()},onClick:()=>{y(e=>!e),x(!1)},get children(){return f(Li,{size:16})}}),(()=>{var e=fb();return Te(e,`click`,rr,!0),z(e,f(pi,{size:16})),e})()]},get children(){return f(_y,{onOpenSettings:()=>{y(!0),x(!1)}})}}),null),z(e,f(v,{get when(){return ld()},get fallback(){return(()=>{var e=pb(),t=e.firstChild;return z(t,L,null),z(t,()=>Oe(!0),null),z(e,De,null),e})()},get children(){var e=ub(),t=e.firstChild;return z(t,L,null),z(t,De,null),z(e,()=>Oe(!1),null),e}}),null),z(e,f(qp,{}),null),e})()}F([`click`,`pointerdown`]);var Cb=P(`<div style=position:relative;width:84px;height:84px;flex-shrink:0><svg width=84 height=84 style=transform:rotate(-90deg)><circle cx=42 cy=42 r=38 fill=none stroke-width=8 opacity=0.2></circle><circle cx=42 cy=42 r=38 fill=none stroke-width=8 stroke-linecap=round></circle></svg><div style=position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center><div style=font-size:26px;font-weight:700;line-height:1></div><div style=font-size:10px;font-weight:300;letter-spacing:0.5px>`),wb=`#4DB6AC`,Tb=`#A7FFEB`,Eb=`#C54444`,Db=`#FF9A9A`;function Ob(e){let t=2*Math.PI*(76/2),n=()=>`${Math.max(0,Math.min(1,e.fraction))*t} ${t}`;return(()=>{var t=Cb(),r=t.firstChild,i=r.firstChild,a=i.nextSibling,o=r.nextSibling,s=o.firstChild,c=s.nextSibling;return z(s,()=>e.value),z(c,()=>e.label),w(r=>{var s=e.tooltip,c=e.ring,l=e.ring,u=n(),d=e.text;return s!==r.e&&I(t,`title`,r.e=s),c!==r.t&&I(i,`stroke`,r.t=c),l!==r.a&&I(a,`stroke`,r.a=l),u!==r.o&&I(a,`stroke-dasharray`,r.o=u),d!==r.i&&R(o,`color`,r.i=d),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),t})()}var kb=P(`<img alt style=display:block;border-radius:3px;flex-shrink:0>`);function Ab(e){let t=()=>e.badge?`data:image/svg+xml,${encodeURIComponent(Kt(e.badge))}`:null;return f(v,{get when(){return t()},get children(){var n=kb();return w(r=>{var i=t(),a=e.size??24,o=e.size??24;return i!==r.e&&I(n,`src`,r.e=i),a!==r.t&&I(n,`width`,r.t=a),o!==r.a&&I(n,`height`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n}})}var jb=P(`<button style="padding:0;border:1px solid #30363d;border-radius:6px;overflow:hidden;background:#161b22;cursor:pointer;line-height:0"><canvas style=display:block></canvas><div style="padding:4px 0;text-align:center;font-size:12px;font-family:monospace;color:#c9d1d9;line-height:1.2;border-top:1px solid #30363d">`),Mb=3;function Nb(e,t,n,r){if(!t.length)return;e.fillStyle=u_(n);let i=Mb-r*2;for(let[n,a]of t)e.fillRect(n*Mb+r,a*Mb+r,i,i)}function Pb(e,t,n,r){if(t.length){e.fillStyle=u_(n),e.beginPath();for(let[n,i]of t){let t=(n+.5)*Mb,a=(i+.5)*Mb;e.moveTo(t+r,a),e.arc(t,a,r,0,Math.PI*2)}e.fill()}}function Fb(e){let t,r=null,a=null,o=()=>{let e=t?.getContext(`2d`);if(!e)return;if(e.setTransform(2,0,0,2,0,0),e.fillStyle=u_(e_),e.fillRect(0,0,150,150),r){let t=r.raw;e.fillStyle=u_(t_);for(let n=0;n<2500;n++)t[n]===st.Wall&&e.fillRect(n%50*Mb,Math.floor(n/50)*Mb,Mb,Mb);e.fillStyle=u_(n_);for(let n=0;n<2500;n++)t[n]===st.Swamp&&e.fillRect(n%50*Mb,Math.floor(n/50)*Mb,Mb,Mb)}let n=a;if(n){Nb(e,n.r??[],r_,0),Nb(e,n.w??[],i_,.5);for(let t of c_)Pb(e,n[t.key]??[],t.color,t.radius);let t=n,r=U()?._id;for(let n in t){if(l_.has(n))continue;let i=t[n];!Array.isArray(i)||i.length===0||Pb(e,i,n===r?o_:s_,1.2)}}};return i(()=>{let t=H();if(!t)return;t.stores.room.terrain(e.room,e.shard).then(e=>{r=e,o()}).catch(()=>{});let i=t.stores.map.subscribeMap2(e.room,e.shard),s=t.stores.map.map2data(e.room,e.shard);s&&(a=s,o());let c=t.stores.map.on(`room:map2update`,({room:t,shard:n,data:r})=>{t!==e.room||(n??null)!==(e.shard??null)||(a=r,o())});n(()=>{i.dispose(),c.dispose()})}),(()=>{var n=jb(),r=n.firstChild,i=r.nextSibling;return n.$$click=()=>e.onClick?.(),Oe(e=>t=e,r),I(r,`width`,300),I(r,`height`,300),R(r,`width`,`150px`),R(r,`height`,`150px`),z(i,()=>e.room),w(()=>I(n,`title`,e.room+(e.shard?` · ${e.shard}`:``))),n})()}F([`click`]);var Ib=2.4,Lb=1e6,Rb=1e3;function zb(e){return Math.floor((e/Lb)**(1/Ib))+1}function Bb(e){let t=zb(e),n=(t-1)**Ib*Lb,r=t**Ib*Lb;return{level:t,current:e-n,total:r-n}}function Vb(e){return Math.floor((e/Rb)**(1/2))}function Hb(e){let t=Vb(e),n=t**2*Rb,r=(t+1)**2*Rb;return{level:t,current:e-n,total:r-n}}function Ub(e){if(e==null||!Number.isFinite(e))return`0`;let t=Math.round(e),n=Math.abs(t);return n<1e4?String(t):n<1e6?`${(t/1e3).toPrecision(3)}K`:n<1e9?`${(t/1e6).toPrecision(3)}M`:`${(t/1e9).toPrecision(3)}B`}var Wb=P(`<div style="flex:1;min-width:0;background:#161b22;border:1px solid #30363d;border-radius:6px;padding:14px 8px 12px;text-align:center"><div style=color:#8b949e;font-size:11px;text-transform:uppercase;line-height:1.3><br></div><div style=font-size:28px;font-weight:300;margin-top:8px>`),Gb=P(`<div style=margin-top:24px><div style=color:#8b949e;font-size:11px;text-transform:uppercase;margin-bottom:12px>Rooms</div><div style=display:flex;flex-wrap:wrap;gap:16px>`),Kb=P(`<div style=width:100%;height:100%;overflow:auto;background:#0d1117;color:#c9d1d9><div style="max-width:900px;margin:0 auto;padding:24px 16px 40px"><div style="display:flex;align-items:center;gap:10px;padding:0 0 14px;border-bottom:1px solid #30363d;margin-bottom:24px"><h1 style=margin:0;font-size:22px;font-weight:600;color:#c9d1d9>Overview</h1><span style=color:#8b949e;font-size:14px></span><div style=flex:1></div><button title="Back to the world"style="display:flex;align-items:center;gap:4px;padding:7px 12px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer"> World</button></div><div style=display:flex;gap:16px;margin-bottom:16px><div><div><div style=font-size:16px;font-weight:600;color:#c9d1d9;margin-bottom:6px>Global Control Level</div><div style=color:#8b949e;font-size:13px><span>Rooms: <strong style=color:#c9d1d9></strong></span><span style=margin-left:14px>CPU: <strong style=color:#c9d1d9></strong></span></div></div></div><div><div><div style=font-size:16px;font-weight:600;color:#c9d1d9;margin-bottom:8px>Global Power Level</div><button title="Manage your power creeps"style="padding:5px 10px;border-radius:4px;border:1px solid #C54444;background:#21262d;color:#ffb7ba;font-size:12px;cursor:pointer">Manage Power Creeps</button></div></div></div><div style=display:flex;gap:10px>`),qb=6e4,Jb=8,Yb=`#161b22`,Xb=`#30363d`,Zb=[{key:`energyControl`,l1:`Control`,l2:`points`,color:`#A7FFEB`},{key:`energyHarvested`,l1:`Energy`,l2:`harvested`,color:`#ffe56d`},{key:`energyConstruction`,l1:`Energy`,l2:`on construct`,color:`#eeeeee`},{key:`energyCreeps`,l1:`Energy`,l2:`on creeps`,color:`#eeeeee`},{key:`creepsProduced`,l1:`Creeps`,l2:`produced`,color:`#65fd62`},{key:`creepsLost`,l1:`Creeps`,l2:`lost`,color:`#f96e76`},{key:`powerProcessed`,l1:`Power`,l2:`processed`,color:`#E04040`}];function Qb(e){return(()=>{var t=Wb(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return z(n,()=>e.l1,r),z(n,()=>e.l2,null),z(i,()=>Ub(e.value)),w(t=>R(i,`color`,e.color)),t})()}function $b(e){return e.shards?Object.entries(e.shards).flatMap(([e,t])=>(t??[]).map(t=>({room:t,shard:e}))):(e.rooms??[]).map(e=>({room:e,shard:null}))}function ex(){let[e,t]=a(null),[r,o]=a([]),c=!1;s(()=>{let e=H(),t=U()?._id;!e||!t||c||(c=!0,e.http.user.rooms(t).then(e=>o($b(e))).catch(()=>{c=!1}))}),i(()=>{let e=H();if(!e)return;let r=null,i=()=>e.http.user.overview(Jb,`energyHarvested`).then(e=>t(e.totals??null));i().then(()=>{r=setInterval(()=>{e.stores.user.refreshMe().catch(()=>{}),i().catch(()=>{})},qb)}).catch(()=>{}),n(()=>{r&&clearInterval(r)})});let l=()=>Bb(U()?.gcl??0),d=()=>Hb(U()?.power??0),p=e=>e.total>0?e.current/e.total:0,m=e=>`Next level: ${Math.floor(e.current).toLocaleString()} / ${Math.floor(e.total).toLocaleString()}`,h={flex:1,display:`flex`,"align-items":`center`,gap:`16px`,background:Yb,border:`1px solid ${Xb}`,"border-radius":`6px`,padding:`16px`};return(()=>{var t=Kb(),n=t.firstChild,i=n.firstChild,a=i.firstChild,o=a.nextSibling,s=o.nextSibling.nextSibling,c=s.firstChild,g=i.nextSibling,_=g.firstChild,y=_.firstChild,b=y.firstChild.nextSibling.firstChild,x=b.firstChild.nextSibling,S=b.nextSibling.firstChild.nextSibling,C=_.nextSibling,T=C.firstChild,E=T.firstChild.nextSibling,D=g.nextSibling;return z(i,f(Ab,{get badge(){return U()?.badge},size:28}),a),z(o,()=>U()?.username),Te(s,`click`,rb,!0),z(s,f(kr,{size:16}),c),z(_,f(Ob,{get value(){return l().level},label:`GCL`,ring:wb,text:Tb,get fraction(){return p(l())},get tooltip(){return m(l())}}),y),z(x,()=>l().level),z(S,()=>U()?.cpu??`—`),z(C,f(Ob,{get value(){return d().level},label:`GPL`,ring:Eb,text:Db,get fraction(){return p(d())},get tooltip(){return m(d())}}),T),Te(E,`click`,eb,!0),z(D,f(u,{each:Zb,children:t=>f(Qb,{get l1(){return t.l1},get l2(){return t.l2},get color(){return t.color},get value(){return e()?.[t.key]}})})),z(n,f(v,{get when(){return r().length},get children(){var e=Gb(),t=e.firstChild.nextSibling;return z(t,f(u,{get each(){return r()},children:e=>f(Fb,{get room(){return e.room},get shard(){return e.shard},onClick:()=>ib(e.room,e.shard)})})),e}}),null),w(e=>{var t=h,n=h;return e.e=L(_,t,e.e),e.t=L(C,n,e.t),e},{e:void 0,t:void 0}),t})()}F([`click`]);var tx=P(`<div style=width:100%;height:100%;overflow:auto;background:#0d1117;color:#c9d1d9><div style="max-width:900px;margin:0 auto;padding:24px 16px 40px"><div style="display:flex;align-items:center;padding:0 0 14px;border-bottom:1px solid #30363d;margin-bottom:24px"><h1 style=margin:0;flex:1;font-size:22px;font-weight:600;color:#c9d1d9>Profile</h1><button title="Back to the world"style="display:flex;align-items:center;gap:4px;padding:7px 12px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer"> World`),nx=P(`<div style=color:#8b949e;text-align:center;padding:40px>Loading…`),rx=P(`<div style=color:#8b949e;text-align:center;font-size:18px;padding:40px>User not found`),ix=P(`<div style="display:flex;align-items:center;gap:20px;background:#161b22;border:1px solid #30363d;border-radius:6px;padding:20px"><div style=flex:1><div style=font-size:22px;font-weight:600;margin-bottom:4px></div><div style=color:#8b949e;font-size:13px>Global Control Level `);function ax(){let[e]=c(()=>Py(),async e=>{let t=H();if(!t)return null;try{return(await t.http.user.find({username:e})).user??null}catch{return null}}),t=()=>Bb(e()?.gcl??0),n=e=>e.total>0?e.current/e.total:0,r=e=>`Next level: ${Math.floor(e.current).toLocaleString()} / ${Math.floor(e.total).toLocaleString()}`;return(()=>{var i=tx(),a=i.firstChild,o=a.firstChild.firstChild.nextSibling,s=o.firstChild;return Te(o,`click`,rb,!0),z(o,f(kr,{size:16}),s),z(a,f(v,{get when(){return!e.loading},get fallback(){return nx()},get children(){return f(v,{get when(){return e()},get fallback(){return rx()},children:e=>(()=>{var i=ix(),a=i.firstChild,o=a.firstChild,s=o.nextSibling;return s.firstChild,z(i,f(Ab,{get badge(){return e().badge},size:64}),a),z(o,()=>e().username),z(s,()=>t().level,null),z(i,f(Ob,{get value(){return t().level},label:`GCL`,ring:wb,text:Tb,get fraction(){return n(t())},get tooltip(){return r(t())}}),null),i})()})}}),null),i})()}F([`click`]);var ox=`#0d1117`,sx=`#161b22`,cx=`#1c2129`,Y=`#30363d`,X=`#c9d1d9`,Z=`#8b949e`,lx=`#58a6ff`,ux=`#3fb950`,dx=`#f85149`;function fx(e){return e==null?`—`:Math.round(e).toLocaleString(`en-US`)}function px(e){return e==null?`—`:e.toLocaleString(`en-US`,{minimumFractionDigits:3,maximumFractionDigits:3})}function mx(){return(wn()?.serverData?.shards??[]).filter(e=>e!=null)}function hx(){return By()??mx()[0]??null}function gx(){return mx().length>1}var _x={token:`subscription token`,energy:`energy`,power:`power`,H:`hydrogen`,O:`oxygen`,U:`utrium`,L:`lemergium`,K:`keanium`,Z:`zynthium`,X:`catalyst`,OH:`hydroxide`,ZK:`zynthium keanite`,UL:`utrium lemergite`,G:`ghodium`,UH:`utrium hydride`,UO:`utrium oxide`,KH:`keanium hydride`,KO:`keanium oxide`,LH:`lemergium hydride`,LO:`lemergium oxide`,ZH:`zynthium hydride`,ZO:`zynthium oxide`,GH:`ghodium hydride`,GO:`ghodium oxide`,UH2O:`utrium acid`,UHO2:`utrium alkalide`,KH2O:`keanium acid`,KHO2:`keanium alkalide`,LH2O:`lemergium acid`,LHO2:`lemergium alkalide`,ZH2O:`zynthium acid`,ZHO2:`zynthium alkalide`,GH2O:`ghodium acid`,GHO2:`ghodium alkalide`,XUH2O:`catalyzed utrium acid`,XUHO2:`catalyzed utrium alkalide`,XKH2O:`catalyzed keanium acid`,XKHO2:`catalyzed keanium alkalide`,XLH2O:`catalyzed lemergium acid`,XLHO2:`catalyzed lemergium alkalide`,XZH2O:`catalyzed zynthium acid`,XZHO2:`catalyzed zynthium alkalide`,XGH2O:`catalyzed ghodium acid`,XGHO2:`catalyzed ghodium alkalide`,ops:`ops`,silicon:`silicon`,metal:`metal`,biomass:`biomass`,mist:`mist`,utrium_bar:`utrium bar`,lemergium_bar:`lemergium bar`,zynthium_bar:`zynthium bar`,keanium_bar:`keanium bar`,ghodium_melt:`ghodium melt`,oxidant:`oxidant`,reductant:`reductant`,purifier:`purifier`,battery:`battery`,composite:`composite`,crystal:`crystal`,liquid:`liquid`,wire:`wire`,switch:`switch`,transistor:`transistor`,microchip:`microchip`,circuit:`circuit`,device:`device`,cell:`cell`,phlegm:`phlegm`,tissue:`tissue`,muscle:`muscle`,organoid:`organoid`,organism:`organism`,alloy:`alloy`,tube:`tube`,fixtures:`fixtures`,frame:`frame`,hydraulics:`hydraulics`,machine:`machine`,condensate:`condensate`,concentrate:`concentrate`,extract:`extract`,spirit:`spirit`,emanation:`emanation`,essence:`essence`},vx=Object.keys(_x);function yx(e){return _x[e]??e}var bx={metal:[`wire`,`switch`,`transistor`,`microchip`,`circuit`,`device`],biomass:[`cell`,`phlegm`,`tissue`,`muscle`,`organoid`,`organism`],silicon:[`alloy`,`tube`,`fixtures`,`frame`,`hydraulics`,`machine`],mist:[`condensate`,`concentrate`,`extract`,`spirit`,`emanation`,`essence`]},xx={utrium_bar:`U`,lemergium_bar:`L`,zynthium_bar:`Z`,keanium_bar:`K`,ghodium_melt:`G`,oxidant:`O`,reductant:`H`,purifier:`X`,battery:`energy`},Sx={ops:14255163,token:15911244},Cx=(()=>{let e={};for(let t in bx)for(let n of bx[t])e[n]=Jo[t];for(let t in xx){let n=xx[t];e[t]=n===`energy`?Wo:qo[n]}return{...e,...Sx}})();function wx(e){if(qo[e]!=null)return qo[e];if(Jo[e]!=null)return Jo[e];if(Cx[e]!=null)return Cx[e];let t=(e.startsWith(`X`)?e.slice(1):e)[0];return qo[t]==null?Ko:qo[t]}var Tx=P(`<span style="display:inline-block;border-radius:50%;border:1px solid rgba(255, 255, 255, 0.25);vertical-align:middle;flex:none">`);function Ex(e){let t=()=>e.size??18,n=()=>`#${wx(e.resourceType).toString(16).padStart(6,`0`)}`;return(()=>{var r=Tx();return w(i=>{var a=yx(e.resourceType),o=`${t()}px`,s=`${t()}px`,c=n();return a!==i.e&&I(r,`title`,i.e=a),o!==i.t&&R(r,`width`,i.t=o),s!==i.a&&R(r,`height`,i.a=s),c!==i.o&&R(r,`background`,i.o=c),i},{e:void 0,t:void 0,a:void 0,o:void 0}),r})()}var Dx=P(`<div style="display:grid;grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));gap:8px">`),Ox=P(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load the market — this server may not support it.`),kx=P(`<button style="display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:6px;cursor:pointer;text-align:left"><span style=flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap></span><span style=font-size:13px> `);function Ax(e){let[t,n]=a({}),[r,i]=a(!0),[o,c]=a(null),l=0;return s(()=>{let t=e.shard,r=H();if(!r)return;let a=++l;i(!0),r.http.game.market.ordersIndex(t).then(e=>{if(a!==l)return;let t={};for(let n of e.list??[])t[n._id]=n.count;n(t),c(null)}).catch(e=>{a===l&&c(e instanceof Error?e.message:String(e))}).finally(()=>{a===l&&i(!1)})}),f(v,{get when(){return!o()},get fallback(){return(()=>{var e=Ox();return R(e,`background`,sx),R(e,`border`,`1px solid ${Y}`),R(e,`color`,Z),e})()},get children(){var n=Dx();return z(n,f(u,{each:vx,children:n=>{let r=()=>t()[n]??0;return(()=>{var t=kx(),i=t.firstChild,a=i.nextSibling,o=a.firstChild;return t.addEventListener(`mouseleave`,e=>e.currentTarget.style.background=sx),t.addEventListener(`mouseenter`,e=>e.currentTarget.style.background=cx),t.$$click=()=>Zy(n,e.shard),R(t,`border`,`1px solid ${Y}`),R(t,`background`,sx),R(t,`color`,X),z(t,f(Ex,{resourceType:n,size:20}),i),z(i,()=>yx(n)),z(a,r,o),z(a,()=>r()===1?`order`:`orders`,null),w(e=>R(a,`color`,r()>0?X:Z)),t})()}})),w(e=>R(n,`opacity`,r()?.6:1)),n}})}F([`click`]);var jx=P(`<div style=border-radius:8px;margin-bottom:16px;overflow:hidden><div style="display:flex;align-items:center;padding:11px 16px"><span style=font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:0.05em></span><div style=flex:1></div></div><div style="padding:4px 16px 12px">`);function Mx(e){return(()=>{var t=jx(),n=t.firstChild,r=n.firstChild;r.nextSibling;var i=n.nextSibling;return R(t,`background`,sx),R(t,`border`,`1px solid ${Y}`),R(n,`border-bottom`,`1px solid ${Y}`),R(n,`background`,cx),z(r,()=>e.title),z(n,()=>e.right,null),z(i,()=>e.children),w(n=>{var i=e.accent?`3px solid ${e.accent}`:`1px solid ${Y}`,a=e.accent??`#c9d1d9`;return i!==n.e&&R(t,`border-left`,n.e=i),a!==n.t&&R(r,`color`,n.t=a),n},{e:void 0,t:void 0}),t})()}function Nx(e){return e%2==1?`rgba(255, 255, 255, 0.022)`:`transparent`}var Px=P(`<div style="border-radius:6px;padding:10px 14px;margin-bottom:16px;font-size:13px">A special item that activates 60 days of CPU subscription for its owner.`),Fx=P(`<div style=display:flex;align-items:center;gap:10px;margin-bottom:16px><label style=font-size:13px>Target room</label><input placeholder="e.g. W1N1"style="padding:6px 8px;border-radius:4px;width:120px"><span style=font-size:12px>shows shipping range to each order's room`),Ix=P(`<div>`),Lx=P(`<div><div style=display:flex;align-items:center;gap:12px;margin-bottom:16px><button style="display:flex;align-items:center;gap:4px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Resources</button><div style=flex:1></div><button title=Refresh style="display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Refresh</button></div><div style=display:flex;align-items:center;gap:10px;margin-bottom:16px><h2 style=margin:0;font-size:20px;font-weight:600>`),Rx=P(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load orders for this resource.`),zx=P(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right></tr></thead><tbody>`),Bx=P(`<span style=font-size:12px> `),Vx=P(`<div style="font-size:13px;padding:10px 0">No orders`),Hx=P(`<a href=# style=text-decoration:none>`),Ux=P(`<td style="padding:7px 0">`),Wx=P(`<td style=padding-right:6px>`),Gx=P(`<tr style=text-align:right><td style="text-align:left;font-family:monospace;padding:7px 8px 7px 6px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0">`),Kx=P(`<span>—`),qx=P(`<th style=font-weight:400;cursor:pointer;user-select:none;white-space:nowrap>`),Jx=P(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right><th style="text-align:left;font-weight:400;padding:0 0 7px 6px">Date</th><th style="font-weight:400;padding:0 0 7px">Transactions</th><th style="font-weight:400;padding:0 0 7px">Total volume</th><th style="font-weight:400;padding:0 6px 7px 0">Price (avg ± stddev)</th></tr></thead><tbody>`),Yx=P(`<div style="font-size:13px;padding:10px 0">No history`),Xx=P(`<tr style=text-align:right><td style="text-align:left;padding:7px 0 7px 6px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 6px 7px 0"> <span>± `);function Zx(e,t){if(!e)return;let n=Nf(e),r=Nf(t);if(!(!n||!r))return Math.max(Math.abs(n.x-r.x),Math.abs(n.y-r.y))}function Qx(e,t){let n=t[0]===`-`,r=t.slice(1);return[...e].sort((e,t)=>{let i=e[r],a=t[r],o;return o=typeof i==`number`||typeof a==`number`?(Number(i)||0)-(Number(a)||0):String(i??``).localeCompare(String(a??``)),n?-o:o})}function $x(e){let[t,n]=a([]),[r,i]=a([]),[o,c]=a([]),[l,u]=a(``),[d,p]=a(!0),[m,h]=a(null),g=()=>e.resourceType===`token`,_=0,y=()=>{let t=H(),r=e.resourceType;if(!t||!r)return;let a=++_;p(!0),t.http.game.market.orders(r,e.shard).then(e=>{if(a!==_)return;let t=e.list??[];n(t.filter(e=>e.type===`sell`)),i(t.filter(e=>e.type===`buy`)),h(null)}).catch(e=>{a===_&&h(e instanceof Error?e.message:String(e))}).finally(()=>{a===_&&p(!1)}),t.http.game.market.stats(r,e.shard).then(e=>{a===_&&c(e.stats??[])}).catch(()=>{a===_&&c([])})};s(()=>{e.resourceType,e.shard,y()});let b=e=>{let t=l().trim().toUpperCase(),n=/^[WE]\d+[NS]\d+$/.test(t);return e.map(e=>({...e,range:n?Zx(e.roomName,t):void 0}))},S=x(()=>b(t())),C=x(()=>b(r()));return(()=>{var t=Lx(),n=t.firstChild,r=n.firstChild,i=r.firstChild,a=r.nextSibling.nextSibling,s=a.firstChild,c=n.nextSibling,p=c.firstChild;return r.$$click=()=>Xy(e.shard),R(r,`border`,`1px solid ${Y}`),R(r,`color`,X),z(r,f(kr,{size:14}),i),a.$$click=y,R(a,`border`,`1px solid ${Y}`),R(a,`color`,X),z(a,f(ji,{size:14}),s),z(c,f(Ex,{get resourceType(){return e.resourceType??``},size:26}),p),R(p,`color`,X),z(p,()=>yx(e.resourceType??``)),z(t,f(v,{get when(){return g()},get children(){var e=Px();return R(e,`background`,sx),R(e,`border`,`1px solid ${Y}`),R(e,`color`,Z),e}}),null),z(t,f(v,{get when(){return!m()},get fallback(){return(()=>{var e=Rx();return R(e,`background`,sx),R(e,`border`,`1px solid ${Y}`),R(e,`color`,Z),e})()},get children(){return[f(v,{get when(){return!g()},get children(){var e=Fx(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling;return R(t,`color`,Z),n.$$input=e=>u(e.currentTarget.value),R(n,`border`,`1px solid ${Y}`),R(n,`background`,sx),R(n,`color`,X),R(r,`color`,Z),w(()=>n.value=l()),e}}),(()=>{var t=Ix();return z(t,f(eS,{title:`Selling`,accent:ux,get rows(){return S()},defaultSort:`+price`,get showRoom(){return!g()},get shard(){return e.shard}}),null),z(t,f(eS,{title:`Buying`,accent:dx,get rows(){return C()},defaultSort:`-price`,get showRoom(){return!g()},get shard(){return e.shard}}),null),z(t,f(nS,{get stats(){return o()}}),null),w(e=>R(t,`opacity`,d()?.6:1)),t})()]}}),null),t})()}function eS(e){let[t,n]=a(e.defaultSort),r=x(()=>Qx(e.rows,t())),i=e=>{n(t=>t===`+${e}`?`-${e}`:`+${e}`)};return f(Mx,{get title(){return e.title},get accent(){return e.accent},get right(){return(()=>{var t=Bx(),n=t.firstChild;return R(t,`color`,Z),z(t,()=>e.rows.length,n),z(t,()=>e.rows.length===1?`order`:`orders`,null),t})()},get children(){return f(v,{get when(){return e.rows.length},get fallback(){return(()=>{var e=Vx();return R(e,`color`,Z),e})()},get children(){var n=zx(),a=n.firstChild,o=a.firstChild,s=a.nextSibling;return R(o,`color`,Z),z(o,f(tS,{label:`Order ID`,col:`_id`,get sort(){return t()},onClick:i,align:`left`}),null),z(o,f(tS,{label:`Price`,col:`price`,get sort(){return t()},onClick:i}),null),z(o,f(tS,{label:`Available`,col:`amount`,get sort(){return t()},onClick:i}),null),z(o,f(tS,{label:`Remaining`,col:`remainingAmount`,get sort(){return t()},onClick:i}),null),z(o,f(v,{get when(){return e.showRoom},get children(){return[f(tS,{label:`Room`,col:`roomName`,get sort(){return t()},onClick:i}),f(tS,{label:`Range`,col:`range`,get sort(){return t()},onClick:i})]}}),null),z(s,f(u,{get each(){return r()},children:(t,n)=>(()=>{var r=Gx(),i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return R(i,`color`,Z),z(i,()=>t._id),z(a,()=>px(t.price)),R(o,`color`,X),z(o,()=>fx(t.amount)),R(s,`color`,Z),z(s,()=>fx(t.remainingAmount)),z(r,f(v,{get when(){return e.showRoom},get children(){return[(()=>{var n=Ux();return z(n,f(v,{get when(){return t.roomName},get fallback(){return(()=>{var e=Kx();return R(e,`color`,Z),e})()},get children(){var n=Hx();return n.$$click=n=>{n.preventDefault(),ib(t.roomName,e.shard)},R(n,`color`,lx),z(n,()=>t.roomName),n}})),n})(),(()=>{var e=Wx();return R(e,`color`,Z),z(e,()=>t.range??`—`),e})()]}}),null),w(t=>{var i=Nx(n()),o=e.accent;return i!==t.e&&R(r,`background`,t.e=i),o!==t.t&&R(a,`color`,t.t=o),t},{e:void 0,t:void 0}),r})()})),n}})}})}function tS(e){let t=()=>e.sort===`+${e.col}`||e.sort===`-${e.col}`,n=()=>e.sort===`+${e.col}`?` ▲`:e.sort===`-${e.col}`?` ▼`:``;return(()=>{var r=qx();return r.$$click=()=>e.onClick(e.col),R(r,`border-bottom`,`1px solid ${Y}`),z(r,()=>e.label,null),z(r,n,null),w(n=>{var i=e.align??`right`,a=t()?X:Z,o=e.align===`left`?`0 0 7px 6px`:`0 0 7px`;return i!==n.e&&R(r,`text-align`,n.e=i),a!==n.t&&R(r,`color`,n.t=a),o!==n.a&&R(r,`padding`,n.a=o),n},{e:void 0,t:void 0,a:void 0}),r})()}function nS(e){return f(Mx,{title:`Price history`,get children(){return f(v,{get when(){return e.stats.length},get fallback(){return(()=>{var e=Yx();return R(e,`color`,Z),e})()},get children(){var t=Jx(),n=t.firstChild,r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=n.nextSibling;return R(r,`color`,Z),R(i,`border-bottom`,`1px solid ${Y}`),R(a,`border-bottom`,`1px solid ${Y}`),R(o,`border-bottom`,`1px solid ${Y}`),R(s,`border-bottom`,`1px solid ${Y}`),z(c,f(u,{get each(){return e.stats},children:(e,t)=>(()=>{var n=Xx(),r=n.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling,s=o.firstChild,c=s.nextSibling;return c.firstChild,R(r,`color`,Z),z(r,()=>e.date),R(i,`color`,X),z(i,()=>fx(e.transactions)),R(a,`color`,X),z(a,()=>fx(e.volume)),R(o,`color`,X),z(o,()=>px(e.avgPrice),s),R(c,`color`,Z),z(c,()=>px(e.stddevPrice),null),w(e=>R(n,`background`,Nx(t()))),n})()})),t}})}})}F([`click`,`input`]);var rS=P(`<div style=display:flex;justify-content:flex-end;margin-bottom:12px><button title=Refresh style="display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Refresh`),iS=P(`<div>`),aS=P(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load your orders.`),oS=P(`<div style=border-radius:8px;padding:32px;text-align:center>You have no orders. Create one with the in-game Market API.`),sS=P(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right><th style="text-align:left;font-weight:400;padding:0 0 7px 6px">Order ID</th><th style="text-align:left;font-weight:400;padding:0 0 7px">Resource</th><th style="font-weight:400;padding:0 0 7px">Type</th><th style="font-weight:400;padding:0 0 7px">Active</th><th style="font-weight:400;padding:0 0 7px">Price</th><th style="font-weight:400;padding:0 0 7px">Available</th><th style="font-weight:400;padding:0 0 7px">Remaining</th><th style="font-weight:400;padding:0 0 7px">Total</th><th style="font-weight:400;padding:0 6px 7px 0">Room</th></tr></thead><tbody>`),cS=P(`<span style=font-size:12px> `),lS=P(`<a href=# style=text-decoration:none>`),uS=P(`<tr style=text-align:right><td style="text-align:left;font-family:monospace;padding:7px 8px 7px 6px"></td><td style="text-align:left;padding:7px 0"><a href=# style=display:inline-flex;align-items:center;gap:8px;text-decoration:none></a></td><td style="padding:7px 0"></td><td style="padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="padding:7px 6px 7px 0">`),dS=P(`<span>—`);function fS(){let[e,t]=a([]),[n,r]=a(!0),[o,s]=a(null),c=()=>{let e=H();e&&(r(!0),e.http.game.market.myOrders().then(e=>{e.shards?t(Object.entries(e.shards).map(([e,t])=>({shard:e,orders:t}))):t([{shard:null,orders:e.list??[]}]),s(null)}).catch(e=>s(e instanceof Error?e.message:String(e))).finally(()=>r(!1)))};i(c);let l=()=>e().reduce((e,t)=>e+t.orders.length,0),d=()=>e().length>1;return f(v,{get when(){return!o()},get fallback(){return(()=>{var e=aS();return R(e,`background`,sx),R(e,`border`,`1px solid ${Y}`),R(e,`color`,Z),e})()},get children(){return[(()=>{var e=rS(),t=e.firstChild,n=t.firstChild;return t.$$click=c,R(t,`border`,`1px solid ${Y}`),R(t,`color`,X),z(t,f(ji,{size:14}),n),e})(),f(v,{get when(){return l()},get fallback(){return(()=>{var e=oS();return R(e,`background`,sx),R(e,`border`,`1px solid ${Y}`),R(e,`color`,Z),e})()},get children(){var t=iS();return z(t,f(u,{get each(){return e()},children:e=>f(v,{get when(){return e.orders.length},get children(){return f(Mx,{get title(){return N(()=>!!d())()?e.shard??`My orders`:`My orders`},get right(){return(()=>{var t=cS(),n=t.firstChild;return R(t,`color`,Z),z(t,()=>e.orders.length,n),z(t,()=>e.orders.length===1?`order`:`orders`,null),t})()},get children(){var t=sS(),n=t.firstChild,r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,d=l.nextSibling,p=d.nextSibling,m=p.nextSibling,h=n.nextSibling;return R(r,`color`,Z),R(i,`border-bottom`,`1px solid ${Y}`),R(a,`border-bottom`,`1px solid ${Y}`),R(o,`border-bottom`,`1px solid ${Y}`),R(s,`border-bottom`,`1px solid ${Y}`),R(c,`border-bottom`,`1px solid ${Y}`),R(l,`border-bottom`,`1px solid ${Y}`),R(d,`border-bottom`,`1px solid ${Y}`),R(p,`border-bottom`,`1px solid ${Y}`),R(m,`border-bottom`,`1px solid ${Y}`),z(h,f(u,{get each(){return e.orders},children:(t,n)=>(()=>{var r=uS(),i=r.firstChild,a=i.nextSibling,o=a.firstChild,s=a.nextSibling,c=s.nextSibling,l=c.nextSibling,u=l.nextSibling,d=u.nextSibling,p=d.nextSibling,m=p.nextSibling;return R(i,`color`,Z),z(i,()=>t._id),o.$$click=n=>{n.preventDefault(),Zy(t.resourceType,e.shard)},R(o,`color`,lx),z(o,f(Ex,{get resourceType(){return t.resourceType},size:16}),null),z(o,()=>yx(t.resourceType),null),z(s,()=>t.type===`sell`?`Selling`:`Buying`),z(c,()=>t.active?`Yes`:`No`),R(l,`color`,X),z(l,()=>px(t.price)),R(u,`color`,X),z(u,()=>fx(t.amount)),R(d,`color`,Z),z(d,()=>fx(t.remainingAmount)),R(p,`color`,Z),z(p,()=>fx(t.totalAmount)),z(m,f(v,{get when(){return t.roomName},get fallback(){return(()=>{var e=dS();return R(e,`color`,Z),e})()},get children(){var n=lS();return n.$$click=n=>{n.preventDefault(),ib(t.roomName,e.shard)},R(n,`color`,lx),z(n,()=>t.roomName),n}})),w(e=>{var i=Nx(n()),a=t.type===`sell`?ux:dx,o=t.active?ux:dx;return i!==e.e&&R(r,`background`,e.e=i),a!==e.t&&R(s,`color`,e.t=a),o!==e.a&&R(c,`color`,e.a=o),e},{e:void 0,t:void 0,a:void 0}),r})()})),t}})}})})),w(e=>R(t,`opacity`,n()?.6:1)),t}})]}})}F([`click`]);var pS=P(`<div style=display:flex;justify-content:flex-end;margin-bottom:12px><button title=Refresh style="display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Refresh`),mS=P(`<th style="text-align:left;font-weight:400;padding:0 0 7px">Shard`),hS=P(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right><th style="text-align:left;font-weight:400;padding:0 0 7px 6px">Date</th><th style="font-weight:400;padding:0 0 7px">Tick</th><th style="text-align:left;font-weight:400;padding:0 12px 7px">Description</th><th style="font-weight:400;padding:0 0 7px">Change</th><th style="font-weight:400;padding:0 6px 7px 0">Balance</th></tr></thead><tbody>`),gS=P(`<button style="display:flex;align-items:center;gap:4px;padding:6px 12px;border-radius:4px;background:#21262d;cursor:pointer"> Newer`),_S=P(`<button style="display:flex;align-items:center;gap:4px;padding:6px 12px;border-radius:4px;background:#21262d;cursor:pointer">Older `),vS=P(`<div style=display:flex;justify-content:space-between;margin-top:16px>`),yS=P(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load your history.`),bS=P(`<div style=border-radius:8px;padding:32px;text-align:center>Your market history is empty.`),xS=P(`<td style="text-align:left;padding:7px 0">`),SS=P(`<tr style=text-align:right><td style="text-align:left;padding:7px 0 7px 6px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="text-align:left;padding:7px 12px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 6px 7px 0">`),CS=P(`<span>`);function wS(e){switch(e.type){case`market.buy`:return`Resources bought via market order`;case`market.sell`:return`Resources sold via market order`;case`market.fee`:return`Market fee`;default:return e.type.replace(/[._]/g,` `)}}function TS(e){let t=new Date(e);return isNaN(t.getTime())?e:t.toLocaleString()}function ES(){let[e,t]=a([]),[n,r]=a(0),[o,s]=a(!1),[c,l]=a(!0),[d,p]=a(null),m=e=>{let n=H();n&&(l(!0),n.http.user.moneyHistory(e).then(n=>{t(n.list??[]),r(n.page??e),s(n.hasMore??!1),p(null)}).catch(e=>p(e instanceof Error?e.message:String(e))).finally(()=>l(!1)))};return i(()=>m(0)),f(v,{get when(){return!d()},get fallback(){return(()=>{var e=yS();return R(e,`background`,sx),R(e,`border`,`1px solid ${Y}`),R(e,`color`,Z),e})()},get children(){return[(()=>{var e=pS(),t=e.firstChild,r=t.firstChild;return t.$$click=()=>m(n()),R(t,`border`,`1px solid ${Y}`),R(t,`color`,X),z(t,f(ji,{size:14}),r),e})(),f(v,{get when(){return e().length},get fallback(){return(()=>{var e=bS();return R(e,`background`,sx),R(e,`border`,`1px solid ${Y}`),R(e,`color`,Z),e})()},get children(){return[f(Mx,{title:`Credit history`,get children(){var t=hS(),n=t.firstChild,r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,l=s.nextSibling,d=n.nextSibling;return R(r,`color`,Z),R(i,`border-bottom`,`1px solid ${Y}`),z(r,f(v,{get when(){return gx()},get children(){var e=mS();return R(e,`border-bottom`,`1px solid ${Y}`),e}}),a),R(a,`border-bottom`,`1px solid ${Y}`),R(o,`border-bottom`,`1px solid ${Y}`),R(s,`border-bottom`,`1px solid ${Y}`),R(l,`border-bottom`,`1px solid ${Y}`),z(d,f(u,{get each(){return e()},children:(e,t)=>(()=>{var n=SS(),r=n.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return R(r,`color`,Z),z(r,()=>TS(e.date)),z(n,f(v,{get when(){return gx()},get children(){var t=xS();return R(t,`color`,Z),z(t,()=>e.shard??`—`),t}}),i),R(i,`color`,Z),z(i,()=>e.tick),R(a,`color`,X),z(a,()=>wS(e)),z(o,()=>e.change>0?`+`:``,null),z(o,()=>px(e.change),null),R(s,`color`,X),z(s,()=>px(e.balance)),w(r=>{var i=Nx(t()),a=e.change>0?ux:e.change<0?dx:Z;return i!==r.e&&R(n,`background`,r.e=i),a!==r.t&&R(o,`color`,r.t=a),r},{e:void 0,t:void 0}),n})()})),w(e=>R(t,`opacity`,c()?.6:1)),t}}),(()=>{var e=vS();return z(e,f(v,{get when(){return n()>0},get fallback(){return CS()},get children(){var e=gS(),t=e.firstChild;return e.$$click=()=>m(n()-1),R(e,`border`,`1px solid ${Y}`),R(e,`color`,X),z(e,f(jr,{size:14}),t),e}}),null),z(e,f(v,{get when(){return o()},get children(){var e=_S();return e.firstChild,e.$$click=()=>m(n()+1),R(e,`border`,`1px solid ${Y}`),R(e,`color`,X),z(e,f(Nr,{size:14}),null),e}}),null),e})()]}})]}})}F([`click`]);var DS=P(`<label style=display:flex;align-items:center;gap:8px;font-size:13px>Shard<select style="padding:6px 8px;border-radius:4px;cursor:pointer">`),OS=P(`<div style=width:100%;height:100%;overflow:auto><div style="max-width:1040px;margin:0 auto;padding:24px 16px 48px"><div style="display:flex;align-items:center;gap:12px;padding:0 0 14px;margin-bottom:8px"><button title="Back to the world"style="display:flex;align-items:center;gap:4px;padding:7px 12px;border-radius:4px;background:#21262d;cursor:pointer"> World</button><h1 style=margin:0;font-size:22px;font-weight:600>Market</h1><div style=flex:1></div></div><div style=display:flex;gap:4px;margin-bottom:20px>`),kS=P(`<option>`),AS=P(`<button style="padding:8px 16px;border:none;background:transparent;font-size:14px;cursor:pointer;margin-bottom:-1px">`);function jS(){let e=()=>Iy()===`all-orders`||Iy()===`resource`,t=e=>{Iy()===`resource`&&Ry()?Zy(Ry(),e):Xy(e)};return(()=>{var n=OS(),r=n.firstChild,i=r.firstChild,a=i.firstChild,o=a.firstChild,s=a.nextSibling;s.nextSibling;var c=i.nextSibling;return R(n,`background`,ox),R(n,`color`,X),R(i,`border-bottom`,`1px solid ${Y}`),Te(a,`click`,rb,!0),R(a,`border`,`1px solid ${Y}`),R(a,`color`,X),z(a,f(kr,{size:16}),o),R(s,`color`,X),z(i,f(v,{get when(){return N(()=>!!e())()&&gx()},get children(){var e=DS(),n=e.firstChild.nextSibling;return R(e,`color`,Z),n.addEventListener(`change`,e=>t(e.currentTarget.value)),R(n,`border`,`1px solid ${Y}`),R(n,`background`,sx),R(n,`color`,X),z(n,f(u,{get each(){return mx()},children:e=>(()=>{var t=kS();return t.value=e,z(t,e),t})()})),w(()=>n.value=hx()??``),e}}),null),R(c,`border-bottom`,`1px solid ${Y}`),z(c,f(MS,{label:`All orders`,get active(){return e()},onClick:()=>Xy(hx())}),null),z(c,f(MS,{label:`My orders`,get active(){return Iy()===`my-orders`},onClick:Qy}),null),z(c,f(MS,{label:`History`,get active(){return Iy()===`history`},onClick:$y}),null),z(r,f(_,{get children(){return[f(d,{get when(){return Iy()===`resource`},get children(){return f($x,{get resourceType(){return Ry()},get shard(){return hx()}})}}),f(d,{get when(){return Iy()===`my-orders`},get children(){return f(fS,{})}}),f(d,{get when(){return Iy()===`history`},get children(){return f(ES,{})}}),f(d,{get when(){return Iy()===`all-orders`},get children(){return f(Ax,{get shard(){return hx()}})}})]}}),null),n})()}function MS(e){return(()=>{var t=AS();return t.$$click=()=>e.onClick(),z(t,()=>e.label),w(n=>{var r=`2px solid ${e.active?lx:`transparent`}`,i=e.active?X:Z,a=e.active?600:400;return r!==n.e&&R(t,`border-bottom`,n.e=r),i!==n.t&&R(t,`color`,n.t=i),a!==n.a&&R(t,`font-weight`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()}F([`click`]);var NS=[`operator`,`commander`,`executor`],PS={operator:{name:`operator`,label:`Operator`,description:`A creep working mainly in the rear, at your base, though it can be used as a saboteur in offensive operations.`,underDevelopment:!1},commander:{name:`commander`,label:`Commander`,description:`This power creep is not very useful on its own, but it's a team player. It influences and affects regular creeps, both friendly and hostile.`,underDevelopment:!0},executor:{name:`executor`,label:`Executor`,description:`This creep class prefers working alone. Due to its skills, it's a very effective performer in your economy or as a war machine when defending or attacking.`,underDevelopment:!0}},FS={GENERATE_OPS:1,OPERATE_SPAWN:2,OPERATE_TOWER:3,OPERATE_STORAGE:4,OPERATE_LAB:5,OPERATE_EXTENSION:6,OPERATE_OBSERVER:7,OPERATE_TERMINAL:8,DISRUPT_SPAWN:9,DISRUPT_TOWER:10,DISRUPT_SOURCE:11,SHIELD:12,REGEN_SOURCE:13,REGEN_MINERAL:14,DISRUPT_TERMINAL:15,OPERATE_POWER:16,FORTIFY:17,OPERATE_CONTROLLER:18,OPERATE_FACTORY:19},IS=[0,2,7,14,22],LS=[10,11,12,14,22],RS=[20,21,22,23,24],zS=(e,t,n,r,i)=>[e,t,n,r,i],BS=[{id:FS.GENERATE_OPS,name:`GENERATE_OPS`,className:`operator`,icon:ra,reqLevel:IS,values:zS(`1`,`2`,`4`,`6`,`8`),effect:`Generate %s ops resource units.`,cooldown:50},{id:FS.OPERATE_SPAWN,name:`OPERATE_SPAWN`,className:`operator`,icon:Ni,reqLevel:IS,values:zS(`10%`,`30%`,`50%`,`65%`,`80%`),effect:`Reduce spawn time by %s.`,duration:1e3,cooldown:300,range:3,ops:100},{id:FS.OPERATE_TOWER,name:`OPERATE_TOWER`,className:`operator`,icon:Vr,reqLevel:IS,values:zS(`10%`,`20%`,`30%`,`40%`,`50%`),effect:`Increase damage, repair and heal amount by %s.`,duration:100,cooldown:10,range:3,ops:10},{id:FS.OPERATE_STORAGE,name:`OPERATE_STORAGE`,className:`operator`,icon:Ur,reqLevel:IS,values:zS(`500K`,`1M`,`2M`,`4M`,`7M`),effect:`Increase capacity by %s units.`,duration:1e3,cooldown:800,range:3,ops:100},{id:FS.OPERATE_LAB,name:`OPERATE_LAB`,className:`operator`,icon:Zr,reqLevel:IS,values:zS(`2`,`4`,`6`,`8`,`10`),effect:`Increase reaction amount by %s units.`,duration:1e3,cooldown:50,range:3,ops:10},{id:FS.OPERATE_EXTENSION,name:`OPERATE_EXTENSION`,className:`operator`,icon:_r,reqLevel:IS,values:zS(`20%`,`40%`,`60%`,`80%`,`100%`),effect:`Instantly fill %s of all extensions in the room using energy from the target structure.`,cooldown:50,range:3,ops:2},{id:FS.OPERATE_OBSERVER,name:`OPERATE_OBSERVER`,className:`operator`,icon:Gr,reqLevel:IS,values:zS(`200`,`400`,`600`,`800`,`1000`),effect:`Grant unlimited range. Effect duration %s ticks.`,cooldown:400,range:3,ops:10},{id:FS.OPERATE_TERMINAL,name:`OPERATE_TERMINAL`,className:`operator`,icon:dr,reqLevel:IS,values:zS(`10%`,`20%`,`30%`,`40%`,`50%`),effect:`Decrease transfer energy cost and cooldown by %s.`,duration:1e3,cooldown:500,range:3,ops:100},{id:FS.DISRUPT_SPAWN,name:`DISRUPT_SPAWN`,className:`operator`,icon:hr,reqLevel:IS,values:zS(`1`,`2`,`3`,`4`,`5`),effect:`Pause spawning process. Effect duration %s ticks.`,cooldown:5,range:20,ops:10},{id:FS.DISRUPT_TOWER,name:`DISRUPT_TOWER`,className:`operator`,icon:ta,reqLevel:IS,values:zS(`10%`,`20%`,`30%`,`40%`,`50%`),effect:`Reduce effectiveness by %s.`,duration:5,cooldown:null,range:50,ops:10},{id:FS.DISRUPT_SOURCE,name:`DISRUPT_SOURCE`,className:`operator`,icon:Fr,reqLevel:IS,values:zS(`100`,`200`,`300`,`400`,`500`),effect:`Pause energy regeneration. Effect duration %s ticks.`,cooldown:100,range:3,ops:100},{id:FS.SHIELD,name:`SHIELD`,className:`operator`,icon:Vi,reqLevel:IS,values:zS(`5K`,`10K`,`15K`,`20K`,`25K`),effect:`Create a temporary non-repairable rampart on the same square with %s hits. Cannot be used on top of another rampart.`,duration:50,cooldown:20},{id:FS.FORTIFY,name:`FORTIFY`,className:`operator`,icon:zi,reqLevel:IS,values:zS(`1`,`2`,`3`,`4`,`5`),effect:`Make a wall or rampart tile invulnerable to all creep attacks and powers. Effect duration %s ticks.`,cooldown:5,range:3,ops:5},{id:FS.OPERATE_FACTORY,name:`OPERATE_FACTORY`,className:`operator`,icon:qr,reqLevel:IS,values:zS(`1`,`2`,`3`,`4`,`5`),effect:`Set the factory level to %s. Permanent and cannot be undone; re-apply to renew the effect.`,duration:1e3,cooldown:800,range:3,ops:100},{id:FS.REGEN_SOURCE,name:`REGEN_SOURCE`,className:`operator`,icon:Gi,reqLevel:LS,values:zS(`50`,`100`,`150`,`200`,`250`),effect:`Regenerate %s energy units in a source every 15 ticks.`,duration:300,cooldown:100,range:3},{id:FS.REGEN_MINERAL,name:`REGEN_MINERAL`,className:`operator`,icon:$r,reqLevel:LS,values:zS(`2`,`4`,`6`,`8`,`10`),effect:`Regenerate %s mineral units in a deposit every 10 ticks.`,duration:100,cooldown:100,range:3},{id:FS.OPERATE_POWER,name:`OPERATE_POWER`,className:`operator`,icon:pr,reqLevel:LS,values:zS(`1`,`2`,`3`,`4`,`5`),effect:`Increase power processing speed of a Power Spawn by %s units per tick.`,duration:1e3,cooldown:800,range:3,ops:200},{id:FS.DISRUPT_TERMINAL,name:`DISRUPT_TERMINAL`,className:`operator`,icon:xi,reqLevel:RS,values:zS(``,``,``,``,``),effect:`Block withdrawing resources from the terminal.`,duration:10,cooldown:8,range:50,ops:[50,40,30,20,10]},{id:FS.OPERATE_CONTROLLER,name:`OPERATE_CONTROLLER`,className:`operator`,icon:Zi,reqLevel:RS,values:zS(`10`,`20`,`30`,`40`,`50`),effect:`Increase the max energy that can upgrade a Level 8 Controller each tick by %s units.`,duration:1e3,cooldown:800,range:3,ops:200}],VS=Object.fromEntries(BS.map(e=>[e.id,e]));function HS(e){return BS.filter(t=>t.className===e)}function US(e,t){let n=e.values[Math.max(0,Math.min(4,t-1))];return e.effect.replace(`%s`,n)}function WS(e,t){let n=[],r=Array.isArray(e.ops)?e.ops[Math.max(0,Math.min(4,t-1))]:e.ops;return r!=null&&n.push(`ops ${r}`),e.duration!=null&&n.push(`dur ${e.duration}`),e.cooldown===null?n.push(`no cooldown`):e.cooldown!=null&&n.push(`cd ${e.cooldown}`),e.range!=null&&n.push(`rng ${e.range}`),n.join(` · `)}function GS(e){return e.level+1}function KS(e,t){return Vb(e??0)-t.reduce((e,t)=>e+GS(t),0)}var qS=P(`<svg><circle cx=12 cy=12 r=9.5></svg>`,!1,!0,!1),JS=P(`<svg><path d="M12 6.5 L17 16 L7 16 Z"stroke=none></svg>`,!1,!0,!1),YS=P(`<svg><path d="M5 8 L12 4 L19 8"></svg>`,!1,!0,!1),XS=P(`<svg><path d="M5 13 L12 9 L19 13"></svg>`,!1,!0,!1),ZS=P(`<svg><path d="M5 18 L12 14 L19 18"></svg>`,!1,!0,!1),QS=P(`<svg><path d="M12 2.5 L15 9 L21.5 12 L15 15 L12 21.5 L9 15 L2.5 12 L9 9 Z"></svg>`,!1,!0,!1),$S=P(`<svg viewBox="0 0 24 24"fill=none stroke-width=1.8 stroke-linecap=round stroke-linejoin=round style=display:block;flex-shrink:0>`);function eC(e){let t=()=>e.size??24,n=()=>e.color??`currentColor`;return(()=>{var r=$S();return z(r,f(_,{get children(){return[f(d,{get when(){return e.class===`operator`},get children(){return[qS(),(()=>{var e=JS();return w(()=>I(e,`fill`,n())),e})()]}}),f(d,{get when(){return e.class===`commander`},get children(){return[YS(),XS(),ZS()]}}),f(d,{get when(){return e.class===`executor`},get children(){return QS()}})]}})),w(e=>{var i=t(),a=t(),o=n();return i!==e.e&&I(r,`width`,e.e=i),a!==e.t&&I(r,`height`,e.t=a),o!==e.a&&I(r,`stroke`,e.a=o),e},{e:void 0,t:void 0,a:void 0}),r})()}var tC=`#0d1117`,nC=`#161b22`,rC=`#1c2128`,Q=`#30363d`,iC=`#c9d1d9`,$=`#8b949e`,aC=`#58a6ff`,oC=`#238636`,sC=`#FF9A9A`,cC=`#E04040`,lC=P(`<button style="display:inline-flex;align-items:center;gap:6px;padding:8px 16px;border-radius:6px;border:none;font-size:13px;font-weight:600"> Create creep`),uC=P(`<div style=display:flex;flex-wrap:wrap;gap:6px>`),dC=P(`<div style=font-size:11px;color:#f0883e>Scheduled for deletion`),fC=P(`<button style=text-align:left;display:flex;flex-direction:column;gap:12px;width:220px;border-radius:8px;padding:16px;cursor:pointer><div style=display:flex;align-items:center;gap:10px><div style=min-width:0;flex:1><div style=font-size:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis></div><div style=font-size:12px> · Lvl `),pC=P(`<div style=font-size:11px>No powers assigned`),mC=P(`<span style=display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:5px>`),hC=P(`<div style=display:flex;align-items:center;margin-bottom:16px><div style=flex:1></div><a href=https://docs.screeps.com/power.html target=_blank rel=noopener style=color:#58a6ff;font-size:13px;text-decoration:none>Learn more`),gC=P(`<div style=display:flex;flex-wrap:wrap;gap:16px>`),_C=P(`<div style=padding:32px;text-align:center>Loading…`),vC=P(`<div style="border-radius:10px;padding:48px 24px;text-align:center"><div style=display:flex;justify-content:center;gap:28px;margin-bottom:24px></div><p style="font-size:15px;margin:0 0 6px;line-height:1.5">You have no Power Creeps yet.</p><p style="font-size:13px;margin:0 0 24px;line-height:1.5">You need 1 free Power Level in your account to create a new Power Creep.</p><div style=display:flex;align-items:center;justify-content:center;gap:16px><a href=https://docs.screeps.com/power.html target=_blank rel=noopener style=color:#58a6ff;font-size:13px;text-decoration:none>Learn more`);function yC(e){let t=()=>e.free>=1;return(()=>{var e=lC(),n=e.firstChild;return e.$$click=()=>t()&&tb(),z(e,f(ki,{size:16}),n),w(n=>{var r=!t(),i=t()?`Create a new power creep`:`You need 1 free Power Level to create a power creep`,a=t()?oC:`#21262d`,o=t()?`#fff`:$,s=t()?`pointer`:`not-allowed`,c=t()?1:.7;return r!==n.e&&(e.disabled=n.e=r),i!==n.t&&I(e,`title`,n.t=i),a!==n.a&&R(e,`background`,n.a=a),o!==n.o&&R(e,`color`,n.o=o),s!==n.i&&R(e,`cursor`,n.i=s),c!==n.n&&R(e,`opacity`,n.n=c),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),e})()}function bC(e){let t=()=>e.creep.className,n=()=>PS[t()]??PS.operator,r=()=>{let t=e.creep.powers??{};return Object.keys(t).filter(e=>(t[e]?.level??0)>0).map(e=>VS[Number(e)]).filter(Boolean)};return(()=>{var i=fC(),a=i.firstChild,o=a.firstChild,s=o.firstChild,c=s.nextSibling,l=c.firstChild;return i.$$click=()=>nb(e.creep._id),R(i,`background`,nC),R(i,`border`,`1px solid ${Q}`),R(i,`color`,iC),z(a,f(eC,{get class(){return t()},size:28,color:sC}),o),z(s,()=>e.creep.name),R(c,`color`,$),z(c,()=>n().label,l),z(c,()=>e.creep.level,null),z(i,f(v,{get when(){return r().length},get fallback(){return(()=>{var e=pC();return R(e,`color`,$),e})()},get children(){var e=uC();return z(e,f(u,{get each(){return r()},children:e=>(()=>{var t=mC();return R(t,`background`,rC),R(t,`border`,`1px solid ${Q}`),z(t,f(We,{get component(){return e.icon},size:14,color:cC})),w(()=>I(t,`title`,e.name)),t})()})),e}}),null),z(i,f(v,{get when(){return e.creep.deleteTime},get children(){return dC()}}),null),i})()}function xC(e){let t=()=>e.ctx.creeps();return f(v,{get when(){return!e.loading},get fallback(){return(()=>{var e=_C();return R(e,`color`,$),e})()},get children(){return f(v,{get when(){return t().length},get fallback(){return(()=>{var t=vC(),n=t.firstChild,r=n.nextSibling,i=r.nextSibling,a=i.nextSibling,o=a.firstChild;return R(t,`background`,nC),R(t,`border`,`1px solid ${Q}`),z(n,f(u,{each:NS,children:e=>f(eC,{class:e,size:44,color:e===`operator`?sC:Q})})),R(r,`color`,iC),R(i,`color`,$),z(a,f(yC,{get free(){return e.ctx.free()}}),o),t})()},get children(){return[(()=>{var t=hC(),n=t.firstChild;return n.nextSibling,z(t,f(yC,{get free(){return e.ctx.free()}}),n),t})(),(()=>{var e=gC();return z(e,f(u,{get each(){return t()},children:e=>f(bC,{creep:e})})),e})()]}})}})}F([`click`]);var SC=P(`<span style=font-size:10px;margin-left:4px>unlocks at Lvl `),CC=P(`<div style="border-radius:8px;padding:12px 14px;display:flex;flex-direction:column;gap:8px"><div style=display:flex;align-items:center;gap:8px><span style=font-size:12px;font-weight:600;letter-spacing:0.02em;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis></span><span style=font-size:11px>Lv </span></div><div style=display:flex;align-items:center;gap:5px></div><div style=font-size:11px;line-height:1.4></div><div style=font-size:10px>`),wC=P(`<button style=width:14px;height:14px;border-radius:50%;padding:0;flex-shrink:0;display:flex;align-items:center;justify-content:center>`);function TC(e){let t=()=>e.stagedLevel??e.currentLevel,n=()=>Math.max(1,t()),r=()=>t()===0,i=()=>t()+1,a=n=>n<=e.currentLevel?`saved`:n<=t()?`staged`:n===i()&&e.editable?e.canIncrement?`next`:`locked`:`empty`;return(()=>{var o=CC(),s=o.firstChild,c=s.firstChild,l=c.nextSibling;l.firstChild;var d=s.nextSibling,p=d.nextSibling,m=p.nextSibling;return R(o,`background`,rC),R(o,`border`,`1px solid ${Q}`),z(s,f(We,{get component(){return e.def.icon},size:16,get color(){return t()>0?cC:$}}),c),R(c,`color`,iC),z(c,()=>e.def.name),z(l,t,null),z(d,f(u,{each:[1,2,3,4,5],children:t=>{let n=()=>a(t),r=()=>n()===`next`;return(()=>{var i=wC();return i.$$click=()=>r()&&e.onIncrement?.(),z(i,f(v,{get when(){return n()===`locked`},get children(){return f(di,{size:8,color:$})}})),w(a=>{var o=!r(),s=n()===`locked`&&e.lockLevel!=null?`Unlocks at creep Lvl ${e.lockLevel}`:r()?`Upgrade to Lv ${t}`:void 0,c=r()?`pointer`:`default`,l=n()===`saved`?cC:n()===`staged`?aC:`transparent`,u=n()===`next`?`1px solid ${aC}`:n()===`locked`?`1px dashed ${Q}`:n()===`saved`||n()===`staged`?`none`:`1px solid ${Q}`;return o!==a.e&&(i.disabled=a.e=o),s!==a.t&&I(i,`title`,a.t=s),c!==a.a&&R(i,`cursor`,a.a=c),l!==a.o&&R(i,`background`,a.o=l),u!==a.i&&R(i,`border`,a.i=u),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),i})()}}),null),z(d,f(v,{get when(){return N(()=>!!(e.editable&&i()<=5&&!e.canIncrement))()&&e.lockLevel!=null},get children(){var t=SC();return t.firstChild,R(t,`color`,$),z(t,()=>e.lockLevel,null),t}}),null),z(p,()=>US(e.def,n())),R(m,`color`,$),z(m,()=>WS(e.def,n())),w(e=>{var n=t()>0?iC:$,i=r()?$:iC;return n!==e.e&&R(l,`color`,e.e=n),i!==e.t&&R(p,`color`,e.t=i),e},{e:void 0,t:void 0}),o})()}F([`click`]);var EC=P(`<span style=color:#f0883e> (Under development)`),DC=P(`<div style=font-size:11px;text-transform:uppercase;letter-spacing:0.06em;font-weight:700;margin-bottom:12px> powers`),OC=P(`<div style="display:grid;grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));gap:12px">`),kC=P(`<div><div style=display:flex;align-items:center;justify-content:space-between;margin-bottom:20px><button style="display:inline-flex;align-items:center;gap:4px;padding:6px 10px;border-radius:4px;background:transparent;font-size:13px;cursor:pointer"> Back</button><span style=font-size:13px>Creating a power creep uses <strong>1</strong> free Power Level</span></div><div style=border-radius:10px;padding:24px><label style=display:block;font-size:11px;text-transform:uppercase;letter-spacing:0.06em;font-weight:700;margin-bottom:8px>Creep name</label><input placeholder="Enter creep name"maxlength=50 style="width:100%;box-sizing:border-box;padding:9px 12px;border-radius:6px;background:#0d1117;font-size:14px;outline:none;margin-bottom:24px"><div style=font-size:11px;text-transform:uppercase;letter-spacing:0.06em;font-weight:700;margin-bottom:10px>Select class</div><div style=display:flex;gap:12px;margin-bottom:14px></div><p style="font-size:13px;line-height:1.5;margin:0 0 24px"></p></div><div style=display:flex;justify-content:flex-end;margin-top:16px><button style="padding:9px 20px;border-radius:6px;border:none;font-size:14px;font-weight:600">`),AC=P(`<span style=font-size:10px;color:#f0883e>Under development`),jC=P(`<button style="flex:1;display:flex;flex-direction:column;align-items:center;gap:8px;padding:16px 8px;border-radius:8px;cursor:pointer"><span style=font-size:13px;font-weight:600>`),MC=P(`<div style="font-size:13px;text-align:center;padding:24px 0">This class has no powers available yet.`);function NC(e){let[t,n]=a(``),[r,i]=a(`operator`),[o,s]=a(!1),c=()=>PS[r()],l=()=>!o()&&e.ctx.free()>=1&&t().trim().length>0&&!c().underDevelopment,d=async()=>{let n=H();if(!n||!l())return;let i=t().trim();s(!0);try{await n.http.game.powerCreeps.create(i,r()),await e.ctx.reload();let t=e.ctx.creeps().find(e=>e.name===i);B(`Power creep "${i}" created`,`success`,3e3),t?nb(t._id):eb()}catch(e){B(`Failed to create power creep: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}finally{s(!1)}};return(()=>{var a=kC(),s=a.firstChild,p=s.firstChild,m=p.firstChild,h=p.nextSibling,g=h.firstChild.nextSibling,_=s.nextSibling,y=_.firstChild,b=y.nextSibling,x=b.nextSibling,S=x.nextSibling,C=S.nextSibling,T=_.nextSibling.firstChild;return Te(p,`click`,eb,!0),R(p,`border`,`1px solid ${Q}`),R(p,`color`,$),z(p,f(kr,{size:16}),m),R(h,`color`,$),R(g,`color`,sC),R(_,`background`,nC),R(_,`border`,`1px solid ${Q}`),R(y,`color`,$),b.$$input=e=>n(e.currentTarget.value),R(b,`border`,`1px solid ${Q}`),R(b,`color`,iC),R(x,`color`,$),z(S,f(u,{each:NS,children:e=>{let t=PS[e],n=()=>r()===e;return(()=>{var r=jC(),a=r.firstChild;return r.$$click=()=>i(e),z(r,f(eC,{class:e,size:36,get color(){return n()?sC:$}}),a),z(a,()=>t.label),z(r,f(v,{get when(){return t.underDevelopment},get children(){return AC()}}),null),w(e=>{var t=`1px solid ${n()?aC:Q}`,i=n()?`#1c2d47`:rC,a=n()?iC:$;return t!==e.e&&R(r,`border`,e.e=t),i!==e.t&&R(r,`background`,e.t=i),a!==e.a&&R(r,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),r})()}})),R(C,`color`,$),z(C,()=>c().description,null),z(C,f(v,{get when(){return c().underDevelopment},get children(){return EC()}}),null),z(_,f(v,{get when(){return!c().underDevelopment},get fallback(){return(()=>{var e=MC();return R(e,`color`,$),e})()},get children(){return[(()=>{var e=DC(),t=e.firstChild;return R(e,`color`,$),z(e,()=>c().label,t),e})(),(()=>{var e=OC();return z(e,f(u,{get each(){return HS(r())},children:e=>f(TC,{def:e,currentLevel:0})})),e})()]}}),null),T.$$click=d,z(T,()=>o()?`Creating…`:`Create creep`),w(t=>{var n=!l(),r=e.ctx.free()<1?`You need 1 free Power Level`:void 0,i=l()?oC:`#21262d`,a=l()?`#fff`:$,o=l()?`pointer`:`not-allowed`,s=l()?1:.7;return n!==t.e&&(T.disabled=t.e=n),r!==t.t&&I(T,`title`,t.t=r),i!==t.a&&R(T,`background`,t.a=i),a!==t.o&&R(T,`color`,t.o=a),o!==t.i&&R(T,`cursor`,t.i=o),s!==t.n&&R(T,`opacity`,t.n=s),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),w(()=>b.value=t()),a})()}F([`click`,`input`]);var PC=P(`<div style=font-size:13px;margin-top:8px;line-height:1.5>`),FC=P(`<button style="padding:8px 22px;border-radius:6px;background:transparent;font-size:14px;cursor:pointer">`),IC=P(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:300;display:flex;align-items:center;justify-content:center><div style="border-radius:10px;padding:24px;max-width:440px;text-align:center;box-shadow:0 8px 24px rgba(0,0,0,0.5)"><div style=font-size:16px;font-weight:600;line-height:1.4></div><div style=display:flex;gap:10px;justify-content:center;margin-top:20px><button style="padding:8px 22px;border-radius:6px;border:none;color:#fff;font-size:14px;font-weight:600;cursor:pointer">`);function LC(e){i(()=>{let t=t=>{t.key===`Escape`?e.onCancel():t.key===`Enter`&&e.onConfirm()};window.addEventListener(`keydown`,t),n(()=>window.removeEventListener(`keydown`,t))});let t=t=>{t.target===t.currentTarget&&e.onCancel()};return(()=>{var n=IC(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.firstChild;return n.$$click=t,R(r,`background`,nC),R(r,`border`,`1px solid ${Q}`),R(i,`color`,iC),z(i,()=>e.title),z(r,f(v,{get when(){return e.body},get children(){var t=PC();return R(t,`color`,$),z(t,()=>e.body),t}}),a),o.$$click=()=>e.onConfirm(),R(o,`background`,aC),z(o,()=>e.confirmLabel??(e.notice?`Close`:`Yes`)),z(a,f(v,{get when(){return!e.notice},get children(){var t=FC();return t.$$click=()=>e.onCancel(),R(t,`border`,`1px solid ${Q}`),R(t,`color`,iC),z(t,()=>e.cancelLabel??`No`),t}}),null),n})()}F([`click`]);var RC=P(`<div style=border-radius:8px;padding:32px;text-align:center>Power creep not found. <a style=cursor:pointer>Back to list`),zC=P(`<div style=display:flex;align-items:center;gap:6px><input maxlength=50 style="padding:4px 8px;border-radius:4px;background:#0d1117;font-size:15px;outline:none"><button title="Save name"style=background:transparent;border:none;cursor:pointer></button><button title=Cancel style=background:transparent;border:none;cursor:pointer>`),BC=P(`<span> → `),VC=P(`<div style=margin-top:2px> staged`),HC=P(`<button style="background:transparent;border:1px solid #f0883e;border-radius:6px;color:#f0883e;cursor:pointer;padding:7px 10px;font-size:12px">Cancel deletion`),UC=P(`<div style="background:#21262d;border-radius:6px;padding:8px 12px;font-size:12px;color:#f0883e;margin-bottom:16px">You have reached the maximum creep level (<!>).`),WC=P(`<div><button style="display:inline-flex;align-items:center;gap:4px;padding:6px 10px;border-radius:4px;background:transparent;font-size:13px;cursor:pointer;margin-bottom:16px"> Back</button><div style="display:flex;align-items:center;gap:14px;border-radius:10px;padding:18px 20px;margin-bottom:16px"><div style=flex:1;min-width:0><div style=font-size:13px;margin-top:2px> · Level <strong></strong></div></div><div style=text-align:right;font-size:12px><div>Free GPL <strong></strong> / </div></div></div><div style="display:grid;grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));gap:12px"></div><div style=display:flex;justify-content:flex-end;gap:10px;margin-top:20px><button style="padding:9px 18px;border-radius:6px;background:transparent;font-size:14px">Reset</button><button style="padding:9px 20px;border-radius:6px;border:none;font-size:14px;font-weight:600">`),GC=P(`<div style=display:flex;align-items:center;gap:8px><span style=font-size:18px;font-weight:600></span><button title=Rename style=background:transparent;border:none;cursor:pointer;padding:2px>`),KC=P(`<button title="Delete power creep"style="background:transparent;border-radius:6px;color:#f85149;cursor:pointer;padding:7px 9px;display:flex">`),qC=P(`<strong> GPL`),JC=P(`<strong>1 Power Level`);function YC(e){let t=()=>e.ctx.creeps().find(t=>t._id===e.id)??null,n=()=>t()?.className??`operator`,r=()=>HS(n()),[i,o]=a({}),[s,c]=a(!1),[l,d]=a(!1),[p,m]=a(!1),[h,g]=a(!1),[_,y]=a(!1),[b,x]=a(!1),[S,C]=a(``),T=e=>t()?.powers?.[e]?.level??0,E=e=>i()[e]??T(e),D=()=>{let e=0;for(let t of r())e+=E(t.id)-T(t.id);return e},O=()=>(t()?.level??0)+D(),ee=()=>e.ctx.free()-D(),k=()=>D()>0,A=e=>{let t=E(e.id);return t<5&&O()<25&&ee()>=1&&O()>=e.reqLevel[t]},te=e=>{let t=E(e.id);return t<5&&O()<e.reqLevel[t]?e.reqLevel[t]:void 0},ne=e=>{if(O()>=25){y(!0);return}A(e)&&o({...i(),[e.id]:E(e.id)+1})},re=async()=>{let n=H(),i=t();if(d(!1),!(!n||!i)){c(!0);try{let t={};for(let e of r()){let n=E(e.id);n>0&&(t[e.id]=n)}await n.http.game.powerCreeps.upgrade(i._id,t),await e.ctx.reload(),await n.stores.user.refreshMe().catch(()=>{}),o({}),B(`Power creep upgraded`,`success`,3e3)}catch(e){B(`Upgrade failed: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}finally{c(!1)}}},ie=async()=>{let n=H(),r=t(),i=S().trim();if(x(!1),!(!n||!r||!i||i===r.name))try{await n.http.game.powerCreeps.rename(r._id,i),await e.ctx.reload()}catch(e){B(`Rename failed: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}},j=async()=>{let n=H(),r=t();if(g(!1),!(!n||!r))try{await n.http.game.powerCreeps.delete(r._id),await e.ctx.reload(),B(`Power creep "${r.name}" deleted`,`success`,3e3),eb()}catch(e){B(`Delete failed: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}},ae=async()=>{let n=H(),r=t();if(!(!n||!r))try{await n.http.game.powerCreeps.cancelDelete(r._id),await e.ctx.reload()}catch(e){B(`Failed to cancel deletion: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}};return f(v,{get when(){return t()},get fallback(){return(()=>{var e=RC(),t=e.firstChild.nextSibling;return R(e,`background`,nC),R(e,`border`,`1px solid ${Q}`),R(e,`color`,$),Te(t,`click`,eb,!0),R(t,`color`,aC),e})()},children:t=>(()=>{var i=WC(),a=i.firstChild,c=a.firstChild,oe=a.nextSibling,M=oe.firstChild,se=M.firstChild,ce=se.firstChild,le=ce.nextSibling,ue=M.nextSibling,de=ue.firstChild,fe=de.firstChild.nextSibling;fe.nextSibling;var pe=oe.nextSibling,me=pe.nextSibling.firstChild,he=me.nextSibling;return Te(a,`click`,eb,!0),R(a,`border`,`1px solid ${Q}`),R(a,`color`,$),z(a,f(kr,{size:16}),c),R(oe,`background`,nC),R(oe,`border`,`1px solid ${Q}`),z(oe,f(eC,{get class(){return n()},size:44,color:sC}),M),z(M,f(v,{get when(){return b()},get fallback(){return(()=>{var e=GC(),n=e.firstChild,r=n.nextSibling;return R(n,`color`,iC),z(n,()=>t().name),r.$$click=()=>{C(t().name),x(!0)},R(r,`color`,$),z(r,f(Ti,{size:14})),e})()},get children(){var e=zC(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling;return t.$$keydown=e=>{e.key===`Enter`&&ie(),e.key===`Escape`&&x(!1)},t.$$input=e=>C(e.currentTarget.value),R(t,`border`,`1px solid ${Q}`),R(t,`color`,iC),n.$$click=()=>void ie(),R(n,`color`,oC),z(n,f(Cr,{size:16})),r.$$click=()=>x(!1),R(r,`color`,$),z(r,f($i,{size:16})),w(()=>t.value=S()),e}}),se),R(se,`color`,$),z(se,()=>PS[n()].label,ce),R(le,`color`,iC),z(le,()=>t().level),z(se,f(v,{get when(){return k()},get children(){var e=BC();return e.firstChild,R(e,`color`,aC),z(e,O,null),e}}),null),R(ue,`color`,$),z(fe,()=>Math.max(0,ee())),z(de,()=>e.ctx.gpl(),null),z(ue,f(v,{get when(){return k()},get children(){var e=VC(),t=e.firstChild;return R(e,`color`,aC),z(e,D,t),e}}),null),z(oe,f(v,{get when(){return t().deleteTime},get fallback(){return(()=>{var e=KC();return e.$$click=()=>g(!0),R(e,`border`,`1px solid ${Q}`),z(e,f(Yi,{size:16})),e})()},get children(){var e=HC();return e.$$click=()=>void ae(),e}}),null),z(i,f(v,{get when(){return O()>=25},get children(){var e=UC(),t=e.firstChild.nextSibling;return t.nextSibling,R(e,`border`,`1px solid ${Q}`),z(e,25,t),e}}),pe),z(pe,f(u,{get each(){return r()},children:e=>f(TC,{def:e,get currentLevel(){return T(e.id)},get stagedLevel(){return E(e.id)},editable:!0,get canIncrement(){return A(e)},get lockLevel(){return te(e)},onIncrement:()=>ne(e)})})),me.$$click=()=>m(!0),R(me,`border`,`1px solid ${Q}`),he.$$click=()=>d(!0),z(he,()=>s()?`Saving…`:`Save changes`),z(i,f(v,{get when(){return l()},get children(){return f(LC,{title:`This action cannot be undone without deleting the creep.`,get body(){return[`Do you want to proceed and use `,(()=>{var e=qC(),t=e.firstChild;return R(e,`color`,sC),z(e,()=>O()+1,t),e})(),` for this creep?`]},onConfirm:()=>void re(),onCancel:()=>d(!1)})}}),null),z(i,f(v,{get when(){return p()},get children(){return f(LC,{title:`Do you really want to reset all changes?`,onConfirm:()=>{o({}),m(!1)},onCancel:()=>m(!1)})}}),null),z(i,f(v,{get when(){return h()},get children(){return f(LC,{get title(){return`Do you really want to delete "${t().name}"?`},get body(){return[`You will lose `,(()=>{var e=JC();return R(e,`color`,cC),e})(),` in your account. The creep's upgrade levels are returned, but the creation level is gone for good.`]},confirmLabel:`Delete`,onConfirm:()=>void j(),onCancel:()=>g(!1)})}}),null),z(i,f(v,{get when(){return _()},get children(){return f(LC,{title:`You have reached the maximum creep level`,notice:!0,onConfirm:()=>y(!1),onCancel:()=>y(!1)})}}),null),w(e=>{var t=ee()>0?sC:$,n=!k()||s(),r=k()?iC:$,i=k()?`pointer`:`not-allowed`,a=k()?1:.6,o=!k()||s(),c=k()?oC:`#21262d`,l=k()?`#fff`:$,u=k()?`pointer`:`not-allowed`,d=k()?1:.7;return t!==e.e&&R(fe,`color`,e.e=t),n!==e.t&&(me.disabled=e.t=n),r!==e.a&&R(me,`color`,e.a=r),i!==e.o&&R(me,`cursor`,e.o=i),a!==e.i&&R(me,`opacity`,e.i=a),o!==e.n&&(he.disabled=e.n=o),c!==e.s&&R(he,`background`,e.s=c),l!==e.h&&R(he,`color`,e.h=l),u!==e.r&&R(he,`cursor`,e.r=u),d!==e.d&&R(he,`opacity`,e.d=d),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),i})()})}F([`click`,`input`,`keydown`]);var XC=P(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load power creeps — this server may not support them.`),ZC=P(`<div style=width:100%;height:100%;overflow:auto><div style="max-width:960px;margin:0 auto;padding:24px 16px 48px"><div style="display:flex;align-items:center;gap:12px;padding:0 0 14px;margin-bottom:24px"><button title="Back to Overview"style="display:flex;align-items:center;gap:4px;padding:7px 12px;border-radius:4px;background:#21262d;cursor:pointer"> Overview</button><h1 style=margin:0;font-size:22px;font-weight:600>Power Creeps</h1><div style=flex:1></div><div style="border-radius:6px;padding:6px 12px;font-size:13px">Global Power Level <strong style=margin-left:4px></strong><span style="margin:0 6px">·</span><strong></strong> free`);function QC(){let[e,t]=a([]),[n,r]=a(!0),[o,s]=a(null),c=async()=>{let e=H();if(e)try{t((await e.http.game.powerCreeps.list()).list??[]),s(null)}catch(e){s(e instanceof Error?e.message:String(e))}finally{r(!1)}};i(()=>{c(),H()?.stores.user.refreshMe().catch(()=>{})});let l=()=>Vb(U()?.power??0),u=()=>KS(U()?.power,e()),p={creeps:e,free:u,gpl:l,reload:c};return(()=>{var e=ZC(),t=e.firstChild,r=t.firstChild,i=r.firstChild,a=i.firstChild,s=i.nextSibling,c=s.nextSibling.nextSibling,m=c.firstChild.nextSibling,h=m.nextSibling,g=h.nextSibling;return R(e,`background`,tC),R(e,`color`,iC),R(r,`border-bottom`,`1px solid ${Q}`),Te(i,`click`,Jy,!0),R(i,`border`,`1px solid ${Q}`),R(i,`color`,iC),z(i,f(kr,{size:16}),a),R(s,`color`,iC),R(c,`background`,nC),R(c,`border`,`1px solid ${Q}`),R(c,`color`,$),R(m,`color`,sC),z(m,l),R(h,`color`,Q),z(g,()=>Math.max(0,u())),z(t,f(v,{get when(){return o()},get children(){var e=XC();return R(e,`background`,nC),R(e,`border`,`1px solid ${Q}`),R(e,`color`,$),e}}),null),z(t,f(v,{get when(){return!o()},get children(){return f(_,{get children(){return[f(d,{get when(){return Hy()===`new`},get children(){return f(NC,{ctx:p})}}),f(d,{get when(){return Hy()===`detail`},get children(){return f(YC,{ctx:p,get id(){return Wy()}})}}),f(d,{get when(){return Hy()===`list`},get children(){return f(xC,{ctx:p,get loading(){return n()}})}})]}})}}),null),w(e=>R(g,`color`,u()>0?sC:$)),e})()}F([`click`]);var $C=P(`<div style=width:100%;height:100%>`),{log:ew}=rn(`app`);function tw(){let e=new URLSearchParams(window.location.search).get(`guest`);return e===null?null:e.startsWith(`http`)?e:pn(an.url)??`https://screeps.com`}function nw(){if(Qt()||tw()!==null)return!0;let e=Zt()?$t():pn(an.url),t=pn(an.token);return!!(e&&t)}function rw(){let e=()=>yn()===`connected`&&H()!==null,[t,n]=a(nw());return i(async()=>{try{if(yn()===`idle`&&(await nr().catch(()=>{}),yn()!==`connected`)){if(Qt()){let e=$t();ew(`xxscreeps mode — auto-connecting as guest to ${e}`),await tr({url:e,auth:`guest`,storage:null}).catch(()=>{})}else if(!Zt()){let e=tw();e&&(ew(`?guest param — auto-connecting as guest to ${e}`),await tr({url:e,auth:`guest`,storage:null}).catch(()=>{}))}}}finally{n(!1)}}),(()=>{var n=$C();return z(n,(()=>{var n=N(()=>!!e());return()=>n()?N(()=>My()===`overview`)()?f(ex,{}):N(()=>My()===`profile`)()?f(ax,{}):N(()=>My()===`market`)()?f(jS,{}):N(()=>My()===`power`)()?f(QC,{}):f(Sb,{}):N(()=>!!t())()?f(La,{}):f(Fa,{})})()),n})()}var iw=document.getElementById(`root`);if(!iw)throw Error(`Root element not found`);xe(()=>f(rw,{}),iw);export{Oe as S,B as _,If as a,R as b,Nf as c,hd as d,H as f,rn as g,Pn as h,Pf as i,pd as l,U as m,Pg as n,Lf as o,Fn as p,zf as r,Mf as s,S_ as t,Dd as u,F as v,P as x,z as y};