screeps-client 0.9.0 → 0.11.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-y0GapZz1.js → CodePanel-Bd6QSYMn.js} +1 -1
  2. package/dist/{standalone/_client/MapViewer-CLPXCgLE.js → embedded/_client/MapViewer-Dfluj-CU.js} +1 -1
  3. package/dist/embedded/_client/index-RyMzFHC0.js +19 -0
  4. package/dist/{xxscreeps-mod/_client/vendor-codemirror-B_kaIH0M.js → embedded/_client/vendor-codemirror-_J5SxhJL.js} +1 -1
  5. package/dist/embedded/_client/{vendor-pixi-Df5Nob1b.js → vendor-pixi-D8ed7Ewt.js} +1 -1
  6. package/dist/embedded/index.html +3 -3
  7. package/dist/standalone/_client/{CodePanel-xr0YpZbf.js → CodePanel-DbJqelUg.js} +1 -1
  8. package/dist/{embedded/_client/MapViewer-BWm4-U-8.js → standalone/_client/MapViewer-prnyDfOQ.js} +1 -1
  9. package/dist/standalone/_client/index-yH_pBmNP.js +19 -0
  10. package/dist/standalone/_client/{vendor-codemirror-B_kaIH0M.js → vendor-codemirror-_J5SxhJL.js} +1 -1
  11. package/dist/standalone/_client/{vendor-pixi-NbxvK8iu.js → vendor-pixi-DSR77-W8.js} +1 -1
  12. package/dist/standalone/index.html +3 -3
  13. package/dist/xxscreeps-mod/_client/{CodePanel-Bu4s43Y2.js → CodePanel-DtNhdpy3.js} +1 -1
  14. package/dist/xxscreeps-mod/_client/{MapViewer-F52NQQmA.js → MapViewer-C2ReOrlB.js} +1 -1
  15. package/dist/xxscreeps-mod/_client/index-D--0q0A1.js +19 -0
  16. package/dist/{embedded/_client/vendor-codemirror-B_kaIH0M.js → xxscreeps-mod/_client/vendor-codemirror-_J5SxhJL.js} +1 -1
  17. package/dist/xxscreeps-mod/_client/{vendor-pixi-DCKL8Yf2.js → vendor-pixi-DpCtDB71.js} +1 -1
  18. package/dist/xxscreeps-mod/index.html +3 -3
  19. package/package.json +1 -1
  20. package/dist/embedded/_client/index-CIL3shc9.js +0 -19
  21. package/dist/standalone/_client/index-V8ZxVMK9.js +0 -19
  22. package/dist/xxscreeps-mod/_client/index-BbGdwuON.js +0 -19
