// ==UserScript== // @name Swarm MMO 助手 // @namespace https://github.com/abangZ/swarm-mmo-scripts // @author abangZ // @license GPL-3.0-only // @homepageURL https://github.com/abangZ/swarm-mmo-scripts // @supportURL https://github.com/abangZ/swarm-mmo-scripts/issues // @downloadURL https://raw.githubusercontent.com/abangZ/swarm-mmo-scripts/main/dist/swarm-mmo.user.js // @updateURL https://raw.githubusercontent.com/abangZ/swarm-mmo-scripts/main/dist/swarm-mmo.meta.js // @version 0.15.14 // @description 分区自动扩张与集结进攻,共享兵力预算、独立派兵队列与运行日志 // @match https://www.swarm-mmo.com/play* // @match https://swarm-mmo.com/play* // @run-at document-idle // @grant none // @sandbox raw // ==/UserScript== // Copyright (C) 2026 abangZ // SPDX-License-Identifier: GPL-3.0-only // License: https://github.com/abangZ/swarm-mmo-scripts/blob/main/LICENSE // Corresponding source: https://github.com/abangZ/swarm-mmo-scripts // Third-party notices: https://github.com/abangZ/swarm-mmo-scripts/blob/main/THIRD_PARTY_NOTICES.md "use strict";(()=>{var ty=Object.create;var Cd=Object.defineProperty;var ey=Object.getOwnPropertyDescriptor;var ny=Object.getOwnPropertyNames;var iy=Object.getPrototypeOf,ay=Object.prototype.hasOwnProperty;var bn=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var ly=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ny(e))!ay.call(t,a)&&a!==n&&Cd(t,a,{get:()=>e[a],enumerable:!(i=ey(e,a))||i.enumerable});return t};var ht=(t,e,n)=>(n=t!=null?ty(iy(t)):{},ly(e||!t||!t.__esModule?Cd(n,"default",{value:t,enumerable:!0}):n,t));var Ud=bn(kt=>{"use strict";/** * @license React * scheduler.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */function or(t,e){var n=t.length;t.push(e);t:for(;0>>1,a=t[i];if(0>>1;iHs(o,n))uHs(d,o)?(t[i]=d,t[u]=n,i=u):(t[i]=o,t[s]=n,i=s);else if(uHs(d,n))t[i]=d,t[u]=n,i=u;else break t}}return e}function Hs(t,e){var n=t.sortIndex-e.sortIndex;return n!==0?n:t.id-e.id}kt.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(Nd=performance,kt.unstable_now=function(){return Nd.now()}):(ar=Date,Id=ar.now(),kt.unstable_now=function(){return ar.now()-Id});var Nd,ar,Id,Qn=[],si=[],sy=1,Pe=null,ge=3,ur=!1,Al=!1,zl=!1,rr=!1,Dd=typeof setTimeout=="function"?setTimeout:null,_d=typeof clearTimeout=="function"?clearTimeout:null,Rd=typeof setImmediate<"u"?setImmediate:null;function Us(t){for(var e=Sn(si);e!==null;){if(e.callback===null)Bs(si);else if(e.startTime<=t)Bs(si),e.sortIndex=e.expirationTime,or(Qn,e);else break;e=Sn(si)}}function cr(t){if(zl=!1,Us(t),!Al)if(Sn(Qn)!==null)Al=!0,ya||(ya=!0,va());else{var e=Sn(si);e!==null&&fr(cr,e.startTime-t)}}var ya=!1,Cl=-1,kd=5,qd=-1;function Hd(){return rr?!0:!(kt.unstable_now()-qdt&&Hd());){var i=Pe.callback;if(typeof i=="function"){Pe.callback=null,ge=Pe.priorityLevel;var a=i(Pe.expirationTime<=t);if(t=kt.unstable_now(),typeof a=="function"){Pe.callback=a,Us(t),e=!0;break e}Pe===Sn(Qn)&&Bs(Qn),Us(t)}else Bs(Qn);Pe=Sn(Qn)}if(Pe!==null)e=!0;else{var l=Sn(si);l!==null&&fr(cr,l.startTime-t),e=!1}}break t}finally{Pe=null,ge=n,ur=!1}e=void 0}}finally{e?va():ya=!1}}}var va;typeof Rd=="function"?va=function(){Rd(lr)}:typeof MessageChannel<"u"?(sr=new MessageChannel,Od=sr.port2,sr.port1.onmessage=lr,va=function(){Od.postMessage(null)}):va=function(){Dd(lr,0)};var sr,Od;function fr(t,e){Cl=Dd(function(){t(kt.unstable_now())},e)}kt.unstable_IdlePriority=5;kt.unstable_ImmediatePriority=1;kt.unstable_LowPriority=4;kt.unstable_NormalPriority=3;kt.unstable_Profiling=null;kt.unstable_UserBlockingPriority=2;kt.unstable_cancelCallback=function(t){t.callback=null};kt.unstable_forceFrameRate=function(t){0>t||125i?(t.sortIndex=n,or(si,t),Sn(Qn)===null&&t===Sn(si)&&(zl?(_d(Cl),Cl=-1):zl=!0,fr(cr,n-i))):(t.sortIndex=a,or(Qn,t),Al||ur||(Al=!0,ya||(ya=!0,va()))),t};kt.unstable_shouldYield=Hd;kt.unstable_wrapCallback=function(t){var e=ge;return function(){var n=ge;ge=e;try{return t.apply(this,arguments)}finally{ge=n}}}});var Yd=bn((WS,Bd)=>{"use strict";Bd.exports=Ud()});var Wd=bn(K=>{"use strict";/** * @license React * react.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var gr=Symbol.for("react.transitional.element"),oy=Symbol.for("react.portal"),uy=Symbol.for("react.fragment"),ry=Symbol.for("react.strict_mode"),cy=Symbol.for("react.profiler"),fy=Symbol.for("react.consumer"),dy=Symbol.for("react.context"),py=Symbol.for("react.forward_ref"),gy=Symbol.for("react.suspense"),hy=Symbol.for("react.memo"),Kd=Symbol.for("react.lazy"),my=Symbol.for("react.activity"),vy=Symbol.for("react.view_transition"),Qd=Symbol.iterator;function yy(t){return t===null||typeof t!="object"?null:(t=Qd&&t[Qd]||t["@@iterator"],typeof t=="function"?t:null)}var Vd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Zd=Object.assign,Jd={};function Sa(t,e,n){this.props=t,this.context=e,this.refs=Jd,this.updater=n||Vd}Sa.prototype.isReactComponent={};Sa.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Sa.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function $d(){}$d.prototype=Sa.prototype;function hr(t,e,n){this.props=t,this.context=e,this.refs=Jd,this.updater=n||Vd}var mr=hr.prototype=new $d;mr.constructor=hr;Zd(mr,Sa.prototype);mr.isPureReactComponent=!0;var Gd=Array.isArray;function pr(){}var Nt={H:null,A:null,T:null,S:null},Pd=Object.prototype.hasOwnProperty;function vr(t,e,n){var i=n.ref;return{$$typeof:gr,type:t,key:e,ref:i!==void 0?i:null,props:n}}function by(t,e){return vr(t.type,e,t.props)}function yr(t){return typeof t=="object"&&t!==null&&t.$$typeof===gr}function Sy(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var Ld=/\/+/g;function dr(t,e){return typeof t=="object"&&t!==null&&t.key!=null?Sy(""+t.key):e.toString(36)}function xy(t){switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:switch(typeof t.status=="string"?t.then(pr,pr):(t.status="pending",t.then(function(e){t.status==="pending"&&(t.status="fulfilled",t.value=e)},function(e){t.status==="pending"&&(t.status="rejected",t.reason=e)})),t.status){case"fulfilled":return t.value;case"rejected":throw t.reason}}throw t}function ba(t,e,n,i,a){var l=typeof t;(l==="undefined"||l==="boolean")&&(t=null);var s=!1;if(t===null)s=!0;else switch(l){case"bigint":case"string":case"number":s=!0;break;case"object":switch(t.$$typeof){case gr:case oy:s=!0;break;case Kd:return s=t._init,ba(s(t._payload),e,n,i,a)}}if(s)return a=a(t),s=i===""?"."+dr(t,0):i,Gd(a)?(n="",s!=null&&(n=s.replace(Ld,"$&/")+"/"),ba(a,e,n,"",function(d){return d})):a!=null&&(yr(a)&&(a=by(a,n+(a.key==null||t&&t.key===a.key?"":(""+a.key).replace(Ld,"$&/")+"/")+s)),e.push(a)),1;s=0;var o=i===""?".":i+":";if(Gd(t))for(var u=0;u{"use strict";tp.exports=Wd()});var ip=bn(he=>{"use strict";/** * @license React * react-dom.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ey=xn();function np(t){var e="https://react.dev/errors/"+t;if(1{"use strict";function ap(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(ap)}catch(t){console.error(t)}}ap(),lp.exports=ip()});var V0=bn(wu=>{"use strict";/** * @license React * react-dom-client.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ft=Yd(),Kg=xn(),Cy=sp();function C(t){var e="https://react.dev/errors/"+t;if(1Na||(t.current=ac[Na],ac[Na]=null,Na--)}function Ot(t,e){Na++,ac[Na]=t.current,t.current=e}var Rn=_n(null),ts=_n(null),Si=_n(null),No=_n(null);function Io(t,e){switch(Ot(Si,e),Ot(ts,t),Ot(Rn,null),e.nodeType){case 9:case 11:t=(t=e.documentElement)&&(t=t.namespaceURI)?Eg(t):0;break;default:if(t=e.tagName,e=e.namespaceURI)e=Eg(e),t=x0(e,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}re(Rn),Ot(Rn,t)}function $a(){re(Rn),re(ts),re(Si)}function lc(t){var e=t.memoizedState;e!==null&&(ll._currentValue=e.memoizedState,Ot(No,t)),e=Rn.current;var n=x0(e,t.type);e!==n&&(Ot(ts,t),Ot(Rn,n))}function Ro(t){ts.current===t&&(re(Rn),re(ts)),No.current===t&&(re(No),ll._currentValue=Ji)}var br,fp;function ri(t){if(br===void 0)try{throw Error()}catch(n){var e=n.stack.trim().match(/\n( *(at )?)/);br=e&&e[1]||"",fp=-1)":-1a||u[i]!==d[a]){var c=` `+u[i].replace(" at new "," at ");return t.displayName&&c.includes("")&&(c=c.replace("",t.displayName)),c}while(1<=i&&0<=a);break}}}finally{Sr=!1,Error.prepareStackTrace=n}return(n=t?t.displayName||t.name:"")?ri(n):""}function Hy(t,e){switch(t.tag){case 26:case 27:case 5:return ri(t.type);case 16:return ri("Lazy");case 13:return t.child!==e&&e!==null?ri("Suspense Fallback"):ri("Suspense");case 19:return ri("SuspenseList");case 0:case 15:return xr(t.type,!1);case 11:return xr(t.type.render,!1);case 1:return xr(t.type,!0);case 31:return ri("Activity");case 30:return ri("ViewTransition");default:return""}}function dp(t){try{var e="",n=null;do e+=Hy(t,n),n=t,t=t.return;while(t);return e}catch(i){return` Error generating stack: `+i.message+` `+i.stack}}var sc=Object.prototype.hasOwnProperty,cf=Ft.unstable_scheduleCallback,Mr=Ft.unstable_cancelCallback,Uy=Ft.unstable_shouldYield,By=Ft.unstable_requestPaint,Qe=Ft.unstable_now,Yy=Ft.unstable_getCurrentPriorityLevel,th=Ft.unstable_ImmediatePriority,eh=Ft.unstable_UserBlockingPriority,Oo=Ft.unstable_NormalPriority,Qy=Ft.unstable_LowPriority,nh=Ft.unstable_IdlePriority,Gy=Ft.log,Ly=Ft.unstable_setDisableYieldValue,vs=null,Ge=null;function gi(t){if(typeof Gy=="function"&&Ly(t),Ge&&typeof Ge.setStrictMode=="function")try{Ge.setStrictMode(vs,t)}catch{}}var Le=Math.clz32?Math.clz32:Vy,Xy=Math.log,Ky=Math.LN2;function Vy(t){return t>>>=0,t===0?32:31-(Xy(t)/Ky|0)|0}var Ls=256,Xs=262144,Ks=4194304;function Li(t){var e=t&42;if(e!==0)return e;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&-t;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function au(t,e,n){var i=t.pendingLanes;if(i===0)return 0;var a=0,l=t.suspendedLanes,s=t.pingedLanes;t=t.warmLanes;var o=i&134217727;return o!==0?(i=o&~l,i!==0?a=Li(i):(s&=o,s!==0?a=Li(s):n||(n=o&~t,n!==0&&(a=Li(n))))):(o=i&~l,o!==0?a=Li(o):s!==0?a=Li(s):n||(n=i&~t,n!==0&&(a=Li(n)))),a===0?0:e!==0&&e!==a&&(e&l)===0&&(l=a&-a,n=e&-e,l>=n||l===32&&(n&4194048)!==0)?e:a}function ys(t,e){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&e)===0}function ih(t,e){(e&8)!==0&&(e|=e&32);var n=t.entangledLanes;if(n!==0)for(t=t.entanglements,n&=e;0n;n++)e.push(t);return e}function bs(t,e){t.pendingLanes|=e,e!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Jy(t,e,n,i,a,l){var s=t.pendingLanes;t.pendingLanes=n,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=n,t.entangledLanes&=n,t.errorRecoveryDisabledLanes&=n,t.shellSuspendCounter=0;var o=t.entanglements,u=t.expirationTimes,d=t.hiddenUpdates;for(n=s&~n;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cc=!1;if(Jn)try{xa={},Object.defineProperty(xa,"passive",{get:function(){cc=!0}}),window.addEventListener("test",xa,xa),window.removeEventListener("test",xa,xa)}catch{cc=!1}var xa,hi=null,hf=null,fo=null;function bh(){if(fo)return fo;var t,e=hf,n=e.length,i,a="value"in hi?hi.value:hi.textContent,l=a.length;for(t=0;t=Ql),Tp=" ",Ap=!1;function xh(t,e){switch(t){case"keyup":return Ib.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Mh(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Ra=!1;function Ob(t,e){switch(t){case"compositionend":return Mh(e);case"keypress":return e.which!==32?null:(Ap=!0,Tp);case"textInput":return t=e.data,t===Tp&&Ap?null:t;default:return null}}function Db(t,e){if(Ra)return t==="compositionend"||!vf&&xh(t,e)?(t=bh(),fo=hf=hi=null,Ra=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Ip(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Rp(t,e){var n=Ip(t);t=0;for(var i;n;){if(n.nodeType===3){if(i=t+n.textContent.length,t<=e&&i>=e)return{node:n,offset:e-t};t=i}t:{for(;n;){if(n.nextSibling){n=n.nextSibling;break t}n=n.parentNode}n=void 0}n=Ip(n)}}function Ah(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Ah(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function zh(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var e=fc(t.document);e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=fc(t.document)}return e}function yf(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}var Qb=Jn&&"documentMode"in document&&11>=document.documentMode,Oa=null,dc=null,Ll=null,pc=!1;function Op(t,e,n){var i=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;pc||Oa==null||Oa!==fc(i)||(i=Oa,"selectionStart"in i&&yf(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Ll&&is(Ll,i)||(Ll=i,i=eu(dc,"onSelect"),0>=s,a-=s,Nn=1<<32-Le(e)+a|n<A?(H=w,w=null):H=w.sibling;var z=f(p,w,g[A],b);if(z===null){w===null&&(w=H);break}t&&w&&z.alternate===null&&e(p,w),r=l(z,r,A),T===null?x=z:T.sibling=z,T=z,w=H}if(A===g.length)return n(p,w),it&&Xn(p,A),x;if(w===null){for(;AA?(H=w,w=null):H=w.sibling;var E=f(p,w,z.value,b);if(E===null){w===null&&(w=H);break}t&&w&&E.alternate===null&&e(p,w),r=l(E,r,A),T===null?x=E:T.sibling=E,T=E,w=H}if(z.done)return n(p,w),it&&Xn(p,A),x;if(w===null){for(;!z.done;A++,z=g.next())z=v(p,z.value,b),z!==null&&(r=l(z,r,A),T===null?x=z:T.sibling=z,T=z);return it&&Xn(p,A),x}for(w=i(w);!z.done;A++,z=g.next())z=m(w,p,A,z.value,b),z!==null&&(t&&(H=z.alternate,H!==null&&w.delete(H.key===null?A:H.key)),r=l(z,r,A),T===null?x=z:T.sibling=z,T=z);return t&&w.forEach(function(_){return e(p,_)}),it&&Xn(p,A),x}function S(p,r,g,b){if(typeof g=="object"&&g!==null&&g.type===Ca&&g.key===null&&g.props.ref===void 0&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case Gs:t:{for(var x=g.key;r!==null;){if(r.key===x){if(x=g.type,x===Ca){if(r.tag===7){n(p,r.sibling),b=a(r,g.props.children),ui(b,g),b.return=p,p=b;break t}}else if(r.elementType===x||typeof x=="object"&&x!==null&&x.$$typeof===fi&&Xi(x)===r.type){n(p,r.sibling),b=a(r,g.props),ui(b,g),b.return=p,p=b;break t}n(p,r);break}else e(p,r);r=r.sibling}g.type===Ca?(b=$i(g.props.children,p.mode,b,g.key),ui(b,g),b.return=p,p=b):(b=go(g.type,g.key,g.props,null,p.mode,b),ui(b,g),b.return=p,p=b)}return s(p);case ql:t:{for(x=g.key;r!==null;){if(r.key===x)if(r.tag===4&&r.stateNode.containerInfo===g.containerInfo&&r.stateNode.implementation===g.implementation){n(p,r.sibling),b=a(r,g.children||[]),b.return=p,p=b;break t}else{n(p,r);break}else e(p,r);r=r.sibling}b=Or(g,p.mode,b),b.return=p,p=b}return s(p);case fi:return g=Xi(g),S(p,r,g,b)}if(Hl(g))return y(p,r,g,b);if(Il(g)){if(x=Il(g),typeof x!="function")throw Error(C(150));return g=x.call(g),h(p,r,g,b)}if(typeof g.then=="function")return S(p,r,js(g),b);if(g.$$typeof===zn)return S(p,r,Ps(p,g),b);Fs(p,g)}return typeof g=="string"&&g!==""||typeof g=="number"||typeof g=="bigint"?(g=""+g,r!==null&&r.tag===6?(n(p,r.sibling),b=a(r,g),b.return=p,p=b):(n(p,r),b=Rr(g,p.mode,b),b.return=p,p=b),s(p)):n(p,r)}return function(p,r,g,b){try{ss=0;var x=S(p,r,g,b);return La=null,x}catch(w){if(w===cl||w===du)throw w;var T=Ne(29,w,null,p.mode);return T.lanes=b,T.return=p,T}}}var ia=Gh(!0),Lh=Gh(!1),di=!1;function Af(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bc(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Mi(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function wi(t,e,n){var i=t.updateQueue;if(i===null)return null;if(i=i.shared,(mt&2)!==0){var a=i.pending;return a===null?e.next=e:(e.next=a.next,a.next=e),i.pending=e,e=ko(t),_h(t,null,n),e}return cu(t,i,e,n),ko(t)}function Kl(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194048)!==0)){var i=e.lanes;i&=t.pendingLanes,n|=i,e.lanes=n,sh(t,n)}}function _r(t,e){var n=t.updateQueue,i=t.alternate;if(i!==null&&(i=i.updateQueue,n===i)){var a=null,l=null;if(n=n.firstBaseUpdate,n!==null){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};l===null?a=l=s:l=l.next=s,n=n.next}while(n!==null);l===null?a=l=e:l=l.next=e}else a=l=e;n={baseState:i.baseState,firstBaseUpdate:a,lastBaseUpdate:l,shared:i.shared,callbacks:i.callbacks},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}var Sc=!1;function Vl(){if(Sc){var t=Ga;if(t!==null)throw t}}function Zl(t,e,n,i){Sc=!1;var a=t.updateQueue;di=!1;var l=a.firstBaseUpdate,s=a.lastBaseUpdate,o=a.shared.pending;if(o!==null){a.shared.pending=null;var u=o,d=u.next;u.next=null,s===null?l=d:s.next=d,s=u;var c=t.alternate;c!==null&&(c=c.updateQueue,o=c.lastBaseUpdate,o!==s&&(o===null?c.firstBaseUpdate=d:o.next=d,c.lastBaseUpdate=u))}if(l!==null){var v=a.baseState;s=0,c=d=u=null,o=l;do{var f=o.lane&-536870913,m=f!==o.lane;if(m?(ct&f)===f:(i&f)===f){f!==0&&f===na&&(Sc=!0),c!==null&&(c=c.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});t:{var y=t,h=o;f=e;var S=n;switch(h.tag){case 1:if(y=h.payload,typeof y=="function"){v=y.call(S,v,f);break t}v=y;break t;case 3:y.flags=y.flags&-65537|128;case 0:if(y=h.payload,f=typeof y=="function"?y.call(S,v,f):y,f==null)break t;v=Tt({},v,f);break t;case 2:di=!0}}f=o.callback,f!==null&&(t.flags|=64,m&&(t.flags|=8192),m=a.callbacks,m===null?a.callbacks=[f]:m.push(f))}else m={lane:f,tag:o.tag,payload:o.payload,callback:o.callback,next:null},c===null?(d=c=m,u=v):c=c.next=m,s|=f;if(o=o.next,o===null){if(o=a.shared.pending,o===null)break;m=o,o=m.next,m.next=null,a.lastBaseUpdate=m,a.shared.pending=null}}while(!0);c===null&&(u=v),a.baseState=u,a.firstBaseUpdate=d,a.lastBaseUpdate=c,l===null&&(a.shared.lanes=0),_i|=s,t.lanes=s,t.memoizedState=v}}function Xh(t,e){if(typeof t!="function")throw Error(C(191,t));t.call(e)}function Kh(t,e){var n=t.callbacks;if(n!==null)for(t.callbacks=null,t=0;tl?l:8;var s=X.T,o={};o.types=s!==null?s.types:null,X.T=o,Yf(t,!1,e,n);try{var u=a(),d=X.S;if(d!==null&&d(o,u),u!==null&&typeof u=="object"&&typeof u.then=="function"){var c=Fb(u,i);Jl(t,e,c,Xe(t))}else Jl(t,e,i,Xe(t))}catch(v){Jl(t,e,{then:function(){},status:"rejected",reason:v},Xe())}finally{vt.p=l,s!==null&&o.types!==null&&(s.types=o.types),X.T=s}}function a1(){}function Tc(t,e,n,i){if(t.tag!==5)throw Error(C(476));var a=mm(t).queue;hm(t,a,e,Ji,n===null?a1:function(){return vm(t),n(i)})}function mm(t){var e=t.memoizedState;if(e!==null)return e;e={memoizedState:Ji,baseState:Ji,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jn,lastRenderedState:Ji},next:null};var n={};return e.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jn,lastRenderedState:n},next:null},t.memoizedState=e,t=t.alternate,t!==null&&(t.memoizedState=e),e}function vm(t){var e=mm(t);e.next===null&&(e=t.alternate.memoizedState),Jl(t,e.next.queue,{},Xe())}function Bf(){return ue(ll)}function ym(){return Gt().memoizedState}function bm(){return Gt().memoizedState}function l1(t){for(var e=t.return;e!==null;){switch(e.tag){case 24:case 3:var n=Xe();t=Mi(n);var i=wi(e,t,n);i!==null&&(Ie(i,e,n),Kl(i,e,n)),e={cache:wf()},t.payload=e;return}e=e.return}}function s1(t,e,n){var i=Xe();n={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},mu(t)?xm(e,n):(n=Sf(t,e,n,i),n!==null&&(Ie(n,t,i),Mm(n,e,i)))}function Sm(t,e,n){var i=Xe();Jl(t,e,n,i)}function Jl(t,e,n,i){var a={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(mu(t))xm(e,a);else{var l=t.alternate;if(t.lanes===0&&(l===null||l.lanes===0)&&(l=e.lastRenderedReducer,l!==null))try{var s=e.lastRenderedState,o=l(s,n);if(a.hasEagerState=!0,a.eagerState=o,Ke(o,s))return cu(t,e,a,0),Et===null&&ru(),!1}catch{}if(n=Sf(t,e,a,i),n!==null)return Ie(n,t,i),Mm(n,e,i),!0}return!1}function Yf(t,e,n,i){if(i={lane:2,revertLane:jf(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},mu(t)){if(e)throw Error(C(479))}else e=Sf(t,n,i,2),e!==null&&Ie(e,t,2)}function mu(t){var e=t.alternate;return t===$||e!==null&&e===$}function xm(t,e){Xa=Go=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function Mm(t,e,n){if((n&4194048)!==0){var i=e.lanes;i&=t.pendingLanes,n|=i,e.lanes=n,sh(t,n)}}var Xo={readContext:ue,use:gu,useCallback:Yt,useContext:Yt,useEffect:Yt,useImperativeHandle:Yt,useLayoutEffect:Yt,useInsertionEffect:Yt,useMemo:Yt,useReducer:Yt,useRef:Yt,useState:Yt,useDebugValue:Yt,useDeferredValue:Yt,useTransition:Yt,useSyncExternalStore:Yt,useId:Yt,useHostTransitionStatus:Yt,useFormState:Yt,useActionState:Yt,useOptimistic:Yt,useMemoCache:Yt,useCacheRefresh:Yt,useEffectEvent:Yt},wm={readContext:ue,use:gu,useCallback:function(t,e){return xe().memoizedState=[t,e===void 0?null:e],t},useContext:ue,useEffect:Jp,useImperativeHandle:function(t,e,n){n=n!=null?n.concat([t]):null,yo(4194308,4,cm.bind(null,e,t),n)},useLayoutEffect:function(t,e){return yo(4194308,4,t,e)},useInsertionEffect:function(t,e){yo(4,2,t,e)},useMemo:function(t,e){var n=xe();e=e===void 0?null:e;var i=t();if(aa){gi(!0);try{t()}finally{gi(!1)}}return n.memoizedState=[i,e],i},useReducer:function(t,e,n){var i=xe();if(n!==void 0){var a=n(e);if(aa){gi(!0);try{n(e)}finally{gi(!1)}}}else a=e;return i.memoizedState=i.baseState=a,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:a},i.queue=t,t=t.dispatch=s1.bind(null,$,t),[i.memoizedState,t]},useRef:function(t){var e=xe();return t={current:t},e.memoizedState=t},useState:function(t){t=wc(t);var e=t.queue,n=Sm.bind(null,$,e);return e.dispatch=n,[t.memoizedState,n]},useDebugValue:Hf,useDeferredValue:function(t,e){var n=xe();return Uf(n,t,e)},useTransition:function(){var t=wc(!1);return t=hm.bind(null,$,t.queue,!0,!1),xe().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,e,n){var i=$,a=xe();if(it){if(n===void 0)throw Error(C(407));n=n()}else{if(n=e(),Et===null)throw Error(C(349));(ct&127)!==0||Ph(i,e,n)}a.memoizedState=n;var l={value:n,getSnapshot:e};return a.queue=l,Jp(Fh.bind(null,i,l,t),[t]),i.flags|=2048,Fa(9,{destroy:void 0},jh.bind(null,i,l,n,e),null),n},useId:function(){var t=xe(),e=Et.identifierPrefix;if(it){var n=In,i=Nn;n=(i&~(1<<32-Le(i)-1)).toString(32)+n,e="_"+e+"R_"+n,n=Lo++,0<\/script>",l=l.removeChild(l.firstChild);break;case"select":l=typeof i.is=="string"?s.createElement("select",{is:i.is}):s.createElement("select"),i.multiple?l.multiple=!0:i.size&&(l.size=i.size);break;default:l=typeof i.is=="string"?s.createElement(a,{is:i.is}):s.createElement(a)}}l[oe]=e,l[Oe]=i;t:for(s=e.child;s!==null;){if(s.tag===5||s.tag===6)l.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===e)break t;for(;s.sibling===null;){if(s.return===null||s.return===e)break t;s=s.return}s.sibling.return=s.return,s=s.sibling}e.stateNode=l;t:switch(fe(l,a,i),a){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break t;case"img":i=!0;break t;default:i=!1}i&&Ln(e)}}return It(e),e.subtreeFlags&=-33554433,Ur(e,e.type,t===null?null:t.memoizedProps,e.pendingProps,n),null;case 6:if(t&&e.stateNode!=null)t.memoizedProps!==i&&Ln(e);else{if(typeof i!="string"&&e.stateNode===null)throw Error(C(166));if(t=Si.current,Ma(e)){if(t=e.stateNode,n=e.memoizedProps,i=null,a=le,a!==null)switch(a.tag){case 27:case 5:i=a.memoizedProps}t[oe]=e,t=!!(t.nodeValue===n||i!==null&&i.suppressHydrationWarning===!0||S0(t.nodeValue,n)),t||Ri(e,!0)}else t=fs(t).createTextNode(i),t[oe]=e,e.stateNode=t}return It(e),null;case 31:if(n=e.memoizedState,t===null||t.memoizedState!==null){if(i=Ma(e),n!==null){if(t===null){if(!i)throw Error(C(318));if(t=e.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(C(557));t[oe]=e}else Wi(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;It(e),t=!1}else n=Dr(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),t=!0;if(!t)return e.flags&256?(Ue(e),e):(Ue(e),null);if((e.flags&128)!==0)throw Error(C(558))}return It(e),null;case 13:if(i=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(a=Ma(e),i!==null&&i.dehydrated!==null){if(t===null){if(!a)throw Error(C(318));if(a=e.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(C(317));a[oe]=e}else Wi(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;It(e),a=!1}else a=Dr(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=a),a=!0;if(!a)return e.flags&256?(Ue(e),e):(Ue(e),null)}return Ue(e),(e.flags&128)!==0?(e.lanes=n,e):(n=i!==null,t=t!==null&&t.memoizedState!==null,n&&(i=e.child,a=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(a=i.alternate.memoizedState.cachePool.pool),l=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),l!==a&&(i.flags|=2048)),n!==t&&n&&(e.child.flags|=8192),eo(e,e.updateQueue),It(e),null);case 4:return $a(),t===null&&Ff(e.stateNode.containerInfo),e.flags|=67108864,It(e),null;case 10:return Zn(e.type),It(e),null;case 19:if(Cf(e),i=e.memoizedState,i===null)return It(e),null;if(a=(e.flags&128)!==0,l=i.rendering,l===null)if(a)Ol(i,!1);else{if(Qt!==0||t!==null&&(t.flags&128)!==0)for(t=e.child;t!==null;){if(l=Qo(t),l!==null){for(e.flags|=128,Ol(i,!1),t=l.updateQueue,e.updateQueue=t,eo(e,t),e.subtreeFlags=0,t=n,n=e.child;n!==null;)kh(n,t),n=n.sibling;return os(e,ce.current&1|2),it&&Xn(e,i.treeForkCount),e.child}t=t.sibling}i.tail!==null&&Qe()>jo&&(e.flags|=128,a=!0,Ol(i,!1),e.lanes=4194304)}else{if(!a)if(t=Qo(l),t!==null){if(e.flags|=128,a=!0,t=t.updateQueue,e.updateQueue=t,eo(e,t),Ol(i,!0),i.tail===null&&i.tailMode!=="collapsed"&&i.tailMode!=="visible"&&!l.alternate&&!it)return It(e),null}else 2*Qe()-i.renderingStartTime>jo&&n!==536870912&&(e.flags|=128,a=!0,Ol(i,!1),e.lanes=4194304);i.isBackwards?(l.sibling=e.child,e.child=l):(t=i.last,t!==null?t.sibling=l:e.child=l,i.last=l)}if(i.tail!==null){t=i.tail;t:{for(n=t;n!==null;){if(n.alternate!==null){n=!1;break t}n=n.sibling}n=!0}return i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Qe(),t.sibling=null,l=ce.current,l=a?l&1|2:l&1,i.tailMode==="visible"||i.tailMode==="collapsed"||!n||it?os(e,l):(n=l,Ot(de,e),Ot(ce,n),me===null&&(me=e)),it&&Xn(e,i.treeForkCount),t}return It(e),null;case 22:case 23:return Ue(e),zf(),i=e.memoizedState!==null,t!==null?t.memoizedState!==null!==i&&(e.flags|=8192):i&&(e.flags|=8192),i?(n&536870912)!==0&&(e.flags&128)===0&&(It(e),e.subtreeFlags&6&&(e.flags|=8192)):It(e),n=e.updateQueue,n!==null&&eo(e,n.retryQueue),n=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(n=t.memoizedState.cachePool.pool),i=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(i=e.memoizedState.cachePool.pool),i!==n&&(e.flags|=2048),t!==null&&re(Pi),null;case 24:return n=null,t!==null&&(n=t.memoizedState.cache),e.memoizedState.cache!==n&&(e.flags|=2048),Zn(Kt),It(e),null;case 25:return null;case 30:return e.flags|=33554432,It(e),null}throw Error(C(156,e.tag))}function p1(t,e){switch(Mf(e),e.tag){case 1:return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Zn(Kt),$a(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 26:case 27:case 5:return Ro(e),null;case 31:if(e.memoizedState!==null){if(Ue(e),e.alternate===null)throw Error(C(340));Wi()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 13:if(Ue(e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(C(340));Wi()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Cf(e),t=e.flags,t&65536?(e.flags=t&-65537|128,t=e.memoizedState,t!==null&&(t.rendering=null,t.tail=null),e.flags|=4,e):null;case 4:return $a(),null;case 10:return Zn(e.type),null;case 22:case 23:return Ue(e),zf(),t!==null&&re(Pi),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 24:return Zn(Kt),null;case 25:return null;default:return null}}function _m(t,e){switch(Mf(e),e.tag){case 3:Zn(Kt),$a();break;case 26:case 27:case 5:Ro(e);break;case 4:$a();break;case 31:e.memoizedState!==null&&Ue(e);break;case 13:Ue(e);break;case 19:Cf(e);break;case 10:Zn(e.type);break;case 22:case 23:Ue(e),zf(),t!==null&&re(Pi);break;case 24:Zn(Kt)}}function Es(t,e){try{var n=e.updateQueue,i=n!==null?n.lastEffect:null;if(i!==null){var a=i.next;n=a;do{if((n.tag&t)===t){i=void 0;var l=n.create,s=n.inst;i=l(),s.destroy=i}n=n.next}while(n!==a)}}catch(o){Mt(e,e.return,o)}}function Di(t,e,n){try{var i=e.updateQueue,a=i!==null?i.lastEffect:null;if(a!==null){var l=a.next;i=l;do{if((i.tag&t)===t){var s=i.inst,o=s.destroy;if(o!==void 0){s.destroy=void 0,a=e;var u=n,d=o;try{d()}catch(c){Mt(a,u,c)}}}i=i.next}while(i!==l)}}catch(c){Mt(e,e.return,c)}}function km(t){var e=t.updateQueue;if(e!==null){var n=t.stateNode;try{Kh(e,n)}catch(i){Mt(t,t.return,i)}}}function qm(t,e,n){n.props=la(t.type,t.memoizedProps),n.state=t.memoizedState;try{n.componentWillUnmount()}catch(i){Mt(t,e,i)}}function Tn(t,e){try{var n=t.ref;if(n!==null){switch(t.tag){case 26:case 27:case 5:var i=t.stateNode;break;case 30:var a=t.stateNode,l=$n(t.memoizedProps,a);(a.ref===null||a.ref.name!==l)&&(a.ref=A0(l)),i=a.ref;break;case 7:if(t.stateNode===null){var s=new Ve(t);Re(t.child,!1,eS,s,void 0,void 0),t.stateNode=s}i=t.stateNode;break;default:i=t.stateNode}typeof n=="function"?t.refCleanup=n(i):n.current=i}}catch(o){Mt(t,e,o)}}function se(t,e){var n=t.ref,i=t.refCleanup;if(n!==null)if(typeof i=="function")try{i()}catch(a){Mt(t,e,a)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(a){Mt(t,e,a)}else n.current=null}function Vo(t,e){if((t.tag===5||t.tag===27||t.tag===6)&&t.alternate===null&&e!==null)for(var n=0;n title"))),fe(i,e,n),i[oe]=t,ae(i),e=i;break t;case"link":if(l=qg("link","href",a).get(e+(n.href||""))){for(s=0;sS&&(s=S,S=h,h=s);var p=Rp(o,h),r=Rp(o,S);if(p&&r&&(m.rangeCount!==1||m.anchorNode!==p.node||m.anchorOffset!==p.offset||m.focusNode!==r.node||m.focusOffset!==r.offset)){var g=v.createRange();g.setStart(p.node,p.offset),m.removeAllRanges(),h>S?(m.addRange(g),m.extend(r.node,r.offset)):(g.setEnd(r.node,r.offset),m.addRange(g))}}}}for(v=[],m=o;m=m.parentNode;)m.nodeType===1&&v.push({element:m,left:m.scrollLeft,top:m.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;on?32:n,X.T=null,n=Xc,Xc=null;var l=gn,s=On;if(Ut=0,sa=gn=null,On=0,(mt&6)!==0)throw Error(C(331));var o=mt;if(mt|=4,e0(l.current),Fm(l,l.current,s,n),mt=o,Ts(0,!1),Ge&&typeof Ge.onPostCommitFiberRoot=="function")try{Ge.onPostCommitFiberRoot(vs,l)}catch{}return!0}finally{vt.p=a,X.T=i,p0(t,e)}}function mg(t,e,n){e=nn(n,e),e=zc(t.stateNode,e,2),t=wi(t,e,2),t!==null&&(bs(t,2),kn(t))}function Mt(t,e,n){if(t.tag===3)mg(t,t,n);else for(;e!==null;){if(e.tag===3){mg(e,t,n);break}else if(e.tag===1){var i=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Ai===null||!Ai.has(i))){t=nn(n,t),n=Cm(2),i=wi(e,n,2),i!==null&&(Nm(n,i,e,t),bs(i,2),kn(i));break}}e=e.return}}function Lr(t,e,n){var i=t.pingCache;if(i===null){i=t.pingCache=new v1;var a=new Set;i.set(e,a)}else a=i.get(e),a===void 0&&(a=new Set,i.set(e,a));a.has(n)||($f=!0,a.add(n),t=T1.bind(null,t,e,n),e.then(t,t))}function T1(t,e,n){var i=t.pingCache;i!==null&&i.delete(e),t.pingedLanes|=t.suspendedLanes&n,t.warmLanes&=~n,Et===t&&(ct&n)===n&&((Qt===4||Qt===3&&(ct&62914560)===ct&&300>Qe()-yu)&&(mt&2)===0?el(t,0):Po|=n,Wa===ct&&(Wa=0)),kn(t)}function g0(t,e){e===0&&(e=ah()),t=ca(t,e),t!==null&&(bs(t,e),kn(t))}function A1(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),g0(t,n)}function z1(t,e){var n=0;switch(t.tag){case 31:case 13:var i=t.stateNode,a=t.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=t.stateNode;break;case 22:i=t.stateNode._retryCache;break;default:throw Error(C(314))}i!==null&&i.delete(e),g0(t,n)}function C1(t,e){return cf(t,e)}var nl=null,Aa=null,$c=!1,tu=!1,Xr=!1,bi=0;function kn(t){t!==Aa&&t.next===null&&(Aa===null?nl=Aa=t:Aa=Aa.next=t),tu=!0,$c||($c=!0,I1())}function Ts(t,e){if(!Xr&&tu){Xr=!0;do for(var n=!1,i=nl;i!==null;){if(!e)if(t!==0){var a=i.pendingLanes;if(a===0)var l=0;else{var s=i.suspendedLanes,o=i.pingedLanes;l=(1<<31-Le(42|t)+1)-1,l&=a&~(s&~o),l=l&201326741?l&201326741|1:l?l|2:0}l!==0&&(n=!0,vg(i,l))}else l=ct,l=au(i,i===Et?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(l&3)===0||ys(i,l)||(n=!0,vg(i,l));i=i.next}while(n);Xr=!1}}function N1(){h0()}function h0(){tu=$c=!1;var t=0;bi!==0&&B1()&&(t=bi);for(var e=Qe(),n=null,i=nl;i!==null;){var a=i.next,l=m0(i,e);l===0?(i.next=null,n===null?nl=a:n.next=a,a===null&&(Aa=n)):(n=i,(t!==0||(l&3)!==0)&&(tu=!0)),i=a}Ut!==0&&Ut!==5||Ts(t,!1),bi!==0&&(bi=0)}function m0(t,e){for(var n=t.suspendedLanes,i=t.pingedLanes,a=t.expirationTimes,l=t.pendingLanes&-62914561;0o)break;var c=u.transferSize,v=u.initiatorType;c&&wg(v)&&(u=u.responseEnd,s+=c*(uAo){h.length=y;break}g=new Promise(K1.bind(g)),h.push(g)}}}if(0"u"?null:document;function _0(t,e,n){var i=pl;if(i&&typeof e=="string"&&e){var a=en(e);a='link[rel="'+t+'"][href="'+a+'"]',typeof n=="string"&&(a+='[crossorigin="'+n+'"]'),Dg.has(a)||(Dg.add(a),t={rel:t,crossOrigin:n,href:e},i.querySelector(a)===null&&(e=i.createElement("link"),fe(e,"link",t),ae(e),i.head.appendChild(e)))}}function cS(t){ni.D(t),_0("dns-prefetch",t,null)}function fS(t,e){ni.C(t,e),_0("preconnect",t,e)}function dS(t,e,n){ni.L(t,e,n);var i=pl;if(i&&t&&e){var a='link[rel="preload"][as="'+en(e)+'"]';e==="image"&&n&&n.imageSrcSet?(a+='[imagesrcset="'+en(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(a+='[imagesizes="'+en(n.imageSizes)+'"]')):a+='[href="'+en(t)+'"]';var l=a;switch(e){case"style":l=al(t);break;case"script":l=gl(t)}if(!(sn.has(l)||(t=Tt({rel:"preload",href:e==="image"&&n&&n.imageSrcSet?void 0:t,as:e},n),sn.set(l,t),i.querySelector(a)!==null||e==="style"&&i.querySelector(As(l))||e==="script"&&i.querySelector(zs(l))))){var s=i.createElement("link");fe(s,"link",t),e==="style"&&(s[Do]=!0,s.onload=s.onerror=function(){rh(s)}),ae(s),i.head.appendChild(s)}}}function pS(t,e){ni.m(t,e);var n=pl;if(n&&t){var i=e&&typeof e.as=="string"?e.as:"script",a='link[rel="modulepreload"][as="'+en(i)+'"][href="'+en(t)+'"]',l=a;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":l=gl(t)}if(!sn.has(l)&&(t=Tt({rel:"modulepreload",href:t},e),sn.set(l,t),n.querySelector(a)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(zs(l)))return}i=n.createElement("link"),fe(i,"link",t),ae(i),n.head.appendChild(i)}}}function gS(t,e,n){ni.S(t,e,n);var i=pl;if(i&&t){var a=Ba(i).hoistableStyles,l=al(t);e=e||"default";var s=a.get(l);if(!s){var o={loading:0,preload:null};if(s=i.querySelector(As(l)))o.loading=5;else{t=Tt({rel:"stylesheet",href:t,"data-precedence":e},n),(n=sn.get(l))&&nd(t,n);var u=s=i.createElement("link");ae(u),fe(u,"link",t),u._p=new Promise(function(d,c){u.onload=d,u.onerror=c}),u.addEventListener("load",function(){o.loading|=1}),u.addEventListener("error",function(){o.loading|=2}),o.loading|=4,Eo(s,e,i)}s={type:"stylesheet",instance:s,count:1,state:o},a.set(l,s)}}}function hS(t,e){ni.X(t,e);var n=pl;if(n&&t){var i=Ba(n).hoistableScripts,a=gl(t),l=i.get(a);l||(l=n.querySelector(zs(a)),l||(t=Tt({src:t,async:!0},e),(e=sn.get(a))&&id(t,e),l=n.createElement("script"),ae(l),fe(l,"link",t),n.head.appendChild(l)),l={type:"script",instance:l,count:1,state:null},i.set(a,l))}}function mS(t,e){ni.M(t,e);var n=pl;if(n&&t){var i=Ba(n).hoistableScripts,a=gl(t),l=i.get(a);l||(l=n.querySelector(zs(a)),l||(t=Tt({src:t,async:!0,type:"module"},e),(e=sn.get(a))&&id(t,e),l=n.createElement("script"),ae(l),fe(l,"link",t),n.head.appendChild(l)),l={type:"script",instance:l,count:1,state:null},i.set(a,l))}}function _g(t,e,n,i){var a=(a=Si.current)?ds(a):null;if(!a)throw Error(C(446));switch(t){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(n=al(n.href),e=Ba(a).hoistableStyles,i=e.get(n),i||(i={type:"style",instance:null,count:0,state:null},e.set(n,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){t=al(n.href);var l=Ba(a).hoistableStyles,s=l.get(t);if(s||(a=a.ownerDocument||a,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},l.set(t,s),(l=a.querySelector(As(t)))?l._p||(s.instance=l,s.state.loading=5):(l=sn.get(t),l||(l={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},sn.set(t,l)),vS(a,t,l,s.state))),e&&i===null)throw Error(C(528,""));return s}if(e&&i!==null)throw Error(C(529,""));return null;case"script":return e=n.async,n=n.src,typeof n=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(n=gl(n),e=Ba(a).hoistableScripts,i=e.get(n),i||(i={type:"script",instance:null,count:0,state:null},e.set(n,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(C(444,t))}}function al(t){return'href="'+en(t)+'"'}function As(t){return'link[rel="stylesheet"]['+t+"]"}function k0(t){return Tt({},t,{"data-precedence":t.precedence,precedence:null})}function vS(t,e,n,i){if(e=t.querySelector('link[rel="preload"][as="style"]['+e+"]")){if(e[Do]!==!0){i.loading=1;return}}else e=t.createElement("link"),e[Do]=!0,e.onload=e.onerror=rh.bind(null,e),fe(e,"link",n),ae(e),t.head.appendChild(e);i.preload=e,e.addEventListener("load",function(){return i.loading|=1}),e.addEventListener("error",function(){return i.loading|=2})}function gl(t){return'[src="'+en(t)+'"]'}function zs(t){return"script[async]"+t}function kg(t,e,n){if(e.count++,e.instance===null)switch(e.type){case"style":var i=t.querySelector('style[data-href~="'+en(n.href)+'"]');if(i)return e.instance=i,ae(i),i;var a=Tt({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return i=(t.ownerDocument||t).createElement("style"),ae(i),fe(i,"style",a),Eo(i,n.precedence,t),e.instance=i;case"stylesheet":a=al(n.href);var l=t.querySelector(As(a));if(l)return e.state.loading|=4,e.instance=l,ae(l),l;i=k0(n),(a=sn.get(a))&&nd(i,a),l=(t.ownerDocument||t).createElement("link"),ae(l);var s=l;return s._p=new Promise(function(o,u){s.onload=o,s.onerror=u}),fe(l,"link",i),e.state.loading|=4,Eo(l,n.precedence,t),e.instance=l;case"script":return l=gl(n.src),(a=t.querySelector(zs(l)))?(e.instance=a,ae(a),a):(i=n,(a=sn.get(l))&&(i=Tt({},n),id(i,a)),t=t.ownerDocument||t,a=t.createElement("script"),ae(a),fe(a,"link",i),t.head.appendChild(a),e.instance=a);case"void":return null;default:throw Error(C(443,e.type))}else e.type==="stylesheet"&&(e.state.loading&4)===0&&(i=e.instance,e.state.loading|=4,Eo(i,n.precedence,t));return e.instance}function Eo(t,e,n){for(var i=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=i.length?i[i.length-1]:null,l=a,s=0;s title"):null)}function yS(t,e,n){if(n===1||e.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;return e.rel==="stylesheet"?(t=e.disabled,typeof e.precedence=="string"&&t==null):!0;case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function Hg(t,e){return t==="img"&&e.src!=null&&e.src!==""&&e.onLoad==null&&e.loading!=="lazy"}function q0(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function H0(t){return(t.width||100)*(t.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function Ug(t,e){typeof e.decode=="function"&&(t.imgCount++,e.complete||(t.imgBytes+=H0(e),t.suspenseyImages.push(e)),t=xS.bind(t),e.decode().then(t,t))}function bS(t,e,n,i){if(n.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var a=al(i.href),l=e.querySelector(As(a));if(l){e=l._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(t.count++,t=ps.bind(t),e.then(t,t)),n.state.loading|=4,n.instance=l,ae(l);return}l=e.ownerDocument||e,i=k0(i),(a=sn.get(a))&&nd(i,a),l=l.createElement("link"),ae(l);var s=l;s._p=new Promise(function(o,u){s.onload=o,s.onerror=u}),fe(l,"link",i),n.instance=l}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(n,e),(e=n.state.preload)&&(n.state.loading&3)===0&&(t.count++,n=ps.bind(t),e.addEventListener("load",n),e.addEventListener("error",n))}}var Ao=0;function SS(t,e){return t.stylesheets&&t.count===0&&zo(t,t.stylesheets),0Ao?50:800)+e);return t.unsuspend=n,function(){t.unsuspend=null,clearTimeout(i),clearTimeout(a)}}:null}function U0(t){if(t.count===0&&(t.imgCount===0||!t.waitingForImages)){if(t.stylesheets)zo(t,t.stylesheets);else if(t.unsuspend){var e=t.unsuspend;t.unsuspend=null,e()}}}function ps(){this.count--,U0(this)}function xS(){this.imgCount--,U0(this)}var nu=null;function zo(t,e){t.stylesheets=null,t.unsuspend!==null&&(t.count++,nu=new Map,e.forEach(MS,t),nu=null,ps.call(t))}function MS(t,e){if(!(e.state.loading&4)){var n=nu.get(t);if(n)var i=n.get(null);else{n=new Map,nu.set(t,n);for(var a=t.querySelectorAll("link[data-precedence],style[data-precedence]"),l=0;l{"use strict";function Z0(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Z0)}catch(t){console.error(t)}}Z0(),J0.exports=V0()});var P0=bn(Eu=>{"use strict";/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var IS=Symbol.for("react.transitional.element"),RS=Symbol.for("react.fragment");function $0(t,e,n){var i=null;if(n!==void 0&&(i=""+n),e.key!==void 0&&(i=""+e.key),"key"in e){n={};for(var a in e)a!=="key"&&(n[a]=e[a])}else n=e;return e=n.ref,{$$typeof:IS,type:t,key:i,ref:e!==void 0?e:null,props:n}}Eu.Fragment=RS;Eu.jsx=$0;Eu.jsxs=$0});var Bt=bn((ux,j0)=>{"use strict";j0.exports=P0()});var Jv=ht(ud(),1);var qn=ht(xn(),1);var Cs=[1e4,3e4,6e4,12e4],Ze=1,ii=10,da={scanMs:1e4,intervalMs:1500,candidates:10,radius:32,horizonMs:12e4,maxTravelMs:18e5,reserve:0,maxSources:3,peacefulDevelopment:0,economicHorizonMs:108e5,cautiousExpansion:0,captureSuns:1,captureMeteorites:1,upgradeStable:1,stableMs:6e5};function Ns(t){if(!Cs.some(n=>n===t.scanMs))throw new Error("\u626B\u63CF\u95F4\u9694\u8BF7\u9009\u62E9 10\u300130\u300160 \u6216 120 \u79D2\u3002");let e=[["scanMs",1e4,12e4],["intervalMs",1e3,2e3],["candidates",1,50],["radius",1,128],["horizonMs",1e4,6e5],["maxTravelMs",1e4,144e5],["reserve",0,4294967295],["maxSources",1,ii]];for(let[n,i,a]of e)if(!Number.isSafeInteger(t[n])||t[n]a)throw new Error(`\u8BBE\u7F6E ${n} \u5E94\u4E3A ${i}\u2013${a} \u8303\u56F4\u5185\u7684\u6574\u6570\u3002`);for(let n of["peacefulDevelopment","cautiousExpansion","captureSuns","captureMeteorites","upgradeStable"])if(t[n]!==0&&t[n]!==1)throw new Error(`\u8BBE\u7F6E ${n} \u5E94\u4E3A\u5F00\u6216\u5173\u3002`);if(!Number.isSafeInteger(t.economicHorizonMs)||t.economicHorizonMs<6e4||t.economicHorizonMs>864e5||!Number.isSafeInteger(t.stableMs)||t.stableMs<6e4||t.stableMs>864e5)throw new Error("\u6536\u76CA\u5468\u671F\u4E0E\u7A33\u5B9A\u65F6\u95F4\u5E94\u4E3A 60\u201386400 \u79D2\u3002")}function At(t,e="planet"){return`${e}:${t}`}function st(t){return At(t.targetId,t.targetKind)}function De(t){return`${t.targetKind==="sun"?"\u6052\u661F":t.targetKind==="comet"?"\u9668\u77F3":"\u661F\u7403"} #${t.targetId}`}function rd(t){return new Set([...t].filter(e=>e.startsWith("planet:")).map(e=>BigInt(e.slice(7))))}function G(t){return[t,...t.support??[]]}function hl(t){let e=G(t);return e.slice(0,3).map(n=>`#${n.sourceId}`).join(" + ")+(e.length>3?` \u7B49 ${e.length} \u9897`:"")}function pe(t){return G(t).reduce((e,n)=>e+n.count,0)}function ot(t){return Math.max(...G(t).map(e=>e.travelMs))}var Tu=ht(xn(),1),pa=ht(Bt(),1);function mn({htmlFor:t,label:e,help:n,children:i}){let a=(0,Tu.useId)(),[l,s]=(0,Tu.useState)(!1);return(0,pa.jsxs)("div",{className:"setting-heading",children:[i??(0,pa.jsx)("label",{htmlFor:t,children:e}),(0,pa.jsxs)("span",{className:"setting-help",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[(0,pa.jsx)("button",{type:"button",className:"help-trigger","aria-label":`${e}\u8BF4\u660E`,"aria-describedby":l?a:void 0,onFocus:()=>s(!0),onBlur:()=>s(!1),onClick:()=>s(!0),onKeyDown:o=>{o.key==="Escape"&&(o.stopPropagation(),s(!1))},children:"?"}),l&&(0,pa.jsx)("span",{id:a,role:"tooltip",className:"setting-tip",children:n})]})]})}var ft=ht(Bt(),1),OS=[{key:"candidates",label:"\u6BCF\u9897\u661F\u7403\u7684\u5019\u9009\u6570\uFF081\u201350\uFF09",min:1,max:50,step:1,help:"\u6BCF\u9897\u6765\u6E90\u53C2\u4E0E\u6BD4\u8F83\u7684\u5019\u9009\u76EE\u6807\u6570\u91CF\u3002\u6570\u91CF\u8D8A\u591A\uFF0C\u8BC4\u4F30\u5DE5\u4F5C\u8D8A\u591A\uFF1B\u9644\u8FD1\u53EF\u6253\u76EE\u6807\u4F18\u5148\u3002"},{key:"radius",label:"\u6700\u5927\u641C\u7D22\u8DDD\u79BB\uFF081\u2013128\uFF09",min:1,max:128,step:1,help:"\u9650\u5236\u9644\u8FD1\u76EE\u6807\u7684\u641C\u7D22\u8303\u56F4\uFF1B\u8BBE\u7F6E\u4E86\u56FA\u5B9A\u6218\u533A\u65F6\uFF0C\u6765\u6E90\u4E0E\u76EE\u6807\u8FD8\u5FC5\u987B\u4F4D\u4E8E\u6218\u533A\u5185\u3002"},{key:"intervalMs",label:"\u64CD\u4F5C\u57FA\u51C6\u95F4\u9694\uFF08\u79D2\uFF09",min:1,max:2,step:.1,help:"\u53EF\u8BBE 1\uFF5E2 \u79D2\uFF0C\u968F\u673A \xB10.2 \u79D2\uFF0C\u6700\u77ED 1 \u79D2\u3002\u4F8B\u5982 1.2 \u79D2\u5BF9\u5E94 1.0\uFF5E1.4 \u79D2\u3002\u4E0D\u7B49\u5F85\u53D1\u5C04\u56DE\u6267\uFF1B\u8D85\u65F6\u8DF3\u8FC7\u5E76\u7EE7\u7EED\uFF0C\u5E93\u5B58\u540E\u53F0\u540C\u6B65\u3002"},{key:"horizonMs",label:"\u89C4\u5212\u961F\u5217\u7A97\u53E3\uFF08\u79D2\uFF09",min:10,max:600,step:1,help:"\u9650\u5236\u9884\u8BA1\u6392\u961F\u65F6\u95F4\uFF0C\u4E0D\u662F\u626B\u63CF\u95F4\u9694\u6216\u822A\u884C\u622A\u6B62\u65F6\u95F4\u3002\u4F8B\u5982 120 \u79D2\u8868\u793A\u5B89\u6392\u8FD1\u671F\u8981\u53D1\u51FA\u7684\u961F\u5217\uFF0C\u4E0D\u8981\u6C42\u4E24\u5206\u949F\u5185\u62B5\u8FBE\u3002"},{key:"reserve",label:"\u6BCF\u9897\u661F\u7403\u7559\u5B88\u63A2\u9488",min:0,max:4294967295,step:1,help:"\u6BCF\u9897\u6765\u6E90\u81F3\u5C11\u4FDD\u7559\u7684\u63A2\u9488\u6570\u3002\u524D\u7EBF\u7559\u5175\u548C\u5DF2\u77E5\u6765\u88AD\u53EF\u80FD\u8981\u6C42\u66F4\u591A\u5B88\u519B\uFF1B\u4E24\u4E2A\u6A21\u5F0F\u5171\u4EAB\u5E93\u5B58\u4E0E\u9632\u5B88\u9884\u7B97\u3002"}],DS=[{key:"captureSuns",label:"\u5C3D\u65E9\u5360\u9886\u9644\u8FD1\u65E0\u4E3B\u6052\u661F",help:"\u4F18\u5148\u5B89\u6392\u53EF\u5360\u6052\u661F\u3002\u5175\u529B\u4E0D\u8DB3\u65F6\uFF0C\u540E\u65B9\u5206\u6279\u8865\u7ED9\u5DF1\u65B9\u4E2D\u8F6C\u661F\uFF0C\u8BA1\u5212\u6301\u7EED\u66F4\u65B0\uFF0C\u5B9E\u9645\u5230\u8D26\u540E\u518D\u51FA\u51FB\u3002"},{key:"captureMeteorites",label:"\u5360\u9886\u80FD\u53CA\u65F6\u62B5\u8FBE\u7684\u65E0\u4E3B\u9668\u77F3",help:"\u53EA\u5B89\u6392\u80FD\u5728\u6D88\u5931\u524D\u62B5\u8FBE\u7684\u76EE\u6807\u3002\u9668\u77F3\u65E0\u4EA7\u91CF\uFF0C\u6301\u6709\u81F3\u5230\u671F\u624D\u83B7\u5F97\u5956\u52B1\uFF0C\u5230\u671F\u65F6\u9A7B\u519B\u4E5F\u6D88\u5931\u3002"},{key:"upgradeStable",label:"\u6309\u6536\u76CA\u4E0E\u5360\u9886\u65F6\u95F4\u5347\u7EA7",help:"\u540E\u65B9\u7A33\u5B9A\u4E14\u65E0\u9644\u8FD1\u65E0\u4E3B\u673A\u4F1A\u65F6\u6309\u56DE\u672C\u5347\u7EA7\uFF1B\u524D\u7EBF\u4EC5\u5728\u5148\u5347 1\u21922 \u7EA7\u9884\u8BA1\u66F4\u65E9\u5360\u9886\u65F6\u5347\u7EA7\uFF0C\u8BA1\u5165\u8865\u7ED9\u4E0E\u5347\u7EA7\u6210\u672C\u3002\u5747\u9700\u7A33\u5B9A\u3001\u65E0\u90BB\u654C\u3001\u65E0\u6765\u88AD\uFF0C\u56DE\u672C\u5728\u6536\u76CA\u5468\u671F\u5185\u3002\u6BCF\u6279\u6700\u591A 200 \u9897\uFF0C\u6BCF\u9897\u53EA\u5347\u4E00\u7EA7\u3002"}];function F0({value:t,disabled:e,onChange:n,attack:i=!1}){let a=!i&&t.peacefulDevelopment==="1",l=s=>i?`attack-${s}`:s;return(0,ft.jsxs)(ft.Fragment,{children:[!i&&(0,ft.jsxs)(ft.Fragment,{children:[(0,ft.jsx)(mn,{htmlFor:"peacefulDevelopment",label:"\u8FD0\u884C\u6A21\u5F0F",help:"\u5B89\u7A33\u53D1\u80B2\u6301\u7EED\u5360\u9886\u53EF\u53CA\u65F6\u62B5\u8FBE\u7684\u65E0\u4E3B\u9668\u77F3\uFF0C\u6682\u7F13\u66B4\u9732\u76EE\u6807\uFF0C\u4E0D\u6269\u5F20\u884C\u661F\u3001\u6052\u661F\u6216\u4E3A\u5176\u96C6\u7ED3\uFF1B\u53EF\u9009\u5B89\u5168\u5347\u7EA7\u3002\u4FDD\u7559\u5B88\u519B\u3001\u6218\u533A\u548C\u65AD\u7EBF\u6062\u590D\uFF0C\u5207\u6362\u540E\u9700\u624B\u52A8\u542F\u52A8\u3002"}),(0,ft.jsxs)("select",{id:"peacefulDevelopment",disabled:e,value:t.peacefulDevelopment,onChange:s=>n("peacefulDevelopment",s.target.value),children:[(0,ft.jsx)("option",{value:"0",children:"\u81EA\u52A8\u6269\u5F20"}),(0,ft.jsx)("option",{value:"1",children:"\u5B89\u7A33\u53D1\u80B2\uFF1A\u6302\u673A\u5360\u9668\u77F3"})]}),a&&(0,ft.jsx)("p",{className:"notice",children:"\u53EA\u5360\u65E0\u4E3B\u9668\u77F3\uFF0C\u6682\u7F13\u66B4\u9732\u76EE\u6807\uFF1B\u65E0\u76EE\u6807\u65F6\u6301\u7EED\u7B49\u5F85\u3002\u8FDB\u653B\u6A21\u5F0F\u72EC\u7ACB\u8FD0\u884C\uFF0C\u5982\u9700\u548C\u5E73\u6302\u673A\u8BF7\u505C\u6B62\u8FDB\u653B\u3002"})]}),(0,ft.jsx)(mn,{htmlFor:l("scanMs"),label:"\u626B\u63CF\u95F4\u9694",help:"\u4ECE\u672C\u8F6E\u89C4\u5212\u5B8C\u6210\u540E\u5F00\u59CB\u8BA1\u65F6\uFF0C\u4E0D\u7B49\u64CD\u4F5C\u961F\u5217\u6267\u884C\u5B8C\u3002\u4E24\u4E2A\u6A21\u5F0F\u540C\u65F6\u8FD0\u884C\u65F6\uFF0C\u8986\u76D6\u626B\u63CF\u91C7\u7528\u8F83\u5FEB\u7684\u5468\u671F\uFF1B\u64CD\u4F5C\u961F\u5217\u548C\u9650\u901F\u5404\u81EA\u72EC\u7ACB\u3002"}),(0,ft.jsx)("select",{id:l("scanMs"),disabled:e,value:t.scanMs,onChange:s=>n("scanMs",s.target.value),children:Cs.map(s=>(0,ft.jsxs)("option",{value:s/1e3,children:[s/1e3," \u79D2"]},s))}),OS.filter(s=>!i||s.key!=="intervalMs").map(({key:s,label:o,help:u,...d})=>(0,ft.jsxs)("div",{children:[(0,ft.jsx)(mn,{htmlFor:l(s),label:o,help:u}),(0,ft.jsx)("input",{id:l(s),type:"number",...d,disabled:e||a&&s==="candidates",value:t[s],onChange:c=>n(s,c.target.value)})]},s)),i&&(0,ft.jsx)(mn,{label:"\u64CD\u4F5C\u95F4\u9694\uFF1A1 \u79D2",help:"\u8FDB\u653B\u64CD\u4F5C\u95F4\u9694\u56FA\u5B9A\u4E3A 1 \u79D2\uFF0C\u4F7F\u7528\u72EC\u7ACB\u961F\u5217\uFF1B\u7B49\u5F85\u672C\u6A21\u5F0F\u53D1\u5C04\u786E\u8BA4\u548C\u5E93\u5B58\u540C\u6B65\u540E\u518D\u6267\u884C\u4E0B\u4E00\u9879\u3002"}),(0,ft.jsx)(mn,{htmlFor:l("maxTravelMs"),label:"\u6700\u957F\u822A\u884C\u65F6\u95F4\uFF08\u79D2\uFF09",help:"\u9ED8\u8BA4 1800 \u79D2\uFF0830 \u5206\u949F\uFF09\uFF0C\u72EC\u7ACB\u9650\u5236\u5355\u6B21\u822A\u7A0B\u3002\u8FD1\u7A0B\u5148\u53D1\uFF0C\u540E\u65B9\u6765\u6E90\u4E5F\u53EF\u6267\u884C\u8F83\u8FDC\u4EFB\u52A1\uFF1B\u641C\u7D22\u8DDD\u79BB\u4E0E\u56FA\u5B9A\u6218\u533A\u4ECD\u751F\u6548\u3002"}),(0,ft.jsx)("input",{id:l("maxTravelMs"),type:"number",min:10,max:14400,step:1,disabled:e,value:t.maxTravelMs,onChange:s=>n("maxTravelMs",s.target.value)}),!i&&(0,ft.jsxs)(ft.Fragment,{children:[(0,ft.jsx)(mn,{htmlFor:"maxSources",label:`\u76F4\u63A5\u5408\u5175\u6700\u591A\u534F\u540C\u661F\u7403\u6570\uFF081\u2013${ii}\uFF09`,help:"\u9ED8\u8BA4 3 \u9897\uFF0C\u586B 1 \u8868\u793A\u4EC5\u5355\u661F\u76F4\u653B\u3002\u540C\u6837\u5360\u70B9\u6570\u4F18\u5148\u66F4\u65E9\u62B5\u8FBE\uFF0C\u65F6\u95F4\u76F8\u540C\u65F6\u4F18\u5148\u66F4\u5C11\u6765\u6E90\uFF0C\u4E0D\u4E3A\u51D1\u6570\u91CF\u800C\u62C6\u5175\u3002\u534F\u540C\u6765\u6E90\u5F7C\u6B64\u8DDD\u79BB\u4E0D\u8D85\u8FC7 8\uFF0C\u62B5\u8FBE\u65F6\u5DEE\u4E0D\u8D85\u8FC7 15 \u79D2\uFF1B\u4E00\u6B21\u6279\u91CF\u6D3E\u5175\u8BA1\u4E00\u4E2A\u64CD\u4F5C\u3002\u540E\u65B9\u8865\u7ED9\u4E0D\u53D7\u6B64\u6570\u91CF\u9650\u5236\uFF0C\u6BCF\u6279\u6700\u591A 50 \u9897\u3002"}),(0,ft.jsx)("input",{id:"maxSources",type:"number",min:1,max:ii,step:1,disabled:e||a,value:t.maxSources,onChange:s=>n("maxSources",s.target.value)}),(0,ft.jsx)(mn,{htmlFor:"cautiousExpansion",label:"\u6269\u5F20\u53D6\u5411",help:"\u9ED8\u8BA4\u6301\u7EED\u6D3E\u5175\uFF0C\u4E0D\u7B49\u5F85\u6574\u6CE2\u843D\u5730\u3002\u4E24\u79CD\u53D6\u5411\u5747\u4FDD\u7559\u5B88\u519B\u548C\u5DF2\u77E5\u6765\u88AD\u9884\u7B97\uFF1B\u98CE\u9669\u6309\u5DF2\u89C2\u6D4B\u90BB\u654C\u4E0E\u652F\u63F4\u8DDD\u79BB\u5224\u65AD\u3002"}),(0,ft.jsxs)("select",{id:"cautiousExpansion",disabled:e||a,value:a?"1":t.cautiousExpansion,onChange:s=>n("cautiousExpansion",s.target.value),children:[(0,ft.jsx)("option",{value:"0",children:"\u5FEB\u901F\u94FA\u5F00\uFF1A\u4F18\u5148\u5360\u66F4\u591A\u70B9"}),(0,ft.jsx)("option",{value:"1",children:"\u7A33\u5065\u6269\u5F20\uFF1A\u6682\u7F13\u5B64\u7ACB\u9AD8\u98CE\u9669\u70B9"})]}),DS.map(({key:s,label:o,help:u})=>(0,ft.jsx)(mn,{label:o,help:u,children:(0,ft.jsxs)("label",{className:"strategy-toggle",htmlFor:s,children:[(0,ft.jsx)("input",{id:s,type:"checkbox",disabled:e||a&&s!=="upgradeStable",checked:a&&s!=="upgradeStable"?s==="captureMeteorites":t[s]==="1",onChange:d=>n(s,d.target.checked?"1":"0")}),o]})},s)),(0,ft.jsx)(mn,{htmlFor:"economicHorizonMs",label:"\u6536\u76CA\u8BC4\u4F30\u5468\u671F\uFF08\u79D2\uFF09",help:"\u9ED8\u8BA4 10800 \u79D2\uFF083 \u5C0F\u65F6\uFF09\u3002\u7528\u4E8E\u8BC4\u4F30\u5360\u9886\u6536\u76CA\u4E0E\u5347\u7EA7\u56DE\u672C\uFF0C\u72EC\u7ACB\u4E8E\u89C4\u5212\u961F\u5217\u7A97\u53E3\uFF1B\u5347\u7EA7\u56DE\u672C\u987B\u5728\u6B64\u5468\u671F\u5185\u3002"}),(0,ft.jsx)("input",{id:"economicHorizonMs",type:"number",min:60,max:86400,step:60,disabled:e,value:t.economicHorizonMs,onChange:s=>n("economicHorizonMs",s.target.value)}),(0,ft.jsx)(mn,{htmlFor:"stableMs",label:"\u5347\u7EA7\u524D\u8FDE\u7EED\u7A33\u5B9A\u65F6\u95F4\uFF08\u79D2\uFF09",help:"\u9ED8\u8BA4 600 \u79D2\uFF0810 \u5206\u949F\uFF09\u3002\u7B26\u5408\u5B89\u5168\u6761\u4EF6\u5E76\u8FDE\u7EED\u89C2\u5BDF\u6EE1\u6B64\u65F6\u95F4\u540E\u624D\u8003\u8651\u5347\u7EA7\uFF1B\u5237\u65B0\u3001\u91CD\u542F\u6216\u65AD\u7EBF\u6062\u590D\u540E\u91CD\u65B0\u89C2\u5BDF\u3002"}),(0,ft.jsx)("input",{id:"stableMs",type:"number",min:60,max:86400,step:60,disabled:e,value:t.stableMs,onChange:s=>n("stableMs",s.target.value)})]})]})}var ev=ht(xn(),1);var Au=ht(xn(),1),k=ht(Bt(),1),W0=t=>Math.round(t.waitMs+(t.waitingSince===void 0?0:Math.max(0,performance.now()-t.waitingSince))),_S={idle:"\u672A\u542F\u52A8",starting:"\u542F\u52A8\u4E2D",scanning:"\u626B\u63CF\u4E2D",waiting:"\u7B49\u5F85\u4E2D",queued:"\u6392\u961F\u4E2D",sending:"\u53D1\u9001\u4E2D",sent:"\u8FD0\u884C\u4E2D",captured:"\u8FD0\u884C\u4E2D",paused:"\u6682\u7F13\u64CD\u4F5C",stopping:"\u505C\u6B62\u4E2D",stopped:"\u5DF2\u505C\u6B62",error:"\u5DF2\u505C\u6B62 \xB7 \u5F02\u5E38"};function kS(t,e,n=Date.now()){return t.running&&!["paused","stopping","error","starting"].includes(t.activity)&&t.work?t.work.dispatch?t.activity==="sending"?"\u7B49\u5F85\u786E\u8BA4":"\u7B49\u5F85\u53D1\u5C04":t.work.plan&&n-t.work.plan.startedAt>=2e3?"\u89C4\u5212\u4E2D":t.work.scanning?"\u626B\u63CF\u4E2D":t.queue.length?"\u6392\u961F\u4E2D":t.work.background?"\u540E\u53F0\u786E\u8BA4\u4E2D":"\u76D1\u6D4B\u53D8\u5316\u4E2D":e&&!t.running?"\u7ED3\u679C\u672A\u77E5 \xB7 \u5DF2\u9501\u5B9A":_S[t.activity]}function zu({state:t,uncertain:e,now:n}){let i=e&&!t.running||t.activity==="error"?"error":t.activity==="paused"||t.activity==="stopping"?"warning":t.running?"active":"idle";return(0,k.jsxs)("span",{className:`status-badge ${i}`,children:[(0,k.jsx)("span",{className:"status-dot"}),kS(t,e,n)]})}var qS=new Intl.DateTimeFormat("zh-CN",{hour:"numeric",minute:"numeric",second:"numeric",hour12:!1});function Is(t){return qS.format(t)}function tv({state:t,uncertain:e,prefix:n="",peaceful:i=!1}){let[a,l]=(0,Au.useState)(Date.now);(0,Au.useEffect)(()=>{if(!t.running)return;l(Date.now());let v=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(v)},[t.running,t.nextScanAt]);let s=t.running&&!["paused","stopping","error","starting"].includes(t.activity)?t.work:void 0,o=s?.plan&&a-s.plan.startedAt>=2e3?s.plan:void 0,u=s?.frontier!==void 0&&a-s.frontier>=2e3,d=v=>`${Math.max(0,Math.floor((a-v)/1e3))} \u79D2`,c=s?.scanning?"\u626B\u63CF\u4E2D\u2026":t.activity==="paused"?n?"\u8FD4\u56DE\u524D\u53F0\u540E\u626B\u63CF":"\u81EA\u52A8\u6062\u590D\u540E\u626B\u63CF":t.nextScanAt===null?s?.plan?"\u672C\u8F6E\u89C4\u5212\u540E\u8BA1\u65F6":"\u2014":`${Math.max(0,Math.ceil((t.nextScanAt-a)/1e3))} \u79D2\u540E`;return(0,k.jsxs)("div",{className:"status-card",children:[(0,k.jsxs)("div",{className:"section-heading",children:[(0,k.jsx)("h3",{children:"\u5F53\u524D\u52A8\u4F5C"}),(0,k.jsx)(zu,{state:t,uncertain:e,now:a})]}),(0,k.jsx)("p",{id:`${n}auto-status`,className:"auto-status",role:"status","aria-live":"polite",children:s?s.dispatch??(o?`\u6B63\u5728${o.stage}`:s.scanning?"\u6B63\u5728\u66F4\u65B0\u6218\u533A\u8986\u76D6\u4E0E\u60C5\u62A5":t.queue.length?`\u6309\u5DF2\u6709\u8BA1\u5212\u6267\u884C\uFF0C\u5F85\u6267\u884C ${t.queue.length} \u9879`:s.background?`\u540E\u53F0\u786E\u8BA4 / \u540C\u6B65 ${s.background} \u9879\uFF1B\u76D1\u6D4B\u524D\u7EBF\u53D8\u5316`:"\u6682\u65E0\u5F85\u6267\u884C\u4EFB\u52A1\uFF1B\u76D1\u6D4B\u5175\u529B\u53D8\u5316\uFF0C\u7B49\u5F85\u65B0\u673A\u4F1A"):t.phase}),s&&(0,k.jsxs)("div",{className:"expansion-progress",children:[(0,k.jsx)("p",{className:"planning-status",children:o?(0,k.jsxs)(k.Fragment,{children:["\u5168\u5C40\u89C4\u5212\uFF1A",o.stage,o.total!==void 0?` \xB7 \u5DF2\u68C0\u67E5 ${o.completed??0}/${o.total} \u9897\u6765\u6E90`:""," \xB7 \u5DF2\u8017\u65F6 ",d(o.startedAt),"\uFF1B\u5DF2\u6709\u961F\u5217\u7EE7\u7EED\u6267\u884C"]}):"\u540E\u53F0\u8BC4\u4F30\uFF1A\u6301\u7EED\u76D1\u6D4B\uFF1B\u5DF2\u6709\u961F\u5217\u7EE7\u7EED\u6267\u884C"}),!n&&(0,k.jsxs)("p",{className:"frontier-status",children:[i?"\u9668\u77F3\u76D1\u6D4B":"\u524D\u7EBF\u76D1\u6D4B","\uFF1A",!i&&u?`\u6B63\u5728\u68C0\u67E5 \xB7 ${d(s.frontier)}`:"\u5DF2\u5F00\u542F"]}),(0,k.jsxs)("p",{children:["\u5F85\u6267\u884C ",t.queue.length," \u9879 \xB7 \u540E\u53F0\u56DE\u6267 / \u540C\u6B65 ",s.background??0," \u9879",s.inventory?` \xB7 \u5E93\u5B58\u91CD\u8BD5 ${s.inventory} \u9897\u6765\u6E90`:""]}),(0,k.jsxs)("p",{className:"muted",children:["\u6700\u8FD1\u4E8B\u4EF6\uFF1A",t.phase]})]}),t.suns?.map(v=>(0,k.jsx)("p",{children:v.waiting??`\u672C\u8F6E\u6052\u661F\u76EE\u6807 #${v.target}${v.hub!==void 0?`\uFF0C\u6C47\u96C6\u661F\u7403 #${v.hub}`:""}`},String(v.target))),t.logistics?.map(v=>(0,k.jsxs)("div",{className:"rally-status",children:[(0,k.jsxs)("strong",{children:[v.kind==="sun"?"\u6052\u661F\u52DF\u96C6":"\u524D\u7EBF\u8865\u7ED9","\uFF1A#",String(v.hub)," \u2192 #",String(v.target)]}),(0,k.jsxs)("p",{children:[v.phase," \xB7 \u53EF\u7528 ",v.available,"/",v.required," \xB7 \u8865\u7ED9\u5728\u9014 ",v.incoming,(0,k.jsx)("br",{}),"\u5F85\u52DF\u96C6 ",v.donors," \u9897 \xB7 \u822A\u8DEF\u5DF2\u68C0\u67E5 ",v.checked,"/",v.total,(0,k.jsx)("br",{}),"\u4E0D\u5347\u7EA7\u9884\u8BA1\u5360\u9886\uFF1A",Number.isFinite(v.readyMs)?`${Math.ceil(v.readyMs/6e4)} \u5206\u949F`:"\u7B49\u5F85\u8DB3\u591F\u5175\u529B",v.upgradeMs!==void 0?`\uFF1B\u5148\u5347 2 \u7EA7\u7EA6 ${Math.ceil(v.upgradeMs/6e4)} \u5206\u949F`:""]})]},`${v.kind}:${v.target}`)),t.diagnostics&&(0,k.jsxs)("details",{children:[(0,k.jsx)("summary",{children:"\u8017\u65F6\u4E0E\u6570\u636E\u6765\u6E90"}),t.work?.planningTiming&&(0,k.jsxs)("p",{children:["\u672C\u8F6E\u5206\u7247\u8BA1\u7B97 ",Math.round(t.work.planningTiming.computeMs)," ms \xB7 \u8C03\u5EA6\u7B49\u5F85 ",W0(t.work.planningTiming)," ms \xB7 \u6062\u590D\u68C0\u67E5 ",Math.round(t.work.planningTiming.refreshMs)," ms\uFF08",t.work.planningTiming.slices," \u6B21\u5206\u7247\uFF09"]}),t.work?.frontierTiming&&(0,k.jsxs)("p",{children:["\u6700\u8FD1\u524D\u7EBF\u68C0\u67E5\uFF1A\u8BA1\u7B97 ",Math.round(t.work.frontierTiming.computeMs)," ms \xB7 \u8C03\u5EA6\u7B49\u5F85 ",W0(t.work.frontierTiming)," ms"]}),(0,k.jsxs)("p",{children:["\u5185\u5B58\u5FEB\u7167 ",Math.round(t.diagnostics.readMs)," ms \xB7 \u6700\u8FD1\u8986\u76D6\u626B\u63CF ",Math.round(t.diagnostics.scanMs)," ms",(0,k.jsx)("br",{}),"\u5176\u4E2D\u5B98\u65B9\u5E93\u5B58\u904D\u5386 ",Math.round(t.diagnostics.ownedBodiesMs??0)," ms \xB7 \u7D2F\u8BA1\u5FEB\u7167 ",t.diagnostics.readCalls??0," \u6B21 / ",Math.round(t.diagnostics.readTotalMs??0)," ms",(0,k.jsx)("br",{}),"\u626B\u63CF\u65B0\u589E\u8BA2\u9605 ",t.diagnostics.newSubscriptions," \u4E2A / \u590D\u7528 ",t.diagnostics.reusedSubscriptions," \u4E2A",(0,k.jsx)("br",{}),"\u7D2F\u8BA1\u539F\u751F\u5185\u5B58\u62A5\u4EF7 ",t.diagnostics.quoteCalls," \u6B21 / ",Math.round(t.diagnostics.quoteMs)," ms",(0,k.jsx)("br",{}),"\u5355\u6B21\u62A5\u4EF7\u5E73\u5747 ",Math.round(t.diagnostics.quoteMs/Math.max(1,t.diagnostics.quoteCalls))," ms \xB7 \u6700\u6162 ",Math.round(t.diagnostics.quoteMaxMs??0)," ms \xB7 \u8D85\u8FC7 8 ms \u5171 ",t.diagnostics.slowQuotes??0," \u6B21",(0,k.jsx)("br",{}),"\u5E93\u5B58\u540C\u6B65 ",t.diagnostics.syncCalls??0," \u6279 / ",t.diagnostics.syncQueries??0," \u6B21\u8BA2\u9605 \xB7 \u6B63\u5728\u540C\u6B65 ",t.diagnostics.syncActive??0," \u6279",(0,k.jsx)("br",{}),"\u6700\u8FD1\u540C\u6B65 ",Math.round(t.diagnostics.syncMs)," ms \xB7 \u7D2F\u8BA1 ",Math.round(t.diagnostics.syncTotalMs??0)," ms\uFF08\u5E76\u53D1\u65F6\u95F4\u4E0D\u76F8\u52A0\u5230\u89C4\u5212\u8017\u65F6\uFF09"]}),(0,k.jsxs)("p",{children:["\u672C\u6B21\u540E\u52E4\u66F4\u65B0 ",Math.round(t.work?.logisticsMs??0)," ms \xB7 \u822A\u8DEF\u65B0\u7B97 ",t.work?.logisticsRoutes??0," / \u590D\u7528 ",t.work?.logisticsReused??0," \u6761"]}),(0,k.jsx)("p",{className:"muted",children:"\u89C4\u5212\u8BFB\u53D6\u6E38\u620F\u5185\u5B58\uFF1B\u8986\u76D6\u8BA2\u9605\u548C\u53D1\u5C04\u540E\u7684\u5E93\u5B58\u786E\u8BA4\u9700\u8981\u670D\u52A1\u5668\u540C\u6B65\u3002"})]}),t.metrics&&(0,k.jsxs)("div",{className:"expansion-progress",children:[(0,k.jsxs)("p",{children:["\u672C\u6B21\u5360\u9886\uFF1A\u661F\u7403 ",t.metrics.planets," \xB7 \u6052\u661F ",t.metrics.suns," \xB7 \u9668\u77F3 ",t.metrics.meteorites,"\uFF1B\u786E\u8BA4\u5347\u7EA7 ",t.metrics.upgrades," \u6B21"]}),(0,k.jsxs)("p",{children:["\u5DF2\u63D0\u4EA4\u5175\u529B ",t.metrics.sentProbes," \xB7 \u5360\u9886\u65F6\u65B0\u589E\u57FA\u7840\u4EA7\u80FD ",t.metrics.addedBaseProduction,"/\u5206\u949F"]}),(0,k.jsxs)("p",{children:["\u6301\u7EED\u4FDD\u6709 30 \u5206\u949F\uFF1A",t.metrics.retention30.held,"/",t.metrics.retention30.total," \xB7 60 \u5206\u949F\uFF1A",t.metrics.retention60.held,"/",t.metrics.retention60.total,"\uFF08\u4EC5\u5DF2\u5230\u89C2\u5BDF\u65F6\u95F4\u7684\u661F\u7403\u4E0E\u6052\u661F\uFF09"]}),!!t.exposed&&(0,k.jsxs)("p",{children:["\u5DF2\u89C2\u6D4B\u5230 ",t.exposed," \u4E2A\u524D\u6CBF\u66B4\u9732\u76EE\u6807\uFF0C\u6309\u6269\u5F20\u53D6\u5411\u5904\u7406\u3002"]})]}),!!t.meteorites?.length&&(0,k.jsxs)("details",{children:[(0,k.jsx)("summary",{children:"\u9668\u77F3\u5FEB\u901F\u68C0\u67E5\uFF08\u6700\u591A 6 \u9897\uFF09"}),(0,k.jsx)("ul",{children:t.meteorites.map(v=>(0,k.jsxs)("li",{children:[(0,k.jsxs)("strong",{children:["\u9668\u77F3 #",String(v.targetId)]}),(0,k.jsx)("br",{}),v.reason]},String(v.targetId)))})]}),!!t.decisions?.length&&(0,k.jsxs)("details",{children:[(0,k.jsx)("summary",{children:"\u672C\u8F6E\u9009\u62E9\u539F\u56E0"}),(0,k.jsx)("ul",{children:t.decisions.map((v,f)=>(0,k.jsx)("li",{children:v},f))})]}),(t.rallies??(t.rally?[t.rally]:[])).map(v=>(0,k.jsxs)("div",{className:"rally-status",children:[(0,k.jsxs)("strong",{children:["\u4E2D\u8F6C\u661F #",String(v.hub)," \u2192 \u76EE\u6807 #",String(v.target)]}),(0,k.jsxs)("p",{children:["\u4E2D\u8F6C\u53EF\u7528 ",v.available," / \u9884\u8BA1\u9700\u8981 ",v.required,(0,k.jsx)("br",{}),"\u8865\u7ED9\u5728\u9014 ",v.incoming," \xB7 \u5F85\u52DF\u96C6\u6765\u6E90 ",v.sources," \u9897"]})]},String(v.hub))),t.attackDiagnostics&&(0,k.jsxs)("div",{className:"expansion-progress",children:[(0,k.jsxs)("p",{children:["\u53EF\u7528\u5175\u529B ",t.attackDiagnostics.available," \xB7 \u6765\u6E90 ",t.attackDiagnostics.sources," \u9897\uFF08\u65E0\u9884\u7B97 ",t.attackDiagnostics.noBudget," \u9897\uFF09"]}),(0,k.jsxs)("p",{children:["\u654C\u65B9\u76EE\u6807 ",t.attackDiagnostics.targets," \xB7 \u5728\u9014 / \u9501\u5B9A ",t.attackDiagnostics.blocked," \xB7 \u8303\u56F4\u5185\u65E0\u53EF\u9009\u76EE\u6807\u7684\u6765\u6E90 ",t.attackDiagnostics.noTargets," \u9897"]}),(0,k.jsxs)("p",{children:["\u68C0\u67E5\u8DEF\u7EBF\uFF1A\u53EF\u76F4\u653B ",t.attackDiagnostics.feasible," \xB7 \u822A\u65F6\u8D85\u9650 ",t.attackDiagnostics.tooSlow," \xB7 \u5175\u529B\u4E0D\u8DB3 ",t.attackDiagnostics.insufficient," \xB7 \u62A5\u4EF7\u4E0D\u53EF\u7528 ",t.attackDiagnostics.noQuote]})]}),t.planning&&(0,k.jsxs)("div",{className:"expansion-progress",children:[(0,k.jsxs)("p",{children:["\u672C\u8F6E\u5DF2\u5B89\u6392 ",t.planning.assigned," / ",t.planning.sources," \u9897\u6765\u6E90 \xB7 ",t.planning.ready," \u9897",i?"\u6709\u53EF\u7528\u5175\u529B":"\u5177\u5907\u53EF\u884C\u65B9\u6848"]}),!!t.planning.idle.length&&(0,k.jsxs)("details",{children:[(0,k.jsx)("summary",{children:"\u672A\u6D3E\u5175\u539F\u56E0\uFF08\u6700\u591A\u663E\u793A 6 \u9897\uFF09"}),(0,k.jsx)("ul",{children:t.planning.idle.slice(0,6).map(v=>(0,k.jsxs)("li",{children:[(0,k.jsxs)("strong",{children:["#",String(v.sourceId)," (",v.x,", ",v.y,") \xB7 \u53EF\u7528 ",v.available]}),(0,k.jsx)("br",{}),v.reason]},String(v.sourceId)))})]})]}),(0,k.jsxs)("dl",{className:"scan-stats",children:[(0,k.jsxs)("div",{children:[(0,k.jsx)("dt",{children:"\u5DF1\u65B9\u661F\u7403"}),(0,k.jsx)("dd",{children:t.lastScanAt===null?"\u2014":t.ownedCount})]}),(0,k.jsxs)("div",{children:[(0,k.jsx)("dt",{children:"\u5019\u9009\u76EE\u6807"}),(0,k.jsx)("dd",{children:t.lastScanAt===null?"\u2014":t.candidateCount})]}),(0,k.jsxs)("div",{children:[(0,k.jsx)("dt",{children:"\u4E0B\u6B21\u626B\u63CF"}),(0,k.jsx)("dd",{id:`${n}next-scan`,children:c})]})]}),(0,k.jsx)("p",{className:"muted",children:t.lastScanAt===null?"\u542F\u52A8\u540E\u52A0\u8F7D\u6218\u533A\u4E0E\u5468\u56F4\u60C5\u62A5\u3002":`\u6700\u8FD1\u626B\u63CF ${Is(t.lastScanAt)} \xB7 \u672C\u8F6E\u89C4\u5212\u5B8C\u6210\u540E\u5F00\u59CB\u626B\u63CF\u5012\u8BA1\u65F6`})]})}var on=ht(Bt(),1),HS=(0,ev.memo)(function({entry:e}){return(0,on.jsxs)("li",{className:`log-entry ${e.level}`,children:[(0,on.jsx)("time",{dateTime:new Date(e.time).toISOString(),children:Is(e.time)}),(0,on.jsx)("span",{children:e.message})]})});function nv({entries:t,prefix:e=""}){return(0,on.jsxs)("div",{className:"log-card",children:[(0,on.jsxs)("div",{className:"section-heading",children:[(0,on.jsx)("h3",{children:"\u8FD0\u884C\u65E5\u5FD7"}),(0,on.jsxs)("span",{className:"muted",children:["\u6700\u8FD1 ",t.length," / 100 \u6761"]})]}),t.length===0?(0,on.jsx)("p",{className:"empty",children:"\u5C1A\u65E0\u65E5\u5FD7\uFF0C\u542F\u52A8\u540E\u4F1A\u8BB0\u5F55\u626B\u63CF\u3001\u6D3E\u5175\u4E0E\u5360\u9886\u7ED3\u679C\u3002"}):(0,on.jsx)("ol",{id:`${e}activity-log`,className:"activity-log","aria-label":"\u8FD0\u884C\u65E5\u5FD7\uFF0C\u6700\u65B0\u5728\u524D",children:t.slice().reverse().map(n=>(0,on.jsx)(HS,{entry:n},n.id))})]})}var V=ht(Bt(),1);function iv({mode:t,region:e,summary:n,state:i,settings:a,logs:l,uncertain:s,settingsOpen:o,onToggleSettings:u,onSettingChange:d,onStart:c,onStop:v}){let f=t==="attack",m=!f&&a.peacefulDevelopment==="1",y=f?"\u8FDB\u653B":m?"\u5B89\u7A33\u53D1\u80B2":"\u6269\u5F20",h=f?"attack-":"",S=`${t}-settings`;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)("div",{className:"run-controls",children:[(0,V.jsx)("button",{id:`${h}start`,className:"primary",disabled:s||i.running,onClick:c,children:i.running?`${y}\u5DF2\u542F\u52A8`:`\u5F00\u59CB${y}`}),(0,V.jsx)("button",{id:`${h}stop`,className:"danger",disabled:!i.running||i.activity==="stopping",onClick:v,children:i.activity==="stopping"?"\u6B63\u5728\u505C\u6B62\u2026":`\u505C\u6B62${y}`})]}),(0,V.jsxs)("div",{className:"settings-card",children:[(0,V.jsxs)("button",{id:`${h}settings-toggle`,className:"settings-toggle","aria-expanded":o,"aria-controls":S,onClick:u,children:[(0,V.jsxs)("span",{children:[(0,V.jsxs)("strong",{children:[y,"\u8BBE\u7F6E"]}),(0,V.jsx)("small",{children:n})]}),(0,V.jsx)("span",{children:o?"\u6536\u8D77 \u25B4":"\u5C55\u5F00 \u25BE"})]}),(0,V.jsxs)("div",{id:S,className:"settings-content",hidden:!o,children:[i.running&&(0,V.jsx)("p",{className:"notice",children:"\u8FD0\u884C\u4E2D\u53EF\u67E5\u770B\u8BBE\u7F6E\uFF0C\u505C\u6B62\u540E\u53EF\u4FEE\u6539\u3002"}),e,(0,V.jsx)(F0,{attack:f,value:a,disabled:i.running,onChange:d}),(0,V.jsx)("p",{children:f?"\u9644\u8FD1\u5175\u529B\u53EF\u76F4\u63A5\u8FDB\u653B\uFF0C\u8FDC\u5904\u4F59\u5175\u6309\u9700\u5411\u4E2D\u8F6C\u661F\u96C6\u7ED3\uFF0C\u4E24\u7C7B\u4EFB\u52A1\u4EA4\u66FF\u6267\u884C\u3002\u51FA\u51FB\u65F6\u91CD\u65B0\u62A5\u4EF7\uFF0C\u8BA1\u5165\u4EA7\u5175\u4F59\u91CF\u548C\u8BBE\u5B9A\u7684\u5360\u9886\u5B88\u519B\u3002":m?"\u6301\u7EED\u626B\u63CF\u65E0\u4E3B\u9668\u77F3\uFF0C\u6838\u5BF9\u6392\u961F\u65F6\u95F4\u3001\u822A\u7A0B\u548C\u6D88\u5931\u65F6\u95F4\u540E\u6D3E\u5175\uFF1B\u4FDD\u7559\u9632\u5B88\u9884\u7B97\uFF0C\u53EF\u9009\u8FDE\u7EED\u7A33\u5B9A\u540E\u7684\u5355\u7EA7\u5347\u7EA7\u3002\u9668\u77F3\u6301\u6709\u81F3\u5230\u671F\u624D\u83B7\u5F97\u5956\u52B1\uFF0C\u9A7B\u519B\u968F\u4E4B\u6D88\u5931\u3002":"\u5355\u661F\u6309\u6E38\u620F\u5360\u9886\u62A5\u4EF7\u6D3E\u5175\u3002\u65E0\u4E3B\u884C\u661F\u9A7B\u519B\u4E3A 4 \u65F6\uFF0C\u96F6\u822A\u635F\u6D3E 5 \u4E2A\u63A2\u9488\uFF1B\u5408\u5175\u6309\u5404\u8230\u961F\u822A\u635F\u51D1\u8DB3\u62B5\u8FBE\u5175\u529B\u3002\u540C\u6837\u5360\u70B9\u6570\u4F18\u5148\u66F4\u65E9\u5B8C\u6210\u5360\u9886\uFF0C\u65F6\u95F4\u76F8\u540C\u518D\u4F18\u5148\u5C11\u7528\u8230\u961F\u3002"})]})]}),(0,V.jsx)(tv,{peaceful:m,prefix:h,state:i,uncertain:s}),(0,V.jsxs)("dl",{id:`${h}auto-counts`,className:"run-stats",children:[(0,V.jsxs)("div",{children:[(0,V.jsx)("dd",{children:i.sent}),(0,V.jsx)("dt",{children:"\u5DF2\u53D1\u8230\u961F"})]}),(0,V.jsxs)("div",{className:"success",children:[(0,V.jsx)("dd",{children:i.captured}),(0,V.jsx)("dt",{children:"\u5DF2\u5360\u9886"})]}),(0,V.jsxs)("div",{children:[(0,V.jsx)("dd",{children:i.flights}),(0,V.jsx)("dt",{children:"\u5728\u9014 / \u9501\u5B9A"})]}),(0,V.jsxs)("div",{children:[(0,V.jsx)("dd",{children:i.missed}),(0,V.jsx)("dt",{children:"\u672A\u5360\u9886"})]})]}),(0,V.jsx)(nv,{prefix:h,entries:l.filter(p=>!p.mode||p.mode===t)}),(0,V.jsxs)("div",{className:"queue-card",children:[(0,V.jsxs)("div",{className:"section-heading",children:[(0,V.jsxs)("h3",{children:["\u5F85\u6267\u884C ",(0,V.jsx)("span",{className:"count",children:i.queue.length})]}),(0,V.jsx)("span",{className:"muted",children:f?"\u96C6\u7ED3 / \u51FA\u51FB \xB7 1 \u79D2\u72EC\u7ACB\u961F\u5217":i.exact?"\u5019\u9009\u96C6\u6700\u4F18\u65B9\u6848":"\u6709\u754C\u4F18\u5316\u65B9\u6848"})]}),i.queue.length===0?(0,V.jsx)("p",{className:"empty",children:i.running?"\u6682\u65E0\u6392\u961F\u4EFB\u52A1\uFF0C\u8BE6\u89C1\u5F53\u524D\u52A8\u4F5C\u3002":"\u542F\u52A8\u540E\u6839\u636E\u5175\u529B\u4E0E\u9644\u8FD1\u76EE\u6807\u751F\u6210\u8BA1\u5212\u3002"}):(0,V.jsx)("ol",{id:`${h}auto-queue`,className:"auto-queue","aria-label":"\u6D3E\u5175\u961F\u5217",children:i.queue.slice(0,5).map(p=>(0,V.jsxs)("li",{children:[(0,V.jsxs)("strong",{children:[hl(p)," \u2192 ",De(p)]}),(0,V.jsxs)("span",{children:[p.kind==="upgrade"?`\u5347\u81F3 ${(p.expectedLevel??0)+1} \u7EA7 \xB7 \u9884\u7B97\u4E0A\u9650 ${p.count} \u63A2\u9488`:`${pe(p)} \u63A2\u9488 \xB7 \u822A\u884C\u7EA6 ${Math.ceil(ot(p)/1e3)} \u79D2`,p.kind==="reinforce"?" \xB7 \u5DF1\u65B9\u4E2D\u8F6C\u96C6\u7ED3":p.kind==="sun-supply"?" \xB7 \u6052\u661F\u8865\u7ED9":p.support?.length?" \xB7 \u5408\u5175":""]})]},st(p)))}),i.queue.length>5&&(0,V.jsxs)("p",{className:"muted",children:["\u53E6\u6709 ",i.queue.length-5," \u9879\uFF0C",f?"\u6267\u884C\u524D\u4F1A\u518D\u6B21\u6821\u9A8C":"\u6309\u672C\u8F6E\u8BA1\u5212\u4F9D\u6B21\u6267\u884C","\u3002"]})]}),(0,V.jsxs)("p",{className:"footer-note",children:["\u6536\u8D77\u6216\u5207\u6362 Tab \u7EE7\u7EED\u8FD0\u884C\uFF1B",f?"\u8FDB\u653B\u5728\u540E\u53F0\u6682\u505C\u6D3E\u5175":"\u6269\u5F20\u5728\u540E\u53F0\u7EE7\u7EED\uFF0C\u65AD\u7EBF\u81EA\u52A8\u5C1D\u8BD5\u6062\u590D","\u3002\u53D1\u5C04\u4E0D\u4EE3\u8868\u5360\u9886\uFF0C\u626B\u63CF\u540E\u6838\u5B9E\u7ED3\u679C\u3002"]})]})}var cd=ht(xn(),1),Y=ht(Bt(),1);function av({mode:t,value:e,preview:n,disabled:i,onChange:a,onPick:l,onPreview:s,onFocus:o,onFocusEnemy:u,onPickHub:d}){let[c,v]=(0,cd.useState)(""),[f,m]=(0,cd.useState)(""),y=p=>`${t}-${p==="radius"?"zone-radius":p}`,h=n.enemies.filter(p=>`${p.name} ${p.id}`.toLowerCase().includes(c.toLowerCase())),S=(n.hubs??[]).filter(p=>`${p.id} ${p.x},${p.y}`.includes(f));return(0,Y.jsxs)("div",{className:"region-settings",children:[(0,Y.jsx)("h3",{children:"\u4F5C\u6218\u533A\u57DF"}),t==="expansion"&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("label",{htmlFor:y("scope"),children:"\u53C2\u4E0E\u8303\u56F4"}),(0,Y.jsxs)("select",{id:y("scope"),disabled:i,value:e.scope,onChange:p=>a("scope",p.target.value),children:[(0,Y.jsx)("option",{value:"all",children:"\u5168\u90E8\u9886\u5730"}),(0,Y.jsx)("option",{value:"circle",children:"\u56FA\u5B9A\u533A\u57DF\uFF08\u63A8\u8350\u5206\u533A\u8FD0\u884C\uFF09"})]})]}),(0,Y.jsxs)("div",{className:"region-actions",children:[(0,Y.jsx)("button",{id:y("pick-view"),disabled:i,onClick:()=>l("view"),children:"\u7528\u5730\u56FE\u89C6\u91CE\u4E2D\u5FC3"}),(0,Y.jsx)("button",{id:y("pick-selection"),disabled:i,onClick:()=>l("selection"),children:"\u7528\u9009\u4E2D\u661F\u7403"})]}),e.scope==="circle"&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{className:"coordinate-grid",children:["x","y","radius"].map(p=>(0,Y.jsxs)("div",{children:[(0,Y.jsx)("label",{htmlFor:y(p),children:p==="radius"?"\u533A\u57DF\u534A\u5F84":`\u4E2D\u5FC3 ${p.toUpperCase()}`}),(0,Y.jsx)("input",{id:y(p),type:"number",step:"1",min:p==="radius"?1:void 0,max:p==="radius"?128:void 0,value:e[p],disabled:i,onChange:r=>a(p,r.target.value)})]},p))}),(0,Y.jsxs)("div",{className:"region-actions",children:[(0,Y.jsx)("button",{id:y("preview"),disabled:n.busy||i,onClick:s,children:n.busy?"\u52A0\u8F7D\u4E2D\u2026":"\u52A0\u8F7D\u533A\u57DF\u4E0E\u654C\u4EBA"}),(0,Y.jsx)("button",{onClick:o,children:"\u5730\u56FE\u5B9A\u4F4D"})]}),(0,Y.jsx)("p",{children:"\u4EC5\u533A\u57DF\u5185\u661F\u7403\u51FA\u5175\uFF0C\u76EE\u6807\u4E5F\u987B\u4F4D\u4E8E\u533A\u57DF\u5185\u3002\u5360\u9886\u65B0\u661F\u7403\u4E0D\u4F1A\u6269\u5927\u8FB9\u754C\u3002"})]}),n.message&&(0,Y.jsx)("p",{id:y("preview-status"),role:"status",children:n.message}),t==="attack"&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("label",{htmlFor:y("enemy-search"),children:"\u7B5B\u9009\u654C\u4EBA\u540D\u5B57 / ID"}),(0,Y.jsx)("input",{id:y("enemy-search"),type:"search",value:c,placeholder:"\u5148\u52A0\u8F7D\u533A\u57DF\uFF0C\u518D\u6309\u540D\u5B57\u67E5\u627E",onChange:p=>v(p.target.value)}),(0,Y.jsx)("label",{htmlFor:y("enemy"),children:"\u8FDB\u653B\u5BF9\u8C61"}),(0,Y.jsxs)("select",{id:y("enemy"),disabled:i,value:e.enemy,onChange:p=>a("enemy",p.target.value),children:[(0,Y.jsx)("option",{value:"",children:"\u533A\u57DF\u5185\u6240\u6709\u975E\u76DF\u53CB"}),e.enemy&&!h.some(p=>p.id===e.enemy)&&(0,Y.jsxs)("option",{value:e.enemy,children:["\u5DF2\u6307\u5B9A\uFF1A",e.enemy.slice(0,12),"\u2026"]}),h.map(p=>(0,Y.jsxs)("option",{value:p.id,children:[p.name," \xB7 ",p.count," \u9897 \xB7 ",p.id.slice(0,6)]},p.id))]}),(0,Y.jsx)("button",{className:"locate-enemy",disabled:!n.enemies.some(p=>p.id===e.enemy),onClick:()=>u(e.enemy),children:"\u5B9A\u4F4D\u8BE5\u654C\u4EBA\u5728\u533A\u57DF\u5185\u7684\u661F\u7403"}),(0,Y.jsx)("p",{children:"\u81EA\u52A8\u6392\u9664\u81EA\u5DF1\u4E0E\u540C\u8054\u76DF\u73A9\u5BB6\uFF1B\u8054\u76DF\u5173\u7CFB\u53D8\u5316\u540E\u4F1A\u91CD\u65B0\u6821\u9A8C\u3002"}),(0,Y.jsx)("h3",{className:"policy-heading",children:"\u4E2D\u8F6C\u96C6\u7ED3"}),(0,Y.jsx)("label",{htmlFor:y("hub-search"),children:"\u7B5B\u9009\u5DF1\u65B9\u4E2D\u8F6C\u661F ID / \u5750\u6807"}),(0,Y.jsx)("input",{id:y("hub-search"),type:"search",value:f,onChange:p=>m(p.target.value),placeholder:"\u52A0\u8F7D\u533A\u57DF\u540E\u53EF\u9009\u62E9\uFF0C\u6216\u4ECE\u5730\u56FE\u8BFB\u53D6"}),(0,Y.jsx)("label",{htmlFor:y("rallyId"),children:"\u521D\u59CB\u4E2D\u8F6C\u661F"}),(0,Y.jsxs)("select",{id:y("rallyId"),disabled:i,value:e.rallyId,onChange:p=>a("rallyId",p.target.value),children:[(0,Y.jsx)("option",{value:"",children:"\u81EA\u52A8\u9009\u62E9\u5408\u9002\u636E\u70B9"}),e.rallyId&&!S.some(p=>p.id===e.rallyId)&&(0,Y.jsxs)("option",{value:e.rallyId,children:["\u5DF2\u6307\u5B9A #",e.rallyId]}),S.map(p=>(0,Y.jsxs)("option",{value:p.id,children:["#",p.id," \xB7 (",p.x,", ",p.y,") \xB7 ",p.probes," \u63A2\u9488"]},p.id))]}),(0,Y.jsx)("button",{id:y("pick-hub"),className:"locate-enemy",disabled:i,onClick:d,children:"\u7528\u5730\u56FE\u9009\u4E2D\u7684\u5DF1\u65B9\u884C\u661F\u4F5C\u4E2D\u8F6C"}),(0,Y.jsx)("label",{htmlFor:y("rallyHubs"),children:"\u540C\u65F6\u96C6\u7ED3\u636E\u70B9\u6570"}),(0,Y.jsx)("select",{id:y("rallyHubs"),disabled:i||!!e.rallyId,value:e.rallyId?"1":e.rallyHubs,onChange:p=>a("rallyHubs",p.target.value),children:[1,2,3].map(p=>(0,Y.jsxs)("option",{value:p,children:[p," \u4E2A\u636E\u70B9"]},p))}),(0,Y.jsx)("p",{children:"\u81EA\u52A8\u9009\u62E9\u5148\u68C0\u67E5\u53EF\u8FDB\u653B\u822A\u7EBF\u548C\u5DF2\u77E5\u6765\u88AD\uFF0C\u518D\u6BD4\u8F83\u96C6\u7ED3\u52A0\u8FDB\u653B\u7684\u603B\u62B5\u8FBE\u65F6\u95F4\u3002\u5404\u636E\u70B9\u6309\u9700\u5206\u914D\u4F59\u5175\u3001\u8F6E\u6D41\u8865\u7ED9\uFF1B\u6307\u5B9A\u4E2D\u8F6C\u661F\u65F6\u4EC5\u4F7F\u7528\u8BE5\u636E\u70B9\uFF0C\u9644\u8FD1\u76F4\u653B\u4ECD\u72EC\u7ACB\u8FDB\u884C\u3002"}),(0,Y.jsx)("label",{htmlFor:y("rallyMinutes"),children:"\u8865\u7ED9\u6700\u957F\u822A\u884C\u65F6\u95F4\uFF08\u5206\u949F\uFF0C1\u2013240\uFF09"}),(0,Y.jsx)("input",{id:y("rallyMinutes"),type:"number",min:"1",max:"240",disabled:i,value:e.rallyMinutes,onChange:p=>a("rallyMinutes",p.target.value)}),(0,Y.jsx)("label",{htmlFor:y("advanceHub"),children:"\u653B\u4E0B\u636E\u70B9\u540E"}),(0,Y.jsxs)("select",{id:y("advanceHub"),disabled:i,value:e.advanceHub,onChange:p=>a("advanceHub",p.target.value),children:[(0,Y.jsx)("option",{value:"yes",children:"\u524D\u79FB\u4E2D\u8F6C\u661F\uFF0C\u5728\u539F\u6218\u533A\u5185\u7EE7\u7EED\u63A8\u8FDB"}),(0,Y.jsx)("option",{value:"no",children:"\u4FDD\u7559\u521D\u59CB\u4E2D\u8F6C\u661F"})]}),(0,Y.jsx)("p",{children:"\u9644\u8FD1\u661F\u7403\u53EF\u76F4\u63A5\u653B\u654C\uFF1B\u5176\u4F59\u5175\u529B\u6309\u9700\u96C6\u7ED3\uFF0C\u6BCF\u6279\u6700\u591A 50 \u4E2A\u6765\u6E90\u3002\u4E2D\u8F6C\u661F\u5B9E\u9645\u6536\u5230\u5175\u529B\u540E\u518D\u51FA\u51FB\uFF0C\u9009\u5B9A\u4E2D\u8F6C\u661F\u4E0D\u9650\u5236\u5176\u4ED6\u661F\u7403\u76F4\u63A5\u8FDB\u653B\u3002"})]}),(0,Y.jsx)("h3",{className:"policy-heading",children:"\u52A8\u6001\u7559\u5175"}),(0,Y.jsxs)("div",{className:"coordinate-grid",children:[(0,Y.jsxs)("div",{children:[(0,Y.jsx)("label",{htmlFor:y("frontlinePercent"),children:"\u524D\u7EBF\u7559\u5175 %"}),(0,Y.jsx)("input",{id:y("frontlinePercent"),type:"number",min:"0",max:"90",disabled:i,value:e.frontlinePercent,onChange:p=>a("frontlinePercent",p.target.value)})]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)("label",{htmlFor:y("threatRadius"),children:"\u654C\u65B9\u8B66\u6212\u8DDD\u79BB"}),(0,Y.jsx)("input",{id:y("threatRadius"),type:"number",min:"1",max:"128",disabled:i,value:e.threatRadius,onChange:p=>a("threatRadius",p.target.value)})]}),t==="attack"&&(0,Y.jsxs)("div",{children:[(0,Y.jsx)("label",{htmlFor:y("holdProbes"),children:"\u5360\u9886\u540E\u7559\u5175"}),(0,Y.jsx)("input",{id:y("holdProbes"),type:"number",min:"2",max:"1000000",disabled:i,value:e.holdProbes,onChange:p=>a("holdProbes",p.target.value)})]})]}),(0,Y.jsx)("p",{children:"\u8B66\u6212\u8DDD\u79BB\u5185\u6709\u654C\u4EBA\u7684\u6765\u6E90\u63D0\u9AD8\u7559\u5175\uFF1B\u5DF2\u77E5\u6765\u88AD\u6309\u62B5\u8FBE\u987A\u5E8F\u9010\u6CE2\u9884\u7559\u5B88\u519B\uFF0C\u4EC5\u62B5\u6263\u7559\u6709\u4E00\u5206\u949F\u7F13\u51B2\u7684\u57FA\u7840\u4EA7\u5175\uFF0C\u4E0D\u63D0\u524D\u8BA1\u5165\u5728\u9014\u8865\u7ED9\u3002\u542F\u7528\u6E38\u620F\u81EA\u52A8\u5347\u7EA7 / \u8F6C\u53D1\u7684\u6765\u6E90\u4E0D\u53C2\u4E0E\u6D3E\u5175\u3002"})]})}var ai=ht(Bt(),1);function lv({reviewed:t,busy:e,status:n,onReviewedChange:i,onUnlock:a}){return(0,ai.jsxs)("details",{children:[(0,ai.jsx)("summary",{children:"\u53D1\u5C04\u7ED3\u679C\u672A\u77E5\u65F6\u6062\u590D"}),(0,ai.jsx)("p",{children:"\u8BF7\u5148\u6838\u5BF9\u6E38\u620F\u65E5\u5FD7\u4E0E\u5728\u9014\u8230\u961F\u3002\u89E3\u9664\u9501\u5B9A\u4E0D\u4F1A\u81EA\u52A8\u542F\u52A8\u6269\u5F20\u3002"}),(0,ai.jsxs)("label",{children:[(0,ai.jsx)("input",{id:"reviewed",type:"checkbox",checked:t,disabled:e,onChange:l=>i(l.target.checked)})," \u6211\u5DF2\u6838\u5B9E\u6E38\u620F\u4E2D\u7684\u53D1\u5C04\u7ED3\u679C"]}),(0,ai.jsx)("button",{id:"unlock",disabled:e,onClick:a,children:"\u89E3\u9664\u53D1\u5C04\u9501\u5B9A"}),(0,ai.jsx)("p",{id:"unlock-status",role:"status",children:n})]})}var sv=`:host { all: initial; position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: max(24px, env(safe-area-inset-bottom)); z-index: 2147483000; font: 13px/1.55 system-ui, sans-serif; color: #e6edf7; color-scheme: dark; } * { box-sizing: border-box; } [hidden] { display: none !important; } button, select, input { font: inherit; color: inherit; border: 1px solid #354961; border-radius: 8px; background: #172638; padding: 9px 11px; max-width: 100%; } button { cursor: pointer; } button:hover:not(:disabled) { background: #21364c; } button:disabled { opacity: .45; cursor: default; } button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid #70cfff; outline-offset: 2px; } h2, h3, p, dl, dd { margin: 0; } h2 { font-size: 16px; letter-spacing: .3px; } h3 { font-size: 13px; font-weight: 600; } p { margin-top: 10px; color: #aebed2; font-size: 12px; } label { display: block; margin: 12px 0 5px; color: #c4d0e0; font-size: 12px; } .setting-heading { position: relative; display: flex; align-items: center; gap: 6px; margin: 12px 0 5px; } .setting-heading label { margin: 0; } .setting-help { display: inline-flex; flex-shrink: 0; } .help-trigger { width: 18px; height: 18px; padding: 0; border-radius: 50%; color: #9db3cc; font-size: 11px; line-height: 16px; background: transparent; } .setting-tip { position: absolute; top: 100%; left: 0; width: 100%; z-index: 10; padding: 10px 12px; border: 1px solid #49617e; border-radius: 8px; background: #1a2b40; box-shadow: 0 4px 16px #0008; color: #d3dfed; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; } select, input { width: 100%; } .strategy-toggle { display: flex; align-items: center; gap: 8px; } .strategy-toggle input { width: 16px; height: 16px; padding: 0; flex-shrink: 0; } strong { font-weight: 600; } .muted, small { color: #8ea3bc; font-size: 11px; } section, #toggle { box-shadow: 0 8px 32px #0009; border: 1px solid #354963; background: #0d1726f7; } section { width: min(380px, calc(100vw - 32px)); max-height: min(780px, calc(100dvh - 48px)); overflow: auto; border-radius: 16px; padding: 16px; scrollbar-width: thin; } header, .section-heading, .compact-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; } header { margin-bottom: 16px; } header button { padding: 5px 9px; font-size: 12px; background: transparent; } #toggle { display: block; width: min(320px, calc(100vw - 32px)); padding: 12px 14px; border-radius: 14px; text-align: left; } #compact-log { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: #afc1d8; font-size: 12px; margin-top: 7px; overflow-wrap: anywhere; } .status-badge { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; font-size: 11px; color: #a7b8cd; } .status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; } .status-badge.active, .success { color: #7ce0bf; } .status-badge.warning, .warning { color: #f0c478; } .status-badge.error, .error { color: #ff9c9c; } .tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 10px; background: #070f1c; } .tabs button { flex: 1; border: 0; background: transparent; padding: 9px 4px; color: #94a8c3; } .tabs button[aria-selected="true"] { background: #203a50; color: #b9e8ff; box-shadow: 0 1px 4px #0005; } .tabs small { font-size: 10px; margin-left: 3px; } .run-controls { display: flex; gap: 8px; margin: 12px 0; } .run-controls button { flex: 1; } button.primary { background: #186e88; border-color: #258aa4; font-weight: 600; } button.primary:hover:not(:disabled) { background: #21819c; } button.danger { color: #ffaaaa; border-color: #683e4d; } .settings-card, .status-card, .queue-card, .log-card { margin-top: 12px; padding: 12px; border: 1px solid #263a52; border-radius: 10px; background: #111f30; } .settings-card { padding: 0; background: transparent; } .settings-toggle { border: 0; width: 100%; padding: 11px 12px; background: transparent; display: flex; justify-content: space-between; align-items: center; text-align: left; font-size: 12px; gap: 8px; } .settings-toggle small { display: block; margin-top: 2px; } .settings-content { padding: 0 12px 12px; border-top: 1px solid #263a52; } .auto-status { font-size: 13px; color: #d8e8f8; overflow-wrap: anywhere; } .scan-stats { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; margin-top: 14px; } .scan-stats dt, .run-stats dt { color: #93a9c2; font-size: 11px; } .scan-stats dd { font-size: 13px; margin-top: 3px; } .run-stats { display: grid; grid-template-columns: repeat(4, 1fr); padding: 14px 0 2px; text-align: center; } .run-stats dd { font-size: 23px; font-weight: 600; font-variant-numeric: tabular-nums; } .count { display: inline-block; border-radius: 4px; background: #253e58; padding: 0 5px; margin-left: 3px; font-size: 11px; } .empty { padding: 5px 0; color: #8ea3bc; } ol { list-style: none; margin: 10px 0 0; padding: 0; } .auto-queue li { border-top: 1px solid #26364c; padding: 8px 0; overflow-wrap: anywhere; } .auto-queue li:last-child { padding-bottom: 0; } .auto-queue strong { display: block; font-size: 12px; } .auto-queue span { font-size: 11px; color: #9bb1cb; } .activity-log { max-height: 210px; overflow: auto; scrollbar-width: thin; } .log-entry { display: grid; grid-template-columns: 55px 1fr; gap: 8px; padding: 7px 0; border-top: 1px solid #23354a; font-size: 12px; } .log-entry time { color: #829bb8; font-size: 11px; font-variant-numeric: tabular-nums; } .log-entry span { overflow-wrap: anywhere; } .notice { border-radius: 8px; background: #302433; padding: 9px; } .footer-note { font-size: 11px; line-height: 1.7; color: #8299b4; } details { margin-top: 14px; padding-top: 12px; border-top: 1px solid #273950; color: #97adc7; font-size: 12px; } summary { cursor: pointer; } #reviewed { width: auto; } .placeholder { padding: 36px 16px; text-align: center; } .placeholder h3 { font-size: 16px; margin-top: 12px; } .placeholder-icon { font-size: 36px; color: #638ba9; } @media (max-width: 380px) { section { padding: 12px; } .tabs small { display: block; margin: 0; } } .compact-modes { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 11px; } .compact-modes > span { display: flex; align-items: center; gap: 5px; } .region-settings { border-bottom: 1px solid #263a52; padding: 14px 0; } .region-actions { display: flex; gap: 6px; margin-top: 10px; } .region-actions button { flex: 1; padding: 8px 5px; font-size: 12px; } .coordinate-grid { display: flex; gap: 8px; } .coordinate-grid > div { flex: 1; min-width: 0; } .coordinate-grid input { padding: 8px; } .policy-heading { margin-top: 18px; } .locate-enemy { margin-top: 8px; width: 100%; font-size: 12px; } .shared-status { display: flex; align-items: center; gap: 8px; color: #b3d4e7; font-size: 11px; } .shared-status button { white-space: nowrap; padding: 5px 8px; font-size: 11px; } .rally-status { margin-top: 12px; padding: 10px; border-radius: 8px; background: #193548; font-size: 12px; } .rally-status p { margin-top: 5px; } .app-version { margin-top: 5px; padding-left: 4px; color: #a6b8cf; font-size: 11px; text-shadow: 0 1px 3px #000; } .expansion-progress ul { margin: 8px 0 0; padding-left: 16px; } .expansion-progress li { margin-top: 8px; overflow-wrap: anywhere; } .planning-status { min-height: 3em; } `;var fd="0.15.14";var pt=ht(Bt(),1);function ov({controller:t}){let e=(0,qn.useSyncExternalStore)(t.subscribe,t.getSnapshot),n=(0,qn.useRef)(null),i=(0,qn.useRef)(null),a=(0,qn.useRef)(null),l=(0,qn.useRef)(null),s=(0,qn.useRef)(e.expanded);(0,qn.useEffect)(()=>{e.expanded!==s.current&&((e.expanded?i:n).current?.focus(),s.current=e.expanded)},[e.expanded]);let o=d=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(d.key))return;d.preventDefault();let c=d.key==="Home"?"expansion":d.key==="End"||e.mode==="expansion"?"attack":"expansion";t.setMode(c),(c==="expansion"?a:l).current?.focus()},u=e.logs.at(-1);return(0,pt.jsxs)(pt.Fragment,{children:[(0,pt.jsx)("style",{children:sv}),(0,pt.jsxs)("button",{id:"toggle",ref:n,hidden:e.expanded,"aria-expanded":e.expanded,"aria-controls":"panel",onClick:t.expand,title:u?.message,children:[(0,pt.jsx)("span",{className:"compact-heading",children:(0,pt.jsx)("strong",{children:"\u2726 Swarm \u52A9\u624B"})}),(0,pt.jsxs)("span",{className:"compact-modes",children:[(0,pt.jsxs)("span",{children:["\u6269\u5F20 ",(0,pt.jsx)(zu,{state:e.expansion,uncertain:e.uncertain})]}),(0,pt.jsxs)("span",{children:["\u8FDB\u653B ",(0,pt.jsx)(zu,{state:e.attack,uncertain:e.uncertain})]})]}),(0,pt.jsx)("span",{id:"compact-log",children:u?`${Is(u.time)} \xB7 ${u.mode==="attack"?"\u8FDB\u653B":"\u6269\u5F20"} \xB7 ${u.message}`:"\u5C1A\u65E0\u8FD0\u884C\u65E5\u5FD7\uFF0C\u70B9\u51FB\u5C55\u5F00\u52A9\u624B\u3002"})]}),(0,pt.jsxs)("section",{id:"panel",hidden:!e.expanded,"aria-label":"Swarm MMO \u52A9\u624B",children:[(0,pt.jsxs)("header",{children:[(0,pt.jsx)("h2",{children:"\u2726 Swarm \u52A9\u624B"}),(0,pt.jsx)("button",{id:"collapse","aria-label":"\u6536\u8D77\u52A9\u624B",ref:i,onClick:t.collapse,children:"\u6536\u8D77 \u2199"})]}),(0,pt.jsxs)("div",{className:"tabs",role:"tablist","aria-label":"\u52A9\u624B\u6A21\u5F0F",children:[(0,pt.jsx)("button",{id:"tab-expansion",role:"tab",ref:a,"aria-selected":e.mode==="expansion","aria-controls":"expansion",tabIndex:e.mode==="expansion"?0:-1,onClick:()=>t.setMode("expansion"),onKeyDown:o,children:"\u81EA\u52A8\u6269\u5F20"}),(0,pt.jsx)("button",{id:"tab-attack",role:"tab",ref:l,"aria-selected":e.mode==="attack","aria-controls":"attack",tabIndex:e.mode==="attack"?0:-1,onClick:()=>t.setMode("attack"),onKeyDown:o,children:"\u8FDB\u653B\u6A21\u5F0F"})]}),e.uncertain&&!e.expansion.running&&!e.attack.running&&(0,pt.jsx)("p",{className:"notice error",role:"alert",children:"\u4E0A\u6B21\u8FDB\u653B\u7ED3\u679C\u672A\u77E5\uFF0C\u5DF2\u9501\u5B9A\u64CD\u4F5C\u3002\u8BF7\u5728\u4E0B\u65B9\u6838\u5BF9\u5E76\u6062\u590D\uFF1B\u6269\u5F20\u8D85\u65F6\u4F1A\u81EA\u52A8\u8DF3\u8FC7\u3002"}),(e.expansion.running||e.attack.running)&&(0,pt.jsxs)("div",{className:"shared-status",children:[(0,pt.jsxs)("span",{children:[e.expansion.running&&e.attack.running?"\u6269\u5F20\u4E0E\u8FDB\u653B\u540C\u65F6\u8FD0\u884C":e.expansion.running?"\u81EA\u52A8\u6269\u5F20\u4ECD\u5728\u8FD0\u884C":"\u8FDB\u653B\u6A21\u5F0F\u4ECD\u5728\u8FD0\u884C"," \xB7 \u5171\u4EAB\u9884\u7B97 \xB7 \u72EC\u7ACB\u961F\u5217"]}),(0,pt.jsx)("button",{id:"stop-all",onClick:t.stopAll,children:"\u5168\u90E8\u505C\u6B62"})]}),["expansion","attack"].map(d=>{let c=d==="attack",v=e.policies[d],f=v.scope==="circle"?`\u4E2D\u5FC3 (${v.x||"\u2014"}, ${v.y||"\u2014"}) \xB7 \u534A\u5F84 ${v.radius}`:"\u5168\u90E8\u9886\u5730";return(0,pt.jsxs)("div",{id:d,role:"tabpanel","aria-labelledby":`tab-${d}`,hidden:e.mode!==d,children:[c&&e.expansion.running&&(0,pt.jsx)("p",{children:"\u81EA\u52A8\u6269\u5F20\u4ECD\u5728\u8FD0\u884C\uFF0C\u53EF\u5207\u6362 Tab \u67E5\u770B\uFF1B\u505C\u6B62\u8FDB\u653B\u4E0D\u4F1A\u505C\u6B62\u6269\u5F20\u3002"}),!c&&e.attack.running&&(0,pt.jsx)("p",{children:"\u8FDB\u653B\u6A21\u5F0F\u4ECD\u5728\u8FD0\u884C\uFF0C\u53EF\u5207\u6362 Tab \u67E5\u770B\uFF1B\u505C\u6B62\u6269\u5F20\u4E0D\u4F1A\u505C\u6B62\u8FDB\u653B\u3002"}),(0,pt.jsx)(iv,{mode:d,summary:f,state:e[d],settings:c?e.attackSettings:e.settings,logs:e.logs,uncertain:e.uncertain,settingsOpen:c?e.attackSettingsOpen:e.settingsOpen,onToggleSettings:c?t.toggleAttackSettings:t.toggleSettings,onSettingChange:c?t.setAttackSetting:t.setSetting,onStart:c?t.startAttack:t.start,onStop:c?t.stopAttack:t.stop,region:(0,pt.jsx)(av,{mode:d,value:v,preview:e.previews[d],disabled:e[d].running,onChange:(m,y)=>t.setPolicy(d,m,y),onPick:m=>t.pickCenter(d,m),onFocus:()=>t.focusRegion(d),onFocusEnemy:t.focusEnemy,onPickHub:t.pickHub,onPreview:()=>{t.previewRegion(d)}})})]},d)}),e.uncertain&&(0,pt.jsx)(lv,{reviewed:e.reviewed,busy:e.unlocking,status:e.unlockStatus,onReviewedChange:t.setReviewed,onUnlock:t.unlock})]}),(0,pt.jsxs)("div",{className:"app-version",title:"\u5F53\u524D\u9875\u9762\u5B9E\u9645\u52A0\u8F7D\u7684\u52A9\u624B\u7248\u672C",children:["Swarm \u52A9\u624B v",fd]})]})}function uv(){for(let t of document.querySelectorAll("canvas")){let e=Object.keys(t).find(i=>i.startsWith("__reactFiber$")),n=e?t[e]:void 0;for(let i=0;n&&i<80;i++,n=n.return){let a=n.memoizedProps,l=a?.conn;if(l?.isActive&&typeof l.db?.planet?.iter=="function"&&typeof l.reducers?.launchSwarm=="function"&&a?.myIdentity)return{conn:l,identity:a.myIdentity}}}throw new Error("\u672A\u8FDE\u63A5\u6E38\u620F\u3002\u8BF7\u8FDB\u5165\u661F\u7CFB\u5730\u56FE\u540E\u5237\u65B0\uFF1B\u82E5\u4ECD\u5931\u8D25\uFF0C\u6E38\u620F\u7248\u672C\u53EF\u80FD\u5DF2\u53D8\u5316\u3002")}function Cu(t){return[...t.conn.db.planet.iter()].filter(e=>e.ownerId?.toHexString()===t.identity).sort((e,n)=>e.planetIdn.planetId?1:0)}function ml(){let t=uv();for(let e of document.querySelectorAll("canvas")){let n=Object.keys(e).find(a=>a.startsWith("__reactFiber$")),i=n?e[n]:void 0;for(let a=0;i&&a<80;a++,i=i.return){if(i.memoizedProps?.conn!==t.conn||i.memoizedProps.myIdentity!==t.identity)continue;let l=i.memoizedProps.ref?.current??i.ref?.current;if(typeof l?.quoteSend=="function"&&typeof l.listOwnedBodies=="function"&&t.conn.db.swarm)return{...t,map:l}}}throw new Error("\u6E38\u620F\u62A5\u4EF7\u6216\u8230\u961F\u63A5\u53E3\u4E0D\u53EF\u7528\uFF0C\u81EA\u52A8\u64CD\u4F5C\u5DF2\u505C\u6B62\u3002")}function Je(t){let e=uv();if(e.conn!==t.conn||e.identity!==t.identity)throw new Error("\u6E38\u620F\u8FDE\u63A5\u6216\u8EAB\u4EFD\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u542F\u52A8\u6240\u9700\u6A21\u5F0F\u3002")}function dd(t,e){return new Promise((n,i)=>{let a,l=!1,s=()=>{l||(l=!0,clearTimeout(o),a?.unsubscribe(),i(new Error("\u661F\u7403\u6570\u636E\u52A0\u8F7D\u5931\u8D25\u6216\u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5\u3002")))},o=setTimeout(s,12e3);try{a=t.subscriptionBuilder().onApplied(()=>{queueMicrotask(()=>{l||(l=!0,clearTimeout(o),n(a))})}).onError(s).subscribe(e)}catch{s()}})}function tt(t,e){return Math.hypot(t.positionX-e.positionX,t.positionY-e.positionY)}var vl=8,rv=15e3;function _t(t){return!!t&&Number.isFinite(t.travelMs)&&t.travelMs>=0&&Number.isInteger(t.lossPct)&&t.lossPct>=0&&t.lossPct<100}function Wt(t,e){return Math.floor(t*(100-e)/100)}function cv(t){return t.length<2?[t]:t.flatMap((e,n)=>cv(t.filter((i,a)=>n!==a)).map(i=>[e,...i]))}function Nu(t,e,n){if(t.ownerId!=null||e.length<2||e.length>n.maxSources||e.length>ii)return[];if(new Set(e.map(s=>s.planet.planetId)).size!==e.length)return[];if(!Number.isSafeInteger(t.probeCount)||t.probeCount<0)return[];for(let s of e){if(s.planet.ownerId==null||s.planet.planetId===t.planetId||!_t(s)||!Number.isSafeInteger(s.available)||s.available<1||tt(s.planet,t)>n.radius||s.travelMs>n.horizonMs)return[];if(e.some(o=>tt(s.planet,o.planet)>vl))return[]}if(Math.max(...e.map(s=>s.travelMs))-Math.min(...e.map(s=>s.travelMs))>rv)return[];let i=t.probeCount+Ze;if(is+Wt(o.available,o.lossPct),0)Wt(o.available,o.lossPct)-Wt(s.available,s.lossPct)),[...e].sort((s,o)=>s.lossPct-o.lossPct||s.travelMs-o.travelMs)];for(let s of l)for(let o of[!1,!0]){let u=i,d=[];for(let m=0;mT+Wt(w.available,w.lossPct),0),r=Math.max(1,u-p),g=Math.min(S,u-h.length);if(gy.available||x>4294967295||Wt(x,y.lossPct)0)continue;d.sort((m,y)=>m.sourceId`${m.sourceId}:${m.count}`).join(",");a.set(f,{...c,targetId:t.planetId,support:v})}return[...a.values()]}function fv(t,e){return e===0?[[]]:t.flatMap((n,i)=>fv(t.slice(i+1),e-1).map(a=>[n,...a]))}function*Iu(t,e){if(e<2)return;let n=[...t].sort((c,v)=>c.travelMs-v.travelMs),i=[...t].sort((c,v)=>v.available*(100-v.lossPct)-c.available*(100-c.lossPct)),a=c=>[...new Map(c.map(v=>[v.planet.planetId,v])).values()],l=a([...n.slice(0,3),...i.slice(0,3)]);for(let c=2;c<=Math.min(e,3);c++)yield*fv(l,c);if(e<=3)return;let s=Math.min(e,ii),o=a([...n.slice(0,s),...i.slice(0,s)]).filter(c=>Wt(c.available,c.lossPct)>0),u=[[...o].sort((c,v)=>c.travelMs-v.travelMs),[...o].sort((c,v)=>Wt(v.available,v.lossPct)-Wt(c.available,c.lossPct))],d=new Set;for(let c of o)for(let v of u){let f=[c];for(let m of v)if(!f.some(y=>y.planet.planetId===m.planet.planetId||tt(y.planet,m.planet)>vl||Math.abs(y.travelMs-m.travelMs)>rv)){if(f.push(m),f.length>=4){let y=f.map(h=>h.planet.planetId).sort((h,S)=>h=32)return}if(f.length>=s)break}}}var Ru={zone:null,enemy:null,frontlinePercent:25,threatRadius:16,holdProbes:10,rallyId:null,rallyMs:18e5,advanceHub:!0,rallyHubs:3};function Q(t,e){return!e||Math.hypot(t.positionX-e.x,t.positionY-e.y)<=e.radius}function Ou(t,e){if(e==="attack"&&!t.zone)throw new Error("\u8BF7\u5148\u9009\u53D6\u8FDB\u653B\u6218\u533A\u3002");if(t.zone&&(!Number.isSafeInteger(t.zone.x)||!Number.isSafeInteger(t.zone.y)||Math.abs(t.zone.x)>2147483e3||Math.abs(t.zone.y)>2147483e3||!Number.isSafeInteger(t.zone.radius)||t.zone.radius<1||t.zone.radius>128))throw new Error("\u6218\u533A\u5750\u6807\u5E94\u4E3A\u6574\u6570\uFF0C\u534A\u5F84\u4E3A 1\u2013128\u3002");if(t.enemy!==null&&!/^[0-9a-f]{64}$/i.test(t.enemy))throw new Error("\u8BF7\u9009\u62E9\u6709\u6548\u7684\u654C\u4EBA\u3002");if(!Number.isInteger(t.rallyHubs)||t.rallyHubs<1||t.rallyHubs>3)throw new Error("\u540C\u65F6\u96C6\u7ED3\u636E\u70B9\u6570\u5E94\u4E3A 1\u20133\u3002");if(t.rallyId!==null&&(!/^[1-9][0-9]{0,19}$/.test(t.rallyId)||BigInt(t.rallyId)>18446744073709551615n))throw new Error("\u8BF7\u9009\u62E9\u6709\u6548\u7684\u4E2D\u8F6C\u661F\u3002");if(!Number.isSafeInteger(t.rallyMs)||t.rallyMs<6e4||t.rallyMs>144e5||typeof t.advanceHub!="boolean")throw new Error("\u96C6\u7ED3\u822A\u884C\u4E0A\u9650\u5E94\u4E3A 1\u2013240 \u5206\u949F\u3002");for(let[n,i,a]of[[t.frontlinePercent,0,90],[t.threatRadius,1,128],[t.holdProbes,2,1e6]])if(!Number.isSafeInteger(n)||na)throw new Error("\u52A8\u6001\u7559\u5175\u53C2\u6570\u8D85\u51FA\u6709\u6548\u8303\u56F4\u3002")}function pd(t,e,n=24){let i=new Set(e),a=t.map(o=>o.filter(u=>i.delete(u))).filter(o=>o.length),l=[...i].sort(),s=0;for(let o of a)for(;o.length({cell:e.split(",").map(Number),planets:n})).sort((e,n)=>e.cell[0]-n.cell[0]||e.cell[1]-n.cell[1]).flatMap(e=>e.planets)}near(e,n){let i=[];for(let a=Math.floor((e.positionX-n)/32);a<=Math.floor((e.positionX+n)/32);a++)for(let l=Math.floor((e.positionY-n)/32);l<=Math.floor((e.positionY+n)/32);l++)for(let s of this.cells.get(`${a},${l}`)??[]){let o=e.positionX-s.positionX,u=e.positionY-s.positionY;o*o+u*u<=n*n&&i.push(s)}return i}};var Du=class{version;cache=new Map;covered(e){return this.cache.get(e)?.covered??!1}coverage;radii=new Map;read(e,n,i,a,l){if(l!==this.version){this.version=l,this.cache.clear(),this.radii.clear();let d=[],c=(v,f,m)=>{if(![v,f,m].every(Number.isFinite))return;let y=BigInt(d.length);this.radii.set(y,m),d.push({planetId:y,positionX:v,positionY:f,probeCount:0,galaxyId:0n})};for(let v of e.sun2?.iter()??[])v.ownerId&&i.has(v.ownerId.toHexString())&&c(v.positionX,v.positionY,8);for(let v of e.base?.iter()??[]){let f=v;f.ownerId&&i.has(f.ownerId.toHexString())&&(f.superprobes??0)>0&&c(f.positionX,f.positionY,Math.min(f.level,10))}this.coverage=new zt(d)}let s=[...e.player_tech?.iter()??[]].find(d=>d.playerId.toHexString()===a)?.construction??0,o=Number.isInteger(s)&&s>=0?Math.floor(6e4/(1+.005*s)):6e4,u=new Map;for(let d of n){let c=this.cache.get(d.planetId);if(!c||c.x!==d.positionX||c.y!==d.positionY){let v=this.coverage?.near(d,10).some(f=>(f.positionX-d.positionX)**2+(f.positionY-d.positionY)**2<=this.radii.get(f.planetId)**2);c={x:d.positionX,y:d.positionY,tick:v?o:6e4,covered:!!v},this.cache.set(d.planetId,c)}u.set(d.planetId,c.tick)}for(let d of this.cache.keys())u.has(d)||this.cache.delete(d);return u}};function Dt(t){return JSON.stringify(t,(e,n)=>typeof n=="bigint"?`${n}n`:typeof n?.toHexString=="function"?n.toHexString():typeof n?.toMillis=="function"?String(n.toMillis()):n)}function dv(t){if(!t||t.outOfRange||t.exact?.reason!=="capture"||!_t(t))return null;let e=t.exact.probes;return!Number.isSafeInteger(e)||e<1||e>4294967295?null:{count:e,travelMs:t.travelMs}}var _u=class{session=ml();subscriptions=new Map;quotes=new Map;scannedSources=new Set;tileBatches=[];ownerBatches=[];configs=[];production=new Du;quoteCore;quoteEpoch=0;timings={readTotalMs:0,readCalls:0,ownedBodiesMs:0,quoteMaxMs:0,slowQuotes:0,syncCalls:0,syncQueries:0,syncTotalMs:0,syncActive:0,readMs:0,scanMs:0,syncMs:0,quoteMs:0,quoteCalls:0,newSubscriptions:0,reusedSubscriptions:0};matchesSession(e){return e.conn===this.session.conn&&e.identity===this.session.identity}diagnostics(){return{...this.timings}}configure(e){this.configs=e}needsScan(){return Je(this.session),Cu(this.session).some(e=>!this.scannedSources.has(e.planetId)&&(!this.configs.length||this.configs.some(n=>Q(e,n.policy.zone))))}async scan(e,n){Je(this.session);let i=performance.now();this.timings.newSubscriptions=0,this.timings.reusedSubscriptions=0;let a=this.session.identity;if(!/^[0-9a-f]{64}$/i.test(a))throw new Error("\u6E38\u620F\u8EAB\u4EFD\u683C\u5F0F\u53D1\u751F\u53D8\u5316\u3002");let l=new Map,s=[],o=async u=>{let d=this.subscriptions.get(u);if(d){if(!d.isActive())throw new Error("\u661F\u7403\u8BA2\u9605\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u542F\u52A8\u3002");if(!n())throw new Error("\u626B\u63CF\u5DF2\u505C\u6B62\u3002");this.timings.reusedSubscriptions++,l.set(u,d);return}this.timings.newSubscriptions++;let c=await dd(this.session.conn,u);if(l.set(u,c),s.push(c),!n())throw new Error("\u626B\u63CF\u5DF2\u505C\u6B62\u3002")};try{if(e.captureMeteorites&&!this.session.conn.db.meteorite2)throw new Error("\u9668\u77F3\u60C5\u62A5\u63A5\u53E3\u4E0D\u53EF\u7528\u3002");if(e.captureSuns&&!this.session.conn.db.sun_swarm2)throw new Error("\u6052\u661F\u8230\u961F\u60C5\u62A5\u63A5\u53E3\u4E0D\u53EF\u7528\u3002");await o(`SELECT * FROM planet WHERE owner_key = x'${a}'`),await o(`SELECT * FROM swarm WHERE owner_id = x'${a}'`);for(let h of["clan_member2","player_tech"])await o(`SELECT * FROM ${h}`);for(let h of["attack_automation","upgrade_automation"])await o(`SELECT * FROM ${h} WHERE owner_id = x'${a}'`);let u=Cu(this.session).filter(h=>!this.configs.length||this.configs.some(S=>Q(h,S.policy.zone))),d=new Map,c=this.configs.length?this.configs.flatMap(h=>h.policy.zone?[{positionX:h.policy.zone.x,positionY:h.policy.zone.y,radius:h.policy.zone.radius+h.policy.threatRadius+10}]:u.map(S=>({...S,radius:Math.max(h.settings.radius,h.policy.threatRadius)+10}))):u.map(h=>({...h,radius:e.radius+10}));for(let h of c)for(let S=Math.floor((h.positionX-h.radius)/32);S<=Math.floor((h.positionX+h.radius)/32);S++)for(let p=Math.floor((h.positionY-h.radius)/32);p<=Math.floor((h.positionY+h.radius)/32);p++)d.set(`${S},${p}`,`(position_x >= ${S*32} AND position_x < ${(S+1)*32} AND position_y >= ${p*32} AND position_y < ${(p+1)*32})`);if(d.size>2048)throw new Error("\u641C\u7D22\u533A\u57DF\u8FC7\u5927\uFF0C\u8BF7\u7F29\u5C0F\u641C\u7D22\u534A\u5F84\u540E\u91CD\u65B0\u542F\u52A8\u3002");let v=pd(this.tileBatches,d.keys()),f=[];for(let h of v){let S=h.map(p=>d.get(p)).join(" OR ");for(let p of["planet","sun2","base"])f.push(`SELECT * FROM ${p} WHERE ${S}`);e.captureMeteorites&&f.push(`SELECT * FROM meteorite2 WHERE ${S}`),e.captureSuns&&f.push(`SELECT * FROM sun_swarm2 WHERE ${S.replaceAll("position_x","target_x").replaceAll("position_y","target_y")}`),f.push(`SELECT * FROM swarm WHERE ${S.replaceAll("position_x","target_x").replaceAll("position_y","target_y")}`)}for(let h=0;hr.status==="rejected");if(p?.status==="rejected")throw p.reason}let m=[...new Set([...this.session.conn.db.planet.iter()].filter(h=>!this.configs.length||this.configs.some(S=>Q(h,S.policy.zone))).flatMap(h=>h.ownerId?[h.ownerId.toHexString()]:[]))].sort(),y=pd(this.ownerBatches,m);for(let h of y){if(h.some(S=>!/^[0-9a-f]{64}$/i.test(S)))throw new Error("\u73A9\u5BB6\u8EAB\u4EFD\u683C\u5F0F\u53D1\u751F\u53D8\u5316\u3002");await o(`SELECT * FROM player WHERE ${h.map(S=>`identity = x'${S}'`).join(" OR ")}`)}if(Je(this.session),!n())throw new Error("\u626B\u63CF\u5DF2\u505C\u6B62\u3002");for(let[h,S]of this.subscriptions)l.has(h)||S.unsubscribe();this.subscriptions=l,this.tileBatches=v,this.ownerBatches=y,this.scannedSources=new Set(u.map(h=>h.planetId))}catch(u){for(let d of s)d.unsubscribe();throw u}finally{this.timings.scanMs=performance.now()-i}}refreshQuotes(){if(Je(this.session),!this.subscriptions.size||[...this.subscriptions.values()].some(n=>!n.isActive()))throw new Error("\u661F\u7403\u8BA2\u9605\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u542F\u52A8\u3002");let e=ml();this.session.map=e.map,this.quotes.clear()}read(){let e=performance.now();this.refreshQuotes();let n=Cu(this.session),i=n.filter(M=>this.scannedSources.has(M.planetId)||this.configs.some(I=>I.policy.zone&&Q(M,I.policy.zone))),a=new Map,l=performance.now(),s=this.session.map.listOwnedBodies();this.timings.ownedBodiesMs=performance.now()-l;for(let M of s)M.kind==="planet"&&Number.isSafeInteger(M.probes)&&M.probes>=0&&a.set(M.id,Math.min(M.probes,4294967295));let o=new Set;for(let M of this.session.conn.db.swarm.iter())M.ownerId.toHexString()===this.session.identity&&M.targetPlanetId>0n&&o.add(M.targetPlanetId);let u=this.session.conn.db;if(!u.clan_member2||!u.player_tech||!u.sun2||!u.base||!u.attack_automation||!u.upgrade_automation)throw new Error("\u6218\u533A\u60C5\u62A5\u63A5\u53E3\u53D1\u751F\u53D8\u5316\uFF0C\u5DF2\u505C\u6B62\u3002");let d=[...u.clan_member2.iter()],c=d.find(M=>M.playerId.toHexString()===this.session.identity)?.clanId,v=new Set([this.session.identity,...d.filter(M=>c!==void 0&&M.clanId===c).map(M=>M.playerId.toHexString())]),f=[...u.planet.iter()],m=new Map(f.map(M=>[`${M.positionX},${M.positionY}`,M])),y=new Map(f.map(M=>[M.planetId,M])),h=[...u.swarm.iter()].filter(M=>M.targetPlanetId>0n).map(M=>{let I=Number.isSafeInteger(M.probeCount)&&M.probeCount>=0?M.probeCount:null,B=Number(M.arrivalTime?.toMillis()),N=m.get(`${M.sourceX},${M.sourceY}`),q=y.get(M.targetPlanetId);return{id:M.swarmId,owner:M.ownerId.toHexString(),target:M.targetPlanetId,source:N?.planetId,count:I,arrival:Number.isFinite(B)?B:null,arriving:N&&q&&N.galaxyId===q.galaxyId?I:null}}),S=new Map;for(let M of h){let I=S.get(M.target)??[];I.push(M),S.set(M.target,I)}let p=new Map,r=(M,I,B)=>{let N=At(M,I),q=p.get(N)??[],et=Number(B.arrivalTime?.toMillis());q.push({id:B.swarmId,owner:B.ownerId.toHexString(),target:M,count:Number.isSafeInteger(B.probeCount)?B.probeCount:null,arrival:Number.isFinite(et)?et:null,arriving:null}),p.set(N,q)};for(let M of u.swarm.iter())M.targetSunId&&M.targetSunId>0n&&r(M.targetSunId,"sun",M),M.targetMeteoriteId&&M.targetMeteoriteId>0n&&r(M.targetMeteoriteId,"comet",M);for(let M of u.sun_swarm2?.iter()??[])!M.targetBlackHole&&M.targetSunId>0n&&r(M.targetSunId,"sun",M);let g=M=>{let{probeCount:I,superprobes:B,lastUpdateTick:N,...q}=M;return{...q,activeBase:typeof B=="number"?B>0:void 0}},b=[...u.player_tech.iter()],x=b.find(M=>M.playerId.toHexString()===this.session.identity)?.assault,T=Number.isSafeInteger(x)&&x>=0?1+.01*x:void 0,w=M=>[...M].map(Dt).sort(),A=Dt([this.session.identity,w(b.filter(M=>M.playerId.toHexString()===this.session.identity)),w(d),w([...u.base.iter()].map(g)),w([...u.sun2.iter()].map(g)),w(u.galaxy?.iter()??[])]),H=this.production.read(u,i,v,this.session.identity,A),z=Dt([this.session.identity,w(b.filter(M=>M.playerId.toHexString()===this.session.identity)),w(u.galaxy?.iter()??[])]);z!==this.quoteCore&&(this.quoteCore=z,this.quoteEpoch++);let E=`${this.session.identity}:${this.quoteEpoch}`,_=new Map(i.map(M=>[M.planetId,Dt([E,M.ownerId,M.positionX,M.positionY,M.galaxyId,M.level,this.production.covered(M.planetId)])]));return this.timings.readMs=performance.now()-e,this.timings.readCalls++,this.timings.readTotalMs+=this.timings.readMs,{productionTicks:H,quoteVersion:A,quoteGlobalVersion:E,sourceQuoteVersions:_,attackMultiplierUpperBound:T,planets:f,owned:i,allOwned:n,budgets:a,incoming:o,fleets:h,fleetsByTarget:S,identity:this.session.identity,allies:v,intelligence:!0,suns:[...u.sun2.iter()],meteorites:[...u.meteorite2?.iter()??[]],bodyFleets:p,automated:new Set([...u.attack_automation.iter()].map(M=>M.sourcePlanetId)),autoUpgrading:new Set([...u.upgrade_automation.iter()].map(M=>M.planetId)),players:new Map([...u.player?.iter()??[]].map(M=>[M.identity.toHexString(),M.username]))}}nativeQuote(e,n,i="planet"){let a=`${e}:${At(n,i)}`;if(!this.quotes.has(a)){let l=performance.now();try{this.timings.quoteCalls++,this.quotes.set(a,this.session.map.quoteSend("planet",e,i,n))}finally{let s=performance.now()-l;this.timings.quoteMs+=s,this.timings.quoteMaxMs=Math.max(this.timings.quoteMaxMs,s),s>=8&&this.timings.slowQuotes++}}return this.quotes.get(a)}quote(e,n){return dv(this.nativeQuote(e,n))}route(e,n){let i=this.nativeQuote(e,n);return _t(i)?{travelMs:i.travelMs,lossPct:i.lossPct}:null}launchGroup(e){if(Je(this.session),!this.session.conn.reducers.launchSwarmBulk)throw new Error("\u6E38\u620F\u6279\u91CF\u53D1\u5C04\u63A5\u53E3\u4E0D\u53EF\u7528\uFF0C\u672A\u6267\u884C\u8054\u5408\u5360\u9886\u3002");return this.session.conn.reducers.launchSwarmBulk({kind:0,targetId:e.targetId,launches:G(e).map(i=>({sourceId:i.sourceId,probeCount:BigInt(i.count)}))})}supportsGroup(){return typeof this.session.conn.reducers.launchSwarmBulk=="function"}quoteBody(e,n,i){return dv(this.nativeQuote(e,n,i))}bodyQuoteIssue(e,n,i){let a=this.nativeQuote(e,n,i);return a?_t(a)?a.outOfRange?`\u539F\u751F\u5224\u5B9A\u65E0\u6CD5\u53D1\u5C04\uFF1A\u822A\u65F6 ${Math.ceil(a.travelMs/1e3)} \u79D2\u3001\u635F\u8017 ${a.lossPct}%${a.exact?.reason==="capture"?`\u3001\u539F\u751F\u9700 ${a.exact.probes} \u63A2\u9488`:""}`:a.exact?.reason!=="capture"?`\u539F\u751F\u672A\u7ED9\u51FA\u5360\u9886\u62A5\u4EF7\uFF08${a.exact?.reason??"\u65E0\u6570\u91CF\u8BF4\u660E"}\uFF09`:this.quoteBody(e,n,i)?void 0:"\u539F\u751F\u5360\u9886\u6570\u91CF\u65E0\u6548\u6216\u8D85\u8FC7\u5355\u6B21\u53D1\u5C04\u4E0A\u9650":"\u539F\u751F\u822A\u65F6\u6216\u822A\u884C\u635F\u8017\u65E0\u6548":"\u539F\u751F\u672A\u8FD4\u56DE\u62A5\u4EF7\uFF0C\u6765\u6E90\u6216\u76EE\u6807\u60C5\u62A5\u53EF\u80FD\u4E0D\u5B8C\u6574"}routeBody(e,n,i){let a=this.nativeQuote(e,n,i);return _t(a)?{travelMs:a.travelMs,lossPct:a.lossPct}:null}launchBody(e){Je(this.session);let n=this.session.conn.reducers;if(e.targetKind==="sun"&&n.launchSwarmAtSun)return n.launchSwarmAtSun({sourcePlanetId:e.sourceId,targetSunId:e.targetId,probeCount:BigInt(e.count)});if(e.targetKind==="comet"&&n.launchSwarmAtMeteorite)return n.launchSwarmAtMeteorite({sourcePlanetId:e.sourceId,targetMeteoriteId:e.targetId,probeCount:BigInt(e.count)});throw new Error("\u76EE\u6807\u7684\u539F\u751F\u6D3E\u5175\u63A5\u53E3\u4E0D\u53EF\u7528\uFF0C\u672A\u53D1\u5C04\u3002")}disableAutoUpgrade(e){if(Je(this.session),this.session.conn.db.planet.planetId.find(e)?.ownerId?.toHexString()!==this.session.identity)throw new Error("\u96C6\u7ED3\u661F\u7403\u5DF2\u5931\u53BB\u6240\u6709\u6743\uFF0C\u672A\u5173\u95ED\u81EA\u52A8\u5347\u7EA7\u3002");if(!this.session.conn.reducers.setUpgradeAutomationBulk)throw new Error("\u539F\u751F\u81EA\u52A8\u5347\u7EA7\u8BBE\u7F6E\u63A5\u53E3\u4E0D\u53EF\u7528\u3002");return this.session.conn.reducers.setUpgradeAutomationBulk({planetIds:[e],enable:!1})}upgrade(e){if(Je(this.session),!this.session.conn.reducers.upgradePlanet)throw new Error("\u539F\u751F\u5347\u7EA7\u63A5\u53E3\u4E0D\u53EF\u7528\u3002");return this.session.conn.reducers.upgradePlanet({planetId:e})}upgradeMany(e){if(Je(this.session),!e.length||e.length>200||new Set(e).size!==e.length)throw new Error("\u6279\u91CF\u5347\u7EA7\u9700\u8981 1\uFF5E200 \u9897\u4E0D\u540C\u661F\u7403\u3002");if(!this.session.conn.reducers.upgradePlanetsBulk)throw new Error("\u539F\u751F\u6279\u91CF\u5347\u7EA7\u63A5\u53E3\u4E0D\u53EF\u7528\u3002");return this.session.conn.reducers.upgradePlanetsBulk({planetIds:e})}async syncInventory(e){this.timings.syncCalls++,this.timings.syncActive++;let n=performance.now();try{Je(this.session);let i=[...new Set(e)];for(let a=0;a`planet_id = ${s}`).join(" OR ")}`);try{Je(this.session)}finally{l.unsubscribe()}}}finally{this.timings.syncMs=performance.now()-n,this.timings.syncTotalMs+=this.timings.syncMs,this.timings.syncActive--}}launch(e,n,i){return Je(this.session),this.session.conn.reducers.launchSwarm({sourcePlanetId:e,targetPlanetId:n,probeCount:BigInt(i)})}dispose(){for(let e of this.subscriptions.values())try{e.unsubscribe()}catch{}this.subscriptions.clear(),this.quotes.clear(),this.tileBatches=[],this.ownerBatches=[]}};var YS={expansion:"\u6269\u5F20",attack:"\u8FDB\u653B"};function gd(t,e,n){let i=(n.targetKind??"planet")==="planet"&&n.targetId===t,a=n.sourceId===t?n:n.support?.find(s=>s.sourceId===t);if(!i&&!a)return;if(n.kind==="upgrade")return`\u672C\u661F\u5347\u7EA7\uFF0C\u6D88\u8017 ${n.count} \u63A2\u9488`;let l=n.kind?"\u8865\u7ED9":e==="attack"?"\u8FDB\u653B":"\u5360\u9886";return a?`\u6D3E ${a.count} \u63A2\u9488${l}${De(n)}`:`${hl(n)} \u6D3E ${pe(n)} \u63A2\u9488${l}\u672C\u661F`}function pv(t,e,n,i){let a=[];if(n.confirming){let s=gd(t,e,n.confirming);s&&a.push(`\u7B49\u5F85\u53D1\u5C04\u56DE\u6267 \xB7 ${s}`)}for(let s of n.queue){if(n.confirming?.targetId===s.targetId)continue;let o=gd(t,e,s);o&&a.push(`\u5F85\u6267\u884C \xB7 ${o}`)}for(let s of i){let o=gd(t,e,s);o&&a.push(`\u5DF2\u63D0\u4EA4 \xB7 ${o}\uFF0C\u5F85\u6838\u5B9E\u5360\u9886`)}for(let s of n.logistics??[]){let o=s.kind==="planet"&&s.target===t;if(s.hub!==t&&!o)continue;let u=o?`\u7531\u4E2D\u8F6C\u661F #${s.hub} \u52DF\u5175\u5360\u9886\u672C\u661F`:`\u672C\u661F\u4E3A${s.kind==="sun"?"\u6052\u661F":"\u661F\u7403"} #${s.target} \u52DF\u5175`;a.push(`${u} \xB7 ${s.phase}\uFF08${s.available}/${s.required}\uFF09`)}for(let s of n.rallies??(n.rally?[n.rally]:[])){if(s.hub!==t&&s.target!==t)continue;let o=s.hub===t?`\u672C\u661F\u4E3A\u8FDB\u653B #${s.target} \u96C6\u7ED3`:`\u4E2D\u8F6C\u661F #${s.hub} \u6B63\u4E3A\u8FDB\u653B\u672C\u661F\u96C6\u7ED3`;a.push(`${o}\uFF08${s.available}/${s.required}\uFF09`)}let l=n.saving;if(l&&(l.sourceId===t||l.targetId===t)&&a.push(`#${l.sourceId} \u6B63\u4E3A\u8FDB\u653B #${l.targetId} \u6512\u5175\uFF0C\u9700\u8981 ${l.count} \u63A2\u9488`),!a.length){let s=n.planning?.idle.find(o=>o.sourceId===t);s&&a.push(`\u4E0A\u8F6E\u672A\u6D3E\u5175 \xB7 \u53EF\u7528 ${s.available}\uFF0C${s.reason}`)}return a.map(s=>`${YS[e]} \xB7 ${s}`)}var gv="swarm-helper-operations-v1",ku="swarm-helper-uncertain-v1",qu={expansion:"swarm-helper-last-operation-v1",attack:"swarm-helper-last-attack-operation-v1"},hd=new Set,bl=new Set;function Hu(){let t=localStorage.getItem(ku);if(t===null)return{};try{let e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(n=>typeof n=="string"))return e}catch{}return{legacy:t}}function md(t){Object.keys(t).length?localStorage.setItem(ku,JSON.stringify(t)):localStorage.removeItem(ku)}function Hn(){return Object.entries(Hu()).some(([t,e])=>t!=="expansion"&&t!=="legacy"&&!hd.has(e))}function QS(){localStorage.removeItem(ku)}async function hv(t){if(!navigator.locks)throw new Error("\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u8DE8\u6807\u7B7E\u9875\u64CD\u4F5C\u9501\uFF0C\u65E0\u6CD5\u5B89\u5168\u542F\u52A8\u64CD\u4F5C\u3002");return navigator.locks.request(gv,{ifAvailable:!0},async e=>{if(!e)throw new Error("\u53E6\u4E00\u4E2A\u6807\u7B7E\u9875\u6216\u52A9\u624B\u64CD\u4F5C\u6B63\u5728\u8FD0\u884C\uFF0C\u8BF7\u5148\u505C\u6B62\u5B83\u3002");if(Hn())throw new Error("\u4E0A\u6B21\u53D1\u5C04\u7ED3\u679C\u672A\u77E5\u3002\u8BF7\u6838\u5BF9\u6E38\u620F\u65E5\u5FD7\u540E\u89E3\u9664\u9501\u5B9A\u3002");let n=Hu();return delete n.expansion,delete n.legacy,md(n),t()})}async function Uu(t,e,n,i){let a="expansion";if(bl.has(a))throw new Error("\u540C\u4E00\u6A21\u5F0F\u5DF2\u6709\u64CD\u4F5C\u7B49\u5F85\u53D1\u9001\u3002");bl.add(a);try{let l=Number(localStorage.getItem(qu.expansion)??0),s=Number.isFinite(l)?Math.max(0,Math.min(e,e-(Date.now()-l))):0,o=Date.now()+s;for(;Date.now(){let c=()=>{clearTimeout(v),i?.removeEventListener("abort",c),d()},v=setTimeout(c,o-Date.now());i?.addEventListener("abort",c,{once:!0})});if(i?.aborted||!n())return;if(Hn())throw new Error("\u8FDB\u653B\u7ED3\u679C\u672A\u77E5\uFF0C\u5DF2\u6682\u505C\u3002");let u=t();if(!u)return;try{u()}finally{localStorage.setItem(qu.expansion,String(Date.now()))}}finally{bl.delete(a)}}var Bu=t=>Math.max(1e3,t+Math.round(Math.random()*400)-200);async function Rs(t,e){let n;try{return await Promise.race([t,new Promise((i,a)=>{n=setTimeout(()=>a(new Error("\u7B49\u5F85\u8D85\u65F6")),e)})])}finally{clearTimeout(n)}}async function mv(t,e,n,i="expansion",a){if(bl.has(i))throw new Error("\u540C\u4E00\u6A21\u5F0F\u5DF2\u6709\u64CD\u4F5C\u7B49\u5F85\u5B8C\u6210\u3002");bl.add(i);let l,s;try{if(Hn())throw new Error("\u4E0A\u6B21\u53D1\u5C04\u7ED3\u679C\u672A\u77E5\uFF0C\u5DF2\u6682\u505C\u3002");let o=Number(localStorage.getItem(qu[i])??0),u=Number.isFinite(o)?Math.max(0,Math.min(e,e-(Date.now()-o))):0,d=Date.now()+u;for(;Date.now(){let h=()=>{clearTimeout(S),a?.removeEventListener("abort",h),y()},S=setTimeout(h,d-Date.now());a?.addEventListener("abort",h,{once:!0})});if(a?.aborted||!n())return;if(Hn())throw new Error("\u4E0A\u6B21\u53D1\u5C04\u7ED3\u679C\u672A\u77E5\uFF0C\u5DF2\u6682\u505C\u3002");let c=t();if(!c)return;let v=s=`${i}-${Date.now()}-${Math.random()}`;hd.add(v),md({...Hu(),[i]:v});let f;try{f=c()}finally{localStorage.setItem(qu[i],String(Date.now()))}let m=Promise.resolve(f).then(y=>{let h=Hu();return h[i]===v&&(delete h[i],md(h)),y});return await Promise.race([m,new Promise((y,h)=>{l=setTimeout(()=>h(new Error("\u53D1\u5C04\u786E\u8BA4\u8D85\u65F6\uFF0C\u7ED3\u679C\u672A\u77E5\u3002\u5DF2\u505C\u6B62\uFF0C\u8BF7\u68C0\u67E5\u6E38\u620F\u65E5\u5FD7\u3002")),15e3)})])}finally{clearTimeout(l),s&&hd.delete(s),bl.delete(i)}}async function vv(){if(!navigator.locks)throw new Error("\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u64CD\u4F5C\u9501\u3002");await navigator.locks.request(gv,{ifAvailable:!0},t=>{if(!t)throw new Error("\u4ECD\u6709\u64CD\u4F5C\u8FD0\u884C\u4E2D\uFF0C\u8BF7\u5148\u505C\u6B62\u5E76\u7B49\u5F85\u5B8C\u6210\u3002");QS()})}function vn(t,e,n="planet"){return n==="planet"?bt(t,e):t.bodyFleets?.get(At(e,n))??[]}function un(t,e,n="planet"){return n==="sun"?t.suns?.find(i=>i.sunId===e):n==="comet"?t.meteorites?.find(i=>i.meteoriteId===e):t.planets.find(i=>i.planetId===e)}function bt(t,e){return t.fleetsByTarget?.get(e)??(t.fleetsByTarget?[]:t.fleets?.filter(n=>n.target===e)??[])}function te(t,e,n){let i=[],a=(l,s)=>l.score-s.score||l.index-s.index;if(e<=0)return[];if(e>=t.length)return t.map((l,s)=>({item:l,index:s,score:n(l)})).sort(a).map(l=>l.item);for(let l=0;l0;){let u=o-1>>1;if(a(i[u],s)>=0)break;i[o]=i[u],o=u}i[o]=s}else if(a(s,i[0])<0){let o=0;for(;o*2+10&&u++,a(s,i[u])>=0)break;i[o]=i[u],o=u}i[o]=s}}return i.sort(a).map(l=>l.item)}function Sl(t,e,n,i,a,l=!1){let s=new Map;return(o,u,d,c,v,f)=>{let m=t.productionTicks?.get(o.planetId),y=o.level;if(!m||!Number.isFinite(m)||m<=0||!Number.isInteger(y)||!y||y<1||y>10||!u||!d||c<=m)return;let h=s.get(o.planetId);if(!h||h.stock!==u){let S=Math.min(e.radius,8),p=n(o,S).filter(g=>g.ownerId==null&&Number.isSafeInteger(g.probeCount)&&g.probeCount>=0&&g.probeCounttt(o,b))){let{route:b,count:x}=a(o,g);if(!_t(b)||b.travelMs>e.maxTravelMs)continue;let T=x??Math.ceil((g.probeCount+Ze)*100/(100-b.lossPct)),w=T-u;!Number.isSafeInteger(T)||w>2||w<=0&&(!l||x===void 0)||r.push({target:g.planetId,required:T,eta:Math.ceil(Math.max(0,w)/y)*m+b.travelMs})}h={stock:u,prospects:r.sort((g,b)=>g.eta-b.eta)},s.set(o.planetId,h)}return h.prospects.find(S=>S.target!==v&&!f?.has(S.target)&&u-dglobalThis.scheduler.postTask(()=>{},{priority:"background"}),Yu=()=>new Promise(t=>setTimeout(t,0)),Os=()=>({computeMs:0,waitMs:0,refreshMs:0,slices:0});async function Hi(t,e,n=()=>{},i=GS,a=8,l,s=a){let o=!1,u=performance.now(),d=!0,c=u+a;try{for(;e();){let v=t.next();if(v.done)return o=!0,v.value;if(performance.now()>=c){let f=performance.now();l&&(l.computeMs+=f-u,l.slices++,l.waitingSince=f),d=!1;try{await i()}finally{l&&(l.waitMs+=performance.now()-f,l.waitingSince=void 0)}let m=Math.max(0,performance.now()-f);if(!e())return;let y=performance.now();try{n()}finally{l&&(l.refreshMs+=performance.now()-y)}u=performance.now(),d=!0,c=u+Math.min(s,a+m/2)}}}finally{l&&d&&(l.computeMs+=performance.now()-u),o||t.return(void 0)}}function we(t,e){let n=t.ownerId?.toHexString();return!!n&&n!==e.identity&&!e.allies?.has(n)}function Qu(t,e,n,i=new zt(e.planets.filter(a=>we(a,e)))){let a=n.filter(f=>Q(t,f.policy.zone)),l=Math.max(0,...a.map(f=>f.settings.reserve));if(e.automated?.has(t.planetId))return 1/0;if(!e.intelligence)return l;let s=e.budgets.get(t.planetId)??0;for(let f of a)i.near(t,f.policy.threatRadius).length&&(l=Math.max(l,Math.ceil(s*f.policy.frontlinePercent/100)));let o=[];for(let f of bt(e,t.planetId))if(!(f.owner===e.identity||e.allies?.has(f.owner))){if(f.count===null||f.arrival===null||!Number.isFinite(f.arrival)||!Number.isSafeInteger(f.count)||f.count<0)return 1/0;o.push(f)}let u=0,d=0,c=Number.isInteger(t.level)&&t.level>=1&&t.level<=10?t.level:0,v=Date.now();for(let f of o.sort((m,y)=>m.arrival-y.arrival)){u+=f.count*2;let m=Math.floor(Math.max(0,f.arrival-v-6e4)/6e4)*c;d=Math.max(d,u+2-m)}return l+d}function yv(t,e,n){let i=new zt(t.planets.filter(a=>we(a,t)));return new Map(t.owned.map(a=>[a.planetId,Math.max(0,(t.budgets.get(a.planetId)??0)-Qu(a,t,e,i)-(n.get(a.planetId)??0))]))}function Un(t,e){let n=new zt(t.planets.filter(a=>we(a,t))),i=new zt(t.owned.filter(a=>Q(a,e.policy.zone)));return a=>{if(!t.intelligence)return"unknown";let l=n.near(a,e.policy.threatRadius);if(!l.length)return"low";let s=Math.min(...l.map(u=>tt(u,a))),o=Math.min(...i.near(a,Math.max(8,e.policy.threatRadius)).map(u=>tt(u,a)));return o>8&&sn+i.count,0))}upgraded(){this.metrics.upgrades++}captured(e,n){if(e.targetKind==="sun")this.metrics.suns++;else if(e.targetKind==="comet"){this.metrics.meteorites++;return}else this.metrics.planets++,this.metrics.addedBaseProduction+=n.planets.find(i=>i.planetId===e.targetId)?.level??1;this.captures.size>=1e3&&this.captures.delete(this.captures.keys().next().value);for(let i of this.captures.values())st(i.job)===st(e)&&(i.held=!1);this.captures.set(`${st(e)}:${++this.sequence}`,{job:e,at:Date.now(),held:!0,checked30:!1})}observe(e){let n=new Set((e.allOwned??e.owned).map(i=>i.planetId));for(let[i,a]of this.captures){let{job:l}=a,s=l.targetKind==="sun"?!!e.identity&&un(e,l.targetId,"sun")?.ownerId?.toHexString()===e.identity:n.has(l.targetId);a.held&&=s;let o=Date.now()-a.at;o>=18e5&&!a.checked30&&(this.metrics.retention30.total++,a.held&&this.metrics.retention30.held++,a.checked30=!0),o>=36e5&&(this.metrics.retention60.total++,a.held&&this.metrics.retention60.held++,this.captures.delete(i))}}snapshot(){return{...this.metrics,retention30:{...this.metrics.retention30},retention60:{...this.metrics.retention60},tracked:this.captures.size}}},Gu=class{safeSince=new Map;attempted=new Map;reset(){this.safeSince.clear(),this.attempted.clear()}observe(e,n){let i=new zt(e.planets.filter(l=>we(l,e))),a=new Set(e.owned.map(l=>l.planetId));for(let l of this.safeSince.keys())a.has(l)||(this.safeSince.delete(l),this.attempted.delete(l));for(let l of e.owned)!e.intelligence||!Q(l,n.policy.zone)||e.automated?.has(l.planetId)||e.autoUpgrading?.has(l.planetId)||i.near(l,n.policy.threatRadius).length>0||bt(e,l.planetId).length>0?this.safeSince.delete(l.planetId):this.safeSince.has(l.planetId)||this.safeSince.set(l.planetId,Date.now())}eligible(e,n,i){if(!i.settings.upgradeStable||n.autoUpgrading?.has(e.planetId)||!n.intelligence||!Number.isInteger(e.level)||e.level<1||e.level>=10||this.attempted.get(e.planetId)===e.level||Date.now()-(this.safeSince.get(e.planetId)??1/0)Q(l,i.policy.zone)&&tt(e,l)<=i.settings.radius;return!i.settings.peacefulDevelopment&&n.planets.some(l=>l.ownerId==null&&a(l))||i.settings.captureSuns&&n.suns?.some(l=>l.ownerId==null&&a(l))||i.settings.captureMeteorites&&n.meteorites?.some(l=>l.ownerId==null&&a(l)&&Number(l.expiresAt.toMillis())>Date.now()+5e3)?!1:100*e.level**2*6e4<=i.settings.economicHorizonMs}plans(e,n,i,a){return ga(this.steps(e,n,i,a))}*steps(e,n,i,a){this.observe(e,n);let l=[];for(let s of e.owned){if(yield,a.has(s.planetId)||!this.eligible(s,e,n))continue;let o=100*s.level**2;if(o<=(i.get(s.planetId)??0)&&l.push({sourceId:s.planetId,targetId:s.planetId,count:o,travelMs:0,kind:"upgrade",expectedLevel:s.level,reason:`\u540E\u65B9\u6301\u7EED\u7A33\u5B9A ${Math.floor(n.settings.stableMs/6e4)} \u5206\u949F\uFF0C\u65E0\u9644\u8FD1\u65E0\u4E3B\u76EE\u6807\uFF1B\u57FA\u7840\u56DE\u672C ${o} \u5206\u949F`}),l.length===200)break}return l}launched(e){e.expectedLevel!==void 0&&this.attempted.set(e.sourceId,e.expectedLevel)}};function vd(t,e,n){return Lu(t,e,n)===void 0}function Lu(t,e,n){let i=un(e,t.targetId,t.targetKind);if(!i)return"\u76EE\u6807\u5DF2\u6D88\u5931\u6216\u4E0D\u5728\u5F53\u524D\u60C5\u62A5\u4E2D";if(i.ownerId!=null)return"\u76EE\u6807\u5DF2\u6709\u4EBA\u5360\u9886";if(!Q(i,n.policy.zone))return"\u76EE\u6807\u4E0D\u5728\u56FA\u5B9A\u6218\u533A\u5185";if(vn(e,t.targetId,t.targetKind).length)return"\u76EE\u6807\u5DF2\u6709\u5176\u4ED6\u8230\u961F\u5728\u9014";if(t.garrison!==void 0&&i.probeCount!==t.garrison)return`\u76EE\u6807\u9A7B\u519B\u5DF2\u53D8\u5316\uFF1A${t.garrison} \u2192 ${i.probeCount}\uFF0C\u9700\u91CD\u65B0\u62A5\u4EF7`;if(t.targetKind==="comet"){let a=e.meteorites?.find(s=>s.meteoriteId===t.targetId),l=a?Number(a.expiresAt.toMillis()):NaN;if(!Number.isFinite(l))return"\u76EE\u6807\u5230\u671F\u65F6\u95F4\u4E0D\u53EF\u7528";if(l<=Date.now()+t.travelMs+5e3)return`\u5269\u4F59\u5BFF\u547D ${Math.max(0,Math.floor((l-Date.now())/1e3))} \u79D2\uFF0C\u4E0D\u8DB3\u822A\u884C ${Math.ceil(t.travelMs/1e3)} \u79D2\u53CA 5 \u79D2\u4F59\u91CF`}}function bv(t){return`${De(t)}\uFF1A${t.reason??"\u589E\u52A0\u5360\u70B9\u6570\uFF0C\u540C\u6837\u5360\u70B9\u6570\u4F18\u5148\u66F4\u65E9\u62B5\u8FBE\uFF0C\u518D\u51CF\u5C11\u8230\u961F"}`}var xl=t=>t.quoteGlobalVersion??t.quoteVersion,_s=(t,e)=>t.sourceQuoteVersions?.get(e)??t.quoteVersion,Ui=(t,e)=>Dt([t.identity,...G(e).map(n=>[n.sourceId,_s(t,n.sourceId)])]),ha=(t,e,n)=>Ui(t,n)===Ui(e,n);function Xu(t,e,n){let i=bt(e,t.planetId);if(!i.length)return e.incoming.has(t.planetId)?null:t.probeCount+Ze;if(i.some(l=>l.owner!==e.identity||l.arriving===null||l.arrival===null||l.arrival>Date.now()+n))return null;let a=t.probeCount+Ze-i.reduce((l,s)=>l+s.arriving,0);return a>0?a:null}function Ku(t,e,n,i,a){if(i.ownerId!=null||!Q(n,a.policy.zone)||!Q(i,a.policy.zone)||tt(n,i)>a.settings.radius)return null;let l=t.route?.(n.planetId,i.planetId),s=t.quote(n.planetId,i.planetId),o=s?.travelMs??l?.travelMs;if(o===void 0||!Number.isFinite(o)||o<0||o>a.settings.maxTravelMs)return null;let u=Xu(i,e,o);if(u===null)return null;let c=bt(e,i.planetId).length>0&&_t(l)?Math.ceil(u*100/(100-l.lossPct)):s?.count;return!c||!Number.isSafeInteger(c)||c>4294967295?null:{sourceId:n.planetId,targetId:i.planetId,count:c,travelMs:o}}function*Sv(t,e,n,i,a,l,s){let{settings:o}=n;if(o.peacefulDevelopment){let N=[];for(let q of e.owned){if(yield,!Q(q,n.policy.zone))continue;let et=i.get(q.planetId)??0;N.push({sourceId:q.planetId,x:q.positionX,y:q.positionY,available:et,reason:et>0?"\u5B89\u7A33\u53D1\u80B2\uFF1A\u4FDD\u7559\u4F59\u5175\u7B49\u5F85\u65E0\u4E3B\u9668\u77F3":"\u5175\u529B\u5DF2\u7528\u4E8E\u9632\u5B88\u6216\u5176\u4ED6\u4EFB\u52A1"})}return l?.(N.length,N.length),{edges:[],candidates:0,sources:N,readySources:N.filter(q=>q.available>0).length}}let u=e.planets.filter(N=>N.ownerId==null&&Q(N,n.policy.zone)),d=Un(e,n),c=new Set;for(let[N,q]of u.entries())d(q)==="exposed"&&c.add(q.planetId),N%32===0&&(yield);let v=u.filter(N=>!a.has(N.planetId)&&Xu(N,e,1/0)!==null&&(!o.cautiousExpansion||!c.has(N.planetId))),f=new zt(u),m=new zt(v),y=new Map,h=Sl(e,o,(N,q)=>m.near(N,q),()=>!0,(N,q)=>({route:t.route?.(N.planetId,q.planetId),count:t.quote(N.planetId,q.planetId)?.count})),S=N=>(y.has(N.planetId)||y.set(N.planetId,Math.min(10,m.near(N,Math.min(o.radius,8)).filter(q=>q.planetId!==N.planetId&&q.probeCount<=N.probeCount+10).length)),y.get(N.planetId)),p=(N,q)=>(N.level??1)*Math.max(0,o.economicHorizonMs-q)/6e4+S(N)*.1,r=e.owned.filter(N=>Q(N,n.policy.zone)),g=new zt(r),b=new Set;for(let N of r)if(yield,(i.get(N.planetId)??0)>0)for(let q of m.near(N,o.radius))b.add(q.planetId);let x=m.ordered().filter(N=>b.has(N.planetId));for(let[N,q]of x.entries())S(q),N%16===0&&(yield);let T=[];for(let N of[q=>q.probeCount,q=>-(q.level??1)/(q.probeCount+Ze),q=>-S(q)])T.push(te(x,x.length,N)),yield;let w=(N,q)=>(N.positionX-q.positionX)**2+(N.positionY-q.positionY)**2,A=[],H=new Set,z=[];l?.(0,r.length);let E=new Map;for(let N of r){yield,l?.(z.length,r.length);let q=i.get(N.planetId)??0,et={sourceId:N.planetId,x:N.positionX,y:N.positionY,available:q,reason:"\u5355\u661F\u5175\u529B\u4E0D\u8DB3\u6216\u62A5\u4EF7\u4E0D\u53EF\u7528\uFF0C\u6682\u65F6\u6CA1\u6709\u53EF\u884C\u534F\u540C"};if(z.push(et),q<=0){et.reason="\u65E0\u53EF\u7528\u5175\u529B\uFF1A\u5DF2\u6263\u9664\u7559\u5B88\u3001\u8FDB\u653B\u9884\u7559\u53CA\u5F85\u540C\u6B65\u7684\u53D1\u5C04";continue}let J=m.near(N,o.radius);if(!J.length){et.reason=o.cautiousExpansion&&f.near(N,o.radius).some(D=>c.has(D.planetId))?"\u7A33\u5065\u6269\u5F20\u6682\u7F13\u654C\u65B9\u66F4\u8FD1\u3001\u7F3A\u4E4F\u8FD1\u90BB\u652F\u63F4\u7684\u5B64\u7ACB\u76EE\u6807":f.near(N,o.radius).length?"\u8303\u56F4\u5185\u76EE\u6807\u5DF2\u5728\u9014\u6216\u9501\u5B9A\uFF0C\u907F\u514D\u91CD\u590D\u53D1\u5C04":"\u641C\u7D22\u8DDD\u79BB / \u6218\u533A\u5185\u6CA1\u6709\u65E0\u4E3B\u661F";continue}let U=o.maxSources>1&&t.launchGroup&&t.supportsGroup?.()!==!1?g.near(N,vl).filter(D=>D.planetId!==N.planetId).map(D=>Math.max(0,i.get(D.planetId)??0)).sort((D,F)=>F-D).slice(0,o.maxSources-1):[],P=e.attackMultiplierUpperBound,nt=P!==void 0&&Number.isFinite(P)&&P>=1?[q,...U].reduce((D,F)=>D+Math.ceil(F*P),0):1/0,Ct=P!==void 0&&Number.isFinite(P)&&P>=1?Math.ceil(q*P):1/0,Lt=Math.max(32,o.candidates*8),ee=te(J,Lt,D=>w(N,D)),Ee=[ee,...T.map(D=>{let F=[];for(let ut of D)if(w(N,ut)<=o.radius**2&&(F.push(ut),F.length>=Lt))break;return F})],_e=new Map;for(let D=0;_e.size[D.planetId,D])),ve=s?.source(N,q,[...Te.values()],o.candidates,_s(e,N.planetId)),j=[],Zt=0,O=0,W=0;for(let{target:D,offset:F}of ve?.visits??[...Te.values()].map(ut=>({target:ut,offset:-1}))){yield;let ut=bt(e,D.planetId).length>0;if(!ut&&nt<=D.probeCount){O++;continue}let Yi=!ut&&Ct<=D.probeCount;if(Yi&&W>=o.candidates||ve&&!ve.allow(D.planetId,F))continue;let rt=Yi?null:Ku(t,e,N,D,n),rn=t.route?.(N.planetId,D.planetId);if(j.push({target:D,quote:rt,route:rn}),_t(rn)&&rn.travelMs<=o.maxTravelMs&&!ut&&!e.incoming.has(D.planetId)&&W++,rt&&rt.count<=q&&Zt++,Zt>=o.candidates&&(!ve||ve.settled))break}for(let{target:D}of j)H.add(D.planetId);let Jt=j.filter(D=>D.quote&&D.quote.count<=q).sort((D,F)=>D.quote.travelMs-F.quote.travelMs||D.quote.count-F.quote.count),R=o.maxSources>1&&t.launchGroup&&t.supportsGroup?.()!==!1?j.filter(D=>_t(D.route)&&D.route.travelMs<=o.maxTravelMs&&!e.incoming.has(D.target.planetId)&&!bt(e,D.target.planetId).length).sort((D,F)=>D.route.travelMs-F.route.travelMs):[],L=[...new Map([...Jt,...R].map(D=>[D.target.planetId,D])).values()].slice(0,o.candidates);ve?.finish(L.map(D=>D.target.planetId));let Z=j.flatMap(D=>D.quote?[D.quote.travelMs]:_t(D.route)?[D.route.travelMs]:[]);Z.length&&Z.every(D=>D>o.maxTravelMs)?et.reason=`\u6700\u8FD1\u822A\u7A0B\u7EA6 ${Math.ceil(Math.min(...Z)/1e3)} \u79D2\uFF0C\u8D85\u8FC7\u6700\u957F\u822A\u884C ${o.maxTravelMs/1e3} \u79D2`:Z.length||(et.reason=!j.length&&O?"\u5355\u661F\u53CA\u53EF\u534F\u540C\u6765\u6E90\u5175\u529B\u4E0D\u8DB3\uFF1A\u6309\u653B\u51FB\u52A0\u6210\u4E0A\u754C\u4ECD\u65E0\u6CD5\u5360\u9886":"\u5F53\u524D\u6CA1\u6709\u6709\u6548\u539F\u751F\u62A5\u4EF7 / \u822A\u7EBF"),j.length1&&t.launchGroup&&t.supportsGroup?.()!==!1&&!e.incoming.has(D.planetId)&&!bt(e,D.planetId).length&&_t(ut)&&ut.travelMs<=o.maxTravelMs){let Yi=E.get(D.planetId)??{target:D,sources:[]};Yi.sources.push({planet:N,available:q,...ut}),E.set(D.planetId,Yi)}}l?.(r.length,r.length);for(let{target:N,sources:q}of E.values()){yield;for(let et of Iu(q,o.maxSources))yield,A.push(...Nu(N,et,{...o,horizonMs:o.maxTravelMs}).map(J=>({...J,value:p(N,Math.max(J.travelMs,...(J.support??[]).map(U=>U.travelMs)))})))}let _=new Map(r.map(N=>[N.planetId,N])),M=new Map,I=[],B=new Set;for(let N of A){yield;let q=ot(N),et=G(N);if(!et.some(J=>{let U=h(_.get(J.sourceId),i.get(J.sourceId)??0,J.count,q,N.targetId);return U&&M.set(J.sourceId,U.target),!!U})){I.push(N);for(let J of et)B.add(J.sourceId)}}for(let N of z)B.has(N.sourceId)?N.reason="\u53EF\u51FA\u5175\uFF1B\u5F53\u524D\u76EE\u6807\u4F18\u5148\u5206\u7ED9\u66F4\u5FEB\u6765\u6E90\u6216\u53D7\u5269\u4F59\u9884\u7B97\u9650\u5236":M.has(N.sourceId)&&(N.reason=`\u4E3A\u9644\u8FD1 #${M.get(N.sourceId)} \u4FDD\u7559\u5175\u529B\uFF0C\u9884\u8BA1\u66F4\u65E9\u5360\u9886`);return{edges:I,candidates:H.size,sources:z,readySources:B.size,exposed:c.size,...s?.deferredSources?{deferredSources:s.deferredSources}:{}}}function LS(t,e,n){let i=[...t].sort((a,l)=>ot(l)-ot(a)||(a.targetIdl*e+ot(a)<=n)?i:null}function xv(t,e,n=!1){if(t.length!==e.length)return t.length>e.length;let i=o=>o.reduce((u,d)=>u+ot(d),0);if(n&&i(t)!==i(e))return i(t)o.reduce((u,d)=>u+G(d).length,0);if(a(t)!==a(e))return a(t)o.reduce((u,d)=>u+(d.value??0),0);if(l(t)!==l(e))return l(t)>l(e);let s=(o,u)=>o.reduce((d,c)=>d+(u==="count"?pe(c):ot(c)),0);return s(t,"count"){if(!s)return LS(y,n,i);if((y.length-1)*n>i)return null;let h=[...y].sort((S,p)=>ot(S)-ot(p)||(S.targetIdS.expiresAt===void 0||o+l+p*n+ot(S)+5e3ii||new Set(S.map(r=>r.sourceId)).size!==S.length||S.some(r=>!Number.isSafeInteger(r.count)||r.count<1||!Number.isFinite(r.travelMs)||r.travelMs<0||r.travelMs>(a??i)||r.count>(e.get(r.sourceId)??0)))continue;let p=d.get(st(h))??[];p.push(h),d.set(st(h),p)}let c=[...d.values()],v=c.length>128||t.length>1e3;if(v){let y=S=>s?1/(1+ot(S)):(1+(S.value??0))/(pe(S)*(1+ot(S)/i)),h=[];for(let S of c)yield,h.push(S.sort((p,r)=>(s?ot(p)-ot(r):0)||G(p).length-G(r).length||y(r)-y(p)).slice(0,8));c=h.sort((S,p)=>y(p[0])-y(S[0])).slice(0,128)}for(let y of c)yield,y.sort((h,S)=>(s?ot(h)-ot(S):0)||G(h).length-G(S).length||pe(h)-pe(S)||ot(h)-ot(S));c.sort((y,h)=>y.length-h.length||ot(y[0])-ot(h[0]));let f=[];for(let y of[c,[...c].sort((h,S)=>pe(h[0])-pe(S[0])),[...c].sort((h,S)=>ot(h[0])-ot(S[0]))]){let h=new Map(e),S=[];for(let p of y){yield;for(let r of p)if(!(G(r).some(g=>g.count>(h.get(g.sourceId)??0))||!u([...S,r]))){S.push(r);for(let g of G(r))h.set(g.sourceId,h.get(g.sourceId)-g.count);break}}xv(S,f,s)&&(f=S)}let m=!v&&c.length<=18&&t.length<=100;if(m){let y=0,h=new Map(e),S=[],p=function*(r){if(++y>2e4){m=!1;return}if(y%64===0&&(yield),xv(S,f,s)&&(f=[...S]),!(r===c.length||S.length+c.length-rx.count>(h.get(x.sourceId)??0))||!u([...S,g]))){S.push(g);for(let x of b)h.set(x.sourceId,h.get(x.sourceId)-x.count);yield*p(r+1),S.pop();for(let x of b)h.set(x.sourceId,h.get(x.sourceId)+x.count);if(!m)return}}yield*p(r+1)}};yield*p(0)}return{jobs:u(f)??[],exact:m}}var Ml=class t{cursors=new Map;pending=!1;deferredSources=0;fork(e){let n=new t;for(let i of e){let a=this.cursors.get(i.planetId);a&&n.cursors.set(i.planetId,a)}return n}source(e,n,i,a,l){let s=Dt([l,e.planetId,e.ownerId,e.positionX,e.positionY,e.galaxyId,e.level]),o=this.cursors.get(e.planetId);(o?.rules!==s||n-o.stock>=Math.max(20,o.stock*.1))&&(o=void 0);let u=new Set(o?.keep),d=o?.next===void 0?-1:i.findIndex(h=>h.planetId===o.next),c=d>=0?d:Math.min(o?.offset??0,i.length),v=new Set(i.slice(0,Math.min(2,a-1)).map(h=>h.planetId));for(let h of u)v.add(h);let f=[...i.filter(h=>v.has(h.planetId)).map(h=>({target:h,offset:-1})),...i.slice(c).flatMap((h,S)=>v.has(h.planetId)?[]:[{target:h,offset:c+S}])],m=0,y;return{visits:f,allow:(h,S)=>u.has(h)?!0:m=0&&(y??=S),!1),settled:!o?.pending,get deferred(){return y!==void 0},finish:h=>{this.pending||=y!==void 0,y!==void 0&&this.deferredSources++,this.cursors.set(e.planetId,{rules:s,stock:Math.min(o?.stock??n,n),next:y===void 0?void 0:i[y]?.planetId,offset:y??0,keep:h,pending:y!==void 0})}}}};var Zu=class{revision=0;timing=Os();resetTiming(){this.timing=Os()}previous;search=new Ml;searchKey;dispose(){this.revision++,this.previous=void 0,this.search=new Ml,this.searchKey=void 0}run(e,n,i,a=()=>{}){let l=this.revision,s=()=>!n.aborted&&l===this.revision&&i();return s()&&a(),Hi(e,s,a,void 0,8,this.timing,12)}async proposals(e,n,i,a,l,s,o,u){let d=this.revision,c=n.quoteVersion===void 0?void 0:Dt([n.quoteVersion,i,n.planets,n.owned,[...a],[...n.productionTicks??[]],[...l],[...n.incoming],n.fleets,[...n.fleetsByTarget??[]],n.attackMultiplierUpperBound,[...n.automated??[]],n.intelligence,n.identity,[...n.allies??[]]]);if(!this.search.pending&&c&&this.previous?.key===c&&this.previous.expires>Date.now()&&!s.aborted&&o())return u?.(this.previous.result.sources.length,this.previous.result.sources.length),this.previous.result;let v=Dt([xl(n),n.identity,i]),f=(v===this.searchKey?this.search:new Ml).fork(n.owned),m=await this.run(Sv(e,n,i,a,l,u,f),s,o,()=>e.refreshQuotes?.());return m&&d===this.revision&&!s.aborted&&o()&&(this.search=f,this.searchKey=v,this.previous=c?{key:c,result:m,expires:Date.now()+(n.fleets?.length?1e3:3e4)}:void 0),m}plan(e,n,i,a,l,s,o,u,d){return this.run(Vu(n,i,a,l,s,o),u,d)}};var Ju=class{stocks=new Map;checked=new Map;initializedAt;reset(){this.stocks.clear(),this.checked.clear(),this.initializedAt=void 0}*steps(e,n,i,a,l,s){let o=Date.now();if(this.initializedAt===void 0)return this.initializedAt=o,this.stocks=new Map(n.budgets),[];let u=n.owned.filter(E=>Q(E,i.policy.zone)&&(a.get(E.planetId)??0)>0),d=i.settings.maxSources>1&&!!e.launchGroup&&!!e.route&&e.supportsGroup?.()!==!1,c=n.attackMultiplierUpperBound,v=E=>c!==void 0&&Number.isFinite(c)&&c>=1?Math.ceil(E*c):1/0,f=E=>(n.budgets.get(E)??0)-(this.stocks.get(E)??0),y=[...u.filter(E=>f(E.planetId)>=Math.max(20,(this.stocks.get(E.planetId)??0)*.1)).sort((E,_)=>f(_.planetId)-f(E.planetId)),...s&&o-this.initializedAt>=2e3?u.filter(E=>o-(this.checked.get(E.planetId)??0)>=5e3).sort((E,_)=>(this.checked.get(E.planetId)??0)-(this.checked.get(_.planetId)??0)||(a.get(_.planetId)??0)-(a.get(E.planetId)??0)):[]];for(let[E,_]of n.budgets)_<(this.stocks.get(E)??0)&&this.stocks.set(E,_);if(!y.length)return[];let h=new Map(a),S=new zt(d?u:[]),p=new zt(n.planets.filter(E=>E.ownerId==null&&Q(E,i.policy.zone)&&!l.has(E.planetId)&&Xu(E,n,1/0)!==null)),r=Un(n,i),g=new Set,b=[],x=0,T=0,w=!1,A=Sl(n,i.settings,(E,_)=>p.near(E,_),E=>!l.has(E.planetId)&&(!i.settings.cautiousExpansion||r(E)!=="exposed"),(E,_)=>T>=96?(w=!0,{}):(T++,{route:e.route?.(E.planetId,_.planetId),count:e.quote(E.planetId,_.planetId)?.count})),H=new Map(u.map(E=>[E.planetId,E])),z=E=>{let _=ot(E);return!G(E).some(I=>A(H.get(I.sourceId),h.get(I.sourceId)??0,I.count,_,E.targetId,l))&&!w};for(let E of y){yield;let _=E.planetId;if(g.has(_))continue;g.add(_),this.checked.set(_,o),this.stocks.set(_,n.budgets.get(_)??0);let M=p.near(E,i.settings.radius);if(!M.length)continue;let I=d?S.near(E,vl).filter(U=>U.planetId!==_&&(h.get(U.planetId)??0)>0):[],B=te(I,20,U=>-(h.get(U.planetId)??0)),N=v(h.get(_)??0)+B.slice(0,i.settings.maxSources-1).reduce((U,P)=>U+v(h.get(P.planetId)??0),0),q=M.filter(U=>N>U.probeCount||bt(n,U.planetId).length);if(!q.length)continue;let et=0,J=0;for(let U of te(q,32,P=>(P.positionX-E.positionX)**2+(P.positionY-E.positionY)**2)){if(yield,l.has(U.planetId)||i.settings.cautiousExpansion&&r(U)==="exposed")continue;if(T>=96)break;let P=bt(n,U.planetId).length>0,nt=null;if((v(h.get(_)??0)>U.probeCount||P)&&(T++,nt=Ku(e,n,E,U,i),nt&&nt.count>(h.get(_)??0)&&(nt=null)),d&&!P&&!n.incoming.has(U.planetId)&&J++<4){let Ct=S.near(U,i.settings.radius).filter(j=>j.planetId!==_&&(h.get(j.planetId)??0)>0),Lt=te(Ct,10,j=>tt(j,U)),ee=te(Ct,10,j=>-(h.get(j.planetId)??0)),Ee=[...new Map([...Lt,...ee].map(j=>[j.planetId,j])).values()],_e=[],Te=nt?[nt]:[],ve=ee.slice(0,i.settings.maxSources).reduce((j,Zt)=>j+v(h.get(Zt.planetId)??0),0);for(let j of nt&&ve<=U.probeCount?[]:[E,...Ee]){yield;let Zt=h.get(j.planetId)??0;if(!Zt||tt(j,U)>i.settings.radius)continue;if(T>=96)break;T++;let O=e.route(j.planetId,U.planetId);if(!(!_t(O)||O.travelMs>i.settings.maxTravelMs)&&!(nt&&!nt.support?.length&&O.travelMs>=nt.travelMs)&&(_e.push({planet:j,available:Zt,...O}),j.planetId!==_&&v(Zt)>U.probeCount)){let W=Ku(e,n,j,U,i);W&&W.count<=Zt&&Te.push(W)}}for(let j of Iu(_e,i.settings.maxSources))yield,Te.push(...Nu(U,j,{...i.settings,horizonMs:i.settings.maxTravelMs}));nt=Te.filter(z).sort((j,Zt)=>ot(j)-ot(Zt)||G(j).length-G(Zt).length||pe(j)-pe(Zt))[0]??null}if(!(!nt||!z(nt))){b.push({...nt,reason:nt.support?.length?"\u524D\u7EBF\u5FEB\u901F\u5408\u5175\uFF1A\u9644\u8FD1\u6765\u6E90\u534F\u540C\u5360\u9886":"\u524D\u7EBF\u5FEB\u901F\u8865\u5145\uFF1A\u9644\u8FD1\u53EF\u5360\u9886\u76EE\u6807"}),l.add(U.planetId);for(let Ct of G(nt))h.set(Ct.sourceId,(h.get(Ct.sourceId)??0)-Ct.count);if(++et>=3)break}}if(++x>=4||b.length||T>=96)break}return b.sort((E,_)=>ot(E)-ot(_))}};var wl=class{version;adapter;entries=new Map;stats={fresh:0,reused:0};clear(){this.entries.clear(),this.version=void 0,this.adapter=void 0}begin(e,n){let i=xl(n);if((e!==this.adapter||i===void 0||i!==this.version)&&this.entries.clear(),this.adapter=e,this.version=i,this.stats={fresh:0,reused:0},n.quoteVersion===void 0)return e;let a=new Map(n.owned.map(r=>[r.planetId,r])),l=new Map;for(let r of n.planets)r.ownerId==null&&l.set(At(r.planetId),r);for(let r of n.suns??[])r.ownerId==null&&l.set(At(r.sunId,"sun"),r);for(let r of n.meteorites??[])r.ownerId==null&&l.set(At(r.meteoriteId,"comet"),r);let s=new Map,o=new Map,u=new Map,d=r=>{if(a.has(r))return s.has(r)||s.set(r,Dt([a.get(r),n.budgets.get(r)])),s.get(r)},c=r=>{let g=a.get(r);if(g)return o.has(r)||o.set(r,Dt([_s(n,r),r,g.ownerId,g.positionX,g.positionY,g.galaxyId,g.level])),o.get(r)},v=r=>{if(l.has(r))return u.has(r)||u.set(r,Dt(l.get(r))),u.get(r)},f=new Map,m=new Set,y=(r,g,b="planet")=>a.has(r)&&l.has(At(g,b)),h=(r,g,b="planet")=>{let x=`${r}:${At(g,b)}`,T=d(r),w=v(At(g,b)),A=c(r),H=n.quoteVersion!==void 0&&T!==void 0&&w!==void 0,z=f.get(x);if(z&&Date.now()1e5&&this.entries.delete(this.entries.keys().next().value)),I},S=(r,g,b="planet")=>{let x=`${r}:${At(g,b)}`,T=this.entries.get(x);return T?.route&&T.rules===c(r)&&T.target===v(At(g,b))&&Date.now()y(r,g)?h(r,g).quote:e.quote(r,g),route:e.route?(r,g)=>y(r,g)?S(r,g):e.route(r,g):void 0,quoteBody:e.quoteBody?(r,g,b)=>y(r,g,b)?h(r,g,b).quote:e.quoteBody(r,g,b):void 0,routeBody:e.routeBody?(r,g,b)=>y(r,g,b)?S(r,g,b):e.routeBody(r,g,b):void 0,bodyQuoteIssue:e.bodyQuoteIssue?(r,g,b)=>y(r,g,b)?h(r,g,b).issue:e.bodyQuoteIssue(r,g,b):void 0};return new Proxy(e,{get(r,g){if(g in p)return p[g];let b=Reflect.get(r,g);return typeof b=="function"?b.bind(r):b}})}};function $u(t,e){let n=t.owned.filter(i=>Q(i,e.policy.zone));if(!n.length){let i=e.policy.zone,a=[...t.allOwned??t.owned].sort((l,s)=>Math.hypot(l.positionX-i.x,l.positionY-i.y)-Math.hypot(s.positionX-i.x,s.positionY-i.y))[0];return`\u8FDB\u653B\u672A\u542F\u52A8\uFF1A\u6218\u533A\u5185\u5DF1\u65B9\u661F\u7403\u4E3A 0\u3002\u8BF7\u628A\u6218\u533A\u79FB\u5230\u654C\u6211\u4EA4\u754C\uFF0C\u5E76\u540C\u65F6\u8986\u76D6\u5175\u6E90\u548C\u76EE\u6807\u3002${a?`\u6700\u8FD1\u5DF1\u65B9\u661F #${a.planetId} (${a.positionX}, ${a.positionY}) \u8DDD\u4E2D\u5FC3 ${Math.ceil(Math.hypot(a.positionX-i.x,a.positionY-i.y))} \u683C\uFF0C\u5F53\u524D\u534A\u5F84 ${i.radius}\u3002`:""}`}if(n.every(i=>t.automated?.has(i.planetId)))return`\u8FDB\u653B\u672A\u542F\u52A8\uFF1A\u6218\u533A\u5185 ${n.length} \u9897\u5DF1\u65B9\u661F\u5747\u542F\u7528\u4E86\u539F\u751F\u81EA\u52A8\u8F6C\u53D1\uFF0C\u6CA1\u6709\u53EF\u8C03\u5EA6\u5175\u6E90\u3002`}function Pu(t,e,n){let i=[te(e,n,l=>(l.positionX-t.positionX)**2+(l.positionY-t.positionY)**2),te(e,n,l=>-(l.level??1)/(l.probeCount+1))],a=new Map;for(let l=0;a.sizea.settings.radius)return null;let s=t.route?.(n.planetId,i.planetId);if(!_t(s)||s.travelMs>a.settings.maxTravelMs||e.incoming.has(i.planetId)||bt(e,i.planetId).length)return null;let o=t.quote(n.planetId,i.planetId),u=i.level;if(!Number.isInteger(u)||u<1||u>10)return null;let d=Math.ceil((u*2+a.policy.holdProbes)*100/(100-s.lossPct)),c=o?o.count+d:NaN;if(!o&&l){let m=Number(i.lastUpdateTick?.toMillis());if(!Number.isFinite(m))return null;let y=Math.ceil((Math.max(0,Date.now()-m)+s.travelMs)/4e4);c=Math.ceil(((i.probeCount+y*u)*2+Ze)*100/(100-s.lossPct))+d}if(!Number.isSafeInteger(c)||c<1||c>4294967295)return null;let v=tt(n,i),f=(2*u+8/(1+v))/(c*(1+s.travelMs/6e4));return{sourceId:n.planetId,targetId:i.planetId,count:c,travelMs:s.travelMs,value:f}}function*Mv(t,e,n,i,a){if(!e.intelligence)throw new Error("\u7F3A\u5C11\u654C\u6211\u5173\u7CFB\u6216\u8230\u961F\u60C5\u62A5\uFF0C\u8FDB\u653B\u672A\u6267\u884C\u3002");let l=e.planets.filter(S=>El(S,e,n)),s=l.filter(S=>!a.has(S.planetId)&&!e.incoming.has(S.planetId)&&!bt(e,S.planetId).length),o=e.owned.filter(S=>Q(S,n.policy.zone)&&!e.automated?.has(S.planetId)),u={sources:o.length,available:o.reduce((S,p)=>S+(i.get(p.planetId)??0),0),targets:l.length,blocked:l.length-s.length,noBudget:0,noTargets:0,tooSlow:0,noQuote:0,insufficient:0,feasible:0},d=new zt(s),c=[],v=[],f=new Set;for(let S of o){yield;let p=i.get(S.planetId)??0;if(p<=0){u.noBudget++;continue}let r=Pu(S,d.near(S,n.settings.radius),Math.max(32,n.settings.candidates*8));r.length||u.noTargets++;let g=[],b=0;for(let x of r){yield,b++,f.add(x.planetId);let T=t.route?.(S.planetId,x.planetId);if(_t(T)&&T.travelMs>n.settings.maxTravelMs){u.tooSlow++;continue}let w=li(t,e,S,x,n,!0);if(!w){u.noQuote++;continue}if(w.count<=p&&t.quote(S.planetId,x.planetId)?(g.push(w),u.feasible++):(u.insufficient++,S.level&&w.count<=p+S.level*2&&v.push(w)),g.length>=n.settings.candidates&&b>=n.settings.candidates*2)break}c.push(...g.sort((x,T)=>x.travelMs-T.travelMs||x.count-T.count).slice(0,n.settings.candidates))}let m=(S,p)=>(p.value??0)-(S.value??0)||S.travelMs-p.travelMs||(S.targetIdthis.campaign.deadline)return;let{hub:i,target:a}=this.campaign;if(!(!e.owned.some(l=>l.planetId===i&&Q(l,n.policy.zone))||e.automated?.has(i)||!e.planets.some(l=>l.planetId===a&&El(l,e,n))))return{hub:i,target:a}}*steps(e,n,i,a,l,s,o,u){let d=this.hubId(i);if(d!==void 0&&!n.owned.some(g=>g.planetId===d&&Q(g,i.policy.zone)&&!n.automated?.has(d)))return{candidates:1,waiting:`\u4E2D\u8F6C\u661F #${d} \u4E0D\u5C5E\u4E8E\u5DF1\u65B9\u3001\u4F4D\u4E8E\u6218\u533A\u5916\u6216\u542F\u7528\u4E86\u539F\u751F\u81EA\u52A8\u5316\uFF1B\u8BF7\u505C\u6B62\u8FDB\u653B\u540E\u8C03\u6574`,reservations:new Map};if(this.campaign){let g=n.planets.find(x=>x.planetId===this.campaign.target),b=n.owned.find(x=>x.planetId===this.campaign.hub);if(!g||!b||u.has(b.planetId)||!El(g,n,i)||n.automated?.has(b.planetId))this.campaign=void 0,d=this.hubId(i);else{if(l.has(g.planetId))return{candidates:0,waiting:"\u96C6\u7ED3\u76EE\u6807\u5DF2\u53EF\u76F4\u63A5\u8FDB\u653B\uFF0C\u6682\u505C\u8865\u7ED9\u5E76\u7B49\u5F85\u51FA\u51FB",reservations:new Map};if(Date.now()>this.campaign.deadline)return this.preferredHub=b.planetId,this.campaign=void 0,{candidates:1,waiting:"\u672C\u6B21\u96C6\u7ED3\u7B49\u5F85\u8D85\u65F6\uFF0C\u5DF2\u91CA\u653E\u672A\u53D1\u5C04\u9884\u7559\uFF1B\u5DF2\u53D1\u8230\u961F\u7EE7\u7EED\u822A\u884C",reservations:new Map};{let x=li(e,n,b,g,i);if(x&&x.count<=(a.get(b.planetId)??0))return{job:x,candidates:1,waiting:"",reservations:new Map([[x.sourceId,x.count]])};let T=yield*this.gather(e,n,i,a,b,g,s(b.planetId),o(b));return T?this.result(T):{candidates:1,waiting:`\u96C6\u7ED3\u76EE\u6807 #${g.planetId} \u7684\u6218\u51B5\u53D8\u5316\uFF0C\u6682\u505C\u8865\u7ED9\u5E76\u7B49\u5F85\u91CD\u65B0\u8BC4\u4F30`,reservations:new Map}}}}let c=d===void 0?n.owned:n.owned.filter(g=>g.planetId===d),v={candidates:0,waiting:"\u5269\u4F59\u5175\u529B\u4E0D\u8DB3\u4EE5\u5B8C\u6210\u65B0\u7684\u96C6\u7ED3\uFF0C\u7EE7\u7EED\u8BC4\u4F30\u9644\u8FD1\u76F4\u653B\u673A\u4F1A"};if(!e.launchGroup||e.supportsGroup?.()===!1)return{...v,reservations:new Map};let f=n.planets.filter(g=>El(g,n,i)&&!l.has(g.planetId));if(!f.length)return{...v,reservations:new Map};let m=new zt(f),y=[];for(let g of c){if(yield,!Q(g,i.policy.zone)||n.automated?.has(g.planetId)||u.has(g.planetId)||bt(n,g.planetId).some(T=>T.owner!==n.identity&&!n.allies?.has(T.owner)))continue;let b=[],x=Pu(g,m.near(g,i.settings.radius),Math.max(32,i.settings.candidates*8));for(let[T,w]of x.entries()){yield;let A=li(e,n,g,w,i,!0);if(A&&b.push({target:w,travelMs:A.travelMs}),b.length>=3&&T>=5)break}b.sort((T,w)=>T.travelMs-w.travelMs),b.length&&y.push({hub:g,targets:b.slice(0,3).map(T=>T.target),travelMs:b[0].travelMs})}let h=[...y].sort((g,b)=>g.travelMs-b.travelMs),S=[...y].sort((g,b)=>(a.get(b.hub.planetId)??0)-(a.get(g.hub.planetId)??0)),p=[...new Map([...h.slice(0,4),...S.slice(0,4)].map(g=>[g.hub.planetId,g])).values()],r;for(let{hub:g,targets:b}of p){yield;let x=yield*this.donors(e,n,i,a,g);for(let T of b){let w=yield*this.gather(e,n,i,a,g,T,s(g.planetId),o(g),x);w?.complete&&(w.job||w.state.incoming>0)&&(!r||w.arrivalMsc.planetId!==l.planetId&&Q(c,i.policy.zone)&&(a.get(c.planetId)??0)>0&&!n.automated?.has(c.planetId)),u=[...o].sort((c,v)=>tt(c,l)-tt(v,l)).slice(0,yd/2),d=[...o].sort((c,v)=>(a.get(v.planetId)??0)-(a.get(c.planetId)??0)).slice(0,yd/2);for(let[c,v]of[...new Map([...u,...d,...o].map(f=>[f.planetId,f])).values()].slice(0,yd).entries()){yield;let f=e.route?.(v.planetId,l.planetId);_t(f)&&f.travelMs<=i.policy.rallyMs&&s.push({planet:v,available:a.get(v.planetId),...f})}return s.sort((c,v)=>c.travelMs-v.travelMs||v.available-c.available||(c.planet.planetIdz.owner!==n.identity&&!n.allies?.has(z.owner)))return null;let c=li(e,n,l,s,i,!0),v=e.route?.(l.planetId,s.planetId);if(!c||!_t(v))return null;let f=bt(n,l.planetId).filter(z=>z.owner===n.identity||n.allies?.has(z.owner));if(f.some(z=>z.arriving===null||z.arrival===null))return null;let m=Math.max(o.count,f.reduce((z,E)=>z+E.arriving,0)),y=Math.max(0,o.arrival-Date.now(),...f.map(z=>z.arrival-Date.now())),h=a.get(l.planetId)??0,S=1-u.percent/100,p=z=>c.count+Math.ceil(Math.ceil(z/4e4)*s.level*2*100/(100-v.lossPct)),r=z=>Math.max(0,Math.ceil((p(z)-h+u.deficit)/S)),g=[],b=m;for(let z of d??(yield*this.donors(e,n,i,a,l))){if(b>=r(y))break;let E=z.travelMs+Math.floor(g.length/wv)*i.settings.intervalMs;y=Math.max(y,E);let _=r(y)-b,M=Math.min(z.available,Math.ceil(_*100/(100-z.lossPct))),I=Wt(M,z.lossPct);I<1||(g.push({sourceId:z.planet.planetId,count:M,travelMs:z.travelMs}),b+=I)}let x=b>=r(y)&&p(y)<=4294967295,T=new Map([[l.planetId,h]]);if(x)for(let z of g)T.set(z.sourceId,z.count);let w=x?g.slice(0,wv):[],[A,...H]=w;return{job:A?{...A,support:H,targetId:l.planetId,kind:"reinforce"}:void 0,reservations:T,state:{hub:l.planetId,target:s.planetId,required:p(y),available:h,incoming:m,sources:g.length},complete:x,arrivalMs:y+v.travelMs}}refresh(e,n,i,a,l){let s=this.campaign;if(!s||s.hub!==l.targetId||!e.launchGroup||e.supportsGroup?.()===!1)return null;let o=n.owned.find(m=>m.planetId===l.targetId),u=n.planets.find(m=>m.planetId===s.target);if(!o||!u||!Q(o,i.policy.zone)||n.automated?.has(o.planetId)||!li(e,n,o,u,i,!0)||bt(n,o.planetId).some(m=>m.owner!==n.identity&&!n.allies?.has(m.owner)))return null;let d=li(e,n,o,u,i);if(d&&d.count<=(a.get(o.planetId)??0))return null;let c=[];for(let m of G(l)){let y=n.owned.find(S=>S.planetId===m.sourceId),h=e.route?.(m.sourceId,o.planetId);if(!y||y.planetId===o.planetId||!Q(y,i.policy.zone)||n.automated?.has(y.planetId)||m.count>(a.get(m.sourceId)??0)||!_t(h)||h.travelMs>i.policy.rallyMs||Wt(m.count,h.lossPct)<1)return null;c.push({...m,travelMs:h.travelMs})}let[v,...f]=c;return v?{...v,targetId:o.planetId,kind:"reinforce",support:f}:null}},Fu=class t{slots=[];lastKind="reinforce";nextRally=0;reset(){this.slots=[],this.lastKind="reinforce",this.nextRally=0}fork(){let e=new t;return e.slots=this.slots.map(n=>n.fork()),e.lastKind=this.lastKind,e.nextRally=this.nextRally,e}captured(e,n){for(let i of this.slots)i.captured(e,n)}launched(e,n){this.lastKind=e.kind==="reinforce"?"reinforce":"direct",this.slots.length||this.slots.push(new ju);let i=this.slots.findIndex(a=>e.kind==="reinforce"?a.hub===e.targetId:a.target===e.targetId);i>=0?(this.slots[i].launched(e,n),e.kind==="reinforce"&&(this.nextRally=(i+1)%this.slots.length)):(this.slots.find(l=>l.hub===e.sourceId)??this.slots[0])?.launched(e,n)}plan(e,n,i,a,l,s,o){return ga(this.steps(e,n,i,a,l,s,o))}*steps(e,n,i,a,l,s,o){let u=i.policy.rallyId?1:i.policy.rallyHubs;for(;this.slots.length{for(let[_,M]of E)v.set(_,Math.max(0,(v.get(_)??0)-M)),f.set(_,(f.get(_)??0)+M)};for(let E of c)m.add(E.targetId),h(new Map([[E.sourceId,E.count]]));let S={...i,settings:{...i.settings,intervalMs:i.settings.intervalMs*u*(c.length?2:1)}},p=this.slots.map(E=>E.claim(n,i)),r=[];for(let E=0;EE.plan.rally).sort((E,_)=>(E.slot-this.nextRally+u)%u-(_.slot-this.nextRally+u)%u),b=[],x=0,T=0,w=this.lastKind==="direct",A=Math.floor(i.settings.horizonMs/i.settings.intervalMs)+1;for(;b.length=c.length)&&T0?f.set(E.sourceId,_):f.delete(E.sourceId)}let H=r.flatMap(E=>E.plan.rallyState?[E.plan.rallyState]:[]),z=H.length?r.filter(E=>E.plan.rallyState).map(E=>E.plan.waiting).join("\uFF1B"):[d.waiting,...r.filter(E=>E.plan.candidates).map(E=>E.plan.waiting)].filter(Boolean).join("\uFF1B");return{...d,job:b.find(E=>E.kind!=="reinforce"),jobs:b,next:b[0],rally:g[0]?.plan.rally,rallyState:H[0],rallyStates:H,exact:d.exact&&!H.length&&c.length===(d.jobs?.length??0)&&x===c.length,reservations:f,candidates:d.candidates+H.length,waiting:z}}refresh(e,n,i,a,l){return this.slots.find(s=>s.hub===l.targetId)?.refresh(e,n,i,a,l)??null}};var Ev=50,Wu=128,bd=16;function XS(t,e){return Number(e.fundable)-Number(t.fundable)||t.required-e.required||t.gap-e.gap||t.travel-e.travel||t.pair.distance-e.pair.distance}function Tv(t,e,n,i,a){if(t>=i)return 0;if(e<=0||!Number.isFinite(n)||n<=0)return 1/0;let l=0;for(let s of[...a].sort((o,u)=>o.at-u.at)){let o=Math.ceil(Math.max(0,i-t-l)/e)*n;if(o<=s.at)return o;if(l+=s.count,t+l+Math.floor(s.at/n)*e>=i)return s.at}return Math.ceil(Math.max(0,i-t-l)/e)*n}var tr=class t{constructor(e){this.kind=e}kind;campaign;routes=new Map;routeLimit=16e3;version;sourceVersions;cursor=0;unfunded=new Map;topology="";pairs=[];nextDiscovery=0;state;upgradeSignature;upgradeInputs(e){return Dt([e.quoteVersion,[...e.budgets],e.planets,e.fleets,[...e.automated??[]],[...e.autoUpgrading??[]],[...e.productionTicks??[]]])}routeBudget=Wu;stats={routes:0,reused:0,checkedPairs:0};get gathering(){return!!this.campaign}get target(){return this.campaign?.target}get hub(){return this.campaign?.hub}reset(){this.campaign=void 0,this.routes.clear(),this.pairs=[],this.topology="",this.nextDiscovery=0,this.unfunded.clear()}fork(){let e=new t(this.kind);return e.campaign=this.campaign&&{...this.campaign,deliveries:this.campaign.deliveries.map(n=>({...n})),attempted:new Map(this.campaign.attempted)},e.routes=this.routes,e.routeLimit=this.routeLimit,e.version=this.version,e.sourceVersions=this.sourceVersions,e.cursor=this.cursor,e.topology=this.topology,e.unfunded=new Map(this.unfunded),e.pairs=this.pairs,e.nextDiscovery=this.nextDiscovery,e.state=this.state,e.upgradeSignature=this.upgradeSignature,e}deferUnstartedSun(e,n){this.kind!=="sun"||this.pairs.length<2||e.attempted.size||e.deliveries.length||bt(n,e.hub).length||(this.unfunded.set(`${e.hub}:${e.target}`,Date.now()+1e4),this.campaign=void 0)}stamp(e,n){return Dt([e.planetId,e.level,e.ownerId,n])}route(e,n,i,a,l){let s=`${n.planetId}:${a}:${l}`,o=Dt([this.sourceVersions?.get(n.planetId)??this.version,n.positionX,n.positionY,n.galaxyId,n.ownerId,i.positionX,i.positionY,i.galaxyId,i.ownerId]),u=this.routes.get(s);if(u?.key===o&&u.expires>Date.now())return this.stats.reused++,u.value;if(this.stats.routes>=this.routeBudget)return null;this.stats.routes++;let d=a==="planet"?e.route?.(n.planetId,l):e.routeBody?.(n.planetId,l,"sun"),c=_t(d)?d:null;return this.routes.set(s,{key:o,value:c,expires:Date.now()+(c?6e5:1e4)}),this.routes.size>this.routeLimit&&this.routes.delete(this.routes.keys().next().value),c}validHub(e,n,i){return!!n.intelligence&&Q(e,i.policy.zone)&&!n.automated?.has(e.planetId)&&(this.kind!=="sun"||!n.planets.some(a=>we(a,n)&&tt(a,e)<=i.policy.threatRadius))&&!bt(n,e.planetId).some(a=>a.owner!==n.identity&&!n.allies?.has(a.owner))}validTarget(e,n,i,a){return e.ownerId==null&&Q(e,a.policy.zone)&&!vn(i,n,this.kind).length&&(this.kind!=="planet"||!i.incoming.has(n))&&(!a.settings.cautiousExpansion||Un(i,a)(e)!=="exposed")}required(e,n){return Math.ceil((e.probeCount+Ze)*(this.kind==="sun"?100:1)*100/(100-n.lossPct))}quote(e,n,i,a,l){let s="sunId"in a?a.sunId:a.planetId,o=this.kind==="sun"?e.quoteBody?.(i.planetId,s,"sun"):e.quote(i.planetId,s);if(!(!o||o.travelMs>l.settings.maxTravelMs))return{...o,sourceId:i.planetId,targetId:s,targetKind:this.kind,campaignKind:this.kind,campaignTargetId:s,garrison:a.probeCount,reason:"\u52DF\u96C6\u5DF2\u5230\u8D26\uFF0C\u6309\u539F\u751F\u62A5\u4EF7\u5B8C\u6210\u524D\u7EBF\u76EE\u6807"}}*steps(e,n,i,a,l,s=()=>0,o={routes:Wu,pairs:bd}){let u=()=>({reservations:new Map});if(this.stats={routes:0,reused:0,checkedPairs:0},this.routeBudget=o.routes,!this.campaign&&(!o.pairs||!o.routes))return u();let d=xl(n);if((d===void 0||d!==this.version)&&this.routes.clear(),this.version=d,this.sourceVersions=n.sourceQuoteVersions,!n.intelligence||this.kind==="planet"&&!e.route||this.kind==="sun"&&(!i.settings.captureSuns||!e.quoteBody||!e.launchBody))return this.campaign=void 0,u();let c=n.owned.filter(R=>Q(R,i.policy.zone)&&!n.automated?.has(R.planetId));this.routeLimit=Math.max(16e3,c.length*2+64);let v=new Map(c.map(R=>[R.planetId,R])),f=(this.kind==="sun"?n.suns??[]:n.planets).filter(R=>R.ownerId==null&&Q(R,i.policy.zone)),m=new Map(f.map(R=>["sunId"in R?R.sunId:R.planetId,R]));if(this.campaign){let R=v.get(this.campaign.hub),L=m.get(this.campaign.target);(!R||!L||!this.validHub(R,n,i)||!this.validTarget(L,this.campaign.target,n,i)||tt(R,L)>i.settings.radius||l.has(At(this.campaign.target,this.kind)))&&(this.campaign=void 0)}if(!this.campaign){if(!o.pairs||!o.routes)return u();let R=this.kind==="sun",L=R&&i.settings.cautiousExpansion?Un(n,i):void 0,Z=R?(n.suns??[]).filter(rt=>m.has(rt.sunId)&&!l.has(At(rt.sunId,"sun"))&&!vn(n,rt.sunId,"sun").length&&L?.(rt)!=="exposed"):f,D=Dt([i.settings.radius,c.map(rt=>[rt.planetId,rt.positionX,rt.positionY]),Z.map(rt=>["sunId"in rt?rt.sunId:rt.planetId,rt.positionX,rt.positionY,R?rt.probeCount:void 0])]);if(D!==this.topology){this.topology=D,this.cursor=0,this.nextDiscovery=0,this.unfunded.clear();let rt=Z.map(Ht=>({...Ht,planetId:"sunId"in Ht?Ht.sunId:Ht.planetId})),rn=new zt(rt),Bn=[];for(let Ht of c){yield;let $t=rn.near(Ht,i.settings.radius),Yn=te($t,2,ke=>tt(Ht,ke)),qs=R?te($t,2,ke=>ke.probeCount+tt(Ht,ke)/(i.settings.radius+1)):[];for(let ke of new Set([...Yn,...qs]))Bn.push({hub:Ht.planetId,target:ke.planetId,distance:tt(Ht,ke)})}if(R){let Ht=new Map;for(let $t of Bn)$t.distance<(Ht.get($t.target)?.distance??1/0)&&Ht.set($t.target,$t);this.pairs=Bn.sort(($t,Yn)=>m.get($t.target).probeCount-m.get(Yn.target).probeCount||+(Yn===Ht.get(Yn.target))-+($t===Ht.get($t.target))||$t.distance-Yn.distance)}else this.pairs=Bn.sort((Ht,$t)=>Ht.distance-$t.distance||m.get(Ht.target).probeCount-m.get($t.target).probeCount)}if(Date.now()rt+(a.get(rn.planetId)??0),0):0,ut,Yi=Math.min(this.cursor+o.pairs,this.pairs.length);for(;this.cursorDate.now())continue;let rn=v.get(rt.hub),Bn=m.get(rt.target);if(!this.validHub(rn,n,i)||!R&&(!this.validTarget(Bn,rt.target,n,i)||l.has(At(rt.target,this.kind))))continue;let Ht=this.route(e,rn,Bn,this.kind,rt.target);if(!Ht||Ht.travelMs>i.settings.maxTravelMs)continue;let $t=this.quote(e,n,rn,Bn,i),Yn=a.get(rt.hub)??0,qs=!!$t&&$t.count<=Yn;if(!R&&qs||!qs&&(!e.launchGroup||e.supportsGroup?.()===!1)&&!(this.kind==="planet"&&i.settings.upgradeStable&&(e.upgrade||e.upgradeMany)))continue;if(!R){this.campaign={hub:rt.hub,target:rt.target,since:Date.now(),deliveries:[],attempted:new Map},this.cursor++;break}let ke=$t?.count??this.required(Bn,Ht);if(!Number.isSafeInteger(ke)||ke>4294967295)continue;let Ad=bt(n,rt.hub).reduce((Fv,Wv)=>Fv+(Wv.arriving??0),0),zd={pair:rt,index:this.cursor,required:ke,gap:Math.max(0,ke-Yn-Ad),travel:Ht.travelMs,fundable:ke<=F+Ad};if((!ut||XS(zd,ut)<0)&&(ut=zd),Z.length===1)break}ut&&(this.campaign={hub:ut.pair.hub,target:ut.pair.target,since:Date.now(),deliveries:[],attempted:new Map},this.cursor=ut.index+1),this.cursor>=this.pairs.length&&(this.cursor=0,this.nextDiscovery=Date.now()+1e4)}let y=this.campaign;if(!y)return u();let h=v.get(y.hub),S=m.get(y.target),p=this.route(e,h,S,this.kind,y.target);if(!p||p.travelMs>i.settings.maxTravelMs)return this.campaign=void 0,u();let r=a.get(h.planetId)??0,g=this.quote(e,n,h,S,i),b=g?.count??this.required(S,p);if(!Number.isSafeInteger(b)||b>4294967295)return this.campaign=void 0,u();let x,T,w=Sl(n,i.settings,(R,L)=>(x??=new zt(n.planets.filter(Z=>Z.ownerId==null&&Q(Z,i.policy.zone))),x.near(R,L)),R=>!l.has(At(R.planetId))&&(!i.settings.cautiousExpansion||(T??=Un(n,i))(R)!=="exposed"),(R,L)=>{let Z=this.route(e,R,L,"planet",L.planetId);if(!Z)return{};let D=this.routes.get(`${R.planetId}:planet:${L.planetId}`),F=n.budgets.get(R.planetId)??0,ut=D.localPrice;return(!ut||ut.stock!==F||ut.garrison!==L.probeCount||ut.level!==L.level)&&(ut=D.localPrice={stock:F,garrison:L.probeCount,level:L.level,count:e.quote(R.planetId,L.planetId)?.count}),{route:Z,count:ut.count}},!0);if(w(h,r,Math.min(r,b),p.travelMs,this.kind==="planet"?y.target:void 0))return this.deferUnstartedSun(y,n),{reservations:new Map,waiting:"\u4E2D\u8F6C\u661F\u4FDD\u7559\u5175\u529B\uFF0C\u9644\u8FD1\u65E0\u4E3B\u661F\u9884\u8BA1\u66F4\u65E9\u5360\u9886"};if(g&&g.count<=r)return{job:g,reservations:new Map([[h.planetId,g.count]]),hub:h.planetId,sun:this.kind==="sun"?y.target:void 0};if(this.kind==="planet"){let R=n.planets.filter(L=>L.planetId!==y.target&&L.ownerId==null&&L.probeCounttt(Z,h))){if(yield,!this.validTarget(L,L.planetId,n,i))continue;let Z=this.quote(e,n,h,L,i);if(Z&&Z.count<=r&&!w(h,r,Z.count,Z.travelMs,L.planetId))return{job:{...Z,campaignTargetId:y.target,reason:"\u7B49\u5F85\u5927\u76EE\u6807\u671F\u95F4\uFF0C\u5148\u5360\u9886\u9644\u8FD1\u53EF\u6253\u76EE\u6807"},reservations:new Map([[h.planetId,Math.min(r,b)]]),hub:h.planetId}}}let A=s(h),H=1-(typeof A=="number"?A:A.percent)/100,z=typeof A=="number"?0:Math.max(0,A.deficit),E=b+z;if(H<=0)return this.deferUnstartedSun(y,n),u();let _=bt(n,h.planetId);y.deliveries=y.deliveries.filter(R=>R.expires>Date.now());let M=new Set(y.deliveries),I=[],B=!1;for(let R of _){let L=[...M].find(D=>R.source===D.source&&R.count===D.sent&&R.arrival!==null&&Math.abs(R.arrival-D.at)<=5e3);L&&M.delete(L);let Z=R.arriving??L?.count;if(Z==null||R.arrival===null){B=!0;break}I.push({count:Z*H,at:Math.max(0,R.arrival-Date.now())})}if(B)return{reservations:new Map([[h.planetId,Math.min(r,b)]]),waiting:`\u4E2D\u8F6C\u661F #${h.planetId} \u6765\u63F4\u6570\u91CF\u6216\u635F\u8017\u672A\u77E5\uFF0C\u7B49\u5F85\u5185\u5B58\u60C5\u62A5\u66F4\u65B0`};for(let R of M)I.push({count:R.count*H,at:Math.max(0,R.at-Date.now())});let N=I.reduce((R,L)=>R+L.count,0),q=n.productionTicks?.get(h.planetId)??6e4,et=h.level??1,J=e.launchGroup&&e.supportsGroup?.()!==!1?c.filter(R=>R.planetId!==h.planetId&&(a.get(R.planetId)??0)>0):[];J.sort((R,L)=>tt(R,h)-tt(L,h)||(a.get(L.planetId)??0)-(a.get(R.planetId)??0));let U=[],P=0,nt=N;for(let R of J){yield;let L=this.stamp(R,n.budgets.get(R.planetId)??0);if(y.attempted.get(R.planetId)===L){P++;continue}let Z=this.route(e,R,h,"planet",h.planetId);if(!Z&&this.stats.routes>=this.routeBudget)break;if(P++,!Z||Z.travelMs>i.settings.maxTravelMs)continue;let D=a.get(R.planetId),F=w(R,D,D,Z.travelMs+p.travelMs),ut=F?Math.max(0,D-F.required):D;if(ut&&(U.push({source:R,available:ut,route:Z}),nt+=Wt(ut,Z.lossPct)*H,nt+r>=E+100))break}U.sort((R,L)=>R.route.travelMs-L.route.travelMs||L.available-R.available);let Ct=[],Lt=[...I],ee=Math.max(0,E-r-N);for(let R of U){if(ee<=0)break;let L=Math.min(R.available,Math.ceil(ee/H*100/(100-R.route.lossPct))),Z=Wt(L,R.route.lossPct)*H;if(Z<=0)continue;let D=R.route.travelMs+Math.floor(Ct.length/Ev)*i.settings.intervalMs;Ct.push({sourceId:R.source.planetId,count:L,travelMs:R.route.travelMs,lossPct:R.route.lossPct}),Lt.push({count:Z,at:D}),ee-=Z}let Ee=g?.count??(this.kind==="planet"?Math.max(1,Math.floor(S.probeCount/(n.attackMultiplierUpperBound??2)*100/(100-p.lossPct))):b),_e=Tv(r+et,et,q,Ee+z,Lt),Te=100,ve=i.settings.intervalMs,j=et===1&&r>=Te?ve+Tv(r-Te,2,q,E,Lt.map(R=>({...R,at:Math.max(0,R.at-ve)}))):1/0,Zt=!n.autoUpgrading?.has(h.planetId)&&!!(e.upgrade||e.upgradeMany)&&this.kind==="planet"&&i.settings.upgradeStable&&y.upgraded!==et&&et===1&&Date.now()-y.since>=i.settings.stableMs&&!_.length&&!y.deliveries.length&&!n.planets.some(R=>we(R,n)&&tt(R,h)<=i.policy.threatRadius)&&!n.planets.some(R=>R.ownerId==null&&tt(R,h)<=i.settings.radius&&R.probeCount+Ze<=r)&&P===J.length&&j+1e3<_e&&Te*q<=i.settings.economicHorizonMs,O={kind:this.kind,hub:h.planetId,target:y.target,required:b,available:r,incoming:Math.round(N),donors:Ct.length,checked:P,total:J.length,readyMs:_e+p.travelMs,upgradeMs:Number.isFinite(j)?j+p.travelMs:void 0,phase:P0?"\u589E\u91CF\u68C0\u67E5\u540E\u65B9\u822A\u8DEF":ee>0?"\u7B49\u5F85\u5175\u529B\u589E\u957F":Ct.length?"\u5206\u6279\u52DF\u96C6\u8865\u7ED9":"\u7B49\u5F85\u8865\u7ED9\u5230\u8D26"};this.state=O,this.upgradeSignature=Zt?this.upgradeInputs(n):void 0;let W=new Map(this.kind==="sun"&&ee>0&&P===J.length?[]:[[h.planetId,Math.min(r,b)]]);if(this.kind==="sun"&&ee>0&&P===J.length&&(this.deferUnstartedSun(y,n),!this.campaign))return{reservations:W,state:O,waiting:"\u5F53\u524D\u6052\u661F\u52DF\u96C6\u4E0D\u8DB3\uFF0C\u7EE7\u7EED\u68C0\u67E5\u5176\u4ED6\u6052\u661F\u4E0E\u4E2D\u8F6C\u661F"};let Jt;if(Zt)Jt={sourceId:h.planetId,targetId:h.planetId,count:Te,travelMs:0,expectedLevel:1,kind:"upgrade",campaignKind:this.kind,campaignTargetId:y.target,garrison:S.probeCount,reason:`\u524D\u7EBF\u5347\u7EA7\u540E\u9884\u8BA1 ${Math.ceil(O.upgradeMs/6e4)} \u5206\u949F\u5360\u9886\uFF0C\u76F4\u63A5\u6512\u5175/\u8865\u7ED9\u7EA6 ${Math.ceil(O.readyMs/6e4)} \u5206\u949F`};else if(ee<=0&&Ct.length){let[R,...L]=Ct.slice(0,Ev);Jt={...R,support:L,targetId:h.planetId,kind:this.kind==="sun"?"sun-supply":"expansion-supply",campaignKind:this.kind,campaignTargetId:y.target,sunId:this.kind==="sun"?y.target:void 0,hubBudget:Math.min(r,b),garrison:S.probeCount,reason:`${O.phase}\uFF1A${Ct.length} \u9897\u6765\u6E90\uFF0C\u5B9E\u9645\u5230\u8D26\u540E\u51FA\u51FB`};for(let Z of G(Jt))W.set(Z.sourceId,Z.count)}return{job:Jt,reservations:W,hub:h.planetId,sun:this.kind==="sun"?y.target:void 0,state:O,waiting:`${this.kind==="sun"?"\u6052\u661F":"\u524D\u7EBF"} #${y.target}\uFF1A${O.phase}\uFF1B\u4E2D\u8F6C #${h.planetId} \u53EF\u7528 ${r}/${b}\uFF0C\u5728\u9014 ${O.incoming}`}}validSupply(e,n,i){let a=n.owned.find(o=>o.planetId===e.targetId),l=e.campaignTargetId??e.sunId,s=l===void 0?void 0:this.kind==="sun"?n.suns?.find(o=>o.sunId===l):n.planets.find(o=>o.planetId===l);return!!a&&!!s&&(!e.campaignKind||!!this.campaign&&this.campaign.hub===a.planetId&&this.campaign.target===l)&&this.validHub(a,n,i)&&this.validTarget(s,l,n,i)&&s.probeCount===e.garrison&&tt(a,s)<=i.settings.radius}validUpgrade(e,n,i,a){let l=n.owned.find(o=>o.planetId===e.sourceId),s=n.planets.find(o=>o.planetId===e.campaignTargetId);return!l||!s||n.autoUpgrading?.has(l.planetId)||l.level!==1||a=this.state.readyMs?!1:a===this.state.available&&!n.planets.some(o=>we(o,n)&&tt(o,l)<=i.policy.threatRadius)}launched(e,n){if(this.campaign)if(e.kind==="sun-supply"||e.kind==="expansion-supply")for(let i of G(e)){this.campaign.deliveries.push({source:i.sourceId,sent:i.count,count:Wt(i.count,i.lossPct??0),at:Date.now()+i.travelMs,expires:Date.now()+i.travelMs+3e4});let a=n?.owned.find(l=>l.planetId===i.sourceId);a&&this.campaign.attempted.set(i.sourceId,this.stamp(a,n.budgets.get(i.sourceId)??0))}else e.kind==="upgrade"?this.campaign.upgraded=e.expectedLevel:e.targetId===this.campaign.target&&(e.targetKind??"planet")===this.kind&&(this.campaign=void 0)}};var Bi=class t{offset=0;cursors=new Map;reports=new Map;fork(){let e=new t;return e.offset=this.offset,e.cursors=new Map(this.cursors),e.reports=new Map(this.reports),e}*steps(e,n,i,a,l,s){let o=[],u=new Map(a),d=[...n.meteorites??[]].sort((h,S)=>Number(h.expiresAt.toMillis())-Number(S.expiresAt.toMillis())),c=new Set(d.map(h=>h.meteoriteId));for(let h of this.cursors.keys())c.has(h)||this.cursors.delete(h);for(let h of this.reports.keys())c.has(h)||this.reports.delete(h);if(!i.settings.captureMeteorites)return{jobs:o,reports:[]};let v=new zt(n.owned.filter(h=>Q(h,i.policy.zone))),f=Un(n,i),m=(h,S)=>{this.reports.delete(h),this.reports.set(h,{targetId:h,reason:S}),this.reports.size>128&&this.reports.delete(this.reports.keys().next().value)},y=this.offset%Math.max(1,d.length);for(let h=0;hm(p,H);if(!e.quoteBody||!e.launchBody){g("\u539F\u751F\u9668\u77F3\u62A5\u4EF7 / \u53D1\u5C04\u63A5\u53E3\u4E0D\u53EF\u7528");continue}if(S.ownerId!=null){g("\u5DF2\u6709\u4EBA\u5360\u9886");continue}if(!Q(S,i.policy.zone)){g("\u76EE\u6807\u4E0D\u5728\u56FA\u5B9A\u6218\u533A\u5185");continue}if(l.has(At(p,"comet"))||vn(n,p,"comet").length){g("\u5DF2\u6709\u8230\u961F\u5728\u9014\u6216\u4EFB\u52A1\u6392\u961F\uFF0C\u907F\u514D\u91CD\u590D\u53D1\u5C04");continue}if(!Number.isFinite(r)||r<=Date.now()+5e3){g("\u5DF2\u5230\u671F\u6216\u5269\u4F59\u5BFF\u547D\u4E0D\u8DB3 5 \u79D2");continue}if(i.settings.cautiousExpansion&&f(S)==="exposed"){g("\u7A33\u5065\u6269\u5F20\u6682\u7F13\u66B4\u9732\u76EE\u6807");continue}let b=v.near(S,i.settings.radius);if(!b.length){g("\u641C\u7D22\u8DDD\u79BB / \u6218\u533A\u5185\u6CA1\u6709\u5DF1\u65B9\u6765\u6E90");continue}let x=te(b.filter(H=>(u.get(H.planetId)??0)>0),b.length,H=>tt(H,S));if(!x.length){g("\u9644\u8FD1\u5175\u529B\u5DF2\u7528\u4E8E\u7559\u5B88\u3001\u8FDB\u653B\u3001\u8865\u7ED9\u6216\u6392\u961F\u4EFB\u52A1");continue}let T=(this.cursors.get(p)??0)%x.length,w=[...new Set([0,...Array.from({length:4},(H,z)=>(T+z)%x.length)])].slice(0,4),A=new Map;for(let H of w){yield;let z=x[H],E=z.planetId;this.cursors.set(p,(H+1)%x.length);let _=e.quoteBody(E,p,"comet"),M;if(_?!Number.isSafeInteger(_.count)||_.count<=0||_.count>4294967295||!Number.isFinite(_.travelMs)||_.travelMs<0?M="\u539F\u751F\u62A5\u4EF7\u6570\u91CF\u6216\u822A\u7A0B\u65E0\u6548":_.count>(u.get(E)??0)?M=`\u53EF\u7528\u5175\u529B\u4E0D\u8DB3\uFF1A\u9700 ${_.count}\uFF0C\u53EF\u7528 ${u.get(E)??0}`:_.travelMs>i.settings.maxTravelMs?M=`\u822A\u884C ${Math.ceil(_.travelMs/1e3)} \u79D2\uFF0C\u8D85\u8FC7\u6700\u957F\u822A\u884C\u8BBE\u7F6E`:Date.now()+s+o.length*i.settings.intervalMs+_.travelMs+5e3>=r&&(M="\u8BA1\u5165\u73B0\u6709\u6392\u961F\u3001\u822A\u7A0B\u53CA 5 \u79D2\u4F59\u91CF\u540E\u65E0\u6CD5\u5728\u6D88\u5931\u524D\u62B5\u8FBE"):M=e.bodyQuoteIssue?.(E,p,"comet")??"\u539F\u751F\u62A5\u4EF7\u4E0D\u53EF\u884C\uFF0C\u672A\u63D0\u4F9B\u5177\u4F53\u539F\u56E0",M){A.set(M,(A.get(M)??0)+1);continue}if(_){o.push({..._,sourceId:E,targetId:p,targetKind:"comet",expiresAt:r,garrison:S.probeCount,reason:"\u9668\u77F3\u5FEB\u901F\u68C0\u67E5\uFF1A\u9644\u8FD1\u53EF\u51FA\u5175\uFF0C\u4E0D\u7B49\u5F85\u5168\u5C40\u89C4\u5212"}),u.set(E,u.get(E)-_.count),m(p,`\u5DF2\u627E\u5230\u53EF\u884C\u6765\u6E90 #${E}\uFF1A\u9700 ${_.count}\uFF0C\u822A\u884C ${Math.ceil(_.travelMs/1e3)} \u79D2`);break}}o.some(H=>H.targetId===p)||m(p,`${[...A].map(([H,z])=>`${H}\uFF08${z} \u6761\uFF09`).join("\uFF1B")}\uFF1B\u672C\u6B21\u68C0\u67E5 ${w.length}/${x.length} \u6765\u6E90\uFF0C\u5176\u4F59\u7EED\u67E5`)}return{jobs:o,reports:[...this.reports.values()].slice(-6).reverse()}}};var Sd=()=>({activity:"idle",ownedCount:0,candidateCount:0,lastScanAt:null,nextScanAt:null,running:!1,phase:"\u5C1A\u672A\u542F\u52A8",queue:[],flights:0,sent:0,captured:0,missed:0,exact:!1}),$e=["expansion","attack"],yn=(t,e)=>[(e.targetKind??"planet")==="planet"&&t.incoming.has(e.targetId),...vn(t,e.targetId,e.targetKind).map(n=>[n.id,n.owner,n.count,n.arriving,n.arrival].join(":")).sort()].join("|"),er=class{constructor(e,n){this.update=e;this.createWorld=n}update;createWorld;states={expansion:Sd(),attack:Sd()};configs={};world;working=!1;run;revision=0;nextScan=0;scanPlans=new Set;expansionFleets=new Map;nextPlan={expansion:0,attack:0};tasks=new Map;cancellations=new Map;wake;pendingSources=new Set;inventoryRevision=0;pendingTargets=new Set;attackReservations=new Map;coveredRevision=-1;scanning=!1;scanTask;planningTask;frontierTask;frontierCancel;frontier=new Ju;frontierQuotes=new wl;nextFrontier=0;meteoriteTask;meteoriteCancel;meteoritePlanner=new Bi;meteoriteQuotes=new wl;nextMeteorite=0;planningCancel;planner=new Zu;planningQuotes=new wl;expansionQuoteVersion;planningMs=0;failure;reconnectAt=null;identity;flights=new Map;debits=new Map;expansionStock=new Map;expansionPending=new Map;expansionObservers=new Set;inventoryDirty=new Set;inventoryRecovery;nextInventoryRetry=0;expansionDelay=0;lastExpansionSupply=!1;saving;savingCooldown=0;offensive=new Fu;logistics=["sun","sun","sun","planet"].map(e=>({planner:new tr(e),reserves:new Map}));resetLogistics(){for(let e of this.logistics)e.planner.reset(),e.reserves.clear();this.states.expansion.suns=[],this.states.expansion.logistics=[]}logisticsTask;logisticsCancel;logisticsRevision=0;nextLogistics=0;logisticsReservations=new Map;upgrades=new Gu;journal=new Ds;supplies=[];planetPlan(e,n){if(!this.active)return["\u81EA\u52A8\u6269\u5F20\u548C\u8FDB\u653B\u5747\u672A\u8FD0\u884C"];if(!this.world||this.reconnectAt!==null||this.identity!==e.identity||this.world.matchesSession?.(e)===!1)return["\u7B49\u5F85\u5F53\u524D\u6E38\u620F\u8FDE\u63A5\u7684\u89C4\u5212"];let i=$e.flatMap(a=>{if(!this.configs[a])return[];let l=Array.from(this.flights.values()).filter(s=>s.mode===a&&s.identity===e.identity).map(s=>s.job);return pv(n,a,this.states[a],l)});return i.length?i:["\u5F53\u524D\u6CA1\u6709\u9488\u5BF9\u672C\u661F\u7684\u4EFB\u52A1"]}emit(e,n,i){let a=this.states[e];a.diagnostics=this.world?.diagnostics?.(),n&&(a.phase=n),i&&(a.activity=i),a.work={...a.work,scanning:this.scanning,background:e==="expansion"?this.expansionObservers.size:0,inventory:e==="expansion"?this.inventoryDirty.size:0},this.update(e,{...a,work:{...a.work},queue:[...a.queue]})}interruptWaiting(){this.scanPlans.clear(),this.planningCancel?.abort(),this.meteoriteCancel?.abort(),this.frontierCancel?.abort(),this.logisticsCancel?.abort();for(let e of this.cancellations.values())e.abort();this.wake?.()}wait(e){return new Promise(n=>{let i=()=>{clearTimeout(a),this.wake===i&&(this.wake=void 0),n()},a=setTimeout(i,e);this.wake=i})}get active(){return $e.some(e=>!!this.configs[e])}activeConfigs(){return $e.flatMap(e=>this.configs[e]?[this.configs[e]]:[])}start(e,n){return this.states[e].running||this.working&&!this.active?this.run??Promise.resolve():(e==="attack"&&(n={...n,settings:{...n.settings,peacefulDevelopment:0,intervalMs:1e3,captureSuns:0,captureMeteorites:0,upgradeStable:0}}),Ns(n.settings),Ou(n.policy,e),e==="expansion"&&n.settings.peacefulDevelopment&&(n={...n,settings:{...n.settings,captureSuns:0,captureMeteorites:1,cautiousExpansion:1}}),e==="attack"?this.offensive.reset():(this.resetLogistics(),this.nextLogistics=0,this.frontier.reset(),this.frontierQuotes.clear(),this.meteoritePlanner=new Bi,this.meteoriteQuotes.clear(),this.nextMeteorite=0,this.nextFrontier=0,this.expansionDelay=0,this.upgrades.reset(),this.journal=new Ds,this.planningQuotes.clear()),this.configs[e]=structuredClone(n),this.states[e]={...Sd(),running:!0},this.revision++,this.nextScan=0,this.nextPlan={expansion:0,attack:0},this.interruptWaiting(),this.emit(e,"\u6B63\u5728\u83B7\u53D6\u64CD\u4F5C\u6743\u2026","starting"),this.working||(this.failure=void 0,this.working=!0,this.run=this.loop()),this.run)}stop(e){for(let n of e?[e]:$e)delete this.configs[n],this.states[n].queue=[],n==="expansion"&&(this.planner.dispose(),this.resetLogistics(),this.nextLogistics=0,this.frontier.reset(),this.frontierQuotes.clear(),this.meteoritePlanner=new Bi,this.meteoriteQuotes.clear(),this.nextMeteorite=0,this.logisticsReservations.clear(),this.upgrades.reset(),this.planningQuotes.clear()),n==="attack"&&(this.attackReservations.clear(),this.saving=void 0,this.savingCooldown=0,this.offensive.reset(),this.states.attack.rally=void 0,this.states.attack.rallies=void 0),this.states[n].running&&this.emit(n,"\u6B63\u5728\u505C\u6B62\uFF1B\u5DF2\u53D1\u5C04\u8230\u961F\u4ECD\u7EE7\u7EED\u822A\u884C","stopping");this.revision++,this.nextScan=0,this.nextPlan={expansion:0,attack:0},this.interruptWaiting()}finishStopped(){for(let e of $e)!this.configs[e]&&!this.tasks.has(e)&&!this.failure&&this.states[e].running&&(this.states[e].running=!1,this.states[e].nextScanAt=null,this.states[e].work=void 0,this.emit(e,"\u5DF2\u505C\u6B62\uFF1B\u672A\u53D1\u5C04\u4EFB\u52A1\u5DF2\u53D6\u6D88\uFF0C\u5DF2\u53D1\u5C04\u8230\u961F\u4ECD\u7EE7\u7EED\u822A\u884C","stopped"))}fail(e){if(!(this.failure||!this.active&&!Hn())){this.failure=e instanceof Error?e:new Error(String(e)),this.configs={},this.attackReservations.clear(),this.revision++,this.interruptWaiting();for(let n of $e)this.states[n].running&&this.emit(n,this.failure.message,"error")}}recover(e){if(!this.configs.expansion||Hn()){this.fail(e);return}this.reconnectAt===null&&(this.configs.attack&&this.stop("attack"),this.revision++,this.nextScan=0,this.scanPlans.clear(),this.interruptWaiting(),this.states.expansion.queue=[],this.states.expansion.planning=void 0,this.states.expansion.nextScanAt=null,this.planner.dispose(),this.logisticsReservations.clear(),this.upgrades.reset(),this.planningQuotes.clear(),this.resetLogistics(),this.nextLogistics=0,this.frontier.reset(),this.frontierQuotes.clear(),this.meteoritePlanner=new Bi,this.meteoriteQuotes.clear(),this.nextMeteorite=0,this.reconnectAt=Date.now()+5e3,this.emit("expansion",`\u8FDE\u63A5\u6216\u60C5\u62A5\u6682\u4E0D\u53EF\u7528\uFF0C5 \u79D2\u540E\u81EA\u52A8\u5C1D\u8BD5\u6062\u590D\uFF1A${e instanceof Error?e.message:String(e)}`,"paused"))}async loop(){try{await hv(async()=>{try{if(!this.active)return;for(;this.active;){try{if(this.reconnectAt!==null){if(Date.now()n.has(l.planetId)):e.owned},this.activeConfigs(),this.debits);for(let l of this.pendingSources)a.set(l,0);return a}reconcile(e,n=!0){if(n)for(let a of this.debits.keys())this.pendingSources.has(a)||this.debits.delete(a);if(n&&!this.world?.syncInventory)for(let a of this.inventoryDirty)this.expansionPending.has(a)||(this.expansionStock.delete(a),this.inventoryDirty.delete(a));this.supplies=this.supplies.filter(a=>a.deliveries.some(l=>Date.now()a.planetId));for(let[a,l]of this.flights){let s=this.states[l.mode],o=l.job;(!o.targetKind||o.targetKind==="planet"?i.has(o.targetId):!!e.identity&&un(e,o.targetId,o.targetKind)?.ownerId?.toHexString()===e.identity)?(s.captured++,this.flights.delete(a),this.inventoryRevision++,l.mode==="expansion"&&this.journal.captured(o,e),l.mode==="attack"&&this.configs.attack&&this.offensive.captured(o.targetId,this.configs.attack),this.configs[l.mode]&&this.emit(l.mode,`\u5DF2\u786E\u8BA4\u5360\u9886${De(o)}`,"captured")):Date.now()>=l.due+5e3&&!vn(e,o.targetId,o.targetKind).length&&(o.targetKind&&o.targetKind!=="planet"||!e.incoming.has(o.targetId))&&(s.missed++,this.flights.delete(a),this.inventoryRevision++,this.configs[l.mode]&&this.emit(l.mode,`\u8230\u961F\u5DF2\u7ED3\u675F\u822A\u884C\uFF0C\u672A\u786E\u8BA4\u5360\u9886${De(o)}\uFF1B\u91CD\u65B0\u8BC4\u4F30`,"waiting"))}this.journal.observe(e),this.states.expansion.metrics=this.journal.snapshot(),this.configs.expansion&&this.upgrades.observe(e,this.configs.expansion)}pendingSupply(e){let n=this.supplies.filter(i=>i.hub===e).flatMap(i=>i.deliveries).filter(i=>i.arrival>Date.now());return{count:n.reduce((i,a)=>i+a.count,0),arrival:Math.max(Date.now(),...n.map(i=>i.arrival))}}flightCount(e){return[...this.flights.values()].filter(n=>n.mode===e).length+(e==="attack"?this.supplies.length:this.logistics.filter(n=>n.planner.kind==="sun"&&n.planner.gathering).length)}planned(e){if(!(!this.scanPlans.delete(e)||this.scanPlans.size)){this.nextScan=Date.now()+Math.min(...this.activeConfigs().map(n=>n.settings.scanMs));for(let n of $e)this.configs[n]&&(this.states[n].nextScanAt=this.nextScan,this.emit(n))}}async scan(e,n=!1){let i=this.revision,a=this.activeConfigs(),l={...a[0].settings,radius:Math.max(...a.map(o=>o.settings.radius))};if(!n){this.nextScan=1/0,this.scanPlans.clear();for(let o of $e)this.configs[o]&&(this.states[o].nextScanAt=null)}e.configure?.(a),this.scanning=!0;for(let o of $e)this.configs[o]&&this.emit(o,n?"\u6B63\u5728\u8865\u5145\u65B0\u6765\u6E90\u8986\u76D6\uFF0C\u5F53\u524D\u89C4\u5212\u4E0E\u961F\u5217\u7EE7\u7EED\u2026":"\u6B63\u5728\u626B\u63CF\u5185\u5B58\u60C5\u62A5\u4E0E\u6218\u533A\u8986\u76D6\uFF0C\u5DF2\u6709\u961F\u5217\u7EE7\u7EED\u6267\u884C\u2026","scanning");try{await e.scan(l,()=>this.active&&i===this.revision&&this.reconnectAt===null)}finally{this.scanning=!1}if(!this.active||i!==this.revision)return;this.coveredRevision=i;let s=e.read();if(this.identity!==void 0&&s.identity!==this.identity){this.fail(new Error("\u6E38\u620F\u8EAB\u4EFD\u5DF2\u53D8\u5316\uFF0C\u5DF2\u505C\u6B62\uFF1B\u8BF7\u91CD\u65B0\u624B\u52A8\u542F\u52A8\u3002"));return}if(this.identity??=s.identity,this.reconcile(s),this.configs.attack&&this.states.attack.lastScanAt===null){let o=$u(s,this.configs.attack);if(o){let u=this.states.attack;u.ownedCount=s.owned.filter(d=>Q(d,this.configs.attack.policy.zone)).length,u.lastScanAt=Date.now(),u.nextScanAt=null,u.running=!1,delete this.configs.attack,this.attackReservations.clear(),this.offensive.reset(),this.revision++,this.nextScan=0,this.interruptWaiting(),this.emit("attack",o,"error");return}}n||(this.scanPlans=new Set($e.filter(o=>this.configs[o]&&(o==="expansion"||document.visibilityState!=="hidden"))));for(let o of $e)if(this.configs[o]){let u=this.states[o];u.lastScanAt=Date.now(),n||(u.nextScanAt=null),u.ownedCount=s.owned.filter(d=>Q(d,this.configs[o].policy.zone)).length,this.emit(o,n?`\u8865\u5145\u8986\u76D6\u5B8C\u6210\uFF1A\u6218\u533A\u5185 ${u.ownedCount} \u9897\u5DF1\u65B9\u661F\u7403\uFF1B\u5F53\u524D\u89C4\u5212\u4E0E\u626B\u63CF\u8BA1\u65F6\u4FDD\u7559`:`\u626B\u63CF\u5B8C\u6210\uFF1A\u6218\u533A\u5185 ${u.ownedCount} \u9897\u5DF1\u65B9\u661F\u7403\uFF0C\u5F00\u59CB\u8BC4\u4F30\u76EE\u6807`,"scanning")}this.nextPlan={expansion:0,attack:0}}async tick(){let e=this.world;this.retryInventory(e),document.visibilityState==="hidden"&&this.planned("attack");let n=!this.scanTask&&e.needsScan?.();if(!this.scanTask&&(n||!this.planningTask&&!this.scanPlans.size&&Date.now()>=this.nextScan)){let i=this.revision,a=!!n&&this.coveredRevision===i&&(!!this.planningTask||!!this.scanPlans.size||Date.now(){this.active&&i===this.revision&&this.recover(l)}).finally(()=>{this.scanTask=void 0,this.wake?.()})}if(!(this.coveredRevision!==this.revision&&(await this.scanTask,this.coveredRevision!==this.revision))&&this.active)for(let i of["attack","expansion"]){let a=this.configs[i];if(!a||i==="attack"&&(document.visibilityState==="hidden"||this.tasks.has(i)||Date.now()=this.nextMeteorite&&a.settings.captureMeteorites){let h=new AbortController;this.meteoriteCancel=h,this.nextMeteorite=Date.now()+1e3,this.meteoriteTask=this.updateMeteorites(a,h.signal).catch(S=>this.recover(S)).finally(()=>{this.meteoriteTask=void 0,this.meteoriteCancel=void 0,this.wake?.()})}if(!a.settings.peacefulDevelopment&&!this.logisticsTask&&Date.now()>=this.nextLogistics){let h=new AbortController;this.logisticsCancel=h,this.nextLogistics=Date.now()+1e3,this.logisticsTask=this.updateLogistics(a,h.signal).catch(S=>this.recover(S)).finally(()=>{this.logisticsTask=void 0,this.logisticsCancel=void 0,this.wake?.()})}if(!a.settings.peacefulDevelopment&&!this.frontierTask&&Date.now()>=this.nextFrontier){let h=new AbortController;this.frontierCancel=h,this.nextFrontier=Date.now()+1e3,this.frontierTask=this.updateFrontier(a,h.signal).catch(S=>this.recover(S)).finally(()=>{this.frontierTask=void 0,this.frontierCancel=void 0,this.states.expansion.work={...this.states.expansion.work,frontier:void 0},this.emit("expansion"),this.wake?.()})}let o=Math.max(3,Math.min(20,Math.ceil(this.planningMs/a.settings.intervalMs)+3));if(!this.scanTask&&!this.planningTask&&Date.now()>=this.nextPlan.expansion&&(this.scanPlans.has(i)||this.states.expansion.queue.length<=o)){let h=new AbortController;this.planningCancel=h,this.planningTask=this.runLane(i,a,h.signal).catch(S=>this.recover(S)).finally(()=>{this.planningTask=void 0,this.planningCancel=void 0,this.states.expansion.work={...this.states.expansion.work,plan:void 0},this.emit("expansion"),this.wake?.()})}let u=this.states.expansion.queue.find(h=>h.kind==="sun-supply"||h.kind==="expansion-supply"),d=this.states.expansion.queue.find(h=>!h.kind),c=this.lastExpansionSupply&&d?d:u??this.states.expansion.queue[0];if(!c||this.tasks.has(i))continue;let v=new AbortController,f=this.revision;this.cancellations.set(i,v);let m=()=>!v.signal.aborted&&this.configs.expansion===a&&f===this.revision&&!this.failure&&this.reconnectAt===null,y=this.executeJob(i,a,v.signal,m,c).catch(h=>this.recover(h)).finally(()=>{this.tasks.delete(i),this.cancellations.delete(i),this.wake?.()});this.tasks.set(i,y);continue}let l=new AbortController;this.cancellations.set(i,l);let s=this.runLane(i,a,l.signal).catch(o=>this.fail(o)).finally(()=>{this.tasks.delete(i),this.cancellations.delete(i),this.states[i].work={...this.states[i].work,plan:void 0,dispatch:void 0},this.emit(i),this.finishStopped(),(!this.active||!this.configs[i])&&this.wake?.()});this.tasks.set(i,s)}}campaignPlanner(e){return this.logistics[e.campaignSlot].planner}fastBudgets(e){let n=this.budgets(e);for(let i of[this.attackReservations,this.logisticsReservations])for(let[a,l]of i)n.set(a,Math.max(0,(n.get(a)??0)-l));for(let i of this.states.expansion.queue)if(i.kind!=="upgrade"&&!i.campaignKind)for(let a of G(i))n.set(a.sourceId,Math.max(0,(n.get(a.sourceId)??0)-a.count));return n}async updateMeteorites(e,n){let i=this.world,a=this.revision,l=()=>!n.aborted&&a===this.revision&&this.configs.expansion===e&&!this.failure&&this.reconnectAt===null,s=i.read();if(s.identity!==this.identity){this.fail(new Error("\u6E38\u620F\u8EAB\u4EFD\u5DF2\u53D8\u5316\uFF0C\u5DF2\u505C\u6B62"));return}if(!s.meteorites?.length){this.states.expansion.meteorites=[];return}this.retainCurrentRules(s);let o=Math.floor(e.settings.horizonMs/e.settings.intervalMs)+1,u=this.states.expansion.queue.filter(p=>p.kind!=="upgrade").length;if(u>=o){this.states.expansion.meteorites=s.meteorites.slice(0,6).map(p=>({targetId:p.meteoriteId,reason:"\u89C4\u5212\u961F\u5217\u7A97\u53E3\u5DF2\u6EE1\uFF0C\u7B49\u5F85\u91CA\u653E\u4F4D\u7F6E\u540E\u590D\u67E5"}));return}let d=new Set([...this.flights.keys(),...this.pendingTargets,...this.states.expansion.queue.map(st)]),c=this.meteoritePlanner.fork(),v=await Hi(c.steps(this.meteoriteQuotes.begin(i,s),s,e,this.fastBudgets(s),d,(u+Number(this.tasks.has("expansion")))*e.settings.intervalMs),l,()=>i.refreshQuotes?.(),Yu);if(!v||!l())return;if(this.meteoritePlanner=c,this.states.expansion.meteorites=v.reports,!v.jobs.length){this.emit("expansion");return}let f=i.read();if(f.identity!==s.identity)return;let m=this.fastBudgets(f),y=[],h=new Set([...this.flights.keys(),...this.pendingTargets,...this.states.expansion.queue.map(st)]),S=this.states.expansion.queue.filter(p=>p.kind!=="upgrade").length;for(let p of v.jobs){let r;if(ha(s,f,p)?h.has(st(p))?r="\u5DF2\u6709\u8230\u961F\u5728\u9014\u6216\u4EFB\u52A1\u6392\u961F":vd(p,f,e)?!f.owned.some(g=>g.planetId===p.sourceId)||p.count>(m.get(p.sourceId)??0)?r="\u6765\u6E90\u5F52\u5C5E\u6216\u5171\u4EAB\u53EF\u7528\u5175\u529B\u5DF2\u53D8\u5316":S+y.length>=o?r="\u89C4\u5212\u961F\u5217\u7A97\u53E3\u5DF2\u6EE1":Date.now()+(S+y.length+Number(this.tasks.has("expansion")))*e.settings.intervalMs+p.travelMs+5e3>=p.expiresAt&&(r="\u5F53\u524D\u6392\u961F\u548C\u822A\u7A0B\u5DF2\u65E0\u6CD5\u8D76\u5728\u6D88\u5931\u524D\u62B5\u8FBE"):r=Lu(p,f,e):r="\u6765\u6E90\u62A5\u4EF7\u89C4\u5219\u5DF2\u53D8\u5316\uFF0C\u7B49\u5F85\u91CD\u65B0\u68C0\u67E5",r){this.states.expansion.meteorites=[{targetId:p.targetId,reason:r},...(this.states.expansion.meteorites??[]).filter(g=>g.targetId!==p.targetId)].slice(0,6);continue}p.quoteRules=Ui(f,p),m.set(p.sourceId,m.get(p.sourceId)-p.count),y.push(p),h.add(st(p)),this.expansionFleets.set(st(p),yn(f,p))}y.length?(this.states.expansion.queue=[...this.states.expansion.queue.filter(p=>p.kind!=="upgrade"||p.campaignKind),...y],this.expansionQuoteVersion=f.quoteVersion,this.emit("expansion",`\u9668\u77F3\u5FEB\u901F\u89C4\u5212\uFF1A\u8865\u5165 ${y.length} \u9879\uFF0C\u4E0D\u7B49\u5F85\u5168\u5C40\u89C4\u5212`,"queued")):this.emit("expansion")}rulesCurrent(e,n){return e.quoteRules!==void 0?e.quoteRules===Ui(n,e):this.expansionQuoteVersion===n.quoteVersion}retainCurrentRules(e){let n=this.states.expansion.queue;this.states.expansion.queue=n.filter(a=>this.rulesCurrent(a,e));let i=n.length-this.states.expansion.queue.length;i&&(this.nextLogistics=0,this.nextPlan.expansion=0,this.emit("expansion",`\u6765\u6E90\u62A5\u4EF7\u89C4\u5219\u53D8\u5316\uFF1A\u91CA\u653E ${i} \u9879\u53D7\u5F71\u54CD\u4EFB\u52A1\uFF1B\u5176\u4F59\u961F\u5217\u4E0E\u89C4\u5212\u7EE7\u7EED`,"waiting"))}async updateLogistics(e,n){let i=this.world,a=this.revision,l=this.logisticsRevision,s=()=>!n.aborted&&a===this.revision&&l===this.logisticsRevision&&this.configs.expansion===e&&!this.failure&&this.reconnectAt===null,o=performance.now(),u=i.read();if(u.identity!==this.identity){this.fail(new Error("\u6E38\u620F\u8EAB\u4EFD\u5DF2\u53D8\u5316\uFF0C\u5DF2\u505C\u6B62"));return}if(!u.intelligence)return;let d=M=>{let I=this.budgets(M);for(let[B,N]of this.attackReservations)I.set(B,Math.max(0,(I.get(B)??0)-N));for(let B of this.states.expansion.queue)if(!B.campaignKind&&B.kind!=="upgrade")for(let N of G(B))I.set(N.sourceId,Math.max(0,(I.get(N.sourceId)??0)-N.count));return I},c=Math.floor(e.settings.horizonMs/e.settings.intervalMs)+1;if(this.states.expansion.queue.filter(M=>M.kind!=="upgrade").length>=c)return;let v=new Set,f=d(u),m=this.logistics.map(M=>M.planner.fork()),y=new Map,h=new Set([...this.flights.keys(),...this.pendingTargets,...this.states.expansion.queue.filter(M=>!M.campaignKind).map(st)]),S=m.map((M,I)=>this.states.expansion.queue.filter(B=>B.campaignSlot===I)),p=M=>u.suns?.some(I=>I.ownerId==null&&Q(I,e.policy.zone)&&!M.has(At(I.sunId,"sun"))),r=M=>S[M].length?0:m[M].gathering?1:2,g=m.map((M,I)=>I).sort((M,I)=>r(M)-r(I)),b={routes:Wu,pairs:bd},x=!1;for(let M of g){let I=m[M],B=I.kind,N=S[M].filter(U=>{let P=un(u,U.targetId,U.targetKind),nt=U.kind==="sun-supply"||U.kind==="expansion-supply"?I.validSupply(U,u,e):U.kind==="upgrade"?I.validUpgrade(U,u,e,f.get(U.sourceId)??0):!!P&&P.ownerId==null&&P.probeCount===U.garrison&&!vn(u,U.targetId,U.targetKind).length;return!this.rulesCurrent(U,u)||!nt||G(U).some(Ct=>Ct.count>(f.get(Ct.sourceId)??0))||(U.hubBudget??0)>(f.get(U.targetId)??0)?(v.add(U),!1):!0}),q=new Set,et=new Set(h);for(let U of m)U!==I&&(U.hub!==void 0&&q.add(U.hub),U.target!==void 0&&et.add(At(U.target,U.kind)));let J;if(N.length)J={reservations:new Map([...this.logistics[M].reserves].map(([P,nt])=>[P,Math.min(nt,f.get(P)??0)])),hub:I.hub,sun:B==="sun"?I.target:void 0,state:this.states.expansion.logistics?.find(P=>P.kind===B&&P.target===I.target)};else if(B==="sun"&&!I.gathering&&(x||!p(et)))J={reservations:new Map};else{let U=g.slice(g.indexOf(M)+1).filter(nt=>m[nt].kind==="sun"&&m[nt].gathering&&!S[nt].length).length,P=B==="sun"?{routes:Math.floor(b.routes/(1+U)),pairs:b.pairs}:void 0;J=await Hi(I.steps(i,{...u,owned:u.owned.filter(nt=>!q.has(nt.planetId))},e,f,et,nt=>({percent:Math.max(0,...this.activeConfigs().filter(Ct=>Q(nt,Ct.policy.zone)&&u.planets.some(Lt=>we(Lt,u)&&tt(Lt,nt)<=Ct.policy.threatRadius)).map(Ct=>Ct.policy.frontlinePercent)),deficit:Math.max(0,Qu(nt,u,this.activeConfigs())-(u.budgets.get(nt.planetId)??0))}),P),s,()=>i.refreshQuotes?.(),Yu),B==="sun"&&(b.routes-=I.stats.routes,b.pairs-=I.stats.checkedPairs,!I.gathering&&I.stats.checkedPairs&&(x=!0))}if(!J||!s())return;y.set(M,J);for(let[U,P]of J.reservations)f.set(U,Math.max(0,(f.get(U)??0)-P))}let T=i.read();if(!s()||u.identity!==T.identity)return;for(let[M,I]of y){let B=m[M].target;if(B!==void 0){let N=At(B,m[M].kind);if(this.flights.has(N)||this.pendingTargets.has(N)||this.states.expansion.queue.some(q=>!q.campaignKind&&st(q)===N))return}if(I.job&&!ha(u,T,I.job)||I.hub!==void 0&&!ha(u,T,{sourceId:I.hub,targetId:I.hub,count:0,travelMs:0}))return}let w=d(T),A=[],H=Math.max(0,c-this.states.expansion.queue.filter(M=>!v.has(M)&&(M.kind!=="upgrade"||M.campaignKind)).length);for(let[M,I]of y){let B=I.job;if(B&&H<=0&&(I.job=B=void 0,I.reservations=new Map([...I.reservations].filter(([N])=>N===I.hub))),B){if(this.states.expansion.queue.some(N=>!v.has(N)&&st(N)===st(B))||this.flights.has(st(B))||this.pendingTargets.has(st(B)))return;if(B.kind==="sun-supply"||B.kind==="expansion-supply"){if(!m[M].validSupply(B,T,e))return}else if(B.kind==="upgrade"){if(!m[M].validUpgrade(B,T,e,w.get(B.sourceId)??0))return}else if(Dt(un(u,B.targetId,B.targetKind))!==Dt(un(T,B.targetId,B.targetKind))||yn(u,B)!==yn(T,B))return}for(let[N,q]of I.reservations){if(q>(w.get(N)??0))return;w.set(N,w.get(N)-q)}B&&(B.campaignSlot=M,B.quoteRules=Ui(T,B),A.push(B),H--)}this.logistics=m.map((M,I)=>({planner:M,reserves:y.get(I).reservations}));let z=new Map;for(let M of y.values())for(let[I,B]of M.reservations)z.set(I,(z.get(I)??0)+B);this.logisticsReservations=z;for(let M of A)this.expansionFleets.set(st(M),yn(T,M));(A.length||v.size)&&(this.states.expansion.queue=[...A,...this.states.expansion.queue.filter(M=>!v.has(M)&&(M.kind!=="upgrade"||M.campaignKind))],this.expansionQuoteVersion=T.quoteVersion),this.states.expansion.logistics=[...y.values()].flatMap(M=>M.state?[M.state]:[]),this.states.expansion.suns=[...y.values()].flatMap(M=>M.sun===void 0?[]:[{target:M.sun,hub:M.hub,waiting:M.waiting}]);let E=m.reduce((M,I)=>M+I.stats.routes,0),_=m.reduce((M,I)=>M+I.stats.reused,0);this.states.expansion.work={...this.states.expansion.work,logisticsMs:performance.now()-o,logisticsRoutes:E,logisticsReused:_},this.emit("expansion",A.length?`\u540E\u52E4\u8BA1\u5212\u589E\u91CF\u66F4\u65B0\uFF1A\u65B0\u589E ${A.length} \u9879\uFF1B\u539F\u751F\u822A\u8DEF\u65B0\u7B97 ${E} \u6761`:void 0,A.length?"queued":void 0)}async updateFrontier(e,n){let i=this.world,a=this.revision,l=()=>!n.aborted&&this.configs.expansion===e&&a===this.revision&&!this.failure&&this.reconnectAt===null,s=i.read();if(this.identity!==void 0&&s.identity!==this.identity){this.fail(new Error("\u6E38\u620F\u8EAB\u4EFD\u5DF2\u53D8\u5316\uFF0C\u5DF2\u505C\u6B62\uFF1B\u8BF7\u91CD\u65B0\u624B\u52A8\u542F\u52A8\u3002"));return}this.reconcile(s,!1),this.retainCurrentRules(s);let o=r=>{let g=this.budgets(r);for(let b of[this.attackReservations,this.logisticsReservations])for(let[x,T]of b)g.set(x,Math.max(0,(g.get(x)??0)-T));for(let b of this.states.expansion.queue)if(!(b.kind==="upgrade"||b.campaignKind))for(let x of G(b))g.set(x.sourceId,Math.max(0,(g.get(x.sourceId)??0)-x.count));return g},u=()=>new Set([...this.flights.keys(),...this.pendingTargets,...this.states.expansion.queue.map(st)]),d=Os();this.states.expansion.work={...this.states.expansion.work,frontier:Date.now(),frontierTiming:d},this.emit("expansion"),i.refreshQuotes?.();let c=this.frontierQuotes.begin(i,s),v=await Hi(this.frontier.steps(c,s,e,o(s),rd(u()),this.states.expansion.queue.filter(r=>r.kind!=="upgrade").length<3),l,()=>i.refreshQuotes?.(),Yu,8,d);if(!v?.length||!l())return;let f=i.read();if(f.identity!==s.identity)return;let m=o(f),y=u(),h=[],S=new Set(f.owned.map(r=>r.planetId)),p=Math.max(0,Math.floor(e.settings.horizonMs/e.settings.intervalMs)+1-this.states.expansion.queue.filter(r=>r.kind!=="upgrade").length);for(let r of v){if(h.length>=p)break;let g=st(r),b=un(f,r.targetId);if(!(!ha(s,f,r)||y.has(g)||!b||b.ownerId!=null||G(r).some(x=>!S.has(x.sourceId)||x.count>(m.get(x.sourceId)??0))||Dt(b)!==Dt(un(s,r.targetId))||yn(s,r)!==yn(f,r))){for(let x of G(r))m.set(x.sourceId,m.get(x.sourceId)-x.count);r.quoteRules=Ui(f,r),h.push(r),y.add(g),this.expansionFleets.set(g,yn(f,r))}}h.length&&(this.states.expansion.queue=[...this.states.expansion.queue.filter(r=>r.kind!=="upgrade"||r.campaignKind),...h].sort((r,g)=>+(g.kind==="sun-supply"||g.targetKind==="sun")-+(r.kind==="sun-supply"||r.targetKind==="sun")||ot(r)-ot(g)),this.expansionQuoteVersion=s.quoteVersion,this.emit("expansion",`\u524D\u7EBF\u589E\u91CF\u89C4\u5212\uFF1A\u8865\u5165 ${h.length} \u4E2A\u9644\u8FD1\u76EE\u6807\uFF1B\u5DF2\u6709\u8BA1\u5212\u7EE7\u7EED\u6267\u884C`,"queued"))}async runLane(e,n,i){let a=this.world,l=this.revision,s=this.inventoryRevision,o=()=>!i.aborted&&this.configs[e]===n&&!this.failure&&this.reconnectAt===null&&l===this.revision&&(e==="expansion"||document.visibilityState!=="hidden");if(e==="attack"&&!this.scanPlans.has(e)&&this.states.attack.queue.length){await this.executeJob(e,n,i,o,this.states.attack.queue[0]);return}let u=performance.now();e==="expansion"&&(this.planner.resetTiming(),this.states.expansion.work={...this.states.expansion.work,planningTiming:this.planner.timing});let d=T=>{let w=this.states[e].work;this.states[e].work={...w,plan:{startedAt:w?.plan?.startedAt??Date.now(),stage:T}},this.emit(e)};d(e==="attack"?"\u8BC4\u4F30\u76F4\u653B\u4E0E\u96C6\u7ED3":"\u8BFB\u53D6\u5E93\u5B58\u4E0E\u5171\u4EAB\u9884\u7B97");let c=a.read(),v=this.activeConfigs();e==="expansion"&&this.retainCurrentRules(c);let f=this.budgets(c),m=new Set([...this.flights.keys(),...this.pendingTargets]),y=e==="expansion"?[...this.states.expansion.queue]:[];for(let T of y)m.add(st(T));let h=rd(m),S=n.settings.intervalMs,p,r=e==="attack"?n:void 0;if(r){for(let[z,E]of this.logisticsReservations)f.set(z,Math.max(0,(f.get(z)??0)-E));let T=new Map,w=this.offensive.fork(),A=await Hi(w.steps(a,c,r,f,h,z=>this.pendingSupply(z),z=>({percent:Math.max(0,...v.filter(E=>Q(z,E.policy.zone)).map(E=>E.policy.frontlinePercent)),deficit:Math.max(0,Qu(z,c,v)-Math.max(0,(c.budgets.get(z.planetId)??0)-(this.debits.get(z.planetId)??0)))})),()=>o()&&s===this.inventoryRevision,()=>a.refreshQuotes?.());if(!A||!o()||s!==this.inventoryRevision)return;this.offensive=w,p=A.next;for(let[z,E]of A.reservations)T.set(z,E);this.states.attack.rally=A.rallyState,this.states.attack.rallies=A.rallyStates,this.states.attack.attackDiagnostics=A.diagnostics,this.states.attack.candidateCount=A.candidates,this.states.attack.exact=A.exact??!1;let H;if(!p&&!A.rallyState&&A.saving&&Date.now()>=this.savingCooldown){let z=`${A.saving.sourceId}:${A.saving.targetId}`;this.saving??={key:z,until:Date.now()+12e4},Date.now()>=this.saving.until?(this.saving=void 0,this.savingCooldown=Date.now()+6e4):this.saving.key===z&&(H=A.saving,T.set(A.saving.sourceId,A.saving.count))}else(p||!A.saving)&&(this.saving=void 0);(T.size!==this.attackReservations.size||[...T].some(([z,E])=>E!==this.attackReservations.get(z)))&&this.inventoryRevision++,this.attackReservations=T,this.states.attack.saving=H,this.states.attack.queue=A.jobs??[],p||this.emit("attack",H?`\u6B63\u5728\u4E3A #${H.targetId} \u6512\u5175\uFF1A#${H.sourceId} \u9700 ${H.count}\uFF0C\u5F53\u524D\u53EF\u7528 ${f.get(H.sourceId)??0}\uFF1B\u6700\u591A\u9884\u7559 120 \u79D2`:A.waiting,"waiting")}let g=e==="expansion"?n:void 0,b;if(g){let T=o,w=this.planningQuotes.begin(a,c),A=new Map(f);for(let[O,W]of this.attackReservations)A.set(O,Math.max(0,(A.get(O)??0)-W));for(let[O,W]of this.logisticsReservations)A.set(O,Math.max(0,(A.get(O)??0)-W));for(let O of y)if(!O.campaignKind)for(let W of G(O))A.set(W.sourceId,Math.max(0,(A.get(W.sourceId)??0)-W.count));d("\u7B5B\u9009\u9644\u8FD1\u76EE\u6807\u4E0E\u5408\u5175");let H=0,z=await this.planner.proposals(w,c,g,A,h,i,T,(O,W)=>{let Jt=this.states.expansion.work;!Jt?.plan||!T()||(this.states.expansion.work={...Jt,plan:{...Jt.plan,completed:O,total:W}},(Date.now()-H>=250||O===W)&&(H=Date.now(),this.emit("expansion")))});if(!z||!T())return;let E=a.read();if(E.identity!==c.identity)return;let _=z.edges.filter(O=>ha(c,E,O));_.lengthO.kind!=="upgrade").length*S;d("\u5206\u914D\u5175\u529B\u4E0E\u53D1\u5C04\u987A\u5E8F");let I=await this.planner.plan(a,_,A,S,Math.max(0,g.settings.horizonMs-M),g.settings.maxTravelMs,M,i,T);if(!I||!T())return;let B=I.jobs,N=new Set([...this.logisticsReservations.keys(),...this.attackReservations.keys(),...B.flatMap(O=>G(O).map(W=>W.sourceId))]);d("\u68C0\u67E5\u540E\u65B9\u5347\u7EA7");let q=a.upgrade||a.upgradeMany?await Hi(this.upgrades.steps(c,n,A,N),T,void 0,void 0,8,this.planner.timing):[];if(!q||!T())return;s!==this.inventoryRevision&&(q=[]);let et=a.read(),J=this.budgets(et),U=new Set([...this.flights.keys(),...this.pendingTargets]);if(et.identity!==c.identity)return;for(let[O,W]of this.attackReservations)J.set(O,Math.max(0,(J.get(O)??0)-W));let P=[...this.states.expansion.queue.filter(O=>O.campaignKind),...this.states.expansion.queue.filter(O=>!O.campaignKind&&O.kind!=="upgrade"),...B,...this.states.expansion.queue.filter(O=>!O.campaignKind&&O.kind==="upgrade"),...q],nt=O=>!!O.campaignKind,Ct=this.logisticsReservations,Lt=new Map,ee=new Map;for(let O of P.filter(nt))for(let W of G(O))ee.set(W.sourceId,(ee.get(W.sourceId)??0)+W.count);for(let[O,W]of Ct){let Jt=Math.min(Math.max(0,W-(ee.get(O)??0)),J.get(O)??0);Jt>0&&(Lt.set(O,Jt),J.set(O,J.get(O)-Jt))}let Ee=[],_e=new Map,Te=0,ve=0;for(let O of P){if(this.states.expansion.queue.includes(O)?!this.rulesCurrent(O,et):!ha(c,et,O))continue;let Jt=st(O),R=this.states.expansion.queue.includes(O)?this.expansionFleets.get(Jt):yn(c,O),L=un(et,O.targetId,O.targetKind);if(U.has(Jt)||!L||R!==yn(et,O)||!O.kind&&L.ownerId!=null||(O.kind==="sun-supply"||O.kind==="expansion-supply")&&!this.campaignPlanner(O).validSupply(O,et,n)||O.targetKind==="sun"&&!vd(O,et,n))continue;let Z=new Map(G(O).map(F=>[F.sourceId,F.count]));if([...Z].some(([F,ut])=>ut>(J.get(F)??0)))continue;let D=O.kind==="upgrade"&&a.upgradeMany?+(ve%200===0):1;if(!(Te+D>Math.floor(n.settings.horizonMs/S)+1)){Te+=D,O.kind==="upgrade"&&ve++,O.quoteRules=Ui(et,O),Ee.push(O),U.add(Jt),_e.set(Jt,R);for(let[F,ut]of Z)J.set(F,(J.get(F)??0)-ut),nt(O)&&Lt.set(F,(Lt.get(F)??0)+ut)}}(Lt.size!==this.logisticsReservations.size||[...Lt].some(([O,W])=>W!==this.logisticsReservations.get(O)))&&this.inventoryRevision++,this.logisticsReservations=Lt;let j=new Set(I.jobs.flatMap(O=>G(O).map(W=>W.sourceId)));for(let O of Ee)for(let W of G(O))j.add(W.sourceId);let Zt=z.sources.filter(O=>!j.has(O.sourceId)).sort((O,W)=>W.available-O.available);this.states.expansion.planning={sources:z.sources.length,ready:z.readySources,assigned:j.size,idle:Zt},this.states.expansion.queue=Ee,this.states.expansion.exact=I.exact&&!y.length&&!q.length,this.states.expansion.candidateCount=z.candidates,this.states.expansion.decisions=Ee.slice(0,5).map(bv),this.states.expansion.exposed=z.exposed,this.expansionFleets=_e,this.expansionQuoteVersion=c.quoteVersion,this.planningMs=performance.now()-u,(Ee.length||this.scanPlans.has("expansion"))&&this.emit("expansion",`\u540E\u53F0\u8BC4\u4F30\u5B8C\u6210\uFF1A${(this.planningMs/1e3).toFixed(1)} \u79D2\uFF0C\u5F85\u6267\u884C ${Ee.length} \u9879\uFF1B\u961F\u5217\u5DF2\u5408\u5E76\uFF1B\u62A5\u4EF7\u65B0\u7B97 ${this.planningQuotes.stats.fresh} / \u590D\u7528 ${this.planningQuotes.stats.reused}${z.deferredSources?`\uFF1B${z.deferredSources} \u9897\u6765\u6E90\u7684\u5269\u4F59\u5019\u9009\u4E0B\u8F6E\u7EED\u67E5`:""}`,Ee.length?"queued":"waiting"),b=Ee[0],b||this.emit("expansion",`${n.settings.peacefulDevelopment?"\u5B89\u7A33\u53D1\u80B2\uFF1A\u7B49\u5F85\u53EF\u5360\u9668\u77F3\u6216\u5B89\u5168\u5347\u7EA7":"\u6682\u65E0\u53EF\u6267\u884C\u6269\u5F20"}\uFF1A${z.readySources}/${z.sources.length} \u9897\u6765\u6E90\u53EF\u51FA\u5175\uFF1B${Zt[0]?.reason??"\u6218\u533A\u5185\u6682\u65E0\u5DF1\u65B9\u6765\u6E90"}`,"waiting")}if(!o())return;this.states[e].work={...this.states[e].work,plan:void 0},this.planned(e),this.states[e].flights=this.flightCount(e),this.emit(e),this.nextPlan[e]=Date.now()+(e==="expansion"&&n.settings.peacefulDevelopment?n.settings.scanMs:s===this.inventoryRevision?1e3:0);let x=e==="attack"?p:b;!x||e==="expansion"||await this.executeJob(e,n,i,o,x)}async executeUpgrades(e,n,i){let a=this.world,l=this.revision,s=[];for(let o of this.states.expansion.queue){if(o.kind!=="upgrade"||s.length===200)break;s.push(o)}this.states.expansion.work={...this.states.expansion.work,dispatch:`\u7B49\u5F85\u6279\u91CF\u5347\u7EA7 ${s.length} \u9897\u7684\u64CD\u4F5C\u95F4\u9694`},this.emit("expansion",`\u51C6\u5907\u6279\u91CF\u5347\u7EA7 ${s.length} \u9897\u661F\u7403\uFF1B\u7B49\u5F85\u64CD\u4F5C\u95F4\u9694`,"queued"),this.expansionDelay||=Bu(e.settings.intervalMs);try{await Uu(()=>{let o=a.read();if(!i()||this.coveredRevision!==l)return null;this.upgrades.observe(o,e);let u=this.budgets(o),d=new Map(o.owned.map(m=>[m.planetId,m])),c=new Set(this.states.expansion.queue.filter(m=>m.kind!=="upgrade").flatMap(m=>G(m).map(y=>y.sourceId))),v=new Set,f=s.filter(m=>{let y=d.get(m.sourceId),h=st(m);return!this.rulesCurrent(m,o)||!this.states.expansion.queue.includes(m)||v.has(m.sourceId)||!y||!Q(y,e.policy.zone)||y.level!==m.expectedLevel||this.flights.has(h)||this.pendingTargets.has(h)||this.expansionFleets.get(h)!==yn(o,m)||c.has(m.sourceId)||this.attackReservations.has(m.sourceId)||!m.campaignKind&&this.logisticsReservations.has(m.sourceId)||m.count>(u.get(m.sourceId)??0)||(m.campaignKind?!this.campaignPlanner(m).validUpgrade(m,o,e,u.get(m.sourceId)??0):!this.upgrades.eligible(y,o,e))?!1:(v.add(m.sourceId),!0)});return f.length?()=>{for(let h of f)this.expansionStock.set(h.sourceId,Math.min(o.budgets.get(h.sourceId)??0,this.expansionStock.get(h.sourceId)??1/0)-h.count),this.expansionPending.set(h.sourceId,(this.expansionPending.get(h.sourceId)??0)+1),this.upgrades.launched(h),h.campaignKind&&(this.campaignPlanner(h).launched(h,o),this.logisticsRevision++);this.inventoryRevision++,this.expansionDelay=0;let m;try{m=a.upgradeMany(f.map(h=>h.sourceId))}catch(h){m=Promise.reject(h)}this.emit("expansion",`\u5DF2\u63D0\u4EA4\u6279\u91CF\u5347\u7EA7 ${f.length} \u9897\u661F\u7403\uFF1B\u540E\u53F0\u6838\u5B9E\uFF0C\u7EE7\u7EED\u5176\u4ED6\u4EFB\u52A1`,"sent");let y=this.observeExpansion(a,e,f[0],m,f).finally(()=>{this.expansionObservers.delete(y),this.emit("expansion")});this.expansionObservers.add(y)}:null},this.expansionDelay,i,n)}finally{this.states.expansion.queue=this.states.expansion.queue.filter(o=>!s.includes(o)),this.states.expansion.work={...this.states.expansion.work,dispatch:void 0},this.emit("expansion")}}async executeJob(e,n,i,a,l){let s=this.world;if(e==="expansion"&&l.kind==="upgrade"&&s.upgradeMany){await this.executeUpgrades(n,i,a);return}let o=this.revision;if(this.states[e].work={...this.states[e].work,dispatch:`\u7B49\u5F85\u53D1\u5C04\u95F4\u9694 \u2192 ${De(l)}`},this.emit(e,`\u51C6\u5907${l.kind==="upgrade"?"\u5347\u7EA7 ":l.kind?"\u96C6\u7ED3 ":" "}${hl(l)} \u2192 ${De(l)}\uFF0C\u5171 ${pe(l)} \u63A2\u9488\uFF1B\u7B49\u5F85\u64CD\u4F5C\u95F4\u9694`,"queued"),e==="expansion"){this.expansionDelay||=Bu(n.settings.intervalMs);let f=!1,m,y=h=>(m=h,null);try{if(l.kind==="sun-supply"){let h;if(await Uu(()=>{let S=s.read();return!a()||!this.states.expansion.queue.includes(l)||this.coveredRevision!==o||!this.campaignPlanner(l).validSupply(l,S,n)||!S.autoUpgrading?.has(l.targetId)?null:s.disableAutoUpgrade?()=>{this.expansionDelay=0,this.states.expansion.work={...this.states.expansion.work,dispatch:`\u5173\u95ED\u96C6\u7ED3\u661F\u7403 #${l.targetId} \u7684\u81EA\u52A8\u5347\u7EA7`},this.emit("expansion",`\u6052\u661F\u96C6\u7ED3\u524D\u5173\u95ED\u661F\u7403 #${l.targetId} \u7684\u539F\u751F\u81EA\u52A8\u5347\u7EA7`,"waiting");try{h=s.disableAutoUpgrade(l.targetId)}catch(p){h=Promise.reject(p)}}:y("\u65E0\u6CD5\u5173\u95ED\u96C6\u7ED3\u661F\u7403\u7684\u539F\u751F\u81EA\u52A8\u5347\u7EA7\uFF0C\u672A\u8865\u7ED9")},this.expansionDelay,a,i),m)return;if(h){try{await Rs(h,15e3)}catch(S){y(`\u5173\u95ED\u96C6\u7ED3\u661F\u7403\u81EA\u52A8\u5347\u7EA7\u5931\u8D25\uFF0C\u672A\u8865\u7ED9\uFF1A${S instanceof Error?S.message:String(S)}`);return}if(!a()||i.aborted)return;this.expansionDelay||=Bu(n.settings.intervalMs)}}await Uu(()=>{let h=s.read();if(!a())return null;if(!this.rulesCurrent(l,h))return this.nextPlan.expansion=0,y("\u6765\u6E90\u79D1\u6280 / \u8986\u76D6\u89C4\u5219\u5DF2\u53D8\u5316\uFF0C\u4EC5\u91CA\u653E\u672C\u4EFB\u52A1\u91CD\u65B0\u89C4\u5212");if(!this.states.expansion.queue.includes(l))return y("\u4EFB\u52A1\u5DF2\u64A4\u9500\u6216\u66FF\u6362");if(this.coveredRevision!==o)return y("\u5F53\u524D\u914D\u7F6E\u7684\u6218\u533A\u8986\u76D6\u5C1A\u672A\u5C31\u7EEA");if(this.flights.has(st(l))||this.pendingTargets.has(st(l)))return y("\u76EE\u6807\u5DF2\u6709\u52A9\u624B\u8230\u961F\u5728\u9014\u6216\u5F85\u786E\u8BA4");let S=un(h,l.targetId,l.targetKind);if(!S)return y("\u76EE\u6807\u5DF2\u6D88\u5931\u6216\u4E0D\u5728\u5F53\u524D\u60C5\u62A5\u4E2D");if(!Q(S,n.policy.zone))return y("\u76EE\u6807\u4E0D\u5728\u56FA\u5B9A\u6218\u533A\u5185");if(this.expansionFleets.get(st(l))!==yn(h,l))return y("\u76EE\u6807\u5728\u9014\u8230\u961F\u5DF2\u53D8\u5316\uFF0C\u907F\u514D\u91CD\u590D\u6216\u9519\u8BEF\u8865\u5175");if(l.kind==="sun-supply"||l.kind==="expansion-supply"){if(!this.campaignPlanner(l).validSupply(l,h,n))return y("\u8865\u7ED9\u8BA1\u5212\u6216\u4E2D\u8F6C\u661F\u6761\u4EF6\u5DF2\u53D8\u5316")}else if(l.kind==="upgrade"){this.upgrades.observe(h,n);let x=h.owned.find(T=>T.planetId===l.sourceId);if(!x||x.level!==l.expectedLevel||this.attackReservations.has(l.sourceId)||!l.campaignKind&&this.logisticsReservations.has(l.sourceId)||(l.campaignKind?!this.campaignPlanner(l).validUpgrade(l,h,n,this.budgets(h).get(l.sourceId)??0):!this.upgrades.eligible(x,h,n)))return y("\u7B49\u7EA7\u3001\u5347\u7EA7\u9884\u7B97\u6216\u7A33\u5B9A\u6761\u4EF6\u5DF2\u53D8\u5316")}else if(l.targetKind&&l.targetKind!=="planet"){let x=Lu(l,h,n);if(x)return y(x)}else if(S.ownerId!=null)return y("\u76EE\u6807\u5DF2\u6709\u4EBA\u5360\u9886");if(l.kind==="sun-supply"&&h.autoUpgrading?.has(l.targetId))return y("\u96C6\u7ED3\u661F\u7403\u7684\u81EA\u52A8\u5347\u7EA7\u5C1A\u672A\u5173\u95ED\uFF0C\u672A\u8865\u7ED9");let p=G(l),r=new Set(p.map(x=>x.sourceId));(l.kind==="sun-supply"||l.kind==="expansion-supply")&&r.add(l.targetId);let g=this.budgets(h,r),b=l.campaignKind?this.logistics[l.campaignSlot].reserves:void 0;if(l.kind==="sun-supply"||l.kind==="expansion-supply"){let x=Math.max(0,(this.logisticsReservations.get(l.targetId)??0)-(b?.get(l.targetId)??0));if((g.get(l.targetId)??0)-(this.attackReservations.get(l.targetId)??0)-x<(l.hubBudget??0))return y("\u4E2D\u8F6C\u661F\u5B9E\u9645\u5E93\u5B58\u4E0D\u8DB3\u8BA1\u5212\u6240\u9700")}for(let x of p){if(!h.owned.some(A=>A.planetId===x.sourceId&&Q(A,n.policy.zone)))return y(`\u6765\u6E90 #${x.sourceId} \u5DF2\u5931\u53BB\u6240\u6709\u6743\u6216\u4E0D\u5728\u6218\u533A\u5185`);let T=b?.get(x.sourceId)??0,w=Math.max(0,(g.get(x.sourceId)??0)-(this.attackReservations.get(x.sourceId)??0)-Math.max(0,(this.logisticsReservations.get(x.sourceId)??0)-Math.min(x.count,T)));if(x.count>w)return y(`\u6765\u6E90 #${x.sourceId} \u5171\u4EAB\u53EF\u7528\u5175\u529B\u4E0D\u8DB3\uFF1A\u9700 ${x.count}\uFF0C\u53EF\u7528 ${w}`)}return()=>{f=!0,this.lastExpansionSupply=l.kind==="sun-supply"||l.kind==="expansion-supply";for(let w of p)this.expansionStock.set(w.sourceId,Math.min(h.budgets.get(w.sourceId)??0,this.expansionStock.get(w.sourceId)??1/0)-w.count),this.expansionPending.set(w.sourceId,(this.expansionPending.get(w.sourceId)??0)+1);if(this.inventoryRevision++,this.expansionDelay=0,l.campaignKind){this.campaignPlanner(l).launched(l,h),this.logisticsRevision++,this.nextLogistics=0;for(let w of p){this.logisticsReservations.set(w.sourceId,Math.max(0,(this.logisticsReservations.get(w.sourceId)??0)-w.count));let A=this.logistics[l.campaignSlot].reserves;A.set(w.sourceId,Math.max(0,(A.get(w.sourceId)??0)-w.count))}}l.kind==="sun-supply"||l.kind==="expansion-supply"||(l.kind==="upgrade"?this.upgrades.launched(l):this.flights.set(st(l),{identity:this.identity,mode:e,job:l,due:Date.now()+Math.max(6e4,ot(l)+15e3)})),l.kind!=="upgrade"&&(this.states.expansion.sent+=p.length),this.journal.sent(l),this.states.expansion.metrics=this.journal.snapshot(),this.states.expansion.flights=this.flightCount(e),this.states.expansion.queue=this.states.expansion.queue.filter(w=>w!==l);let x;try{x=l.kind==="upgrade"?s.upgrade(l.sourceId):l.targetKind&&l.targetKind!=="planet"?s.launchBody(l):l.kind==="sun-supply"||l.kind==="expansion-supply"||l.support?.length?s.launchGroup(l):s.launch(l.sourceId,l.targetId,l.count)}catch(w){x=Promise.reject(w)}this.emit(e,`\u5DF2\u63D0\u4EA4${l.kind==="upgrade"?"\u5347\u7EA7":"\u53D1\u5C04"} \u2192 ${De(l)}\uFF1B\u540E\u53F0\u786E\u8BA4\uFF0C\u7EE7\u7EED\u4E0B\u4E00\u9879`,"sent");let T=this.observeExpansion(s,n,l,x).finally(()=>{this.expansionObservers.delete(T),this.emit("expansion")});this.expansionObservers.add(T)}},this.expansionDelay,a,i)}finally{!f&&m&&a()&&(l.targetKind==="comet"&&(this.states.expansion.meteorites=[{targetId:l.targetId,reason:m},...(this.states.expansion.meteorites??[]).filter(h=>h.targetId!==l.targetId)].slice(0,6)),this.emit("expansion",`\u8DF3\u8FC7${De(l)}\uFF1A${m}`,"waiting")),this.states.expansion.work={...this.states.expansion.work,dispatch:void 0},this.emit("expansion"),this.states.expansion.queue=this.states.expansion.queue.filter(h=>h!==l),!f&&l.campaignKind&&(this.nextLogistics=l.kind==="sun-supply"?Date.now()+1e3:0)}return}let u,d=!1,c=()=>{if(!(d||this.configs.attack!==n)){d=!0;for(let f of G(l)){let m=Math.max(0,(this.attackReservations.get(f.sourceId)??0)-f.count);m?this.attackReservations.set(f.sourceId,m):this.attackReservations.delete(f.sourceId)}this.inventoryRevision++}},v=[];try{if(await mv(()=>{let f=s.read();if(!a()||this.scanning||this.coveredRevision!==o||this.flights.has(st(l))||this.pendingTargets.has(st(l)))return null;let m=f.planets.find(g=>g.planetId===l.targetId);if(!m||!Q(m,n.policy.zone))return null;let y=this.budgets(f);for(let[g,b]of this.logisticsReservations)y.set(g,Math.max(0,(y.get(g)??0)-b));let h=new Map(G(l).map(g=>[g.sourceId,g.count])),S=new Map(y);for(let[g,b]of this.attackReservations)S.set(g,Math.max(0,(y.get(g)??0)-Math.max(0,b-(h.get(g)??0))));if(G(l).some(g=>!f.owned.some(b=>b.planetId===g.sourceId&&Q(b,n.policy.zone))))return null;let p=f.owned.find(g=>g.planetId===l.sourceId),r=l.kind==="reinforce"?this.offensive.refresh(s,f,n,y,l):li(s,f,p,m,n);if(!r||G(r).some(g=>g.count>(S.get(g.sourceId)??0)))return null;u=r;for(let g of G(u))this.pendingSources.add(g.sourceId),this.debits.set(g.sourceId,(this.debits.get(g.sourceId)??0)+g.count);return c(),this.pendingTargets.add(st(u)),this.inventoryRevision++,r.kind==="reinforce"&&(v=G(r).map(g=>({count:Wt(g.count,s.route(g.sourceId,r.targetId).lossPct),travelMs:g.travelMs}))),()=>(this.states[e].confirming=r,this.states[e].work={...this.states[e].work,dispatch:`\u7B49\u5F85\u670D\u52A1\u5668\u786E\u8BA4 \u2192 #${r.targetId}`},this.emit(e,`\u6B63\u5728${r.kind==="reinforce"?`\u96C6\u7ED3 ${G(r).length} \u9897\u6765\u6E90`:"\u53D1\u9001"} \u2192 #${r.targetId}\uFF0C${pe(r)} \u63A2\u9488\uFF1B\u7B49\u5F85\u670D\u52A1\u5668\u786E\u8BA4`,"sending"),r.support?.length?s.launchGroup(r):s.launch(r.sourceId,r.targetId,r.count))},n.settings.intervalMs,a,e,i),this.states[e].confirming=void 0,u&&(u.kind==="reinforce"?this.supplies.push({hub:u.targetId,deliveries:v.map(f=>({count:f.count,arrival:Date.now()+f.travelMs}))}):this.flights.set(st(u),{identity:this.identity,mode:e,job:u,due:Date.now()+ot(u)}),e==="attack"&&this.configs.attack===n&&this.offensive.launched(u,n),this.states[e].sent+=G(u).length,this.states[e].flights=this.flightCount(e),this.states[e].queue=this.states[e].queue.filter(f=>f.targetId!==u.targetId),this.failure||this.emit(e,u.kind==="reinforce"?`\u5DF2\u786E\u8BA4\u96C6\u7ED3\u53D1\u5C04\uFF1A${G(u).length} \u9897\u6765\u6E90 \u2192 \u4E2D\u8F6C\u661F #${u.targetId}\uFF1B\u7B49\u5F85\u5B9E\u9645\u5230\u8FBE\u540E\u51FA\u51FB`:`\u5DF2\u786E\u8BA4\u53D1\u5C04 \u2192 #${u.targetId}\uFF1B\u7B49\u5F85\u62B5\u8FBE\u548C\u5360\u9886\u786E\u8BA4`,"sent"),s.syncInventory)){let f=G(u).map(m=>m.sourceId);await s.syncInventory(f);for(let m of f)this.debits.delete(m)}}catch(f){this.fail(f)}finally{if(this.states.attack.confirming=void 0,this.states.attack.queue=this.states.attack.queue.filter(f=>f!==l),c(),u){for(let f of G(u))this.pendingSources.delete(f.sourceId);this.pendingTargets.delete(st(u)),this.inventoryRevision++,this.nextPlan={expansion:0,attack:0},this.nextFrontier=0,this.nextMeteorite=0,this.wake?.()}this.nextPlan[e]=0}}async observeExpansion(e,n,i,a,l){let s=()=>this.configs.expansion===n&&!this.failure,o=!1;try{await Rs(a,15e3),o=!0;let c=this.flights.get(st(i));c?.job===i&&(c.due=Date.now()+ot(i)),i.kind==="upgrade"&&!l&&(this.journal.upgraded(),this.states.expansion.metrics=this.journal.snapshot()),s()&&this.emit("expansion",l?`\u5DF2\u786E\u8BA4\u6279\u91CF\u5347\u7EA7\u8BF7\u6C42\uFF1A${l.length} \u9897\uFF1B\u540C\u6B65\u5E93\u5B58\u5E76\u6838\u5B9E\u7B49\u7EA7`:i.kind==="upgrade"?`\u5DF2\u786E\u8BA4\u5347\u7EA7\u661F\u7403 #${i.sourceId}\uFF1B\u540C\u6B65\u5E93\u5B58`:i.kind==="sun-supply"||i.kind==="expansion-supply"?`\u5DF2\u786E\u8BA4\u6269\u5F20\u8865\u7ED9 \u2192 \u661F\u7403 #${i.targetId}\uFF1B\u7B49\u5F85\u5230\u8D26\u540E\u5355\u661F\u51FA\u51FB`:`\u5DF2\u786E\u8BA4\u53D1\u5C04 \u2192 ${De(i)}\uFF1B\u7B49\u5F85\u62B5\u8FBE\u548C\u5360\u9886\u786E\u8BA4`,"sent")}catch(c){s()&&this.emit("expansion",`${l?`\u6279\u91CF\u5347\u7EA7 ${l.length} \u9897`:`\u53D1\u5C04 \u2192 #${i.targetId}`}\u56DE\u6267\u672A\u786E\u8BA4\uFF1A${c instanceof Error?c.message:String(c)}\uFF1B\u5DF2\u8DF3\u8FC7\uFF0C\u7EE7\u7EED\u5176\u4ED6\u76EE\u6807`,"waiting")}let u=(l??G(i)).map(c=>c.sourceId),d=!1;try{if(e.syncInventory&&(await Rs(e.syncInventory(u),12e3),d=!0,l&&o)){let c=e.read(),v=new Map(c.owned.map(m=>[m.planetId,m.level??0])),f=l.filter(m=>(v.get(m.sourceId)??0)>m.expectedLevel);for(let m of f)this.journal.upgraded();this.states.expansion.metrics=this.journal.snapshot(),s()&&this.emit("expansion",`\u6279\u91CF\u5347\u7EA7\u6838\u5B9E\uFF1A${f.length}/${l.length} \u9897\u7B49\u7EA7\u5DF2\u63D0\u5347${f.length!this.expansionPending.has(i)).slice(0,24);n.length&&(this.nextInventoryRetry=Date.now()+5e3,this.inventoryRecovery=Rs(e.syncInventory(n),12e3).then(()=>{for(let i of n)this.expansionPending.has(i)||(this.expansionStock.delete(i),this.inventoryDirty.delete(i));this.inventoryRevision++,this.nextPlan={expansion:0,attack:0},this.wake?.()},()=>{}).finally(()=>{this.inventoryRecovery=void 0}))}};var zv="swarm-helper-expansion-settings",Cv=new Set(["scanMs","intervalMs","horizonMs","maxTravelMs","economicHorizonMs","stableMs"]),xd=Object.keys(da);function Av(t){return Object.fromEntries(xd.map(e=>[e,String(t[e]/(Cv.has(e)?1e3:1))]))}function Md(t=zv){try{let e=JSON.parse(localStorage.getItem(t)??"null");if(e){let n={...da,...e};return n.maxSources??=da.maxSources,n.maxTravelMs??=da.maxTravelMs,Cs.some(i=>i===n.scanMs)||(n.scanMs=da.scanMs),Ns(n),Av(n)}}catch{}return Av(da)}function wd(t){if(xd.some(n=>!t[n].trim()))throw new Error("\u8BF7\u586B\u5199\u5B8C\u6574\u7684\u8FD0\u884C\u53C2\u6570\u3002");let e=Object.fromEntries(xd.map(n=>[n,Number(t[n])*(Cv.has(n)?1e3:1)]));return Ns(e),e}function Nv(t,e=zv){let n=wd(t);return localStorage.setItem(e,JSON.stringify(n)),n}var Rv="swarm-helper-regions-v1",Iv=t=>({scope:t==="attack"?"circle":"all",x:"",y:"",radius:"32",enemy:"",frontlinePercent:String(Ru.frontlinePercent),threatRadius:String(Ru.threatRadius),holdProbes:String(Ru.holdProbes),rallyId:"",rallyMinutes:"30",advanceHub:"yes",rallyHubs:"3"});function ks(t,e){if(t.scope!=="all"&&t.scope!=="circle")throw new Error("\u8BF7\u9009\u62E9\u6709\u6548\u7684\u6218\u533A\u8303\u56F4\u3002");if(t.scope==="circle"&&(!t.x.trim()||!t.y.trim()||!t.radius.trim()))throw new Error("\u8BF7\u4F7F\u7528\u5730\u56FE\u9009\u53D6\u6218\u533A\u4E2D\u5FC3\uFF0C\u6216\u586B\u5199\u5750\u6807\u4E0E\u534A\u5F84\u3002");if(!t.frontlinePercent.trim()||!t.threatRadius.trim()||!t.holdProbes.trim())throw new Error("\u8BF7\u586B\u5199\u52A8\u6001\u7559\u5175\u53C2\u6570\u3002");let n={zone:t.scope==="circle"?{x:Number(t.x),y:Number(t.y),radius:Number(t.radius)}:null,enemy:e==="attack"&&t.enemy?t.enemy:null,frontlinePercent:Number(t.frontlinePercent),threatRadius:Number(t.threatRadius),holdProbes:Number(t.holdProbes),rallyId:t.rallyId||null,rallyMs:Number(t.rallyMinutes)*6e4,advanceHub:t.advanceHub==="yes",rallyHubs:Number(t.rallyHubs)};return Ou(n,e),n}function Ov(){let t={expansion:Iv("expansion"),attack:Iv("attack")};try{let e=JSON.parse(localStorage.getItem(Rv)??"null");for(let n of["expansion","attack"])if(e?.[n]){let i={...t[n],...e[n]};ks(i,n),t[n]=i}}catch{}return t}function Dv(t){localStorage.setItem(Rv,JSON.stringify(t))}function _v(t){let{map:e}=ml(),n=t==="selection"?e.getPickedBody?.():null,i=t==="selection"?n:e.getViewCenter?.();if(!i||!Number.isSafeInteger(i.x)||!Number.isSafeInteger(i.y))throw new Error(t==="selection"?"\u8BF7\u5148\u5728\u6E38\u620F\u4E2D\u9009\u4E2D\u4E00\u9897\u661F\u7403\uFF0C\u518D\u8BFB\u53D6\u4E2D\u5FC3\u3002":"\u65E0\u6CD5\u8BFB\u53D6\u5730\u56FE\u4E2D\u5FC3\uFF0C\u8BF7\u624B\u52A8\u586B\u5199\u5750\u6807\u3002");return{x:i.x,y:i.y,...n&&!n.isSun?{planetId:String(n.id)}:{}}}function kv(t,e){let{map:n}=ml();if(!n.focusPlanet)throw new Error("\u5730\u56FE\u5B9A\u4F4D\u63A5\u53E3\u4E0D\u53EF\u7528\u3002");n.focusPlanet(t,e)}var ma=t=>t instanceof Error?t.message:String(t),qv="swarm-helper-attack-settings",nr=class{constructor(e=()=>new _u,n={point:_v,focus:kv}){this.createWorld=e;this.mapActions=n;this.engine=new er((i,a)=>this.onUpdate(i,a),e),this.state={expanded:!1,mode:"expansion",settingsOpen:!0,attackSettingsOpen:!0,uncertain:Hn(),settings:Md(),attackSettings:{...Md(qv),maxSources:"1",intervalMs:"1",captureSuns:"0",captureMeteorites:"0",upgradeStable:"0"},policies:Ov(),previews:{expansion:{busy:!1,message:"",enemies:[]},attack:{busy:!1,message:"",enemies:[]}},expansion:{...this.engine.states.expansion},attack:{...this.engine.states.attack},logs:[],reviewed:!1,unlocking:!1,unlockStatus:""}}createWorld;mapActions;listeners=new Set;engine;disposed=!1;logId=0;state;previewVersions={expansion:0,attack:0};previews=new Set;planetPlan=e=>this.engine.planetPlan(e,e.planetId);getSnapshot=()=>this.state;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});patch(e){if(!this.disposed){this.state={...this.state,...e};for(let n of this.listeners)n()}}onUpdate(e,n){if(this.disposed)return;let i=this.state[e],a=n.phase!==i.phase||n.activity!==i.activity,l=n.activity==="error"?"error":n.activity==="paused"||n.activity==="stopping"?"warning":n.activity==="sent"||n.activity==="captured"?"success":"info",s=this.state.logs.filter(d=>d.mode===e),o=s.length>=50?this.state.logs.filter(d=>d.id!==s[0].id):this.state.logs,u=a?[...o,{id:++this.logId,time:Date.now(),message:n.phase,level:l,mode:e}].slice(-100):this.state.logs;this.patch({[e]:n,uncertain:Hn(),logs:u,...e==="attack"&&n.activity==="error"&&!n.running?{attackSettingsOpen:!0}:{}})}expand=()=>{this.patch({expanded:!0})};collapse=()=>{this.patch({expanded:!1})};setMode=e=>{this.patch({mode:e})};toggleSettings=()=>{this.patch({settingsOpen:!this.state.settingsOpen})};toggleAttackSettings=()=>{this.patch({attackSettingsOpen:!this.state.attackSettingsOpen})};setSetting=(e,n)=>{this.state.expansion.running||this.patch({settings:{...this.state.settings,[e]:n}})};setAttackSetting=(e,n)=>{e!=="intervalMs"&&!this.state.attack.running&&this.patch({attackSettings:{...this.state.attackSettings,[e]:n}})};setPolicy=(e,n,i)=>{this.state[e].running||(this.patch({policies:{...this.state.policies,[e]:{...this.state.policies[e],[n]:i}}}),["scope","x","y","radius"].includes(n)&&(this.previewVersions[e]++,this.patchPreview(e,{busy:!1,message:"",enemies:[],hubs:[]})))};patchPreview(e,n){this.patch({previews:{...this.state.previews,[e]:{...this.state.previews[e],...n}}})}pickCenter=(e,n)=>{if(!this.state[e].running)try{let i=this.mapActions.point(n);this.previewVersions[e]++,this.patch({policies:{...this.state.policies,[e]:{...this.state.policies[e],scope:"circle",x:String(i.x),y:String(i.y)}}}),this.patchPreview(e,{busy:!1,message:"\u4E2D\u5FC3\u5DF2\u9009\u5B9A\uFF0C\u53EF\u8C03\u6574\u534A\u5F84\u540E\u52A0\u8F7D\u533A\u57DF\u6982\u89C8\u3002",enemies:[],hubs:[]})}catch(i){this.patchPreview(e,{message:ma(i)})}};pickHub=()=>{if(!this.state.attack.running)try{let e=this.mapActions.point("selection");if(!e.planetId)throw new Error("\u8BF7\u5148\u5728\u6E38\u620F\u4E2D\u5355\u9009\u4E00\u9897\u5DF1\u65B9\u884C\u661F\uFF0C\u4F5C\u4E3A\u521D\u59CB\u4E2D\u8F6C\u661F\u3002");this.setPolicy("attack","rallyId",e.planetId),this.patchPreview("attack",{message:`\u5DF2\u9009\u4E2D\u8F6C\u661F #${e.planetId} (${e.x}, ${e.y})\uFF1B\u542F\u52A8\u65F6\u4F1A\u6838\u5B9E\u5F52\u5C5E\u548C\u6218\u533A\u8303\u56F4\u3002`})}catch(e){this.patchPreview("attack",{message:ma(e)})}};focusRegion=e=>{try{let n=ks(this.state.policies[e],e);if(!n.zone)throw new Error("\u8BF7\u5148\u9009\u62E9\u56FA\u5B9A\u533A\u57DF\u3002");this.mapActions.focus(n.zone.x,n.zone.y)}catch(n){this.patchPreview(e,{message:ma(n)})}};focusEnemy=e=>{let n=this.state.previews.attack.enemies.find(i=>i.id===e);if(n)try{this.mapActions.focus(n.x,n.y)}catch(i){this.patchPreview("attack",{message:ma(i)})}};previewRegion=async e=>{if(this.disposed||this.state.previews[e].busy)return;let n=++this.previewVersions[e],i;try{let a={settings:wd(e==="attack"?this.state.attackSettings:this.state.settings),policy:ks(this.state.policies[e],e)};if(!a.policy.zone)throw new Error("\u8BF7\u5148\u9009\u62E9\u56FA\u5B9A\u533A\u57DF\uFF0C\u518D\u52A0\u8F7D\u6982\u89C8\u3002");this.patchPreview(e,{busy:!0,message:"\u6B63\u5728\u52A0\u8F7D\u533A\u57DF\u60C5\u62A5\u2026"}),i=this.createWorld(),this.previews.add(i),i.configure?.([a]);let l=()=>!this.disposed&&this.previewVersions[e]===n;if(await i.scan(a.settings,l),!l())return;let s=i.read(),o=s.planets.filter(c=>Q(c,a.policy.zone)),u=new Map;for(let c of o.filter(v=>we(v,s))){let v=c.ownerId.toHexString(),f=u.get(v)??{id:v,name:s.players?.get(v)||v.slice(0,12),count:0,x:c.positionX,y:c.positionY};f.count++,u.set(v,f)}let d=s.owned.filter(c=>Q(c,a.policy.zone)&&!s.automated?.has(c.planetId)).map(c=>({id:String(c.planetId),x:c.positionX,y:c.positionY,probes:s.budgets.get(c.planetId)??0})).sort((c,v)=>v.probes-c.probes);this.patchPreview(e,{busy:!1,message:`\u533A\u57DF\u5185\uFF1A\u5DF1\u65B9 ${s.owned.filter(c=>Q(c,a.policy.zone)).length} \xB7 \u65E0\u4E3B ${o.filter(c=>!c.ownerId).length} \xB7 \u654C\u65B9 ${[...u.values()].reduce((c,v)=>c+v.count,0)} \u9897\uFF1B${u.size} \u4F4D\u654C\u4EBA${e==="attack"?`\u3002${$u(s,a)??""}`:""}`,enemies:[...u.values()].sort((c,v)=>v.count-c.count||c.name.localeCompare(v.name)),hubs:d})}catch(a){n===this.previewVersions[e]&&this.patchPreview(e,{busy:!1,message:ma(a)})}finally{i?.dispose(),i&&this.previews.delete(i)}};setReviewed=e=>{this.patch({reviewed:e})};startMode(e){if(!(this.disposed||this.state.uncertain||this.state[e].running))try{let n=ks(this.state.policies[e],e),i=Nv(e==="attack"?this.state.attackSettings:this.state.settings,e==="attack"?qv:void 0);Dv(this.state.policies),this.patch(e==="attack"?{attackSettingsOpen:!1}:{settingsOpen:!1}),this.engine.start(e,{settings:i,policy:n})}catch(n){this.onUpdate(e,{...this.state[e],activity:"error",phase:ma(n)})}}start=()=>{this.startMode("expansion")};startAttack=()=>{this.startMode("attack")};stop=()=>{this.engine.stop("expansion")};stopAttack=()=>{this.engine.stop("attack")};stopAll=()=>{this.engine.stop()};unlock=async()=>{if(!(this.disposed||this.state.unlocking)){this.patch({unlocking:!0});try{if(!this.state.reviewed)throw new Error("\u8BF7\u5148\u6838\u5B9E\u6E38\u620F\u65E5\u5FD7\uFF0C\u5E76\u52FE\u9009\u786E\u8BA4\u3002");await vv(),this.patch({uncertain:!1,reviewed:!1,unlockStatus:"\u5DF2\u89E3\u9664\u9501\u5B9A\uFF0C\u53EF\u4EE5\u624B\u52A8\u91CD\u65B0\u542F\u52A8\u3002"})}catch(e){this.patch({unlockStatus:ma(e)})}finally{this.patch({unlocking:!1})}}};dispose=()=>{if(!this.disposed){this.disposed=!0,this.engine.stop();for(let e of this.previews)e.dispose();this.listeners.clear()}}};function Hv(t){let e=Object.keys(t).find(a=>a.startsWith("__reactFiber$")),n=e?t[e]:void 0,i=n;for(;i?.return;)i=i.return;return i?.stateNode?.current&&i.stateNode.current!==i&&(n=n?.alternate),n}function KS(t){let e=t.map(n=>n.getBoundingClientRect()).filter(n=>n.width>0&&n.height>0);return e.length?{left:Math.min(...e.map(n=>n.left)),right:Math.max(...e.map(n=>n.right)),top:Math.min(...e.map(n=>n.top)),bottom:Math.max(...e.map(n=>n.bottom))}:null}var VS=t=>typeof t=="bigint"&&t>0n&&t<=0xffffffffffffffffn;function Uv(){let t=document.querySelector('[data-testid="radial-menu"]'),e=document.querySelector('[data-testid="dial-slider"]'),n=t??e?.closest(".gesture-surface");if(!n)return null;let i=KS([...n.querySelectorAll(t?'button, [data-testid="radial-detail"]':'button, [data-testid="dial-slider"]')]);if(!i)return null;let a=Number(window.getComputedStyle(n).zIndex)||100;for(let l=Hv(n),s=0;l&&s<80;l=l.return,s++){let o=l.memoizedProps,u=o?.conn,d=o?.myIdentity;if(!u?.isActive||!u.db?.swarm||typeof d!="string")continue;let c;if(t)typeof o?.screenX=="number"&&typeof o.screenY=="number"&&(c=o.planetId);else{let v;for(let f=Hv(n),m=0;f&&m<80;f=f.return,m++)if(typeof f.memoizedProps?.onSend=="function"){v=f.memoizedProps;break}for(let f=l.memoizedState,m=0;f&&m<200;f=f.next,m++){let y=f.memoizedState;if(y?.descriptor?.targetKind==="planet"&&v&&y.screenX===v.x&&y.screenY===v.y){c=y.targetId;break}}}if(VS(c)&&u.db.planet.planetId.find(c))return{conn:u,identity:d,planetId:c,bounds:i,zIndex:a}}return null}function ZS(t,e,n){if(!t.db.swarm||!t.db.clan_member2)throw new Error("\u8230\u961F\u60C5\u62A5\u63A5\u53E3\u4E0D\u53EF\u7528");let i=[...t.db.clan_member2.iter()],a=i.find(d=>d.playerId.toHexString()===e)?.clanId,l=new Set(i.filter(d=>a!==void 0&&d.clanId===a).map(d=>d.playerId.toHexString())),s={mine:{count:0n,fleets:0,unknown:0},enemy:{count:0n,fleets:0,unknown:0},ally:{count:0n,fleets:0,unknown:0}},o=new Set;for(let d of t.db.swarm.iter()){if(d.targetPlanetId!==n||o.has(d.swarmId))continue;o.add(d.swarmId);let c=d.ownerId.toHexString(),v=s[c===e?"mine":l.has(c)?"ally":"enemy"];v.fleets++,Number.isSafeInteger(d.probeCount)&&d.probeCount>=0?v.count+=BigInt(d.probeCount):v.unknown++}let u=d=>({probes:String(d.count),fleets:d.fleets,unknown:d.unknown});return{mine:u(s.mine),enemy:u(s.enemy),ally:u(s.ally)}}function Bv(t,e,n){let i=[],a=!1,l=!1,s=0,o,u=()=>{clearTimeout(o);for(let c of i.splice(0))try{c.unsubscribe()}catch{}},d=()=>{a||(l=!0,u())};o=setTimeout(d,12e3);try{if(!t.db.swarm||!t.db.clan_member2||n<=0n||n>0xffffffffffffffffn)throw new Error("\u63A5\u53E3\u4E0D\u53EF\u7528");for(let c of[`SELECT * FROM swarm WHERE target_planet_id = ${n}`,"SELECT * FROM clan_member2"]){let v=!1,f=t.subscriptionBuilder().onApplied(()=>{a||l||v||(v=!0,++s===2&&clearTimeout(o))}).onError(d).subscribe(c);if(l||a){f.unsubscribe();break}i.push(f)}}catch{d()}return{read(){if(a||l)return{status:"error"};if(!t.isActive)return d(),{status:"error"};if(s<2)return{status:"loading"};if(i.some(c=>!c.isActive()))return d(),{status:"error"};try{return{status:"ready",totals:ZS(t,e,n)}}catch{return d(),{status:"error"}}},dispose(){a=!0,u()}}}var Yv=(t,e)=>t.conn===e.conn&&t.identity===e.identity&&t.planetId===e.planetId,ir=class{constructor(e,n=Uv,i=Bv){this.readPlan=e;this.readMenu=n;this.watch=i}readPlan;readMenu;watch;snapshot=null;listeners=new Set;watcher;timer;lastRead=0;disposed=!1;getSnapshot=()=>this.snapshot;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});start(){!this.disposed&&!this.timer&&(this.refresh(),this.timer=setInterval(this.refresh,250))}load=e=>{this.refresh();let n=this.snapshot;this.disposed||!n||!Yv(n.menu,e)||this.watcher&&n.incoming.status!=="error"||(this.watcher?.dispose(),this.watcher=this.watch(n.menu.conn,n.menu.identity,n.menu.planetId),this.lastRead=Date.now(),this.snapshot={...n,incoming:this.watcher.read()},this.emit())};refresh=()=>{if(this.disposed)return;let e;try{e=this.readMenu()}catch{e=null}let n=this.snapshot;if(!e){this.watcher?.dispose(),this.watcher=void 0,n&&(this.snapshot=null,this.emit());return}let i=!n||!Yv(n.menu,e);i&&(this.watcher?.dispose(),this.watcher=void 0);let a=!!this.watcher&&(!n||n.incoming.status==="loading"||Date.now()-this.lastRead>=1e3),l=a?this.watcher.read():i?{status:"idle"}:n.incoming;a&&(this.lastRead=Date.now());let s=this.readPlan(e);(i||JSON.stringify([n?.menu.bounds,n?.menu.zIndex,n?.incoming,n?.plan])!==JSON.stringify([e.bounds,e.zIndex,l,s]))&&(this.snapshot={menu:e,incoming:l,plan:s},this.emit())};emit(){for(let e of this.listeners)e()}dispose(){this.disposed=!0,clearInterval(this.timer),this.timer=void 0,this.watcher?.dispose(),this.watcher=void 0,this.snapshot=null,this.listeners.clear()}};var Xv=ht(xn(),1),Kv=ht(ud(),1);var Tl=ht(xn(),1);var Qv=`:host { pointer-events: none; } .incoming { position: fixed; box-sizing: border-box; width: 270px; max-width: calc(100vw - 16px); padding: 11px 13px; border: 1px solid #7dd3fc55; border-radius: 10px; background: #090f1deb; box-shadow: 0 5px 20px #0006; color: #e5edf6; font: 13px/1.6 system-ui, sans-serif; pointer-events: none; } header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 5px; font-weight: 600; } small, footer { color: #99a9bc; font-size: 11px; font-weight: 400; } .incoming > div { display: flex; gap: 6px; align-items: baseline; } strong { margin-left: auto; font-variant-numeric: tabular-nums; } .enemy strong { color: #ff9696; } .mine strong { color: #81ceff; } .ally strong { color: #8ee2b1; } p { margin: 5px 0; color: #c5d1df; } footer { margin-top: 7px; } button { pointer-events: auto; width: 100%; padding: 6px 10px; border: 1px solid #7dd3fc66; border-radius: 6px; background: #203a50; color: #c7ecff; font: inherit; cursor: pointer; } button:hover { background: #2b4c68; } button:focus-visible { outline: 2px solid #81ceff; outline-offset: 2px; } .planet-plans { list-style: none; padding: 0; margin: 3px 0 5px; max-height: min(24vh, 9em); overflow-y: auto; overflow-wrap: anywhere; pointer-events: auto; overscroll-behavior: contain; } .planet-plans li + li { margin-top: 4px; } .query-icon { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 50%; border-color: #7dd3fc44; background: #101a29cc; color: #a7c5d8; } `;var dt=ht(Bt(),1);function $S(t,e,n,i,a){let s=(t.left+t.right-e)/2,o=t.bottom+8;return o+n>a-8&&(t.top-8-n>=8?o=t.top-8-n:(s=t.right+8+e<=i-8?t.right+8:t.left-8-e,o=t.top)),{left:Math.max(8,Math.min(s,i-e-8)),top:Math.max(8,Math.min(o,a-n-8))}}var Gv=new Intl.NumberFormat("zh-CN");function Ed({label:t,kind:e,total:n}){return(0,dt.jsxs)("div",{className:e,children:[(0,dt.jsx)("span",{children:t}),(0,dt.jsx)("strong",{children:n.unknown?n.probes==="0"?"\u672A\u77E5":`\u2265 ${Gv.format(BigInt(n.probes))}`:Gv.format(BigInt(n.probes))}),(0,dt.jsxs)("span",{children:["\u5175 \xB7 ",n.fleets," \u652F"]})]})}function Lv({snapshot:t,onLoad:e}){let n=(0,Tl.useRef)(null),[i,a]=(0,Tl.useState)({left:8,top:8});if((0,Tl.useLayoutEffect)(()=>{if(!t||!n.current)return;let s=()=>{let o=n.current.getBoundingClientRect();a($S(t.menu.bounds,o.width,o.height,window.innerWidth,window.innerHeight))};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[t]),!t)return null;let{incoming:l}=t;return(0,dt.jsxs)(dt.Fragment,{children:[(0,dt.jsx)("style",{children:Qv}),(0,dt.jsxs)("section",{ref:n,className:"incoming","aria-label":"\u661F\u7403\u7F16\u53F7\u4E0E\u89C4\u5212",style:{...i,zIndex:t.menu.zIndex+1},children:[(0,dt.jsxs)("header",{children:[(0,dt.jsxs)("span",{children:["\u661F\u7403 #",String(t.menu.planetId)]}),l.status==="idle"&&(0,dt.jsx)("button",{className:"query-icon",type:"button",title:"\u67E5\u8BE2\u5728\u9014\u5175\u529B","aria-label":"\u67E5\u8BE2\u5728\u9014\u5175\u529B",onClick:e,children:(0,dt.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:[(0,dt.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,dt.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,dt.jsx)("path",{d:"M12 12 18.4 5.6"}),(0,dt.jsx)("circle",{cx:"7",cy:"16",r:"1",fill:"currentColor",stroke:"none"})]})})]}),(0,dt.jsx)("small",{children:"\u811A\u672C\u89C4\u5212"}),(0,dt.jsx)("ul",{className:"planet-plans",children:t.plan.map((s,o)=>(0,dt.jsx)("li",{children:s},o))},String(t.menu.planetId)),l.status!=="idle"&&(0,dt.jsx)("small",{children:"\u98DE\u5F80\u6B64\u661F\u7403\u7684\u5728\u9014\u5175\u529B"}),l.status==="idle"?null:l.status==="loading"?(0,dt.jsx)("p",{children:"\u52A0\u8F7D\u4E2D\u2026"}):l.status==="error"?(0,dt.jsxs)(dt.Fragment,{children:[(0,dt.jsx)("p",{children:"\u6570\u636E\u4E0D\u53EF\u7528"}),(0,dt.jsx)("button",{type:"button",onClick:e,children:"\u91CD\u65B0\u67E5\u8BE2"})]}):(0,dt.jsxs)(dt.Fragment,{children:[(0,dt.jsx)(Ed,{label:"\u654C\u65B9\u5728\u9014",kind:"enemy",total:l.totals.enemy}),(0,dt.jsx)(Ed,{label:"\u6211\u7684\u5728\u9014",kind:"mine",total:l.totals.mine}),l.totals.ally.fleets>0&&(0,dt.jsx)(Ed,{label:"\u76DF\u53CB\u5728\u9014",kind:"ally",total:l.totals.ally}),Object.values(l.totals).some(s=>s.unknown>0)&&(0,dt.jsx)("p",{children:"\u90E8\u5206\u8230\u961F\u5175\u529B\u672A\u77E5"}),(0,dt.jsx)("footer",{children:"\u6309\u8230\u961F\u8BB0\u5F55\u7EDF\u8BA1\uFF0C\u975E\u635F\u8017\u540E\u62B5\u8FBE\u5175\u529B"})]})]})]})}var Td=ht(Bt(),1);function PS({controller:t}){let e=(0,Xv.useSyncExternalStore)(t.subscribe,t.getSnapshot);return(0,Td.jsx)(Lv,{snapshot:e,onLoad:()=>{e&&t.load(e.menu)}})}function Vv(t){let e=document.createElement("div");e.id="swarm-helper-incoming",e.style.pointerEvents="none";let n=["pointerdown","pointerup","mousedown","mouseup","click","dblclick","wheel"],i=o=>o.stopPropagation();for(let o of n)e.addEventListener(o,i);let a=o=>{o.composedPath().includes(e)&&o.stopImmediatePropagation()};window.addEventListener("keydown",a,!0),window.addEventListener("keyup",a,!0);let l=(0,Kv.createRoot)(e.attachShadow({mode:"open"}),{onUncaughtError:()=>t.dispose()});document.body.append(e),l.render((0,Td.jsx)(PS,{controller:t})),t.start();let s=!1;return()=>{if(!s){s=!0,t.dispose(),l.unmount(),e.remove();for(let o of n)e.removeEventListener(o,i);window.removeEventListener("keydown",a,!0),window.removeEventListener("keyup",a,!0)}}}var Pv=ht(Bt(),1),Zv=["keydown","keyup","pointerdown","pointerup","mousedown","mouseup","click","dblclick","wheel"];function $v(t=new nr){if(document.getElementById("swarm-helper-root"))return t.dispose(),()=>{};let e=document.createElement("div");e.id="swarm-helper-root";let n=e.attachShadow({mode:"open"}),i=u=>u.stopPropagation();for(let u of Zv)e.addEventListener(u,i);let a=(0,Jv.createRoot)(n,{onUncaughtError:u=>{t.dispose(),console.error("[Swarm MMO \u52A9\u624B] \u9762\u677F\u6E32\u67D3\u5931\u8D25\uFF0C\u5DF2\u505C\u6B62\u672A\u53D1\u5C04\u64CD\u4F5C\u3002",u)}}),l=Vv(new ir(t.planetPlan)),s=!1,o=()=>{if(!s){s=!0,t.dispose(),l(),a.unmount(),window.removeEventListener("pagehide",o);for(let u of Zv)e.removeEventListener(u,i);e.remove()}};return window.addEventListener("pagehide",o,{once:!0}),document.body.append(e),a.render((0,Pv.jsx)(ov,{controller:t})),o}function jv(){/^\/play\/?$/.test(location.pathname)&&!document.getElementById("swarm-helper-root")&&$v()}window.addEventListener("pageshow",t=>{t.persisted&&jv()});jv();})();