@@ -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-Bd6QSYMn.js","_client/vendor-codemirror-_J5SxhJL.js","_client/MapViewer-Dfluj-CU.js"])))=>i.map(i=>d[i]);
2
+ import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,b as s,c,d as l,f as u,g as d,h as f,k as p,l as m,m as h,p as g,s as _,u as v,v as y,w as b,x,y as S}from"./vendor-codemirror-_J5SxhJL.js";import{n as C,t as w}from"./decompress-DIM550rx.js";import{_ as T,a as E,c as D,d as O,f as k,g as ee,h as te,i as ne,l as A,m as j,n as re,o as ie,p as M,r as ae,s as oe,t as se,u as ce}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 le=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(`.`)]),ue=new Set([`innerHTML`,`textContent`,`innerText`,`children`]),de=Object.assign(Object.create(null),{className:`class`,htmlFor:`for`}),fe=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 pe(e,t){let n=fe[e];return typeof n==`object`?n[t]?n.$:void 0:n}var me=new Set([`beforeinput`,`click`,`dblclick`,`contextmenu`,`focusin`,`focusout`,`input`,`keydown`,`keyup`,`mousedown`,`mousemove`,`mouseout`,`mouseover`,`mouseup`,`pointerdown`,`pointermove`,`pointerout`,`pointerover`,`pointerup`,`touchend`,`touchmove`,`touchstart`]),he=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(`.`)),ge={xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`},N=e=>d(()=>e());function _e(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 ve=`_$DX_DELEGATE`;function ye(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 S(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(ke())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?()=>p(()=>document.importNode(i||=a(),!0)):()=>(i||=a()).cloneNode(!0);return o.cloneNode=o,o}function F(e,t=window.document){let n=t[ve]||(t[ve]=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,Ne))}}function I(e,t,n){ke(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function be(e,t,n,r){ke(e)||(r==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r))}function xe(e,t,n){ke(e)||(n?e.setAttribute(t,``):e.removeAttribute(t))}function Se(e,t){ke(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function Ce(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 we(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]||(je(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||(je(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 Te(e,t={},n,r){let i={};return r||o(()=>i.children=Pe(e,t.children,i.children)),o(()=>typeof t.ref==`function`&&Ee(t.ref,e)),o(()=>De(e,t,n,!0,i,!0)),i}function Ee(e,t,n){return p(()=>e(t,n))}function z(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return Pe(e,t,r,n);o(r=>Pe(e,t(),r,n),r)}function De(e,t,n,r,i={},a=!1){t||={};for(let r in i)if(!(r in t)){if(r===`children`)continue;i[r]=Me(e,r,null,i[r],n,a,t)}for(let o in t){if(o===`children`){r||Pe(e,t.children);continue}let s=t[o];i[o]=Me(e,o,s,i[o],n,a,t)}}function Oe(e){let n,r,i=ke();if(!i||!(n=t.registry.get(r=Re()))){if(i)throw t.done=!0,Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${r}\n${e?e().outerHTML:``}`);return e()}return t.completed&&t.completed.add(n),t.registry.delete(r),n}function ke(e){return!!t.context&&!t.done&&(!e||e.isConnected)}function Ae(e){return e.toLowerCase().replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function je(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 Me(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 we(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=me.has(i);if(!a&&r){let t=Array.isArray(r)?r[0]:r;e.removeEventListener(i,t)}(a||n)&&(Ce(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:`)xe(e,t.slice(5),n);else if((d=t.slice(0,5)===`prop:`)||(l=ue.has(t))||!i&&((u=pe(t,e.tagName))||(c=le.has(t)))||(s=e.nodeName.includes(`-`)||`is`in o)){if(d)t=t.slice(5),c=!0;else if(ke(e))return n;t===`class`||t===`className`?Se(e,n):s&&!c&&!l?e[Ae(t)]=n:e[u||t]=n}else{let r=i&&t.indexOf(`:`)>-1&&ge[t.split(`:`)[0]];r?be(e,r,t,n):I(e,de[t]||t,n)}return n}function Ne(e){if(t.registry&&t.events&&t.events.find(([t,n])=>n===e))return;let n=e.target,r=`$$${e.type}`,i=e.target,a=e.currentTarget,o=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),s=()=>{let t=n[r];if(t&&!n.disabled){let i=n[`${r}Data`];if(i===void 0?t.call(n,e):t.call(n,i,e),e.cancelBubble)return}return n.host&&typeof n.host!=`string`&&!n.host._$host&&n.contains(e.target)&&o(n.host),!0},c=()=>{for(;s()&&(n=n._$host||n.parentNode||n.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return n||document}}),t.registry&&!t.done&&(t.done=_$HY.done=!0),e.composedPath){let t=e.composedPath();o(t[0]);for(let e=0;e<t.length-2&&(n=t[e],s());e++){if(n._$host){n=n._$host,c();break}if(n.parentNode===a)break}}else c();o(i)}function Pe(e,t,n,r,i){let a=ke(e);if(a){!n&&(n=[...e.childNodes]);let t=[];for(let e=0;e<n.length;e++){let r=n[e];r.nodeType===8&&r.data.slice(0,2)===`!$`?r.remove():t.push(r)}n=t}for(;typeof n==`function`;)n=n();if(t===n)return n;let s=typeof t,c=r!==void 0;if(e=c&&n[0]&&n[0].parentNode||e,s===`string`||s===`number`){if(a||s===`number`&&(t=t.toString(),t===n))return n;if(c){let i=n[0];i&&i.nodeType===3?i.data!==t&&(i.data=t):i=document.createTextNode(t),n=Le(e,n,r,i)}else n=n!==``&&typeof n==`string`?e.firstChild.data=t:e.textContent=t}else if(t==null||s===`boolean`){if(a)return n;n=Le(e,n,r)}else if(s===`function`)return o(()=>{let i=t();for(;typeof i==`function`;)i=i();n=Pe(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let s=[],l=n&&Array.isArray(n);if(Fe(s,t,n,i))return o(()=>n=Pe(e,s,n,r,!0)),()=>n;if(a){if(!s.length)return n;if(r===void 0)return n=[...e.childNodes];let t=s[0];if(t.parentNode!==e)return n;let i=[t];for(;(t=t.nextSibling)!==r;)i.push(t);return n=i}if(s.length===0){if(n=Le(e,n,r),c)return n}else l?n.length===0?Ie(e,s,r):_e(e,n,s):(n&&Le(e),Ie(e,s));n=s}else if(t.nodeType){if(a&&t.parentNode)return n=c?[t]:t;if(Array.isArray(n)){if(c)return n=Le(e,n,r,t);Le(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 Fe(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=Fe(e,o,s)||i;else if(c===`function`)if(r){for(;typeof o==`function`;)o=o();i=Fe(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 Ie(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function Le(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 Re(){return t.getNextContextId()}var ze=`http://www.w3.org/2000/svg`;function Be(e,t=!1,n=void 0){return t?document.createElementNS(ze,e):document.createElement(e,{is:n})}function Ve(e,n){let r=d(e);return d(()=>{let e=r();switch(typeof e){case`function`:return Object.assign(e,{[_]:!0}),p(()=>e(n));case`string`:let r=he.has(e),i=t.context?Oe():Be(e,r,p(()=>n.is));return Te(i,n,r),i}})}function He(e){let[,t]=r(e,[`component`]);return Ve(()=>e.component,t)}var Ue=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 We(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 Ge(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 B(e,t){return t&&(e.shard=t),e}function Ke(e,t){return{roomTerrain:(t,n)=>e.request(`GET`,`/api/game/room-terrain`,B({room:t,encoded:1},n)),roomObjects:(t,n)=>e.request(`GET`,`/api/game/room-objects`,B({room:t},n)),roomDecorations:t?()=>Promise.resolve(t):(t,n)=>e.request(`GET`,`/api/game/room-decorations`,B({room:t},n)),roomStatus:(t,n)=>e.request(`GET`,`/api/game/room-status`,B({room:t},n)),roomOverview:(t,n=8,r)=>e.request(`GET`,`/api/game/room-overview`,B({room:t,interval:n},r)),time:t=>e.request(`GET`,`/api/game/time`,B({},t)),worldSize:t=>e.request(`GET`,`/api/game/world-size`,B({},t)),mapStats:(t,n,r)=>e.request(`POST`,`/api/game/map-stats`,B({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`,B({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`,B({type:t},n)),checkUniqueObjectName:(t,n,r)=>e.request(`POST`,`/api/game/check-unique-object-name`,B({type:t,name:n},r)),placeSpawn:(t,n,r,i,a)=>e.request(`POST`,`/api/game/place-spawn`,B({room:t,x:n,y:r,...i?{name:i}:{}},a)),createConstruction:(t,n,r,i,a,o)=>e.request(`POST`,`/api/game/create-construction`,B({room:t,x:n,y:r,structureType:i,...a?{name:a}:{}},o)),removeConstructionSite:(t,n,r)=>e.request(`POST`,`/api/game/add-object-intent`,B({_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`,B({_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:Ge(e),market:{ordersIndex:t=>e.request(`GET`,`/api/game/market/orders-index`,B({},t)),myOrders:()=>e.request(`GET`,`/api/game/market/my-orders`),orders:(t,n)=>e.request(`GET`,`/api/game/market/orders`,B({resourceType:t},n)),stats:(t,n)=>e.request(`GET`,`/api/game/market/stats`,B({resourceType:t},n))},shards:{info:()=>e.request(`GET`,`/api/game/shards/info`)}}}function qe(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 Je(e,t){return t&&(e.shard=t),e}function Ye(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`,Je({path:t},n)),set:(t,n,r)=>e.request(`POST`,`/api/user/memory`,Je({path:t,value:n},r)),segment:{get:(t,n)=>e.request(`GET`,`/api/user/memory-segment`,Je({segment:t},n)),set:(t,n,r)=>e.request(`POST`,`/api/user/memory-segment`,Je({segment:t,data:n},r))}},console:(t,n)=>e.request(`POST`,`/api/user/console`,Je({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`,Je({},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:qe(e)}}function Xe(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 Ze(e){return{pvp:(t=100)=>e.request(`GET`,`/api/experimental/pvp`,{interval:t}),nukes:()=>e.request(`GET`,`/api/experimental/nukes`)}}function Qe(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 $e=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??Ue.create(),this.serverPassword=e.serverPassword??null,this.auth=We(this),this.register=Qe(this),this.game=Ke(this,e.decorationsMock),this.user=Ye(this),this.leaderboard=Xe(this),this.experimental=Ze(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 w(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 et(e){let t=typeof e==`string`?e:e.data;if(t.startsWith(`gz:`)&&(t=JSON.stringify(await C(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 tt=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??Ue.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 et(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`))}},nt=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()}},rt=class extends EventTarget{logger;constructor(e){super(),this.logger=e??Ue.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)}}}},it=function(e){return e[e.Plain=0]=`Plain`,e[e.Wall=1]=`Wall`,e[e.Swamp=2]=`Swamp`,e}({}),at=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 ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function st(e,t){let n={...e};for(let e in t){let r=t[e];r===null?delete n[e]:ot(r)&&ot(n[e])?n[e]=st(n[e],r):n[e]=r}return n}var ct=class extends rt{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 at(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=at.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 at(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=at.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]=st(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()))}}}},lt=class extends rt{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 T(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()}}}},ut=class extends rt{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`}`)}},dt=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 ft(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 pt=class extends rt{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?ft(o):null};s.listenerSub=this.socket.on(i,n=>{let r=n,i=ft(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)}},mt=class extends rt{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}}},ht=class extends rt{_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]}}},gt=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=Ue.create(e.debug),this.logger.log(`[screeps:client] init ${e.url}`),this.cache=new nt(t,e.storage??null),this.http=new $e({url:e.url,auth:e.auth,logger:this.logger.child(`http`),serverPassword:e.serverPassword,decorationsMock:e.decorationsMock}),this.socket=new tt({url:e.url,WebSocket:e.WebSocket,logger:this.logger.child(`socket`)});let n=new dt({adapter:e.storage??null,namespace:t,maxEntries:e.map2?.maxCacheEntries??1e4});this.stores={room:new ct(this.http,this.socket,this.cache,this.logger.child(`room`)),user:new lt(this.http,this.socket,this.cache,this.logger.child(`user`)),server:new ut(this.http,this.socket,this.cache,this.logger.child(`server`)),map:new pt(this.socket,n,{maxSubscriptions:e.map2?.maxSubscriptions??500},this.logger.child(`map`)),mapStats:new mt(this.http,100,500,this.logger.child(`mapStats`)),navigation:new ht(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()}},_t=class{token;constructor(e){this.token=e.token}async authenticate(e){return this.token}},vt=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}},yt=class{async authenticate(e){return`guest`}},bt=1,xt=`data`,St=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,bt);n.onupgradeneeded=()=>{n.result.createObjectStore(xt)},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(xt,`readonly`).objectStore(xt).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(xt,`readwrite`).objectStore(xt).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(xt,`readwrite`).objectStore(xt).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(xt,`readwrite`).objectStore(xt).clear();r.onsuccess=()=>t(),r.onerror=()=>n(r.error)})}},Ct=class{subs=[];add(e){this.subs.push(e)}dispose(){for(let e of this.subs)e.dispose();this.subs.length=0}},wt=5*6e4;function Tt(e,t){try{return`screeps:${e}:${new URL(t).hostname}`}catch{return`screeps:${e}:${t}`}}function Et(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 Dt(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(e,JSON.stringify({data:t,expires:Date.now()+wt}))}catch{}}function Ot(e){return e.endsWith(`/`)?e:`${e}/`}async function kt(e){let t=Tt(`version`,e),n=Et(t);if(n)return n;let r=await fetch(`${Ot(e)}api/version`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();return Dt(t,i),i}async function At(e){let t=Tt(`authmod`,e),n=Et(t);if(n)return n;let r=await fetch(`${Ot(e)}api/authmod`);if(!r.ok)return null;let i=await r.json();return i.ok?(Dt(t,i),i):null}async function jt(e,t){let n=new URLSearchParams({username:t}),r=await fetch(`${Ot(e)}api/register/check-username?${n}`);if(!r.ok)throw Error(`HTTP ${r.status}`);return r.json()}async function Mt(e,t){let n=new URLSearchParams({email:t}),r=await fetch(`${Ot(e)}api/register/check-email?${n}`);if(!r.ok)throw Error(`HTTP ${r.status}`);return r.json()}async function Nt(e,t,n,r){let i=await fetch(`${Ot(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 Pt(e,t){return e.serverData.features.find(e=>e.name===t)}function Ft(e){return Pt(e,`screepsmod-auth`)}var It={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`}}}]},Lt={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 Rt(e){let t=Math.round(e).toString(16);return t.length<2?`0`+t:t}function zt(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`#`+Rt(u)+Rt(d)+Rt(f)}function Bt(){let e=[],t=0;e.push({index:t++,rgb:zt(0,0,.8)});for(let n=0;n<19;n++)e.push({index:t++,rgb:zt(n*360/19,.6,.8)});e.push({index:t++,rgb:zt(0,0,.5)});for(let n=0;n<19;n++)e.push({index:t++,rgb:zt(n*360/19,.7,.5)});e.push({index:t++,rgb:zt(0,0,.3)});for(let n=0;n<19;n++)e.push({index:t++,rgb:zt(n*360/19,.4,.3)});e.push({index:t++,rgb:zt(0,0,.1)});for(let n=0;n<19;n++)e.push({index:t++,rgb:zt(n*360/19,.5,.1)});return e}var Vt=Bt();function Ht(e){if(typeof e==`string`)return e;if(typeof e==`number`){let t=Vt[e];return t?t.rgb:`#000000`}return`#000000`}function Ut(e){let t=Ht(e.color1),n=Ht(e.color2),r=Ht(e.color3),i=e.param??0;if(typeof e.type==`number`){let t=Lt[e.type];t&&t.calc(i)}let a=0;if(e.flip&&typeof e.type==`number`){let t=Lt[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=Lt[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[Wt,Gt]=s([]),Kt=0;function V(e,t=`success`,n=4e3){let r=Kt++;Gt(i=>[...i,{id:r,message:e,type:t,duration:n}]),setTimeout(()=>{Gt(e=>e.filter(e=>e.id!==r))},n)}var qt=!1;function Jt(){return!0}function Yt(){return qt}function Xt(){return window.location.origin}function Zt(){return`0.11.0`}function Qt(){return typeof window>`u`?null:window.__SCREEPS_CLIENT_EMBEDDED__??null}function $t(){let e=`/client/`;return e.startsWith(`.`)?``:e.replace(/\/$/,``)}function en(e){let t=`[${e}]`;return{log:()=>{},warn:()=>{},error:(...e)=>console.error(t,...e)}}var H={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`},U={url:`screeps:url`,token:`screeps:token`,serverPassword:`screeps:serverPassword`,authMethod:`screeps:authMethod`};function tn(e){return localStorage.getItem(e)}function nn(e,t){localStorage.setItem(e,t)}function rn(e){localStorage.removeItem(e)}function an(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 on(e,t){localStorage.setItem(e,String(t))}function sn(e,t){let n=localStorage.getItem(e);if(n===null)return t;try{return JSON.parse(n)}catch{return t}}function cn(e,t){localStorage.setItem(e,JSON.stringify(t))}function ln(e){return sessionStorage.getItem(e)}function un(e,t){sessionStorage.setItem(e,t)}function dn(e){sessionStorage.removeItem(e)}async function fn(){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:pn}=en(`client`),[W,mn]=s(null),[hn,gn]=s(`idle`),[_n,vn]=s(null),[G,yn]=s(null),[bn,xn]=s(null),[K,Sn]=s(null),[Cn,wn]=s(null),[Tn,En]=s(!1),[Dn,On]=s(null),[kn,An]=s(null),[jn,Mn]=s({}),[Nn,Pn]=s(null),Fn=1e3,In=15e3,Ln=null,Rn=0;function zn(){Ln===null&&(pn(`world status polling: start`),Ln=setInterval(()=>{let e=W();e&&e.stores.user.refreshWorldStatus().catch(()=>{})},Fn))}function Bn(){Ln!==null&&(pn(`world status polling: stop`),clearInterval(Ln),Ln=null)}function Vn(e){e===`empty`||e===`lost`||Date.now()<Rn?zn():Bn()}function Hn(){Rn=Date.now()+In,zn()}var Un=-1,Wn=-1,Gn=[],Kn=5;function qn(e){if(e===void 0)return;let t=Date.now();if(Un>=0&&e>Un){let e=t-Wn;if(e>0){Gn.push(e),Gn.length>Kn&&Gn.shift();let t=Gn.reduce((e,t)=>e+t,0)/Gn.length;wn(Math.round(t))}}Un=e,Wn=t}function Jn(){Un=-1,Wn=-1,Gn.length=0,wn(null)}var Yn=()=>{let e=bn();return e?(e.serverData?.shards?.length??0)===0:null};async function Xn(e){Jt()&&(e={...e,url:Xt()}),pn(`connecting to ${e.url} (auth: ${e.auth})`),gn(`connecting`),vn(null);try{let t;if(e.auth===`guest`)t=new yt,En(!0);else if(e.auth===`password`){if(!e.email||!e.password)throw Error(`Email and password are required`);t=new vt({email:e.email,password:e.password})}else{if(!e.token)throw Error(`Token is required`);t=new _t({token:e.token})}let n=new gt({url:e.url,auth:t,storage:e.storage??new St(`screeps-client`),debug:!1,serverPassword:e.serverPassword,decorationsMock:It});n.http.on(`http:tokenRefresh`,({token:e})=>{pn(`token refreshed`),un(U.token,e)}),n.http.on(`http:error`,({method:e,path:t,error:n,silent:r})=>{pn(`http error:`,e,t,n.message),r||V(`Request failed: ${e} ${t} — ${n.message}`,`error`,6e3)}),n.stores.server.on(`server:disconnected`,e=>{pn(`server disconnected (willReconnect: ${e.willReconnect})`),e.willReconnect||(gn(`idle`),mn(null),yn(null),xn(null),Rn=0,Vn(null))}),n.stores.server.on(`server:error`,e=>{pn(`server error:`,e.error.message),vn(e.error.message),gn(`error`)}),n.stores.user.on(`user:me`,e=>{pn(`user: ${e.username} (id: ${e._id})`),yn(e)}),n.stores.server.on(`server:version`,e=>{pn(`server version: ${e.package??`unknown`}`),xn(e)}),n.stores.user.on(`user:stream`,e=>{if(e&&typeof e==`object`&&`flags`in e){let t=e.flags;t&&typeof t==`object`&&Mn(t)}}),n.stores.user.on(`user:worldStatus`,({status:e})=>{pn(`world status: ${e}`),Pn(e),Vn(e)}),await n.connect(),n.stores.user.subscribeUserStream(),mn(n),gn(`connected`),pn(`connected to ${e.url}`),n.stores.server.worldInfo().then(e=>{An(e),pn(`world: ${e.width}x${e.height} x[${e.minX},${e.maxX}] y[${e.minY},${e.maxY}]`)}).catch(()=>{}),un(U.url,e.url);let r=e.authMethod??e.auth;On(r),un(U.authMethod,r),n.http.token&&un(U.token,n.http.token),e.serverPassword?un(U.serverPassword,e.serverPassword):dn(U.serverPassword)}catch(e){let t=e instanceof Error?e.message:String(e);throw pn(`connection failed:`,t),vn(t),gn(`error`),mn(null),e}}async function Zn(){let e=Jt()?Xt():ln(U.url),t=ln(U.token);if(!e||!t)return;let n=ln(U.serverPassword)??void 0,r=ln(U.authMethod);pn(`auto-connect: ${e}`);try{t===`guest`?await Xn({url:e,auth:`guest`,storage:null,serverPassword:n}):await Xn({url:e,auth:`token`,token:t,serverPassword:n,authMethod:r??`token`})}catch{pn(`auto-connect failed — clearing stored token`),dn(U.token)}}function Qn(){pn(`disconnecting`);let e=W();e&&e.disconnect(),mn(null),gn(`idle`),vn(null),yn(null),xn(null),Sn(null),En(!1),On(null),An(null),Mn({}),Pn(null),Rn=0,Vn(null),Jn(),dn(U.token),dn(U.url),dn(U.serverPassword),dn(U.authMethod)}var $n={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`},er=P(`<svg>`),tr=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),nr=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),rr=e=>{let t=nr(e);return t.charAt(0).toUpperCase()+t.slice(1)},ir=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),q=t=>{let[n,i]=r(t,[`color`,`size`,`strokeWidth`,`children`,`class`,`name`,`iconNode`,`absoluteStrokeWidth`]);return(()=>{var t=er();return Te(t,e($n,{get width(){return n.size??$n.width},get height(){return n.size??$n.height},get stroke(){return n.color??$n.stroke},get"stroke-width"(){return N(()=>!!n.absoluteStrokeWidth)()?Number(n.strokeWidth??$n[`stroke-width`])*24/Number(n.size):Number(n.strokeWidth??$n[`stroke-width`])},get class(){return ir(`lucide`,`lucide-icon`,...n.name==null?[]:[`lucide-${tr(rr(n.name))}`,`lucide-${tr(n.name)}`],n.class==null?``:n.class)}},i),!0,!0),z(t,h(l,{get each(){return n.iconNode},children:([t,n])=>h(He,e({component:t},n))})),t})()},ar=[[`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`}]],or=t=>h(q,e(t,{iconNode:ar,name:`bell-off`})),sr=[[`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`}]],cr=t=>h(q,e(t,{iconNode:sr,name:`bell`})),lr=[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]],ur=t=>h(q,e(t,{iconNode:lr,name:`check`})),dr=[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]],fr=t=>h(q,e(t,{iconNode:dr,name:`chevron-down`})),pr=[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]],mr=t=>h(q,e(t,{iconNode:pr,name:`chevron-right`})),hr=[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]],gr=t=>h(q,e(t,{iconNode:hr,name:`chevron-left`})),_r=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]],vr=t=>h(q,e(t,{iconNode:_r,name:`clock`})),yr=[[`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`}]],br=t=>h(q,e(t,{iconNode:yr,name:`code-xml`})),xr=[[`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`}]],Sr=t=>h(q,e(t,{iconNode:xr,name:`eye`})),Cr=[[`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`}]],wr=t=>h(q,e(t,{iconNode:Cr,name:`flag`})),Tr=[[`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`}]],Er=t=>h(q,e(t,{iconNode:Tr,name:`hammer`})),Dr=[[`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`}]],Or=t=>h(q,e(t,{iconNode:Dr,name:`key-round`})),kr=[[`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`}]],Ar=t=>h(q,e(t,{iconNode:kr,name:`layout-dashboard`})),jr=[[`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`}]],Mr=t=>h(q,e(t,{iconNode:jr,name:`layout-grid`})),Nr=[[`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`}]],Pr=t=>h(q,e(t,{iconNode:Nr,name:`loader`})),Fr=[[`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`}]],Ir=t=>h(q,e(t,{iconNode:Fr,name:`log-in`})),Lr=[[`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`}]],Rr=t=>h(q,e(t,{iconNode:Lr,name:`log-out`})),zr=[[`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`}]],Br=t=>h(q,e(t,{iconNode:zr,name:`map`})),Vr=[[`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`}]],Hr=t=>h(q,e(t,{iconNode:Vr,name:`move`})),Ur=[[`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`}]],Wr=t=>h(q,e(t,{iconNode:Ur,name:`pause`})),Gr=[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]],Kr=t=>h(q,e(t,{iconNode:Gr,name:`play`})),qr=[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]],Jr=t=>h(q,e(t,{iconNode:qr,name:`plus`})),Yr=[[`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`}]],Xr=t=>h(q,e(t,{iconNode:Yr,name:`refresh-cw`})),Zr=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]],Qr=t=>h(q,e(t,{iconNode:Zr,name:`rotate-ccw`})),$r=[[`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`}]],ei=t=>h(q,e(t,{iconNode:$r,name:`settings`})),ti=[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]],ni=t=>h(q,e(t,{iconNode:ti,name:`terminal`})),ri=[[`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`}]],ii=t=>h(q,e(t,{iconNode:ri,name:`trash-2`})),ai=[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]],oi=t=>h(q,e(t,{iconNode:ai,name:`x`})),si=P(`<span style=font-size:11px;display:inline-flex;align-items:center;gap:3px>`),ci=P(`<div style="color:#3fb950;font-size:14px;text-align:center;padding:8px 0">Account created! Logging you in…`),li=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>`),ui=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>`),di=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>`),fi=P(`<span style=font-size:11px;color:#f85149>Passwords don't match`),pi=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>`),mi=P(`<button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),hi=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`),gi=P(`<form style=display:flex;flex-direction:column;gap:16px><h2 style=margin:0;font-size:20px>Create Account`),_i=P(`<div style=color:#f85149;font-size:13px>`),vi=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">`),yi=P(`<button type=button style=background:none;border:none;color:#58a6ff;font-size:12px;cursor:pointer;padding:0>Create account`),bi=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`),xi=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>`),Si=P(`<div style=color:#8b949e;font-size:12px;margin-top:-8px>`),Ci=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>`),wi=P(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#1b2838;color:#c7d5e0;font-weight:600>Login with Steam`),Ti=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)`),Ei=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>`),Di=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>`),Oi=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">`),ki=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>`),Ai=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>`),ji=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>`),Mi=P(`<span style="font-size:11px;padding:2px 8px;border-radius:12px;background:#21262d;border:1px solid #30363d;color:#8b949e;font-family:monospace">`),Ni={padding:`8px 12px`,"border-radius":`6px`,border:`1px solid #30363d`,background:`#0d1117`,color:`#c9d1d9`};function Pi(e){let[t,n]=s(null),[r,i]=s(null),[o,c]=s(null);return f(()=>{let t=e();n(null),i(null),c(null);let r=!1,o=setTimeout(async()=>{try{let e=await kt(t);if(r)return;if(n(e),c(null),Ft(e)){let e=await At(t);r||i(e)}}catch{r||(c(`Could not reach server`),n(null))}},400);a(()=>{r=!0,clearTimeout(o)})}),{serverVersion:t,authModInfo:r,serverError:o}}function Fi(e,t,n){let[r,i]=s(`idle`);return f(()=>{let r=t();if(!r){i(`idle`);return}i(`checking`);let o=!1,s=setTimeout(async()=>{try{let t=await n(e(),r);o||i(t.error?`taken`:`available`)}catch{o||i(`error`)}},500);a(()=>{o=!0,clearTimeout(s)})}),r}function Ii(e){let t={idle:null,checking:{children:`Checking…`,color:`#8b949e`},available:{children:[h(ur,{size:12}),` Available`],color:`#3fb950`},taken:{children:[h(oi,{size:12}),` Already taken`],color:`#f85149`},error:{children:`Could not verify`,color:`#d29922`}},n=()=>t[e.state];return h(u,{get when(){return n()},get children(){var e=si();return z(e,()=>n().children),o(t=>R(e,`color`,n().color)),e}})}function Li(e){let[t,n]=s(``),[r,i]=s(``),[a,c]=s(``),[l,d]=s(``),[f,p]=s(!1),[m,g]=s(null),[_,v]=s(!1),y=Fi(()=>e.url,t,jt),b=Fi(()=>e.url,r,Mt),x=()=>l()!==``&&a()!==l(),S=()=>!f()&&t()!==``&&r()!==``&&a().length>=4&&a()===l()&&y()!==`taken`&&y()!==`checking`&&b()!==`taken`&&b()!==`checking`,C=async n=>{if(n.preventDefault(),S()){p(!0),g(null);try{let n=await Nt(e.url,t(),r(),a());if(n.error){g(n.error);return}v(!0),setTimeout(()=>e.onSuccess(r(),a()),1500)}catch(e){g(e instanceof Error?e.message:`Registration failed`)}finally{p(!1)}}};return(()=>{var s=gi();return s.firstChild,s.addEventListener(`submit`,C),z(s,h(u,{get when(){return _()},get children(){return ci()}}),null),z(s,h(u,{get when(){return!_()},get children(){return[(()=>{var e=li(),r=e.firstChild;r.firstChild;var i=r.nextSibling;return z(r,h(Ii,{get state(){return y()}}),null),i.$$input=e=>n(e.currentTarget.value),o(e=>{var t=Ni,n=f();return e.e=L(i,t,e.e),n!==e.t&&(i.disabled=e.t=n),e},{e:void 0,t:void 0}),o(()=>i.value=t()),e})(),(()=>{var e=ui(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return z(t,h(Ii,{get state(){return b()}}),null),n.$$input=e=>i(e.currentTarget.value),o(e=>{var t=Ni,r=f();return e.e=L(n,t,e.e),r!==e.t&&(n.disabled=e.t=r),e},{e:void 0,t:void 0}),o(()=>n.value=r()),e})(),(()=>{var e=di(),t=e.firstChild.nextSibling;return t.$$input=e=>c(e.currentTarget.value),o(e=>{var n=Ni,r=f();return e.e=L(t,n,e.e),r!==e.t&&(t.disabled=e.t=r),e},{e:void 0,t:void 0}),o(()=>t.value=a()),e})(),(()=>{var e=pi(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return z(t,h(u,{get when(){return x()},get children(){return fi()}}),null),n.$$input=e=>d(e.currentTarget.value),o(e=>{var t={...Ni,border:x()?`1px solid #f85149`:`1px solid #30363d`},r=f();return e.e=L(n,t,e.e),r!==e.t&&(n.disabled=e.t=r),e},{e:void 0,t:void 0}),o(()=>n.value=l()),e})(),N(()=>N(()=>!!m())()&&(()=>{var e=_i();return z(e,m),e})()),(()=>{var e=mi();return z(e,()=>f()?`Creating account…`:`Create Account`),o(t=>{var n=!S(),r=S()?`pointer`:`not-allowed`,i=S()?1:.5;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&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=hi();return t.$$click=()=>e.onCancel(),t})()]}}),null),s})()}function Ri(){let e=Jt(),t=Yt(),[n,r]=s(`login`),[i,c]=s(`password`),[d,f]=s(e?Xt():window.location.origin),[p,m]=s(``),[g,_]=s(``),[v,y]=s(``),[b,x]=s(``),{serverVersion:S,authModInfo:C,serverError:w}=Pi(d),T=()=>S()?.serverData?.welcomeText??null,E=()=>(S()?.serverData?.features??[]).filter(e=>e.name!==`auth`&&e.version!=null),D=()=>{let e=S();return e?Ft(e)?.authTypes?.includes(`steam`)??!0:!0},O=()=>C()?.allowRegistration===!0||(S()?.serverData?.features??[]).some(e=>e.name===`official-like`),k=()=>{let e=d().replace(/\/$/,``),t=window.open(`${e}/api/auth/steam`,`screeps-steam-auth`,`width=800,height=600,left=200,top=100`),n=t=>{try{let n=JSON.parse(t.data);n.token&&(i(),Xn({url:e,auth:`token`,authMethod:`steam`,token:n.token,serverPassword:b()||void 0,storage:null}))}catch{}},r=setInterval(()=>{t?.closed&&i()},500),i=()=>{clearInterval(r),window.removeEventListener(`message`,n)};window.addEventListener(`message`,n),a(i)},ee=async e=>{e.preventDefault(),await Xn({url:d(),auth:i(),email:p()||void 0,password:g()||void 0,token:v()||void 0,serverPassword:b()||void 0,storage:null})},te=async e=>{e.preventDefault(),await Xn({url:d(),auth:`guest`,serverPassword:b()||void 0,storage:null})},ne=async(e,t)=>{try{await Xn({url:d(),auth:`password`,email:e,password:t,serverPassword:b()||void 0,storage:null})}catch{r(`login`),c(`password`),m(e),_(t)}},A=()=>hn()===`connecting`;return(()=>{var a=Oi(),s=a.firstChild;return z(a,h(u,{get when(){return T()},get children(){var e=vi();return o(()=>e.innerHTML=T()),e}}),s),z(s,h(u,{get when(){return n()===`register`},get children(){return h(Li,{get url(){return d()},get serverPassword(){return b()},onSuccess:ne,onCancel:()=>r(`login`)})}}),null),z(s,h(u,{get when(){return n()===`login`},get children(){var n=Ei(),a=n.firstChild;a.firstChild;var s=a.nextSibling,l=s.firstChild;l.firstChild.nextSibling;var S=l.nextSibling,C=s.nextSibling;return n.addEventListener(`submit`,ee),z(a,h(u,{get when(){return O()},get children(){var e=yi();return e.$$click=()=>r(`register`),e}}),null),z(n,h(u,{when:!e,get children(){var e=bi(),t=e.firstChild,n=t.nextSibling;return t.$$click=()=>c(`password`),n.$$click=()=>c(`token`),o(e=>{var r=i()===`password`?`#238636`:`transparent`,a=i()===`token`?`#238636`:`transparent`;return r!==e.e&&R(t,`background`,e.e=r),a!==e.t&&R(n,`background`,e.t=a),e},{e:void 0,t:void 0}),e}}),s),z(n,h(u,{when:!e,get children(){return[(()=>{var e=xi(),t=e.firstChild.nextSibling;return t.$$input=e=>f(e.currentTarget.value),o(e=>L(t,Ni,e)),o(()=>t.value=d()),e})(),h(u,{get when(){return w()},get children(){var e=Si();return z(e,w),e}})]}}),s),z(n,(()=>{var e=N(()=>i()===`password`);return()=>e()?[(()=>{var e=ki(),t=e.firstChild.nextSibling;return t.$$input=e=>m(e.currentTarget.value),o(e=>L(t,Ni,e)),o(()=>t.value=p()),e})(),(()=>{var e=Ai(),t=e.firstChild.nextSibling;return t.$$input=e=>_(e.currentTarget.value),o(e=>L(t,Ni,e)),o(()=>t.value=g()),e})()]:(()=>{var e=ji(),t=e.firstChild.nextSibling;return t.$$input=e=>y(e.currentTarget.value),o(e=>L(t,Ni,e)),o(()=>t.value=v()),e})()})(),s),S.$$input=e=>x(e.currentTarget.value),z(n,(()=>{var e=N(()=>!!_n());return()=>e()&&(()=>{var e=_i();return z(e,_n),e})()})(),C),z(C,()=>A()?`Connecting…`:`Connect`),z(n,h(u,{get when(){return D()},get children(){return[(()=>{var e=Ci();return e.firstChild.nextSibling.nextSibling,e})(),(()=>{var e=wi();return e.$$click=k,o(t=>{var n=A(),r=A()?`not-allowed`:`pointer`,i=A()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&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,h(u,{when:!e||t,get children(){var e=Ti();return e.addEventListener(`mouseleave`,e=>{e.currentTarget.style.borderColor=`#30363d`}),e.addEventListener(`mouseenter`,e=>{A()||(e.currentTarget.style.borderColor=`#8b949e`)}),e.$$click=te,o(t=>{var n=A(),r=A()?`not-allowed`:`pointer`,i=A()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&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),o(e=>{var t=Ni,n=A(),r=A()?`not-allowed`:`pointer`,i=A()?.6:1;return e.e=L(S,t,e.e),n!==e.t&&(C.disabled=e.t=n),r!==e.a&&R(C,`cursor`,e.a=r),i!==e.o&&R(C,`opacity`,e.o=i),e},{e:void 0,t:void 0,a:void 0,o:void 0}),o(()=>S.value=b()),n}}),null),z(a,h(u,{get when(){return E().length>0},get children(){var e=Di(),t=e.firstChild.nextSibling;return z(t,h(l,{get each(){return E()},children:e=>(()=>{var t=Mi();return z(t,()=>e.name,null),z(t,(()=>{var t=N(()=>!!e.version);return()=>t()?` ${e.version}`:``})(),null),t})()})),e}}),null),a})()}F([`input`,`click`]);var zi=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 Bi(){return(()=>{var e=zi();return e.firstChild.nextSibling,e})()}var Vi=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`),Hi=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 Ui(){let e=()=>{switch(hn()){case`connected`:return`#238636`;case`connecting`:return`#d29922`;case`error`:return`#f85149`;default:return`#8b949e`}};return(()=>{var t=Hi(),n=t.firstChild.firstChild,r=n.nextSibling;return z(r,(()=>{var e=N(()=>hn()===`connected`);return()=>e()?`Online`:hn()})()),z(t,h(u,{get when(){return Tn()},get children(){return Vi()}}),null),o(t=>R(n,`background-color`,e())),t})()}var Wi=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 E,this.hoverGraphics.eventMode=`none`,this.container.addChild(this.hoverGraphics),this.pendingGraphics=new E,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 E;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()}},Gi=.2,Ki=3,qi=class{displaySprite;renderer;rt;scene;gradientTexture;lights=new Map;dirty=!1;destroyed=!1;constructor(e){this.renderer=e,this.gradientTexture=Ji(),this.rt=se.create({width:600,height:600}),this.scene=new M;let t=new E;t.rect(0,0,600,600),t.fill({color:0,alpha:Gi}),this.scene.addChild(t),this.displaySprite=new k(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 k(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 Ji(){let e=Ki*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 J=48,Yi=128,Xi={terrain:0,objects:10,animations:20,darkOverlay:30,visuals:40,hover:50,nav:60},Zi=new Set([`road`,`constructedWall`,`rampart`]),Qi=class e{app;world;hoverLayer;darkOverlay;lightLayer;lighting;destroyed=!1;canDrag=!1;container;resizeObserver=null;bounceRaf=null;wheelTimeout=null;navOverlay;lastMouseX=0;lastMouseY=0;onHoverTile=null;onClickTile=null;onRightClick=null;constructor(e,t){this.app=e,this.container=t,this.world=new M({sortableChildren:!0}),this.app.stage.addChild(this.world),this.lighting=new qi(this.app.renderer),this.darkOverlay=this.lighting.displaySprite,this.darkOverlay.label=`darkOverlay`,this.darkOverlay.zIndex=Xi.darkOverlay,this.world.addChild(this.darkOverlay),this.lightLayer=new M,this.lightLayer.label=`lightLayer`,this.hoverLayer=new Wi(e.ticker),this.hoverLayer.container.zIndex=Xi.hover,this.world.addChild(this.hoverLayer.container),this.navOverlay=new M,this.navOverlay.zIndex=Xi.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 O;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?Yi:0;if(t<=n){let r=n/2-t/2;e?this.world.x=Math.min(r+Yi,Math.max(r-Yi,this.world.x)):this.world.x=r}else{let e=n-t-J-i,r=J+i;this.world.x=Math.min(r,Math.max(e,this.world.x))}if(t<=r){let n=r/2-t/2;e?this.world.y=Math.min(n+Yi,Math.max(n-Yi,this.world.y)):this.world.y=n}else{let e=r-t-J-i,n=J+i;this.world.y=Math.min(n,Math.max(e,this.world.y))}this.canDrag=!0}getTargetPosition(){let e=600*this.world.scale.x,t=this.container.clientWidth,n=this.container.clientHeight,r=null,i=null;if(e<=t)r=t/2-e/2;else{let n=t-e-J,i=J;this.world.x<n?r=n:this.world.x>i&&(r=i)}if(e<=n)i=n/2-e/2;else{let t=n-e-J,r=J;this.world.y<t?i=t:this.world.y>r&&(i=r)}return r===null&&i===null?null:{x:r??this.world.x,y:i??this.world.y}}springBack(){let e=this.getTargetPosition(),t=this.getTargetScale();if(!e&&t===null)return;let n=this.world.x,r=this.world.y,i=this.world.scale.x,a=performance.now(),o=this.container.clientWidth/2,s=this.container.clientHeight/2,c=(o-n)/i,l=(s-r)/i,u=d=>{let f=d-a,p=Math.min(1,f/300),m=1-(1-p)**3;if(t!==null){let e=i+(t-i)*m;this.world.scale.set(e),this.world.x=o-c*e,this.world.y=s-l*e}e&&t===null&&(this.world.x=n+(e.x-n)*m,this.world.y=r+(e.y-r)*m),p<1?this.bounceRaf=requestAnimationFrame(u):(this.bounceRaf=null,this.clampView())};this.cancelBounce(),this.bounceRaf=requestAnimationFrame(u)}cancelBounce(){this.bounceRaf!==null&&(cancelAnimationFrame(this.bounceRaf),this.bounceRaf=null)}cancelWheelTimeout(){this.wheelTimeout!==null&&(clearTimeout(this.wheelTimeout),this.wheelTimeout=null)}getTargetScale(){let e=this.getMinScale();return this.world.scale.x<e?e:this.world.scale.x>5?5:null}setupCamera(){let e=!1,t=new ee(0,0),n=new ee(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 ee(u.clientX,u.clientY),n=new ee(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 ee(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 E;o.x=e,o.y=t,o.hitArea=new te(0,0,n,r),o.fill({color:16777215,alpha:.12}),o.poly(i),o.fill(),o.eventMode=`static`,o.cursor=`pointer`,o.alpha=1,o.on(`pointerover`,()=>{o.clear(),o.fill({color:16777215,alpha:.06}),o.rect(0,0,n,r),o.fill(),o.fill({color:16777215,alpha:.35}),o.poly(i),o.fill()}),o.on(`pointerout`,()=>{o.clear(),o.fill({color:16777215,alpha:.12}),o.poly(i),o.fill()}),o.on(`pointerdown`,a),this.navOverlay.addChild(o)};t(-48,0,J,600,[18,300,J-6,282,J-6,318],e.west),t(600,0,J,600,[J-18,300,6,282,6,318],e.east),t(0,-48,600,J,[300,18,282,J-6,318,J-6],e.north),t(0,600,600,J,[300,J-18,282,6,318,6],e.south);for(let e of this.navOverlay.children){let t=e,n=t.hitArea,r=this.world.x+t.x*this.world.scale.x,i=this.world.y+t.y*this.world.scale.y,a=n.width*this.world.scale.x,o=n.height*this.world.scale.y;this.lastMouseX>=r&&this.lastMouseX<=r+a&&this.lastMouseY>=i&&this.lastMouseY<=i+o&&t.emit(`pointerover`,new Event(`pointerover`))}}clear(){for(let e=this.world.children.length-1;e>=0;e--){let t=this.world.children[e];t!==this.navOverlay&&t!==this.hoverLayer.container&&t!==this.darkOverlay&&this.world.removeChild(t)}this.navOverlay.removeChildren(),this.hoverLayer.clearSelection(),this.hoverLayer.setHoveredTile(null,null),this.clearLighting(),this.world.scale.set(1),this.cancelBounce(),this.cancelWheelTimeout(),this.clampView()}clearLighting(){this.lighting.clear()}updateLighting(e){let t=[];for(let n in e){let r=e[n];r&&(typeof r.type==`string`&&Zi.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}))}},$i=856343,ea=1448738,ta=1843496,na=$i,ra=7039337,ia=3159613,aa={tough:5000268,move:11122630,work:16770413,carry:7829367,attack:16332866,ranged_attack:6127794,heal:6684002,claim:12164347},oa=5809919,sa=7979263,ca=4176208,la=9147550,ua=13801762,da=10711543,fa=16218298,pa=16273737,ma=15763518,ha=2172461,ga=ra,_a=12283502,va=[16777215,16711680,8388736,255,65535,32768,16776960,16753920,10824234,8421504,16777215],ya={creep:ma,spawn:oa,extension:sa,tower:ca,container:la,storage:ua,link:da,rampart:oa,road:ga,constructedWall:ha,extractor:la,lab:fa,terminal:ua,observer:sa,powerSpawn:ma,nuker:pa,factory:la,invaderCore:pa,source:ua,mineral:sa,deposit:ua,controller:oa,powerBank:ma,portal:da},ba=16771195,xa=ba,Sa=sa,Ca=ba,wa=sa,Ta=ba,Ea=ba,Da=pa,Oa=ca,ka=sa,Aa=16777215,ja=9419667,Ma=7245682,Na=12116924,Pa=12283502,Fa=9787480,Ia=14721184,La=ta,Ra=13684944,za=4067858,Ba=14440008,Va=11940394,Y=1579032,Ha=5592405,Ua=11184810,Wa=9419667,Ga=16771195,Ka=16069959,qa={energy:Ga,power:Ka,H:13421772,O:16777215,U:5822457,L:62626,K:10514943,Z:16631694,X:11568379,G:16777215},Ja=5617743,Ya=9099642,Xa=11680314,Za=14049376;function Qa(e){return e}function $a(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 eo(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 to(e,t){let n=ra,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)!==it.Wall&&r(e,0,`up`),t.get(e,49)!==it.Wall&&r(e,49,`down`);for(let e=0;e<50;e++)t.get(0,e)!==it.Wall&&r(0,e,`left`),t.get(49,e)!==it.Wall&&r(49,e,`right`)}function no(e){let t=new E;return t.rect(0,0,600,600),t.fill(e.floorColor),t}function ro(e,t){let n=new E,r={color:t.swampBorderColor,width:12*t.swampBorderWidth,alignment:0,cap:`round`,join:`round`};return eo(n,e,it.Swamp,e=>e.stroke(r)),eo(n,e,it.Swamp,e=>e.fill(t.swampFillColor)),n}function io(e,t){let n=new E,r={color:t.wallBorderColor,width:12*t.wallBorderWidth,alignment:0,cap:`round`,join:`round`};return eo(n,e,it.Wall,e=>e.stroke(r)),eo(n,e,it.Wall,e=>e.fill(t.wallFillColor)),to(n,e),n.rect(0,0,600,600),n.stroke({width:1,color:ia}),n}function ao(e,t){let n=new E;return n.label=`swampGlow`,eo(n,e,it.Swamp,e=>e.fill(t.swampGlowColor)),n.alpha=.45,n.filters=[new oe({strength:5,quality:3})],n}function oo(e,t,n){let r=new E;eo(r,e,it.Wall,e=>e.fill(n.wallNoiseColor)),r.alpha=.5,r.filters=[new ie({noise:.12,seed:1})],r.filterArea=new te(0,0,600,600);let i=t.generateTexture({target:r,frame:r.filterArea});r.filters=null,r.destroy();let a=new k(i);return a.label=`wallNoise`,a}function so(e,t,n){let r=$a(n),i=new M,a=oo(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(no(r)),i.addChild(ro(e,r)),i.addChild(io(e,r)),i.addChild(ao(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;D.load(Qa(e)).then(e=>{if(i.destroyed)return;let n=new ne({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;D.load(Qa(t)).then(t=>{if(i.destroyed)return;let n=new ne({texture:t,width:600,height:600});n.tint=r,n.alpha=a,n.tileScale.set(o);let s=new E;eo(s,e,it.Wall,e=>e.fill(16777215)),i.addChild(s),n.mask=s,i.addChild(n)}).catch(()=>{})}return i}function co(e,t){e.getChildByLabel(`swampGlow`).visible=t,e.getChildByLabel(`wallNoise`).visible=t}function lo(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 uo(e){return parseInt(e.replace(`#`,``),16)}function fo(e,t){if(e==null)return t;let n=Number(e);return isNaN(n)?t:n}function po(e,t,n){let r=n.terrain??{};e.floorBackgroundColor&&(r.floorColor=lo(e.floorBackgroundColor,fo(e.floorBackgroundBrightness,1))),e.swampColor&&(r.swampFillColor=uo(e.swampColor)),e.swampStrokeColor&&(r.swampBorderColor=uo(e.swampStrokeColor)),e.swampStrokeWidth!=null&&(r.swampBorderWidth=fo(e.swampStrokeWidth,50)/250),e.roadsColor&&(n.roadColor=lo(e.roadsColor,fo(e.roadsBrightness,1))),t.floorForegroundUrl&&(r.floorTextureUrl=t.floorForegroundUrl,e.floorForegroundColor&&(r.floorTextureTint=lo(e.floorForegroundColor,fo(e.floorForegroundBrightness,1))),r.floorTextureAlpha=fo(e.floorForegroundAlpha,1),r.floorTextureTileScale=fo(e.tileScale??t.tileScale,1)),n.terrain=r}function mo(e,t,n){let r=n.terrain??{};e.backgroundColor&&(r.wallFillColor=lo(e.backgroundColor,fo(e.backgroundBrightness,1))),e.strokeColor&&(r.wallBorderColor=lo(e.strokeColor,fo(e.strokeBrightness,1))),e.strokeWidth!=null&&(r.wallBorderWidth=fo(e.strokeWidth,10)/250),t.foregroundUrl&&(r.wallTextureUrl=t.foregroundUrl,e.foregroundColor&&(r.wallTextureTint=lo(e.foregroundColor,fo(e.foregroundBrightness,1))),r.wallTextureAlpha=fo(e.foregroundAlpha,1),r.wallTextureTileScale=fo(e.tileScale??t.tileScale,1)),n.terrain=r}function ho(e){let t={};for(let n of e.decorations){let e=n.decoration.type;e===`floorLandscape`?po(n.active,n.decoration,t):e===`wallLandscape`&&mo(n.active,n.decoration,t)}return t}function go(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=n,r.src=e})}var _o=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=Ut(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 go(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()}},vo={1:200,2:45e3,3:135e3,4:405e3,5:1215e3,6:3645e3,7:10935e3},yo={1:2e4,2:1e4,3:2e4,4:4e4,5:8e4,6:12e4,7:15e4,8:2e5},bo=new _o,xo=12*.44,So=12*.28,Co=50,wo=32,To=12/wo,Eo=12/2-12*.44,Do=2,Oo=12*1.2/wo,ko=5,Ao=2.5,jo=2,Mo=2.6,No=2,Po=12,Fo=15790320,Io=1710618,Lo=12*.42,Ro=12*.3,zo=1,Bo={H:2236962,O:2236962},Vo={biomass:8695826,metal:9793372,mist:14314485,silicon:5023717},Ho=.2,Uo=12*.42,Wo=32,Go=9/Wo,Ko=8,qo=1600,Jo=16776428,Yo=4473924,Xo=1.7999999999999998;function Zo(e,t){return t<=0?Ko:Ko*Math.max(0,Math.min(1,e/t))}function Qo(e){let t=e%qo/qo;return .5-.5*Math.cos(t*Math.PI*2)}function $o(e){return cs(Ga,Jo,Qo(e))}function es(e,t,n){e.clear();let r=t<=0,i=Ko/2,a=Ko*.25;if(e.roundRect(6-i,6-i,Ko,Ko,a),e.fill(Y),r)e.roundRect(6-i,6-i,Ko,Ko,a),e.stroke({width:Xo,color:cs(Y,Yo,Qo(n))});else{let r=t/2;e.roundRect(6-r,6-r,t,t,t*.25),e.fill($o(n))}}function ts(e,t){let n=e.__sourceGraphics;n&&(e.__sourceSize=t,es(n,t,performance.now()))}function ns(e){return{energy:typeof e.energy==`number`?e.energy:0,capacity:typeof e.energyCapacity==`number`?e.energyCapacity:3e3}}var rs=12*.3,is=1.44,as=rs-is/2,os=12*.42,ss=1500;function cs(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 ls(e,t){e.clear(),e.circle(12/2,12/2,rs),e.stroke({width:is,color:t,alpha:.95})}var us=12*.975,ds=2.16,fs=Math.PI/3,ps=1;function ms(e,t){e.clear();for(let n=0;n<3;n++){let r=n*(2*Math.PI/3)+fs/2,i=r+2*Math.PI/3-fs;e.arc(0,0,us,r,i),e.stroke({width:ds,color:t,cap:`round`})}}function hs(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 gs=12*.5,_s=1.2000000000000002;function vs(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 ys(e){let t=e.spawning;return!t||typeof t!=`object`?null:`${String(t.name)}:${String(t.needTime)}:${String(t.remainingTime)}:${String(t.spawnTime)}`}function bs(e,t,n){return Math.max(0,Math.min(1,1-(t-n)/e))}function xs(e,t){if(e.clear(),t===null||(e.circle(6,6,gs),e.stroke({width:_s,color:16777215,alpha:.12}),t<=0))return;let n=-Math.PI/2,r=n+Math.min(1,t)*Math.PI*2;e.moveTo(6+gs*Math.cos(n),6+gs*Math.sin(n)),e.arc(6,6,gs,n,r),e.stroke({width:_s,color:Ga,alpha:.95,cap:`round`})}function Ss(e,t,n){return n.flatMap(([n,r])=>[e+n*12,t+r*12])}function Cs(e,t,n,r){n-t<.001||(e.moveTo(xo*Math.cos(t),xo*Math.sin(t)),e.arc(0,0,xo,t,n),e.lineTo(So*Math.cos(n),So*Math.sin(n)),e.arc(0,0,So,n,t,!0),e.closePath(),e.fill(r))}var ws=[[0,-.3],[.22,.05],[.15,.2],[-.15,.2],[-.22,.05]],Ts=12*.073,Es=null;function Ds(){if(Es)return Es;let e=Ss(12/2,12/2,ws),t=new ce({type:`linear`,start:{x:.5,y:0},end:{x:.5,y:1},colorStops:[{offset:0,color:Ba},{offset:1,color:Va}]});return Es=new A().poly(e).fill(t).poly(e).stroke({width:Ts,color:za,alignment:.5,join:`miter`,miterLimit:6}),Es}function Os(e){e.addChild(new E({context:Ds()}))}function ks(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 As(e,t){return t<=0||e<=0?0:So*.8*Math.min(1,e/t)}function js(e,t){let n=e.__creepFillGraphics;n&&(n.clear(),t>0&&(n.circle(0,0,t),n.fill(ba)))}function Ms(e){return ya[e]??13226457}function Ns(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 Ps(e){return e>=200?1.15:e>=100?.85:.7}function Fs(e,t){return t<=0||e<=0?0:Ro*Ps(t)*Math.min(1,e/t)}var Is=12*.25,Ls=12*.3;function Rs(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function zs(e,t){let n=e.__linkFillGraphics;if(!n||(n.clear(),t<=0))return;let r=Is*t,i=Ls*t;n.poly([6,6-i,6+r,6,6,6+i,6-r,6]),n.fill(Ga)}function Bs(e,t,n,r){let i=Ps(n),a=new E;a.circle(6,6,Lo*i),a.fill(Y),a.circle(6,6,Lo*i),a.stroke({width:zo*i,color:r}),a.circle(6,6,Ro*i),a.fill(Ua),e.addChild(a);let o=new E,s=Fs(t,n);s>0&&(o.circle(6,6,s),o.fill(Ga)),e.addChild(o),e.__fillGraphics=o}function Vs(e,t){let n=e.__fillGraphics;n&&(n.clear(),t>0&&(n.circle(6,6,t),n.fill(Ga)))}var Hs=-12*.4,Us=-12*.3,Ws=12*.8,Gs=12*.6,Ks=.4,qs=.3,Js=Math.PI/2,Ys=Math.PI/2;function Xs(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 Zs=12*.45,Qs=12*.6,$s=12*.275,ec=12*.2,tc=.5;function nc(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function rc(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(Ga);return}let i=.5,a=Gs*t;n.rect(Hs+i,Us+Gs-a+i,Ws-i*2,a-i*2),n.fill(Ga)}var ic=0,ac=-12*.1,oc=12,sc=12*1.2,cc=[`energy`,`power`];function lc(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=cc.indexOf(e),r=cc.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:qa[e]??7105644,amount:t})),used:o,capacity:t,dominant:i}}function uc(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(Ga);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 dc(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 fc(e,t){return t<=0||e<=0?0:Qs*Math.min(1,e/t)}function pc(e,t){let n=e.__containerFillG;n&&(n.clear(),uc(n,$s,ec+Qs,Zs,t,e.__containerBands,e.__containerUsed??0,tc))}function mc(e,t){return t<=0||e<=0?0:sc*Math.min(1,e/t)}function hc(e,t){let n=e.__storageFillG;n&&(n.clear(),uc(n,ic,ac+sc,oc,t,e.__storageBands,e.__storageUsed??0))}function gc(e){return qa[e]??7105644}function X(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}var _c=12*.35;function vc(e,t){let n=e.__terminalFillG;if(n&&(n.clear(),t>0)){let r=_c*t;n.rect(6-r,6-r,r*2,r*2),n.fill(e.__terminalFillColor??16771195)}}var yc=12*.025,bc=12*.36,xc=12*.05,Sc=12*.8,Cc=12*.9,wc=12*.25,Tc=2e3,Ec=3e3,Dc=16777215,Oc=12*.55,kc=12*.16,Ac=12*.07,jc=.22,Mc=.5;function Nc(e,t,n){e.circle(t,n,Oc),e.stroke({width:kc,color:Dc,alpha:jc}),e.circle(t,n,Oc),e.stroke({width:Ac,color:Dc,alpha:Mc})}function Pc(e){return typeof e.cooldownTime==`number`?e.cooldownTime:0}function Fc(e){let t=e.store&&typeof e.store==`object`?e.store:{},n=e.storeCapacityResource&&typeof e.storeCapacityResource==`object`?e.storeCapacityResource:{},r=typeof t.energy==`number`?t.energy:0,i=typeof n.energy==`number`?n.energy:Tc,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]:Ec;return{energy:r,energyCap:i,mineralType:a,mineral:o,mineralCap:s}}function Ic(e,t,n){let r=e.__labMineralG;r&&(r.clear(),n>0)&&(r.circle(6,6-yc,bc*n),r.fill(e.__labMineralColor??7105644));let i=e.__labEnergyG;if(i&&(i.clear(),t>0)){let e=.5;i.rect(xc+e,Sc+e,(Cc-e*2)*t,wc-e*2),i.fill(Ga)}}var Lc=3e5,Rc=5e3,zc=-.8,Bc=.2,Vc=.4,Hc=-.34,Uc=.34,Wc=.27,Gc=.45;function Kc(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:Lc,ghodium:typeof t.G==`number`?t.G:0,ghodiumCap:typeof n.G==`number`?n.G:Rc}}function qc(e,t,n){let r=e.__nukerEnergyG;if(r&&(r.clear(),t>0)){let e=Bc-zc,n=Bc-e*t,i=Vc*(n-zc)/e;r.poly([6+i*12,6+n*12,6+Vc*12,6+Bc*12,6-Vc*12,6+Bc*12,6-i*12,6+n*12]),r.fill(Ga)}let i=e.__nukerGhodiumG;if(i&&(i.clear(),n>0)){let e=6+Hc*12,t=6+Wc*12,r=(Uc-Hc)*12,a=(Gc-Wc)*12;i.rect(e,t,r*n,a),i.fill(gc(`G`))}}var Jc=8,Yc=12*.4,Xc=12*.5,Zc=.22,Qc=12*.25,$c=12*.32,el=12*.24,tl=12*.28,nl=12*.38,rl=12*.36,il=5,al=16777215;function ol(){let e=2*Math.PI/Jc,t=[];for(let n=0;n<Jc;n++){let r=-Math.PI/2+n*e,i=r-Zc,a=r+Zc,o=r-e+Zc;for(let e=0;e<=3;e++){let n=o+(i-o)*(e/3);t.push(6+Yc*Math.cos(n),6+Yc*Math.sin(n))}for(let e=0;e<=3;e++){let n=i+(a-i)*(e/3);t.push(6+Xc*Math.cos(n),6+Xc*Math.sin(n))}}return t}var sl=ol();function cl(e){return typeof e.cooldown==`number`&&e.cooldown>0}function ll(e,t){e.clear(),e.poly(sl),e.fill(Y),e.poly(sl),e.stroke({width:12*.06,color:t})}function ul(e,t){e.clear();let n=.14,r=2*Math.PI/il-n;for(let i=0;i<il;i++){let a=-Math.PI/2+i*(2*Math.PI/il)+n/2,o=a+r;e.moveTo(6+Qc*Math.cos(a),6+Qc*Math.sin(a)),e.arc(6,6,$c,a,o),e.arc(6,6,Qc,o,a,!0),e.closePath(),e.fill(i<t?Ua:Ha)}}function dl(e,t){return t<=0||e<=0?0:tl*Math.min(1,e/t)}function fl(e,t){let n=e.__factoryFillG;n&&(n.clear(),uc(n,nl,rl+tl,el,t,e.__factoryBands,e.__factoryUsed??0,.5))}var pl=12*.65,ml=pl,hl=12*.42;function gl(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 _l(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 vl(e,t){let n=e.user;return typeof n!=`string`||!t?!1:n!==t}var yl=`2`;function bl(e,t){let n=typeof e.user==`string`?e.user:void 0;return n?n===yl?!0:t?.[n]?.username===`Invader`:!1}function xl(e,t=!0,n,r,i,a,o,s){let c=new M,l=new E,u=Ms(e.type),d=typeof e.user==`string`?e.user:void 0,f=d!==void 0&&n!==void 0&&d!==n?_a:Wa;switch(e.type){case`creep`:{if(bl(e,a)){Os(c);break}let t=2*Math.PI,r=new M;r.position.set(6,6),r.rotation=-Math.PI/2;let o=vl(e,n);if(o){let e=new E;e.circle(0,0,xo+.75),e.stroke({width:1.5,color:_a}),r.addChild(e)}let s=new E;s.circle(0,0,xo),s.fill($i),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/Co*t,g=d/Co*t,_=f/Co*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 E;h>0&&Cs(w,-h/2,v,aa.work??16770413);let T=v;for(let e of p){let n=(m[e]??0)/Co*t/2;Cs(w,T,T+n,aa[e]??7829367),T+=n}Cs(w,y,b,La),g>0&&Cs(w,b,x,aa.move??11122630),Cs(w,x,S,La);let D=C;for(let e of p){let n=(m[e]??0)/Co*t/2;Cs(w,D-n,D,aa[e]??7829367),D-=n}r.addChild(w);let O=new E;O.circle(0,0,So),O.fill(ea),r.addChild(O);let ee=typeof e.user==`string`?e.user:void 0,te=ee?a?.[ee]?.badge:void 0;if(te&&i){let e=new k;e.anchor.set(.5,.5);let t=So*2;e.width=t,e.height=t,e.rotation=Math.PI/2,r.addChild(e),c.__creepBadgeSprite=e,i.getOrCreate(te).then(t=>{e.destroyed||(e.texture=t)}).catch(()=>{})}else if(o){let e=new E;e.circle(0,0,So*.82),e.fill({color:_a,alpha:.9}),r.addChild(e),c.__creepForeignMark=e}let{used:ne,capacity:A}=ks(e),j=As(ne,A),re=new E;j>0&&(re.circle(0,0,j),re.fill(ba)),r.addChild(re),c.__creepFillGraphics=re,c.__creepUsed=ne,c.__creepCapacity=A;let ie=(xo+So)/2,ae=(xo-So)*.45,oe=new E;oe.moveTo(xo,0),oe.lineTo(ie,-ae),oe.lineTo(ie,ae),oe.closePath(),oe.fill(Ra),r.addChild(oe),c.addChild(r),c.__bodyContainer=r;break}case`extension`:{let{energy:t,capacity:n}=Ns(e);Bs(c,t,n,f),c.__extEnergy=t,c.__extCapacity=n;break}case`spawn`:{l.circle(6,6,12*.65),l.fill(Y),l.circle(6,6,12*.65),l.stroke({width:12*.1,color:13421772}),l.circle(6,6,12*.4),l.fill(Ga),c.sortableChildren=!0;let t=new E;t.zIndex=1;let n=vs(e,0),r=n?bs(n.needTime,n.endTime,0):null;xs(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=ys(e);break}case`powerSpawn`:l.circle(6,6,12*.65),l.fill(Y),l.circle(6,6,12*.65),l.stroke({width:12*.1,color:Ka}),l.circle(6,6,12*.4),l.fill(Ga);break;case`source`:{let{energy:t,capacity:n}=ns(e),r=Zo(t,n),i=new E;es(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?ja:Pa,a=r?Ma:Fa,o=r?Na:Ia,s=typeof e.progress==`number`?e.progress:0,l=typeof e.progressTotal==`number`?e.progressTotal:1,u=new E;c.addChild(u),c.__csBuildGlow=u;let d=new E;hs(d,6,6,as,s,l,i),c.addChild(d),c.__csFillGraphics=d;let f=new E;ls(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 k;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=qa[t]??7979263,n=Bo[t]??16777215,r=new E;r.circle(6,6,Uo),r.fill(e),c.addChild(r);let i=new re({text:t,style:{fontSize:Wo,fill:n,fontWeight:`bold`}});i.anchor.set(.5,.5),i.scale.set(Go),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=Vo[t];for(let e of[`deposit/${t}/shape`,`deposit/${t}/fill`]){let t=e.endsWith(`/fill`),n=new k;n.anchor.set(.5,.5),n.x=6,n.y=6,i!==void 0&&(n.tint=i),t&&(n.alpha=Ho),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 k;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 k;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,_l(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 E,i=[];for(let e=0;e<8;e++){let t=-Math.PI/2+e*Math.PI/4;i.push(6+pl*Math.cos(t),6+pl*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 E;gl(a,6,6,ml,hl,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 E;if(d?(p.circle(6,6,hl),p.fill(Y)):(p.circle(6,6,hl),p.fill(3028031),p.circle(6,6,hl),p.stroke({width:12*.04,color:8027781}),p.circle(6,6,12*.16),p.fill(10133672)),c.addChild(p),d&&i){let e=new k;e.anchor.set(.5,.5),e.width=hl*2,e.height=hl*2,e.position.set(6,6);let t=new E;t.circle(6,6,hl),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(Ga);break;case`road`:break;case`constructedWall`:break;case`rampart`:break;case`tower`:{let{energy:t,capacity:n}=Ns(e),r=o?.tower;if(r&&s){let e=12*r.tileScale,i=new k;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 k;l.anchor.set(.5,.5),a.addChild(l);let u=new E;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},rc(c,nc(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 E;i.circle(6,6,12*.6),i.fill(Y),i.circle(6,6,12*.6),i.stroke({width:12*.05,color:f}),c.addChild(i);let a=new M;a.position.set(6,6);let l=new E;l.rect(Hs,Us,Ws,Gs),l.fill(Y),a.addChild(l);let u=new E;a.addChild(u),c.__towerFillGraphics=u,c.__towerEnergy=t,c.__towerCapacity=n,rc(c,nc(t,n));let d=new E;d.rect(Hs,Us,Ws,Gs),d.stroke({width:1,color:Ha}),a.addChild(d);let p=new E;p.rect(-12*.2,-12*.9,12*.4,12*.5),p.fill(Ua),p.rect(-12*.2,-12*.9,12*.4,12*.5),p.stroke({width:12*.07,color:Y}),a.addChild(p),c.addChild(a),c.__barrelContainer=a;break}case`storage`:{let t=o?.sprites.storage;if(t&&s){let{bands:n,used:r,capacity:i}=lc(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 k;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 E;c.addChild(u),c.__storageFillG=u,c.__storageBands=n,c.__storageUsed=r,c.__storageCapacity=i,hc(c,mc(r,i));break}let{bands:n,used:r,capacity:i}=lc(e),a=Ss(6,6,[[-.6,-.7],[0,-.8],[.6,-.7],[.65,0],[.6,.7],[0,.8],[-.6,.7],[-.65,0],[-.6,-.7]]);l.poly(a),l.fill(Y),l.poly(a),l.stroke({width:12*.05,color:f}),l.rect(6-12*.5,6-12*.6,12,12*1.2),l.fill(Ha),c.addChild(l);let u=new E;c.addChild(u),c.__storageFillG=u,c.__storageBands=n,c.__storageUsed=r,c.__storageCapacity=i,hc(c,mc(r,i));let d=new E;d.rect(6-12*.5,6-12*.6,12,12*1.2),d.stroke({width:12*.1,color:Y}),c.addChild(d);break}case`terminal`:{let t=Ss(6,6,[[0,-.8],[.55,-.55],[.8,0],[.55,.55],[0,.8],[-.55,.55],[-.8,0],[-.55,-.55],[0,-.8]]),n=Ss(6,6,[[0,-.65],[.45,-.45],[.65,0],[.45,.45],[0,.65],[-.45,.45],[-.65,0],[-.45,-.45],[0,-.65]]);l.poly(t),l.fill(Y),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(Ua),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.fill(Ha),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.stroke({width:12*.1,color:Y}),c.addChild(l);let{used:r,capacity:i,dominant:a}=lc(e),o=new E;c.addChild(o);let s=c;s.__terminalFillG=o,s.__terminalDominant=a??void 0,s.__terminalFillColor=a?gc(a):Ga,s.__terminalUsed=r,s.__terminalCapacity=i,vc(s,X(r,i));break}case`link`:{let t=Ss(6,6,[[0,-.5],[.4,0],[0,.5],[-.4,0],[0,-.5]]),n=Ss(6,6,[[0,-.3],[.25,0],[0,.3],[-.25,0],[0,-.3]]);l.poly(t),l.fill(Y),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(Ha),c.addChild(l);let{energy:r,capacity:i}=Ns(e),a=new E;c.addChild(a);let o=c;o.__linkFillGraphics=a,o.__linkEnergy=r,o.__linkCapacity=i,zs(o,Rs(r,i));break}case`lab`:{let t=6-12*.025;l.circle(6,t,12*.55),l.fill(Y),l.circle(6,t,12*.55),l.stroke({width:12*.05,color:f}),l.circle(6,t,12*.4),l.fill(Ha),c.addChild(l);let{energy:n,energyCap:r,mineralType:i,mineral:a,mineralCap:o}=Fc(e),s=new E;c.addChild(s);let u=new E;u.rect(6-12*.45,9.6,12*.9,12*.25),u.fill(Y),u.poly(Ss(6,6,[[-.45,.3],[-.45,.55],[.45,.55],[.45,.3]])),u.stroke({width:12*.05,color:f}),c.addChild(u);let d=new E;c.addChild(d);let p=c;p.__labMineralG=s,p.__labEnergyG=d,p.__labMineralType=i??void 0,p.__labMineralColor=i?gc(i):void 0,p.__labEnergy=n,p.__labEnergyCap=r,p.__labMineral=a,p.__labMineralCap=o,Ic(p,X(n,r),X(a,o));let m=new E;Nc(m,6,t),m.alpha=0,c.addChild(m),p.__labCooldownG=m,p.__labCooldownTime=Pc(e);break}case`container`:{let{bands:t,used:n,capacity:r}=lc(e);l.rect($s,ec,Zs,Qs),l.fill(Y),l.rect($s+tc,ec+tc,Zs-tc*2,Qs-tc*2),l.fill(Ha),c.addChild(l);let i=new E;c.addChild(i),c.__containerFillG=i,c.__containerBands=t,c.__containerUsed=n,c.__containerCapacity=r,pc(c,fc(n,r));let a=new E;a.rect($s,ec,Zs,Qs),a.stroke({width:12*.1,color:Y}),c.addChild(a);break}case`observer`:l.circle(6,6,12*.45),l.fill(Y),l.circle(6,6,12*.45),l.stroke({width:12*.05,color:f}),l.circle(8.7,6,12*.2),l.fill(f);break;case`nuker`:{let t=Ss(6,6,[[0,-1],[-.47,.2],[-.5,.5],[.5,.5],[.47,.2],[0,-1]]),n=Ss(6,6,[[0,-.8],[-.4,.2],[.4,.2],[0,-.8]]);l.poly(t),l.fill(Y),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(Ha),l.poly(n),l.stroke({width:12*.01,color:f}),c.addChild(l);let{energy:r,energyCap:i,ghodium:a,ghodiumCap:o}=Kc(e),s=new E;c.addChild(s);let u=new E;c.addChild(u);let d=c;d.__nukerEnergyG=s,d.__nukerGhodiumG=u,d.__nukerEnergy=r,d.__nukerEnergyCap=i,d.__nukerGhodium=a,d.__nukerGhodiumCap=o,qc(d,X(r,i),X(a,o));break}case`factory`:{let t=typeof e.level==`number`?e.level:0,{bands:n,used:r,capacity:i}=lc(e),a=new E;ll(a,f),c.addChild(a),l.rect(nl,rl,el,tl),l.fill(Ha),c.addChild(l);let o=new E;ul(o,t),c.addChild(o);let s=new E;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=Pc(e),u.__factoryGlowColor=f,fl(u,dl(r,i));break}case`extractor`:{let t=new E;t.position.set(6,6),ms(t,d===void 0?la:f),c.addChild(t);let n=c;n.__extractorRing=t,n.__extractorActive=cl(e);break}case`invaderCore`:l.circle(6,6,12*.45),l.fill(Y),l.circle(6,6,12*.45),l.stroke({width:12*.05,color:f}),l.circle(6,6,12*.35),l.fill(Ha);break;case`flag`:{let n=typeof e.color==`number`?e.color:0,r=typeof e.secondaryColor==`number`?e.secondaryColor:0,i=va[n]??va[0],a=va[r]??va[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 k;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 k;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 re({text:e.name,style:{fontSize:wo,fill:16777215}});n.scale.set(To),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?ja:_a,i=12*.42,a=Math.PI/5,o=new E;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 E;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?ja:_a,i=o?.tombstone;if(i&&s){let e=12*i.tileScale,t=()=>s.getOrLoad(o.atlasUrl),n=new k;n.anchor.set(.5,.5),n.x=6,n.y=6,n.width=e,n.height=e,c.addChild(n);let a=new k;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 E;i.moveTo(t,4.8),i.arc(6,4.8,n,Math.PI,0,!1),i.lineTo(9.719999999999999,10.92),i.lineTo(t,10.92),i.closePath(),i.fill(Y),i.moveTo(t,4.8),i.arc(6,4.8,n,Math.PI,0,!1),i.lineTo(9.719999999999999,10.92),i.lineTo(t,10.92),i.closePath(),i.stroke({width:12*.07,color:r,alpha:.9}),c.addChild(i);let a=12*.18,o=new E;o.moveTo(6-a,6-a*.6),o.lineTo(8.16,7.296),o.moveTo(8.16,6-a*.6),o.lineTo(6-a,7.296),o.stroke({width:12*.09,color:r,cap:`round`}),c.addChild(o)}break}default:l.rect(1,1,10,10),l.fill(u)}if(e.type!==`extension`&&e.type!==`road`&&e.type!==`creep`&&e.type!==`tower`&&e.type!==`controller`&&e.type!==`flag`&&e.type!==`source`&&e.type!==`constructionSite`&&e.type!==`mineral`&&e.type!==`tombstone`&&e.type!==`ruin`&&e.type!==`storage`&&e.type!==`constructedWall`&&e.type!==`rampart`&&e.type!==`container`&&e.type!==`deposit`&&e.type!==`link`&&e.type!==`terminal`&&e.type!==`lab`&&e.type!==`nuker`&&e.type!==`factory`&&c.addChild(l),e.type===`creep`&&typeof e.name==`string`){let r=vl(e,n),i;if(r){let t=typeof e.user==`string`?e.user:void 0;i=bl(e,a)?`Invader`:t?a?.[t]?.username??t:`Hostile`}else i=e.name;let o=new re({text:i,style:{fontSize:wo,fill:r?_a:16777215}});o.scale.set(To),o.anchor.set(.5,1),o.x=6,o.y=Eo-Do,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`?ps:o?.sprites[e.type]?.zIndex??0),c.position.set(e.x*12,e.y*12),c}function Sl(e){e.destroy({children:!0})}function Cl(e){let t=new re({text:e.length>Po?e.slice(0,Po):e,style:{fontSize:wo,fill:Io,fontWeight:`600`}});t.scale.set(Oo),t.anchor.set(.5,.5);let n=t.width,r=t.height,i=n+ko*2,a=r+Ao*2,o=a/2,s=new E;s.roundRect(-i/2,-a/2,i,a,o),s.fill(Fo),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+Mo),s.lineTo(jo,a/2-.1),s.closePath(),s.fill(Fo),s.moveTo(-2,a/2-.1),s.lineTo(0,a/2+Mo),s.lineTo(jo,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+Mo),c}var wl=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=bo;users;activeTheme=null;atlasCache=null;roadColor=ga;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 E,this.wallGraphics.zIndex=-3,this.container.addChild(this.wallGraphics),this.wallMarkGraphics=new E,this.wallMarkGraphics.zIndex=-2,this.container.addChild(this.wallMarkGraphics),this.rampartGraphics=new E,this.rampartGraphics.zIndex=150,this.container.addChild(this.rampartGraphics),this.rampartGlowGraphics=new E,this.rampartGlowGraphics.zIndex=149,this.rampartGlowGraphics.filters=[new oe({strength:3,quality:3})],this.container.addChild(this.rampartGlowGraphics),this.roadGraphics=new E,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/ss),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=Xs(t.rotation,e.__towerAimAngle,qs):(e.__towerAimUntil!==void 0&&(e.__towerIdlePhase=t.rotation-i*Ks,e.__towerAimUntil=void 0,e.__towerAimAngle=void 0),t.rotation=i*Ks+(e.__towerIdlePhase??0))}if(e.__extractorRing){let t=e.__extractorActive===!0;t&&!e.__extractorWasActive&&(e.__extractorPhase=e.__extractorRing.rotation-i*Js),t&&(e.__extractorRing.rotation=i*Js+(e.__extractorPhase??0)),e.__extractorWasActive=t}if(e.__csRingGraphics&&e.__csColorDark!==void 0&&e.__csColorLight!==void 0&&ls(e.__csRingGraphics,cs(e.__csColorDark,e.__csColorLight,a)),e.__factoryGearG){let t=(e.__factoryCooldownEnd??0)>this.currentGameTime;t?ll(e.__factoryGearG,cs(e.__factoryGlowColor??9419667,al,.5*a)):e.__factoryWasOnCd&&ll(e.__factoryGearG,e.__factoryGlowColor??9419667),e.__factoryWasOnCd=t}if(e.__labCooldownG){let t=(e.__labCooldownTime??0)>this.currentGameTime;e.__labCooldownG.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&&es(t,e.__sourceSize??Ko,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,os),i.fill({color:Ga,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=yo[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=cs(16777215,cs(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,Vs,Fs(n,r),Fs(i,a))}startLinkAnimation(e,t,n,r,i,a){this.startFill(e,t,zs,Rs(n,r),Rs(i,a))}startCreepFillAnimation(e,t,n,r,i,a){this.startFill(e,t,js,As(n,r),As(i,a))}startTowerFillAnimation(e,t,n,r,i,a){this.startFill(e,t,rc,nc(n,r),nc(i,a))}startStorageFillAnimation(e,t,n,r,i,a){this.startFill(e,t,hc,mc(n,r),mc(i,a))}startContainerFillAnimation(e,t,n,r,i,a){this.startFill(e,t,pc,fc(n,r),fc(i,a))}startTerminalFillAnimation(e,t,n,r,i,a){this.startFill(e,t,vc,X(n,r),X(i,a))}startFactoryFillAnimation(e,t,n,r,i,a){this.startFill(e,t,fl,dl(n,r),dl(i,a))}startLabFillAnimation(e,t,n,r,i,a,o,s,c,l){this.startFill(e,t,Ic,X(n,r),X(o,s),X(i,a),X(c,l))}startNukerFillAnimation(e,t,n,r,i,a,o,s,c,l){this.startFill(e,t,qc,X(n,r),X(o,s),X(i,a),X(c,l))}startSourceAnimation(e,t,n,r,i,a){this.startFill(e,t,ts,Zo(n,r),Zo(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),Sl(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}=ks(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),Sl(r),this.objects.delete(n);let e=xl(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}=Ns(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}=Ns(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}=Ns(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}=lc(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 dc(r.__storageBands,e)||(r.__storageBands=e,hc(r,mc(i,a)))}if(t.type===`container`){let{bands:e,used:i,capacity:a}=lc(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 dc(r.__containerBands,e)||(r.__containerBands=e,pc(r,fc(i,a)))}if(t.type===`terminal`){let{used:e,capacity:i,dominant:a}=lc(t),o=a??void 0;if(r.__terminalDominant!==o&&(r.__terminalDominant=o,r.__terminalFillColor=o?gc(o):Ga,vc(r,X(e,i))),r.__terminalUsed!==e||r.__terminalCapacity!==i){let t=r.__terminalUsed??0,a=r.__terminalCapacity??i;r.__terminalUsed=e,r.__terminalCapacity=i,this.startTerminalFillAnimation(n,r,t,a,e,i)}}if(t.type===`lab`){let{energy:e,energyCap:i,mineralType:a,mineral:o,mineralCap:s}=Fc(t),c=a??void 0;if(r.__labMineralType!==c&&(r.__labMineralType=c,r.__labMineralColor=a?gc(a):void 0,Ic(r,X(e,i),X(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=Pc(t)}if(t.type===`nuker`){let{energy:e,energyCap:i,ghodium:a,ghodiumCap:o}=Kc(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===`extractor`&&(r.__extractorActive=cl(t)),t.type===`factory`){let{bands:e,used:i,capacity:a}=lc(t),o=typeof t.level==`number`?t.level:0;if(r.__factoryLevel!==o&&r.__factoryRingG&&(r.__factoryLevel=o,ul(r.__factoryRingG,o)),r.__factoryCooldownEnd=Pc(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 dc(r.__factoryBands,e)||(r.__factoryBands=e,fl(r,dl(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),Sl(r),this.objects.delete(n);let e=xl(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}),_l(r,e,i,a)):r.__ctrlSegGraphics&&gl(r.__ctrlSegGraphics,12/2,12/2,ml,hl,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}=ns(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&&hs(r.__csFillGraphics,12/2,12/2,as,e,n,r.__csColor??9419667),r.__csProgress=e,r.__csProgressTotal=n)}}else{let e=xl(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}=ks(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),Sl(i),this.objects.delete(n);let e=xl(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}=Ns(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}=Ns(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}=Ns(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),Sl(i),this.objects.delete(n);let e=xl(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}),_l(i,e,t,a)):i.__ctrlSegGraphics&&gl(i.__ctrlSegGraphics,12/2,12/2,ml,hl,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}=ns(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&&hs(i.__csFillGraphics,12/2,12/2,as,e,t,i.__csColor??9419667),i.__csProgress=e,i.__csProgressTotal=t)}}else{let e=xl(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),Sl(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?ys(n):null;if(r!==t.__spawnSig){t.__spawnSig=r;let e=n&&r?vs(n,this.currentGameTime):null;t.__spawnNeedTime=e?.needTime,t.__spawnEndTime=e?.endTime}let i=t.__spawnNeedTime!==void 0&&t.__spawnEndTime!==void 0?bs(t.__spawnNeedTime,t.__spawnEndTime,this.currentGameTime):null;i!==t.__spawnRatio&&(xs(t.__spawnRing,i),t.__spawnRatio=i)}this.refreshForeignCreepLabels(),this.refreshForeignCreepBadges()}redrawWalls(){this.wallGraphics.clear(),this.wallMarkGraphics.clear();let e=Array.from({length:50},()=>Array(50).fill(!1)),t=[];for(let n of this.rawObjects.values())n.type===`constructedWall`&&typeof n.x==`number`&&typeof n.y==`number`&&n.x>=0&&n.x<50&&n.y>=0&&n.y<50&&(e[n.x][n.y]=!0,t.push({x:n.x,y:n.y}));if(t.length===0)return;let n=t=>{let n=!1;for(let r=0;r<50;r++)for(let i=0;i<50;i++){let a=e[i][r],o=r>0&&e[i][r-1],s=r<49&&e[i][r+1],c=i>0&&e[i-1][r],l=i<49&&e[i+1][r],u=i*12+6,d=r*12+6;a?(n=!0,!o&&!c&&r>0&&i>0?(t.moveTo(u,r*12),t.arc(u,d,6,-Math.PI/2,Math.PI,!0),t.lineTo(u,d),t.closePath()):t.rect(i*12,r*12,6,6)):o&&c&&e[i-1][r-1]&&(n=!0,t.moveTo(u,r*12),t.lineTo(i*12,r*12),t.lineTo(i*12,d),t.arc(u,d,6,Math.PI,-Math.PI/2,!1),t.closePath()),a?!o&&!l&&r>0&&i<49?(t.moveTo(u,r*12),t.arc(u,d,6,-Math.PI/2,0,!1),t.lineTo(u,d),t.closePath()):t.rect(u,r*12,6,6):o&&l&&e[i+1][r-1]&&(n=!0,t.moveTo(u,r*12),t.lineTo(i*12+12,r*12),t.lineTo(i*12+12,d),t.arc(u,d,6,0,-Math.PI/2,!0),t.closePath()),a?!s&&!c&&r<49&&i>0?(t.moveTo(i*12,d),t.arc(u,d,6,Math.PI,Math.PI/2,!0),t.lineTo(u,d),t.closePath()):t.rect(i*12,d,6,6):s&&c&&e[i-1][r+1]&&(n=!0,t.moveTo(i*12,d),t.lineTo(i*12,r*12+12),t.lineTo(u,r*12+12),t.arc(u,d,6,Math.PI/2,Math.PI,!1),t.closePath()),a?!s&&!l&&r<49&&i<49?(t.moveTo(u,r*12+12),t.arc(u,d,6,Math.PI/2,0,!0),t.lineTo(u,d),t.closePath()):t.rect(u,d,6,6):s&&l&&e[i+1][r+1]&&(n=!0,t.moveTo(u,r*12+12),t.lineTo(i*12+12,r*12+12),t.lineTo(i*12+12,d),t.arc(u,d,6,0,Math.PI/2,!1),t.closePath())}return n};n(this.wallGraphics)&&this.wallGraphics.stroke({color:0,width:12*.06,alignment:0,cap:`round`,join:`round`}),n(this.wallGraphics),this.wallGraphics.fill(Y);let r=12*.32,i=12*.09;for(let{x:e,y:n}of t){let t=e*12,a=n*12;this.wallMarkGraphics.rect(t+12*.12,a+12*.3,r,i),this.wallMarkGraphics.rect(t+12*.56,a+12*.58,r,i)}this.wallMarkGraphics.fill({color:4210752})}redrawRoads(){this.roadGraphics.clear();let e=this.roadColor,t=Array.from({length:50},()=>Array(50).fill(!1)),n=[];for(let e of this.rawObjects.values())e.type===`road`&&(n.push(e),e.x>=0&&e.x<50&&e.y>=0&&e.y<50&&(t[e.x][e.y]=!0));if(n.length===0)return;let r=12*.125;for(let e of n)this.roadGraphics.circle(e.x*12+6,e.y*12+6,r);this.roadGraphics.fill(e);let i=[[1,0],[1,1],[0,1],[-1,1]];for(let e of n){let n=e.x*12+6,r=e.y*12+6;for(let[a,o]of i){let i=e.x+a,s=e.y+o;if(i>=0&&i<50&&s>=0&&s<50&&t[i][s]){let e=i*12+6,t=s*12+6;this.roadGraphics.moveTo(n,r),this.roadGraphics.lineTo(e,t)}}}this.roadGraphics.stroke({width:r*2,color:e})}redrawRamparts(){this.rampartGraphics.clear(),this.rampartGlowGraphics.clear();let e=Array.from({length:50},()=>Array(50).fill(void 0));for(let t of this.rawObjects.values())t.type===`rampart`&&t.x>=0&&t.x<50&&t.y>=0&&t.y<50&&(e[t.x][t.y]=typeof t.user==`string`?t.user:void 0);let t=e=>!e||!this.currentUserId||e===this.currentUserId?{color:Ja,alpha:.4}:{color:Xa,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,Ya),i(r,Za)}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(To/t),e.__nameLabel.anchor.y===0?e.__nameLabel.y=12.600000000000001:e.__nameLabel.y=Eo-Do/t),e.__sayBubble&&!e.__sayBubble.destroyed&&(e.__sayBubble.scale.set(1/t),e.__sayBubble.position.set(12/2,Eo-No/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||!vl(n,this.currentUserId))continue;let r=typeof n.user==`string`?n.user:void 0,i=bl(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`||!vl(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 k;o.anchor.set(.5,.5);let s=So*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)+Ys,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=Cl(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())Sl(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}},Tl=2,El=3,Dl=12*.45,Ol=.55;function kl(e,t){return{cx:e*12+12/2,cy:t*12+12/2}}var Al=class{container;graphics;animations=[];ticker=null;tickerCallback=null;constructor(e){this.container=new M,this.graphics=new E,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=kl(e,t),o=kl(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:xa,width:Tl,glowAtSource:!0})}addUpgradeController(e,t,n,r,i){let a=kl(e,t),o=kl(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Sa,width:Tl})}addTransfer(e,t,n,r,i){let a=kl(e,t),o=kl(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Ta,width:Tl})}addBuild(e,t,n,r,i){let a=kl(e,t),o=kl(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Ca,width:Tl})}addRepair(e,t,n,r,i){let a=kl(e,t),o=kl(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:wa,width:Tl})}addLinkTransfer(e,t,n,r,i){let a=kl(e,t),o=kl(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Ea,width:Tl})}addLabReaction(e,t,n,r,i){let a=kl(e,t),o=kl(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Aa,width:Tl})}addTowerBeam(e,t,n,r,i,a){let o=kl(e,t),s=kl(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:El})}addTowerAttack(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,Da)}addTowerHeal(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,Oa)}addTowerRepair(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,ka)}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)*Ol,n=r.width/Tl*Dl*(.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()}},jl=e=>(e+.5)*12,Ml={dashed:[.3*12,.25*12],dotted:[.1*12,.2*12]},Nl=2400;function Pl(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 Fl(e){if(typeof e!=`string`)return`sans-serif`;let t=e.match(/^[0-9.]+(px)?\s+(.+)$/);return t?t[2]:`sans-serif`}var Il=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 k(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),Nl)}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`?Ml.dotted:t.lineStyle===`dashed`?Ml.dashed:[]),r.beginPath(),r.moveTo(jl(e.x1),jl(e.y1)),r.lineTo(jl(e.x2),jl(e.y2)),r.stroke(),r.restore()}drawCircle(e,t,n){let{ctx:r}=this;r.save(),r.globalAlpha=n,r.setLineDash(t.lineStyle===`dotted`?Ml.dotted:t.lineStyle===`dashed`?Ml.dashed:[]),r.beginPath(),r.arc(jl(e.x),jl(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`?Ml.dotted:t.lineStyle===`dashed`?Ml.dashed:[]),r.beginPath(),r.rect(jl(e.x),jl(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`?Ml.dotted:t.lineStyle===`dashed`?Ml.dashed:[]),r.beginPath(),r.moveTo(jl(e.points[0][0]),jl(e.points[0][1]));for(let t=1;t<e.points.length;t++)r.lineTo(jl(e.points[t][0]),jl(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=Pl(t.font)*12,a=Fl(t.font),o=t.align??`left`,s=jl(e.x),c=jl(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 Ll(e,t){let n=localStorage.getItem(e),[r,i]=s(n===null?t:n===`true`);return[r,t=>{i(t),localStorage.setItem(e,String(t))}]}function Rl(e,t){let[n,r]=s(localStorage.getItem(e)??t);return[n,t=>{r(t),localStorage.setItem(e,t)}]}var[zl,Bl]=Ll(H.widescreenMode,!0),[Vl,Hl]=Ll(H.showCreepLabels,!0),[Ul,Wl]=Ll(H.showMapRoomNames,!1),[Gl,Kl]=Ll(H.showUnclaimableRooms,!0),[ql,Jl]=Ll(H.terrainEffects,!0),[Yl,Xl]=Ll(H.showRoomDecorations,!1),[Zl,Ql]=Ll(H.roomDarkOverlay,!0),[$l,eu]=Ll(H.showRoomVisuals,!0),[tu,nu]=Rl(H.spriteTheme,`default`),[ru,iu]=Ll(H.showMapVisuals,!0),au=Zt(),ou=au?`?v=${encodeURIComponent(au)}`:``,su={id:`default`,name:`Default`,atlasUrl:`${$t()}/themes/default/sprite-0.json${ou}`,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}}},cu=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=D.load(e).then(t=>(this.cache.set(e,t),this.frames.set(e,lu(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 lu(e){let t={...e.textures};for(let n of e.linkedSheets??[])Object.assign(t,n.textures);return t}var uu=new cu,du=Symbol(`store-raw`),fu=Symbol(`store-node`),pu=Symbol(`store-has`),mu=Symbol(`store-self`),hu={onStoreNodeUpdate:null};function gu(e){let t=e[c];if(!t&&(Object.defineProperty(e,c,{value:t=new Proxy(e,wu)}),!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 _u(e){let t;return typeof e==`object`&&!!e&&(e[c]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function vu(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[du])return n;if(!_u(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=vu(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=vu(i,t))!==i&&(e[a]=r))}return e}function yu(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function bu(e,t,n){if(e[t])return e[t];let[r,i]=s(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function xu(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===c||t===fu?n:(delete n.value,delete n.writable,n.get=()=>e[c][t],n)}function Su(e){x()&&bu(yu(e,fu),mu)()}function Cu(e){return Su(e),Reflect.ownKeys(e)}var wu={get(e,t,n){if(t===du)return e;if(t===c)return n;if(t===m)return Su(e),n;let r=yu(e,fu),i=r[t],a=i?i():e[t];if(t===fu||t===pu||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);x()&&(typeof a!=`function`||e.hasOwnProperty(t))&&!(n&&n.get)&&(a=bu(r,t,a)())}return _u(a)?gu(a):a},has(e,t){return t===du||t===c||t===m||t===fu||t===pu||t===`__proto__`?!0:(x()&&bu(yu(e,pu),t)(),t in e)},set(){return console.warn(`Cannot mutate a Store directly`),!0},deleteProperty(){return console.warn(`Cannot mutate a Store directly`),!0},ownKeys:Cu,getOwnPropertyDescriptor:xu};function Tu(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;hu.onStoreNodeUpdate&&hu.onStoreNodeUpdate(e,t,n,i),n===void 0?(delete e[t],e[pu]&&e[pu][t]&&i!==void 0&&e[pu][t].$()):(e[t]=n,e[pu]&&e[pu][t]&&i===void 0&&e[pu][t].$());let o=yu(e,fu),s;if((s=bu(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=bu(o,`length`,a))&&s.$(e.length)}(s=o[mu])&&s.$()}function Eu(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];Du(i)||Tu(e,i,t[i])}}function Du(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function Ou(e,t){if(typeof t==`function`&&(t=t(e)),t=vu(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&&Tu(e,n,r)}Tu(e,`length`,r)}else Eu(e,t)}function ku(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&&Du(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++)ku(e,[r[i]].concat(t),n);return}else if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&ku(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)ku(e,[r].concat(t),n);return}else if(t.length>1){ku(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=vu(a),r===void 0||_u(i)&&_u(a)&&!Array.isArray(a)?Eu(i,a):Tu(e,r,a))}function Au(...[e,t]){let n=vu(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=gu(n);v.registerGraph({value:n,name:t&&t.name});function a(...e){g(()=>{r&&e.length===1?Ou(n,e[0]):ku(n,e)})}return[i,a]}var ju=Symbol(`store-root`);function Mu(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function Nu(e,t,n,r,i){if(Mu(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==ju&&(!_u(e)||!_u(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){Tu(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++)Nu(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++)Tu(a,n,e[n]);for(;n<e.length;n++)Tu(a,n,f[n]),Nu(e[n],a,n,r,i);a.length>e.length&&Tu(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?(Tu(a,n,f[n]),Nu(e[n],a,n,r,i)):Tu(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)Nu(e[t],a,t,r,i);a.length>e.length&&Tu(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)Mu(s[t])||Nu(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&&Tu(a,c[t],void 0)}function Pu(e,t={}){let{merge:n,key:r=`id`}=t,i=vu(e);return e=>{if(!_u(e)||!_u(i))return i;let t=Nu(i,{[ju]:e},ju,n,r);return t===void 0?e:t}}var Fu=new WeakMap;function Iu(e,t){let[n,r]=Au(t),i={id:e,type:t.type,raw:n};return Fu.set(i,e=>r(Pu(e,{key:`_id`,merge:!1}))),i}var[Lu,Ru]=s([]);function zu(){Ru([])}function Bu(e){Ru(t=>t.filter(t=>t.id!==e))}function Vu(e,t){let n=Lu(),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&&Fu.get(a)?.(e)}i.push(a)}r&&Ru(i)}function Hu(e){let t=Lu();if(t.length===0)return;let n=!1,r=[];for(let i of t){let t=e[i.id];if(!t){n=!0;continue}Fu.get(i)?.(t),r.push(i)}n&&Ru(r)}var[Uu,Wu]=s(null),[Gu,Ku]=s(null),[qu,Ju]=s(null),[Yu,Xu]=s(null),[Zu,Qu]=s(null),[$u,ed]=s({}),[td,nd]=s(null),[rd,id]=s(null),[ad,od]=s(null);function sd(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 cd(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 ld(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 ud(e){return e===0||e<0&&(e+1)%10==0||e>0&&e%10==0}function dd(e,t){return ud(e)||ud(t)}function fd(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 pd(e){let t=e;if(!t)return!1;let n=t.tagName??``;return n===`INPUT`||n===`TEXTAREA`?!0:t.isContentEditable===!0}function md(e){let t=t=>{if(pd(t.target))return;let n=e.currentRoom(),r=n?cd(n):null;if(!r)return;let i=e.worldBounds(),a=(e,t)=>!i||sd(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),a(()=>window.removeEventListener(`keydown`,t))}var[Z,hd]=s(!1),[gd,_d]=s(0),[vd,yd]=s(0),[bd,xd]=s(0),[Sd,Cd]=s(!1),[wd,Td]=s(1),[Ed,Dd]=s(!1),Od=null;function kd(){Od!==null&&(clearInterval(Od),Od=null)}function Ad(){kd(),Od=setInterval(()=>{let e=gd()+1;e>bd()?(kd(),Cd(!1)):_d(e)},Math.max(50,Math.round(1e3/wd())))}function jd(e){let t=e,n=Math.max(0,t-2e5);xd(t),yd(n),_d(e),Cd(!1),kd(),hd(!0)}function Md(){kd(),Cd(!1),hd(!1)}function Nd(e){_d(Math.max(vd(),Math.min(bd(),e)))}function Pd(e){Nd(gd()+e)}function Fd(){Sd()?(kd(),Cd(!1)):(Cd(!0),Ad())}function Id(e){Td(e),Sd()&&Ad()}var Ld=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}}},Rd=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`),zd=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`),Bd=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`),Vd=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`),Hd=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`),Ud=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:Wd,warn:Gd,error:Kd}=en(`build`),qd={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},Jd={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}},[Yd,Xd]=s(`view`),[Zd,Qd]=s({name:``,color:`COLOR_WHITE`,secondaryColor:`COLOR_WHITE`}),[$d,ef]=s(null),[tf,nf]=s(null),[rf,af]=s({structureType:``,structureName:``});S(()=>{f(()=>{let e=rf().structureType;if(!e)return;let t=qu()??0,n=Jd[e];if(!n)return;let r=Nn()===`empty`&&e===`spawn`?Math.max(n[t]??0,1):n[t]??0;r!==2500&&($u()[e]??0)>=r&&(af({structureType:``,structureName:``}),of())})});function of(){ef(null)}function sf(){nf(null)}function cf(){af({structureType:``,structureName:``})}function lf(e,t){let n=W(),r=rf(),i=$d();if(!n||!r.structureType||!i){Gd(`missing requirements`,{hasClient:!!n,structureType:r.structureType,pending:i});return}if(Nn()===`empty`&&r.structureType===`spawn`){Wd(`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(()=>(Wd(`spawn placed`),V(`Spawn placed successfully`,`success`),of(),n.stores.user.refreshWorldStatus())).catch(e=>{Kd(`place spawn failed:`,e),V(`Failed to place spawn: ${e.message}`,`error`)});return}Wd(`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(()=>{Wd(`construction site created`),V(`Construction site for ${r.structureType} created`,`success`),of()}).catch(e=>{Kd(`create construction failed:`,e),V(`Failed to create construction site: ${e.message}`,`error`)})}function uf(){Xd(`view`),of(),sf(),cf()}function df(){Xd(`view`),of(),p(tf)?.type!==`moveFlag`&&sf(),cf()}function ff(){let e=Yd(),t=$d(),n=tf(),r=Nn();if(r===`empty`)return(()=>{var e=Rd(),t=e.firstChild.nextSibling;return t.$$click=()=>{Xd(`build`),af({structureType:`spawn`,structureName:``})},e})();if(r===`lost`)return(()=>{var e=zd(),t=e.firstChild.nextSibling;return t.$$click=()=>{let e=W();e&&e.http.user.respawn().then(()=>{V(`Respawn successful`,`success`),Hn()}).catch(e=>{V(`Respawn failed: ${e.message}`,`error`)})},e})();if(n?.type===`moveFlag`)return(()=>{var e=Bd(),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=Vd(),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=rf(),t=qu(),n=$u(),r=e.structureType;if(!r)return(()=>{var e=Hd();return e.firstChild.nextSibling.nextSibling,e})();let i=Jd[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=Ud(),t=e.firstChild;return t.nextSibling.nextSibling,z(t,`Click to build ${o} (${s})`),e})()}return null}F([`click`]);var pf=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>`),mf=P(`<div style=width:100%;height:100%;position:relative><div style=width:100%;height:100%>`),hf=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">`),gf=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:_f,error:vf}=en(`room`);function yf(e,t,n=4){e.http.game.genUniqueFlagName().then(r=>{if(r.name===t&&n>0){setTimeout(()=>yf(e,t,n-1),200);return}Qd(e=>({...e,name:r.name}))}).catch(e=>vf(`gen unique flag name failed:`,e))}function bf(e){let t=e=>e==="default"?su:null,r,i=null,c=null,l=null,d=null,m=null,[g,_]=s(null),[v,y]=s(null),[b,x]=s(null),[S,C]=s(null),[w,T]=s(``),[E,D]=s(gd());f(()=>D(gd()));let O=null;return n(async()=>{r&&_(await Qi.create(r))}),a(()=>{O!==null&&clearTimeout(O),i?.destroy(),i=null,l?.destroy(),l=null,d?.destroy(),d=null;let e=g();e&&e.destroy()}),f(()=>{let t=W();if(!t||Z())return;let n=e.room,r=e.shard;_f(`navigate → ${n} (shard=${r??`default`})`),y(null),x(null),C(null),T(``),Sn(null),zu(),od(n),id(r),Wu(null),Ku(null),Ju(null),Xu(null),Qu(null),ed({}),nd(null);let i=new Ct,o=!1;t.stores.room.terrain(n,r).then(e=>{o||(_f(`terrain loaded — ${n}`),y({room:n,data:e}))}).catch(e=>{o||vf(`terrain load failed for ${n}:`,e)}),p(Yl)&&t.http.game.roomDecorations(n,r).then(e=>{o||(_f(`decorations loaded — ${n}: ${e.decorations.length} item(s)`),x({room:n,decoration:ho(e)}))}).catch(e=>{o||_f(`no decorations for ${n}: ${e}`)}),i.add(t.stores.room.subscribe(n,r)),i.add(t.stores.room.on(`room:error`,e=>{V(`Room subscription error (${e.room}): ${e.message}`,`error`,8e3)})),i.add(t.stores.room.on(`room:update`,e=>{let t=0,r={},i=0,a=null,o=null,s=null;for(let n in e.objects){t++;let c=e.objects[n];if(!c)continue;let l=c.type;if(typeof l==`string`)if(l===`constructionSite`){let e=c.structureType;typeof e==`string`&&(r[e]=(r[e]||0)+1)}else r[l]=(r[l]||0)+1;if(l===`controller`){if(typeof c.user==`string`){let t=c.user;o={userId:t,username:e.users?.[t]?.username??t},typeof c.level==`number`&&(i=c.level),typeof c.progress==`number`&&(a=c.progress)}let t=c.reservation;t&&typeof t.user==`string`&&typeof t.endTime==`number`&&(s={user:t.user,endTime:t.endTime})}}e.diff||_f(`objects loaded — ${n}: ${t} objects, tick=${e.gameTime}`),C({objects:e.objects,diff:e.diff,users:e.users}),T(e.visual),Sn(e.gameTime??null),qn(e.gameTime),Wu(t),Ku(o),Ju(i||null),Xu(a),Qu(s),ed(r),nd(e.users??null)})),a(()=>{_f(`leaving ${n}`),o=!0,i.dispose()})}),f(()=>{let t=W();if(!t||!Z())return;T(``);let n=e.room,r=e.shard,i=Yn()??!0,o=bn()?.serverData?.historyChunkSize??(i?20:100),s=p(td)??void 0,c=new Ld(n,r,t.http,o);f(()=>{let e=gd(),t=!1;Dd(!0),c.getStateAtTick(e).then(e=>{if(t)return;if(Dd(!1),e.clampedTo!==void 0){xd(e.clampedTo),Nd(e.clampedTo);return}C({objects:e.objects,diff:void 0,users:s}),Sn(e.gameTime);let n=0,r={},i=0,a=null,o=null,c=null;for(let t in e.objects){n++;let l=e.objects[t];if(!l)continue;let u=l.type;if(typeof u==`string`)if(u===`constructionSite`){let e=l.structureType;typeof e==`string`&&(r[e]=(r[e]||0)+1)}else r[u]=(r[u]||0)+1;if(u===`controller`){if(typeof l.user==`string`){let e=l.user;o={userId:e,username:s?.[e]?.username??e},typeof l.level==`number`&&(i=l.level),typeof l.progress==`number`&&(a=l.progress)}let e=l.reservation;e&&typeof e.user==`string`&&typeof e.endTime==`number`&&(c={user:e.user,endTime:e.endTime})}}Wu(n),Ku(o),Ju(i||null),Xu(a),Qu(c),ed(r)}).catch(n=>{t||(Dd(!1),V(`History load failed for tick ${e}: ${n.message}`,`error`,5e3))}),a(()=>{t=!0})})}),f(()=>{let t=g();if(!t)return;e.room,e.shard,df(),t.hoverLayer.clearPendingTile();let n=p(tf);n?.type===`moveFlag`?nf({...n,targetRoom:e.room}):t.resetView(),m?.destroy(),m=null,t.clear(),t.resetView(),i?.destroy(),i=null,l?.destroy(),l=null,d?.destroy(),d=null;let r=p(v);if(r&&r.room===e.room){_f(`terrain applied immediately (pre-loaded) — ${e.room}`);let n=p(b);m=so(r.data,t.app.renderer,n?.room===e.room?n.decoration.terrain:void 0),co(m,p(ql)),m.zIndex=Xi.terrain,t.world.addChild(m),t.bringNavOverlayToTop()}let a=e.room,o=e.shard,s=cd(a),c=p(()=>e.onNavigate),u=p(kn);if(s&&c){let e=(e,t)=>!u||sd(e,t,u),n=e=>{_f(`navigate requested: ${a} → ${e}`),c(e,o)};t.setupNavigationZones({west:e(s.x-1,s.y)?()=>n(ld(s.x-1,s.y)):void 0,east:e(s.x+1,s.y)?()=>n(ld(s.x+1,s.y)):void 0,north:e(s.x,s.y-1)?()=>n(ld(s.x,s.y-1)):void 0,south:e(s.x,s.y+1)?()=>n(ld(s.x,s.y+1)):void 0})}}),f(()=>{let t=g();if(!t)return;let n=p(()=>e.room),r=p(()=>e.shard),i=cd(n);if(i&&e.onNavigate){let a=e.onNavigate,o=kn(),s=(e,t)=>!o||sd(e,t,o),c=e=>{_f(`navigate requested: ${n} → ${e}`),a(e,r)};md({currentRoom:()=>e.room,worldBounds:kn,onMove:(e,t)=>c(ld(e,t))}),t.setupNavigationZones({west:s(i.x-1,i.y)?()=>c(ld(i.x-1,i.y)):void 0,east:s(i.x+1,i.y)?()=>c(ld(i.x+1,i.y)):void 0,north:s(i.x,i.y-1)?()=>c(ld(i.x,i.y-1)):void 0,south:s(i.x,i.y+1)?()=>c(ld(i.x,i.y+1)):void 0})}}),f(()=>{let e=Yd(),t=g();e===`view`&&t&&(of(),t.hoverLayer.clearPendingTile())}),f(()=>{let e=g(),t=$d();e&&(t?e.hoverLayer.setPendingTile(t.tx,t.ty):e.hoverLayer.clearPendingTile())}),f(()=>{let t=g(),n=v();if(!t||!n||n.room!==e.room)return;if(m?.parent){_f(`terrain already in scene, skipping — ${e.room}`);return}_f(`terrain applied (async) — ${e.room}`);let r=p(b);m=so(n.data,t.app.renderer,r?.room===e.room?r.decoration.terrain:void 0),co(m,p(ql)),t.world.addChildAt(m,0),t.bringNavOverlayToTop()}),f(()=>{if(Yl())return;x(null);let t=p(g),n=p(v);!t||!n||n.room!==e.room||m?.parent&&(m.destroy(),m=so(n.data,t.app.renderer),co(m,p(ql)),t.world.addChildAt(m,0),t.bringNavOverlayToTop(),i?.setRoadColor(ga))}),f(()=>{let t=g(),n=b(),r=p(v);!t||!n||n.room!==e.room||!r||r.room!==e.room||m?.parent&&(_f(`decoration arrived, rebuilding terrain layer — ${e.room}`),m.destroy(),m=so(r.data,t.app.renderer,n.decoration.terrain),co(m,p(ql)),t.world.addChildAt(m,0),t.bringNavOverlayToTop(),i&&n.decoration.roadColor!=null&&i.setRoadColor(n.decoration.roadColor))}),f(()=>{let n=g(),r=S();if(!n)return;if(!r){i?.clear(),l?.clear(),n.clearLighting();return}let{objects:a,diff:o,users:s}=r,u=i?o:void 0;if(!i){_f(`object layer created — ${e.room}`),i=new wl(n.app.ticker,Vl(),G()?._id,G()?.badge,s),i.setTheme(t(p(tu)),uu),i.setInstantMode(p(Z));let r=p(b);r?.room===e.room&&r.decoration.roadColor!=null&&i.setRoadColor(r.decoration.roadColor),i.setLightingLayer(n.lighting),i.container.label=`objects`,i.container.zIndex=Xi.objects,n.world.addChild(i.container),l=new Al(n.app.ticker),l.container.label=`animations`,l.container.zIndex=Xi.animations,n.world.addChild(l.container),d=new Il(n.app.renderer,n.world,n.app.ticker),d.container.zIndex=Xi.visuals,n.world.addChild(d.container),n.setTileHandlers((e,t)=>{},(t,r,a)=>{let o=e.room,s=e.shard,c=Yd(),l=tf();if(l?.type===`moveFlag`){let e=W();if(!e)return;let{name:n,room:i,color:a,secondaryColor:o,targetRoom:c}=l;e.http.game.removeFlag(i,n).then(()=>e.http.game.createFlag(c,t,r,n,a,o,s??void 0)).then(()=>{V(`Flag "${n}" moved`,`success`),sf()}).catch(e=>{vf(`move flag failed:`,e),V(`Failed to move flag "${n}"`,`error`),sf()});return}if(c===`flag`){let e=$d();if(!e||e.tx!==t||e.ty!==r){ef({tx:t,ty:r}),n.hoverLayer.setPendingTile(t,r);return}let i=W();if(!i)return;let a=Zd(),c=a.name.trim();if(!c){V(`Flag name is required`,`error`);return}let l=qd[a.color]??0,u=qd[a.secondaryColor]??0;i.http.game.createFlag(o,t,r,c,l,u,s??void 0).then(()=>{V(`Flag "${c}" created`,`success`),of(),n.hoverLayer.clearPendingTile(),yf(i,c)}).catch(e=>vf(`create flag failed:`,e));return}if(c===`build`){if(!a&&!rf().structureType){V(`Select a structure type first`,`error`);return}if(a){if(!i)return;let e=i.getObjectsAtTile(t,r).filter(({obj:e})=>e.type===`constructionSite`);if(e.length===0){V(`No construction sites on this tile`,`error`);return}let a=W();if(!a)return;a.http.game.removeConstructionSite(o,e.map(({id:e})=>e),s??void 0).then(()=>{V(`Removed ${e.length} construction site${e.length>1?`s`:``}`,`success`),of(),n.hoverLayer.clearPendingTile()}).catch(e=>{vf(`remove construction sites failed:`,e),V(`Failed to remove construction sites: ${e.message}`,`error`)});return}ef({tx:t,ty:r}),n.hoverLayer.setPendingTile(t,r),lf(o,s);return}if(of(),n.hoverLayer.clearPendingTile(),!i)return;let u=i.getObjectsAtTile(t,r);if(u.length===0){a||(Ru([]),n.hoverLayer.clearSelection());return}let d=[...Lu()];if(a){let e=new Set(u.map(e=>e.id));if(d.some(t=>e.has(t.id)))d=d.filter(t=>!e.has(t.id));else{let e=u.filter(({id:e})=>!d.some(t=>t.id===e)).map(({id:e,obj:t})=>Iu(e,t));d=[...d,...e]}}else d=u.map(({id:e,obj:t})=>Iu(e,t));Ru(d);let f=d.map(({id:e,type:t})=>({id:e,type:t,visual:i.getVisualById(e)})).filter(e=>e.visual!=null);n.hoverLayer.setSelectedObjects(f)},()=>{let e=Yd();(e===`build`||e===`flag`||tf()?.type===`moveFlag`)&&(uf(),n.hoverLayer.clearPendingTile())})}u?Vu(u,a):Hu(a);let f=Z()?Math.round(1e3/p(wd)):Cn()??2e3,m=f*.6,h=Math.round(f*.9);i.setMoveDuration(h),i.setTickDuration(f),c={objects:a,users:s},i.update(a,u,s,K()??void 0),i.setShowLabels(p(Vl));let _=new Set;if(l){l.clear();for(let e in a){let t=a[e];if(!t)continue;let n=t.actionLog;if(!n)continue;if(t.type===`tower`){let r=n.attack,a=n.heal,o=n.repair;r&&l.addTowerAttack(t.x,t.y,r.x,r.y,m),a&&l.addTowerHeal(t.x,t.y,a.x,a.y,m),o&&l.addTowerRepair(t.x,t.y,o.x,o.y,m);let s=r??a??o;s&&i?.triggerTowerAim(e,s.x,s.y,m);continue}if(t.type===`link`){let e=n.transferEnergy;e&&l.addLinkTransfer(t.x,t.y,e.x,e.y,m);continue}if(t.type===`lab`){let e=n.runReaction??n.reverseReaction;e&&(l.addLabReaction(e.x1,e.y1,t.x,t.y,m),l.addLabReaction(e.x2,e.y2,t.x,t.y,m));continue}if(t.type!==`creep`)continue;let r=n.harvest;r&&l.addHarvest(r.x,r.y,t.x,t.y,m);let o=n.upgradeController;o&&l.addUpgradeController(t.x,t.y,o.x,o.y,m);let s=n.build;s&&(l.addBuild(t.x,t.y,s.x,s.y,m),i?.triggerBuildAt(s.x,s.y,m));let c=n.repair;c&&l.addRepair(t.x,t.y,c.x,c.y,m);let u=n.transfer;u&&l.addTransfer(t.x,t.y,u.x,u.y,m);let d=n.say;d&&typeof d.message==`string`&&d.message.length>0&&(i?.triggerSay(e,d.message),_.add(e))}}i.pruneSayBubblesExcept(_),p(Zl)&&n.updateLighting(a)}),f(()=>{let e=w();d?.update($l()?e:``)}),f(()=>{i?.setInstantMode(Z())}),f(()=>{let e=ql();m&&co(m,e)}),f(()=>{let e=g();if(!e)return;let t=Zl();e.darkOverlay.visible=t,e.lightLayer.visible=t,t||e.clearLighting()}),f(()=>{let e=t(tu());i&&(i.setTheme(e,uu),c&&(i.clear(),i.update(c.objects,void 0,c.users)))}),(()=>{var e=mf(),t=e.firstChild;return Ee(e=>r=e,t),z(e,(()=>{var e=N(()=>!!ff());return()=>e()&&(()=>{var e=hf();return z(e,ff),o(t=>R(e,`pointer-events`,Nn()===`empty`||Nn()===`lost`?`auto`:`none`)),e})()})(),null),z(e,(()=>{var e=N(()=>!Z()&&K()!==null);return()=>e()&&(()=>{var e=gf();return e.firstChild,z(e,K,null),e})()})(),null),z(e,h(u,{get when(){return Z()},get children(){var e=pf(),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,Nd(t)},150)},z(n,vd),z(r,(()=>{var e=N(()=>!!Ed());return()=>e()?`Loading…`:`Tick ${gd()}`})()),z(i,bd),o(e=>{var n=vd(),i=bd(),a=Ed()?`#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}),o(()=>t.value=E()),e}}),null),e})()}F([`input`]);var xf=P(`<div style=position:fixed;bottom:16px;right:16px;display:flex;flex-direction:column;gap:8px;z-index:9999;pointer-events:none>`),Sf=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 Cf(){return(()=>{var e=xf();return z(e,h(l,{get each(){return Wt()},children:e=>(()=>{var t=Sf();return z(t,()=>e.message),o(n=>R(t,`background`,e.type===`error`?`#da3633`:`#238636`)),t})()})),e})()}var[wf,Tf]=s(!0),[Ef,Df]=s(!0),[Of,kf]=s(!1),[Af,jf]=s(``),Mf;function Nf(e){Mf=e}function Pf(e){jf(e),Df(!0),requestAnimationFrame(()=>{Mf?.focus();let t=e.length;Mf?.setSelectionRange(t,t)})}function Ff(){Tf(e=>!e)}function If(){Df(e=>!e)}function Lf(){kf(e=>!e)}var[Rf,zf]=s(sn(H.memoryWatches,[])),[Bf,Vf]=s(null),[Hf,Uf]=Au({});function Wf(e){let t=e.trim();t&&(zf(e=>e.includes(t)?e:[...e,t]),cn(H.memoryWatches,Rf()))}function Gf(e){zf(t=>t.filter(t=>t!==e)),cn(H.memoryWatches,Rf())}function Kf(){Vf(null)}function qf(e,t){Vf({creepId:e,name:t})}function Jf(e,t){let n=[...t];if(e){let t=`creeps.${e.name}`;n.includes(t)||n.push(t)}return n}function Yf(e){let t=new Map,n=()=>{let n=W();if(!n)return;let r=new Set(Jf(Bf(),Rf()));for(let i of r)t.has(i)||t.set(i,n.stores.user.subscribeMemory(i,e));for(let[e,n]of t)r.has(e)||(n.dispose(),t.delete(e))};f(()=>{Rf(),Bf(),n()});let r=W(),i=null;return r?i=r.stores.user.on(`user:memory`,e=>{Uf(e.path,e.value)}):console.warn(`[memoryStore] no client available when initMemorySubscriptions called`),a(()=>{for(let e of t.values())e.dispose();t.clear(),i?.dispose()}),n(),()=>{for(let e of t.values())e.dispose();t.clear(),i?.dispose()}}S(()=>{f(()=>{let e=Bf();e&&(Lu().some(t=>t.id===e.creepId)||Kf())})});var Xf=P(`<button style=color:#8b949e>`),Zf=P(`<span style=width:18px;flex-shrink:0>`),Qf=P(`<span style=color:#484f58;font-style:italic>{…}`),$f=P(`<span style=color:#484f58;font-style:italic>`),ep=P(`<button title=Reload>`),tp=P(`<span title="Click to edit"style=cursor:text;flex:1>`),np=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">`),rp=P(`<button title=Save style=color:#3fb950>`),ip=P(`<button title=Discard style=color:#f85149>`),ap=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:op}=en(`MemoryTree`);function sp(e){return typeof e==`object`&&!!e&&`__screeps_object__`in e}var cp={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},lp={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 up(e){return e.replace(/^Memory\.?/,``)}function dp(e){let[t,r]=s((e.depth??0)<2),i=()=>e.depth??0,[a,c]=s(!1),[d,f]=s(``),[p,m]=s(!1),[g,_]=s(void 0),v=()=>sp(e.value)&&g()!==void 0?g():e.value,y=()=>{let e=v();return!sp(e)&&typeof e==`object`&&!!e},b=()=>y()?Object.entries(v()):[],x=()=>b().length,S=async()=>{m(!0);try{let t=W();if(!t)return;let n=up(e.path),r=await t.http.user.memory.get(n,e.shard);_(r.data===`[object Object]`?{__screeps_object__:!0}:r.data)}catch(e){op(`fetch memory failed`,e)}finally{m(!1)}},C=()=>{_(void 0),S()};n(()=>{t()&&sp(e.value)&&g()===void 0&&S()});let w=async()=>{if(sp(e.value)&&g()===void 0){await S(),r(!0);return}t()&&_(void 0),r(e=>!e)},T=async()=>{let t=d().trim(),n;if(t===`null`)n=null;else if(t===`true`)n=!0;else if(t===`false`)n=!1;else{let e=Number(t);if(!Number.isNaN(e)&&t!==``)n=e;else try{n=JSON.parse(t)}catch{n=t}}let r=W();if(!r)return;let i=up(e.path);try{await r.http.user.memory.set(i,n,e.shard)}catch(e){op(`set memory failed`,e),c(!1);return}c(!1),e.onRefresh?.()},E=()=>{let e=v();return y()?`#c9d1d9`:typeof e==`string`?`#3fb950`:typeof e==`number`?`#79c0ff`:typeof e==`boolean`?`#a371f7`:`#8b949e`},D=()=>{let e=v();return e===null?`null`:e===void 0?`undefined`:typeof e==`string`?JSON.stringify(e):String(e)};return(()=>{var n=ap(),r=n.firstChild,s=r.firstChild,m=s.nextSibling.nextSibling;return z(r,h(u,{get when(){return y()||sp(v())},get children(){var e=Xf();return e.$$click=()=>void w(),z(e,h(u,{get when(){return p()},get children(){return h(Pr,{size:12,style:{animation:`spin 1s linear infinite`}})}}),null),z(e,h(u,{get when(){return!p()},get children(){return h(u,{get when(){return t()},get fallback(){return h(mr,{size:12})},get children(){return h(fr,{size:12})}})}}),null),o(n=>{var r={...lp},i=t()?`Collapse`:`Expand`,a=p();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}}),s),z(r,h(u,{get when(){return N(()=>!y())()&&!sp(v())},get children(){return Zf()}}),s),z(s,()=>e.label),z(r,h(u,{get when(){return sp(v())},get children(){return Qf()}}),m),z(r,h(u,{get when(){return y()},get children(){var e=$f();return z(e,(()=>{var e=N(()=>!!Array.isArray(v()));return()=>e()?`[${x()}]`:`{${x()}}`})()),e}}),m),z(r,h(u,{get when(){return N(()=>!!sp(e.value))()&&!p()},get children(){var e=ep();return e.$$click=()=>C(),z(e,h(Xr,{size:11})),o(t=>L(e,lp,t)),e}}),m),z(r,h(u,{get when(){return N(()=>!y())()&&!sp(v())},get children(){return[h(u,{get when(){return!a()},get children(){var e=tp();return e.$$click=()=>{f(D()),c(!0)},z(e,D),o(t=>R(e,`color`,E())),e}}),h(u,{get when(){return a()},get children(){return[(()=>{var e=np();return e.$$keydown=e=>{e.key===`Enter`&&T(),e.key===`Escape`&&c(!1)},e.$$input=e=>f(e.currentTarget.value),o(()=>e.value=d()),e})(),(()=>{var e=rp();return e.$$mousedown=e=>{e.preventDefault(),T()},z(e,h(ur,{size:12})),o(t=>L(e,{...lp},t)),e})(),(()=>{var e=ip();return e.$$mousedown=e=>{e.preventDefault(),c(!1)},z(e,h(oi,{size:12})),o(t=>L(e,{...lp},t)),e})()]}})]}}),m),m.$$click=()=>Pf(`Memory.${up(e.path)} = `),z(m,h(ni,{size:11})),z(n,h(u,{get when(){return N(()=>!!y())()&&t()},get children(){return h(l,{get each(){return b()},children:([t,n])=>h(dp,{value:n,path:Array.isArray(v())?`${e.path}[${t}]`:`${e.path}.${t}`,label:t,get shard(){return e.shard},get depth(){return i()+1},get onRefresh(){return N(()=>!!sp(e.value))()?C:e.onRefresh}})})}}),null),o(t=>{var r={"padding-left":i()>0?`14px`:`0`,...cp},a=lp,o=`Insert Memory.${up(e.path)} = into console`;return t.e=L(n,r,t.e),t.t=L(m,a,t.t),o!==t.a&&I(m,`title`,t.a=o),t},{e:void 0,t:void 0,a:void 0}),n})()}function fp(e){return h(dp,{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 pp=P(`<div style=color:#484f58;font-style:italic>No paths watched — add one below.`),mp=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`),hp=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">`),gp=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">`),_p=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>`),vp=P(`<div style=width:4px;flex-shrink:0;cursor:col-resize>`),yp=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`),bp=P(`<div style=flex:1;display:flex;overflow:hidden>`),xp=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
+ `),Sp=P(`<div style=color:#484f58;font-style:italic>No log output yet…`),Cp=P(`<div style=margin-bottom:4px;color:#f85149;white-space:pre-wrap;word-break:break-word>`),wp=P(`<div style=margin-bottom:4px;color:#c9d1d9;white-space:pre-wrap;word-break:break-word>`),Tp=P(`<div style=color:#484f58;font-style:italic>No command results yet…`),Ep=P(`<div style=margin-bottom:4px;color:#58a6ff;white-space:pre-wrap;word-break:break-word>`),{error:Dp}=en(`console`);function Op(e){let[t,r]=s(``),i=()=>e.shard??rd();n(()=>{Yf(i())});let a={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},c={background:`transparent`,border:`none`,color:`#8b949e`,cursor:`pointer`,padding:`4px`,"border-radius":`4px`,display:`flex`,"align-items":`center`,"justify-content":`center`};return(()=>{var n=mp(),s=n.firstChild,d=s.nextSibling,f=d.firstChild,p=f.nextSibling,m=p.firstChild;return z(s,h(u,{get when(){return Bf()},children:e=>{let t=`creeps.${e().name}`;return(()=>{var e=hp(),n=e.firstChild.firstChild,r=n.nextSibling.nextSibling;return z(n,t),Ce(r,`click`,Kf,!0),z(r,h(oi,{size:12})),z(e,h(fp,{get value(){return Hf[t]},path:`Memory.${t}`,label:t,get shard(){return i()}}),null),o(e=>L(r,c,e)),e})()}}),null),z(s,h(l,{get each(){return Rf()},children:e=>(()=>{var t=gp(),n=t.firstChild.firstChild,r=n.nextSibling;return z(n,e),r.$$click=()=>Gf(e),z(r,h(oi,{size:12})),z(t,h(fp,{get value(){return Hf[e]},path:`Memory.${e}`,label:e,get shard(){return i()}}),null),o(e=>L(r,c,e)),t})()}),null),z(s,h(u,{get when(){return N(()=>Rf().length===0)()&&!Bf()},get children(){return pp()}}),null),d.addEventListener(`submit`,e=>{e.preventDefault(),Wf(t()),r(``)}),f.$$input=e=>r(e.currentTarget.value),z(p,h(Jr,{size:14}),m),o(t=>{var r=`${e.width*100}%`,i={...a};return r!==t.e&&R(n,`width`,t.e=r),t.t=L(s,i,t.t),t},{e:void 0,t:void 0}),o(()=>f.value=t()),n})()}function kp(e){let[t,r]=s([]),[i,c]=s(!0),[d,p]=s(sn(H.consoleWeights,[1,1,1])),[m,g]=s(null),_,v,y,b=0;n(()=>{let e=W();if(!e)return;let t=new Ct;t.add(e.stores.user.subscribe(`console`)),t.add(e.stores.user.on(`user:console`,e=>{let t=e.messages,n={id:b++,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})})),a(()=>t.dispose())}),f(()=>{t(),i()&&requestAnimationFrame(()=>{wf()&&_&&(_.scrollTop=_.scrollHeight),Ef()&&v&&(v.scrollTop=v.scrollHeight)})});let x=(t,n,r)=>{let i=!t&&!n&&!r;i&&!e.isCollapsed&&e.onToggle?.(),!i&&e.isCollapsed&&e.onToggle?.()};f(()=>{x(wf(),Ef(),Of())});let S=()=>{let e=d(),t=[wf(),Ef(),Of()],n=t.filter(Boolean).length;if(n===0)return[0,0,0];if(n===1){let e=t.findIndex(Boolean);return[0,0,0].map((t,n)=>+(n===e))}let r=t.map((t,n)=>t?e[n]:0).reduce((e,t)=>e+t,0);if(r===0){let e=1/n;return[0,0,0].map((n,r)=>t[r]?e:0)}return t.map((t,n)=>t?e[n]/r:0)};f(()=>{cn(H.consoleWeights,d())});let C=e=>t=>{t.preventDefault(),t.stopPropagation(),g(e),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,w),window.addEventListener(`pointerup`,T,{once:!0})},w=e=>{let t=m();if(t===null)return;let n=y;if(!n)return;let r=n.getBoundingClientRect(),i=Math.max(.02,Math.min(.98,(e.clientX-r.left)/r.width)),a=[...d()],o=[wf(),Ef(),Of()];if(t===0){let e=o[0],t=o[1];if(!e||!t)return;a[0]=i/(1-i),a[1]=1,p(a)}else{let e=o[1],t=o[2];if(!e||!t)return;a[1]=i/(1-i),a[2]=1,p(a)}},T=()=>{g(null),document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,w)},[E,D]=s([]),[O,k]=s(null),[ee,te]=s(``),ne=e=>{let t=E();if(t.length!==0){if(e.key===`ArrowUp`){e.preventDefault();let n=O();n===null?(te(Af()),k(t.length-1),jf(t[t.length-1])):n>0&&(k(n-1),jf(t[n-1]))}else if(e.key===`ArrowDown`){e.preventDefault();let n=O();if(n===null)return;n<t.length-1?(k(n+1),jf(t[n+1])):(k(null),jf(ee()))}}},A=async t=>{t.preventDefault();let n=W(),r=Af().trim();if(!(!n||!r))try{await n.http.user.console(r,e.shard??`shard0`),D(e=>[...e,r]),k(null),te(``),jf(``)}catch(e){Dp(`command failed:`,e)}},j=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`}),re=()=>t().flatMap(e=>e.log),ie=()=>t().flatMap(e=>e.error),M=()=>t().flatMap(e=>e.results),ae={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},oe={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(()=>{wf()&&_&&(_.scrollTop=_.scrollHeight),Ef()&&v&&(v.scrollTop=v.scrollHeight)})};return(()=>{var t=xp(),n=t.firstChild,a=n.firstChild,s=a.nextSibling,d=s.nextSibling;return n.nextSibling,Ce(a,`click`,Ff,!0),Ce(s,`click`,If,!0),Ce(d,`click`,Lf,!0),z(t,h(u,{get when(){return!e.isCollapsed},get children(){var t=bp();return Ee(e=>y=e,t),z(t,h(u,{get when(){return wf()},get children(){var e=_p(),t=e.firstChild,n=t.firstChild,a=n.nextSibling,s=t.nextSibling;n.$$click=()=>i()?c(!1):se(),z(n,(()=>{var e=N(()=>!!i());return()=>e()?h(Wr,{size:16}):h(Kr,{size:16})})()),a.$$click=()=>r([]),z(a,h(ii,{size:16})),s.addEventListener(`scroll`,()=>{_&&c(_.scrollHeight-_.scrollTop-_.clientHeight<20)});var u=_;return typeof u==`function`?Ee(u,s):_=s,z(s,(()=>{var e=N(()=>re().length===0&&ie().length===0);return()=>e()&&Sp()})(),null),z(s,h(l,{get each(){return ie()},children:e=>(()=>{var t=Cp();return t.innerHTML=e,t})()}),null),z(s,h(l,{get each(){return re()},children:e=>(()=>{var t=wp();return t.innerHTML=e,t})()}),null),o(t=>{var r=`${S()[0]*100}%`,o=i()?`Pause scrolling`:`Resume scrolling`,c=oe,l=oe,u={...ae};return r!==t.e&&R(e,`width`,t.e=r),o!==t.t&&I(n,`title`,t.t=o),t.a=L(n,c,t.a),t.o=L(a,l,t.o),t.i=L(s,u,t.i),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),z(t,h(u,{get when(){return N(()=>!!wf())()&&Ef()},get children(){var e=vp();return Ce(e,`pointerdown`,C(0),!0),o(t=>R(e,`background`,m()===0?`#388bfd`:`#21262d`)),e}}),null),z(t,h(u,{get when(){return Ef()},get children(){var e=yp(),t=e.firstChild,n=t.nextSibling,r=n.firstChild.nextSibling;r.nextSibling,t.addEventListener(`scroll`,()=>{v&&c(v.scrollHeight-v.scrollTop-v.clientHeight<20)});var i=v;return typeof i==`function`?Ee(i,t):v=t,z(t,(()=>{var e=N(()=>M().length===0);return()=>e()&&Tp()})(),null),z(t,h(l,{get each(){return M()},children:e=>(()=>{var t=Ep();return t.innerHTML=e,t})()}),null),n.addEventListener(`submit`,A),r.$$keydown=ne,r.$$input=e=>{k(null),jf(e.currentTarget.value)},Ee(e=>Nf(e),r),o(n=>{var r=`${S()[1]*100}%`,i={...ae};return r!==n.e&&R(e,`width`,n.e=r),n.t=L(t,i,n.t),n},{e:void 0,t:void 0}),o(()=>r.value=Af()),e}}),null),z(t,h(u,{get when(){return N(()=>!!Ef())()&&Of()},get children(){var e=vp();return Ce(e,`pointerdown`,C(1),!0),o(t=>R(e,`background`,m()===1?`#388bfd`:`#21262d`)),e}}),null),z(t,h(u,{get when(){return Of()},get children(){return h(Op,{get shard(){return e.shard??null},get width(){return S()[2]}})}}),null),o(e=>R(t,`user-select`,m()===null?`auto`:`none`)),t}}),null),o(e=>{var t=j(wf()),n=j(Ef()),r=j(Of());return e.e=L(a,t,e.e),e.t=L(s,n,e.t),e.a=L(d,r,e.a),e},{e:void 0,t:void 0,a:void 0}),t})()}F([`input`,`click`,`pointerdown`,`keydown`]);var Ap=P(`<div style=display:flex;gap:5px;flex-wrap:wrap>`),jp=P(`<div style=width:18px;height:18px;border-radius:50%;cursor:pointer;flex-shrink:0>`),Mp=[{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 Np(e){return(()=>{var t=Ap();return z(t,h(l,{each:Mp,children:t=>(()=>{var n=jp();return n.$$click=()=>e.onChange(t.value),o(r=>{var i=t.label,a=t.css,o=e.value===t.value?`0 0 0 2px #0d1117, 0 0 0 4px #c9d1d9`:`none`;return i!==r.e&&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 Pp=P(`<div>`),Fp=P(`<div style=font-variant-numeric:tabular-nums>`),Ip=P(`<span style=font-variant-numeric:tabular-nums;font-weight:400> / `),Lp=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">`),Rp=P(`<div style="padding:3px 8px;background:#0d1117;color:#8b949e">`),zp=P(`<div style="padding:3px 8px;background:#0d1117;color:#c9d1d9;font-variant-numeric:tabular-nums">`),Bp=P(`<div>Owner`),Vp=P(`<div>Hits`),Hp=P(`<div style=font-variant-numeric:tabular-nums> / `),Up=P(`<div>Time to live`),Wp=P(`<div>Fatigue`),Gp=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">`),Kp=P(`<div><div>`),qp=P(`<div style=width:11px;height:11px;border-radius:50%;flex-shrink:0>`),Jp=P(`<span style=font-size:10px;font-variant-numeric:tabular-nums><span style=color:#8b949e>×</span><span>`),Yp=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">`),Xp=P(`<div style=padding:8px;display:flex;flex-direction:column;gap:8px;background:#0d1117><label>Primary color</label><label>Secondary color`),Zp=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`),Qp=P(`<div>Reserved by`),$p=P(`<div>Reservation`),em=P(`<div style=font-variant-numeric:tabular-nums> ticks`),tm=P(`<div>Level`),nm=P(`<div>Safe modes`),rm=P(`<div>Power`),im=P(`<div>Downgrade in`),am=P(`<div>Safe mode active`),om=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>`),sm=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">`),cm=P(`<div><div><div>Owner</div><div>`),lm=P(`<div>Cooldown`),um=P(`<div>Notify when attacked`),dm=P(`<div style=display:flex;align-items:center><button style=background:transparent;border:none;cursor:pointer;padding:0;display:flex;align-items:center>`),fm=P(`<div><div>Energy</div><div style=font-variant-numeric:tabular-nums> / `),pm=P(`<div><div>Hits</div><div style=font-variant-numeric:tabular-nums> / `),mm=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>`),hm=P(`<div>Decay in`),gm=P(`<div>Energy cap`),_m=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>`),vm=P(`<div style=width:8px;height:8px;border-radius:50%;flex-shrink:0>`),ym=P(`<button style="background:transparent;border:none;cursor:pointer;padding:0 2px;display:flex;align-items:center;justify-content:center;flex-shrink:0">`),bm=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">`),xm=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">×`),Sm=P(`<span style=font-weight:400;color:#8b949e>`),Cm=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">`),wm=P(`<div style=flex:1;overflow:auto;min-height:0;padding:8px>`),Tm=P(`<div style=color:#484f58;font-style:italic;font-size:12px>Click a tile to select objects…`),{log:Em,error:Dm}=en(`SelectionList`),Om={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`},km={creep:`Creep`,spawn:`Spawn`,extension:`Extension`,tower:`Tower`,container:`Container`,storage:`Storage`,link:`Link`,rampart:`Rampart`,road:`Road`,wall:`Wall`,extractor:`Extractor`,lab:`Lab`,terminal:`Terminal`,observer:`Observer`,powerSpawn:`Power Spawn`,nuker:`Nuker`,factory:`Factory`,invaderCore:`Invader Core`,source:`Source`,mineral:`Mineral`,deposit:`Deposit`,controller:`Controller`,powerBank:`Power Bank`,portal:`Portal`,energy:`Energy`,flag:`Flag`},Am=new Set([`x`,`y`,`type`,`id`,`name`,`user`,`_id`,`room`,`hitsMax`,`energyCapacity`,`body`,`storeCapacity`,`storeCapacityResource`,`invaderHarvested`,`ticksToRegeneration`]),jm=new Set([`hits`,`energy`,`energyCapacity`,`store`,`progress`,`progressTotal`,`nextDecayTime`,`ticksToRegeneration`,`nextRegenerationTime`]),Mm={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 Nm(e){return Mm[e]?Mm[e]:e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()).trim()}function Pm(e){return typeof e==`number`?String(e):typeof e==`string`?e:typeof e==`boolean`?e?`Yes`:`No`:null}function Fm(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`}),Im={display:`grid`,"grid-template-columns":`1fr 1fr`,gap:`1px`,background:`#21262d`,"font-size":`10px`};function Lm(e){let t=()=>{let t=e.item.raw,n=[];for(let e in t){if(Am.has(e))continue;let r=t[e],i=Pm(r);if(!(e===`notifyWhenAttacked`&&r===!1)&&!(e===`off`&&r===!1)){if(e===`hits`&&typeof t.hitsMax==`number`&&(i=`${r} / ${t.hitsMax}`),e===`energy`&&typeof t.energyCapacity==`number`&&(i=`${r} / ${t.energyCapacity}`),e===`nextDecayTime`&&typeof r==`number`){let e=K();e!==null&&(i=String(r-e))}if(e===`nextRegenerationTime`&&typeof r==`number`){let e=K();e!==null&&(i=String(r-e))}i!==null&&n.push({key:e,label:Nm(e),value:i})}}return n.sort((e,t)=>!jm.has(e.key)-+!jm.has(t.key)),n};return h(u,{get when(){return t().length>0},get children(){var e=Pp();return z(e,h(l,{get each(){return t()},children:e=>[(()=>{var t=Pp();return z(t,()=>e.label),o(e=>L(t,Q(!0),e)),t})(),(()=>{var t=Fp();return z(t,()=>e.value),o(e=>L(t,{...Q()},e)),t})()]})),o(t=>L(e,Im,t)),e}})}function Rm(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 h(u,{get when(){return t().length>0},get children(){var r=Lp(),i=r.firstChild;i.firstChild;var a=i.nextSibling;return z(i,h(u,{get when(){return e.capacity!=null},get children(){var t=Ip(),r=t.firstChild;return z(t,n,r),z(t,()=>e.capacity,null),t}}),null),z(a,h(l,{get each(){return t()},children:([e,t])=>[(()=>{var t=Rp();return z(t,e),t})(),(()=>{var e=zp();return z(e,t),e})()]})),r}})}var zm={tough:`#4c4c4c`,move:`#a9b7c6`,work:`#ffe56d`,carry:`#777777`,attack:`#f93842`,ranged_attack:`#5d80b2`,heal:`#65fd62`,claim:`#b99cfb`};function Bm(e){let t=()=>e.item.raw,n=()=>typeof t().user==`string`?t().user:null,r=()=>{let e=n();return e?td()?.[e]?.username??e:null},i=()=>typeof t().hits==`number`?t().hits:null,a=()=>typeof t().hitsMax==`number`?t().hitsMax:null,s=()=>{let e=t().ageTime,n=K();return typeof e==`number`&&n!==null?Math.max(0,e-n):null},c=()=>typeof t().fatigue==`number`?t().fatigue:null,d=()=>t().store,f=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null,p=()=>t().body??[],m=()=>{let e=new Map;for(let t of p())e.set(t.type,(e.get(t.type)??0)+1);return[...e.entries()].map(([e,t])=>({type:e,count:t}))};return(()=>{var e=Kp(),t=e.firstChild;return z(t,h(u,{get when(){return r()},get children(){return[(()=>{var e=Bp();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Pp();return z(e,r),o(t=>L(e,Q(),t)),e})()]}}),null),z(t,h(u,{get when(){return N(()=>i()!==null)()&&a()!==null},get children(){return[(()=>{var e=Vp();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Hp(),t=e.firstChild;return z(e,i,t),z(e,a,null),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(t,h(u,{get when(){return s()!==null},get children(){return[(()=>{var e=Up();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Fp();return z(e,s),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(t,h(u,{get when(){return c()!==null},get children(){return[(()=>{var e=Wp();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Fp();return z(e,c),o(t=>L(e,{...Q(),color:c()>0?`#e3b341`:void 0},t)),e})()]}}),null),z(e,h(Rm,{get store(){return d()},get capacity(){return f()}}),null),z(e,h(u,{get when(){return p().length>0},get children(){var e=Gp(),t=e.firstChild,n=t.firstChild.nextSibling;n.nextSibling;var r=t.nextSibling,i=r.nextSibling;return z(t,()=>p().length,n),z(r,h(l,{get each(){return p()},children:e=>(()=>{var t=qp();return o(n=>{var r=e.type.replace(`_`,` `),i=zm[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,h(l,{get each(){return m()},children:({type:e,count:t})=>(()=>{var n=Jp(),r=n.firstChild,i=r.firstChild,a=r.nextSibling;return z(r,t,i),z(a,()=>e.replace(`_`,` `).toUpperCase()),o(t=>R(a,`color`,zm[e]??`#484f58`)),n})()})),e}}),null),o(e=>L(t,Im,e)),e})()}function Vm(e){let t=()=>e.item.raw,n=()=>typeof t().name==`string`?t().name:``,r=()=>typeof t().room==`string`?t().room:``,i=()=>typeof t().color==`number`?t().color:1,a=()=>typeof t().secondaryColor==`number`?t().secondaryColor:1,[c,l]=s(i()),[d,p]=s(a());f(()=>{l(i()),p(a())});let m=()=>c()!==i()||d()!==a(),g=()=>{let e=W();if(!e)return;let t=c(),i=d();Em(`changeFlagColor: name="${n()}" room=${r()} primary=${t} secondary=${i}`),e.http.game.changeFlagColor(r(),n(),t,i).then(()=>Em(`changeFlagColor OK`)).catch(e=>Dm(`changeFlagColor FAILED:`,e))},_=()=>{let t=tf();return t?.type===`moveFlag`&&t.id===e.item.id},v=()=>{if(_()){nf(null);return}nf({type:`moveFlag`,id:e.item.id,name:n(),room:r(),color:c(),secondaryColor:d(),targetRoom:ad()??r()})},y=()=>{let t=tf();return t?.type===`moveFlag`&&t.id===e.item.id?t:null},b={display:`flex`,"flex-direction":`column`,gap:`5px`,"font-size":`11px`,color:`#8b949e`};return(()=>{var e=Xp(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return n.firstChild,z(t,h(Np,{get value(){return c()},onChange:l}),null),z(n,h(Np,{get value(){return d()},onChange:p}),null),z(e,h(u,{get when(){return!Z()},get children(){return[(()=>{var e=Yp(),t=e.firstChild,n=t.nextSibling;return t.addEventListener(`mouseleave`,e=>{m()&&(e.currentTarget.style.background=`#238636`)}),t.addEventListener(`mouseenter`,e=>{m()&&(e.currentTarget.style.background=`#2ea043`)}),t.$$click=g,n.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=_()?`#c9d1d9`:`#8b949e`}),n.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=`#c9d1d9`}),n.$$click=v,z(n,(()=>{var e=N(()=>!!_());return()=>e()?h(oi,{size:13}):h(Hr,{size:13})})()),o(e=>{var r=!m(),i=m()?`#238636`:`#161b22`,a=m()?`#fff`:`#484f58`,o=`1px solid ${m()?`#238636`:`#30363d`}`,s=m()?`pointer`:`not-allowed`,c=_()?`Abort move`:`Move flag`,l=_()?`#30363d`:`#21262d`,u=_()?`#c9d1d9`:`#8b949e`,d=`1px solid ${_()?`#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})(),h(u,{get when(){return y()},children:e=>(()=>{var t=Zp(),n=t.firstChild.nextSibling;return n.nextSibling,n.$$input=t=>nf({...e(),targetRoom:t.currentTarget.value.toUpperCase()}),o(e=>L(t,b,e)),o(()=>n.value=e().targetRoom),t})()})]}}),null),o(e=>{var r=b,i=b;return e.e=L(t,r,e.e),e.t=L(n,i,e.t),e},{e:void 0,t:void 0}),e})()}function Hm(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:vo[n()]??null,a=()=>typeof t().downgradeTime==`number`?t().downgradeTime:null,c=()=>typeof t().safeModeAvailable==`number`?t().safeModeAvailable:0,l=()=>typeof t().safeMode==`number`?t().safeMode:null,d=()=>t().isPowerEnabled===!0,f=()=>t().reservation,p=()=>typeof t().user==`string`?t().user:null,m=()=>{let e=p();return e?Gu()?.username??e:null},g=()=>{let e=a(),t=K();return e!==null&&t!==null?Math.max(0,e-t):null},_=()=>{let e=g();if(e===null)return`—`;let t=yo[n()];return t!==void 0&&e>=t?`Max`:String(e)},v=()=>p()!==null&&p()===G()?._id,[y,b]=s(!1),x=null,S=()=>{let n=W();n&&n.http.game.addObjectIntent(e.item.id,ad()??t().room??``,`activateSafeMode`,{id:e.item.id},rd()).catch(e=>Dm(`activateSafeMode failed:`,e))},C=()=>{if(!y()){b(!0),x=setTimeout(()=>b(!1),3e3);return}x&&=(clearTimeout(x),null),b(!1);let n=W();n&&n.http.game.addObjectIntent(e.item.id,ad()??t().room??``,`unclaim`,{id:e.item.id},rd()).catch(e=>Dm(`unclaim failed:`,e))};return(()=>{var e=cm(),t=e.firstChild,a=t.firstChild,s=a.nextSibling;return z(s,()=>m()??`None`),z(t,h(u,{get when(){return f()},get children(){return[(()=>{var e=Qp();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Pp();return z(e,()=>td()?.[f().user]?.username??f().user),o(t=>L(e,Q(),t)),e})(),(()=>{var e=$p();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=em(),t=e.firstChild;return z(e,(()=>{var e=N(()=>K()!==null);return()=>e()?Math.max(0,f().endTime-K()):f().endTime})(),t),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(t,h(u,{get when(){return n()>0},get children(){return[(()=>{var e=tm();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Pp();return z(e,n),o(t=>L(e,Q(),t)),e})(),(()=>{var e=nm();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Pp();return z(e,c),o(t=>L(e,Q(),t)),e})(),(()=>{var e=rm();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Pp();return z(e,()=>d()?`Enabled`:`Disabled`),o(t=>L(e,Q(),t)),e})(),(()=>{var e=im();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Fp();return z(e,_),o(t=>L(e,{...Q(),color:_()===`Max`?`#3fb950`:void 0},t)),e})()]}}),null),z(t,h(u,{get when(){return l()!==null},get children(){return[(()=>{var e=am();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=em(),t=e.firstChild;return z(e,l,t),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(e,h(u,{get when(){return N(()=>n()>0&&n()<8&&r()!==null)()&&i()!==null},get children(){var e=om(),t=e.firstChild,a=t.firstChild,s=a.firstChild.nextSibling;s.nextSibling;var c=a.nextSibling,l=c.firstChild,u=l.nextSibling,d=u.nextSibling.nextSibling;d.nextSibling;var f=t.nextSibling.firstChild;return z(a,n,s),z(a,()=>n()+1,null),z(c,()=>Fm(r()),l),z(c,()=>Fm(i()),u),z(c,()=>(r()/i()*100).toFixed(1),d),o(e=>R(f,`width`,`${Math.min(100,r()/i()*100)}%`)),e}}),null),z(e,h(u,{get when(){return N(()=>!!v())()&&!Z()},get children(){var e=sm(),t=e.firstChild,n=t.nextSibling;return t.addEventListener(`mouseleave`,e=>{c()>0&&(e.currentTarget.style.background=`#1f6feb`)}),t.addEventListener(`mouseenter`,e=>{c()>0&&(e.currentTarget.style.background=`#388bfd`)}),t.$$click=S,n.addEventListener(`mouseleave`,e=>{y()||(e.currentTarget.style.background=`#f85149`)}),n.addEventListener(`mouseenter`,e=>{y()||(e.currentTarget.style.background=`#da3633`)}),n.$$click=C,z(n,()=>y()?`Confirm unclaim`:`Unclaim`),o(e=>{var r=c()===0,i=c()>0?`#1f6feb`:`#161b22`,a=c()>0?`pointer`:`not-allowed`,o=c()>0?1:.5,s=y()?`#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),s!==e.i&&R(n,`background`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),o(e=>{var n=Im,r=Q(!0),i=Q();return e.e=L(t,n,e.e),e.t=L(a,r,e.t),e.a=L(s,i,e.a),e},{e:void 0,t:void 0,a:void 0}),e})()}function Um(e){let t=()=>e.item.raw,n=()=>t().store?.energy??0,r=()=>t().storeCapacityResource?.energy??0,i=()=>typeof t().hits==`number`?t().hits:null,a=()=>typeof t().hitsMax==`number`?t().hitsMax:null,s=()=>{if(typeof t().cooldown==`number`)return t().cooldown;let e=t().cooldownTime,n=K();return typeof e==`number`&&n!==null?Math.max(0,e-n):null},c=()=>t().notifyWhenAttacked===!0,l=()=>typeof t().user==`string`?t().user:null,d=()=>l()!==null&&l()===G()?._id,f=()=>{let n=W();n&&n.http.game.addObjectIntent(e.item.id,t().room,`notifyWhenAttacked`,{enabled:!c()}).catch(e=>Dm(`notifyWhenAttacked failed:`,e))};return(()=>{var e=fm(),t=e.firstChild,l=t.nextSibling,p=l.firstChild;return z(l,n,p),z(l,r,null),z(e,h(u,{get when(){return N(()=>i()!==null)()&&a()!==null},get children(){return[(()=>{var e=Vp();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Hp(),t=e.firstChild;return z(e,i,t),z(e,a,null),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(e,h(u,{get when(){return s()!==null},get children(){return[(()=>{var e=lm();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Fp();return z(e,s),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(e,h(u,{get when(){return N(()=>!!d())()&&!Z()},get children(){return[(()=>{var e=um();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=dm(),t=e.firstChild;return t.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=c()?`#3fb950`:`#484f58`}),t.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=c()?`#56d364`:`#8b949e`}),t.$$click=f,z(t,(()=>{var e=N(()=>!!c());return()=>e()?h(cr,{size:12}):h(or,{size:12})})()),o(n=>{var r={...Q()},i=c()?`Notifications on — click to disable`:`Notifications off — click to enable`,a=c()?`#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),o(n=>{var r=Im,i=Q(!0),a={...Q()};return n.e=L(e,r,n.e),n.t=L(t,i,n.t),n.a=L(l,a,n.a),n},{e:void 0,t:void 0,a:void 0}),e})()}function Wm(e){let t=()=>e.item.raw,n=()=>typeof t().hits==`number`?t().hits:null,r=()=>typeof t().hitsMax==`number`?t().hitsMax:null,i=()=>t().store,a=()=>{if(typeof t().storeCapacity==`number`)return t().storeCapacity;let e=t().storeCapacityResource;if(e){let t=0;for(let n in e)t+=e[n];return t}return null},s=()=>{let e=i();if(!e)return 0;let t=0;for(let n in e)t+=e[n];return t},c=()=>{let e=a();return!e||e===0?0:Math.min(100,s()/e*100)};return(()=>{var e=Pp();return z(e,h(u,{get when(){return N(()=>n()!==null)()&&r()!==null},get children(){var e=pm(),t=e.firstChild,i=t.nextSibling,a=i.firstChild;return z(i,n,a),z(i,r,null),o(n=>{var r=Im,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,h(u,{get when(){return a()!==null},get children(){var e=mm(),t=e.firstChild,n=t.firstChild.nextSibling,r=n.firstChild,i=r.nextSibling,l=i.nextSibling.nextSibling;l.nextSibling;var u=t.nextSibling.firstChild;return z(n,()=>Fm(s()),r),z(n,()=>Fm(a()),i),z(n,()=>c().toFixed(1),l),o(e=>R(u,`width`,`${c()}%`)),e}}),null),z(e,h(Rm,{get store(){return i()},capacity:null}),null),e})()}function Gm(e){let t=()=>e.item.raw,n=()=>{let e=t().decayTime;if(typeof e!=`number`)return null;let n=K();return n===null?e:Math.max(0,e-n)},r=()=>typeof t().user==`string`?t().user:null,i=()=>{let e=r();return e?td()?.[e]?.username??e:null},a=()=>t().structure,s=()=>typeof a()?.type==`string`?a().type:null,c=()=>typeof a()?.hits==`number`?a().hits:null,l=()=>typeof a()?.hitsMax==`number`?a().hitsMax:null,d=()=>typeof a()?.level==`number`?a().level:null,f=()=>typeof a()?.energy==`number`?a().energy:null,p=()=>typeof a()?.energyCapacity==`number`?a().energyCapacity:null,m=()=>t().store,g=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null;return(()=>{var e=Kp(),t=e.firstChild;return z(t,h(u,{get when(){return n()!==null},get children(){return[(()=>{var e=hm();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Fp();return z(e,n),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(t,h(u,{get when(){return i()},get children(){return[(()=>{var e=Bp();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Pp();return z(e,i),o(t=>L(e,Q(),t)),e})()]}}),null),z(e,h(u,{get when(){return s()},get children(){var e=_m(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return z(t,s,null),z(n,h(u,{get when(){return l()!==null},get children(){return[(()=>{var e=Vp();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Hp(),t=e.firstChild;return z(e,()=>c()??0,t),z(e,l,null),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(n,h(u,{get when(){return d()!==null},get children(){return[(()=>{var e=tm();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Fp();return z(e,d),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(n,h(u,{get when(){return p()!==null},get children(){return[(()=>{var e=gm();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Hp(),t=e.firstChild;return z(e,()=>f()??0,t),z(e,p,null),o(t=>L(e,{...Q()},t)),e})()]}}),null),o(e=>L(n,Im,e)),e}}),null),z(e,h(Rm,{get store(){return m()},get capacity(){return g()}}),null),o(e=>L(t,Im,e)),e})()}var Km={creep:Bm,flag:Vm,controller:Hm,spawn:Um,extension:Um,tower:Um,link:Um,storage:Wm,terminal:Wm,container:Wm,lab:Wm,factory:Wm,nuker:Wm,powerSpawn:Wm,ruin:Gm};function qm(e){let t=()=>Om[e.item.type]??`#c9d1d9`,n=()=>km[e.item.type]??e.item.type,r=()=>e.item.type===`creep`,i=()=>e.item.type===`flag`,a=()=>{if(!r())return!1;let t=e.item.raw,n=typeof t.user==`string`?t.user:null;return n!==null&&n===G()?._id},c=()=>{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?Gu()?.userId===G()?._id:n===G()?._id},l=()=>Km[e.item.type]||Lm,[d,f]=s(!1),p=null,[m,g]=s(!1),_=null,[v,y]=s(!1),b=null,x=t=>{if(t.stopPropagation(),!v()){y(!0),b=setTimeout(()=>y(!1),3e3);return}b&&=(clearTimeout(b),null),y(!1);let n=W();if(!n)return;let r=e.item.id,i=e.item.raw;n.http.game.removeFlag(i.room,i.name).then(()=>Bu(r)).catch(()=>{})},S=t=>{if(t.stopPropagation(),!m()){g(!0),_=setTimeout(()=>g(!1),3e3);return}_&&=(clearTimeout(_),null),g(!1);let n=W();if(!n)return;let r=e.item.id,i=e.item.raw,a=(typeof i.room==`string`?i.room:null)??ad()??``;if(e.item.type===`constructionSite`)n.http.game.removeConstructionSite(a,[r],rd()??void 0).then(()=>Bu(r)).catch(e=>Dm(`removeConstructionSite failed:`,e));else{let e=typeof i.user==`string`?i.user:Gu()?.userId??``;n.http.game.addObjectIntent(`room`,a,`destroyStructure`,[{id:r,roomName:a,user:e}],rd()).then(()=>Bu(r)).catch(e=>Dm(`destroyStructure failed:`,e))}},C=t=>{if(t.stopPropagation(),!d()){f(!0),p=setTimeout(()=>f(!1),3e3);return}p&&=(clearTimeout(p),null),f(!1);let n=W();if(!n)return;let r=e.item.id;n.http.game.addObjectIntent(r,ad()??e.item.raw.room??``,`suicide`,{id:r},rd()).then(()=>Bu(r)).catch(e=>Dm(`suicide failed:`,e))};return(()=>{var s=xm(),f=s.firstChild,p=f.firstChild,g=p.nextSibling,_=g.firstChild.nextSibling,y=_.nextSibling.nextSibling;y.nextSibling;var b=g.nextSibling;return z(f,h(u,{get when(){return N(()=>!r())()&&!i()},get children(){var e=vm();return o(n=>R(e,`background`,t())),e}}),p),z(p,h(u,{get when(){return i()},get fallback(){return N(n)},get children(){return h(wr,{size:12})}}),null),z(p,h(u,{get when(){return N(()=>typeof e.item.raw.name==`string`)()&&e.item.raw.name},children:e=>(()=>{var t=Sm();return z(t,()=>e()),t})()}),null),z(g,()=>e.item.raw.x,_),z(g,()=>e.item.raw.y,y),z(f,h(u,{get when(){return N(()=>!!a())()&&!Z()},get children(){return[(()=>{var e=ym();return e.addEventListener(`mouseleave`,e=>{d()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{d()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=C,z(e,h(ii,{size:13})),o(t=>{var n=d()?`Click again to confirm suicide`:`Suicide`,r=d()?`#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=bm();return t.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),t.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),t.$$click=()=>{qf(e.item.id,e.item.raw.name),kf(!0)},z(t,h(Sr,{size:13})),t})()]}}),b),z(f,h(u,{get when(){return N(()=>!!c())()&&!Z()},get children(){var t=ym();return t.addEventListener(`mouseleave`,e=>{m()||(e.currentTarget.style.color=`#8b949e`)}),t.addEventListener(`mouseenter`,e=>{m()||(e.currentTarget.style.color=`#f85149`)}),t.$$click=S,z(t,h(ii,{size:13})),o(n=>{var r=m()?`Click again to confirm`:e.item.type===`constructionSite`?`Remove construction site`:`Destroy structure`,i=m()?`#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}}),b),z(f,h(u,{get when(){return N(()=>!!i())()&&!Z()},get children(){var e=ym();return e.addEventListener(`mouseleave`,e=>{v()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{v()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=x,z(e,h(ii,{size:13})),o(t=>{var n=v()?`Click again to confirm deletion`:`Delete flag`,r=v()?`#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}}),b),b.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),b.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#fff`),b.$$click=()=>Bu(e.item.id),z(s,h(He,{get component(){return l()},get item(){return e.item}}),null),z(s,h(u,{get when(){return e.item.id},children:e=>(()=>{var t=Cm();return t.$$click=()=>navigator.clipboard?.writeText(e()),z(t,e),o(()=>I(t,`title`,e())),t})()}),null),o(e=>R(s,`border`,`1px solid ${a()&&d()||m()||v()?`#f85149`:`#30363d`}`)),s})()}function Jm(){return(()=>{var e=wm();return z(e,h(u,{get when(){return Lu().length>0},get fallback(){return Tm()},get children(){return h(l,{get each(){return Lu()},children:e=>h(qm,{item:e})})}})),e})()}F([`click`,`input`]);var Ym=P(`<div style="padding:3px 0;color:#8b949e">Reserved by`),Xm=P(`<div style="padding:3px 0;color:#c9d1d9">`),Zm=P(`<div style="padding:3px 0;color:#8b949e">Expires in`),Qm=P(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums"> ticks`),$m=P(`<div style="padding:3px 0;color:#8b949e">RCL`),eh=P(`<span style=color:#8b949e>(<!>%)`),th=P(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums">`),nh=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">`),rh=P(`<span>`),ih=P(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;display:flex;align-items:center;justify-content:center">`),ah=[{mode:`view`,label:`View`,icon:()=>h(Sr,{size:14})},{mode:`flag`,label:`Flag`,icon:()=>h(wr,{size:14})},{mode:`build`,label:`Build`,icon:()=>h(Er,{size:14})}];function oh(e){return(()=>{var t=nh(),n=t.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling,a=i.firstChild.nextSibling,s=a.nextSibling.nextSibling,c=s.nextSibling.nextSibling,d=c.nextSibling.nextSibling,f=d.nextSibling.nextSibling,p=i.nextSibling,m=p.firstChild.nextSibling,g=p.nextSibling.firstChild.nextSibling,_=n.nextSibling,v=_.firstChild;return z(r,()=>e.room),z(a,()=>e.shard??`—`),z(s,()=>K()??`—`),z(c,(()=>{var e=N(()=>!!Cn());return()=>e()?`${Cn()}ms`:`—`})()),z(d,()=>Uu()??`—`),z(f,()=>Gu()?.username??`—`),z(i,h(u,{get when(){return N(()=>!Gu())()&&Zu()},get children(){return[Ym(),(()=>{var e=Xm();return z(e,()=>td()?.[Zu().user]?.username??Zu().user),e})(),Zm(),(()=>{var e=Qm(),t=e.firstChild;return z(e,(()=>{var e=N(()=>K()!==null);return()=>e()?Math.max(0,Zu().endTime-K()):`—`})(),t),e})()]}}),null),z(i,h(u,{get when(){return N(()=>qu()!==null)()&&qu()>0},get children(){return[$m(),(()=>{var e=th();return z(e,h(u,{get when(){return N(()=>qu()<8)()&&Yu()!==null},get fallback(){return(()=>{var e=rh();return z(e,qu),e})()},get children(){return[N(()=>qu()),` → `,N(()=>qu()+1),`\xA0`,(()=>{var e=eh(),t=e.firstChild.nextSibling;return t.nextSibling,z(e,()=>(Yu()/(vo[qu()]??1)*100).toFixed(1),t),e})()]}})),e})()]}}),null),m.addEventListener(`change`,e=>Hl(e.currentTarget.checked)),g.addEventListener(`change`,e=>eu(e.currentTarget.checked)),z(_,h(u,{get when(){return!Tn()},get children(){return h(l,{each:ah,children:e=>{let t=()=>!Z()&&Yd()===e.mode;return(()=>{var n=ih();return n.$$click=()=>{Z()&&Md(),Xd(e.mode)},z(n,()=>e.icon()),o(r=>{var i=e.label,a=`1px solid ${t()?`#58a6ff`:`#30363d`}`,o=t()?`#1f6feb33`:`#161b22`,s=t()?`#c9d1d9`:`#8b949e`;return i!==r.e&&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})()}})}}),v),v.$$click=()=>Z()?Md():K()!==null&&jd(K()),z(v,h(vr,{size:14})),o(e=>{var t=`repeat(${Tn()?2:4}, 1fr)`,n=!Z()&&K()===null,r=Tn()?`span 2`:void 0,i=`1px solid ${Z()?`#58a6ff`:`#30363d`}`,a=Z()?`#1f6feb33`:`#161b22`,o=Z()?`#c9d1d9`:`#8b949e`,s=!Z()&&K()===null?`not-allowed`:`pointer`,c=!Z()&&K()===null?.4:1;return t!==e.e&&R(_,`grid-template-columns`,e.e=t),n!==e.t&&(v.disabled=e.t=n),r!==e.a&&R(v,`grid-column`,e.a=r),i!==e.o&&R(v,`border`,e.o=i),a!==e.i&&R(v,`background`,e.i=a),o!==e.n&&R(v,`color`,e.n=o),s!==e.s&&R(v,`cursor`,e.s=s),c!==e.h&&R(v,`opacity`,e.h=c),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),o(()=>m.checked=Vl()),o(()=>g.checked=$l()),t})()}F([`click`]);var[sh,ch]=s(`owner`),lh=3,uh=lh*50,dh=4;function fh(e,t,n){let r=cd(e);return r?[r.x*uh+t*lh,r.y*uh+n*lh]:null}var ph=3*lh,mh=2.5*lh,hh=1*lh,gh=2*lh;function _h(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 vh(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 yh=class{container;g;constructor(){this.container=new M,this.container.label=`mapVisuals`,this.g=new E,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=fh(t.n1,t.x1,t.y1),a=fh(t.n2,t.x2,t.y2);if(!i||!a)return;let o=n.color??`#ffffff`,s=(n.width??.5)*lh;n.lineStyle===`dashed`?_h(e,[i,a],ph*(n.width??.5),mh*(n.width??.5)):n.lineStyle===`dotted`?_h(e,[i,a],hh*(n.width??.5),gh*(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=fh(t.n,t.x,t.y);if(!i)return;let[a,o]=i,s=(n.radius??10)*lh,c=!!(n.fill&&n.fill!==`transparent`),l=!!(n.stroke&&n.strokeWidth),u=(n.strokeWidth??.5)*lh;c&&(e.circle(a,o,s),e.fill({color:n.fill,alpha:r})),l&&(n.lineStyle===`dashed`?_h(e,vh(a,o,s),ph*(n.strokeWidth??.5),mh*(n.strokeWidth??.5)):n.lineStyle===`dotted`?_h(e,vh(a,o,s),hh*(n.strokeWidth??.5),gh*(n.strokeWidth??.5)):e.circle(a,o,s),e.stroke({color:n.stroke,width:u,alpha:r}))}drawRect(e,t,n,r){let i=fh(t.n,t.x,t.y),a=fh(t.n,t.x+t.w,t.y),o=fh(t.n,t.x+t.w,t.y+t.h),s=fh(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)*lh;c&&(e.poly(d.slice(0,8),!0),e.fill({color:n.fill,alpha:r})),l&&(n.lineStyle===`dashed`?_h(e,u,ph*(n.strokeWidth??.5),mh*(n.strokeWidth??.5)):n.lineStyle===`dotted`?_h(e,u,hh*(n.strokeWidth??.5),gh*(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=fh(e,n,r);if(!t)return;o.push(t)}let s=o.flatMap(e=>e),c=(n.strokeWidth??.5)*lh;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];_h(e,t[0]===r[0]&&t[1]===r[1]?o:[...o,t],ph*(n.strokeWidth??.5),mh*(n.strokeWidth??.5))}else if(n.lineStyle===`dotted`){let t=o[0],r=o[o.length-1];_h(e,t[0]===r[0]&&t[1]===r[1]?o:[...o,t],hh*(n.strokeWidth??.5),gh*(n.strokeWidth??.5))}else e.poly(s,!0);e.stroke({color:n.stroke,width:c,alpha:r})}}drawText(e,t,n){let r=fh(e.n,e.x,e.y);if(!r)return;let[i,a]=r,o=t.fontSize??10,s=t.fontFamily??`sans-serif`,c=o*lh,l=t.align??`center`,u=new ae({fill:t.color??`#ffffff`,fontSize:c*dh,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*lh*dh}}:{}});if(t.backgroundColor&&t.backgroundColor!==`transparent`){let r=(t.backgroundPadding??2)*lh,o=new re({text:e.text,style:u});o.scale.set(1/dh);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 E;p.rect(d,f,s+r*2,c+r*2),p.fill({color:t.backgroundColor,alpha:n}),this.container.addChild(p)}let d=new re({text:e.text,style:u});d.scale.set(1/dh),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:bh}=en(`terrainCache`),xh=`screeps-terrain-v1`;async function Sh(e,t,n){try{let r=await caches.open(xh),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){bh(`get failed:`,e)}return null}async function Ch(e,t,n,r){try{let i=await caches.open(xh),a=`/terrain/${e}_${t}_z${n}.webp`,o=new Request(a),s=new Response(r);await i.put(o,s)}catch(e){bh(`save failed:`,e)}}var wh=null;async function Th(e){if(wh!==!1)try{let t=await createImageBitmap(e);return wh=!0,t}catch(e){if(wh===!0)throw e;wh=!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 Eh(e){return new Worker(`/client/_client/terrain.worker-CiQZPqa4.js`,{name:e?.name})}var Dh=2962235,Oh=856343,kh=4020797,Ah=ra,jh=4486980,Mh=8921634,Nh=ca,Ph=_a,Fh=[{key:`s`,color:ba,radius:2.5},{key:`c`,color:16777215,radius:2},{key:`m`,color:sa,radius:2},{key:`k`,color:ma,radius:2},{key:`pb`,color:16720418,radius:2.5},{key:`d`,color:16777215,radius:2.5}],Ih=new Set([`w`,`r`,`pb`,`p`,`s`,`c`,`m`,`k`,`d`]);function Lh(e){return`#`+e.toString(16).padStart(6,`0`)}var{warn:Rh}=en(`MapRenderer`),zh=3,$=zh*50,Bh=[50,60,70,80,90,100,105,120],Vh=1,Hh=.5,Uh=50,Wh=2600,Gh=5,Kh=.2,qh=5,Jh=[80,104,128,160],Yh=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 _o;constructor(e){this.app=new O,this.callbacks=e,this.worker=new Eh,this.worker.onmessage=e=>{let t=e.data;if(t.kind===`cache`){Ch(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:na,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 E,this.world.addChild(this.boundsGraphics),this.selectionGraphics=new E,this.world.addChild(this.selectionGraphics),this.safeModeGraphics=new E,this.world.addChild(this.safeModeGraphics),this.mapVisualLayer=new yh,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(Kh,Math.min(qh,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>=Vh,o=this.zoom>=Hh,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>=Vh!==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*$+$/2,i=t*$+$/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 Sh(r,e,t);if(i)return await Th(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 Rh(`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=$,i.terrainSprite.height=$,this.terrainBaked.add(e),this.ensureCurrentLod(e,i)}getLOD(){return this.zoom<Vh?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=zh;r.clear();let a=t.r??[];for(let[e,t]of a)r.rect(e*i,t*i,i,i);a.length&&r.fill(Ah);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`?Mh:jh);for(let e of Fh){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(Ih.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?Nh:Ph;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,$,$),r.fill({color:10027008,alpha:.18})):t===`own`&&(r.rect(0,0,$,$),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 k(i);e.anchor.set(.5),e.x=$/2,e.y=$/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){Rh(`failed to load badge for`,e,t)}}}applyBadgeSize(e,t){if(!e.badgeSprite||e.badgeLevel===void 0)return;let n=(Bh[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 k;n.anchor.set(.5),n.x=$/2,n.y=$/2;let i=r.container.getChildIndex(r.nameLabel);r.container.addChildAt(n,i),r.mineralSprite=n,r.mineralType=t;let a=uu.getTexture(su.atlasUrl,e);a?n.texture=a:uu.getOrLoad(su.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=Jh[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=cd(e);if(!t)return;let n=t.x*$,r=t.y*$;this.selectionGraphics.rect(n,r,$,$);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=cd(t);if(!n)continue;let r=n.x*$,i=n.y*$;this.safeModeGraphics.rect(r,i,$,$),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*$,a=n*$,o=(t-e+1)*$,s=(r-n+1)*$;this.boundsGraphics.rect(i,a,o,s),this.boundsGraphics.stroke({color:ia,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<Wh?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=cd(n);if(e&&e.x>=t.rxMin-Uh&&e.x<=t.rxMax+Uh&&e.y>=t.ryMin-Uh&&e.y<=t.ryMax+Uh)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){Rh(`destroy error (ignored):`,e)}}}getOrCreate(e){let t=this.activeRooms.get(e);if(t)return t;let n=cd(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 k(j.EMPTY),n=new E,i=new E;e.addChild(t),e.addChild(n),e.addChild(i);let a=new re({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*$,r.container.y=n.y*$,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=cd(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(Kh,Math.min(qh,this.pinchStartScale*(o/this.pinchStartDist))),c=this.getLOD(),l=this.zoom>=Vh,u=this.zoom>=Hh;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>=Vh!==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)*$*n,a=this.app.screen.width-50-r.minX*$*n,o=50-(r.maxY+1)*$*n,s=this.app.screen.height-50-r.minY*$*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(Kh,Math.min(qh,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*$*t,a=this.world.x+(e.maxX+1)*$*t,o=this.world.y+e.minY*$*t,s=this.world.y+(e.maxY+1)*$*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 ld(Math.floor(r/$),Math.floor(i/$))}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/$)-1,c=Math.ceil(a/$),l=Math.floor(i/$)-1,u=Math.ceil(o/$);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=ld(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)},Gh))}},Xh=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">`),Zh=P(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;font-size:11px;font-weight:600">`),Qh=[{mode:`owner`,label:`Owner`},{mode:`mineral`,label:`Mineral`},{mode:`none`,label:`None`}];function $h(e){let t=()=>(e.zoom??1)>=Hh;return(()=>{var n=Xh(),r=n.firstChild,i=r.firstChild.nextSibling,a=i.firstChild.nextSibling,s=a.nextSibling.nextSibling,c=i.nextSibling,u=c.firstChild.nextSibling,d=c.nextSibling,f=d.firstChild.nextSibling,p=d.nextSibling.firstChild.nextSibling,m=r.nextSibling;return z(a,()=>e.zoom?.toFixed(2)??`—`),z(s,()=>e.subsActive?`Yes`:`No`),u.addEventListener(`change`,e=>Wl(e.currentTarget.checked)),f.addEventListener(`change`,e=>Kl(e.currentTarget.checked)),p.addEventListener(`change`,e=>iu(e.currentTarget.checked)),z(m,h(l,{each:Qh,children:e=>{let t=()=>sh()===e.mode;return(()=>{var n=Zh();return n.$$click=()=>ch(e.mode),z(n,()=>e.label),o(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})()}})),o(e=>{var n=t()?`#c9d1d9`:`#484f58`,r=t()?`pointer`:`default`,i=!t();return n!==e.e&&R(c,`color`,e.e=n),r!==e.t&&R(c,`cursor`,e.t=r),i!==e.a&&(u.disabled=e.a=i),e},{e:void 0,t:void 0,a:void 0}),o(()=>u.checked=Ul()),o(()=>f.checked=Gl()),o(()=>p.checked=ru()),n})()}F([`click`]);var eg=P(`<img width=12 height=12 alt style="border-radius:2px;flex:0 0 auto;display:block">`),tg=P(`<div style="padding:3px 8px;color:#484f58">None`),ng=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>`),rg=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">`),ig=P(`<div style="padding:6px 8px;font-size:11px;color:#484f58;font-style:italic">None`),ag=P(`<div style="padding:3px 8px;color:#8b949e">Reservation`),og=P(`<div style="padding:3px 8px;color:#8b949e">Mineral`),sg=P(`<div style="padding:3px 8px;color:#79c0ff">`),cg=P(`<div style="padding:3px 8px;color:#8b949e">Density`),lg=P(`<div style="padding:3px 8px;color:#c9d1d9">`),ug=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">`),dg=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">`),fg=P(`<div style="padding:3px 8px;color:#8b949e">Owner`),pg=P(`<div style=display:flex;align-items:center;gap:4px;align-self:flex-end;color:#8b949e><span>&mdash;</span><span>`),mg=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>`),hg=[`Low`,`Medium`,`High`,`Ultra`];function gg(e){return hg[e-1]??String(e)}function _g(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 vg(e){let t=d(()=>`data:image/svg+xml,${encodeURIComponent(Ut(e.badge))}`);return(()=>{var e=eg();return o(()=>I(e,`src`,t())),e})()}function yg(e){return h(u,{get when(){return e.name},get fallback(){return tg()},children:t=>(()=>{var n=ng(),r=n.firstChild;return z(n,h(u,{get when(){return e.badge},children:e=>h(vg,{get badge(){return e()}})}),r),z(r,t),n})()})}function bg(e){return(()=>{var t=rg(),n=t.firstChild;return z(n,()=>e.label),z(t,h(u,{get when(){return e.info},get fallback(){return ig()},children:e=>(()=>{var t=ug(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return z(r,()=>e().room),z(n,h(u,{get when(){return e().level},children:e=>(()=>{var t=dg();return z(t,e),t})()}),null),z(i,h(u,{get when(){return e().reservation},get fallback(){return[fg(),h(yg,{get name(){return e().owner},get badge(){return e().badge}})]},get children(){return[ag(),h(yg,{get name(){return e().reservation},get badge(){return e().badge}})]}}),null),z(i,h(u,{get when(){return e().mineral},get children(){return[og(),(()=>{var t=sg();return z(t,()=>e().mineral),t})(),cg(),(()=>{var t=lg();return z(t,()=>gg(e().density??0)),t})()]}}),null),z(t,h(u,{get when(){return e().sign},children:e=>(()=>{var t=mg(),n=t.firstChild.nextSibling,r=n.firstChild.nextSibling;r.nextSibling;var i=n.nextSibling;return z(n,()=>e().text,r),z(t,h(u,{get when(){return e().username||e().badge},get children(){var t=pg(),n=t.firstChild.nextSibling;return z(t,h(u,{get when(){return e().badge},children:e=>h(vg,{get badge(){return e()}})}),n),z(n,()=>e().username),t}}),i),z(i,()=>_g(e().datetime)),t})()}),null),t})()}),null),o(n=>{var r=`1px solid ${e.dim?`#21262d`:`#30363d`}`,i=e.dim?.6:1;return r!==n.e&&R(t,`border`,n.e=r),i!==n.t&&R(t,`opacity`,n.t=i),n},{e:void 0,t:void 0}),t})()}var xg=P(`<span style=color:#8b949e;font-size:11px>Checking…`),Sg=P(`<div style=margin-top:8px><div style="padding:6px 8px;font-size:11px;font-weight:600;color:#c9d1d9;margin-bottom:6px">Your flags`),Cg=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>`),wg=P(`<span style=color:#f85149;font-size:11px>`),Tg=P(`<div style=margin-top:8px;color:#484f58;font-style:italic;font-size:12px>No flags.`),Eg=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:Dg}=en(`flag`),Og={};for(let[e,t]of Object.entries(qd))Og[t]=e;function kg(){let e=e=>{Qd({...Zd(),...e})},[t,n]=s(null),[r,i]=s(!1),a=null,c=t=>{t.http.game.genUniqueFlagName().then(t=>{e({name:t.name}),n(null)}).catch(e=>{Dg(`gen unique name failed:`,e)})};f(()=>{if(Yd()!==`flag`)return;let e=W();if(!e)return;let t=p(()=>Zd().name.trim());if(!t){c(e);return}e.http.game.checkUniqueFlagName(t).then(()=>{n(null)}).catch(()=>{c(e)})});let d=t=>{e({name:t}),n(null),a&&clearTimeout(a);let r=t.trim();if(!r){i(!1);return}i(!0),a=setTimeout(()=>{let e=W();if(!e){i(!1);return}e.http.game.checkUniqueFlagName(r).then(()=>{n(null)}).catch(e=>{n(e.message)}).finally(()=>{i(!1)})},300)},m=()=>qd[Zd().color]??1,g=()=>qd[Zd().secondaryColor]??1,_=t=>{e({color:Og[t]??`COLOR_WHITE`})},v=t=>{e({secondaryColor:Og[t]??`COLOR_WHITE`})},y=()=>{let e=jn(),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},b=e=>e===void 0||e<0||e>=va.length?`#8b949e`:`#${va[e].toString(16).padStart(6,`0`)}`,x={display:`flex`,"flex-direction":`column`,gap:`5px`,"font-size":`11px`,color:`#8b949e`};return(()=>{var e=Cg(),n=e.firstChild.firstChild.nextSibling.firstChild,i=n.firstChild.nextSibling,a=n.nextSibling;a.firstChild;var s=a.nextSibling;s.firstChild;var c=s.nextSibling;return i.$$input=e=>d(e.currentTarget.value),z(n,h(u,{get when(){return t()},children:e=>(()=>{var t=wg();return z(t,e),t})()}),null),z(n,h(u,{get when(){return r()},get children(){return xg()}}),null),z(a,h(Np,{get value(){return m()},onChange:_}),null),z(s,h(Np,{get value(){return g()},onChange:v}),null),z(c,(()=>{var e=N(()=>!!$d());return()=>e()?`Marked at x=${$d().tx}, y=${$d().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,h(u,{get when(){return y().length>0},get fallback(){return Tg()},get children(){var e=Sg();return e.firstChild,z(e,h(l,{get each(){return y()},children:([e,t])=>(()=>{var n=Eg(),r=n.firstChild.firstChild,i=r.nextSibling,a=i.nextSibling,s=a.nextSibling,c=s.firstChild.nextSibling,l=c.nextSibling.nextSibling;return l.nextSibling,z(i,e),z(a,()=>t.room),z(s,()=>t.x,c),z(s,()=>t.y,l),o(e=>R(r,`background`,b(t.color))),n})()}),null),e}}),null),o(e=>{var r=x,o=`1px solid ${t()?`#f85149`:`#30363d`}`,c=x,l=x;return e.e=L(n,r,e.e),o!==e.t&&R(i,`border`,e.t=o),e.a=L(a,c,e.a),e.o=L(s,l,e.o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),o(()=>i.value=Zd().name),e})()}F([`input`]);var Ag=P(`<span style=color:#8b949e>…`),jg=P(`<span style=color:#3fb950>✓`),Mg=P(`<span style=color:#f85149>✗`),Ng=P(`<div style=font-size:10px;color:#f85149>`),Pg=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>`),Fg=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>`),Ig=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 Lg(e){let t=Object.keys(Jd),[n,r]=s(`idle`),[i,c]=s(``),d=null,p=(e,t)=>{let n=Jd[e];return n?Nn()===`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=$u()[e]??0;return Math.max(0,n-r)},g=()=>rf().structureType===`spawn`;f(b(()=>rf().structureType,(t,n)=>{if(t!==`spawn`||t===n)return;let i=W();if(!i)return;r(`loading`),c(``);let o=!1;a(()=>{o=!0}),i.http.game.genUniqueObjectName(`spawn`,e.shard).then(e=>{o||(af({structureType:`spawn`,structureName:e.name}),r(`valid`))}).catch(()=>{o||(af({structureType:`spawn`,structureName:`Spawn1`}),r(`idle`))})}));let _=t=>{if(d&&clearTimeout(d),!t.trim()){r(`invalid`),c(`Name cannot be empty`);return}r(`loading`),c(``),d=setTimeout(()=>{let n=W();n&&n.http.game.checkUniqueObjectName(`spawn`,t.trim(),e.shard).then(e=>{e.error?(r(`invalid`),c(e.error)):(r(`valid`),c(``))}).catch(()=>{r(`invalid`),c(`Could not validate name`)})},400)},v=e=>{af({structureType:`spawn`,structureName:e}),_(e)},y=e=>{af({structureType:e,structureName:``}),r(`idle`),c(``)},x=()=>{switch(n()){case`loading`:return Ag();case`valid`:return jg();case`invalid`:return Mg();default:return null}};return(()=>{var e=Fg(),r=e.firstChild,a=r.firstChild;a.firstChild;var s=a.nextSibling,c=r.nextSibling;c.firstChild;var d=c.nextSibling,f=d.firstChild;return z(a,()=>qu()??`?`,null),z(s,()=>{let e=Nn();return e===`empty`?`World is empty — place a spawn to claim this room.`:e===`lost`?`You lost all your spawns — respawn to continue.`:qu()==null?`No controller — roads and containers only.`:`RCL ${qu()} — Select a structure type and click a tile to build.`}),z(c,h(l,{each:t,children:e=>{let t=()=>qu()??0,n=()=>p(e,t()),r=()=>$u()[e]??0,i=()=>rf().structureType===e,a=()=>n()===2500,s=()=>!a()&&m(e,t())<=0;return h(u,{get when(){return n()>0},get children(){var t=Ig(),c=t.firstChild,l=c.nextSibling;return t.$$click=()=>!s()&&y(e),z(c,()=>e.replace(/([A-Z])/g,` $1`).trim(),null),z(c,()=>i()&&` ✓`,null),z(l,(()=>{var e=N(()=>!!a());return()=>e()?`${r()}/∞`:`${r()}/${n()}`})(),null),z(l,()=>s()&&` (Max)`,null),o(e=>{var n=i()?`#1f3158`:`transparent`,r=s()?`default`:`pointer`,a=s()?.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,h(u,{get when(){return g()},get children(){var e=Pg(),t=e.firstChild.nextSibling,r=t.firstChild.firstChild,a=r.nextSibling;return r.$$input=e=>v(e.currentTarget.value),z(a,x),z(t,h(u,{get when(){return N(()=>n()===`invalid`)()&&i()},get children(){var e=Ng();return z(e,i),e}}),null),o(e=>R(r,`border`,`1px solid ${n()===`invalid`?`#f85149`:n()===`valid`?`#238636`:`#30363d`}`)),o(()=>r.value=rf().structureName??``),e}}),d),z(f,()=>rf().structureType?`Click a tile in the room to build.`:`Select a structure type, then click a tile.`),e})()}F([`input`,`click`]);var Rg=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">`),zg=P(`<button type=button>`),Bg=P(`<option>/s`),Vg=[.5,1,2,5,10,20],Hg=[{delta:-100,label:`-100`},{delta:-10,label:`-10`}],Ug=[{delta:10,label:`+10`},{delta:100,label:`+100`}];function Wg(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 Gg(){let e=()=>{let e=bd(),t=gd(),n=Cn()??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=Rg(),n=t.firstChild.firstChild,r=n.firstChild,i=r.nextSibling;i.firstChild;var a=n.nextSibling,s=a.firstChild,c=a.nextSibling.firstChild.nextSibling;return z(r,(()=>{var e=N(()=>!!Ed());return()=>e()?`Loading…`:`Tick ${gd()}`})()),z(i,e,null),z(a,h(l,{each:Hg,children:e=>(()=>{var t=zg();return t.$$click=()=>Pd(e.delta),z(t,()=>e.label),o(e=>{var n=Ed(),r=Wg(Ed());return n!==e.e&&(t.disabled=e.e=n),e.t=L(t,r,e.t),e},{e:void 0,t:void 0}),t})()}),s),Ce(s,`click`,Fd,!0),z(s,()=>Sd()?`⏸`:`▶`),z(a,h(l,{each:Ug,children:e=>(()=>{var t=zg();return t.$$click=()=>Pd(e.delta),z(t,()=>e.label),o(e=>{var n=Ed(),r=Wg(Ed());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),c.addEventListener(`change`,e=>Id(parseFloat(e.currentTarget.value))),z(c,h(l,{each:Vg,children:e=>(()=>{var t=Bg(),n=t.firstChild;return t.value=e,z(t,e,n),t})()})),o(e=>{var t=Ed()?`#f0883e`:`#c9d1d9`,n=Ed(),i=Sd()?`#1a3a2a`:`#161b22`,a=Sd()?`#3fb950`:`#8b949e`,o=Ed()?`not-allowed`:`pointer`;return t!==e.e&&R(r,`color`,e.e=t),n!==e.t&&(s.disabled=e.t=n),i!==e.a&&R(s,`background`,e.a=i),a!==e.o&&R(s,`color`,e.o=a),o!==e.i&&R(s,`cursor`,e.i=o),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),o(()=>c.value=wd()),t})()}F([`click`]);var Kg=P(`<div style=padding-bottom:8px;overflow:auto;min-height:0>`),qg=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`),Jg=P(`<button style=background:transparent;border:none;color:#8b949e;font-size:14px;cursor:pointer;padding:4px>`),Yg=P(`<button style=background:transparent;border:none;color:#8b949e;font-size:11px;cursor:pointer>Collapse`);function Xg(e){return h(u,{get when(){return Yd()===`flag`},get fallback(){return h(u,{get when(){return Yd()===`build`},get fallback(){return h(Jm,{})},get children(){return h(Lg,{get shard(){return e.shard}})}})},get children(){return h(kg,{})}})}function Zg(e){let t=()=>{e.onToggle?.()},n=t=>{t.stopPropagation(),e.onToggle?.()};return(()=>{var r=qg(),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=Jg();return t.$$click=n,z(t,()=>e.isCollapsed?`▶`:`◀`),t})()})()),z(o,(()=>{var t=N(()=>!!e.onToggle);return()=>t()&&(()=>{var e=Yg();return e.$$click=n,e})()})(),null),z(a,h(u,{get when(){return e.mapMode},get fallback(){return h(oh,{get room(){return e.room??`—`},get shard(){return e.shard??null}})},get children(){return h($h,{get zoom(){return e.mapZoom},get subsActive(){return e.mapSubsActive}})}}),null),z(a,h(u,{get when(){return N(()=>!e.mapMode)()&&Z()},get children(){return h(Gg,{})}}),null),z(a,h(u,{get when(){return e.mapMode},get fallback(){return h(Xg,{get shard(){return e.shard}})},get children(){var t=Kg();return z(t,h(bg,{label:`Selected`,get info(){return e.selectedRoomInfo??null}}),null),z(t,h(bg,{label:`Cursor`,get info(){return e.hoveredRoomInfo??null},dim:!0}),null),t}}),null),r})()}F([`click`]);var Qg=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>CPU:</span><span style=color:#c9d1d9>`),$g=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Memory:</span><span style=color:#c9d1d9>`),e_=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Zoom:</span><span style=color:#c9d1d9>%`),t_=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Subs:</span><span>`),n_=P(`<div style="display:flex;gap:16px;padding:6px 16px;font-size:12px;color:#8b949e;align-items:center">`);function r_(e){let[t,r]=s(null);n(()=>{let e=W();if(!e)return;let t=new Ct;t.add(e.stores.user.subscribe(`cpu`)),t.add(e.stores.user.on(`user:cpu`,e=>{r(e)})),a(()=>{t.dispose()})});let i=()=>{let e=t();if(!e)return`—`;let n=G()?.cpu??`?`;return`${e.cpu.toFixed(0)} / ${n}`},c=()=>{let e=t();return e?`${(e.memory/1024).toFixed(1)} KB`:`—`};return(()=>{var n=n_();return z(n,h(u,{get when(){return t()!==null},get children(){return[(()=>{var e=Qg(),t=e.firstChild.nextSibling;return z(t,i),e})(),(()=>{var e=$g(),t=e.firstChild.nextSibling;return z(t,c),e})()]}}),null),z(n,h(u,{get when(){return N(()=>e.mapZoom!==null)()&&e.mapZoom!==void 0},get children(){return[(()=>{var t=e_(),n=t.firstChild.nextSibling,r=n.firstChild;return z(n,()=>(e.mapZoom*100).toFixed(0),r),t})(),(()=>{var t=t_(),n=t.firstChild.nextSibling;return z(n,()=>e.mapSubsActive===!1?`paused`:`active`),o(t=>R(n,`color`,e.mapSubsActive===!1?`#e3b341`:`#3fb950`)),t})()]}}),null),n})()}var i_=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">`),a_=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>`),o_=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">`),s_=P(`<button style=width:100%;aspect-ratio:1;border-radius:2px;cursor:pointer;padding:0;outline:none>`),c_={};for(let e=1;e<=24;e++){let t=Ut({type:e,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1});c_[e]=`data:image/svg+xml,${encodeURIComponent(t)}`}function l_(e){return typeof e==`string`?e:Vt[e]?.rgb??`#000000`}function u_(e){return typeof e==`number`?Math.max(0,Math.min(79,e)):e}var d_=[{slot:1,label:`Background`},{slot:2,label:`Primary`},{slot:3,label:`Secondary`}],f_=Array.from({length:24},(e,t)=>t+1),p_=/^#[0-9a-f]{6}$/i;function m_(e){let[t,n]=s(p(()=>typeof e.badge.type==`number`?e.badge.type:1)),[r,i]=s(p(()=>u_(e.badge.color1))),[a,c]=s(p(()=>u_(e.badge.color2))),[u,m]=s(p(()=>u_(e.badge.color3))),[g,_]=s(p(()=>e.badge.param??0)),[v,y]=s(p(()=>e.badge.flip??!1)),[b,x]=s(1),[S,C]=s(!1),[w,T]=s(p(()=>l_(u_(e.badge.color1)))),E=e=>e===1?r():e===2?a():u(),D=e=>{let t=b();t===1?i(e):t===2?c(e):m(e)};f(()=>{T(l_(E(b())))});let O=e=>{let t=E(b());return typeof t==`number`?t===e:t.toLowerCase()===(Vt[e]?.rgb??``).toLowerCase()},k=()=>({type:t(),color1:l_(r()),color2:l_(a()),color3:l_(u()),param:g(),flip:v()}),ee=d(()=>{let e=Ut(k());return`data:image/svg+xml,${encodeURIComponent(e)}`}),te=e=>{if(T(e),!p_.test(e))return;let t=Vt.findIndex(t=>t.rgb.toLowerCase()===e.toLowerCase());D(t>=0?t:e)},ne=async()=>{let t=W();if(t){C(!0);try{await t.http.user.badge(k()),await t.stores.user.refreshMe(),e.onClose(),e.onSaved?.(),V(`Badge saved`,`success`,3e3)}catch(e){V(`Failed to save badge: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}finally{C(!1)}}},A=t=>{t.target===t.currentTarget&&e.onClose()};return(()=>{var r=i_(),i=r.firstChild.firstChild,a=i.firstChild.nextSibling,s=i.nextSibling,c=s.firstChild,u=c.firstChild,d=u.firstChild.nextSibling,f=u.nextSibling.firstChild.nextSibling,p=c.nextSibling,m=p.firstChild.nextSibling,C=m.nextSibling,T=C.nextSibling.firstChild,k=T.nextSibling,j=p.nextSibling,re=j.firstChild,ie=re.firstChild.nextSibling,M=re.nextSibling,ae=j.nextSibling.firstChild,oe=s.nextSibling.firstChild,se=oe.nextSibling;return r.$$click=A,a.$$click=()=>e.onClose(),z(a,h(oi,{size:18})),z(f,h(l,{each:f_,children:e=>(()=>{var r=a_(),i=r.firstChild;return r.$$click=()=>n(e),o(n=>{var a=t()===e?`#1f3a2a`:`#0d1117`,o=`1px solid ${t()===e?`#238636`:`#21262d`}`,s=t()===e?ee():c_[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(m,h(l,{each:d_,children:({slot:e,label:t})=>(()=>{var n=o_(),r=n.firstChild;return n.$$click=()=>x(e),z(n,t,null),o(t=>{var i=`1px solid ${b()===e?`#58a6ff`:`#30363d`}`,a=b()===e?`#1c2d47`:`transparent`,o=b()===e?`#58a6ff`:`#8b949e`,s=l_(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(C,h(l,{each:Vt,children:e=>(()=>{var t=s_();return t.$$click=()=>D(e.index),o(n=>{var r=e.rgb,i=e.rgb,a=O(e.index)?`2px solid #fff`:`1px solid transparent`;return r!==n.e&&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})()})),k.$$input=e=>te(e.currentTarget.value),z(ie,g),M.$$input=e=>_(+e.currentTarget.value),ae.addEventListener(`change`,e=>y(e.currentTarget.checked)),oe.$$click=()=>e.onClose(),se.$$click=ne,z(se,()=>S()?`Saving…`:`Save Badge`),o(e=>{var t=ee(),n=p_.test(w())?w():l_(E(b())),r=`1px solid ${p_.test(w())?`#30363d`:`#f85149`}`,i=S(),a=S()?`not-allowed`:`pointer`,o=S(),s=S()?`not-allowed`:`pointer`,c=S()?.7:1;return t!==e.e&&I(d,`src`,e.e=t),n!==e.t&&R(T,`background`,e.t=n),r!==e.a&&R(k,`border`,e.a=r),i!==e.o&&(oe.disabled=e.o=i),a!==e.i&&R(oe,`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}),o(()=>k.value=w()),o(()=>M.value=g()),o(()=>ae.checked=v()),r})()}F([`click`,`input`]);var h_=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">`),g_=P(`<div style=font-size:11px;color:#8b949e;margin-top:3px>`),__=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>`),v_=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>`),y_=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)`),b_=P(`<img width=40 height=40 style=display:block>`),x_=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">`),S_=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">`),C_=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>`),w_={type:1,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1};function T_(e){return(()=>{var t=h_(),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=g_();return z(t,()=>e.description),t})()})(),null),i.$$click=()=>e.onChange(!e.value),o(t=>{var n=e.value?`#238636`:`#30363d`,r=e.value?`22px`:`2px`;return n!==t.e&&R(i,`background`,t.e=n),r!==t.t&&R(a,`left`,t.t=r),t},{e:void 0,t:void 0}),t})()}function E_(e){return(()=>{var t=__(),n=t.firstChild;return z(n,()=>e.title),z(t,()=>e.children,null),t})()}function D_(e){return(()=>{var t=v_(),n=t.firstChild,r=n.nextSibling;return z(n,()=>e.label),z(r,()=>e.value),t})()}function O_(e){let t=Qt(),n=!Tn()&&!G()?.badge,[r,i]=s(n),[a,c]=s(!1),l=d(()=>{let e=G()?.badge;if(!e)return null;let t=Ut(e);return`data:image/svg+xml,${encodeURIComponent(t)}`});async function f(){c(!0);try{await fn(),V(`All caches cleared. Reloading…`,`success`,2e3),setTimeout(()=>window.location.reload(),1500)}catch{V(`Failed to clear caches.`,`error`),c(!1)}}return(()=>{var s=C_(),c=s.firstChild,d=c.firstChild.nextSibling,p=c.nextSibling,m=p.firstChild;return d.$$click=()=>e.onClose(),z(d,h(oi,{size:18})),z(s,h(u,{get when(){return r()},get children(){return h(m_,{get badge(){return G()?.badge??w_},onClose:()=>i(!1),onSaved:n?()=>e.onClose():void 0})}}),p),z(m,h(E_,{title:`Layout`,get children(){return h(T_,{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 zl()},onChange:Bl})}}),null),z(m,h(E_,{title:`Room View`,get children(){return[h(T_,{label:`Terrain effects`,description:`Swamp glow and wall noise texture overlay.`,get value(){return ql()},onChange:Jl}),h(T_,{label:`Room decorations`,description:`Load player-activated theme decorations (floor, wall, road colors) from the server.`,get value(){return Yl()},onChange:Xl}),h(T_,{label:`Dark overlay + lights`,description:`Darken the room and add per-object light glows.`,get value(){return Zl()},onChange:Ql}),(()=>{var e=y_(),t=e.firstChild.nextSibling;return t.addEventListener(`change`,e=>nu(e.currentTarget.value)),o(()=>t.value=tu()),e})()]}}),null),z(m,h(u,{get when(){return!Tn()},get children(){return h(E_,{title:`Player Badge`,get children(){var e=x_(),t=e.firstChild,n=t.firstChild,r=t.nextSibling;return z(t,h(u,{get when(){return l()},get children(){var e=b_();return o(()=>I(e,`src`,l())),e}}),n),z(n,()=>G()?.username??``),r.$$click=()=>i(!0),z(r,()=>l()?`Edit Badge`:`Create Badge`),e}})}}),null),z(m,h(E_,{title:`Data`,get children(){var e=S_(),t=e.firstChild;t.firstChild.nextSibling;var n=t.nextSibling;return n.$$click=f,z(n,()=>a()?`Clearing…`:`Clear`),o(e=>{var t=a(),r=a()?`#8b949e`:`#f85149`,i=a()?`default`:`pointer`,o=a()?.6:1;return t!==e.e&&(n.disabled=e.e=t),r!==e.t&&R(n,`color`,e.t=r),i!==e.a&&R(n,`cursor`,e.a=i),o!==e.o&&R(n,`opacity`,e.o=o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e}}),null),z(m,h(E_,{title:`About`,get children(){return[h(D_,{label:`Client version`,get value(){return Zt()}}),N(()=>t&&h(D_,{label:`Mod version`,get value(){return`${t.version} (${t.kind})`}}))]}}),null),s})()}F([`click`]);var k_=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">`),A_=15e3;function j_(e){let t,r=()=>{t!==void 0&&(clearTimeout(t),t=void 0)},i=()=>{r(),t=setTimeout(()=>e.onClose(),A_)};return n(i),a(r),(()=>{var t=k_(),n=t.firstChild,a=n.nextSibling;return t.addEventListener(`mouseleave`,i),t.addEventListener(`mouseenter`,r),n.$$click=()=>e.onClose(),z(n,h(oi,{size:16})),o(()=>a.innerHTML=e.text),t})()}F([`click`]);var M_=P(`<img width=20 height=20 style=display:block;border-radius:3px>`),N_=P(`<span>Settings`),P_=P(`<span>`),F_=P(`<span>Respawn`),I_=P(`<span>Logout`),L_=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">`),R_=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">`),z_=P(`<div style=font-size:12px;color:#f85149;margin-bottom:12px>`),B_=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">`),V_=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>`),H_=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">`),U_=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 W_(e){let[t,n]=s(!1),[r,i]=s(!1),[c,l]=s(!1),[p,m]=s(!1),[g,_]=s(``),[v,y]=s(``),[b,x]=s(``),[S,C]=s(!1),w=()=>Dn()===`password`||Dn()===`steam`,T=()=>G()?.password===!0,E=d(()=>T()&&g().length===0?`Enter your current password.`:v().length<8?`New password must be at least 8 characters.`:v()===b()?null:`Passwords don't match.`),D,O=d(()=>{let e=G()?.badge;return e?`data:image/svg+xml,${encodeURIComponent(Ut(e))}`:null});f(()=>{if(!t())return;let e=e=>{D&&!D.contains(e.target)&&n(!1)},r=e=>{e.key===`Escape`&&n(!1)};document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,r),a(()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,r)})});function k(){let e=W();e&&(l(!0),e.http.user.respawn().then(()=>{V(`Respawn successful`,`success`),Hn()}).catch(e=>V(`Respawn failed: ${e.message}`,`error`)).finally(()=>{l(!1),i(!1)}))}function ee(){_(``),y(``),x(``),m(!0)}function te(){let e=W();if(!e||E())return;let t=!T();C(!0),e.http.user.password(v(),g()).then(()=>{V(t?`Password set`:`Password changed`,`success`),m(!1),t&&e.stores.user.refreshMe()}).catch(e=>V(`Password ${t?`setup`:`change`} failed: ${e.message}`,`error`)).finally(()=>C(!1))}return(()=>{var a=V_(),s=a.firstChild,l=s.firstChild;return Ee(e=>D=e,a),s.$$click=()=>n(e=>!e),z(s,h(u,{get when(){return O()},get children(){var e=M_();return o(()=>I(e,`src`,O())),e}}),l),z(l,()=>G()?.username??`…`),z(s,h(fr,{size:14}),null),z(a,h(u,{get when(){return t()},get children(){var t=L_();return z(t,h(K_,{onClick:()=>{n(!1),e.onOpenSettings()},get children(){return[h(ei,{size:15}),N_()]}}),null),z(t,h(u,{get when(){return w()},get children(){return h(K_,{onClick:()=>{n(!1),ee()},get children(){return[h(Or,{size:15}),(()=>{var e=P_();return z(e,()=>T()?`Change password`:`Set password`),e})()]}})}}),null),z(t,h(K_,{onClick:()=>{n(!1),i(!0)},get children(){return[h(Qr,{size:15}),F_()]}}),null),z(t,h(K_,{onClick:()=>{n(!1),Qn()},danger:!0,get children(){return[h(Rr,{size:15}),I_()]}}),null),t}}),null),z(a,h(u,{get when(){return r()},get children(){var e=R_(),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()&&i(!1)},n.$$click=()=>i(!1),r.$$click=k,z(r,()=>c()?`Respawning…`:`Respawn`),o(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(a,h(u,{get when(){return p()},get children(){var e=B_(),t=e.firstChild,n=t.firstChild,r=n.nextSibling,i=r.firstChild,a=i.nextSibling;return e.$$click=e=>{e.target===e.currentTarget&&!S()&&m(!1)},t.addEventListener(`submit`,e=>{e.preventDefault(),te()}),z(n,()=>T()?`Change password`:`Set password`),z(t,h(u,{get when(){return T()},get children(){return h(G_,{label:`Current password`,get value(){return g()},onInput:_,autofocus:!0})}}),r),z(t,h(G_,{label:`New password`,get value(){return v()},onInput:y,get autofocus(){return!T()}}),r),z(t,h(G_,{label:`Confirm new password`,get value(){return b()},onInput:x}),r),z(t,h(u,{get when(){return N(()=>!!E())()&&(v()||b())},get children(){var e=z_();return z(e,E),e}}),r),i.$$click=()=>m(!1),z(a,()=>S()?`Saving…`:`Save`),o(e=>{var t=S(),n=S()?`default`:`pointer`,r=S()||E()!=null,o=S()||E()!=null?`default`:`pointer`,s=S()||E()!=null?.6:1;return t!==e.e&&(i.disabled=e.e=t),n!==e.t&&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),o(e=>R(s,`background`,t()?`#21262d`:`#161b22`)),a})()}function G_(e){return(()=>{var t=H_(),n=t.firstChild,r=n.nextSibling;return z(n,()=>e.label),r.$$input=t=>e.onInput(t.currentTarget.value),o(()=>r.autofocus=e.autofocus),o(()=>r.value=e.value),t})()}function K_(e){let[t,n]=s(!1);return(()=>{var r=U_();return r.addEventListener(`mouseleave`,()=>n(!1)),r.addEventListener(`mouseenter`,()=>n(!0)),r.$$click=()=>e.onClick(),z(r,()=>e.children),o(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 q_(){return`${$t()}/overview`}function J_(){return`${$t()}/profile/`}function Y_(){return window.location.pathname+window.location.search+window.location.hash}function X_(){let e=window.location.pathname;return e===q_()?`overview`:e.startsWith(J_())?`profile`:`game`}function Z_(){let e=window.location.pathname;return e.startsWith(J_())&&decodeURIComponent(e.slice(J_().length))||null}var[Q_,$_]=s(X_()),[ev,tv]=s(Z_()),nv=X_()===`game`?Y_():`${$t()}/map`;function rv(){X_()===`game`&&(nv=Y_())}function iv(){rv(),history.pushState(null,``,q_()),$_(`overview`)}function av(){history.pushState(null,``,nv),$_(`game`)}function ov(e,t){let n=`${$t()}/room/${e}${t?`?shard=${encodeURIComponent(t)}`:``}`;nv=n,history.pushState(null,``,n),$_(`game`)}typeof window<`u`&&window.addEventListener(`popstate`,()=>{$_(X_()),tv(Z_())});var sv=P(`<button style="padding:7px;border-radius:4px;cursor:pointer;margin:0 4px;display:flex;align-items:center">`),cv=P(`<button style="padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;margin:0 2px;display:flex;align-items:center">`),lv=P(`<div style=flex:1;position:relative;overflow:hidden>`),uv=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>`),dv=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>`),fv=P(`<div style=display:flex;flex:1;overflow:hidden><div style=display:flex;flex-direction:column;flex:1;overflow:hidden>`),pv=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>`),mv=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">`),hv=P(`<div style=display:flex;flex-direction:column;flex:1;overflow:hidden><div style=display:flex;flex:1;overflow:hidden>`),gv=i(()=>T(()=>import(`./CodePanel-Bd6QSYMn.js`).then(e=>({default:e.CodePanel})),__vite__mapDeps([2,3]))),_v=i(()=>T(()=>import(`./MapViewer-Dfluj-CU.js`).then(e=>({default:e.MapViewer})),__vite__mapDeps([4,3])));function vv(){let e=$t(),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(!cd(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 yv(e,t){return`${$t()}/room/${e}${t?`?shard=${encodeURIComponent(t)}`:``}`}function bv(e){return`${$t()}/map${e?`?shard=${encodeURIComponent(e)}`:``}`}function xv(){return window.location.pathname.startsWith(`${$t()}/map`)?{shard:new URLSearchParams(window.location.search).get(`shard`)}:null}function Sv(e){return(()=>{var t=sv();return t.$$click=()=>e.onClick(),z(t,()=>e.children),o(n=>{var r=e.title,i=`1px solid ${e.active?`#388bfd`:`#30363d`}`,a=e.active?`#1f3158`:`#21262d`,o=e.active?`#58a6ff`:`#c9d1d9`;return r!==n.e&&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 Cv(e){return(()=>{var t=cv();return t.$$click=()=>e.onClick(),z(t,()=>e.children),o(n=>{var r=e.title,i=e.disabled,a=e.disabled?`#484f58`:`#c9d1d9`,o=e.disabled?`default`:`pointer`;return r!==n.e&&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 wv(){let e=vv(),[t,r]=s(e.room??tn(H.room)??`W1N1`),[i,c]=s(e.shard??tn(H.shard)),[l,d]=s(xv()!==null||!e.room),m=()=>bn()?.serverData?.welcomeText??null,[g,_]=s(!1),v=()=>Tn()&&l()&&!g()&&m()!==null,[y,b]=s(!Tn()&&!G()?.badge),[x,S]=s(!1),[C,w]=s(!1);f(()=>{x(),w(!0),Promise.resolve().then(()=>w(!1))}),f(()=>{Tn()&&Xd(`view`)}),f(()=>{if(i()!==null||Yn()!==!1)return;let e=bn()?.serverData?.shards?.[0];e&&c(e)});let[T,E]=s(void 0),[D,O]=s(null),[k,ee]=s(null),te=tn(H.mapZoom),[ne,A]=s(e.room&&te?Number(te):null),[j,re]=s(null),[ie,M]=s(!1),[ae,oe]=s(!1),se=e.tick;f(()=>{let e=K();if(e===null||se===null)return;let t=se;se=null,jd(e),Nd(t)}),f(()=>{if(p(l))return;let e=yv(t(),i());Z()?history.replaceState(null,``,`${e}#tick=${gd()}`):history.replaceState(null,``,e)});let[ce,le]=s(an(H.sidebarWidth,300)),[ue,de]=s(an(H.sidebarWidth,300)),[fe,pe]=s(an(H.consoleHeight,220)),[me,he]=s(an(H.consoleHeight,220)),[ge,_e]=s(!1),[ve,ye]=s(!1),P=()=>ce()<=32,F=()=>fe()<=32,I=()=>{ce()>32?(de(ce()),le(32)):le(ue())},be=()=>{fe()>32?(he(fe()),pe(32)):pe(me())},xe=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),on(H.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),on(H.consoleHeight,fe()),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},we=(e,t)=>{W()?.stores.navigation.navigateTo(e,t)},L=e=>{E(e),d(!0),history.pushState(null,``,bv(i()))},Te=()=>{l()?(d(!1),O(null),ee(null),history.pushState(null,``,yv(t(),i()))):L(t())};n(()=>{!vv().room&&!xv()&&history.replaceState(null,``,bv(i()));let e=()=>{let e=xv();if(e){d(!0),e.shard!==null&&c(e.shard),p(Z)&&Md();return}let{room:t,shard:n,tick:i}=vv();t&&(r(t),c(n),d(!1),i===null?p(Z)&&Md():se=i)};window.addEventListener(`popstate`,e),a(()=>window.removeEventListener(`popstate`,e));let n=W()?.stores.navigation;if(n){let e=n.on(`navigation:change`,e=>{e.room!==null&&(r(e.room),c(e.shard),d(!1),O(null),ee(null),M(n.canBack()),oe(n.canForward()),nn(H.room,e.room),e.shard?nn(H.shard,e.shard):rn(H.shard),history.pushState(null,``,yv(e.room,e.shard)))});a(()=>e.dispose())}let o=e=>{if(!pd(e.target)){if(e.key===`o`||e.key===`O`){S(e=>!e),b(!1);return}(e.key===`l`||e.key===`L`)&&Ff(),(e.key===`c`||e.key===`C`)&&If(),(e.key===`y`||e.key===`Y`)&&Lf(),l()||(e.key===`1`&&Xd(`view`),Tn()||(e.key===`2`&&Xd(`flag`),e.key===`3`&&Xd(`build`)),e.key===`m`&&L(t()))}};window.addEventListener(`keydown`,o),a(()=>window.removeEventListener(`keydown`,o))});let Ee=()=>(()=>{var e=lv();return z(e,h(u,{get when(){return y()},get children(){return h(O_,{onClose:()=>b(!1)})}}),null),z(e,h(u,{get when(){return x()},get children(){return h(gv,{onClose:()=>S(!1)})}}),null),z(e,h(u,{get when(){return!l()},get fallback(){return h(_v,{get shard(){return i()},get originRoom(){return T()},get initialZoom(){return ne()??void 0},onNavigateToRoom:e=>we(e,i()),onHoveredRoomChanged:O,onSelectedRoomChanged:ee,onZoomChanged:e=>{A(e),on(H.mapZoom,e)},onSubscriptionStateChanged:re})},get children(){return h(bf,{get room(){return t()},get shard(){return i()},onNavigate:we})}}),null),z(e,h(u,{get when(){return v()},get children(){return h(j_,{get text(){return m()},onClose:()=>_(!0)})}}),null),e})(),De=()=>h(u,{get when(){return!Tn()},get children(){var e=uv(),t=e.firstChild;return t.$$pointerdown=Se,z(e,h(kp,{get shard(){return i()},get isCollapsed(){return F()},onToggle:be}),null),o(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=dv(),r=n.firstChild;return r.$$pointerdown=xe,z(n,h(Zg,{get isCollapsed(){return P()},onToggle:I,get mapMode(){return l()},get hoveredRoomInfo(){return D()},get selectedRoomInfo(){return k()},get room(){return t()},get shard(){return i()},get mapZoom(){return ne()},get mapSubsActive(){return j()}}),null),o(t=>{var r=x()?`0`:`${ce()}px`,i=e&&!(C()||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=pv(),t=e.firstChild,n=t.firstChild;return z(t,h(Ui,{}),n),z(t,h(u,{get when(){return!Tn()||l()},get children(){return h(r_,{get mapZoom(){return N(()=>!!l())()?ne():null},get mapSubsActive(){return N(()=>!!l())()?j():null}})}}),n),z(t,h(Cv,{title:`Back`,get disabled(){return!ie()},onClick:()=>W()?.stores.navigation.back(),get children(){return h(gr,{size:16})}}),null),z(t,h(Cv,{title:`Forward`,get disabled(){return!ae()},onClick:()=>W()?.stores.navigation.forward(),get children(){return h(mr,{size:16})}}),null),z(t,h(Sv,{get title(){return l()?`Room View`:`Map`},get active(){return l()},onClick:Te,get children(){return N(()=>!!l())()?h(Mr,{size:16}):h(Br,{size:16})}}),null),z(t,h(u,{get when(){return!Tn()},get children(){return h(Sv,{title:`Overview`,onClick:iv,get children(){return h(Ar,{size:16})}})}}),null),z(t,h(u,{get when(){return!Tn()},get children(){return h(Sv,{title:`Code Editor`,get active(){return x()},onClick:()=>{S(e=>!e),b(!1)},get children(){return h(br,{size:16})}})}}),null),z(t,h(u,{get when(){return!Tn()},get fallback(){return[h(Sv,{title:`Settings`,get active(){return y()},onClick:()=>{b(e=>!e),S(!1)},get children(){return h(ei,{size:16})}}),(()=>{var e=mv();return Ce(e,`click`,Qn,!0),z(e,h(Ir,{size:16})),e})()]},get children(){return h(W_,{onOpenSettings:()=>{b(!0),S(!1)}})}}),null),z(e,h(u,{get when(){return zl()},get fallback(){return(()=>{var e=hv(),t=e.firstChild;return z(t,Ee,null),z(t,()=>Oe(!0),null),z(e,De,null),e})()},get children(){var e=fv(),t=e.firstChild;return z(t,Ee,null),z(t,De,null),z(e,()=>Oe(!1),null),e}}),null),z(e,h(Cf,{}),null),e})()}F([`click`,`pointerdown`]);var Tv=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>`),Ev=`#4DB6AC`,Dv=`#A7FFEB`,Ov=`#C54444`,kv=`#FF9A9A`;function Av(e){let t=2*Math.PI*(76/2),n=()=>`${Math.max(0,Math.min(1,e.fraction))*t} ${t}`;return(()=>{var t=Tv(),r=t.firstChild,i=r.firstChild,a=i.nextSibling,s=r.nextSibling,c=s.firstChild,l=c.nextSibling;return z(c,()=>e.value),z(l,()=>e.label),o(r=>{var o=e.tooltip,c=e.ring,l=e.ring,u=n(),d=e.text;return o!==r.e&&I(t,`title`,r.e=o),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(s,`color`,r.i=d),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),t})()}var jv=P(`<img alt style=display:block;border-radius:3px;flex-shrink:0>`);function Mv(e){let t=()=>e.badge?`data:image/svg+xml,${encodeURIComponent(Ut(e.badge))}`:null;return h(u,{get when(){return t()},get children(){var n=jv();return o(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 Nv=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">`),Pv=3;function Fv(e,t,n,r){if(!t.length)return;e.fillStyle=Lh(n);let i=Pv-r*2;for(let[n,a]of t)e.fillRect(n*Pv+r,a*Pv+r,i,i)}function Iv(e,t,n,r){if(t.length){e.fillStyle=Lh(n),e.beginPath();for(let[n,i]of t){let t=(n+.5)*Pv,a=(i+.5)*Pv;e.moveTo(t+r,a),e.arc(t,a,r,0,Math.PI*2)}e.fill()}}function Lv(e){let t,r=null,i=null,s=()=>{let e=t?.getContext(`2d`);if(!e)return;if(e.setTransform(2,0,0,2,0,0),e.fillStyle=Lh(Dh),e.fillRect(0,0,150,150),r){let t=r.raw;e.fillStyle=Lh(Oh);for(let n=0;n<2500;n++)t[n]===it.Wall&&e.fillRect(n%50*Pv,Math.floor(n/50)*Pv,Pv,Pv);e.fillStyle=Lh(kh);for(let n=0;n<2500;n++)t[n]===it.Swamp&&e.fillRect(n%50*Pv,Math.floor(n/50)*Pv,Pv,Pv)}let n=i;if(n){Fv(e,n.r??[],Ah,0),Fv(e,n.w??[],jh,.5);for(let t of Fh)Iv(e,n[t.key]??[],t.color,t.radius);let t=n,r=G()?._id;for(let n in t){if(Ih.has(n))continue;let i=t[n];!Array.isArray(i)||i.length===0||Iv(e,i,n===r?Nh:Ph,1.2)}}};return n(()=>{let t=W();if(!t)return;t.stores.room.terrain(e.room,e.shard).then(e=>{r=e,s()}).catch(()=>{});let n=t.stores.map.subscribeMap2(e.room,e.shard),o=t.stores.map.map2data(e.room,e.shard);o&&(i=o,s());let c=t.stores.map.on(`room:map2update`,({room:t,shard:n,data:r})=>{t!==e.room||(n??null)!==(e.shard??null)||(i=r,s())});a(()=>{n.dispose(),c.dispose()})}),(()=>{var n=Nv(),r=n.firstChild,i=r.nextSibling;return n.$$click=()=>e.onClick?.(),Ee(e=>t=e,r),I(r,`width`,300),I(r,`height`,300),R(r,`width`,`150px`),R(r,`height`,`150px`),z(i,()=>e.room),o(()=>I(n,`title`,e.room+(e.shard?` · ${e.shard}`:``))),n})()}F([`click`]);var Rv=2.4,zv=1e6,Bv=1e3;function Vv(e){return Math.floor((e/zv)**(1/Rv))+1}function Hv(e){let t=Vv(e),n=(t-1)**Rv*zv,r=t**Rv*zv;return{level:t,current:e-n,total:r-n}}function Uv(e){return Math.floor((e/Bv)**(1/2))}function Wv(e){let t=Uv(e),n=t**2*Bv,r=(t+1)**2*Bv;return{level:t,current:e-n,total:r-n}}function Gv(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 Kv=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>`),qv=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>`),Jv=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 disabled title="Not available yet"style="padding:5px 10px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#8b949e;font-size:12px;cursor:default;opacity:0.7">Manage Power Creeps</button></div></div></div><div style=display:flex;gap:10px>`),Yv=6e4,Xv=8,Zv=`#161b22`,Qv=`#30363d`,$v=[{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 ey(e){return(()=>{var t=Kv(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return z(n,()=>e.l1,r),z(n,()=>e.l2,null),z(i,()=>Gv(e.value)),o(t=>R(i,`color`,e.color)),t})()}function ty(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 ny(){let[e,t]=s(null),[r,i]=s([]),c=!1;f(()=>{let e=W(),t=G()?._id;!e||!t||c||(c=!0,e.http.user.rooms(t).then(e=>i(ty(e))).catch(()=>{c=!1}))}),n(()=>{let e=W();if(!e)return;let n=null,r=()=>e.http.user.overview(Xv,`energyHarvested`).then(e=>t(e.totals??null));r().then(()=>{n=setInterval(()=>{e.stores.user.refreshMe().catch(()=>{}),r().catch(()=>{})},Yv)}).catch(()=>{}),a(()=>{n&&clearInterval(n)})});let d=()=>Hv(G()?.gcl??0),p=()=>Wv(G()?.power??0),m=e=>e.total>0?e.current/e.total:0,g=e=>`Next level: ${Math.floor(e.current).toLocaleString()} / ${Math.floor(e.total).toLocaleString()}`,_={flex:1,display:`flex`,"align-items":`center`,gap:`16px`,background:Zv,border:`1px solid ${Qv}`,"border-radius":`6px`,padding:`16px`};return(()=>{var t=Jv(),n=t.firstChild,i=n.firstChild,a=i.firstChild,s=a.nextSibling,c=s.nextSibling.nextSibling,f=c.firstChild,v=i.nextSibling,y=v.firstChild,b=y.firstChild,x=b.firstChild.nextSibling.firstChild,S=x.firstChild.nextSibling,C=x.nextSibling.firstChild.nextSibling,w=y.nextSibling,T=w.firstChild;T.firstChild.nextSibling;var E=v.nextSibling;return z(i,h(Mv,{get badge(){return G()?.badge},size:28}),a),z(s,()=>G()?.username),Ce(c,`click`,av,!0),z(c,h(gr,{size:16}),f),z(y,h(Av,{get value(){return d().level},label:`GCL`,ring:Ev,text:Dv,get fraction(){return m(d())},get tooltip(){return g(d())}}),b),z(S,()=>d().level),z(C,()=>G()?.cpu??`—`),z(w,h(Av,{get value(){return p().level},label:`GPL`,ring:Ov,text:kv,get fraction(){return m(p())},get tooltip(){return g(p())}}),T),z(E,h(l,{each:$v,children:t=>h(ey,{get l1(){return t.l1},get l2(){return t.l2},get color(){return t.color},get value(){return e()?.[t.key]}})})),z(n,h(u,{get when(){return r().length},get children(){var e=qv(),t=e.firstChild.nextSibling;return z(t,h(l,{get each(){return r()},children:e=>h(Lv,{get room(){return e.room},get shard(){return e.shard},onClick:()=>ov(e.room,e.shard)})})),e}}),null),o(e=>{var t=_,n=_;return e.e=L(y,t,e.e),e.t=L(w,n,e.t),e},{e:void 0,t:void 0}),t})()}F([`click`]);var ry=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`),iy=P(`<div style=color:#8b949e;text-align:center;padding:40px>Loading…`),ay=P(`<div style=color:#8b949e;text-align:center;font-size:18px;padding:40px>User not found`),oy=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 sy(){let[e]=y(()=>ev(),async e=>{let t=W();if(!t)return null;try{return(await t.http.user.find({username:e})).user??null}catch{return null}}),t=()=>Hv(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=ry(),a=i.firstChild,o=a.firstChild.firstChild.nextSibling,s=o.firstChild;return Ce(o,`click`,av,!0),z(o,h(gr,{size:16}),s),z(a,h(u,{get when(){return!e.loading},get fallback(){return iy()},get children(){return h(u,{get when(){return e()},get fallback(){return ay()},children:e=>(()=>{var i=oy(),a=i.firstChild,o=a.firstChild,s=o.nextSibling;return s.firstChild,z(i,h(Mv,{get badge(){return e().badge},size:64}),a),z(o,()=>e().username),z(s,()=>t().level,null),z(i,h(Av,{get value(){return t().level},label:`GCL`,ring:Ev,text:Dv,get fraction(){return n(t())},get tooltip(){return r(t())}}),null),i})()})}}),null),i})()}F([`click`]);var cy=P(`<div style=width:100%;height:100%>`),{log:ly}=en(`app`);function uy(){let e=new URLSearchParams(window.location.search).get(`guest`);return e===null?null:e.startsWith(`http`)?e:ln(U.url)??`https://screeps.com`}function dy(){if(Yt()||uy()!==null)return!0;let e=Jt()?Xt():ln(U.url),t=ln(U.token);return!!(e&&t)}function fy(){let e=()=>hn()===`connected`&&W()!==null,[t,r]=s(dy());return n(async()=>{try{if(hn()===`idle`&&(await Zn().catch(()=>{}),hn()!==`connected`)){if(Yt()){let e=Xt();ly(`xxscreeps mode — auto-connecting as guest to ${e}`),await Xn({url:e,auth:`guest`,storage:null}).catch(()=>{})}else if(!Jt()){let e=uy();e&&(ly(`?guest param — auto-connecting as guest to ${e}`),await Xn({url:e,auth:`guest`,storage:null}).catch(()=>{}))}}}finally{r(!1)}}),(()=>{var n=cy();return z(n,(()=>{var n=N(()=>!!e());return()=>n()?N(()=>Q_()===`overview`)()?h(ny,{}):N(()=>Q_()===`profile`)()?h(sy,{}):h(wv,{}):N(()=>!!t())()?h(Bi,{}):h(Ri,{})})()),n})()}var py=document.getElementById(`root`);if(!py)throw Error(`Root element not found`);ye(()=>h(fy,{}),py);export{Ee as S,V as _,dd as a,R as b,cd as c,Gl as d,W as f,en as g,kn as h,ld as i,Ul as l,G as m,sh as n,fd as o,An as p,md as r,sd as s,Yh as t,ru as u,F as v,P as x,z as y};